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

Improved PowerShell lexer #700

Merged
merged 2 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions lexers/embedded/powershell.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
<token type="Punctuation"/>
<push state="child"/>
</rule>
<rule pattern="(\$)((global|script|private|env):)?\w+">
<token type="NameVariable"/>
</rule>
<rule pattern="&#34;&#34;">
<token type="LiteralStringDouble"/>
</rule>
Expand All @@ -139,6 +142,9 @@
<token type="Punctuation"/>
<push state="child"/>
</rule>
<rule pattern="(\$)((global|script|private|env):)?\w+">
<token type="NameVariable"/>
</rule>
<rule pattern="[^@\n]+&#34;]">
<token type="LiteralStringHeredoc"/>
</rule>
Expand Down
4 changes: 4 additions & 0 deletions lexers/testdata/powershell.actual
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
Get-ChildItem -Recurse -Force -ErrorAction SilentlyContinue -Name -Path C:\ *.txt
$x = "Here is a $var inside a string"
$x = @"
Here is a $var inside a here-string
"@
17 changes: 16 additions & 1 deletion lexers/testdata/powershell.expected
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,20 @@
{"type":"Text","value":" "},
{"type":"Punctuation","value":"*."},
{"type":"Name","value":"txt"},
{"type":"Text","value":"\n"}
{"type":"Text","value":"\n"},
{"type":"NameVariable","value":"$x"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"="},
{"type":"Text","value":" "},
{"type":"LiteralStringDouble","value":"\"Here is a "},
{"type":"NameVariable","value":"$var"},
{"type":"LiteralStringDouble","value":" inside a string\""},
{"type":"Text","value":"\n"},
{"type":"NameVariable","value":"$x"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"="},
{"type":"Text","value":" "},
{"type":"LiteralStringHeredoc","value":"@\"\nHere is a "},
{"type":"NameVariable","value":"$var"},
{"type":"LiteralStringHeredoc","value":" inside a here-string\n\"@"}
]