machete 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +9 -0
- data/README.md +78 -9
- data/VERSION +1 -1
- data/lib/machete/matchers.rb +128 -2
- data/lib/machete/parser.rb +382 -119
- data/lib/machete/parser.y +127 -49
- data/spec/machete/matchers_spec.rb +356 -0
- data/spec/machete/parser_spec.rb +202 -111
- metadata +5 -5
data/lib/machete/parser.rb
CHANGED
@@ -8,7 +8,7 @@ require 'racc/parser.rb'
|
|
8
8
|
module Machete
|
9
9
|
class Parser < Racc::Parser
|
10
10
|
|
11
|
-
module_eval(<<'...end parser.y/module_eval...', 'parser.y',
|
11
|
+
module_eval(<<'...end parser.y/module_eval...', 'parser.y', 102)
|
12
12
|
|
13
13
|
include Matchers
|
14
14
|
|
@@ -23,7 +23,65 @@ end
|
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
-
|
26
|
+
def integer_value(value)
|
27
|
+
if value =~ /^0[bB]/
|
28
|
+
value[2..-1].to_i(2)
|
29
|
+
elsif value =~ /^0[oO]/
|
30
|
+
value[2..-1].to_i(8)
|
31
|
+
elsif value =~ /^0[dD]/
|
32
|
+
value[2..-1].to_i(10)
|
33
|
+
elsif value =~ /^0[xX]/
|
34
|
+
value[2..-1].to_i(16)
|
35
|
+
elsif value =~ /^0/
|
36
|
+
value[1..-1].to_i(8)
|
37
|
+
else
|
38
|
+
value.to_i
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def string_value(value)
|
43
|
+
quote = value[0..0]
|
44
|
+
if quote == "'"
|
45
|
+
value[1..-2].gsub("\\\\", "\\").gsub("\\'", "'")
|
46
|
+
elsif quote == '"'
|
47
|
+
value[1..-2].
|
48
|
+
gsub("\\\\", "\\").
|
49
|
+
gsub('\\"', '"').
|
50
|
+
gsub("\\n", "\n").
|
51
|
+
gsub("\\t", "\t").
|
52
|
+
gsub("\\r", "\r").
|
53
|
+
gsub("\\f", "\f").
|
54
|
+
gsub("\\v", "\v").
|
55
|
+
gsub("\\a", "\a").
|
56
|
+
gsub("\\e", "\e").
|
57
|
+
gsub("\\b", "\b").
|
58
|
+
gsub("\\s", "\s").
|
59
|
+
gsub(/\\([0-7]{1,3})/) { $1.to_i(8).chr }.
|
60
|
+
gsub(/\\x([0-9a-fA-F]{1,2})/) { $1.to_i(16).chr }
|
61
|
+
else
|
62
|
+
raise "Unknown quote: #{quote.inspect}."
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# "^" needs to be here because if it were among operators recognized by
|
67
|
+
# METHOD_NAME, "^=" would be recognized as two tokens.
|
68
|
+
SIMPLE_TOKENS = [
|
69
|
+
"|",
|
70
|
+
"<",
|
71
|
+
">",
|
72
|
+
",",
|
73
|
+
"=",
|
74
|
+
"^=",
|
75
|
+
"^",
|
76
|
+
"$=",
|
77
|
+
"[",
|
78
|
+
"]",
|
79
|
+
"*",
|
80
|
+
"+",
|
81
|
+
"?",
|
82
|
+
"{",
|
83
|
+
"}"
|
84
|
+
]
|
27
85
|
|
28
86
|
COMPLEX_TOKENS = [
|
29
87
|
# INTEGER needs to be before METHOD_NAME, otherwise e.g. "+1" would be
|
@@ -76,9 +134,14 @@ COMPLEX_TOKENS = [
|
|
76
134
|
)
|
77
135
|
/x
|
78
136
|
],
|
79
|
-
#
|
80
|
-
#
|
81
|
-
|
137
|
+
# ANY, EVEN and ODD need to be before METHOD_NAME, otherwise they would be
|
138
|
+
# recognized as method names.
|
139
|
+
[:ANY, /^any/],
|
140
|
+
[:EVEN, /^even/],
|
141
|
+
[:ODD, /^odd/],
|
142
|
+
# We exclude "*", "+", "<", ">", "^" and "|" from method names since they are
|
143
|
+
# lexed as simple tokens. This is because they have also other meanings in
|
144
|
+
# Machette patterns beside Ruby method names.
|
82
145
|
[
|
83
146
|
:METHOD_NAME,
|
84
147
|
/^
|
@@ -87,7 +150,7 @@ COMPLEX_TOKENS = [
|
|
87
150
|
[a-z_][a-zA-Z0-9_]*[?!=]?
|
88
151
|
|
|
89
152
|
# operator (sorted by length, then alphabetically)
|
90
|
-
(<=>|===|\[\]=|\*\*|\+@|-@|<<|<=|==|=~|>=|>>|\[\]|[
|
153
|
+
(<=>|===|\[\]=|\*\*|\+@|-@|<<|<=|==|=~|>=|>>|\[\]|[%&\-\/`~])
|
91
154
|
)
|
92
155
|
/x
|
93
156
|
],
|
@@ -152,79 +215,147 @@ end
|
|
152
215
|
##### State transition tables begin ###
|
153
216
|
|
154
217
|
racc_action_table = [
|
155
|
-
|
156
|
-
|
157
|
-
|
218
|
+
61, 1, 2, 4, 18, 19, 58, 5, 6, 1,
|
219
|
+
2, 4, 22, 23, 19, 5, 6, 25, 26, 3,
|
220
|
+
47, 48, 62, 1, 2, 4, 20, 3, 21, 5,
|
221
|
+
6, 1, 2, 4, 60, 55, 43, 5, 6, 44,
|
222
|
+
45, 3, 64, 17, 1, 2, 4, 46, 63, 3,
|
223
|
+
5, 6, 33, 34, 35, 36, 54, 19, 37, 38,
|
224
|
+
39, 53, 3, 40, 56, 29, 31, 32, 33, 34,
|
225
|
+
35, 36, 52, nil, 37, 38, 39, 50, 51, 49,
|
226
|
+
nil, 29, 31, 32 ]
|
158
227
|
|
159
228
|
racc_action_check = [
|
160
|
-
|
161
|
-
|
162
|
-
|
229
|
+
53, 21, 21, 21, 7, 16, 49, 21, 21, 0,
|
230
|
+
0, 0, 16, 16, 7, 0, 0, 16, 16, 21,
|
231
|
+
27, 27, 53, 50, 50, 50, 13, 0, 14, 50,
|
232
|
+
50, 3, 3, 3, 51, 45, 26, 3, 3, 26,
|
233
|
+
26, 50, 61, 5, 19, 19, 19, 26, 56, 3,
|
234
|
+
19, 19, 17, 17, 17, 17, 44, 59, 17, 17,
|
235
|
+
17, 43, 19, 18, 46, 17, 17, 17, 48, 48,
|
236
|
+
48, 48, 43, nil, 48, 48, 48, 30, 30, 30,
|
237
|
+
nil, 48, 48, 48 ]
|
163
238
|
|
164
239
|
racc_action_pointer = [
|
165
|
-
|
166
|
-
|
167
|
-
nil, nil,
|
240
|
+
7, nil, nil, 29, nil, 32, nil, 4, nil, nil,
|
241
|
+
nil, nil, nil, 5, 15, nil, -5, 48, 63, 42,
|
242
|
+
nil, -1, nil, nil, nil, nil, 34, 8, nil, nil,
|
243
|
+
63, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
244
|
+
nil, nil, nil, 48, 32, 11, 62, nil, 64, 3,
|
245
|
+
21, 31, nil, -2, nil, nil, 24, nil, nil, 47,
|
246
|
+
nil, 18, nil, nil, nil ]
|
168
247
|
|
169
248
|
racc_action_default = [
|
170
|
-
-
|
171
|
-
|
172
|
-
|
249
|
+
-44, -41, -42, -25, -43, -7, -40, -44, -1, -3,
|
250
|
+
-4, -5, -6, -44, -26, -27, -29, -44, -44, -44,
|
251
|
+
-24, -44, -31, -32, -30, -33, -44, -44, -9, -18,
|
252
|
+
-44, -19, -22, -15, -16, -17, -14, -23, -20, -21,
|
253
|
+
65, -2, -28, -44, -44, -44, -44, -8, -44, -44,
|
254
|
+
-44, -44, -34, -44, -38, -39, -44, -10, -13, -11,
|
255
|
+
-12, -44, -35, -36, -37 ]
|
173
256
|
|
174
257
|
racc_goto_table = [
|
175
|
-
|
176
|
-
nil, nil, nil, nil,
|
177
|
-
nil, nil, nil,
|
258
|
+
7, 28, 15, 41, 27, 13, 14, 24, nil, nil,
|
259
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
260
|
+
42, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
261
|
+
nil, nil, 57, nil, nil, nil, nil, nil, nil, nil,
|
262
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
263
|
+
59 ]
|
178
264
|
|
179
265
|
racc_goto_check = [
|
180
|
-
1,
|
181
|
-
nil, nil, nil, nil,
|
182
|
-
nil, nil, nil,
|
266
|
+
1, 8, 12, 2, 7, 10, 11, 13, nil, nil,
|
267
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
268
|
+
12, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
269
|
+
nil, nil, 8, nil, nil, nil, nil, nil, nil, nil,
|
270
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
271
|
+
1 ]
|
183
272
|
|
184
273
|
racc_goto_pointer = [
|
185
|
-
nil, 0,
|
274
|
+
nil, 0, -16, nil, nil, nil, nil, -13, -16, nil,
|
275
|
+
2, 3, -1, -9 ]
|
186
276
|
|
187
277
|
racc_goto_default = [
|
188
|
-
nil,
|
278
|
+
nil, 16, 8, 9, 10, 11, 12, nil, nil, 30,
|
279
|
+
nil, nil, nil, nil ]
|
189
280
|
|
190
281
|
racc_reduce_table = [
|
191
282
|
0, 0, :racc_error,
|
192
|
-
1,
|
193
|
-
3,
|
194
|
-
1,
|
195
|
-
1,
|
196
|
-
1,
|
197
|
-
|
198
|
-
1,
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
1,
|
206
|
-
1,
|
207
|
-
1,
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
283
|
+
1, 26, :_reduce_none,
|
284
|
+
3, 26, :_reduce_2,
|
285
|
+
1, 27, :_reduce_none,
|
286
|
+
1, 27, :_reduce_none,
|
287
|
+
1, 27, :_reduce_none,
|
288
|
+
1, 27, :_reduce_none,
|
289
|
+
1, 28, :_reduce_7,
|
290
|
+
4, 28, :_reduce_8,
|
291
|
+
1, 32, :_reduce_none,
|
292
|
+
3, 32, :_reduce_10,
|
293
|
+
3, 33, :_reduce_11,
|
294
|
+
3, 33, :_reduce_12,
|
295
|
+
3, 33, :_reduce_13,
|
296
|
+
1, 34, :_reduce_none,
|
297
|
+
1, 34, :_reduce_none,
|
298
|
+
1, 34, :_reduce_none,
|
299
|
+
1, 34, :_reduce_none,
|
300
|
+
1, 34, :_reduce_none,
|
301
|
+
1, 34, :_reduce_none,
|
302
|
+
1, 34, :_reduce_none,
|
303
|
+
1, 34, :_reduce_none,
|
304
|
+
1, 34, :_reduce_none,
|
305
|
+
1, 34, :_reduce_none,
|
306
|
+
3, 29, :_reduce_24,
|
307
|
+
0, 35, :_reduce_25,
|
308
|
+
1, 35, :_reduce_none,
|
309
|
+
1, 36, :_reduce_27,
|
310
|
+
3, 36, :_reduce_28,
|
311
|
+
1, 37, :_reduce_none,
|
312
|
+
2, 37, :_reduce_30,
|
313
|
+
1, 38, :_reduce_31,
|
314
|
+
1, 38, :_reduce_32,
|
315
|
+
1, 38, :_reduce_33,
|
316
|
+
3, 38, :_reduce_34,
|
317
|
+
4, 38, :_reduce_35,
|
318
|
+
4, 38, :_reduce_36,
|
319
|
+
5, 38, :_reduce_37,
|
320
|
+
3, 38, :_reduce_38,
|
321
|
+
3, 38, :_reduce_39,
|
322
|
+
1, 30, :_reduce_40,
|
323
|
+
1, 30, :_reduce_41,
|
324
|
+
1, 30, :_reduce_42,
|
325
|
+
1, 31, :_reduce_43 ]
|
326
|
+
|
327
|
+
racc_reduce_n = 44
|
328
|
+
|
329
|
+
racc_shift_n = 65
|
212
330
|
|
213
331
|
racc_token_table = {
|
214
332
|
false => 0,
|
215
333
|
:error => 1,
|
216
|
-
:
|
217
|
-
:
|
218
|
-
:
|
219
|
-
:
|
220
|
-
:
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
"
|
225
|
-
"
|
226
|
-
|
227
|
-
|
334
|
+
:INTEGER => 2,
|
335
|
+
:STRING => 3,
|
336
|
+
:ANY => 4,
|
337
|
+
:EVEN => 5,
|
338
|
+
:ODD => 6,
|
339
|
+
:METHOD_NAME => 7,
|
340
|
+
:CLASS_NAME => 8,
|
341
|
+
:SYMBOL => 9,
|
342
|
+
"|" => 10,
|
343
|
+
"<" => 11,
|
344
|
+
">" => 12,
|
345
|
+
"," => 13,
|
346
|
+
"=" => 14,
|
347
|
+
"^=" => 15,
|
348
|
+
"$=" => 16,
|
349
|
+
"*" => 17,
|
350
|
+
"+" => 18,
|
351
|
+
"^" => 19,
|
352
|
+
"[" => 20,
|
353
|
+
"]" => 21,
|
354
|
+
"?" => 22,
|
355
|
+
"{" => 23,
|
356
|
+
"}" => 24 }
|
357
|
+
|
358
|
+
racc_nt_base = 25
|
228
359
|
|
229
360
|
racc_use_result_var = true
|
230
361
|
|
@@ -247,24 +378,43 @@ Racc_arg = [
|
|
247
378
|
Racc_token_to_s_table = [
|
248
379
|
"$end",
|
249
380
|
"error",
|
381
|
+
"INTEGER",
|
382
|
+
"STRING",
|
383
|
+
"ANY",
|
384
|
+
"EVEN",
|
385
|
+
"ODD",
|
250
386
|
"METHOD_NAME",
|
251
387
|
"CLASS_NAME",
|
252
388
|
"SYMBOL",
|
253
|
-
"INTEGER",
|
254
|
-
"STRING",
|
255
389
|
"\"|\"",
|
256
390
|
"\"<\"",
|
257
391
|
"\">\"",
|
258
392
|
"\",\"",
|
259
393
|
"\"=\"",
|
394
|
+
"\"^=\"",
|
395
|
+
"\"$=\"",
|
396
|
+
"\"*\"",
|
397
|
+
"\"+\"",
|
398
|
+
"\"^\"",
|
399
|
+
"\"[\"",
|
400
|
+
"\"]\"",
|
401
|
+
"\"?\"",
|
402
|
+
"\"{\"",
|
403
|
+
"\"}\"",
|
260
404
|
"$start",
|
261
405
|
"expression",
|
262
406
|
"primary",
|
263
407
|
"node",
|
408
|
+
"array",
|
264
409
|
"literal",
|
410
|
+
"any",
|
265
411
|
"attrs",
|
266
412
|
"attr",
|
267
|
-
"method_name"
|
413
|
+
"method_name",
|
414
|
+
"items_opt",
|
415
|
+
"items",
|
416
|
+
"item",
|
417
|
+
"quantifier" ]
|
268
418
|
|
269
419
|
Racc_debug_parser = false
|
270
420
|
|
@@ -274,7 +424,7 @@ Racc_debug_parser = false
|
|
274
424
|
|
275
425
|
# reduce 1 omitted
|
276
426
|
|
277
|
-
module_eval(<<'.,.,', 'parser.y',
|
427
|
+
module_eval(<<'.,.,', 'parser.y', 17)
|
278
428
|
def _reduce_2(val, _values, result)
|
279
429
|
result = if val[0].is_a?(ChoiceMatcher)
|
280
430
|
ChoiceMatcher.new(val[0].alternatives << val[2])
|
@@ -290,99 +440,212 @@ module_eval(<<'.,.,', 'parser.y', 14)
|
|
290
440
|
|
291
441
|
# reduce 4 omitted
|
292
442
|
|
293
|
-
|
294
|
-
|
443
|
+
# reduce 5 omitted
|
444
|
+
|
445
|
+
# reduce 6 omitted
|
446
|
+
|
447
|
+
module_eval(<<'.,.,', 'parser.y', 30)
|
448
|
+
def _reduce_7(val, _values, result)
|
295
449
|
result = NodeMatcher.new(val[0].to_sym)
|
296
450
|
|
297
451
|
result
|
298
452
|
end
|
299
453
|
.,.,
|
300
454
|
|
301
|
-
module_eval(<<'.,.,', 'parser.y',
|
302
|
-
def
|
455
|
+
module_eval(<<'.,.,', 'parser.y', 33)
|
456
|
+
def _reduce_8(val, _values, result)
|
303
457
|
result = NodeMatcher.new(val[0].to_sym, val[2])
|
304
458
|
|
305
459
|
result
|
306
460
|
end
|
307
461
|
.,.,
|
308
462
|
|
309
|
-
# reduce
|
463
|
+
# reduce 9 omitted
|
310
464
|
|
311
|
-
module_eval(<<'.,.,', 'parser.y',
|
312
|
-
def
|
465
|
+
module_eval(<<'.,.,', 'parser.y', 37)
|
466
|
+
def _reduce_10(val, _values, result)
|
313
467
|
result = val[0].merge(val[2])
|
314
468
|
result
|
315
469
|
end
|
316
470
|
.,.,
|
317
471
|
|
318
|
-
module_eval(<<'.,.,', 'parser.y',
|
319
|
-
def
|
472
|
+
module_eval(<<'.,.,', 'parser.y', 39)
|
473
|
+
def _reduce_11(val, _values, result)
|
320
474
|
result = { val[0].to_sym => val[2] }
|
321
475
|
result
|
322
476
|
end
|
323
477
|
.,.,
|
324
478
|
|
325
|
-
|
479
|
+
module_eval(<<'.,.,', 'parser.y', 41)
|
480
|
+
def _reduce_12(val, _values, result)
|
481
|
+
result = {
|
482
|
+
val[0].to_sym => StartsWithMatcher.new(string_value(val[2]))
|
483
|
+
}
|
484
|
+
|
485
|
+
result
|
486
|
+
end
|
487
|
+
.,.,
|
488
|
+
|
489
|
+
module_eval(<<'.,.,', 'parser.y', 46)
|
490
|
+
def _reduce_13(val, _values, result)
|
491
|
+
result = {
|
492
|
+
val[0].to_sym => EndsWithMatcher.new(string_value(val[2]))
|
493
|
+
}
|
494
|
+
|
495
|
+
result
|
496
|
+
end
|
497
|
+
.,.,
|
326
498
|
|
327
|
-
# reduce
|
499
|
+
# reduce 14 omitted
|
328
500
|
|
329
|
-
# reduce
|
501
|
+
# reduce 15 omitted
|
330
502
|
|
331
|
-
# reduce
|
503
|
+
# reduce 16 omitted
|
332
504
|
|
333
|
-
|
334
|
-
|
505
|
+
# reduce 17 omitted
|
506
|
+
|
507
|
+
# reduce 18 omitted
|
508
|
+
|
509
|
+
# reduce 19 omitted
|
510
|
+
|
511
|
+
# reduce 20 omitted
|
512
|
+
|
513
|
+
# reduce 21 omitted
|
514
|
+
|
515
|
+
# reduce 22 omitted
|
516
|
+
|
517
|
+
# reduce 23 omitted
|
518
|
+
|
519
|
+
module_eval(<<'.,.,', 'parser.y', 65)
|
520
|
+
def _reduce_24(val, _values, result)
|
521
|
+
result = ArrayMatcher.new(val[1])
|
522
|
+
result
|
523
|
+
end
|
524
|
+
.,.,
|
525
|
+
|
526
|
+
module_eval(<<'.,.,', 'parser.y', 67)
|
527
|
+
def _reduce_25(val, _values, result)
|
528
|
+
result = []
|
529
|
+
result
|
530
|
+
end
|
531
|
+
.,.,
|
532
|
+
|
533
|
+
# reduce 26 omitted
|
534
|
+
|
535
|
+
module_eval(<<'.,.,', 'parser.y', 70)
|
536
|
+
def _reduce_27(val, _values, result)
|
537
|
+
result = [val[0]]
|
538
|
+
result
|
539
|
+
end
|
540
|
+
.,.,
|
541
|
+
|
542
|
+
module_eval(<<'.,.,', 'parser.y', 71)
|
543
|
+
def _reduce_28(val, _values, result)
|
544
|
+
result = val[0] << val[2]
|
545
|
+
result
|
546
|
+
end
|
547
|
+
.,.,
|
548
|
+
|
549
|
+
# reduce 29 omitted
|
550
|
+
|
551
|
+
module_eval(<<'.,.,', 'parser.y', 74)
|
552
|
+
def _reduce_30(val, _values, result)
|
553
|
+
result = Quantifier.new(val[0], *val[1])
|
554
|
+
result
|
555
|
+
end
|
556
|
+
.,.,
|
557
|
+
|
558
|
+
module_eval(<<'.,.,', 'parser.y', 76)
|
559
|
+
def _reduce_31(val, _values, result)
|
560
|
+
result = [0, nil, 1]
|
561
|
+
result
|
562
|
+
end
|
563
|
+
.,.,
|
564
|
+
|
565
|
+
module_eval(<<'.,.,', 'parser.y', 77)
|
566
|
+
def _reduce_32(val, _values, result)
|
567
|
+
result = [1, nil, 1]
|
568
|
+
result
|
569
|
+
end
|
570
|
+
.,.,
|
571
|
+
|
572
|
+
module_eval(<<'.,.,', 'parser.y', 78)
|
573
|
+
def _reduce_33(val, _values, result)
|
574
|
+
result = [0, 1, 1]
|
575
|
+
result
|
576
|
+
end
|
577
|
+
.,.,
|
578
|
+
|
579
|
+
module_eval(<<'.,.,', 'parser.y', 80)
|
580
|
+
def _reduce_34(val, _values, result)
|
581
|
+
result = [integer_value(val[1]), integer_value(val[1]), 1]
|
582
|
+
|
583
|
+
result
|
584
|
+
end
|
585
|
+
.,.,
|
586
|
+
|
587
|
+
module_eval(<<'.,.,', 'parser.y', 83)
|
588
|
+
def _reduce_35(val, _values, result)
|
589
|
+
result = [integer_value(val[1]), nil, 1]
|
590
|
+
|
591
|
+
result
|
592
|
+
end
|
593
|
+
.,.,
|
594
|
+
|
595
|
+
module_eval(<<'.,.,', 'parser.y', 86)
|
596
|
+
def _reduce_36(val, _values, result)
|
597
|
+
result = [0, integer_value(val[2]), 1]
|
598
|
+
|
599
|
+
result
|
600
|
+
end
|
601
|
+
.,.,
|
602
|
+
|
603
|
+
module_eval(<<'.,.,', 'parser.y', 89)
|
604
|
+
def _reduce_37(val, _values, result)
|
605
|
+
result = [integer_value(val[1]), integer_value(val[3]), 1]
|
606
|
+
|
607
|
+
result
|
608
|
+
end
|
609
|
+
.,.,
|
610
|
+
|
611
|
+
module_eval(<<'.,.,', 'parser.y', 91)
|
612
|
+
def _reduce_38(val, _values, result)
|
613
|
+
result = [0, nil, 2]
|
614
|
+
result
|
615
|
+
end
|
616
|
+
.,.,
|
617
|
+
|
618
|
+
module_eval(<<'.,.,', 'parser.y', 92)
|
619
|
+
def _reduce_39(val, _values, result)
|
620
|
+
result = [1, nil, 2]
|
621
|
+
result
|
622
|
+
end
|
623
|
+
.,.,
|
624
|
+
|
625
|
+
module_eval(<<'.,.,', 'parser.y', 94)
|
626
|
+
def _reduce_40(val, _values, result)
|
335
627
|
result = LiteralMatcher.new(val[0][1..-1].to_sym)
|
336
628
|
result
|
337
629
|
end
|
338
630
|
.,.,
|
339
631
|
|
340
|
-
module_eval(<<'.,.,', 'parser.y',
|
341
|
-
def
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
elsif val[0] =~ /^0/
|
351
|
-
val[0][1..-1].to_i(8)
|
352
|
-
else
|
353
|
-
val[0].to_i
|
354
|
-
end
|
355
|
-
result = LiteralMatcher.new(value)
|
356
|
-
|
632
|
+
module_eval(<<'.,.,', 'parser.y', 95)
|
633
|
+
def _reduce_41(val, _values, result)
|
634
|
+
result = LiteralMatcher.new(integer_value(val[0]))
|
635
|
+
result
|
636
|
+
end
|
637
|
+
.,.,
|
638
|
+
|
639
|
+
module_eval(<<'.,.,', 'parser.y', 96)
|
640
|
+
def _reduce_42(val, _values, result)
|
641
|
+
result = LiteralMatcher.new(string_value(val[0]))
|
357
642
|
result
|
358
643
|
end
|
359
644
|
.,.,
|
360
645
|
|
361
|
-
module_eval(<<'.,.,', 'parser.y',
|
362
|
-
def
|
363
|
-
|
364
|
-
value = if quote == "'"
|
365
|
-
val[0][1..-2].gsub("\\\\", "\\").gsub("\\'", "'")
|
366
|
-
elsif quote == '"'
|
367
|
-
val[0][1..-2].
|
368
|
-
gsub("\\\\", "\\").
|
369
|
-
gsub('\\"', '"').
|
370
|
-
gsub("\\n", "\n").
|
371
|
-
gsub("\\t", "\t").
|
372
|
-
gsub("\\r", "\r").
|
373
|
-
gsub("\\f", "\f").
|
374
|
-
gsub("\\v", "\v").
|
375
|
-
gsub("\\a", "\a").
|
376
|
-
gsub("\\e", "\e").
|
377
|
-
gsub("\\b", "\b").
|
378
|
-
gsub("\\s", "\s").
|
379
|
-
gsub(/\\([0-7]{1,3})/) { $1.to_i(8).chr }.
|
380
|
-
gsub(/\\x([0-9a-fA-F]{1,2})/) { $1.to_i(16).chr }
|
381
|
-
else
|
382
|
-
raise "Unknown quote: #{quote.inspect}."
|
383
|
-
end
|
384
|
-
result = LiteralMatcher.new(value)
|
385
|
-
|
646
|
+
module_eval(<<'.,.,', 'parser.y', 98)
|
647
|
+
def _reduce_43(val, _values, result)
|
648
|
+
result = AnyMatcher.new
|
386
649
|
result
|
387
650
|
end
|
388
651
|
.,.,
|