lib/rouge/lexers/powershell.rb in rouge-3.24.0 vs lib/rouge/lexers/powershell.rb in rouge-3.25.0
- old
+ new
@@ -129,38 +129,54 @@
rule %r/\s+/, Text::Whitespace
rule %r/\w+/, Name::Class
rule %r/[:,]/, Punctuation
end
- state :hasht do
- rule %r/\s+/, Text::Whitespace
- rule %r/\}/, Punctuation, :pop!
+ state :expr do
+ mixin :comments
rule %r/"/, Str::Double, :dq
rule %r/'/, Str::Single, :sq
- rule %r/\w+/, Name::Other
+ rule %r/@"/, Str::Heredoc, :heredoc
+ rule %r/@'.*?'@/m, Str::Heredoc
+ rule %r/\d*\.\d+/, Num::Float
+ rule %r/\d+/, Num::Integer
+ rule %r/@\{/, Punctuation, :hasht
+ rule %r/@\(/, Punctuation, :array
+ rule %r/{/, Punctuation, :brace
+ rule %r/\[/, Punctuation, :bracket
+ end
+
+ state :hasht do
+ rule %r/\}/, Punctuation, :pop!
rule %r/=/, Operator
- rule %r/,/, Punctuation
+ rule %r/[,;]/, Punctuation
+ mixin :expr
+ rule %r/\w+/, Name::Other
mixin :variable
end
state :array do
rule %r/\s+/, Text::Whitespace
rule %r/\)/, Punctuation, :pop!
- rule %r/"/, Str::Double, :dq
- rule %r/'/, Str::Single, :sq
- rule %r/,/, Punctuation
+ rule %r/[,;]/, Punctuation
+ mixin :expr
mixin :variable
end
+ state :brace do
+ rule %r/[}]/, Punctuation, :pop!
+ mixin :root
+ end
+
state :bracket do
rule %r/\]/, Punctuation, :pop!
- rule %r/[A-Za-z]\w+\./, Name::Constant
+ rule %r/[A-Za-z]\w+\./, Name
rule %r/([A-Za-z]\w+)/ do |m|
if ATTRIBUTES.include? m[0]
token Name::Builtin::Pseudo
else
- token Keyword::Type
+ token Name
end
end
mixin :root
end
@@ -172,25 +188,20 @@
rule %r/[\/\\~\w][-.:\/\\~\w]*/, Name::Other
rule %r/\w[-\w]+/, Name::Other
mixin :root
end
- state :root do
+ state :comments do
rule %r/\s+/, Text::Whitespace
-
- rule %r/#requires\s-version \d(?:\.\d+)?/, Comment::Preproc
rule %r/#.*/, Comment
rule %r/<#/, Comment::Multiline, :multiline
+ end
- rule %r/"/, Str::Double, :dq
- rule %r/'/, Str::Single, :sq
- rule %r/@"/, Str::Heredoc, :heredoc
- rule %r/@'.*?'@/m, Str::Heredoc
+ state :root do
+ mixin :comments
+ rule %r/#requires\s-version \d(?:\.\d+)?/, Comment::Preproc
- rule %r/\d*\.\d+/, Num::Float
- rule %r/\d+/, Num::Integer
-
rule %r/\.\.(?=\.?\d)/, Operator
rule %r/(?:#{OPERATORS})\b/i, Operator
rule %r/(class)(\s+)(\w+)/i do
groups Keyword::Reserved, Text::Whitespace, Name::Class
@@ -202,31 +213,30 @@
rule %r/(?:#{KEYWORDS})\b(?![-.])/i, Keyword::Reserved
rule %r/-{1,2}\w+/, Name::Tag
rule %r/(\.)?([-\w]+)(\[)/ do |m|
- groups Operator, Name::Function, Punctuation
+ groups Operator, Name, Punctuation
push :bracket
end
- rule %r/([\/\\~\w][-.:\/\\~\w]*)(\n)?/ do |m|
- groups Name::Function, Text::Whitespace
+ rule %r/([\/\\~[a-z]][-.:\/\\~\w]*)(\n)?/i do |m|
+ groups Name, Text::Whitespace
push :parameters
end
- rule %r/(\.)?([-\w]+)(?:(\()|(\n))?/ do |m|
+ rule %r/(\.)([-\w]+)(?:(\()|(\n))?/ do |m|
groups Operator, Name::Function, Punctuation, Text::Whitespace
push :parameters unless m[3].nil?
end
rule %r/\?/, Name::Function, :parameters
- rule %r/[-+*\/%=!.&|]/, Operator
- rule %r/@\{/, Punctuation, :hasht
- rule %r/@\(/, Punctuation, :array
- rule %r/\[/, Punctuation, :bracket
- rule %r/[{}(),:;]/, Punctuation
+ mixin :expr
mixin :variable
+
+ rule %r/[-+*\/%=!.&|]/, Operator
+ rule %r/[{}(),:;]/, Punctuation
end
end
end
end