Skip to content

Commit

Permalink
Improved PowerShell lexer (#700)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRoos committed Nov 11, 2022
1 parent 16fd666 commit 42e5421
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lexers/embedded/powershell.xml
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
@@ -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
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\"@"}
]

0 comments on commit 42e5421

Please sign in to comment.