Update the regex for the PowerShell parser (#33) · CommunityToolkit/ColorCode-Universal@7c21251 (original) (raw)

`@@ -78,11 +78,17 @@ public IList Rules

`

78

78

`{0, ScopeName.PowerShellVariable}

`

79

79

`}),

`

80

80

`new LanguageRule(

`

81

``

`-

@"\b(begin|break|catch|continue|data|do|dynamicparam|elseif|else|end|exit|filter|finally|foreach|for|from|function|if|in|param|process|return|switch|throw|trap|try|until|while)\b",

`

``

81

`+

@"(?i)\b(begin|break|catch|continue|data|do|dynamicparam|elseif|else|end|exit|filter|finally|foreach|for|from|function|if|in|param|process|return|switch|throw|trap|try|until|while)\b",

`

82

82

`new Dictionary<int, string>

`

83

83

`{

`

84

84

`{1, ScopeName.Keyword}

`

85

85

`}),

`

``

86

`+

new LanguageRule(

`

``

87

`+

@"\b(\w+-\w+)\b",

`

``

88

`+

new Dictionary<int, string>

`

``

89

`+

{

`

``

90

`+

{1, ScopeName.PowerShellCommand}

`

``

91

`+

}),

`

86

92

`new LanguageRule(

`

87

93

`@"-(?:c|i)?(?:eq|ne|gt|ge|lt|le|notlike|like|notmatch|match|notcontains|contains|replace)",

`

88

94

`new Dictionary<int, string>

`

`@@ -98,7 +104,14 @@ public IList Rules

`

98

104

`}

`

99

105

`),

`

100

106

`new LanguageRule(

`

101

``

`-

@"(?:+=|-=|*=|/=|%=|=|++|--|+|-|*|/|%)",

`

``

107

`+

@"-\w+\d\w",

`

``

108

`+

new Dictionary<int, string>

`

``

109

`+

{

`

``

110

`+

{0, ScopeName.PowerShellParameter}

`

``

111

`+

}

`

``

112

`+

),

`

``

113

`+

new LanguageRule(

`

``

114

`+

@"(?:+=|-=|*=|/=|%=|=|++|--|+|-|*|/|%|||,)",

`

102

115

`new Dictionary<int, string>

`

103

116

`{

`

104

117

`{0, ScopeName.PowerShellOperator}

`

`@@ -112,7 +125,7 @@ public IList Rules

`

112

125

`}

`

113

126

`),

`

114

127

`new LanguageRule(

`

115

``

`-

@"(?s)[(CmdletBinding)[^]]+]",

`

``

128

`+

@"(?is)[(cmdletbinding|alias|outputtype|parameter|validatenotnull|validatenotnullorempty|validatecount|validateset|allownull|allowemptycollection|allowemptystring|validatescript|validaterange|validatepattern|validatelength|supportswildcards)[^]]+]",

`

116

129

`new Dictionary<int, string>

`

117

130

`{

`

118

131

`{1, ScopeName.PowerShellAttribute}

`

`@@ -136,6 +149,7 @@ public bool HasAlias(string lang)

`

136

149

`{

`

137

150

`case "posh":

`

138

151

`case "ps1":

`

``

152

`+

case "pwsh":

`

139

153

`return true;

`

140

154

``

141

155

`default:

`