@@ -37,44 +37,44 @@ def self.functions
3737 punctuations = %w( ( ) { } [ ] , : ; = . )
3838
3939 state :root do
40- mixin :comments
41-
42- # Match strings
43- rule %r/'/ , Str ::Single , :string
44-
45- # Match numbers
46- rule %r/\b \d +\b / , Num
47-
48- # Rules for sets of reserved keywords
49- rule %r/\b \w +\b / do |m |
50- if self . class . keywords . include? m [ 0 ]
51- token Keyword
52- elsif self . class . datatypes . include? m [ 0 ]
53- token Keyword ::Type
54- elsif self . class . functions . include? m [ 0 ]
55- token Name ::Function
56- else
57- token Name
58- end
40+ mixin :comments
41+
42+ # Match strings
43+ rule %r/'/ , Str ::Single , :string
44+
45+ # Match numbers
46+ rule %r/\b \d +\b / , Num
47+
48+ # Rules for sets of reserved keywords
49+ rule %r/\b \w +\b / do |m |
50+ if self . class . keywords . include? m [ 0 ]
51+ token Keyword
52+ elsif self . class . datatypes . include? m [ 0 ]
53+ token Keyword ::Type
54+ elsif self . class . functions . include? m [ 0 ]
55+ token Name ::Function
56+ else
57+ token Name
5958 end
59+ end
6060
61- # Match operators
62- rule %r/#{ operators . map { |o | Regexp . escape ( o ) } . join ( '|' ) } / , Operator
61+ # Match operators
62+ rule %r/#{ operators . map { |o | Regexp . escape ( o ) } . join ( '|' ) } / , Operator
6363
64- # Enter a state when encountering an opening curly bracket
65- rule %r/{/ , Punctuation ::Indicator , :block
64+ # Enter a state when encountering an opening curly bracket
65+ rule %r/{/ , Punctuation ::Indicator , :block
6666
67- # Match punctuation
68- rule %r/#{ punctuations . map { |p | Regexp . escape ( p ) } . join ( '|' ) } / , Punctuation
67+ # Match punctuation
68+ rule %r/#{ punctuations . map { |p | Regexp . escape ( p ) } . join ( '|' ) } / , Punctuation
6969
70- # Match identifiers
71- rule %r/[a-zA-Z_]\w */ , Name
70+ # Match identifiers
71+ rule %r/[a-zA-Z_]\w */ , Name
7272
73- # Match decorators
74- rule %r/@[a-zA-Z_]\w */ , Name ::Decorator
73+ # Match decorators
74+ rule %r/@[a-zA-Z_]\w */ , Name ::Decorator
7575
76- # Ignore whitespace
77- rule %r/\s +/ , Text
76+ # Ignore whitespace
77+ rule %r/\s +/ , Text
7878 end
7979
8080 state :comments do
@@ -89,7 +89,7 @@ def self.functions
8989 rule %r/\' / , Str ::Single , :pop!
9090 rule %r/\$ +/ , Str ::Single
9191 end
92-
92+
9393 state :interp do
9494 rule %r/\} / , Str ::Interpol , :pop!
9595 mixin :root
0 commit comments