rouge 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/bin/rougify +1 -1
- data/lib/rouge/demos/{text → plaintext} +0 -0
- data/lib/rouge/formatters/html.rb +13 -8
- data/lib/rouge/formatters/terminal256.rb +15 -11
- data/lib/rouge/lexer.rb +3 -1
- data/lib/rouge/lexers/c.rb +65 -55
- data/lib/rouge/lexers/clojure.rb +19 -19
- data/lib/rouge/lexers/coffeescript.rb +42 -42
- data/lib/rouge/lexers/common_lisp.rb +49 -48
- data/lib/rouge/lexers/conf.rb +6 -6
- data/lib/rouge/lexers/cpp.rb +48 -48
- data/lib/rouge/lexers/csharp.rb +25 -25
- data/lib/rouge/lexers/css.rb +32 -33
- data/lib/rouge/lexers/diff.rb +8 -8
- data/lib/rouge/lexers/elixir.rb +30 -30
- data/lib/rouge/lexers/erb.rb +5 -5
- data/lib/rouge/lexers/erlang.rb +38 -38
- data/lib/rouge/lexers/factor.rb +56 -56
- data/lib/rouge/lexers/gherkin.rb +27 -27
- data/lib/rouge/lexers/go.rb +21 -21
- data/lib/rouge/lexers/groovy.rb +32 -32
- data/lib/rouge/lexers/haml.rb +35 -35
- data/lib/rouge/lexers/handlebars.rb +27 -27
- data/lib/rouge/lexers/haskell.rb +78 -79
- data/lib/rouge/lexers/html.rb +28 -28
- data/lib/rouge/lexers/http.rb +13 -13
- data/lib/rouge/lexers/ini.rb +13 -13
- data/lib/rouge/lexers/io.rb +19 -19
- data/lib/rouge/lexers/java.rb +29 -29
- data/lib/rouge/lexers/javascript.rb +49 -52
- data/lib/rouge/lexers/literate_haskell.rb +5 -5
- data/lib/rouge/lexers/llvm.rb +14 -14
- data/lib/rouge/lexers/lua.rb +33 -33
- data/lib/rouge/lexers/make.rb +26 -26
- data/lib/rouge/lexers/markdown.rb +49 -49
- data/lib/rouge/lexers/nginx.rb +19 -19
- data/lib/rouge/lexers/perl.rb +53 -54
- data/lib/rouge/lexers/php.rb +42 -43
- data/lib/rouge/lexers/{text.rb → plain_text.rb} +3 -2
- data/lib/rouge/lexers/prolog.rb +19 -19
- data/lib/rouge/lexers/puppet.rb +40 -40
- data/lib/rouge/lexers/python.rb +63 -63
- data/lib/rouge/lexers/r.rb +15 -15
- data/lib/rouge/lexers/racket.rb +29 -29
- data/lib/rouge/lexers/ruby.rb +94 -97
- data/lib/rouge/lexers/rust.rb +37 -37
- data/lib/rouge/lexers/sass.rb +15 -15
- data/lib/rouge/lexers/sass/common.rb +144 -136
- data/lib/rouge/lexers/scheme.rb +25 -25
- data/lib/rouge/lexers/scss.rb +7 -7
- data/lib/rouge/lexers/sed.rb +39 -39
- data/lib/rouge/lexers/shell.rb +45 -45
- data/lib/rouge/lexers/smalltalk.rb +36 -36
- data/lib/rouge/lexers/sql.rb +27 -27
- data/lib/rouge/lexers/tcl.rb +34 -34
- data/lib/rouge/lexers/tex.rb +24 -24
- data/lib/rouge/lexers/toml.rb +18 -18
- data/lib/rouge/lexers/viml.rb +19 -19
- data/lib/rouge/lexers/xml.rb +16 -16
- data/lib/rouge/lexers/yaml.rb +78 -81
- data/lib/rouge/plugins/redcarpet.rb +1 -1
- data/lib/rouge/regex_lexer.rb +31 -14
- data/lib/rouge/template_lexer.rb +1 -1
- data/lib/rouge/theme.rb +12 -10
- data/lib/rouge/themes/thankful_eyes.rb +43 -43
- data/lib/rouge/token.rb +145 -148
- data/lib/rouge/version.rb +1 -1
- metadata +4 -4
data/lib/rouge/lexers/r.rb
CHANGED
@@ -21,33 +21,33 @@ module Rouge
|
|
21
21
|
end
|
22
22
|
|
23
23
|
state :root do
|
24
|
-
rule /#.*?\n/,
|
25
|
-
rule /\s+/m,
|
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
|
28
|
+
token Keyword
|
29
29
|
else
|
30
|
-
token
|
30
|
+
token Name
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
rule /`.*?`/,
|
35
|
-
rule /'(\\.|.)*?'/m,
|
36
|
-
rule /"(\\.|.)*?"/m,
|
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/,
|
38
|
+
rule /\b(NULL|Inf|TRUE|FALSE|NaN)\b/, Keyword::Constant
|
39
39
|
rule /\bNA(_(integer|real|complex|character)_)?\b/,
|
40
|
-
|
41
|
-
rule /\b[TF]\b/,
|
40
|
+
Keyword::Constant
|
41
|
+
rule /\b[TF]\b/, Keyword::Variable
|
42
42
|
|
43
|
-
rule /0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?/,
|
43
|
+
rule /0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?/, Num::Hex
|
44
44
|
rule /[+-]?(\d+([.]\d+)?|[.]\d+)([eE][+-]?\d+)?[Li]?/,
|
45
|
-
|
45
|
+
Num
|
46
46
|
|
47
|
-
rule /[\[\]{}();,]/,
|
47
|
+
rule /[\[\]{}();,]/, Punctuation
|
48
48
|
|
49
|
-
rule %r([-<>?*+^/!=~$@:%&|]),
|
50
|
-
rule /[.][.][.]/,
|
49
|
+
rule %r([-<>?*+^/!=~$@:%&|]), Operator
|
50
|
+
rule /[.][.][.]/, Keyword
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
data/lib/rouge/lexers/racket.rb
CHANGED
@@ -483,53 +483,53 @@ module Rouge
|
|
483
483
|
|
484
484
|
state :root do
|
485
485
|
# comments
|
486
|
-
rule /;.*$/,
|
487
|
-
rule /\s+/m,
|
486
|
+
rule /;.*$/, Comment::Single
|
487
|
+
rule /\s+/m, Text
|
488
488
|
|
489
|
-
rule /[+-]inf[.][f0]/,
|
490
|
-
rule /[+-]nan[.]0/,
|
491
|
-
rule /[-]min[.]0/,
|
492
|
-
rule /[+]max[.]0/,
|
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+/,
|
495
|
-
rule /-?\d+/,
|
494
|
+
rule /-?\d+\.\d+/, Num::Float
|
495
|
+
rule /-?\d+/, Num::Integer
|
496
496
|
|
497
|
-
rule /#:#{id}+/,
|
497
|
+
rule /#:#{id}+/, Name::Tag # keyword
|
498
498
|
|
499
|
-
rule /#b[01]+/,
|
500
|
-
rule /#o[0-7]+/,
|
501
|
-
rule /#d[0-9]+/,
|
502
|
-
rule /#x[0-9a-f]+/i,
|
503
|
-
rule /#[ei][\d.]+/,
|
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 /"(\\\\|\\"|[^"])*"/,
|
506
|
-
rule /['`]#{id}/i,
|
505
|
+
rule /"(\\\\|\\"|[^"])*"/, Str
|
506
|
+
rule /['`]#{id}/i, Str::Symbol
|
507
507
|
rule /#\\([()\/'"._!\$%& ?=+-]{1}|[a-z0-9]+)/i,
|
508
|
-
|
509
|
-
rule /#t|#f/,
|
510
|
-
rule /(?:'|#|`|,@|,|\.)/,
|
508
|
+
Str::Char
|
509
|
+
rule /#t|#f/, Name::Constant
|
510
|
+
rule /(?:'|#|`|,@|,|\.)/, Operator
|
511
511
|
|
512
512
|
rule /(['#])(\s*)(\()/m do
|
513
|
-
group
|
514
|
-
group
|
515
|
-
group
|
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 /\(|\[|\{/,
|
520
|
-
rule /\)|\]|\}/,
|
519
|
+
rule /\(|\[|\{/, Punctuation, :command
|
520
|
+
rule /\)|\]|\}/, Punctuation
|
521
521
|
|
522
|
-
rule id,
|
522
|
+
rule id, Name::Variable
|
523
523
|
end
|
524
524
|
|
525
525
|
state :command do
|
526
|
-
rule id,
|
526
|
+
rule id, Name::Function do |m|
|
527
527
|
if self.class.keywords.include? m[0]
|
528
|
-
token
|
528
|
+
token Keyword
|
529
529
|
elsif self.class.builtins.include? m[0]
|
530
|
-
token
|
530
|
+
token Name::Builtin
|
531
531
|
else
|
532
|
-
token
|
532
|
+
token Name::Function
|
533
533
|
end
|
534
534
|
|
535
535
|
pop!
|
data/lib/rouge/lexers/ruby.rb
CHANGED
@@ -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,
|
23
|
+
)xi, Str::Symbol
|
24
24
|
|
25
25
|
# special symbols
|
26
26
|
rule %r(:(?:\*\*|[-+]@|[/\%&\|^`~]|\[\]=?|<<|>>|<=?>|<=?|===?)),
|
27
|
-
|
27
|
+
Str::Symbol
|
28
28
|
|
29
|
-
rule /:'(\\\\|\\'|[^'])*'/,
|
30
|
-
rule /\b[a-z_]\w*?:\s+/,
|
31
|
-
rule /'(\\\\|\\'|[^'])*'/,
|
32
|
-
rule /:"/,
|
33
|
-
rule /"/,
|
34
|
-
rule /(?<!\.)`/,
|
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 =
|
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 =
|
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}\\]/,
|
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]*/,
|
80
|
+
rule /[mixounse]*/, Str::Regex, :pop!
|
81
81
|
end
|
82
82
|
|
83
83
|
# double-quoted string and symbol
|
84
|
-
[[:string,
|
85
|
-
[:sym,
|
86
|
-
[:backtick,
|
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
|
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,
|
142
|
-
rule /\s+/,
|
143
|
-
rule /#.*$/,
|
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,
|
146
|
-
rule /(?:#{keywords.join('|')})\b/,
|
147
|
-
rule /(?:#{keywords_pseudo.join('|')})\b/,
|
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
|
-
|
154
|
-
group 'Text'
|
155
|
-
group 'Name.Namespace'
|
153
|
+
groups Keyword, Text, Name::Namespace
|
156
154
|
end
|
157
155
|
|
158
|
-
rule /def\s
|
159
|
-
|
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('|')})\?/,
|
162
|
-
rule /(?:#{builtins_b.join('|')})!/,
|
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
|
-
|
169
|
+
Name::Builtin, :method_call
|
165
170
|
|
166
|
-
rule /__END__/,
|
171
|
+
rule /__END__/, Comment::Preproc, :end_part
|
167
172
|
|
168
|
-
rule /0_?[0-7]+(?:_[0-7]+)*/,
|
169
|
-
rule /0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*/,
|
170
|
-
rule /0b[01]+(?:_[01]+)*/,
|
171
|
-
rule /[\d]+(?:_\d+)*/,
|
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,
|
175
|
-
rule /@[a-z_]\w*/i,
|
176
|
-
rule /\$\w+/,
|
177
|
-
rule %r(\$[!@&`'+~=/\\,;.<>_*\$?:"]),
|
178
|
-
rule /\$-[0adFiIlpvw]/,
|
179
|
-
rule /::/,
|
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,
|
194
|
+
)x, Str::Char
|
190
195
|
|
191
196
|
mixin :has_heredocs
|
192
197
|
|
193
|
-
rule /[A-Z][a-zA-Z0-9_]+/,
|
198
|
+
rule /[A-Z][a-zA-Z0-9_]+/, Name::Constant, :method_call
|
194
199
|
rule /(\.|::)([a-z_]\w*[!?]?|[*%&^`~+-\/\[<>=])/,
|
195
|
-
|
196
|
-
rule /[a-zA-Z_]\w*[?!]/,
|
197
|
-
rule /[a-zA-Z_]\w*/,
|
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
|
-
|
200
|
-
rule /[-+\/*%=<>&!^|~]=?/,
|
201
|
-
rule %r<[({,?:\\;/]>,
|
202
|
-
rule %r<[)}]>,
|
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
|
208
|
-
token
|
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
|
215
|
-
token
|
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
|
-
|
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
|
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
|
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
|
250
|
+
group Str::Heredoc
|
246
251
|
end
|
247
252
|
end
|
248
253
|
|
249
|
-
rule /[#\\\n]/,
|
250
|
-
rule /[^#\\\n]+/,
|
254
|
+
rule /[#\\\n]/, Str::Heredoc
|
255
|
+
rule /[^#\\\n]+/, Str::Heredoc
|
251
256
|
end
|
252
257
|
|
253
258
|
state :funcname do
|
254
|
-
rule /\s+/,
|
255
|
-
rule /\(/,
|
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
|
-
|
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+/,
|
276
|
-
rule /\(/,
|
278
|
+
rule /\s+/, Text
|
279
|
+
rule /\(/, Punctuation, :defexpr
|
277
280
|
|
278
281
|
# class << expr
|
279
|
-
rule /<</,
|
280
|
-
rule /[A-Z_]\w*/,
|
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
|
-
|
288
|
-
group 'Operator'
|
290
|
+
groups Punctuation, Operator
|
289
291
|
pop!
|
290
292
|
end
|
291
|
-
rule /\(/,
|
293
|
+
rule /\(/, Operator, :defexpr
|
292
294
|
mixin :root
|
293
295
|
end
|
294
296
|
|
295
297
|
state :in_interp do
|
296
|
-
rule /}/,
|
298
|
+
rule /}/, Str::Interpol, :pop!
|
297
299
|
mixin :root
|
298
300
|
end
|
299
301
|
|
300
302
|
state :string_intp do
|
301
|
-
rule /\#{/,
|
302
|
-
rule /#(@@?|\$)[a-z_]\w*/i,
|
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
|
-
|
309
|
-
rule /\\./,
|
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
|
-
|
315
|
-
|
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(//) {
|
322
|
+
rule(//) { goto :expr_start }
|
323
323
|
end
|
324
324
|
|
325
325
|
state :expr_start do
|
326
326
|
rule %r((\s*)(/)) do
|
327
|
-
|
328
|
-
|
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
|
-
|
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(\\\\),
|
347
|
-
rule %r(\\/),
|
348
|
-
rule %r([\\#]),
|
349
|
-
rule %r([^\\/#]+)m,
|
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
|
352
|
-
|
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
|
358
|
-
rule /.+/m,
|
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
|