rouge 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/Gemfile +2 -0
  2. data/bin/rougify +1 -1
  3. data/lib/rouge/demos/{text → plaintext} +0 -0
  4. data/lib/rouge/formatters/html.rb +13 -8
  5. data/lib/rouge/formatters/terminal256.rb +15 -11
  6. data/lib/rouge/lexer.rb +3 -1
  7. data/lib/rouge/lexers/c.rb +65 -55
  8. data/lib/rouge/lexers/clojure.rb +19 -19
  9. data/lib/rouge/lexers/coffeescript.rb +42 -42
  10. data/lib/rouge/lexers/common_lisp.rb +49 -48
  11. data/lib/rouge/lexers/conf.rb +6 -6
  12. data/lib/rouge/lexers/cpp.rb +48 -48
  13. data/lib/rouge/lexers/csharp.rb +25 -25
  14. data/lib/rouge/lexers/css.rb +32 -33
  15. data/lib/rouge/lexers/diff.rb +8 -8
  16. data/lib/rouge/lexers/elixir.rb +30 -30
  17. data/lib/rouge/lexers/erb.rb +5 -5
  18. data/lib/rouge/lexers/erlang.rb +38 -38
  19. data/lib/rouge/lexers/factor.rb +56 -56
  20. data/lib/rouge/lexers/gherkin.rb +27 -27
  21. data/lib/rouge/lexers/go.rb +21 -21
  22. data/lib/rouge/lexers/groovy.rb +32 -32
  23. data/lib/rouge/lexers/haml.rb +35 -35
  24. data/lib/rouge/lexers/handlebars.rb +27 -27
  25. data/lib/rouge/lexers/haskell.rb +78 -79
  26. data/lib/rouge/lexers/html.rb +28 -28
  27. data/lib/rouge/lexers/http.rb +13 -13
  28. data/lib/rouge/lexers/ini.rb +13 -13
  29. data/lib/rouge/lexers/io.rb +19 -19
  30. data/lib/rouge/lexers/java.rb +29 -29
  31. data/lib/rouge/lexers/javascript.rb +49 -52
  32. data/lib/rouge/lexers/literate_haskell.rb +5 -5
  33. data/lib/rouge/lexers/llvm.rb +14 -14
  34. data/lib/rouge/lexers/lua.rb +33 -33
  35. data/lib/rouge/lexers/make.rb +26 -26
  36. data/lib/rouge/lexers/markdown.rb +49 -49
  37. data/lib/rouge/lexers/nginx.rb +19 -19
  38. data/lib/rouge/lexers/perl.rb +53 -54
  39. data/lib/rouge/lexers/php.rb +42 -43
  40. data/lib/rouge/lexers/{text.rb → plain_text.rb} +3 -2
  41. data/lib/rouge/lexers/prolog.rb +19 -19
  42. data/lib/rouge/lexers/puppet.rb +40 -40
  43. data/lib/rouge/lexers/python.rb +63 -63
  44. data/lib/rouge/lexers/r.rb +15 -15
  45. data/lib/rouge/lexers/racket.rb +29 -29
  46. data/lib/rouge/lexers/ruby.rb +94 -97
  47. data/lib/rouge/lexers/rust.rb +37 -37
  48. data/lib/rouge/lexers/sass.rb +15 -15
  49. data/lib/rouge/lexers/sass/common.rb +144 -136
  50. data/lib/rouge/lexers/scheme.rb +25 -25
  51. data/lib/rouge/lexers/scss.rb +7 -7
  52. data/lib/rouge/lexers/sed.rb +39 -39
  53. data/lib/rouge/lexers/shell.rb +45 -45
  54. data/lib/rouge/lexers/smalltalk.rb +36 -36
  55. data/lib/rouge/lexers/sql.rb +27 -27
  56. data/lib/rouge/lexers/tcl.rb +34 -34
  57. data/lib/rouge/lexers/tex.rb +24 -24
  58. data/lib/rouge/lexers/toml.rb +18 -18
  59. data/lib/rouge/lexers/viml.rb +19 -19
  60. data/lib/rouge/lexers/xml.rb +16 -16
  61. data/lib/rouge/lexers/yaml.rb +78 -81
  62. data/lib/rouge/plugins/redcarpet.rb +1 -1
  63. data/lib/rouge/regex_lexer.rb +31 -14
  64. data/lib/rouge/template_lexer.rb +1 -1
  65. data/lib/rouge/theme.rb +12 -10
  66. data/lib/rouge/themes/thankful_eyes.rb +43 -43
  67. data/lib/rouge/token.rb +145 -148
  68. data/lib/rouge/version.rb +1 -1
  69. metadata +4 -4
@@ -16,17 +16,17 @@ module Rouge
16
16
  end
17
17
 
18
18
  state :header do
19
- rule /^diff .*?\n(?=---|\+\+\+)/m, 'Generic.Heading'
20
- rule /^--- .*?\n/, 'Generic.Deleted'
21
- rule /^\+\+\+ .*?\n/, 'Generic.Inserted'
19
+ rule /^diff .*?\n(?=---|\+\+\+)/m, Generic::Heading
20
+ rule /^--- .*?\n/, Generic::Deleted
21
+ rule /^\+\+\+ .*?\n/, Generic::Inserted
22
22
  end
23
23
 
24
24
  state :diff do
25
- rule /@@ -\d+,\d+ \+\d+,\d+ @@.*?\n/, 'Generic.Heading'
26
- rule /^\+.*?\n/, 'Generic.Inserted'
27
- rule /^-.*?\n/, 'Generic.Deleted'
28
- rule /^ .*?\n/, 'Text'
29
- rule /^.*?\n/, 'Error'
25
+ rule /@@ -\d+,\d+ \+\d+,\d+ @@.*?\n/, Generic::Heading
26
+ rule /^\+.*?\n/, Generic::Inserted
27
+ rule /^-.*?\n/, Generic::Deleted
28
+ rule /^ .*?\n/, Text
29
+ rule /^.*?\n/, Error
30
30
  end
31
31
 
32
32
  state :root do
@@ -19,40 +19,40 @@ module Rouge
19
19
  ]
20
20
 
21
21
  state :root do
22
- rule /\s+/m, 'Text'
23
- rule /#.*$/, 'Comment.Single'
22
+ rule /\s+/m, Text
23
+ rule /#.*$/, Comment::Single
24
24
  rule %r{\b(case|cond|end|bc|lc|if|unless|try|loop|receive|fn|defmodule|
25
25
  defp?|defprotocol|defimpl|defrecord|defmacrop?|defdelegate|
26
26
  defexception|exit|raise|throw|unless|after|rescue|catch|else)\b(?![?!])|
27
- (?<!\.)\b(do|\-\>)\b}x, 'Keyword'
28
- rule /\b(import|require|use|recur|quote|unquote|super|refer)\b(?![?!])/, 'Keyword.Namespace'
29
- rule /(?<!\.)\b(and|not|or|when|xor|in)\b/, 'Operator.Word'
27
+ (?<!\.)\b(do|\-\>)\b}x, Keyword
28
+ rule /\b(import|require|use|recur|quote|unquote|super|refer)\b(?![?!])/, Keyword::Namespace
29
+ rule /(?<!\.)\b(and|not|or|when|xor|in)\b/, Operator::Word
30
30
  rule %r{%=|\*=|\*\*=|\+=|\-=|\^=|\|\|=|
31
31
  <=>|<(?!<|=)|>(?!<|=|>)|<=|>=|===|==|=~|!=|!~|(?=[\s\t])\?|
32
32
  (?<=[\s\t])!+|&&|\|\||\^|\*|\+|\-|/|
33
- \||\+\+|\-\-|\*\*|\/\/|\<\-|\<\>|<<|>>|=|\.}x, 'Operator'
33
+ \||\+\+|\-\-|\*\*|\/\/|\<\-|\<\>|<<|>>|=|\.}x, Operator
34
34
  rule %r{(?<!:)(:)([a-zA-Z_]\w*([?!]|=(?![>=]))?|\<\>|===?|>=?|<=?|
35
35
  <=>|&&?|%\(\)|%\[\]|%\{\}|\+\+?|\-\-?|\|\|?|\!|//|[%&`/\|]|
36
- \*\*?|=?~|<\-)|([a-zA-Z_]\w*([?!])?)(:)(?!:)}, 'Literal.String.Symbol'
37
- rule /:"/, 'Literal.String.Symbol', :interpoling_symbol
38
- rule /\b(nil|true|false)\b(?![?!])|\b[A-Z]\w*\b/, 'Name.Constant'
39
- rule /\b(__(FILE|LINE|MODULE|MAIN|FUNCTION)__)\b(?![?!])/, 'Name.Builtin.Pseudo'
40
- rule /[a-zA-Z_!][\w_]*[!\?]?/, 'Name'
41
- rule %r{::|[(){};,/\|:\\\[\]]}, 'Punctuation'
42
- rule /@[a-zA-Z_]\w*|&\d/, 'Name.Variable'
36
+ \*\*?|=?~|<\-)|([a-zA-Z_]\w*([?!])?)(:)(?!:)}, Str::Symbol
37
+ rule /:"/, Str::Symbol, :interpoling_symbol
38
+ rule /\b(nil|true|false)\b(?![?!])|\b[A-Z]\w*\b/, Name::Constant
39
+ rule /\b(__(FILE|LINE|MODULE|MAIN|FUNCTION)__)\b(?![?!])/, Name::Builtin::Pseudo
40
+ rule /[a-zA-Z_!][\w_]*[!\?]?/, Name
41
+ rule %r{::|[(){};,/\|:\\\[\]]}, Punctuation
42
+ rule /@[a-zA-Z_]\w*|&\d/, Name::Variable
43
43
  rule %r{\b(0[xX][0-9A-Fa-f]+|\d(_?\d)*(\.(?![^\d\s])
44
- (_?\d)*)?([eE][-+]?\d(_?\d)*)?|0[bB][01]+)\b}x, 'Literal.Number'
45
- rule %r{%r\/.*\/}, 'Literal.String.Regex'
44
+ (_?\d)*)?([eE][-+]?\d(_?\d)*)?|0[bB][01]+)\b}x, Num
45
+ rule %r{%r\/.*\/}, Str::Regex
46
46
 
47
47
  mixin :strings
48
48
  end
49
49
 
50
50
  state :strings do
51
- rule /(%[A-Ba-z])?"""(?:.|\n)*?"""/, 'Literal.String.Doc'
52
- rule /'''(?:.|\n)*?'''/, 'Literal.String.Doc'
53
- rule /"/, 'Literal.String.Doc', :dqs
54
- rule /'.*?'/, 'Literal.String.Single'
55
- rule %r{(?<!\w)\?(\\(x\d{1,2}|\h{1,2}(?!\h)\b|0[0-7]{0,2}(?![0-7])\b[^x0MC])|(\\[MC]-)+\w|[^\s\\])}, 'Literal.String.Other'
51
+ rule /(%[A-Ba-z])?"""(?:.|\n)*?"""/, Str::Doc
52
+ rule /'''(?:.|\n)*?'''/, Str::Doc
53
+ rule /"/, Str::Doc, :dqs
54
+ rule /'.*?'/, Str::Single
55
+ rule %r{(?<!\w)\?(\\(x\d{1,2}|\h{1,2}(?!\h)\b|0[0-7]{0,2}(?![0-7])\b[^x0MC])|(\\[MC]-)+\w|[^\s\\])}, Str::Other
56
56
 
57
57
  BRACES.each do |_, _, name|
58
58
  mixin :"braces_#{name}"
@@ -61,43 +61,43 @@ module Rouge
61
61
 
62
62
  BRACES.each do |lbrace, rbrace, name|
63
63
  state :"braces_#{name}" do
64
- rule /%[a-z]#{lbrace}/, 'Literal.String.Double', :"braces_#{name}_intp"
65
- rule /%[A-Z]#{lbrace}/, 'Literal.String.Double', :"braces_#{name}_no_intp"
64
+ rule /%[a-z]#{lbrace}/, Str::Double, :"braces_#{name}_intp"
65
+ rule /%[A-Z]#{lbrace}/, Str::Double, :"braces_#{name}_no_intp"
66
66
  end
67
67
 
68
68
  state :"braces_#{name}_intp" do
69
- rule /#{rbrace}[a-z]*/, 'Literal.String.Double', :pop!
69
+ rule /#{rbrace}[a-z]*/, Str::Double, :pop!
70
70
  mixin :enddoublestr
71
71
  end
72
72
 
73
73
  state :"braces_#{name}_no_intp" do
74
- rule /.*#{rbrace}[a-z]*/, 'Literal.String.Double', :pop!
74
+ rule /.*#{rbrace}[a-z]*/, Str::Double, :pop!
75
75
  end
76
76
  end
77
77
 
78
78
  state :dqs do
79
- rule /"/, 'Literal.String.Double', :pop!
79
+ rule /"/, Str::Double, :pop!
80
80
  mixin :enddoublestr
81
81
  end
82
82
 
83
83
  state :interpoling do
84
- rule /#\{/, 'Literal.String.Interpol', :interpoling_string
84
+ rule /#\{/, Str::Interpol, :interpoling_string
85
85
  end
86
86
 
87
87
  state :interpoling_string do
88
- rule /\}/, 'Literal.String.Interpol', :pop!
88
+ rule /\}/, Str::Interpol, :pop!
89
89
  mixin :root
90
90
  end
91
91
 
92
92
  state :interpoling_symbol do
93
- rule /"/, 'Literal.String.Symbol', :pop!
93
+ rule /"/, Str::Symbol, :pop!
94
94
  mixin :interpoling
95
- rule /[^#"]+/, 'Literal.String.Symbol'
95
+ rule /[^#"]+/, Str::Symbol
96
96
  end
97
97
 
98
98
  state :enddoublestr do
99
99
  mixin :interpoling
100
- rule /[^#"]+/, 'Literal.String.Double'
100
+ rule /[^#"]+/, Str::Double
101
101
  end
102
102
  end
103
103
  end
@@ -27,9 +27,9 @@ module Rouge
27
27
  close = /%%>|-%>|%>/
28
28
 
29
29
  state :root do
30
- rule /<%#/, 'Comment', :comment
30
+ rule /<%#/, Comment, :comment
31
31
 
32
- rule open, 'Comment.Preproc', :ruby
32
+ rule open, Comment::Preproc, :ruby
33
33
 
34
34
  rule /.+?(?=#{open})|.+/m do
35
35
  delegate parent
@@ -37,12 +37,12 @@ module Rouge
37
37
  end
38
38
 
39
39
  state :comment do
40
- rule close, 'Comment', :pop!
41
- rule /.+(?=#{close})|.+/m, 'Comment'
40
+ rule close, Comment, :pop!
41
+ rule /.+(?=#{close})|.+/m, Comment
42
42
  end
43
43
 
44
44
  state :ruby do
45
- rule close, 'Comment.Preproc', :pop!
45
+ rule close, Comment::Preproc, :pop!
46
46
 
47
47
  rule /.+?(?=#{close})|.+/m do
48
48
  delegate @ruby_lexer
@@ -64,60 +64,60 @@ module Rouge
64
64
  base_re = %r{(?:[2-9]|[12][0-9]|3[0-6])}
65
65
 
66
66
  state :root do
67
- rule(/\s+/, "Text")
68
- rule(/%.*\n/, "Comment")
69
- rule(%r{(#{keywords.join('|')})\b}, "Keyword")
70
- rule(%r{(#{builtins.join('|')})\b}, "Name.Builtin")
71
- rule(%r{(#{word_operators.join('|')})\b}, "Operator.Word")
72
- rule(/^-/, "Punctuation", :directive)
73
- rule(operators, "Operator")
74
- rule(/"/, "Literal.String", :string)
75
- rule(/<</, "Name.Label")
76
- rule(/>>/, "Name.Label")
67
+ rule(/\s+/, Text)
68
+ rule(/%.*\n/, Comment)
69
+ rule(%r{(#{keywords.join('|')})\b}, Keyword)
70
+ rule(%r{(#{builtins.join('|')})\b}, Name::Builtin)
71
+ rule(%r{(#{word_operators.join('|')})\b}, Operator::Word)
72
+ rule(/^-/, Punctuation, :directive)
73
+ rule(operators, Operator)
74
+ rule(/"/, Str, :string)
75
+ rule(/<</, Name::Label)
76
+ rule(/>>/, Name::Label)
77
77
  rule %r{(#{atom_re})(:)} do
78
- group "Name.Namespace"
79
- group "Punctuation"
78
+ group Name::Namespace
79
+ group Punctuation
80
80
  end
81
81
  rule %r{(?:^|(?<=:))(#{atom_re})(\s*)(\()} do
82
- group "Name.Function"
83
- group "Text"
84
- group "Punctuation"
82
+ group Name::Function
83
+ group Text
84
+ group Punctuation
85
85
  end
86
- rule(%r{[+-]?#{base_re}#[0-9a-zA-Z]+}, "Literal.Number.Integer")
87
- rule(/[+-]?\d+/, "Literal.Number.Integer")
88
- rule(/[+-]?\d+.\d+/, "Literal.Number.Float")
89
- rule(%r{[\]\[:_@\".{}()|;,]}, "Punctuation")
90
- rule(variable_re, "Name.Variable")
91
- rule(atom_re, "Name")
92
- rule(%r{\?#{macro_re}}, "Name.Constant")
93
- rule(%r{\$(?:#{escape_re}|\\[ %]|[^\\])}, "Literal.String.Char")
94
- rule(%r{##{atom_re}(:?\.#{atom_re})?}, "Name.Label")
86
+ rule(%r{[+-]?#{base_re}#[0-9a-zA-Z]+}, Num::Integer)
87
+ rule(/[+-]?\d+/, Num::Integer)
88
+ rule(/[+-]?\d+.\d+/, Num::Float)
89
+ rule(%r{[\]\[:_@\".{}()|;,]}, Punctuation)
90
+ rule(variable_re, Name::Variable)
91
+ rule(atom_re, Name)
92
+ rule(%r{\?#{macro_re}}, Name::Constant)
93
+ rule(%r{\$(?:#{escape_re}|\\[ %]|[^\\])}, Str::Char)
94
+ rule(%r{##{atom_re}(:?\.#{atom_re})?}, Name::Label)
95
95
  end
96
96
 
97
97
  state :string do
98
- rule(escape_re, "Literal.String.Escape")
99
- rule(/"/, "Literal.String", :pop!)
100
- rule(%r{~[0-9.*]*[~#+bBcdefginpPswWxX]}, "Literal.String.Interpol")
101
- rule(%r{[^"\\~]+}, "Literal.String")
102
- rule(/~/, "Literal.String")
98
+ rule(escape_re, Str::Escape)
99
+ rule(/"/, Str, :pop!)
100
+ rule(%r{~[0-9.*]*[~#+bBcdefginpPswWxX]}, Str::Interpol)
101
+ rule(%r{[^"\\~]+}, Str)
102
+ rule(/~/, Str)
103
103
  end
104
104
 
105
105
  state :directive do
106
106
  rule %r{(define)(\s*)(\()(#{macro_re})} do
107
- group "Name.Entity"
108
- group "Text"
109
- group "Punctuation"
110
- group "Name.Constant"
107
+ group Name::Entity
108
+ group Text
109
+ group Punctuation
110
+ group Name::Constant
111
111
  pop!
112
112
  end
113
113
  rule %r{(record)(\s*)(\()(#{macro_re})} do
114
- group "Name.Entity"
115
- group "Text"
116
- group "Punctuation"
117
- group "Name.Label"
114
+ group Name::Entity
115
+ group Text
116
+ group Punctuation
117
+ group Name::Label
118
118
  pop!
119
119
  end
120
- rule(atom_re, "Name.Entity", :pop!)
120
+ rule(atom_re, Name::Entity, :pop!)
121
121
  end
122
122
  end
123
123
  end
@@ -163,135 +163,135 @@ module Rouge
163
163
  end
164
164
 
165
165
  state :root do
166
- rule /\s+/m, 'Text'
166
+ rule /\s+/m, Text
167
167
 
168
168
  rule /(:|::|MACRO:|MEMO:|GENERIC:|HELP:)(\s+)(\S+)/m do
169
- group 'Keyword'; group 'Text'
170
- group 'Name.Function'
169
+ group Keyword; group Text
170
+ group Name::Function
171
171
  end
172
172
 
173
173
  rule /(M:|HOOK:|GENERIC#)(\s+)(\S+)(\s+)(\S+)/m do
174
- group 'Keyword'; group 'Text'
175
- group 'Name.Class'; group 'Text'
176
- group 'Name.Function'
174
+ group Keyword; group Text
175
+ group Name::Class; group Text
176
+ group Name::Function
177
177
  end
178
178
 
179
- rule /\((?=\s)/, 'Name.Function', :stack_effect
180
- rule /;(?=\s)/, 'Keyword'
179
+ rule /\((?=\s)/, Name::Function, :stack_effect
180
+ rule /;(?=\s)/, Keyword
181
181
 
182
182
  rule /(USING:)((?:\s|\\\s)+)/m do
183
- group 'Keyword.Namespace'; group 'Text'
183
+ group Keyword::Namespace; group Text
184
184
  push :import
185
185
  end
186
186
 
187
187
  rule /(IN:|USE:|UNUSE:|QUALIFIED:|QUALIFIED-WITH:)(\s+)(\S+)/m do
188
- group 'Keyword.Namespace'; group 'Text'; group 'Name.Namespace'
188
+ group Keyword::Namespace; group Text; group Name::Namespace
189
189
  end
190
190
 
191
191
  rule /(FROM:|EXCLUDE:)(\s+)(\S+)(\s+)(=>)/m do
192
- group 'Keyword.Namespace'; group 'Text'
193
- group 'Name.Namespace'; group 'Text'
194
- group 'Punctuation'
192
+ group Keyword::Namespace; group Text
193
+ group Name::Namespace; group Text
194
+ group Punctuation
195
195
  end
196
196
 
197
- rule /(?:ALIAS|DEFER|FORGET|POSTPONE):/, 'Keyword.Namespace'
197
+ rule /(?:ALIAS|DEFER|FORGET|POSTPONE):/, Keyword::Namespace
198
198
 
199
199
  rule /(TUPLE:)(\s+)(\S+)(\s+)(<)(\s+)(\S+)/m do
200
- group 'Keyword'; group 'Text'
201
- group 'Name.Class'; group 'Text'
202
- group 'Punctuation'; group 'Text'
203
- group 'Name.Class'
200
+ group Keyword; group Text
201
+ group Name::Class; group Text
202
+ group Punctuation; group Text
203
+ group Name::Class
204
204
  push :slots
205
205
  end
206
206
 
207
207
  rule /(TUPLE:)(\s+)(\S+)/m do
208
- group 'Keyword'; group 'Text'; group 'Name.Class'
208
+ group Keyword; group Text; group Name::Class
209
209
  push :slots
210
210
  end
211
211
 
212
212
  rule /(UNION:|INTERSECTION:)(\s+)(\S+)/m do
213
- group 'Keyword'; group 'Text'; group 'Name.Class'
213
+ group Keyword; group Text; group Name::Class
214
214
  end
215
215
 
216
216
  rule /(PREDICATE:)(\s+)(\S+)(\s+)(<)(\s+)(\S+)/m do
217
- group 'Keyword'; group 'Text'
218
- group 'Name.Class'; group 'Text'
219
- group 'Punctuation'; group 'Text'
220
- group 'Name.Class'
217
+ group Keyword; group Text
218
+ group Name::Class; group Text
219
+ group Punctuation; group Text
220
+ group Name::Class
221
221
  end
222
222
 
223
223
  rule /(C:)(\s+)(\S+)(\s+)(\S+)/m do
224
- group 'Keyword'; group 'Text'
225
- group 'Name.Function'; group 'Text'
226
- group 'Name.Class'
224
+ group Keyword; group Text
225
+ group Name::Function; group Text
226
+ group Name::Class
227
227
  end
228
228
 
229
229
  rule %r(
230
230
  (INSTANCE|SLOT|MIXIN|SINGLETONS?|CONSTANT|SYMBOLS?|ERROR|SYNTAX
231
231
  |ALIEN|TYPEDEF|FUNCTION|STRUCT):
232
- )x, 'Keyword'
232
+ )x, Keyword
233
233
 
234
- rule /(?:<PRIVATE|PRIVATE>)/, 'Keyword.Namespace'
234
+ rule /(?:<PRIVATE|PRIVATE>)/, Keyword::Namespace
235
235
 
236
236
  rule /(MAIN:)(\s+)(\S+)/ do
237
- group 'Keyword.Namespace'; group 'Text'; group 'Name.Function'
237
+ group Keyword::Namespace; group Text; group Name::Function
238
238
  end
239
239
 
240
240
  # strings
241
- rule /"""\s+.*?\s+"""/, 'Literal.String'
242
- rule /"(\\.|[^\\])*?"/, 'Literal.String'
243
- rule /(CHAR:)(\s+)(\\[\\abfnrstv]*|\S)(?=\s)/, 'Literal.String.Char'
241
+ rule /"""\s+.*?\s+"""/, Str
242
+ rule /"(\\.|[^\\])*?"/, Str
243
+ rule /(CHAR:)(\s+)(\\[\\abfnrstv]*|\S)(?=\s)/, Str::Char
244
244
 
245
245
  # comments
246
- rule /!\s+.*$/, 'Comment'
247
- rule /#!\s+.*$/, 'Comment'
246
+ rule /!\s+.*$/, Comment
247
+ rule /#!\s+.*$/, Comment
248
248
 
249
249
  # booleans
250
- rule /[tf](?=\s)/, 'Name.Constant'
250
+ rule /[tf](?=\s)/, Name::Constant
251
251
 
252
252
  # numbers
253
- rule /-?\d+\.\d+(?=\s)/, 'Literal.Number.Float'
254
- rule /-?\d+(?=\s)/, 'Literal.Number.Integer'
253
+ rule /-?\d+\.\d+(?=\s)/, Num::Float
254
+ rule /-?\d+(?=\s)/, Num::Integer
255
255
 
256
- rule /HEX:\s+[a-fA-F\d]+(?=\s)/m, 'Literal.Number.Hex'
257
- rule /BIN:\s+[01]+(?=\s)/, 'Literal.Number.Bin'
258
- rule /OCT:\s+[0-7]+(?=\s)/, 'Literal.Number.Oct'
256
+ rule /HEX:\s+[a-fA-F\d]+(?=\s)/m, Num::Hex
257
+ rule /BIN:\s+[01]+(?=\s)/, Num::Bin
258
+ rule /OCT:\s+[0-7]+(?=\s)/, Num::Oct
259
259
 
260
- rule %r([-+/*=<>^](?=\s)), 'Operator'
260
+ rule %r([-+/*=<>^](?=\s)), Operator
261
261
 
262
262
  rule /(?:deprecated|final|foldable|flushable|inline|recursive)(?=\s)/,
263
- 'Keyword'
263
+ Keyword
264
264
 
265
265
  rule /\S+/ do |m|
266
266
  name = m[0]
267
267
 
268
268
  if self.class.builtins.values.any? { |b| b.include? name }
269
- token 'Name.Builtin'
269
+ token Name::Builtin
270
270
  else
271
- token 'Name'
271
+ token Name
272
272
  end
273
273
  end
274
274
  end
275
275
 
276
276
  state :stack_effect do
277
- rule /\s+/, 'Text'
278
- rule /\(/, 'Name.Function', :stack_effect
279
- rule /\)/, 'Name.Function', :pop!
277
+ rule /\s+/, Text
278
+ rule /\(/, Name::Function, :stack_effect
279
+ rule /\)/, Name::Function, :pop!
280
280
 
281
- rule /--/, 'Name.Function'
282
- rule /\S+/, 'Name.Variable'
281
+ rule /--/, Name::Function
282
+ rule /\S+/, Name::Variable
283
283
  end
284
284
 
285
285
  state :slots do
286
- rule /\s+/, 'Text'
287
- rule /;(?=\s)/, 'Keyword', :pop!
288
- rule /\S+/, 'Name.Variable'
286
+ rule /\s+/, Text
287
+ rule /;(?=\s)/, Keyword, :pop!
288
+ rule /\S+/, Name::Variable
289
289
  end
290
290
 
291
291
  state :import do
292
- rule /;(?=\s)/, 'Keyword', :pop!
293
- rule /\s+/, 'Text'
294
- rule /\S+/, 'Name.Namespace'
292
+ rule /;(?=\s)/, Keyword, :pop!
293
+ rule /\s+/, Text
294
+ rule /\S+/, Name::Namespace
295
295
  end
296
296
  end
297
297
  end