Powershell lexer

All questions regarding lexer highlighting schemes are discussed here...
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

Operator -f and -c* -i* - fixed.
! and other symbols (comparision): IMO better hilite them as symbols, not like operators,
to not list all as regex (! > >= < <= etc).
Hilite switch options as operators: OK

Lexer update in 10min.
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

Lexer now lives in AddonManager, not in Cud distro.
ANewUser
Posts: 50
Joined: 25.01.2020 12:15

Post by ANewUser »

Thanks!
I will test it.
ANewUser
Posts: 50
Joined: 25.01.2020 12:15

Post by ANewUser »

The are missing built-in variables:

Code: Select all

$ErrorActionPreference
$ConfirmPreference
$WhatIfPreference
$DebugPreference
$ProgressPreference
$VerbosePreference
$WarningPreference
$InformationPreference

$MaximumAliasCount
$MaximumDriveCount
$MaximumErrorCount
$MaximumFunctionCount
$MaximumHistoryCount
$MaximumVariableCount

$ErrorView

$PSEmailServer
$PSModuleAutoLoadingPreference
$PSDefaultParameterValues
 
$PSSessionApplicationName
$PSSessionConfigurationName
$PSSessionOption
The are additional operators related to strings (I should have listed the operators with case-sensitivity), only the i* and c* variants are missing:

Code: Select all

-replace -ireplace -creplace
-split -isplit -csplit
-like -ilike -clike
-notlike -inotlike -cnotlike
-contains -icontains -ccontains
-notcontains -inotcontains -cnotcontains
-in -iin -cin
-notin -inotin -cnotin
-match -imatch -cmatch
-notmatch -inotmatch -cnotmatch
Some operators could be highlighted not as symbols:
related to calling and parameters: & -- --%
the ++ -- increment/decrement operators
static member access: :: (double colon)
assignment: += -= *= /= %=

https://i.imgur.com/i5VOcU1.png

Code: Select all

# highlight as variable the ${...} 
# the name is "a very ugly variable name in the braces {} ..."
${a very ugly variable name in the braces `{`} ...} = "12345"
# another weird name
${foreach and switch var} = "it is legal"

# highlight types as [type-name] or just the type-name
# types are in brackets
[switch] $w

# the switch statement is highlighted as type
switch ( )
{ }

# better keyword/statement detection ?
# there is no "-" before them
# begin/process/end {...} are script blocks
# function must be followed an "identifier {...}" part 
Some-Cmdlet -Process -Switch -Begin { }
Sort-Object -Property Function,Other
Thank you!
ANewUser
Posts: 50
Joined: 25.01.2020 12:15

Post by ANewUser »

Video about a small glitch, when the closing "@ characters are in the right position again, the comment does not be highlghted.
https://streamable.com/g4t22
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

Fixed most of issues
- "function" without Id name - still is keyword, it is ok to hilite all keywords in all places, even w/o next Id.
- here-strings @" ... "@ - do you type spaces after @" ? here strings cannot have space there -
https://powershell.org/2019/04/hear-hea ... e-strings/
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

glitch with editing of end - it exists, because editor parses text from start of changed line.
lexer updated.
ANewUser
Posts: 50
Joined: 25.01.2020 12:15

Post by ANewUser »

Thank you!
ANewUser
Posts: 50
Joined: 25.01.2020 12:15

Post by ANewUser »

Hello!
The "#Requires ..." statement is highlighted as comment not as statement or some other category.
https://docs.microsoft.com/en-us/powers ... wershell-7
Thanks
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

fixed this, used style Id3 for this. lexer updated. Pls test.
Post Reply