Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add PowerShell support. #1543

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: Add PowerShell support.
Updates #460
  • Loading branch information
ianlewis committed Aug 23, 2024
commit 96bc62308bf5a070d1ec61787d9d080c5afa9828
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

3 changes: 2 additions & 1 deletion SUPPORTED_LANGUAGES.md
Original file line number Diff line number Diff line change
@@ -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` | `#` |
18 changes: 7 additions & 11 deletions internal/scanner/languages.go
Original file line number Diff line number Diff line change
@@ -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
Loading