diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e5be96..dc6d734 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Support was added for - [MATLAB](https://www.mathworks.com/products/matlab.html) and + [MATLAB](https://www.mathworks.com/products/matlab.html) +- Support was added for [Vim Script](https://vimdoc.sourceforge.net/htmldoc/usr_41.html). +- Support was added for + [Powershell](https://learn.microsoft.com/en-us/powershell/). ## [0.9.0] - 2024-08-08 diff --git a/SUPPORTED_LANGUAGES.md b/SUPPORTED_LANGUAGES.md index 8e8584e..23be10f 100644 --- a/SUPPORTED_LANGUAGES.md +++ b/SUPPORTED_LANGUAGES.md @@ -1,6 +1,6 @@ # Supported Languages -44 languages are currently supported. +45 languages are currently supported. | File type | Extension | Supported comments | | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | @@ -30,6 +30,7 @@ | Objective-C | `.m`, `.h` | `//`, `/* */` | | PHP | `.php`, `.aw`, `.ctp`, `.fcgi`, `.inc`, `.php3`, `.php4`, `.php5`, `.phps`, `.phpt` | `#`, `//`, `/* */` | | Perl | `.pl`, `.al`, `.cgi`, `.fcgi`, `.perl`, `.ph`, `.plx`, `.pm`, `.psgi`, `.t` | `#`, `= =cut` | +| PowerShell | `.ps1`, `.psd1`, `.psm1` | `#`, `<# #>` | | Puppet | `.pp` | `#` | | Python | `.py`, `.cgi`, `.fcgi`, `.gyp`, `.gypi`, `.lmi`, `.py3`, `.pyde`, `.pyi`, `.pyp`, `.pyt`, `.pyw`, `.rpy`, `.spec`, `.tac`, `.wsgi`, `.xpy` | `#`, `""" """` | | R | `.r`, `.rd`, `.rsx` | `#` | diff --git a/internal/scanner/languages.go b/internal/scanner/languages.go index e716f1e..58ace59 100644 --- a/internal/scanner/languages.go +++ b/internal/scanner/languages.go @@ -32,10 +32,12 @@ type MultilineCommentConfig struct { } var ( - // BackslashEscape indicates characters can be escaped by a backslash. - BackslashEscape = "backslash" - // NoEscape indicates characters cannot be escaped. + // CharEscape indicates the following character is the escape character. + CharEscape = "character" + + // NoEscape indicates characters cannot be escaped. This is the default. NoEscape = "none" + // DoubleEscape indicates that strings can be escaped with double characters. DoubleEscape = "double" ) @@ -56,18 +58,12 @@ type Config struct { type escapeFunc func(s *CommentScanner, st *stateString) ([]rune, error) -var escapeFuncs = map[string]escapeFunc{ - BackslashEscape: backslashEscape, - NoEscape: noEscape, - DoubleEscape: doubleEscape, -} - func noEscape(_ *CommentScanner, _ *stateString) ([]rune, error) { return nil, nil } -func backslashEscape(s *CommentScanner, st *stateString) ([]rune, error) { - b := append([]rune{'\\'}, s.config.Strings[st.index].End...) +func charEscape(c rune, s *CommentScanner, st *stateString) ([]rune, error) { + b := append([]rune{c}, s.config.Strings[st.index].End...) eq, err := s.peekEqual(b) if err != nil { return nil, err diff --git a/internal/scanner/languages.yml b/internal/scanner/languages.yml index 2ae6a09..90d1c41 100644 --- a/internal/scanner/languages.yml +++ b/internal/scanner/languages.yml @@ -33,10 +33,10 @@ C: strings: - start: '"' end: '"' - escape: backslash + escape: character \ - start: "'" end: "'" - escape: backslash + escape: character \ C++: line_comment_start: ["//"] multiline_comment: @@ -45,10 +45,10 @@ C++: strings: - start: '"' end: '"' - escape: backslash + escape: character \ - start: "'" end: "'" - escape: backslash + escape: character \ C#: line_comment_start: ["//"] multiline_comment: @@ -57,16 +57,16 @@ C#: strings: - start: '"' end: '"' - escape: backslash + escape: character \ - start: "'" end: "'" - escape: backslash + escape: character \ Clojure: line_comment_start: [";"] strings: - start: '"' end: '"' - escape: backslash + escape: character \ CoffeeScript: line_comment_start: ["#"] multiline_comment: @@ -75,34 +75,34 @@ CoffeeScript: strings: - start: '"' end: '"' - escape: backslash + escape: character \ - start: "'" end: "'" - escape: backslash + escape: character \ Dockerfile: line_comment_start: ["#"] strings: - start: '"' end: '"' - escape: backslash + escape: character \ - start: "'" end: "'" - escape: backslash + escape: character \ Emacs Lisp: line_comment_start: [";"] strings: - start: '"' end: '"' - escape: backslash + escape: character \ Erlang: line_comment_start: ["%"] strings: - start: '"' end: '"' - escape: backslash + escape: character \ - start: "'" end: "'" - escape: backslash + escape: character \ Fortran: line_comment_start: ["!"] strings: @@ -129,11 +129,11 @@ Go: strings: - start: '"' end: '"' - escape: backslash + escape: character \ # Rune - start: "'" end: "'" - escape: backslash + escape: character \ # Raw strings - start: "`" end: "`" @@ -145,7 +145,7 @@ Go Module: strings: - start: '"' end: '"' - escape: backslash + escape: character \ # Raw strings - start: "`" end: "`" @@ -158,13 +158,13 @@ Groovy: strings: - start: '"' end: '"' - escape: backslash + escape: character \ - start: "'" end: "'" - escape: backslash + escape: character \ - start: "'''" end: "'''" - escape: backslash + escape: character \ Haskell: line_comment_start: ["--"] multiline_comment: @@ -173,10 +173,10 @@ Haskell: strings: - start: '"' end: '"' - escape: backslash + escape: character \ - start: "'" end: "'" - escape: backslash + escape: character \ HTML: multiline_comment: start: "