rouge 3.1.1 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rouge.rb +1 -0
- data/lib/rouge/cli.rb +3 -1
- data/lib/rouge/demos/crystal +45 -0
- data/lib/rouge/demos/hcl +7 -0
- data/lib/rouge/demos/terraform +31 -0
- data/lib/rouge/lexers/crystal.rb +429 -0
- data/lib/rouge/lexers/css.rb +1 -1
- data/lib/rouge/lexers/erb.rb +1 -1
- data/lib/rouge/lexers/fortran.rb +2 -2
- data/lib/rouge/lexers/haskell.rb +15 -0
- data/lib/rouge/lexers/hcl.rb +162 -0
- data/lib/rouge/lexers/html.rb +1 -1
- data/lib/rouge/lexers/igorpro.rb +449 -194
- data/lib/rouge/lexers/java.rb +1 -1
- data/lib/rouge/lexers/javascript.rb +1 -0
- data/lib/rouge/lexers/julia.rb +19 -25
- data/lib/rouge/lexers/kotlin.rb +1 -1
- data/lib/rouge/lexers/markdown.rb +1 -1
- data/lib/rouge/lexers/nix.rb +13 -8
- data/lib/rouge/lexers/objective_c.rb +1 -1
- data/lib/rouge/lexers/perl.rb +1 -1
- data/lib/rouge/lexers/scheme.rb +2 -2
- data/lib/rouge/lexers/terraform.rb +104 -0
- data/lib/rouge/lexers/vhdl.rb +1 -1
- data/lib/rouge/version.rb +1 -1
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cb5bb343a9196b359989181d97b571f0448e99e
|
4
|
+
data.tar.gz: eed1d68491017119f8d68103b62624143a67e633
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e500f0918908c3345cc7604977b06659e1225124dff3f9444d91a56a74c1659d6e9bf0e8add27cb6c4024134639f3bc312cfe919627cc5177e74a8910f55dcd0
|
7
|
+
data.tar.gz: 1c0fe8631b0cb1a4ef332bf8e73a5164a195f301d6371827ec9fe1f162dd2cbf3ed382ff02efe8d93c98a44ed8c0c33d4b9fde3c71fc8b9f629deb8701ca010b
|
data/lib/rouge.rb
CHANGED
data/lib/rouge/cli.rb
CHANGED
@@ -304,7 +304,9 @@ module Rouge
|
|
304
304
|
yield %|usage: rougify style [<theme-name>] [<options>]|
|
305
305
|
yield %||
|
306
306
|
yield %|Print CSS styles for the given theme. Extra options are|
|
307
|
-
yield %|passed to the theme.
|
307
|
+
yield %|passed to the theme. To select a mode (light/dark) for the|
|
308
|
+
yield %|theme, append '.light' or '.dark' to the <theme-name>|
|
309
|
+
yield %|respectively. Theme defaults to thankful_eyes.|
|
308
310
|
yield %||
|
309
311
|
yield %|options:|
|
310
312
|
yield %| --scope (default: .highlight) a css selector to scope by|
|
@@ -0,0 +1,45 @@
|
|
1
|
+
lib LibC
|
2
|
+
WNOHANG = 0x00000001
|
3
|
+
|
4
|
+
@[ReturnsTwice]
|
5
|
+
fun fork : PidT
|
6
|
+
fun getpgid(pid : PidT) : PidT
|
7
|
+
fun kill(pid : PidT, signal : Int) : Int
|
8
|
+
fun getpid : PidT
|
9
|
+
fun getppid : PidT
|
10
|
+
fun exit(status : Int) : NoReturn
|
11
|
+
|
12
|
+
ifdef x86_64
|
13
|
+
alias ClockT = UInt64
|
14
|
+
else
|
15
|
+
alias ClockT = UInt32
|
16
|
+
end
|
17
|
+
|
18
|
+
SC_CLK_TCK = 3
|
19
|
+
|
20
|
+
struct Tms
|
21
|
+
utime : ClockT
|
22
|
+
stime : ClockT
|
23
|
+
cutime : ClockT
|
24
|
+
cstime : ClockT
|
25
|
+
end
|
26
|
+
|
27
|
+
fun times(buffer : Tms*) : ClockT
|
28
|
+
fun sysconf(name : Int) : Long
|
29
|
+
end
|
30
|
+
|
31
|
+
class Process
|
32
|
+
def self.exit(status = 0)
|
33
|
+
LibC.exit(status)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.pid
|
37
|
+
LibC.getpid
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.getpgid(pid : Int32)
|
41
|
+
ret = LibC.getpgid(pid)
|
42
|
+
raise Errno.new(ret) if ret < 0
|
43
|
+
ret
|
44
|
+
end
|
45
|
+
end
|
data/lib/rouge/demos/hcl
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# From: https://github.com/terraform-providers/terraform-provider-aws/blob/master/examples/count/main.tf
|
2
|
+
|
3
|
+
# Specify the provider and access details
|
4
|
+
provider "aws" {
|
5
|
+
region = "${var.aws_region}"
|
6
|
+
}
|
7
|
+
|
8
|
+
resource "aws_elb" "web" {
|
9
|
+
name = "terraform-example-elb"
|
10
|
+
|
11
|
+
# The same availability zone as our instances
|
12
|
+
availability_zones = ["${aws_instance.web.*.availability_zone}"]
|
13
|
+
|
14
|
+
listener {
|
15
|
+
instance_port = 80
|
16
|
+
instance_protocol = "http"
|
17
|
+
lb_port = 80
|
18
|
+
lb_protocol = "http"
|
19
|
+
}
|
20
|
+
|
21
|
+
# The instances are registered automatically
|
22
|
+
instances = ["${aws_instance.web.*.id}"]
|
23
|
+
}
|
24
|
+
|
25
|
+
resource "aws_instance" "web" {
|
26
|
+
instance_type = "m1.small"
|
27
|
+
ami = "${lookup(var.aws_amis, var.aws_region)}"
|
28
|
+
|
29
|
+
# This will create 4 instances
|
30
|
+
count = 4
|
31
|
+
}
|
@@ -0,0 +1,429 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
|
3
|
+
module Rouge
|
4
|
+
module Lexers
|
5
|
+
class Crystal < RegexLexer
|
6
|
+
title "Crystal"
|
7
|
+
desc "Crystal The Programming Language (crystal-lang.org)"
|
8
|
+
tag 'crystal'
|
9
|
+
aliases 'cr'
|
10
|
+
filenames '*.cr'
|
11
|
+
|
12
|
+
mimetypes 'text/x-crystal', 'application/x-crystal'
|
13
|
+
|
14
|
+
def self.detect?(text)
|
15
|
+
return true if text.shebang? 'crystal'
|
16
|
+
end
|
17
|
+
|
18
|
+
state :symbols do
|
19
|
+
# symbols
|
20
|
+
rule %r(
|
21
|
+
: # initial :
|
22
|
+
@{0,2} # optional ivar, for :@foo and :@@foo
|
23
|
+
[a-z_]\w*[!?]? # the symbol
|
24
|
+
)xi, Str::Symbol
|
25
|
+
|
26
|
+
# special symbols
|
27
|
+
rule %r(:(?:\*\*|[-+]@|[/\%&\|^`~]|\[\]=?|<<|>>|<=?>|<=?|===?)),
|
28
|
+
Str::Symbol
|
29
|
+
|
30
|
+
rule /:'(\\\\|\\'|[^'])*'/, Str::Symbol
|
31
|
+
rule /:"/, Str::Symbol, :simple_sym
|
32
|
+
end
|
33
|
+
|
34
|
+
state :sigil_strings do
|
35
|
+
# %-sigiled strings
|
36
|
+
# %(abc), %[abc], %<abc>, %.abc., %r.abc., etc
|
37
|
+
delimiter_map = { '{' => '}', '[' => ']', '(' => ')', '<' => '>' }
|
38
|
+
rule /%([rqswQWxiI])?([^\w\s])/ do |m|
|
39
|
+
open = Regexp.escape(m[2])
|
40
|
+
close = Regexp.escape(delimiter_map[m[2]] || m[2])
|
41
|
+
interp = /[rQWxI]/ === m[1]
|
42
|
+
toktype = Str::Other
|
43
|
+
|
44
|
+
puts " open: #{open.inspect}" if @debug
|
45
|
+
puts " close: #{close.inspect}" if @debug
|
46
|
+
|
47
|
+
# regexes
|
48
|
+
if m[1] == 'r'
|
49
|
+
toktype = Str::Regex
|
50
|
+
push :regex_flags
|
51
|
+
end
|
52
|
+
|
53
|
+
token toktype
|
54
|
+
|
55
|
+
push do
|
56
|
+
rule /\\[##{open}#{close}\\]/, Str::Escape
|
57
|
+
# nesting rules only with asymmetric delimiters
|
58
|
+
if open != close
|
59
|
+
rule /#{open}/ do
|
60
|
+
token toktype
|
61
|
+
push
|
62
|
+
end
|
63
|
+
end
|
64
|
+
rule /#{close}/, toktype, :pop!
|
65
|
+
|
66
|
+
if interp
|
67
|
+
mixin :string_intp_escaped
|
68
|
+
rule /#/, toktype
|
69
|
+
else
|
70
|
+
rule /[\\#]/, toktype
|
71
|
+
end
|
72
|
+
|
73
|
+
rule /[^##{open}#{close}\\]+/m, toktype
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
state :strings do
|
79
|
+
mixin :symbols
|
80
|
+
rule /\b[a-z_]\w*?[?!]?:\s+/, Str::Symbol, :expr_start
|
81
|
+
rule /'(\\\\|\\'|[^'])*'/, Str::Single
|
82
|
+
rule /"/, Str::Double, :simple_string
|
83
|
+
rule /(?<!\.)`/, Str::Backtick, :simple_backtick
|
84
|
+
end
|
85
|
+
|
86
|
+
state :regex_flags do
|
87
|
+
rule /[mixounse]*/, Str::Regex, :pop!
|
88
|
+
end
|
89
|
+
|
90
|
+
# double-quoted string and symbol
|
91
|
+
[[:string, Str::Double, '"'],
|
92
|
+
[:sym, Str::Symbol, '"'],
|
93
|
+
[:backtick, Str::Backtick, '`']].each do |name, tok, fin|
|
94
|
+
state :"simple_#{name}" do
|
95
|
+
mixin :string_intp_escaped
|
96
|
+
rule /[^\\#{fin}#]+/m, tok
|
97
|
+
rule /[\\#]/, tok
|
98
|
+
rule /#{fin}/, tok, :pop!
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
keywords = %w(
|
103
|
+
BEGIN END alias begin break case defined\? do else elsif end
|
104
|
+
ensure for if ifdef in next redo rescue raise retry return super then
|
105
|
+
undef unless until when while yield lib fun type of as
|
106
|
+
)
|
107
|
+
|
108
|
+
keywords_pseudo = %w(
|
109
|
+
initialize new loop include extend raise attr_reader attr_writer
|
110
|
+
attr_accessor alias_method attr catch throw private module_function
|
111
|
+
public protected true false nil __FILE__ __LINE__
|
112
|
+
getter getter? getter! property property? property! struct record
|
113
|
+
)
|
114
|
+
|
115
|
+
builtins_g = %w(
|
116
|
+
abort ancestors at_exit
|
117
|
+
caller catch chomp chop clone constants
|
118
|
+
display dup eval exec exit extend fail fork format freeze
|
119
|
+
getc gets global_variables gsub hash id included_modules
|
120
|
+
inspect instance_eval instance_method instance_methods
|
121
|
+
lambda loop method method_missing
|
122
|
+
methods module_eval name object_id open p print printf
|
123
|
+
proc putc puts raise rand
|
124
|
+
readline readlines require scan select self send
|
125
|
+
sleep split sprintf srand sub syscall system
|
126
|
+
test throw to_a to_s trap warn
|
127
|
+
)
|
128
|
+
|
129
|
+
builtins_q = %w(
|
130
|
+
eql equal include is_a iterator kind_of nil
|
131
|
+
)
|
132
|
+
|
133
|
+
builtins_b = %w(chomp chop exit gsub sub)
|
134
|
+
|
135
|
+
start do
|
136
|
+
push :expr_start
|
137
|
+
@heredoc_queue = []
|
138
|
+
end
|
139
|
+
|
140
|
+
state :whitespace do
|
141
|
+
mixin :inline_whitespace
|
142
|
+
rule /\n\s*/m, Text, :expr_start
|
143
|
+
rule /#.*$/, Comment::Single
|
144
|
+
|
145
|
+
rule %r(=begin\b.*?\n=end\b)m, Comment::Multiline
|
146
|
+
end
|
147
|
+
|
148
|
+
state :inline_whitespace do
|
149
|
+
rule /[ \t\r]+/, Text
|
150
|
+
end
|
151
|
+
|
152
|
+
state :root do
|
153
|
+
mixin :whitespace
|
154
|
+
rule /__END__/, Comment::Preproc, :end_part
|
155
|
+
|
156
|
+
rule /0_?[0-7]+(?:_[0-7]+)*/, Num::Oct
|
157
|
+
rule /0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*/, Num::Hex
|
158
|
+
rule /0b[01]+(?:_[01]+)*/, Num::Bin
|
159
|
+
rule /\d+\.\d+(e[\+\-]?\d+)?/, Num::Float
|
160
|
+
rule /[\d]+(?:_\d+)*/, Num::Integer
|
161
|
+
|
162
|
+
rule /@\[([^\]]+)\]/, Name::Decorator
|
163
|
+
|
164
|
+
# names
|
165
|
+
rule /@@[a-z_]\w*/i, Name::Variable::Class
|
166
|
+
rule /@[a-z_]\w*/i, Name::Variable::Instance
|
167
|
+
rule /\$\w+/, Name::Variable::Global
|
168
|
+
rule %r(\$[!@&`'+~=/\\,;.<>_*\$?:"]), Name::Variable::Global
|
169
|
+
rule /\$-[0adFiIlpvw]/, Name::Variable::Global
|
170
|
+
rule /::/, Operator
|
171
|
+
|
172
|
+
mixin :strings
|
173
|
+
|
174
|
+
rule /(?:#{keywords.join('|')})\b/, Keyword, :expr_start
|
175
|
+
rule /(?:#{keywords_pseudo.join('|')})\b/, Keyword::Pseudo, :expr_start
|
176
|
+
|
177
|
+
rule %r(
|
178
|
+
(module)
|
179
|
+
(\s+)
|
180
|
+
([a-zA-Z_][a-zA-Z0-9_]*(::[a-zA-Z_][a-zA-Z0-9_]*)*)
|
181
|
+
)x do
|
182
|
+
groups Keyword, Text, Name::Namespace
|
183
|
+
end
|
184
|
+
|
185
|
+
rule /(def\b)(\s*)/ do
|
186
|
+
groups Keyword, Text
|
187
|
+
push :funcname
|
188
|
+
end
|
189
|
+
|
190
|
+
rule /(class\b)(\s*)/ do
|
191
|
+
groups Keyword, Text
|
192
|
+
push :classname
|
193
|
+
end
|
194
|
+
|
195
|
+
rule /(?:#{builtins_q.join('|')})[?]/, Name::Builtin, :expr_start
|
196
|
+
rule /(?:#{builtins_b.join('|')})!/, Name::Builtin, :expr_start
|
197
|
+
rule /(?<!\.)(?:#{builtins_g.join('|')})\b/,
|
198
|
+
Name::Builtin, :method_call
|
199
|
+
|
200
|
+
mixin :has_heredocs
|
201
|
+
|
202
|
+
# `..` and `...` for ranges must have higher priority than `.`
|
203
|
+
# Otherwise, they will be parsed as :method_call
|
204
|
+
rule /\.{2,3}/, Operator, :expr_start
|
205
|
+
|
206
|
+
rule /[A-Z][a-zA-Z0-9_]*/, Name::Constant, :method_call
|
207
|
+
rule /(\.|::)(\s*)([a-z_]\w*[!?]?|[*%&^`~+-\/\[<>=])/ do
|
208
|
+
groups Punctuation, Text, Name::Function
|
209
|
+
push :method_call
|
210
|
+
end
|
211
|
+
|
212
|
+
rule /[a-zA-Z_]\w*[?!]/, Name, :expr_start
|
213
|
+
rule /[a-zA-Z_]\w*/, Name, :method_call
|
214
|
+
rule /\*\*|<<?|>>?|>=|<=|<=>|=~|={3}|!~|&&?|\|\||\./,
|
215
|
+
Operator, :expr_start
|
216
|
+
rule /[-+\/*%=<>&!^|~]=?/, Operator, :expr_start
|
217
|
+
rule(/[?]/) { token Punctuation; push :ternary; push :expr_start }
|
218
|
+
rule %r<[\[({,:\\;/]>, Punctuation, :expr_start
|
219
|
+
rule %r<[\])}]>, Punctuation
|
220
|
+
end
|
221
|
+
|
222
|
+
state :has_heredocs do
|
223
|
+
rule /(?<!\w)(<<[-~]?)(["`']?)([a-zA-Z_]\w*)(\2)/ do |m|
|
224
|
+
token Operator, m[1]
|
225
|
+
token Name::Constant, "#{m[2]}#{m[3]}#{m[4]}"
|
226
|
+
@heredoc_queue << [['<<-', '<<~'].include?(m[1]), m[3]]
|
227
|
+
push :heredoc_queue unless state? :heredoc_queue
|
228
|
+
end
|
229
|
+
|
230
|
+
rule /(<<[-~]?)(["'])(\2)/ do |m|
|
231
|
+
token Operator, m[1]
|
232
|
+
token Name::Constant, "#{m[2]}#{m[3]}#{m[4]}"
|
233
|
+
@heredoc_queue << [['<<-', '<<~'].include?(m[1]), '']
|
234
|
+
push :heredoc_queue unless state? :heredoc_queue
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
state :heredoc_queue do
|
239
|
+
rule /(?=\n)/ do
|
240
|
+
goto :resolve_heredocs
|
241
|
+
end
|
242
|
+
|
243
|
+
mixin :root
|
244
|
+
end
|
245
|
+
|
246
|
+
state :resolve_heredocs do
|
247
|
+
mixin :string_intp_escaped
|
248
|
+
|
249
|
+
rule /\n/, Str::Heredoc, :test_heredoc
|
250
|
+
rule /[#\\\n]/, Str::Heredoc
|
251
|
+
rule /[^#\\\n]+/, Str::Heredoc
|
252
|
+
end
|
253
|
+
|
254
|
+
state :test_heredoc do
|
255
|
+
rule /[^#\\\n]*$/ do |m|
|
256
|
+
tolerant, heredoc_name = @heredoc_queue.first
|
257
|
+
check = tolerant ? m[0].strip : m[0].rstrip
|
258
|
+
|
259
|
+
# check if we found the end of the heredoc
|
260
|
+
puts " end heredoc check #{check.inspect} = #{heredoc_name.inspect}" if @debug
|
261
|
+
if check == heredoc_name
|
262
|
+
@heredoc_queue.shift
|
263
|
+
# if there's no more, we're done looking.
|
264
|
+
pop! if @heredoc_queue.empty?
|
265
|
+
token Name::Constant
|
266
|
+
else
|
267
|
+
token Str::Heredoc
|
268
|
+
end
|
269
|
+
|
270
|
+
pop!
|
271
|
+
end
|
272
|
+
|
273
|
+
rule(//) { pop! }
|
274
|
+
end
|
275
|
+
|
276
|
+
state :funcname do
|
277
|
+
rule /\s+/, Text
|
278
|
+
rule /\(/, Punctuation, :defexpr
|
279
|
+
rule %r(
|
280
|
+
(?:([a-zA-Z_][\w_]*)(\.))?
|
281
|
+
(
|
282
|
+
[a-zA-Z_][\w_]*[!?]? |
|
283
|
+
\*\*? | [-+]@? | [/%&\|^`~] | \[\]=? |
|
284
|
+
<<? | >>? | <=>? | >= | ===?
|
285
|
+
)
|
286
|
+
)x do |m|
|
287
|
+
puts "matches: #{[m[0], m[1], m[2], m[3]].inspect}" if @debug
|
288
|
+
groups Name::Class, Operator, Name::Function
|
289
|
+
pop!
|
290
|
+
end
|
291
|
+
|
292
|
+
rule(//) { pop! }
|
293
|
+
end
|
294
|
+
|
295
|
+
state :classname do
|
296
|
+
rule /\s+/, Text
|
297
|
+
rule /\(/ do
|
298
|
+
token Punctuation
|
299
|
+
push :defexpr
|
300
|
+
push :expr_start
|
301
|
+
end
|
302
|
+
|
303
|
+
# class << expr
|
304
|
+
rule /<</ do
|
305
|
+
token Operator
|
306
|
+
goto :expr_start
|
307
|
+
end
|
308
|
+
|
309
|
+
rule /[A-Z_]\w*/, Name::Class, :pop!
|
310
|
+
|
311
|
+
rule(//) { pop! }
|
312
|
+
end
|
313
|
+
|
314
|
+
state :ternary do
|
315
|
+
rule(/:(?!:)/) { token Punctuation; goto :expr_start }
|
316
|
+
|
317
|
+
mixin :root
|
318
|
+
end
|
319
|
+
|
320
|
+
state :defexpr do
|
321
|
+
rule /(\))(\.|::)?/ do
|
322
|
+
groups Punctuation, Operator
|
323
|
+
pop!
|
324
|
+
end
|
325
|
+
rule /\(/ do
|
326
|
+
token Punctuation
|
327
|
+
push :defexpr
|
328
|
+
push :expr_start
|
329
|
+
end
|
330
|
+
|
331
|
+
mixin :root
|
332
|
+
end
|
333
|
+
|
334
|
+
state :in_interp do
|
335
|
+
rule /}/, Str::Interpol, :pop!
|
336
|
+
mixin :root
|
337
|
+
end
|
338
|
+
|
339
|
+
state :string_intp do
|
340
|
+
rule /[#][{]/, Str::Interpol, :in_interp
|
341
|
+
rule /#(@@?|\$)[a-z_]\w*/i, Str::Interpol
|
342
|
+
end
|
343
|
+
|
344
|
+
state :string_intp_escaped do
|
345
|
+
mixin :string_intp
|
346
|
+
rule /\\([\\abefnrstv#"']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})/,
|
347
|
+
Str::Escape
|
348
|
+
rule /\\./, Str::Escape
|
349
|
+
end
|
350
|
+
|
351
|
+
state :method_call do
|
352
|
+
rule %r(/) do
|
353
|
+
token Operator
|
354
|
+
goto :expr_start
|
355
|
+
end
|
356
|
+
|
357
|
+
rule(/(?=\n)/) { pop! }
|
358
|
+
|
359
|
+
rule(//) { goto :method_call_spaced }
|
360
|
+
end
|
361
|
+
|
362
|
+
state :method_call_spaced do
|
363
|
+
mixin :whitespace
|
364
|
+
|
365
|
+
rule %r([%/]=) do
|
366
|
+
token Operator
|
367
|
+
goto :expr_start
|
368
|
+
end
|
369
|
+
|
370
|
+
rule %r((/)(?=\S|\s*/)) do
|
371
|
+
token Str::Regex
|
372
|
+
goto :slash_regex
|
373
|
+
end
|
374
|
+
|
375
|
+
mixin :sigil_strings
|
376
|
+
|
377
|
+
rule(%r((?=\s*/))) { pop! }
|
378
|
+
|
379
|
+
rule(/\s+/) { token Text; goto :expr_start }
|
380
|
+
rule(//) { pop! }
|
381
|
+
end
|
382
|
+
|
383
|
+
state :expr_start do
|
384
|
+
mixin :inline_whitespace
|
385
|
+
|
386
|
+
rule %r(/) do
|
387
|
+
token Str::Regex
|
388
|
+
goto :slash_regex
|
389
|
+
end
|
390
|
+
|
391
|
+
# char operator. ?x evaulates to "x", unless there's a digit
|
392
|
+
# beforehand like x>=0?n[x]:""
|
393
|
+
rule %r(
|
394
|
+
[?](\\[MC]-)* # modifiers
|
395
|
+
(\\([\\abefnrstv\#"']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})|\S)
|
396
|
+
(?!\w)
|
397
|
+
)x, Str::Char, :pop!
|
398
|
+
|
399
|
+
# special case for using a single space. Ruby demands that
|
400
|
+
# these be in a single line, otherwise it would make no sense.
|
401
|
+
rule /(\s*)(%[rqswQWxiI]? \S* )/ do
|
402
|
+
groups Text, Str::Other
|
403
|
+
pop!
|
404
|
+
end
|
405
|
+
|
406
|
+
mixin :sigil_strings
|
407
|
+
|
408
|
+
rule(//) { pop! }
|
409
|
+
end
|
410
|
+
|
411
|
+
state :slash_regex do
|
412
|
+
mixin :string_intp
|
413
|
+
rule %r(\\\\), Str::Regex
|
414
|
+
rule %r(\\/), Str::Regex
|
415
|
+
rule %r([\\#]), Str::Regex
|
416
|
+
rule %r([^\\/#]+)m, Str::Regex
|
417
|
+
rule %r(/) do
|
418
|
+
token Str::Regex
|
419
|
+
goto :regex_flags
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
state :end_part do
|
424
|
+
# eat up the rest of the stream as Comment::Preproc
|
425
|
+
rule /.+/m, Comment::Preproc, :pop!
|
426
|
+
end
|
427
|
+
end
|
428
|
+
end
|
429
|
+
end
|