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
@@ -21,33 +21,33 @@ module Rouge
21
21
  end
22
22
 
23
23
  state :root do
24
- rule /#.*?\n/, 'Comment.Single'
25
- rule /\s+/m, 'Text'
24
+ rule /#.*?\n/, Comment::Single
25
+ rule /\s+/m, Text
26
26
  rule /[.]?[a-zA-Z_][\w.]*/ do |m|
27
27
  if self.class.keywords.include? m[0]
28
- token 'Keyword'
28
+ token Keyword
29
29
  else
30
- token 'Name'
30
+ token Name
31
31
  end
32
32
  end
33
33
 
34
- rule /`.*?`/, 'Literal.String.Backtick'
35
- rule /'(\\.|.)*?'/m, 'Literal.String.Single'
36
- rule /"(\\.|.)*?"/m, 'Literal.String.Double'
34
+ rule /`.*?`/, Str::Backtick
35
+ rule /'(\\.|.)*?'/m, Str::Single
36
+ rule /"(\\.|.)*?"/m, Str::Double
37
37
 
38
- rule /\b(NULL|Inf|TRUE|FALSE|NaN)\b/, 'Keyword.Constant'
38
+ rule /\b(NULL|Inf|TRUE|FALSE|NaN)\b/, Keyword::Constant
39
39
  rule /\bNA(_(integer|real|complex|character)_)?\b/,
40
- 'Keyword.Constant'
41
- rule /\b[TF]\b/, 'Keyword.Variable'
40
+ Keyword::Constant
41
+ rule /\b[TF]\b/, Keyword::Variable
42
42
 
43
- rule /0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?/, 'Literal.Number.Hex'
43
+ rule /0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?/, Num::Hex
44
44
  rule /[+-]?(\d+([.]\d+)?|[.]\d+)([eE][+-]?\d+)?[Li]?/,
45
- 'Literal.Number'
45
+ Num
46
46
 
47
- rule /[\[\]{}();,]/, 'Punctuation'
47
+ rule /[\[\]{}();,]/, Punctuation
48
48
 
49
- rule %r([-<>?*+^/!=~$@:%&|]), 'Operator'
50
- rule /[.][.][.]/, 'Keyword'
49
+ rule %r([-<>?*+^/!=~$@:%&|]), Operator
50
+ rule /[.][.][.]/, Keyword
51
51
  end
52
52
  end
53
53
  end
@@ -483,53 +483,53 @@ module Rouge
483
483
 
484
484
  state :root do
485
485
  # comments
486
- rule /;.*$/, 'Comment.Single'
487
- rule /\s+/m, 'Text'
486
+ rule /;.*$/, Comment::Single
487
+ rule /\s+/m, Text
488
488
 
489
- rule /[+-]inf[.][f0]/, 'Literal.Number.Float'
490
- rule /[+-]nan[.]0/, 'Literal.Number.Float'
491
- rule /[-]min[.]0/, 'Literal.Number.Float'
492
- rule /[+]max[.]0/, 'Literal.Number.Float'
489
+ rule /[+-]inf[.][f0]/, Num::Float
490
+ rule /[+-]nan[.]0/, Num::Float
491
+ rule /[-]min[.]0/, Num::Float
492
+ rule /[+]max[.]0/, Num::Float
493
493
 
494
- rule /-?\d+\.\d+/, 'Literal.Number.Float'
495
- rule /-?\d+/, 'Literal.Number.Integer'
494
+ rule /-?\d+\.\d+/, Num::Float
495
+ rule /-?\d+/, Num::Integer
496
496
 
497
- rule /#:#{id}+/, 'Name.Tag' # keyword
497
+ rule /#:#{id}+/, Name::Tag # keyword
498
498
 
499
- rule /#b[01]+/, 'Literal.Number.Binary'
500
- rule /#o[0-7]+/, 'Literal.Number.Oct'
501
- rule /#d[0-9]+/, 'Literal.Number.Integer'
502
- rule /#x[0-9a-f]+/i, 'Literal.Number.Hex'
503
- rule /#[ei][\d.]+/, 'Literal.Number.Other'
499
+ rule /#b[01]+/, Num::Bin
500
+ rule /#o[0-7]+/, Num::Oct
501
+ rule /#d[0-9]+/, Num::Integer
502
+ rule /#x[0-9a-f]+/i, Num::Hex
503
+ rule /#[ei][\d.]+/, Num::Other
504
504
 
505
- rule /"(\\\\|\\"|[^"])*"/, 'Literal.String'
506
- rule /['`]#{id}/i, 'Literal.String.Symbol'
505
+ rule /"(\\\\|\\"|[^"])*"/, Str
506
+ rule /['`]#{id}/i, Str::Symbol
507
507
  rule /#\\([()\/'"._!\$%& ?=+-]{1}|[a-z0-9]+)/i,
508
- 'Literal.String.Char'
509
- rule /#t|#f/, 'Name.Constant'
510
- rule /(?:'|#|`|,@|,|\.)/, 'Operator'
508
+ Str::Char
509
+ rule /#t|#f/, Name::Constant
510
+ rule /(?:'|#|`|,@|,|\.)/, Operator
511
511
 
512
512
  rule /(['#])(\s*)(\()/m do
513
- group 'Literal.String.Symbol'
514
- group 'Text'
515
- group 'Punctuation'
513
+ group Str::Symbol
514
+ group Text
515
+ group Punctuation
516
516
  end
517
517
 
518
518
  # () [] {} are all permitted as like pairs
519
- rule /\(|\[|\{/, 'Punctuation', :command
520
- rule /\)|\]|\}/, 'Punctuation'
519
+ rule /\(|\[|\{/, Punctuation, :command
520
+ rule /\)|\]|\}/, Punctuation
521
521
 
522
- rule id, 'Name.Variable'
522
+ rule id, Name::Variable
523
523
  end
524
524
 
525
525
  state :command do
526
- rule id, 'Name.Function' do |m|
526
+ rule id, Name::Function do |m|
527
527
  if self.class.keywords.include? m[0]
528
- token 'Keyword'
528
+ token Keyword
529
529
  elsif self.class.builtins.include? m[0]
530
- token 'Name.Builtin'
530
+ token Name::Builtin
531
531
  else
532
- token 'Name.Function'
532
+ token Name::Function
533
533
  end
534
534
 
535
535
  pop!
@@ -20,18 +20,18 @@ module Rouge
20
20
  : # initial :
21
21
  @{0,2} # optional ivar, for :@foo and :@@foo
22
22
  [a-z_]\w*[!?]? # the symbol
23
- )xi, 'Literal.String.Symbol'
23
+ )xi, Str::Symbol
24
24
 
25
25
  # special symbols
26
26
  rule %r(:(?:\*\*|[-+]@|[/\%&\|^`~]|\[\]=?|<<|>>|<=?>|<=?|===?)),
27
- 'Literal.String.Symbol'
27
+ Str::Symbol
28
28
 
29
- rule /:'(\\\\|\\'|[^'])*'/, 'Literal.String.Symbol'
30
- rule /\b[a-z_]\w*?:\s+/, 'Literal.String.Symbol'
31
- rule /'(\\\\|\\'|[^'])*'/, 'Literal.String.Single'
32
- rule /:"/, 'Literal.String.Symbol', :simple_sym
33
- rule /"/, 'Literal.String.Double', :simple_string
34
- rule /(?<!\.)`/, 'Literal.String.Backtick', :simple_backtick
29
+ rule /:'(\\\\|\\'|[^'])*'/, Str::Symbol
30
+ rule /\b[a-z_]\w*?:\s+/, Str::Symbol
31
+ rule /'(\\\\|\\'|[^'])*'/, Str::Single
32
+ rule /:"/, Str::Symbol, :simple_sym
33
+ rule /"/, Str::Double, :simple_string
34
+ rule /(?<!\.)`/, Str::Backtick, :simple_backtick
35
35
 
36
36
  # %-style delimiters
37
37
  # %(abc), %[abc], %<abc>, %.abc., %r.abc., etc
@@ -40,21 +40,21 @@ module Rouge
40
40
  open = Regexp.escape(m[2])
41
41
  close = Regexp.escape(delimiter_map[m[2]] || m[2])
42
42
  interp = /[rQWxI]/ === m[1]
43
- toktype = 'Literal.String.Other'
43
+ toktype = Str::Other
44
44
 
45
45
  debug { " open: #{open.inspect}" }
46
46
  debug { " close: #{close.inspect}" }
47
47
 
48
48
  # regexes
49
49
  if m[1] == 'r'
50
- toktype = 'Literal.String.Regex'
50
+ toktype = Str::Regex
51
51
  push :regex_flags
52
52
  end
53
53
 
54
54
  token toktype
55
55
 
56
56
  push do
57
- rule /\\[##{open}#{close}\\]/, 'Literal.String.Escape'
57
+ rule /\\[##{open}#{close}\\]/, Str::Escape
58
58
  # nesting rules only with asymmetric delimiters
59
59
  if open != close
60
60
  rule /#{open}/ do
@@ -77,13 +77,13 @@ module Rouge
77
77
  end
78
78
 
79
79
  state :regex_flags do
80
- rule /[mixounse]*/, 'Literal.String.Regex', :pop!
80
+ rule /[mixounse]*/, Str::Regex, :pop!
81
81
  end
82
82
 
83
83
  # double-quoted string and symbol
84
- [[:string, 'Literal.String.Double', '"'],
85
- [:sym, 'Literal.String.Symbol', '"'],
86
- [:backtick, 'Literal.String.Backtick', '`']].each do |name, tok, fin|
84
+ [[:string, Str::Double, '"'],
85
+ [:sym, Str::Symbol, '"'],
86
+ [:backtick, Str::Backtick, '`']].each do |name, tok, fin|
87
87
  state :"simple_#{name}" do
88
88
  mixin :string_intp_escaped
89
89
  rule /[^\\#{fin}#]+/m, tok
@@ -105,7 +105,7 @@ module Rouge
105
105
  )
106
106
 
107
107
  builtins_g = %w(
108
- Array Float Integer String __id__ __send__ abort ancestors
108
+ Array Float Integer Str __id__ __send__ abort ancestors
109
109
  at_exit autoload binding callcc caller catch chomp chop
110
110
  class_eval class_variables clone const_defined\? const_get
111
111
  const_missing const_set constants display dup eval exec exit
@@ -138,45 +138,50 @@ module Rouge
138
138
  end
139
139
 
140
140
  state :root do
141
- rule /\n\s*/m, 'Text', :expr_start
142
- rule /\s+/, 'Text' # NB: NOT /m
143
- rule /#.*$/, 'Comment.Single'
141
+ rule /\n\s*/m, Text, :expr_start
142
+ rule /\s+/, Text # NB: NOT /m
143
+ rule /#.*$/, Comment::Single
144
144
 
145
- rule %r(=begin\b.*?end\b)m, 'Comment.Multiline'
146
- rule /(?:#{keywords.join('|')})\b/, 'Keyword', :expr_start
147
- rule /(?:#{keywords_pseudo.join('|')})\b/, 'Keyword.Pseudo', :expr_start
145
+ rule %r(=begin\b.*?end\b)m, Comment::Multiline
146
+ rule /(?:#{keywords.join('|')})\b/, Keyword, :expr_start
147
+ rule /(?:#{keywords_pseudo.join('|')})\b/, Keyword::Pseudo, :expr_start
148
148
  rule %r(
149
149
  (module)
150
150
  (\s+)
151
151
  ([a-zA-Z_][a-zA-Z0-9_]*(::[a-zA-Z_][a-zA-Z0-9_]*)*)
152
152
  )x do
153
- group 'Keyword'
154
- group 'Text'
155
- group 'Name.Namespace'
153
+ groups Keyword, Text, Name::Namespace
156
154
  end
157
155
 
158
- rule /def\s+/, 'Keyword', :funcname
159
- rule /class\s+/, 'Keyword', :classname
156
+ rule /(def\b)(\s*)/ do
157
+ groups Keyword, Text
158
+ push :funcname
159
+ end
160
+
161
+ rule /(class\b)(\s*)/ do
162
+ groups Keyword, Text
163
+ push :classname
164
+ end
160
165
 
161
- rule /(?:#{builtins_q.join('|')})\?/, 'Name.Builtin', :expr_start
162
- rule /(?:#{builtins_b.join('|')})!/, 'Name.Builtin', :expr_start
166
+ rule /(?:#{builtins_q.join('|')})\?/, Name::Builtin, :expr_start
167
+ rule /(?:#{builtins_b.join('|')})!/, Name::Builtin, :expr_start
163
168
  rule /(?<!\.)(?:#{builtins_g.join('|')})\b/,
164
- 'Name.Builtin', :method_call
169
+ Name::Builtin, :method_call
165
170
 
166
- rule /__END__/, 'Comment.Preproc', :end_part
171
+ rule /__END__/, Comment::Preproc, :end_part
167
172
 
168
- rule /0_?[0-7]+(?:_[0-7]+)*/, 'Literal.Number.Oct'
169
- rule /0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*/, 'Literal.Number.Hex'
170
- rule /0b[01]+(?:_[01]+)*/, 'Literal.Number.Bin'
171
- rule /[\d]+(?:_\d+)*/, 'Literal.Number.Integer'
173
+ rule /0_?[0-7]+(?:_[0-7]+)*/, Num::Oct
174
+ rule /0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*/, Num::Hex
175
+ rule /0b[01]+(?:_[01]+)*/, Num::Bin
176
+ rule /[\d]+(?:_\d+)*/, Num::Integer
172
177
 
173
178
  # names
174
- rule /@@[a-z_]\w*/i, 'Name.Variable.Class'
175
- rule /@[a-z_]\w*/i, 'Name.Variable.Instance'
176
- rule /\$\w+/, 'Name.Variable.Global'
177
- rule %r(\$[!@&`'+~=/\\,;.<>_*\$?:"]), 'Name.Variable.Global'
178
- rule /\$-[0adFiIlpvw]/, 'Name.Variable.Global'
179
- rule /::/, 'Operator'
179
+ rule /@@[a-z_]\w*/i, Name::Variable::Class
180
+ rule /@[a-z_]\w*/i, Name::Variable::Instance
181
+ rule /\$\w+/, Name::Variable::Global
182
+ rule %r(\$[!@&`'+~=/\\,;.<>_*\$?:"]), Name::Variable::Global
183
+ rule /\$-[0adFiIlpvw]/, Name::Variable::Global
184
+ rule /::/, Operator
180
185
 
181
186
  mixin :strings
182
187
 
@@ -186,33 +191,33 @@ module Rouge
186
191
  \?(\\[MC]-)* # modifiers
187
192
  (\\([\\abefnrstv\#"']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})|\S)
188
193
  (?!\w)
189
- )x, 'Literal.String.Char'
194
+ )x, Str::Char
190
195
 
191
196
  mixin :has_heredocs
192
197
 
193
- rule /[A-Z][a-zA-Z0-9_]+/, 'Name.Constant', :method_call
198
+ rule /[A-Z][a-zA-Z0-9_]+/, Name::Constant, :method_call
194
199
  rule /(\.|::)([a-z_]\w*[!?]?|[*%&^`~+-\/\[<>=])/,
195
- 'Name.Function', :expr_start
196
- rule /[a-zA-Z_]\w*[?!]/, 'Name', :expr_start
197
- rule /[a-zA-Z_]\w*/, 'Name', :method_call
200
+ Name::Function, :expr_start
201
+ rule /[a-zA-Z_]\w*[?!]/, Name, :expr_start
202
+ rule /[a-zA-Z_]\w*/, Name, :method_call
198
203
  rule /\[|\]|\*\*|<<?|>>?|>=|<=|<=>|=~|={3}|!~|&&?|\|\||\.{1,3}/,
199
- 'Operator', :expr_start
200
- rule /[-+\/*%=<>&!^|~]=?/, 'Operator', :expr_start
201
- rule %r<[({,?:\\;/]>, 'Punctuation', :expr_start
202
- rule %r<[)}]>, 'Punctuation'
204
+ Operator, :expr_start
205
+ rule /[-+\/*%=<>&!^|~]=?/, Operator, :expr_start
206
+ rule %r<[({,?:\\;/]>, Punctuation, :expr_start
207
+ rule %r<[)}]>, Punctuation
203
208
  end
204
209
 
205
210
  state :has_heredocs do
206
211
  rule /(?<!\w)(<<-?)(["`']?)([a-zA-Z_]\w*)(\2)/ do |m|
207
- token 'Operator', m[1]
208
- token 'Name.Constant', "#{m[2]}#{m[3]}#{m[4]}"
212
+ token Operator, m[1]
213
+ token Name::Constant, "#{m[2]}#{m[3]}#{m[4]}"
209
214
  @heredoc_queue << [m[1] == '<<-', m[3]]
210
215
  push :heredoc_queue unless state? :heredoc_queue
211
216
  end
212
217
 
213
218
  rule /(<<-?)(["'])(\2)/ do |m|
214
- token 'Operator', m[1]
215
- token 'Name.Constant', "#{m[2]}#{m[3]}#{m[4]}"
219
+ token Operator, m[1]
220
+ token Name::Constant, "#{m[2]}#{m[3]}#{m[4]}"
216
221
  @heredoc_queue << [m[1] == '<<-', '']
217
222
  push :heredoc_queue unless state? :heredoc_queue
218
223
  end
@@ -220,7 +225,7 @@ module Rouge
220
225
 
221
226
  state :heredoc_queue do
222
227
  rule /(?=\n)/ do
223
- pop!; push :resolve_heredocs
228
+ goto :resolve_heredocs
224
229
  end
225
230
 
226
231
  mixin :root
@@ -233,38 +238,36 @@ module Rouge
233
238
  tolerant, heredoc_name = @heredoc_queue.first
234
239
  check = tolerant ? m[2].strip : m[2].rstrip
235
240
 
236
- group 'Literal.String.Heredoc'
241
+ group Str::Heredoc
237
242
 
238
243
  # check if we found the end of the heredoc
239
244
  if check == heredoc_name
240
- group 'Name.Constant'
245
+ group Name::Constant
241
246
  @heredoc_queue.shift
242
247
  # if there's no more, we're done looking.
243
248
  pop! if @heredoc_queue.empty?
244
249
  else
245
- group 'Literal.String.Heredoc'
250
+ group Str::Heredoc
246
251
  end
247
252
  end
248
253
 
249
- rule /[#\\\n]/, 'Literal.String.Heredoc'
250
- rule /[^#\\\n]+/, 'Literal.String.Heredoc'
254
+ rule /[#\\\n]/, Str::Heredoc
255
+ rule /[^#\\\n]+/, Str::Heredoc
251
256
  end
252
257
 
253
258
  state :funcname do
254
- rule /\s+/, 'Text'
255
- rule /\(/, 'Punctuation', :defexpr
259
+ rule /\s+/, Text
260
+ rule /\(/, Punctuation, :defexpr
256
261
  rule %r(
257
262
  (?:([a-zA-Z_][\w_]*)(\.))?
258
263
  (
259
264
  [a-zA-Z_][\w_]*[!?]? |
260
265
  \*\*? | [-+]@? | [/%&\|^`~] | \[\]=? |
261
- << | >> | <=?> | >=? | ===?
266
+ <<? | >>? | <=>? | >= | ===?
262
267
  )
263
268
  )x do |m|
264
269
  debug { "matches: #{[m[0], m[1], m[2], m[3]].inspect}" }
265
- group 'Name.Class'
266
- group 'Operator'
267
- group 'Name.Function'
270
+ groups Name::Class, Operator, Name::Function
268
271
  pop!
269
272
  end
270
273
 
@@ -272,69 +275,63 @@ module Rouge
272
275
  end
273
276
 
274
277
  state :classname do
275
- rule /\s+/, 'Text'
276
- rule /\(/, 'Punctuation', :defexpr
278
+ rule /\s+/, Text
279
+ rule /\(/, Punctuation, :defexpr
277
280
 
278
281
  # class << expr
279
- rule /<</, 'Operator', :pop!
280
- rule /[A-Z_]\w*/, 'Name.Class'
282
+ rule /<</, Operator, :pop!
283
+ rule /[A-Z_]\w*/, Name::Class
281
284
 
282
285
  rule(//) { pop! }
283
286
  end
284
287
 
285
288
  state :defexpr do
286
289
  rule /(\))(\.|::)?/ do
287
- group 'Punctuation'
288
- group 'Operator'
290
+ groups Punctuation, Operator
289
291
  pop!
290
292
  end
291
- rule /\(/, 'Operator', :defexpr
293
+ rule /\(/, Operator, :defexpr
292
294
  mixin :root
293
295
  end
294
296
 
295
297
  state :in_interp do
296
- rule /}/, 'Literal.String.Interpol', :pop!
298
+ rule /}/, Str::Interpol, :pop!
297
299
  mixin :root
298
300
  end
299
301
 
300
302
  state :string_intp do
301
- rule /\#{/, 'Literal.String.Interpol', :in_interp
302
- rule /#(@@?|\$)[a-z_]\w*/i, 'Literal.String.Interpol'
303
+ rule /\#{/, Str::Interpol, :in_interp
304
+ rule /#(@@?|\$)[a-z_]\w*/i, Str::Interpol
303
305
  end
304
306
 
305
307
  state :string_intp_escaped do
306
308
  mixin :string_intp
307
309
  rule /\\([\\abefnrstv#"']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})/,
308
- 'Literal.String.Escape'
309
- rule /\\./, 'Literal.String.Escape'
310
+ Str::Escape
311
+ rule /\\./, Str::Escape
310
312
  end
311
313
 
312
314
  state :method_call do
313
315
  rule %r((\s+)(/)(?=\S|\s*/)) do
314
- group 'Text'
315
- group 'Literal.String.Regex'
316
- pop!
317
- push :slash_regex
316
+ groups Text, Str::Regex
317
+ goto :slash_regex
318
318
  end
319
319
 
320
320
  rule(%r((?=\s*/))) { pop! }
321
321
 
322
- rule(//) { pop!; push :expr_start }
322
+ rule(//) { goto :expr_start }
323
323
  end
324
324
 
325
325
  state :expr_start do
326
326
  rule %r((\s*)(/)) do
327
- group 'Text'
328
- group 'Literal.String.Regex'
329
- pop!
330
- push :slash_regex
327
+ groups Text, Str::Regex
328
+ goto :slash_regex
331
329
  end
332
330
 
333
331
  # special case for using a single space. Ruby demands that
334
332
  # these be in a single line, otherwise it would make no sense.
335
333
  rule /(\s*)(%[rqswQWxiI]? \S* )/ do
336
- group 'Text'
337
- group 'Literal.String.Other'
334
+ groups Text, Str::Other
338
335
  pop!
339
336
  end
340
337
 
@@ -343,19 +340,19 @@ module Rouge
343
340
 
344
341
  state :slash_regex do
345
342
  mixin :string_intp
346
- rule %r(\\\\), 'Literal.String.Regex'
347
- rule %r(\\/), 'Literal.String.Regex'
348
- rule %r([\\#]), 'Literal.String.Regex'
349
- rule %r([^\\/#]+)m, 'Literal.String.Regex'
343
+ rule %r(\\\\), Str::Regex
344
+ rule %r(\\/), Str::Regex
345
+ rule %r([\\#]), Str::Regex
346
+ rule %r([^\\/#]+)m, Str::Regex
350
347
  rule %r(/) do
351
- token 'Literal.String.Regex'
352
- pop!; push :regex_flags
348
+ token Str::Regex
349
+ goto :regex_flags
353
350
  end
354
351
  end
355
352
 
356
353
  state :end_part do
357
- # eat up the rest of the stream as Comment.Preproc
358
- rule /.+/m, 'Comment.Preproc', :pop!
354
+ # eat up the rest of the stream as Comment::Preproc
355
+ rule /.+/m, Comment::Preproc, :pop!
359
356
  end
360
357
  end
361
358
  end