edn-abnf 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/edn-abnf +57 -0
- data/edn-abnf.gemspec +20 -0
- data/lib/edn-abnf.rb +41 -0
- data/lib/parser/edn-util.rb +19 -0
- data/lib/parser/edngrammar.rb +3736 -0
- metadata +105 -0
@@ -0,0 +1,3736 @@
|
|
1
|
+
# Encoding: UTF-8
|
2
|
+
# Autogenerated from a Treetop grammar. Edits may be lost.
|
3
|
+
|
4
|
+
|
5
|
+
module EDNGRAMMAR
|
6
|
+
include Treetop::Runtime
|
7
|
+
|
8
|
+
def root
|
9
|
+
@root ||= :seq
|
10
|
+
end
|
11
|
+
|
12
|
+
module Seq0
|
13
|
+
def S1
|
14
|
+
elements[1]
|
15
|
+
end
|
16
|
+
|
17
|
+
def item
|
18
|
+
elements[2]
|
19
|
+
end
|
20
|
+
|
21
|
+
def S2
|
22
|
+
elements[3]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module Seq1
|
27
|
+
def item
|
28
|
+
elements[0]
|
29
|
+
end
|
30
|
+
|
31
|
+
def S
|
32
|
+
elements[1]
|
33
|
+
end
|
34
|
+
|
35
|
+
def OC
|
36
|
+
elements[3]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
module Seq2
|
41
|
+
def S1
|
42
|
+
elements[0]
|
43
|
+
end
|
44
|
+
|
45
|
+
def S2
|
46
|
+
elements[2]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
module Seq3
|
51
|
+
def ast
|
52
|
+
r = if e = elements[1].elements
|
53
|
+
[e[0].ast] + e[2].elements.map {|x| x.item.ast }
|
54
|
+
else
|
55
|
+
[]
|
56
|
+
end
|
57
|
+
if r.size == 1
|
58
|
+
r.first
|
59
|
+
else
|
60
|
+
CBOR::Sequence.new(r)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def _nt_seq
|
66
|
+
start_index = index
|
67
|
+
if node_cache[:seq].has_key?(index)
|
68
|
+
cached = node_cache[:seq][index]
|
69
|
+
if cached
|
70
|
+
node_cache[:seq][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
71
|
+
@index = cached.interval.end
|
72
|
+
end
|
73
|
+
return cached
|
74
|
+
end
|
75
|
+
|
76
|
+
i0, s0 = index, []
|
77
|
+
r1 = _nt_S
|
78
|
+
s0 << r1
|
79
|
+
if r1
|
80
|
+
i3, s3 = index, []
|
81
|
+
r4 = _nt_item
|
82
|
+
s3 << r4
|
83
|
+
if r4
|
84
|
+
r5 = _nt_S
|
85
|
+
s3 << r5
|
86
|
+
if r5
|
87
|
+
s6, i6 = [], index
|
88
|
+
loop do
|
89
|
+
i7, s7 = index, []
|
90
|
+
if (match_len = has_terminal?(",", false, index))
|
91
|
+
r8 = true
|
92
|
+
@index += match_len
|
93
|
+
else
|
94
|
+
terminal_parse_failure('","')
|
95
|
+
r8 = nil
|
96
|
+
end
|
97
|
+
s7 << r8
|
98
|
+
if r8
|
99
|
+
r9 = _nt_S
|
100
|
+
s7 << r9
|
101
|
+
if r9
|
102
|
+
r10 = _nt_item
|
103
|
+
s7 << r10
|
104
|
+
if r10
|
105
|
+
r11 = _nt_S
|
106
|
+
s7 << r11
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
if s7.last
|
111
|
+
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
112
|
+
r7.extend(Seq0)
|
113
|
+
else
|
114
|
+
@index = i7
|
115
|
+
r7 = nil
|
116
|
+
end
|
117
|
+
if r7
|
118
|
+
s6 << r7
|
119
|
+
else
|
120
|
+
break
|
121
|
+
end
|
122
|
+
end
|
123
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
124
|
+
s3 << r6
|
125
|
+
if r6
|
126
|
+
r12 = _nt_OC
|
127
|
+
s3 << r12
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
if s3.last
|
132
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
133
|
+
r3.extend(Seq1)
|
134
|
+
else
|
135
|
+
@index = i3
|
136
|
+
r3 = nil
|
137
|
+
end
|
138
|
+
if r3
|
139
|
+
r2 = r3
|
140
|
+
else
|
141
|
+
r2 = instantiate_node(SyntaxNode,input, index...index)
|
142
|
+
end
|
143
|
+
s0 << r2
|
144
|
+
if r2
|
145
|
+
r13 = _nt_S
|
146
|
+
s0 << r13
|
147
|
+
end
|
148
|
+
end
|
149
|
+
if s0.last
|
150
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
151
|
+
r0.extend(Seq2)
|
152
|
+
r0.extend(Seq3)
|
153
|
+
else
|
154
|
+
@index = i0
|
155
|
+
r0 = nil
|
156
|
+
end
|
157
|
+
|
158
|
+
node_cache[:seq][start_index] = r0
|
159
|
+
|
160
|
+
r0
|
161
|
+
end
|
162
|
+
|
163
|
+
def _nt_item
|
164
|
+
start_index = index
|
165
|
+
if node_cache[:item].has_key?(index)
|
166
|
+
cached = node_cache[:item][index]
|
167
|
+
if cached
|
168
|
+
node_cache[:item][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
169
|
+
@index = cached.interval.end
|
170
|
+
end
|
171
|
+
return cached
|
172
|
+
end
|
173
|
+
|
174
|
+
i0 = index
|
175
|
+
r1 = _nt_map
|
176
|
+
if r1
|
177
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
178
|
+
r0 = r1
|
179
|
+
else
|
180
|
+
r2 = _nt_array
|
181
|
+
if r2
|
182
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
183
|
+
r0 = r2
|
184
|
+
else
|
185
|
+
r3 = _nt_tagged
|
186
|
+
if r3
|
187
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
188
|
+
r0 = r3
|
189
|
+
else
|
190
|
+
r4 = _nt_basenumber
|
191
|
+
if r4
|
192
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
193
|
+
r0 = r4
|
194
|
+
else
|
195
|
+
r5 = _nt_decnumber
|
196
|
+
if r5
|
197
|
+
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
198
|
+
r0 = r5
|
199
|
+
else
|
200
|
+
r6 = _nt_infin
|
201
|
+
if r6
|
202
|
+
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
203
|
+
r0 = r6
|
204
|
+
else
|
205
|
+
r7 = _nt_simple
|
206
|
+
if r7
|
207
|
+
r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
|
208
|
+
r0 = r7
|
209
|
+
else
|
210
|
+
r8 = _nt_tstr
|
211
|
+
if r8
|
212
|
+
r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
|
213
|
+
r0 = r8
|
214
|
+
else
|
215
|
+
r9 = _nt_bstr
|
216
|
+
if r9
|
217
|
+
r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
|
218
|
+
r0 = r9
|
219
|
+
else
|
220
|
+
r10 = _nt_embedded
|
221
|
+
if r10
|
222
|
+
r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
|
223
|
+
r0 = r10
|
224
|
+
else
|
225
|
+
r11 = _nt_streamstring
|
226
|
+
if r11
|
227
|
+
r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
|
228
|
+
r0 = r11
|
229
|
+
else
|
230
|
+
@index = i0
|
231
|
+
r0 = nil
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
node_cache[:item][start_index] = r0
|
245
|
+
|
246
|
+
r0
|
247
|
+
end
|
248
|
+
|
249
|
+
def _nt_sign
|
250
|
+
start_index = index
|
251
|
+
if node_cache[:sign].has_key?(index)
|
252
|
+
cached = node_cache[:sign][index]
|
253
|
+
if cached
|
254
|
+
node_cache[:sign][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
255
|
+
@index = cached.interval.end
|
256
|
+
end
|
257
|
+
return cached
|
258
|
+
end
|
259
|
+
|
260
|
+
i0 = index
|
261
|
+
if (match_len = has_terminal?("+", false, index))
|
262
|
+
r1 = true
|
263
|
+
@index += match_len
|
264
|
+
else
|
265
|
+
terminal_parse_failure('"+"')
|
266
|
+
r1 = nil
|
267
|
+
end
|
268
|
+
if r1
|
269
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
270
|
+
r0 = r1
|
271
|
+
else
|
272
|
+
if (match_len = has_terminal?("-", false, index))
|
273
|
+
r2 = true
|
274
|
+
@index += match_len
|
275
|
+
else
|
276
|
+
terminal_parse_failure('"-"')
|
277
|
+
r2 = nil
|
278
|
+
end
|
279
|
+
if r2
|
280
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
281
|
+
r0 = r2
|
282
|
+
else
|
283
|
+
@index = i0
|
284
|
+
r0 = nil
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
node_cache[:sign][start_index] = r0
|
289
|
+
|
290
|
+
r0
|
291
|
+
end
|
292
|
+
|
293
|
+
module Decnumber0
|
294
|
+
end
|
295
|
+
|
296
|
+
module Decnumber1
|
297
|
+
end
|
298
|
+
|
299
|
+
module Decnumber2
|
300
|
+
end
|
301
|
+
|
302
|
+
module Decnumber3
|
303
|
+
def ast
|
304
|
+
ip = elements[0].text_value + elements[1].text_value
|
305
|
+
dp = elements[2].text_value
|
306
|
+
ep = elements[3].text_value
|
307
|
+
if dp.empty? && ep.empty?
|
308
|
+
ip.to_i
|
309
|
+
else
|
310
|
+
(ip + dp + ep).to_f
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
def _nt_decnumber
|
316
|
+
start_index = index
|
317
|
+
if node_cache[:decnumber].has_key?(index)
|
318
|
+
cached = node_cache[:decnumber][index]
|
319
|
+
if cached
|
320
|
+
node_cache[:decnumber][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
321
|
+
@index = cached.interval.end
|
322
|
+
end
|
323
|
+
return cached
|
324
|
+
end
|
325
|
+
|
326
|
+
i0, s0 = index, []
|
327
|
+
r2 = _nt_sign
|
328
|
+
if r2
|
329
|
+
r1 = r2
|
330
|
+
else
|
331
|
+
r1 = instantiate_node(SyntaxNode,input, index...index)
|
332
|
+
end
|
333
|
+
s0 << r1
|
334
|
+
if r1
|
335
|
+
s3, i3 = [], index
|
336
|
+
loop do
|
337
|
+
r4 = _nt_DIGIT
|
338
|
+
if r4
|
339
|
+
s3 << r4
|
340
|
+
else
|
341
|
+
break
|
342
|
+
end
|
343
|
+
end
|
344
|
+
if s3.empty?
|
345
|
+
@index = i3
|
346
|
+
r3 = nil
|
347
|
+
else
|
348
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
349
|
+
end
|
350
|
+
s0 << r3
|
351
|
+
if r3
|
352
|
+
i6, s6 = index, []
|
353
|
+
if (match_len = has_terminal?(".", false, index))
|
354
|
+
r7 = true
|
355
|
+
@index += match_len
|
356
|
+
else
|
357
|
+
terminal_parse_failure('"."')
|
358
|
+
r7 = nil
|
359
|
+
end
|
360
|
+
s6 << r7
|
361
|
+
if r7
|
362
|
+
s8, i8 = [], index
|
363
|
+
loop do
|
364
|
+
r9 = _nt_DIGIT
|
365
|
+
if r9
|
366
|
+
s8 << r9
|
367
|
+
else
|
368
|
+
break
|
369
|
+
end
|
370
|
+
end
|
371
|
+
if s8.empty?
|
372
|
+
@index = i8
|
373
|
+
r8 = nil
|
374
|
+
else
|
375
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
376
|
+
end
|
377
|
+
s6 << r8
|
378
|
+
end
|
379
|
+
if s6.last
|
380
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
381
|
+
r6.extend(Decnumber0)
|
382
|
+
else
|
383
|
+
@index = i6
|
384
|
+
r6 = nil
|
385
|
+
end
|
386
|
+
if r6
|
387
|
+
r5 = r6
|
388
|
+
else
|
389
|
+
r5 = instantiate_node(SyntaxNode,input, index...index)
|
390
|
+
end
|
391
|
+
s0 << r5
|
392
|
+
if r5
|
393
|
+
i11, s11 = index, []
|
394
|
+
if (match_len = has_terminal?("e", :insens, index))
|
395
|
+
r12 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
396
|
+
@index += match_len
|
397
|
+
else
|
398
|
+
terminal_parse_failure('"e"')
|
399
|
+
r12 = nil
|
400
|
+
end
|
401
|
+
s11 << r12
|
402
|
+
if r12
|
403
|
+
r14 = _nt_sign
|
404
|
+
if r14
|
405
|
+
r13 = r14
|
406
|
+
else
|
407
|
+
r13 = instantiate_node(SyntaxNode,input, index...index)
|
408
|
+
end
|
409
|
+
s11 << r13
|
410
|
+
if r13
|
411
|
+
s15, i15 = [], index
|
412
|
+
loop do
|
413
|
+
r16 = _nt_DIGIT
|
414
|
+
if r16
|
415
|
+
s15 << r16
|
416
|
+
else
|
417
|
+
break
|
418
|
+
end
|
419
|
+
end
|
420
|
+
if s15.empty?
|
421
|
+
@index = i15
|
422
|
+
r15 = nil
|
423
|
+
else
|
424
|
+
r15 = instantiate_node(SyntaxNode,input, i15...index, s15)
|
425
|
+
end
|
426
|
+
s11 << r15
|
427
|
+
end
|
428
|
+
end
|
429
|
+
if s11.last
|
430
|
+
r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
|
431
|
+
r11.extend(Decnumber1)
|
432
|
+
else
|
433
|
+
@index = i11
|
434
|
+
r11 = nil
|
435
|
+
end
|
436
|
+
if r11
|
437
|
+
r10 = r11
|
438
|
+
else
|
439
|
+
r10 = instantiate_node(SyntaxNode,input, index...index)
|
440
|
+
end
|
441
|
+
s0 << r10
|
442
|
+
end
|
443
|
+
end
|
444
|
+
end
|
445
|
+
if s0.last
|
446
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
447
|
+
r0.extend(Decnumber2)
|
448
|
+
r0.extend(Decnumber3)
|
449
|
+
else
|
450
|
+
@index = i0
|
451
|
+
r0 = nil
|
452
|
+
end
|
453
|
+
|
454
|
+
node_cache[:decnumber][start_index] = r0
|
455
|
+
|
456
|
+
r0
|
457
|
+
end
|
458
|
+
|
459
|
+
module Basenumber0
|
460
|
+
end
|
461
|
+
|
462
|
+
module Basenumber1
|
463
|
+
end
|
464
|
+
|
465
|
+
module Basenumber2
|
466
|
+
end
|
467
|
+
|
468
|
+
module Basenumber3
|
469
|
+
end
|
470
|
+
|
471
|
+
module Basenumber4
|
472
|
+
def ast; Integer(text_value) end
|
473
|
+
end
|
474
|
+
|
475
|
+
def _nt_basenumber
|
476
|
+
start_index = index
|
477
|
+
if node_cache[:basenumber].has_key?(index)
|
478
|
+
cached = node_cache[:basenumber][index]
|
479
|
+
if cached
|
480
|
+
node_cache[:basenumber][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
481
|
+
@index = cached.interval.end
|
482
|
+
end
|
483
|
+
return cached
|
484
|
+
end
|
485
|
+
|
486
|
+
i0, s0 = index, []
|
487
|
+
r2 = _nt_sign
|
488
|
+
if r2
|
489
|
+
r1 = r2
|
490
|
+
else
|
491
|
+
r1 = instantiate_node(SyntaxNode,input, index...index)
|
492
|
+
end
|
493
|
+
s0 << r1
|
494
|
+
if r1
|
495
|
+
if (match_len = has_terminal?("0", false, index))
|
496
|
+
r3 = true
|
497
|
+
@index += match_len
|
498
|
+
else
|
499
|
+
terminal_parse_failure('"0"')
|
500
|
+
r3 = nil
|
501
|
+
end
|
502
|
+
s0 << r3
|
503
|
+
if r3
|
504
|
+
i4 = index
|
505
|
+
i5, s5 = index, []
|
506
|
+
if (match_len = has_terminal?("x", :insens, index))
|
507
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
508
|
+
@index += match_len
|
509
|
+
else
|
510
|
+
terminal_parse_failure('"x"')
|
511
|
+
r6 = nil
|
512
|
+
end
|
513
|
+
s5 << r6
|
514
|
+
if r6
|
515
|
+
s7, i7 = [], index
|
516
|
+
loop do
|
517
|
+
r8 = _nt_HEXDIG
|
518
|
+
if r8
|
519
|
+
s7 << r8
|
520
|
+
else
|
521
|
+
break
|
522
|
+
end
|
523
|
+
end
|
524
|
+
if s7.empty?
|
525
|
+
@index = i7
|
526
|
+
r7 = nil
|
527
|
+
else
|
528
|
+
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
529
|
+
end
|
530
|
+
s5 << r7
|
531
|
+
end
|
532
|
+
if s5.last
|
533
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
534
|
+
r5.extend(Basenumber0)
|
535
|
+
else
|
536
|
+
@index = i5
|
537
|
+
r5 = nil
|
538
|
+
end
|
539
|
+
if r5
|
540
|
+
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
541
|
+
r4 = r5
|
542
|
+
else
|
543
|
+
i9, s9 = index, []
|
544
|
+
if (match_len = has_terminal?("o", :insens, index))
|
545
|
+
r10 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
546
|
+
@index += match_len
|
547
|
+
else
|
548
|
+
terminal_parse_failure('"o"')
|
549
|
+
r10 = nil
|
550
|
+
end
|
551
|
+
s9 << r10
|
552
|
+
if r10
|
553
|
+
s11, i11 = [], index
|
554
|
+
loop do
|
555
|
+
r12 = _nt_ODIGIT
|
556
|
+
if r12
|
557
|
+
s11 << r12
|
558
|
+
else
|
559
|
+
break
|
560
|
+
end
|
561
|
+
end
|
562
|
+
if s11.empty?
|
563
|
+
@index = i11
|
564
|
+
r11 = nil
|
565
|
+
else
|
566
|
+
r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
|
567
|
+
end
|
568
|
+
s9 << r11
|
569
|
+
end
|
570
|
+
if s9.last
|
571
|
+
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
572
|
+
r9.extend(Basenumber1)
|
573
|
+
else
|
574
|
+
@index = i9
|
575
|
+
r9 = nil
|
576
|
+
end
|
577
|
+
if r9
|
578
|
+
r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
|
579
|
+
r4 = r9
|
580
|
+
else
|
581
|
+
i13, s13 = index, []
|
582
|
+
if (match_len = has_terminal?("b", :insens, index))
|
583
|
+
r14 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
584
|
+
@index += match_len
|
585
|
+
else
|
586
|
+
terminal_parse_failure('"b"')
|
587
|
+
r14 = nil
|
588
|
+
end
|
589
|
+
s13 << r14
|
590
|
+
if r14
|
591
|
+
s15, i15 = [], index
|
592
|
+
loop do
|
593
|
+
r16 = _nt_BDIGIT
|
594
|
+
if r16
|
595
|
+
s15 << r16
|
596
|
+
else
|
597
|
+
break
|
598
|
+
end
|
599
|
+
end
|
600
|
+
if s15.empty?
|
601
|
+
@index = i15
|
602
|
+
r15 = nil
|
603
|
+
else
|
604
|
+
r15 = instantiate_node(SyntaxNode,input, i15...index, s15)
|
605
|
+
end
|
606
|
+
s13 << r15
|
607
|
+
end
|
608
|
+
if s13.last
|
609
|
+
r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
|
610
|
+
r13.extend(Basenumber2)
|
611
|
+
else
|
612
|
+
@index = i13
|
613
|
+
r13 = nil
|
614
|
+
end
|
615
|
+
if r13
|
616
|
+
r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true
|
617
|
+
r4 = r13
|
618
|
+
else
|
619
|
+
@index = i4
|
620
|
+
r4 = nil
|
621
|
+
end
|
622
|
+
end
|
623
|
+
end
|
624
|
+
s0 << r4
|
625
|
+
end
|
626
|
+
end
|
627
|
+
if s0.last
|
628
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
629
|
+
r0.extend(Basenumber3)
|
630
|
+
r0.extend(Basenumber4)
|
631
|
+
else
|
632
|
+
@index = i0
|
633
|
+
r0 = nil
|
634
|
+
end
|
635
|
+
|
636
|
+
node_cache[:basenumber][start_index] = r0
|
637
|
+
|
638
|
+
r0
|
639
|
+
end
|
640
|
+
|
641
|
+
module Infin0
|
642
|
+
def ast; Float::INFINITY end
|
643
|
+
end
|
644
|
+
|
645
|
+
module Infin1
|
646
|
+
def ast; -Float::INFINITY end
|
647
|
+
end
|
648
|
+
|
649
|
+
module Infin2
|
650
|
+
def ast; Float::NAN end
|
651
|
+
end
|
652
|
+
|
653
|
+
def _nt_infin
|
654
|
+
start_index = index
|
655
|
+
if node_cache[:infin].has_key?(index)
|
656
|
+
cached = node_cache[:infin][index]
|
657
|
+
if cached
|
658
|
+
node_cache[:infin][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
659
|
+
@index = cached.interval.end
|
660
|
+
end
|
661
|
+
return cached
|
662
|
+
end
|
663
|
+
|
664
|
+
i0 = index
|
665
|
+
if (match_len = has_terminal?("Infinity", false, index))
|
666
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
667
|
+
r1.extend(Infin0)
|
668
|
+
@index += match_len
|
669
|
+
else
|
670
|
+
terminal_parse_failure('"Infinity"')
|
671
|
+
r1 = nil
|
672
|
+
end
|
673
|
+
if r1
|
674
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
675
|
+
r0 = r1
|
676
|
+
else
|
677
|
+
if (match_len = has_terminal?("-Infinity", false, index))
|
678
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
679
|
+
r2.extend(Infin1)
|
680
|
+
@index += match_len
|
681
|
+
else
|
682
|
+
terminal_parse_failure('"-Infinity"')
|
683
|
+
r2 = nil
|
684
|
+
end
|
685
|
+
if r2
|
686
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
687
|
+
r0 = r2
|
688
|
+
else
|
689
|
+
if (match_len = has_terminal?("NaN", false, index))
|
690
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
691
|
+
r3.extend(Infin2)
|
692
|
+
@index += match_len
|
693
|
+
else
|
694
|
+
terminal_parse_failure('"NaN"')
|
695
|
+
r3 = nil
|
696
|
+
end
|
697
|
+
if r3
|
698
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
699
|
+
r0 = r3
|
700
|
+
else
|
701
|
+
@index = i0
|
702
|
+
r0 = nil
|
703
|
+
end
|
704
|
+
end
|
705
|
+
end
|
706
|
+
|
707
|
+
node_cache[:infin][start_index] = r0
|
708
|
+
|
709
|
+
r0
|
710
|
+
end
|
711
|
+
|
712
|
+
module Simple0
|
713
|
+
def ast; false end
|
714
|
+
end
|
715
|
+
|
716
|
+
module Simple1
|
717
|
+
def ast; true end
|
718
|
+
end
|
719
|
+
|
720
|
+
module Simple2
|
721
|
+
def ast; nil end
|
722
|
+
end
|
723
|
+
|
724
|
+
module Simple3
|
725
|
+
def ast; CBOR::Simple.new(23) end
|
726
|
+
end
|
727
|
+
|
728
|
+
module Simple4
|
729
|
+
def S1
|
730
|
+
elements[1]
|
731
|
+
end
|
732
|
+
|
733
|
+
def item
|
734
|
+
elements[2]
|
735
|
+
end
|
736
|
+
|
737
|
+
def S2
|
738
|
+
elements[3]
|
739
|
+
end
|
740
|
+
|
741
|
+
end
|
742
|
+
|
743
|
+
module Simple5
|
744
|
+
def ast; CBOR::Simple.new(item.ast) end
|
745
|
+
end
|
746
|
+
|
747
|
+
def _nt_simple
|
748
|
+
start_index = index
|
749
|
+
if node_cache[:simple].has_key?(index)
|
750
|
+
cached = node_cache[:simple][index]
|
751
|
+
if cached
|
752
|
+
node_cache[:simple][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
753
|
+
@index = cached.interval.end
|
754
|
+
end
|
755
|
+
return cached
|
756
|
+
end
|
757
|
+
|
758
|
+
i0 = index
|
759
|
+
if (match_len = has_terminal?("false", false, index))
|
760
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
761
|
+
r1.extend(Simple0)
|
762
|
+
@index += match_len
|
763
|
+
else
|
764
|
+
terminal_parse_failure('"false"')
|
765
|
+
r1 = nil
|
766
|
+
end
|
767
|
+
if r1
|
768
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
769
|
+
r0 = r1
|
770
|
+
else
|
771
|
+
if (match_len = has_terminal?("true", false, index))
|
772
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
773
|
+
r2.extend(Simple1)
|
774
|
+
@index += match_len
|
775
|
+
else
|
776
|
+
terminal_parse_failure('"true"')
|
777
|
+
r2 = nil
|
778
|
+
end
|
779
|
+
if r2
|
780
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
781
|
+
r0 = r2
|
782
|
+
else
|
783
|
+
if (match_len = has_terminal?("null", false, index))
|
784
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
785
|
+
r3.extend(Simple2)
|
786
|
+
@index += match_len
|
787
|
+
else
|
788
|
+
terminal_parse_failure('"null"')
|
789
|
+
r3 = nil
|
790
|
+
end
|
791
|
+
if r3
|
792
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
793
|
+
r0 = r3
|
794
|
+
else
|
795
|
+
if (match_len = has_terminal?("undefined", false, index))
|
796
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
797
|
+
r4.extend(Simple3)
|
798
|
+
@index += match_len
|
799
|
+
else
|
800
|
+
terminal_parse_failure('"undefined"')
|
801
|
+
r4 = nil
|
802
|
+
end
|
803
|
+
if r4
|
804
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
805
|
+
r0 = r4
|
806
|
+
else
|
807
|
+
i5, s5 = index, []
|
808
|
+
if (match_len = has_terminal?("simple(", false, index))
|
809
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
810
|
+
@index += match_len
|
811
|
+
else
|
812
|
+
terminal_parse_failure('"simple("')
|
813
|
+
r6 = nil
|
814
|
+
end
|
815
|
+
s5 << r6
|
816
|
+
if r6
|
817
|
+
r7 = _nt_S
|
818
|
+
s5 << r7
|
819
|
+
if r7
|
820
|
+
r8 = _nt_item
|
821
|
+
s5 << r8
|
822
|
+
if r8
|
823
|
+
r9 = _nt_S
|
824
|
+
s5 << r9
|
825
|
+
if r9
|
826
|
+
if (match_len = has_terminal?(")", false, index))
|
827
|
+
r10 = true
|
828
|
+
@index += match_len
|
829
|
+
else
|
830
|
+
terminal_parse_failure('")"')
|
831
|
+
r10 = nil
|
832
|
+
end
|
833
|
+
s5 << r10
|
834
|
+
end
|
835
|
+
end
|
836
|
+
end
|
837
|
+
end
|
838
|
+
if s5.last
|
839
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
840
|
+
r5.extend(Simple4)
|
841
|
+
r5.extend(Simple5)
|
842
|
+
else
|
843
|
+
@index = i5
|
844
|
+
r5 = nil
|
845
|
+
end
|
846
|
+
if r5
|
847
|
+
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
848
|
+
r0 = r5
|
849
|
+
else
|
850
|
+
@index = i0
|
851
|
+
r0 = nil
|
852
|
+
end
|
853
|
+
end
|
854
|
+
end
|
855
|
+
end
|
856
|
+
end
|
857
|
+
|
858
|
+
node_cache[:simple][start_index] = r0
|
859
|
+
|
860
|
+
r0
|
861
|
+
end
|
862
|
+
|
863
|
+
module Uint0
|
864
|
+
def DIGIT1
|
865
|
+
elements[0]
|
866
|
+
end
|
867
|
+
|
868
|
+
end
|
869
|
+
|
870
|
+
def _nt_uint
|
871
|
+
start_index = index
|
872
|
+
if node_cache[:uint].has_key?(index)
|
873
|
+
cached = node_cache[:uint][index]
|
874
|
+
if cached
|
875
|
+
node_cache[:uint][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
876
|
+
@index = cached.interval.end
|
877
|
+
end
|
878
|
+
return cached
|
879
|
+
end
|
880
|
+
|
881
|
+
i0 = index
|
882
|
+
if (match_len = has_terminal?("0", false, index))
|
883
|
+
r1 = true
|
884
|
+
@index += match_len
|
885
|
+
else
|
886
|
+
terminal_parse_failure('"0"')
|
887
|
+
r1 = nil
|
888
|
+
end
|
889
|
+
if r1
|
890
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
891
|
+
r0 = r1
|
892
|
+
else
|
893
|
+
i2, s2 = index, []
|
894
|
+
r3 = _nt_DIGIT1
|
895
|
+
s2 << r3
|
896
|
+
if r3
|
897
|
+
s4, i4 = [], index
|
898
|
+
loop do
|
899
|
+
r5 = _nt_DIGIT
|
900
|
+
if r5
|
901
|
+
s4 << r5
|
902
|
+
else
|
903
|
+
break
|
904
|
+
end
|
905
|
+
end
|
906
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
907
|
+
s2 << r4
|
908
|
+
end
|
909
|
+
if s2.last
|
910
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
911
|
+
r2.extend(Uint0)
|
912
|
+
else
|
913
|
+
@index = i2
|
914
|
+
r2 = nil
|
915
|
+
end
|
916
|
+
if r2
|
917
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
918
|
+
r0 = r2
|
919
|
+
else
|
920
|
+
@index = i0
|
921
|
+
r0 = nil
|
922
|
+
end
|
923
|
+
end
|
924
|
+
|
925
|
+
node_cache[:uint][start_index] = r0
|
926
|
+
|
927
|
+
r0
|
928
|
+
end
|
929
|
+
|
930
|
+
module Tagged0
|
931
|
+
def uint
|
932
|
+
elements[0]
|
933
|
+
end
|
934
|
+
|
935
|
+
def S1
|
936
|
+
elements[2]
|
937
|
+
end
|
938
|
+
|
939
|
+
def item
|
940
|
+
elements[3]
|
941
|
+
end
|
942
|
+
|
943
|
+
def S2
|
944
|
+
elements[4]
|
945
|
+
end
|
946
|
+
|
947
|
+
end
|
948
|
+
|
949
|
+
module Tagged1
|
950
|
+
def ast
|
951
|
+
CBOR::Tagged.new(uint.text_value.to_i, item.ast)
|
952
|
+
end
|
953
|
+
end
|
954
|
+
|
955
|
+
def _nt_tagged
|
956
|
+
start_index = index
|
957
|
+
if node_cache[:tagged].has_key?(index)
|
958
|
+
cached = node_cache[:tagged][index]
|
959
|
+
if cached
|
960
|
+
node_cache[:tagged][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
961
|
+
@index = cached.interval.end
|
962
|
+
end
|
963
|
+
return cached
|
964
|
+
end
|
965
|
+
|
966
|
+
i0, s0 = index, []
|
967
|
+
r1 = _nt_uint
|
968
|
+
s0 << r1
|
969
|
+
if r1
|
970
|
+
if (match_len = has_terminal?("(", false, index))
|
971
|
+
r2 = true
|
972
|
+
@index += match_len
|
973
|
+
else
|
974
|
+
terminal_parse_failure('"("')
|
975
|
+
r2 = nil
|
976
|
+
end
|
977
|
+
s0 << r2
|
978
|
+
if r2
|
979
|
+
r3 = _nt_S
|
980
|
+
s0 << r3
|
981
|
+
if r3
|
982
|
+
r4 = _nt_item
|
983
|
+
s0 << r4
|
984
|
+
if r4
|
985
|
+
r5 = _nt_S
|
986
|
+
s0 << r5
|
987
|
+
if r5
|
988
|
+
if (match_len = has_terminal?(")", false, index))
|
989
|
+
r6 = true
|
990
|
+
@index += match_len
|
991
|
+
else
|
992
|
+
terminal_parse_failure('")"')
|
993
|
+
r6 = nil
|
994
|
+
end
|
995
|
+
s0 << r6
|
996
|
+
end
|
997
|
+
end
|
998
|
+
end
|
999
|
+
end
|
1000
|
+
end
|
1001
|
+
if s0.last
|
1002
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1003
|
+
r0.extend(Tagged0)
|
1004
|
+
r0.extend(Tagged1)
|
1005
|
+
else
|
1006
|
+
@index = i0
|
1007
|
+
r0 = nil
|
1008
|
+
end
|
1009
|
+
|
1010
|
+
node_cache[:tagged][start_index] = r0
|
1011
|
+
|
1012
|
+
r0
|
1013
|
+
end
|
1014
|
+
|
1015
|
+
module AppPrefix0
|
1016
|
+
def lcalpha
|
1017
|
+
elements[0]
|
1018
|
+
end
|
1019
|
+
|
1020
|
+
end
|
1021
|
+
|
1022
|
+
def _nt_app_prefix
|
1023
|
+
start_index = index
|
1024
|
+
if node_cache[:app_prefix].has_key?(index)
|
1025
|
+
cached = node_cache[:app_prefix][index]
|
1026
|
+
if cached
|
1027
|
+
node_cache[:app_prefix][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1028
|
+
@index = cached.interval.end
|
1029
|
+
end
|
1030
|
+
return cached
|
1031
|
+
end
|
1032
|
+
|
1033
|
+
i0, s0 = index, []
|
1034
|
+
r1 = _nt_lcalpha
|
1035
|
+
s0 << r1
|
1036
|
+
if r1
|
1037
|
+
s2, i2 = [], index
|
1038
|
+
loop do
|
1039
|
+
r3 = _nt_lcalnum
|
1040
|
+
if r3
|
1041
|
+
s2 << r3
|
1042
|
+
else
|
1043
|
+
break
|
1044
|
+
end
|
1045
|
+
end
|
1046
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1047
|
+
s0 << r2
|
1048
|
+
end
|
1049
|
+
if s0.last
|
1050
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1051
|
+
r0.extend(AppPrefix0)
|
1052
|
+
else
|
1053
|
+
@index = i0
|
1054
|
+
r0 = nil
|
1055
|
+
end
|
1056
|
+
|
1057
|
+
node_cache[:app_prefix][start_index] = r0
|
1058
|
+
|
1059
|
+
r0
|
1060
|
+
end
|
1061
|
+
|
1062
|
+
module AppString0
|
1063
|
+
def app_prefix
|
1064
|
+
elements[0]
|
1065
|
+
end
|
1066
|
+
|
1067
|
+
def sqstr
|
1068
|
+
elements[1]
|
1069
|
+
end
|
1070
|
+
end
|
1071
|
+
|
1072
|
+
module AppString1
|
1073
|
+
def ast # XXX ignoring h and b64
|
1074
|
+
data = sqstr.ast.force_encoding(Encoding::UTF_8) # XXX undo .b
|
1075
|
+
app = app_prefix.text_value
|
1076
|
+
# Find a better place to put a default initialization
|
1077
|
+
EDNGRAMMAR.const_set(:APPS, Hash.new { |h, k|
|
1078
|
+
h[k] = begin ::CBOR_DIAG.const_get("App_#{app}")
|
1079
|
+
rescue NameError
|
1080
|
+
raise ArgumentError.new("cbor-diagnostic: Unknown application-oriented extension #{k}")
|
1081
|
+
end
|
1082
|
+
}) unless ::EDNGRAMMAR.const_defined?(:APPS)
|
1083
|
+
::EDNGRAMMAR::APPS[app].decode(app, data)
|
1084
|
+
end
|
1085
|
+
end
|
1086
|
+
|
1087
|
+
def _nt_app_string
|
1088
|
+
start_index = index
|
1089
|
+
if node_cache[:app_string].has_key?(index)
|
1090
|
+
cached = node_cache[:app_string][index]
|
1091
|
+
if cached
|
1092
|
+
node_cache[:app_string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1093
|
+
@index = cached.interval.end
|
1094
|
+
end
|
1095
|
+
return cached
|
1096
|
+
end
|
1097
|
+
|
1098
|
+
i0, s0 = index, []
|
1099
|
+
r1 = _nt_app_prefix
|
1100
|
+
s0 << r1
|
1101
|
+
if r1
|
1102
|
+
r2 = _nt_sqstr
|
1103
|
+
s0 << r2
|
1104
|
+
end
|
1105
|
+
if s0.last
|
1106
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1107
|
+
r0.extend(AppString0)
|
1108
|
+
r0.extend(AppString1)
|
1109
|
+
else
|
1110
|
+
@index = i0
|
1111
|
+
r0 = nil
|
1112
|
+
end
|
1113
|
+
|
1114
|
+
node_cache[:app_string][start_index] = r0
|
1115
|
+
|
1116
|
+
r0
|
1117
|
+
end
|
1118
|
+
|
1119
|
+
module Sqstr0
|
1120
|
+
end
|
1121
|
+
|
1122
|
+
module Sqstr1
|
1123
|
+
def ast
|
1124
|
+
elements[1].elements.map {|x| x.ast}.join.b # XXX .b
|
1125
|
+
end
|
1126
|
+
end
|
1127
|
+
|
1128
|
+
def _nt_sqstr
|
1129
|
+
start_index = index
|
1130
|
+
if node_cache[:sqstr].has_key?(index)
|
1131
|
+
cached = node_cache[:sqstr][index]
|
1132
|
+
if cached
|
1133
|
+
node_cache[:sqstr][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1134
|
+
@index = cached.interval.end
|
1135
|
+
end
|
1136
|
+
return cached
|
1137
|
+
end
|
1138
|
+
|
1139
|
+
i0, s0 = index, []
|
1140
|
+
if (match_len = has_terminal?("'", false, index))
|
1141
|
+
r1 = true
|
1142
|
+
@index += match_len
|
1143
|
+
else
|
1144
|
+
terminal_parse_failure('"\'"')
|
1145
|
+
r1 = nil
|
1146
|
+
end
|
1147
|
+
s0 << r1
|
1148
|
+
if r1
|
1149
|
+
s2, i2 = [], index
|
1150
|
+
loop do
|
1151
|
+
r3 = _nt_single_quoted
|
1152
|
+
if r3
|
1153
|
+
s2 << r3
|
1154
|
+
else
|
1155
|
+
break
|
1156
|
+
end
|
1157
|
+
end
|
1158
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1159
|
+
s0 << r2
|
1160
|
+
if r2
|
1161
|
+
if (match_len = has_terminal?("'", false, index))
|
1162
|
+
r4 = true
|
1163
|
+
@index += match_len
|
1164
|
+
else
|
1165
|
+
terminal_parse_failure('"\'"')
|
1166
|
+
r4 = nil
|
1167
|
+
end
|
1168
|
+
s0 << r4
|
1169
|
+
end
|
1170
|
+
end
|
1171
|
+
if s0.last
|
1172
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1173
|
+
r0.extend(Sqstr0)
|
1174
|
+
r0.extend(Sqstr1)
|
1175
|
+
else
|
1176
|
+
@index = i0
|
1177
|
+
r0 = nil
|
1178
|
+
end
|
1179
|
+
|
1180
|
+
node_cache[:sqstr][start_index] = r0
|
1181
|
+
|
1182
|
+
r0
|
1183
|
+
end
|
1184
|
+
|
1185
|
+
def _nt_bstr
|
1186
|
+
start_index = index
|
1187
|
+
if node_cache[:bstr].has_key?(index)
|
1188
|
+
cached = node_cache[:bstr][index]
|
1189
|
+
if cached
|
1190
|
+
node_cache[:bstr][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1191
|
+
@index = cached.interval.end
|
1192
|
+
end
|
1193
|
+
return cached
|
1194
|
+
end
|
1195
|
+
|
1196
|
+
i0 = index
|
1197
|
+
r1 = _nt_app_string
|
1198
|
+
if r1
|
1199
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
1200
|
+
r0 = r1
|
1201
|
+
else
|
1202
|
+
r2 = _nt_sqstr
|
1203
|
+
if r2
|
1204
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
1205
|
+
r0 = r2
|
1206
|
+
else
|
1207
|
+
@index = i0
|
1208
|
+
r0 = nil
|
1209
|
+
end
|
1210
|
+
end
|
1211
|
+
|
1212
|
+
node_cache[:bstr][start_index] = r0
|
1213
|
+
|
1214
|
+
r0
|
1215
|
+
end
|
1216
|
+
|
1217
|
+
module Tstr0
|
1218
|
+
def DQUOTE1
|
1219
|
+
elements[0]
|
1220
|
+
end
|
1221
|
+
|
1222
|
+
def DQUOTE2
|
1223
|
+
elements[2]
|
1224
|
+
end
|
1225
|
+
end
|
1226
|
+
|
1227
|
+
module Tstr1
|
1228
|
+
def ast
|
1229
|
+
elements[1].elements.map {|x| x.ast}.join
|
1230
|
+
end
|
1231
|
+
end
|
1232
|
+
|
1233
|
+
def _nt_tstr
|
1234
|
+
start_index = index
|
1235
|
+
if node_cache[:tstr].has_key?(index)
|
1236
|
+
cached = node_cache[:tstr][index]
|
1237
|
+
if cached
|
1238
|
+
node_cache[:tstr][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1239
|
+
@index = cached.interval.end
|
1240
|
+
end
|
1241
|
+
return cached
|
1242
|
+
end
|
1243
|
+
|
1244
|
+
i0, s0 = index, []
|
1245
|
+
r1 = _nt_DQUOTE
|
1246
|
+
s0 << r1
|
1247
|
+
if r1
|
1248
|
+
s2, i2 = [], index
|
1249
|
+
loop do
|
1250
|
+
r3 = _nt_double_quoted
|
1251
|
+
if r3
|
1252
|
+
s2 << r3
|
1253
|
+
else
|
1254
|
+
break
|
1255
|
+
end
|
1256
|
+
end
|
1257
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1258
|
+
s0 << r2
|
1259
|
+
if r2
|
1260
|
+
r4 = _nt_DQUOTE
|
1261
|
+
s0 << r4
|
1262
|
+
end
|
1263
|
+
end
|
1264
|
+
if s0.last
|
1265
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1266
|
+
r0.extend(Tstr0)
|
1267
|
+
r0.extend(Tstr1)
|
1268
|
+
else
|
1269
|
+
@index = i0
|
1270
|
+
r0 = nil
|
1271
|
+
end
|
1272
|
+
|
1273
|
+
node_cache[:tstr][start_index] = r0
|
1274
|
+
|
1275
|
+
r0
|
1276
|
+
end
|
1277
|
+
|
1278
|
+
module Embedded0
|
1279
|
+
def seq
|
1280
|
+
elements[1]
|
1281
|
+
end
|
1282
|
+
|
1283
|
+
end
|
1284
|
+
|
1285
|
+
module Embedded1
|
1286
|
+
def ast
|
1287
|
+
sn = seq.ast
|
1288
|
+
if CBOR::Sequence === sn
|
1289
|
+
sn.to_cborseq
|
1290
|
+
else
|
1291
|
+
CBOR.encode(sn)
|
1292
|
+
end
|
1293
|
+
end
|
1294
|
+
end
|
1295
|
+
|
1296
|
+
def _nt_embedded
|
1297
|
+
start_index = index
|
1298
|
+
if node_cache[:embedded].has_key?(index)
|
1299
|
+
cached = node_cache[:embedded][index]
|
1300
|
+
if cached
|
1301
|
+
node_cache[:embedded][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1302
|
+
@index = cached.interval.end
|
1303
|
+
end
|
1304
|
+
return cached
|
1305
|
+
end
|
1306
|
+
|
1307
|
+
i0, s0 = index, []
|
1308
|
+
if (match_len = has_terminal?("<<", false, index))
|
1309
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1310
|
+
@index += match_len
|
1311
|
+
else
|
1312
|
+
terminal_parse_failure('"<<"')
|
1313
|
+
r1 = nil
|
1314
|
+
end
|
1315
|
+
s0 << r1
|
1316
|
+
if r1
|
1317
|
+
r2 = _nt_seq
|
1318
|
+
s0 << r2
|
1319
|
+
if r2
|
1320
|
+
if (match_len = has_terminal?(">>", false, index))
|
1321
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1322
|
+
@index += match_len
|
1323
|
+
else
|
1324
|
+
terminal_parse_failure('">>"')
|
1325
|
+
r3 = nil
|
1326
|
+
end
|
1327
|
+
s0 << r3
|
1328
|
+
end
|
1329
|
+
end
|
1330
|
+
if s0.last
|
1331
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1332
|
+
r0.extend(Embedded0)
|
1333
|
+
r0.extend(Embedded1)
|
1334
|
+
else
|
1335
|
+
@index = i0
|
1336
|
+
r0 = nil
|
1337
|
+
end
|
1338
|
+
|
1339
|
+
node_cache[:embedded][start_index] = r0
|
1340
|
+
|
1341
|
+
r0
|
1342
|
+
end
|
1343
|
+
|
1344
|
+
module Array0
|
1345
|
+
def S1
|
1346
|
+
elements[1]
|
1347
|
+
end
|
1348
|
+
|
1349
|
+
def item
|
1350
|
+
elements[2]
|
1351
|
+
end
|
1352
|
+
|
1353
|
+
def S2
|
1354
|
+
elements[3]
|
1355
|
+
end
|
1356
|
+
end
|
1357
|
+
|
1358
|
+
module Array1
|
1359
|
+
def item
|
1360
|
+
elements[0]
|
1361
|
+
end
|
1362
|
+
|
1363
|
+
def S
|
1364
|
+
elements[1]
|
1365
|
+
end
|
1366
|
+
|
1367
|
+
def OC
|
1368
|
+
elements[3]
|
1369
|
+
end
|
1370
|
+
end
|
1371
|
+
|
1372
|
+
module Array2
|
1373
|
+
def spec
|
1374
|
+
elements[1]
|
1375
|
+
end
|
1376
|
+
|
1377
|
+
end
|
1378
|
+
|
1379
|
+
module Array3
|
1380
|
+
def ast
|
1381
|
+
r = if e = elements[2].elements
|
1382
|
+
[e[0].ast] + e[2].elements.map {|x| x.item.ast }
|
1383
|
+
else
|
1384
|
+
[]
|
1385
|
+
end
|
1386
|
+
if spec.ast
|
1387
|
+
r.cbor_stream!
|
1388
|
+
end
|
1389
|
+
r
|
1390
|
+
end
|
1391
|
+
end
|
1392
|
+
|
1393
|
+
def _nt_array
|
1394
|
+
start_index = index
|
1395
|
+
if node_cache[:array].has_key?(index)
|
1396
|
+
cached = node_cache[:array][index]
|
1397
|
+
if cached
|
1398
|
+
node_cache[:array][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1399
|
+
@index = cached.interval.end
|
1400
|
+
end
|
1401
|
+
return cached
|
1402
|
+
end
|
1403
|
+
|
1404
|
+
i0, s0 = index, []
|
1405
|
+
if (match_len = has_terminal?("[", false, index))
|
1406
|
+
r1 = true
|
1407
|
+
@index += match_len
|
1408
|
+
else
|
1409
|
+
terminal_parse_failure('"["')
|
1410
|
+
r1 = nil
|
1411
|
+
end
|
1412
|
+
s0 << r1
|
1413
|
+
if r1
|
1414
|
+
r2 = _nt_spec
|
1415
|
+
s0 << r2
|
1416
|
+
if r2
|
1417
|
+
i4, s4 = index, []
|
1418
|
+
r5 = _nt_item
|
1419
|
+
s4 << r5
|
1420
|
+
if r5
|
1421
|
+
r6 = _nt_S
|
1422
|
+
s4 << r6
|
1423
|
+
if r6
|
1424
|
+
s7, i7 = [], index
|
1425
|
+
loop do
|
1426
|
+
i8, s8 = index, []
|
1427
|
+
if (match_len = has_terminal?(",", false, index))
|
1428
|
+
r9 = true
|
1429
|
+
@index += match_len
|
1430
|
+
else
|
1431
|
+
terminal_parse_failure('","')
|
1432
|
+
r9 = nil
|
1433
|
+
end
|
1434
|
+
s8 << r9
|
1435
|
+
if r9
|
1436
|
+
r10 = _nt_S
|
1437
|
+
s8 << r10
|
1438
|
+
if r10
|
1439
|
+
r11 = _nt_item
|
1440
|
+
s8 << r11
|
1441
|
+
if r11
|
1442
|
+
r12 = _nt_S
|
1443
|
+
s8 << r12
|
1444
|
+
end
|
1445
|
+
end
|
1446
|
+
end
|
1447
|
+
if s8.last
|
1448
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
1449
|
+
r8.extend(Array0)
|
1450
|
+
else
|
1451
|
+
@index = i8
|
1452
|
+
r8 = nil
|
1453
|
+
end
|
1454
|
+
if r8
|
1455
|
+
s7 << r8
|
1456
|
+
else
|
1457
|
+
break
|
1458
|
+
end
|
1459
|
+
end
|
1460
|
+
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
1461
|
+
s4 << r7
|
1462
|
+
if r7
|
1463
|
+
r13 = _nt_OC
|
1464
|
+
s4 << r13
|
1465
|
+
end
|
1466
|
+
end
|
1467
|
+
end
|
1468
|
+
if s4.last
|
1469
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
1470
|
+
r4.extend(Array1)
|
1471
|
+
else
|
1472
|
+
@index = i4
|
1473
|
+
r4 = nil
|
1474
|
+
end
|
1475
|
+
if r4
|
1476
|
+
r3 = r4
|
1477
|
+
else
|
1478
|
+
r3 = instantiate_node(SyntaxNode,input, index...index)
|
1479
|
+
end
|
1480
|
+
s0 << r3
|
1481
|
+
if r3
|
1482
|
+
if (match_len = has_terminal?("]", false, index))
|
1483
|
+
r14 = true
|
1484
|
+
@index += match_len
|
1485
|
+
else
|
1486
|
+
terminal_parse_failure('"]"')
|
1487
|
+
r14 = nil
|
1488
|
+
end
|
1489
|
+
s0 << r14
|
1490
|
+
end
|
1491
|
+
end
|
1492
|
+
end
|
1493
|
+
if s0.last
|
1494
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1495
|
+
r0.extend(Array2)
|
1496
|
+
r0.extend(Array3)
|
1497
|
+
else
|
1498
|
+
@index = i0
|
1499
|
+
r0 = nil
|
1500
|
+
end
|
1501
|
+
|
1502
|
+
node_cache[:array][start_index] = r0
|
1503
|
+
|
1504
|
+
r0
|
1505
|
+
end
|
1506
|
+
|
1507
|
+
module Map0
|
1508
|
+
def S1
|
1509
|
+
elements[1]
|
1510
|
+
end
|
1511
|
+
|
1512
|
+
def kp
|
1513
|
+
elements[2]
|
1514
|
+
end
|
1515
|
+
|
1516
|
+
def S2
|
1517
|
+
elements[3]
|
1518
|
+
end
|
1519
|
+
end
|
1520
|
+
|
1521
|
+
module Map1
|
1522
|
+
def kp
|
1523
|
+
elements[0]
|
1524
|
+
end
|
1525
|
+
|
1526
|
+
def S
|
1527
|
+
elements[1]
|
1528
|
+
end
|
1529
|
+
|
1530
|
+
def OC
|
1531
|
+
elements[3]
|
1532
|
+
end
|
1533
|
+
end
|
1534
|
+
|
1535
|
+
module Map2
|
1536
|
+
def spec
|
1537
|
+
elements[1]
|
1538
|
+
end
|
1539
|
+
|
1540
|
+
end
|
1541
|
+
|
1542
|
+
module Map3
|
1543
|
+
def ast
|
1544
|
+
r = if e = elements[2].elements
|
1545
|
+
Hash[ [e[0].ast] + e[2].elements.map {|x| x.kp.ast } ]
|
1546
|
+
else
|
1547
|
+
{}
|
1548
|
+
end
|
1549
|
+
if spec.ast
|
1550
|
+
r.cbor_stream!
|
1551
|
+
end
|
1552
|
+
r
|
1553
|
+
end
|
1554
|
+
end
|
1555
|
+
|
1556
|
+
def _nt_map
|
1557
|
+
start_index = index
|
1558
|
+
if node_cache[:map].has_key?(index)
|
1559
|
+
cached = node_cache[:map][index]
|
1560
|
+
if cached
|
1561
|
+
node_cache[:map][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1562
|
+
@index = cached.interval.end
|
1563
|
+
end
|
1564
|
+
return cached
|
1565
|
+
end
|
1566
|
+
|
1567
|
+
i0, s0 = index, []
|
1568
|
+
if (match_len = has_terminal?("{", false, index))
|
1569
|
+
r1 = true
|
1570
|
+
@index += match_len
|
1571
|
+
else
|
1572
|
+
terminal_parse_failure('"{"')
|
1573
|
+
r1 = nil
|
1574
|
+
end
|
1575
|
+
s0 << r1
|
1576
|
+
if r1
|
1577
|
+
r2 = _nt_spec
|
1578
|
+
s0 << r2
|
1579
|
+
if r2
|
1580
|
+
i4, s4 = index, []
|
1581
|
+
r5 = _nt_kp
|
1582
|
+
s4 << r5
|
1583
|
+
if r5
|
1584
|
+
r6 = _nt_S
|
1585
|
+
s4 << r6
|
1586
|
+
if r6
|
1587
|
+
s7, i7 = [], index
|
1588
|
+
loop do
|
1589
|
+
i8, s8 = index, []
|
1590
|
+
if (match_len = has_terminal?(",", false, index))
|
1591
|
+
r9 = true
|
1592
|
+
@index += match_len
|
1593
|
+
else
|
1594
|
+
terminal_parse_failure('","')
|
1595
|
+
r9 = nil
|
1596
|
+
end
|
1597
|
+
s8 << r9
|
1598
|
+
if r9
|
1599
|
+
r10 = _nt_S
|
1600
|
+
s8 << r10
|
1601
|
+
if r10
|
1602
|
+
r11 = _nt_kp
|
1603
|
+
s8 << r11
|
1604
|
+
if r11
|
1605
|
+
r12 = _nt_S
|
1606
|
+
s8 << r12
|
1607
|
+
end
|
1608
|
+
end
|
1609
|
+
end
|
1610
|
+
if s8.last
|
1611
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
1612
|
+
r8.extend(Map0)
|
1613
|
+
else
|
1614
|
+
@index = i8
|
1615
|
+
r8 = nil
|
1616
|
+
end
|
1617
|
+
if r8
|
1618
|
+
s7 << r8
|
1619
|
+
else
|
1620
|
+
break
|
1621
|
+
end
|
1622
|
+
end
|
1623
|
+
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
1624
|
+
s4 << r7
|
1625
|
+
if r7
|
1626
|
+
r13 = _nt_OC
|
1627
|
+
s4 << r13
|
1628
|
+
end
|
1629
|
+
end
|
1630
|
+
end
|
1631
|
+
if s4.last
|
1632
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
1633
|
+
r4.extend(Map1)
|
1634
|
+
else
|
1635
|
+
@index = i4
|
1636
|
+
r4 = nil
|
1637
|
+
end
|
1638
|
+
if r4
|
1639
|
+
r3 = r4
|
1640
|
+
else
|
1641
|
+
r3 = instantiate_node(SyntaxNode,input, index...index)
|
1642
|
+
end
|
1643
|
+
s0 << r3
|
1644
|
+
if r3
|
1645
|
+
if (match_len = has_terminal?("}", false, index))
|
1646
|
+
r14 = true
|
1647
|
+
@index += match_len
|
1648
|
+
else
|
1649
|
+
terminal_parse_failure('"}"')
|
1650
|
+
r14 = nil
|
1651
|
+
end
|
1652
|
+
s0 << r14
|
1653
|
+
end
|
1654
|
+
end
|
1655
|
+
end
|
1656
|
+
if s0.last
|
1657
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1658
|
+
r0.extend(Map2)
|
1659
|
+
r0.extend(Map3)
|
1660
|
+
else
|
1661
|
+
@index = i0
|
1662
|
+
r0 = nil
|
1663
|
+
end
|
1664
|
+
|
1665
|
+
node_cache[:map][start_index] = r0
|
1666
|
+
|
1667
|
+
r0
|
1668
|
+
end
|
1669
|
+
|
1670
|
+
module Kp0
|
1671
|
+
def item1
|
1672
|
+
elements[0]
|
1673
|
+
end
|
1674
|
+
|
1675
|
+
def S1
|
1676
|
+
elements[1]
|
1677
|
+
end
|
1678
|
+
|
1679
|
+
def S2
|
1680
|
+
elements[3]
|
1681
|
+
end
|
1682
|
+
|
1683
|
+
def item2
|
1684
|
+
elements[4]
|
1685
|
+
end
|
1686
|
+
end
|
1687
|
+
|
1688
|
+
module Kp1
|
1689
|
+
def ast
|
1690
|
+
[elements[0].ast, elements[4].ast]
|
1691
|
+
end
|
1692
|
+
end
|
1693
|
+
|
1694
|
+
def _nt_kp
|
1695
|
+
start_index = index
|
1696
|
+
if node_cache[:kp].has_key?(index)
|
1697
|
+
cached = node_cache[:kp][index]
|
1698
|
+
if cached
|
1699
|
+
node_cache[:kp][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1700
|
+
@index = cached.interval.end
|
1701
|
+
end
|
1702
|
+
return cached
|
1703
|
+
end
|
1704
|
+
|
1705
|
+
i0, s0 = index, []
|
1706
|
+
r1 = _nt_item
|
1707
|
+
s0 << r1
|
1708
|
+
if r1
|
1709
|
+
r2 = _nt_S
|
1710
|
+
s0 << r2
|
1711
|
+
if r2
|
1712
|
+
if (match_len = has_terminal?(":", false, index))
|
1713
|
+
r3 = true
|
1714
|
+
@index += match_len
|
1715
|
+
else
|
1716
|
+
terminal_parse_failure('":"')
|
1717
|
+
r3 = nil
|
1718
|
+
end
|
1719
|
+
s0 << r3
|
1720
|
+
if r3
|
1721
|
+
r4 = _nt_S
|
1722
|
+
s0 << r4
|
1723
|
+
if r4
|
1724
|
+
r5 = _nt_item
|
1725
|
+
s0 << r5
|
1726
|
+
end
|
1727
|
+
end
|
1728
|
+
end
|
1729
|
+
end
|
1730
|
+
if s0.last
|
1731
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1732
|
+
r0.extend(Kp0)
|
1733
|
+
r0.extend(Kp1)
|
1734
|
+
else
|
1735
|
+
@index = i0
|
1736
|
+
r0 = nil
|
1737
|
+
end
|
1738
|
+
|
1739
|
+
node_cache[:kp][start_index] = r0
|
1740
|
+
|
1741
|
+
r0
|
1742
|
+
end
|
1743
|
+
|
1744
|
+
def _nt_blank
|
1745
|
+
start_index = index
|
1746
|
+
if node_cache[:blank].has_key?(index)
|
1747
|
+
cached = node_cache[:blank][index]
|
1748
|
+
if cached
|
1749
|
+
node_cache[:blank][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1750
|
+
@index = cached.interval.end
|
1751
|
+
end
|
1752
|
+
return cached
|
1753
|
+
end
|
1754
|
+
|
1755
|
+
i0 = index
|
1756
|
+
if (match_len = has_terminal?("\t", false, index))
|
1757
|
+
r1 = true
|
1758
|
+
@index += match_len
|
1759
|
+
else
|
1760
|
+
terminal_parse_failure('"\\t"')
|
1761
|
+
r1 = nil
|
1762
|
+
end
|
1763
|
+
if r1
|
1764
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
1765
|
+
r0 = r1
|
1766
|
+
else
|
1767
|
+
if (match_len = has_terminal?("\n", false, index))
|
1768
|
+
r2 = true
|
1769
|
+
@index += match_len
|
1770
|
+
else
|
1771
|
+
terminal_parse_failure('"\\n"')
|
1772
|
+
r2 = nil
|
1773
|
+
end
|
1774
|
+
if r2
|
1775
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
1776
|
+
r0 = r2
|
1777
|
+
else
|
1778
|
+
if (match_len = has_terminal?("\r", false, index))
|
1779
|
+
r3 = true
|
1780
|
+
@index += match_len
|
1781
|
+
else
|
1782
|
+
terminal_parse_failure('"\\r"')
|
1783
|
+
r3 = nil
|
1784
|
+
end
|
1785
|
+
if r3
|
1786
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
1787
|
+
r0 = r3
|
1788
|
+
else
|
1789
|
+
if (match_len = has_terminal?(" ", false, index))
|
1790
|
+
r4 = true
|
1791
|
+
@index += match_len
|
1792
|
+
else
|
1793
|
+
terminal_parse_failure('" "')
|
1794
|
+
r4 = nil
|
1795
|
+
end
|
1796
|
+
if r4
|
1797
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
1798
|
+
r0 = r4
|
1799
|
+
else
|
1800
|
+
@index = i0
|
1801
|
+
r0 = nil
|
1802
|
+
end
|
1803
|
+
end
|
1804
|
+
end
|
1805
|
+
end
|
1806
|
+
|
1807
|
+
node_cache[:blank][start_index] = r0
|
1808
|
+
|
1809
|
+
r0
|
1810
|
+
end
|
1811
|
+
|
1812
|
+
def _nt_non_slash
|
1813
|
+
start_index = index
|
1814
|
+
if node_cache[:non_slash].has_key?(index)
|
1815
|
+
cached = node_cache[:non_slash][index]
|
1816
|
+
if cached
|
1817
|
+
node_cache[:non_slash][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1818
|
+
@index = cached.interval.end
|
1819
|
+
end
|
1820
|
+
return cached
|
1821
|
+
end
|
1822
|
+
|
1823
|
+
i0 = index
|
1824
|
+
r1 = _nt_blank
|
1825
|
+
if r1
|
1826
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
1827
|
+
r0 = r1
|
1828
|
+
else
|
1829
|
+
if has_terminal?(@regexps[gr = '\A[!-\\.]'] ||= Regexp.new(gr), :regexp, index)
|
1830
|
+
r2 = true
|
1831
|
+
@index += 1
|
1832
|
+
else
|
1833
|
+
terminal_parse_failure('[!-\\.]')
|
1834
|
+
r2 = nil
|
1835
|
+
end
|
1836
|
+
if r2
|
1837
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
1838
|
+
r0 = r2
|
1839
|
+
else
|
1840
|
+
if has_terminal?(@regexps[gr = '\A[0-]'] ||= Regexp.new(gr), :regexp, index)
|
1841
|
+
r3 = true
|
1842
|
+
@index += 1
|
1843
|
+
else
|
1844
|
+
terminal_parse_failure('[0-]')
|
1845
|
+
r3 = nil
|
1846
|
+
end
|
1847
|
+
if r3
|
1848
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
1849
|
+
r0 = r3
|
1850
|
+
else
|
1851
|
+
@index = i0
|
1852
|
+
r0 = nil
|
1853
|
+
end
|
1854
|
+
end
|
1855
|
+
end
|
1856
|
+
|
1857
|
+
node_cache[:non_slash][start_index] = r0
|
1858
|
+
|
1859
|
+
r0
|
1860
|
+
end
|
1861
|
+
|
1862
|
+
module S0
|
1863
|
+
end
|
1864
|
+
|
1865
|
+
module S1
|
1866
|
+
end
|
1867
|
+
|
1868
|
+
def _nt_S
|
1869
|
+
start_index = index
|
1870
|
+
if node_cache[:S].has_key?(index)
|
1871
|
+
cached = node_cache[:S][index]
|
1872
|
+
if cached
|
1873
|
+
node_cache[:S][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1874
|
+
@index = cached.interval.end
|
1875
|
+
end
|
1876
|
+
return cached
|
1877
|
+
end
|
1878
|
+
|
1879
|
+
i0, s0 = index, []
|
1880
|
+
s1, i1 = [], index
|
1881
|
+
loop do
|
1882
|
+
r2 = _nt_blank
|
1883
|
+
if r2
|
1884
|
+
s1 << r2
|
1885
|
+
else
|
1886
|
+
break
|
1887
|
+
end
|
1888
|
+
end
|
1889
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
1890
|
+
s0 << r1
|
1891
|
+
if r1
|
1892
|
+
s3, i3 = [], index
|
1893
|
+
loop do
|
1894
|
+
i4, s4 = index, []
|
1895
|
+
if (match_len = has_terminal?("/", false, index))
|
1896
|
+
r5 = true
|
1897
|
+
@index += match_len
|
1898
|
+
else
|
1899
|
+
terminal_parse_failure('"/"')
|
1900
|
+
r5 = nil
|
1901
|
+
end
|
1902
|
+
s4 << r5
|
1903
|
+
if r5
|
1904
|
+
s6, i6 = [], index
|
1905
|
+
loop do
|
1906
|
+
r7 = _nt_non_slash
|
1907
|
+
if r7
|
1908
|
+
s6 << r7
|
1909
|
+
else
|
1910
|
+
break
|
1911
|
+
end
|
1912
|
+
end
|
1913
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
1914
|
+
s4 << r6
|
1915
|
+
if r6
|
1916
|
+
if (match_len = has_terminal?("/", false, index))
|
1917
|
+
r8 = true
|
1918
|
+
@index += match_len
|
1919
|
+
else
|
1920
|
+
terminal_parse_failure('"/"')
|
1921
|
+
r8 = nil
|
1922
|
+
end
|
1923
|
+
s4 << r8
|
1924
|
+
if r8
|
1925
|
+
s9, i9 = [], index
|
1926
|
+
loop do
|
1927
|
+
r10 = _nt_blank
|
1928
|
+
if r10
|
1929
|
+
s9 << r10
|
1930
|
+
else
|
1931
|
+
break
|
1932
|
+
end
|
1933
|
+
end
|
1934
|
+
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
1935
|
+
s4 << r9
|
1936
|
+
end
|
1937
|
+
end
|
1938
|
+
end
|
1939
|
+
if s4.last
|
1940
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
1941
|
+
r4.extend(S0)
|
1942
|
+
else
|
1943
|
+
@index = i4
|
1944
|
+
r4 = nil
|
1945
|
+
end
|
1946
|
+
if r4
|
1947
|
+
s3 << r4
|
1948
|
+
else
|
1949
|
+
break
|
1950
|
+
end
|
1951
|
+
end
|
1952
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
1953
|
+
s0 << r3
|
1954
|
+
end
|
1955
|
+
if s0.last
|
1956
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1957
|
+
r0.extend(S1)
|
1958
|
+
else
|
1959
|
+
@index = i0
|
1960
|
+
r0 = nil
|
1961
|
+
end
|
1962
|
+
|
1963
|
+
node_cache[:S][start_index] = r0
|
1964
|
+
|
1965
|
+
r0
|
1966
|
+
end
|
1967
|
+
|
1968
|
+
module OC0
|
1969
|
+
def S
|
1970
|
+
elements[1]
|
1971
|
+
end
|
1972
|
+
end
|
1973
|
+
|
1974
|
+
def _nt_OC
|
1975
|
+
start_index = index
|
1976
|
+
if node_cache[:OC].has_key?(index)
|
1977
|
+
cached = node_cache[:OC][index]
|
1978
|
+
if cached
|
1979
|
+
node_cache[:OC][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1980
|
+
@index = cached.interval.end
|
1981
|
+
end
|
1982
|
+
return cached
|
1983
|
+
end
|
1984
|
+
|
1985
|
+
i1, s1 = index, []
|
1986
|
+
if (match_len = has_terminal?(",", false, index))
|
1987
|
+
r2 = true
|
1988
|
+
@index += match_len
|
1989
|
+
else
|
1990
|
+
terminal_parse_failure('","')
|
1991
|
+
r2 = nil
|
1992
|
+
end
|
1993
|
+
s1 << r2
|
1994
|
+
if r2
|
1995
|
+
r3 = _nt_S
|
1996
|
+
s1 << r3
|
1997
|
+
end
|
1998
|
+
if s1.last
|
1999
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
2000
|
+
r1.extend(OC0)
|
2001
|
+
else
|
2002
|
+
@index = i1
|
2003
|
+
r1 = nil
|
2004
|
+
end
|
2005
|
+
if r1
|
2006
|
+
r0 = r1
|
2007
|
+
else
|
2008
|
+
r0 = instantiate_node(SyntaxNode,input, index...index)
|
2009
|
+
end
|
2010
|
+
|
2011
|
+
node_cache[:OC][start_index] = r0
|
2012
|
+
|
2013
|
+
r0
|
2014
|
+
end
|
2015
|
+
|
2016
|
+
module Streamstring0
|
2017
|
+
def S1
|
2018
|
+
elements[1]
|
2019
|
+
end
|
2020
|
+
|
2021
|
+
def tstr
|
2022
|
+
elements[2]
|
2023
|
+
end
|
2024
|
+
|
2025
|
+
def S2
|
2026
|
+
elements[3]
|
2027
|
+
end
|
2028
|
+
end
|
2029
|
+
|
2030
|
+
module Streamstring1
|
2031
|
+
def spec1
|
2032
|
+
elements[1]
|
2033
|
+
end
|
2034
|
+
|
2035
|
+
def tstr
|
2036
|
+
elements[2]
|
2037
|
+
end
|
2038
|
+
|
2039
|
+
def S
|
2040
|
+
elements[3]
|
2041
|
+
end
|
2042
|
+
|
2043
|
+
def OC
|
2044
|
+
elements[5]
|
2045
|
+
end
|
2046
|
+
|
2047
|
+
end
|
2048
|
+
|
2049
|
+
module Streamstring2
|
2050
|
+
def S1
|
2051
|
+
elements[1]
|
2052
|
+
end
|
2053
|
+
|
2054
|
+
def sqstr
|
2055
|
+
elements[2]
|
2056
|
+
end
|
2057
|
+
|
2058
|
+
def S2
|
2059
|
+
elements[3]
|
2060
|
+
end
|
2061
|
+
end
|
2062
|
+
|
2063
|
+
module Streamstring3
|
2064
|
+
def spec1
|
2065
|
+
elements[1]
|
2066
|
+
end
|
2067
|
+
|
2068
|
+
def sqstr
|
2069
|
+
elements[2]
|
2070
|
+
end
|
2071
|
+
|
2072
|
+
def S
|
2073
|
+
elements[3]
|
2074
|
+
end
|
2075
|
+
|
2076
|
+
def OC
|
2077
|
+
elements[5]
|
2078
|
+
end
|
2079
|
+
|
2080
|
+
end
|
2081
|
+
|
2082
|
+
def _nt_streamstring
|
2083
|
+
start_index = index
|
2084
|
+
if node_cache[:streamstring].has_key?(index)
|
2085
|
+
cached = node_cache[:streamstring][index]
|
2086
|
+
if cached
|
2087
|
+
node_cache[:streamstring][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
2088
|
+
@index = cached.interval.end
|
2089
|
+
end
|
2090
|
+
return cached
|
2091
|
+
end
|
2092
|
+
|
2093
|
+
i0 = index
|
2094
|
+
i1, s1 = index, []
|
2095
|
+
if (match_len = has_terminal?("(", false, index))
|
2096
|
+
r2 = true
|
2097
|
+
@index += match_len
|
2098
|
+
else
|
2099
|
+
terminal_parse_failure('"("')
|
2100
|
+
r2 = nil
|
2101
|
+
end
|
2102
|
+
s1 << r2
|
2103
|
+
if r2
|
2104
|
+
r3 = _nt_spec1
|
2105
|
+
s1 << r3
|
2106
|
+
if r3
|
2107
|
+
r4 = _nt_tstr
|
2108
|
+
s1 << r4
|
2109
|
+
if r4
|
2110
|
+
r5 = _nt_S
|
2111
|
+
s1 << r5
|
2112
|
+
if r5
|
2113
|
+
s6, i6 = [], index
|
2114
|
+
loop do
|
2115
|
+
i7, s7 = index, []
|
2116
|
+
if (match_len = has_terminal?(",", false, index))
|
2117
|
+
r8 = true
|
2118
|
+
@index += match_len
|
2119
|
+
else
|
2120
|
+
terminal_parse_failure('","')
|
2121
|
+
r8 = nil
|
2122
|
+
end
|
2123
|
+
s7 << r8
|
2124
|
+
if r8
|
2125
|
+
r9 = _nt_S
|
2126
|
+
s7 << r9
|
2127
|
+
if r9
|
2128
|
+
r10 = _nt_tstr
|
2129
|
+
s7 << r10
|
2130
|
+
if r10
|
2131
|
+
r11 = _nt_S
|
2132
|
+
s7 << r11
|
2133
|
+
end
|
2134
|
+
end
|
2135
|
+
end
|
2136
|
+
if s7.last
|
2137
|
+
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
2138
|
+
r7.extend(Streamstring0)
|
2139
|
+
else
|
2140
|
+
@index = i7
|
2141
|
+
r7 = nil
|
2142
|
+
end
|
2143
|
+
if r7
|
2144
|
+
s6 << r7
|
2145
|
+
else
|
2146
|
+
break
|
2147
|
+
end
|
2148
|
+
end
|
2149
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
2150
|
+
s1 << r6
|
2151
|
+
if r6
|
2152
|
+
r12 = _nt_OC
|
2153
|
+
s1 << r12
|
2154
|
+
if r12
|
2155
|
+
if (match_len = has_terminal?(")", false, index))
|
2156
|
+
r13 = true
|
2157
|
+
@index += match_len
|
2158
|
+
else
|
2159
|
+
terminal_parse_failure('")"')
|
2160
|
+
r13 = nil
|
2161
|
+
end
|
2162
|
+
s1 << r13
|
2163
|
+
end
|
2164
|
+
end
|
2165
|
+
end
|
2166
|
+
end
|
2167
|
+
end
|
2168
|
+
end
|
2169
|
+
if s1.last
|
2170
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
2171
|
+
r1.extend(Streamstring1)
|
2172
|
+
else
|
2173
|
+
@index = i1
|
2174
|
+
r1 = nil
|
2175
|
+
end
|
2176
|
+
if r1
|
2177
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
2178
|
+
r0 = r1
|
2179
|
+
else
|
2180
|
+
i14, s14 = index, []
|
2181
|
+
if (match_len = has_terminal?("(", false, index))
|
2182
|
+
r15 = true
|
2183
|
+
@index += match_len
|
2184
|
+
else
|
2185
|
+
terminal_parse_failure('"("')
|
2186
|
+
r15 = nil
|
2187
|
+
end
|
2188
|
+
s14 << r15
|
2189
|
+
if r15
|
2190
|
+
r16 = _nt_spec1
|
2191
|
+
s14 << r16
|
2192
|
+
if r16
|
2193
|
+
r17 = _nt_sqstr
|
2194
|
+
s14 << r17
|
2195
|
+
if r17
|
2196
|
+
r18 = _nt_S
|
2197
|
+
s14 << r18
|
2198
|
+
if r18
|
2199
|
+
s19, i19 = [], index
|
2200
|
+
loop do
|
2201
|
+
i20, s20 = index, []
|
2202
|
+
if (match_len = has_terminal?(",", false, index))
|
2203
|
+
r21 = true
|
2204
|
+
@index += match_len
|
2205
|
+
else
|
2206
|
+
terminal_parse_failure('","')
|
2207
|
+
r21 = nil
|
2208
|
+
end
|
2209
|
+
s20 << r21
|
2210
|
+
if r21
|
2211
|
+
r22 = _nt_S
|
2212
|
+
s20 << r22
|
2213
|
+
if r22
|
2214
|
+
r23 = _nt_sqstr
|
2215
|
+
s20 << r23
|
2216
|
+
if r23
|
2217
|
+
r24 = _nt_S
|
2218
|
+
s20 << r24
|
2219
|
+
end
|
2220
|
+
end
|
2221
|
+
end
|
2222
|
+
if s20.last
|
2223
|
+
r20 = instantiate_node(SyntaxNode,input, i20...index, s20)
|
2224
|
+
r20.extend(Streamstring2)
|
2225
|
+
else
|
2226
|
+
@index = i20
|
2227
|
+
r20 = nil
|
2228
|
+
end
|
2229
|
+
if r20
|
2230
|
+
s19 << r20
|
2231
|
+
else
|
2232
|
+
break
|
2233
|
+
end
|
2234
|
+
end
|
2235
|
+
r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
|
2236
|
+
s14 << r19
|
2237
|
+
if r19
|
2238
|
+
r25 = _nt_OC
|
2239
|
+
s14 << r25
|
2240
|
+
if r25
|
2241
|
+
if (match_len = has_terminal?(")", false, index))
|
2242
|
+
r26 = true
|
2243
|
+
@index += match_len
|
2244
|
+
else
|
2245
|
+
terminal_parse_failure('")"')
|
2246
|
+
r26 = nil
|
2247
|
+
end
|
2248
|
+
s14 << r26
|
2249
|
+
end
|
2250
|
+
end
|
2251
|
+
end
|
2252
|
+
end
|
2253
|
+
end
|
2254
|
+
end
|
2255
|
+
if s14.last
|
2256
|
+
r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
|
2257
|
+
r14.extend(Streamstring3)
|
2258
|
+
else
|
2259
|
+
@index = i14
|
2260
|
+
r14 = nil
|
2261
|
+
end
|
2262
|
+
if r14
|
2263
|
+
r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true
|
2264
|
+
r0 = r14
|
2265
|
+
else
|
2266
|
+
@index = i0
|
2267
|
+
r0 = nil
|
2268
|
+
end
|
2269
|
+
end
|
2270
|
+
|
2271
|
+
node_cache[:streamstring][start_index] = r0
|
2272
|
+
|
2273
|
+
r0
|
2274
|
+
end
|
2275
|
+
|
2276
|
+
module Spec0
|
2277
|
+
def S
|
2278
|
+
elements[1]
|
2279
|
+
end
|
2280
|
+
end
|
2281
|
+
|
2282
|
+
module Spec1
|
2283
|
+
def S
|
2284
|
+
elements[0]
|
2285
|
+
end
|
2286
|
+
|
2287
|
+
end
|
2288
|
+
|
2289
|
+
module Spec2
|
2290
|
+
def ast; (e1 = elements[1].elements) && !e1[0].empty? end
|
2291
|
+
end
|
2292
|
+
|
2293
|
+
def _nt_spec
|
2294
|
+
start_index = index
|
2295
|
+
if node_cache[:spec].has_key?(index)
|
2296
|
+
cached = node_cache[:spec][index]
|
2297
|
+
if cached
|
2298
|
+
node_cache[:spec][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
2299
|
+
@index = cached.interval.end
|
2300
|
+
end
|
2301
|
+
return cached
|
2302
|
+
end
|
2303
|
+
|
2304
|
+
i0, s0 = index, []
|
2305
|
+
r1 = _nt_S
|
2306
|
+
s0 << r1
|
2307
|
+
if r1
|
2308
|
+
i3, s3 = index, []
|
2309
|
+
if (match_len = has_terminal?("_", false, index))
|
2310
|
+
r4 = true
|
2311
|
+
@index += match_len
|
2312
|
+
else
|
2313
|
+
terminal_parse_failure('"_"')
|
2314
|
+
r4 = nil
|
2315
|
+
end
|
2316
|
+
s3 << r4
|
2317
|
+
if r4
|
2318
|
+
r5 = _nt_S
|
2319
|
+
s3 << r5
|
2320
|
+
end
|
2321
|
+
if s3.last
|
2322
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
2323
|
+
r3.extend(Spec0)
|
2324
|
+
else
|
2325
|
+
@index = i3
|
2326
|
+
r3 = nil
|
2327
|
+
end
|
2328
|
+
if r3
|
2329
|
+
r2 = r3
|
2330
|
+
else
|
2331
|
+
r2 = instantiate_node(SyntaxNode,input, index...index)
|
2332
|
+
end
|
2333
|
+
s0 << r2
|
2334
|
+
end
|
2335
|
+
if s0.last
|
2336
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
2337
|
+
r0.extend(Spec1)
|
2338
|
+
r0.extend(Spec2)
|
2339
|
+
else
|
2340
|
+
@index = i0
|
2341
|
+
r0 = nil
|
2342
|
+
end
|
2343
|
+
|
2344
|
+
node_cache[:spec][start_index] = r0
|
2345
|
+
|
2346
|
+
r0
|
2347
|
+
end
|
2348
|
+
|
2349
|
+
module Spec10
|
2350
|
+
def S1
|
2351
|
+
elements[0]
|
2352
|
+
end
|
2353
|
+
|
2354
|
+
def S2
|
2355
|
+
elements[2]
|
2356
|
+
end
|
2357
|
+
end
|
2358
|
+
|
2359
|
+
def _nt_spec1
|
2360
|
+
start_index = index
|
2361
|
+
if node_cache[:spec1].has_key?(index)
|
2362
|
+
cached = node_cache[:spec1][index]
|
2363
|
+
if cached
|
2364
|
+
node_cache[:spec1][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
2365
|
+
@index = cached.interval.end
|
2366
|
+
end
|
2367
|
+
return cached
|
2368
|
+
end
|
2369
|
+
|
2370
|
+
i0, s0 = index, []
|
2371
|
+
r1 = _nt_S
|
2372
|
+
s0 << r1
|
2373
|
+
if r1
|
2374
|
+
if (match_len = has_terminal?("_", false, index))
|
2375
|
+
r2 = true
|
2376
|
+
@index += match_len
|
2377
|
+
else
|
2378
|
+
terminal_parse_failure('"_"')
|
2379
|
+
r2 = nil
|
2380
|
+
end
|
2381
|
+
s0 << r2
|
2382
|
+
if r2
|
2383
|
+
r3 = _nt_S
|
2384
|
+
s0 << r3
|
2385
|
+
end
|
2386
|
+
end
|
2387
|
+
if s0.last
|
2388
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
2389
|
+
r0.extend(Spec10)
|
2390
|
+
else
|
2391
|
+
@index = i0
|
2392
|
+
r0 = nil
|
2393
|
+
end
|
2394
|
+
|
2395
|
+
node_cache[:spec1][start_index] = r0
|
2396
|
+
|
2397
|
+
r0
|
2398
|
+
end
|
2399
|
+
|
2400
|
+
module DoubleQuoted0
|
2401
|
+
def ast; text_value end
|
2402
|
+
end
|
2403
|
+
|
2404
|
+
module DoubleQuoted1
|
2405
|
+
def ast; text_value end
|
2406
|
+
end
|
2407
|
+
|
2408
|
+
module DoubleQuoted2
|
2409
|
+
def DQUOTE
|
2410
|
+
elements[1]
|
2411
|
+
end
|
2412
|
+
end
|
2413
|
+
|
2414
|
+
module DoubleQuoted3
|
2415
|
+
def ast; elements[1].text_value end
|
2416
|
+
end
|
2417
|
+
|
2418
|
+
module DoubleQuoted4
|
2419
|
+
def escapable
|
2420
|
+
elements[1]
|
2421
|
+
end
|
2422
|
+
end
|
2423
|
+
|
2424
|
+
module DoubleQuoted5
|
2425
|
+
def ast; escapable.ast end
|
2426
|
+
end
|
2427
|
+
|
2428
|
+
def _nt_double_quoted
|
2429
|
+
start_index = index
|
2430
|
+
if node_cache[:double_quoted].has_key?(index)
|
2431
|
+
cached = node_cache[:double_quoted][index]
|
2432
|
+
if cached
|
2433
|
+
node_cache[:double_quoted][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
2434
|
+
@index = cached.interval.end
|
2435
|
+
end
|
2436
|
+
return cached
|
2437
|
+
end
|
2438
|
+
|
2439
|
+
i0 = index
|
2440
|
+
r1 = _nt_unescaped
|
2441
|
+
r1.extend(DoubleQuoted0)
|
2442
|
+
r1.extend(DoubleQuoted0)
|
2443
|
+
if r1
|
2444
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
2445
|
+
r0 = r1
|
2446
|
+
else
|
2447
|
+
if (match_len = has_terminal?("'", false, index))
|
2448
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
2449
|
+
r2.extend(DoubleQuoted1)
|
2450
|
+
@index += match_len
|
2451
|
+
else
|
2452
|
+
terminal_parse_failure('"\'"')
|
2453
|
+
r2 = nil
|
2454
|
+
end
|
2455
|
+
if r2
|
2456
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
2457
|
+
r0 = r2
|
2458
|
+
else
|
2459
|
+
i3, s3 = index, []
|
2460
|
+
if (match_len = has_terminal?("\\", false, index))
|
2461
|
+
r4 = true
|
2462
|
+
@index += match_len
|
2463
|
+
else
|
2464
|
+
terminal_parse_failure('"\\\\"')
|
2465
|
+
r4 = nil
|
2466
|
+
end
|
2467
|
+
s3 << r4
|
2468
|
+
if r4
|
2469
|
+
r5 = _nt_DQUOTE
|
2470
|
+
s3 << r5
|
2471
|
+
end
|
2472
|
+
if s3.last
|
2473
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
2474
|
+
r3.extend(DoubleQuoted2)
|
2475
|
+
r3.extend(DoubleQuoted3)
|
2476
|
+
else
|
2477
|
+
@index = i3
|
2478
|
+
r3 = nil
|
2479
|
+
end
|
2480
|
+
if r3
|
2481
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
2482
|
+
r0 = r3
|
2483
|
+
else
|
2484
|
+
i6, s6 = index, []
|
2485
|
+
if (match_len = has_terminal?("\\", false, index))
|
2486
|
+
r7 = true
|
2487
|
+
@index += match_len
|
2488
|
+
else
|
2489
|
+
terminal_parse_failure('"\\\\"')
|
2490
|
+
r7 = nil
|
2491
|
+
end
|
2492
|
+
s6 << r7
|
2493
|
+
if r7
|
2494
|
+
r8 = _nt_escapable
|
2495
|
+
s6 << r8
|
2496
|
+
end
|
2497
|
+
if s6.last
|
2498
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
2499
|
+
r6.extend(DoubleQuoted4)
|
2500
|
+
r6.extend(DoubleQuoted5)
|
2501
|
+
else
|
2502
|
+
@index = i6
|
2503
|
+
r6 = nil
|
2504
|
+
end
|
2505
|
+
if r6
|
2506
|
+
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
2507
|
+
r0 = r6
|
2508
|
+
else
|
2509
|
+
@index = i0
|
2510
|
+
r0 = nil
|
2511
|
+
end
|
2512
|
+
end
|
2513
|
+
end
|
2514
|
+
end
|
2515
|
+
|
2516
|
+
node_cache[:double_quoted][start_index] = r0
|
2517
|
+
|
2518
|
+
r0
|
2519
|
+
end
|
2520
|
+
|
2521
|
+
module SingleQuoted0
|
2522
|
+
def ast; text_value end
|
2523
|
+
end
|
2524
|
+
|
2525
|
+
module SingleQuoted1
|
2526
|
+
def ast; text_value end
|
2527
|
+
end
|
2528
|
+
|
2529
|
+
module SingleQuoted2
|
2530
|
+
end
|
2531
|
+
|
2532
|
+
module SingleQuoted3
|
2533
|
+
def ast; elements[1].text_value end
|
2534
|
+
end
|
2535
|
+
|
2536
|
+
module SingleQuoted4
|
2537
|
+
def escapable
|
2538
|
+
elements[1]
|
2539
|
+
end
|
2540
|
+
end
|
2541
|
+
|
2542
|
+
module SingleQuoted5
|
2543
|
+
def ast; escapable.ast end
|
2544
|
+
end
|
2545
|
+
|
2546
|
+
def _nt_single_quoted
|
2547
|
+
start_index = index
|
2548
|
+
if node_cache[:single_quoted].has_key?(index)
|
2549
|
+
cached = node_cache[:single_quoted][index]
|
2550
|
+
if cached
|
2551
|
+
node_cache[:single_quoted][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
2552
|
+
@index = cached.interval.end
|
2553
|
+
end
|
2554
|
+
return cached
|
2555
|
+
end
|
2556
|
+
|
2557
|
+
i0 = index
|
2558
|
+
r1 = _nt_unescaped
|
2559
|
+
r1.extend(SingleQuoted0)
|
2560
|
+
r1.extend(SingleQuoted0)
|
2561
|
+
if r1
|
2562
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
2563
|
+
r0 = r1
|
2564
|
+
else
|
2565
|
+
r2 = _nt_DQUOTE
|
2566
|
+
r2.extend(SingleQuoted1)
|
2567
|
+
r2.extend(SingleQuoted1)
|
2568
|
+
if r2
|
2569
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
2570
|
+
r0 = r2
|
2571
|
+
else
|
2572
|
+
i3, s3 = index, []
|
2573
|
+
if (match_len = has_terminal?("\\", false, index))
|
2574
|
+
r4 = true
|
2575
|
+
@index += match_len
|
2576
|
+
else
|
2577
|
+
terminal_parse_failure('"\\\\"')
|
2578
|
+
r4 = nil
|
2579
|
+
end
|
2580
|
+
s3 << r4
|
2581
|
+
if r4
|
2582
|
+
if (match_len = has_terminal?("'", false, index))
|
2583
|
+
r5 = true
|
2584
|
+
@index += match_len
|
2585
|
+
else
|
2586
|
+
terminal_parse_failure('"\'"')
|
2587
|
+
r5 = nil
|
2588
|
+
end
|
2589
|
+
s3 << r5
|
2590
|
+
end
|
2591
|
+
if s3.last
|
2592
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
2593
|
+
r3.extend(SingleQuoted2)
|
2594
|
+
r3.extend(SingleQuoted3)
|
2595
|
+
else
|
2596
|
+
@index = i3
|
2597
|
+
r3 = nil
|
2598
|
+
end
|
2599
|
+
if r3
|
2600
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
2601
|
+
r0 = r3
|
2602
|
+
else
|
2603
|
+
i6, s6 = index, []
|
2604
|
+
if (match_len = has_terminal?("\\", false, index))
|
2605
|
+
r7 = true
|
2606
|
+
@index += match_len
|
2607
|
+
else
|
2608
|
+
terminal_parse_failure('"\\\\"')
|
2609
|
+
r7 = nil
|
2610
|
+
end
|
2611
|
+
s6 << r7
|
2612
|
+
if r7
|
2613
|
+
r8 = _nt_escapable
|
2614
|
+
s6 << r8
|
2615
|
+
end
|
2616
|
+
if s6.last
|
2617
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
2618
|
+
r6.extend(SingleQuoted4)
|
2619
|
+
r6.extend(SingleQuoted5)
|
2620
|
+
else
|
2621
|
+
@index = i6
|
2622
|
+
r6 = nil
|
2623
|
+
end
|
2624
|
+
if r6
|
2625
|
+
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
2626
|
+
r0 = r6
|
2627
|
+
else
|
2628
|
+
@index = i0
|
2629
|
+
r0 = nil
|
2630
|
+
end
|
2631
|
+
end
|
2632
|
+
end
|
2633
|
+
end
|
2634
|
+
|
2635
|
+
node_cache[:single_quoted][start_index] = r0
|
2636
|
+
|
2637
|
+
r0
|
2638
|
+
end
|
2639
|
+
|
2640
|
+
module Escapable0
|
2641
|
+
def ast; "\b" end
|
2642
|
+
end
|
2643
|
+
|
2644
|
+
module Escapable1
|
2645
|
+
def ast; "\f" end
|
2646
|
+
end
|
2647
|
+
|
2648
|
+
module Escapable2
|
2649
|
+
def ast; "\n" end
|
2650
|
+
end
|
2651
|
+
|
2652
|
+
module Escapable3
|
2653
|
+
def ast; "\r" end
|
2654
|
+
end
|
2655
|
+
|
2656
|
+
module Escapable4
|
2657
|
+
def ast; "\t" end
|
2658
|
+
end
|
2659
|
+
|
2660
|
+
module Escapable5
|
2661
|
+
def ast; text_value end
|
2662
|
+
end
|
2663
|
+
|
2664
|
+
module Escapable6
|
2665
|
+
def ast; text_value end
|
2666
|
+
end
|
2667
|
+
|
2668
|
+
module Escapable7
|
2669
|
+
def hexchar
|
2670
|
+
elements[1]
|
2671
|
+
end
|
2672
|
+
end
|
2673
|
+
|
2674
|
+
module Escapable8
|
2675
|
+
def ast; hexchar.ast end
|
2676
|
+
end
|
2677
|
+
|
2678
|
+
def _nt_escapable
|
2679
|
+
start_index = index
|
2680
|
+
if node_cache[:escapable].has_key?(index)
|
2681
|
+
cached = node_cache[:escapable][index]
|
2682
|
+
if cached
|
2683
|
+
node_cache[:escapable][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
2684
|
+
@index = cached.interval.end
|
2685
|
+
end
|
2686
|
+
return cached
|
2687
|
+
end
|
2688
|
+
|
2689
|
+
i0 = index
|
2690
|
+
if (match_len = has_terminal?("b", false, index))
|
2691
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
2692
|
+
r1.extend(Escapable0)
|
2693
|
+
@index += match_len
|
2694
|
+
else
|
2695
|
+
terminal_parse_failure('"b"')
|
2696
|
+
r1 = nil
|
2697
|
+
end
|
2698
|
+
if r1
|
2699
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
2700
|
+
r0 = r1
|
2701
|
+
else
|
2702
|
+
if (match_len = has_terminal?("f", false, index))
|
2703
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
2704
|
+
r2.extend(Escapable1)
|
2705
|
+
@index += match_len
|
2706
|
+
else
|
2707
|
+
terminal_parse_failure('"f"')
|
2708
|
+
r2 = nil
|
2709
|
+
end
|
2710
|
+
if r2
|
2711
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
2712
|
+
r0 = r2
|
2713
|
+
else
|
2714
|
+
if (match_len = has_terminal?("n", false, index))
|
2715
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
2716
|
+
r3.extend(Escapable2)
|
2717
|
+
@index += match_len
|
2718
|
+
else
|
2719
|
+
terminal_parse_failure('"n"')
|
2720
|
+
r3 = nil
|
2721
|
+
end
|
2722
|
+
if r3
|
2723
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
2724
|
+
r0 = r3
|
2725
|
+
else
|
2726
|
+
if (match_len = has_terminal?("r", false, index))
|
2727
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
2728
|
+
r4.extend(Escapable3)
|
2729
|
+
@index += match_len
|
2730
|
+
else
|
2731
|
+
terminal_parse_failure('"r"')
|
2732
|
+
r4 = nil
|
2733
|
+
end
|
2734
|
+
if r4
|
2735
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
2736
|
+
r0 = r4
|
2737
|
+
else
|
2738
|
+
if (match_len = has_terminal?("t", false, index))
|
2739
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
2740
|
+
r5.extend(Escapable4)
|
2741
|
+
@index += match_len
|
2742
|
+
else
|
2743
|
+
terminal_parse_failure('"t"')
|
2744
|
+
r5 = nil
|
2745
|
+
end
|
2746
|
+
if r5
|
2747
|
+
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
2748
|
+
r0 = r5
|
2749
|
+
else
|
2750
|
+
if (match_len = has_terminal?("/", false, index))
|
2751
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
2752
|
+
r6.extend(Escapable5)
|
2753
|
+
@index += match_len
|
2754
|
+
else
|
2755
|
+
terminal_parse_failure('"/"')
|
2756
|
+
r6 = nil
|
2757
|
+
end
|
2758
|
+
if r6
|
2759
|
+
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
2760
|
+
r0 = r6
|
2761
|
+
else
|
2762
|
+
if (match_len = has_terminal?("\\", false, index))
|
2763
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
2764
|
+
r7.extend(Escapable6)
|
2765
|
+
@index += match_len
|
2766
|
+
else
|
2767
|
+
terminal_parse_failure('"\\\\"')
|
2768
|
+
r7 = nil
|
2769
|
+
end
|
2770
|
+
if r7
|
2771
|
+
r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
|
2772
|
+
r0 = r7
|
2773
|
+
else
|
2774
|
+
i8, s8 = index, []
|
2775
|
+
if (match_len = has_terminal?("u", false, index))
|
2776
|
+
r9 = true
|
2777
|
+
@index += match_len
|
2778
|
+
else
|
2779
|
+
terminal_parse_failure('"u"')
|
2780
|
+
r9 = nil
|
2781
|
+
end
|
2782
|
+
s8 << r9
|
2783
|
+
if r9
|
2784
|
+
r10 = _nt_hexchar
|
2785
|
+
s8 << r10
|
2786
|
+
end
|
2787
|
+
if s8.last
|
2788
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
2789
|
+
r8.extend(Escapable7)
|
2790
|
+
r8.extend(Escapable8)
|
2791
|
+
else
|
2792
|
+
@index = i8
|
2793
|
+
r8 = nil
|
2794
|
+
end
|
2795
|
+
if r8
|
2796
|
+
r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
|
2797
|
+
r0 = r8
|
2798
|
+
else
|
2799
|
+
@index = i0
|
2800
|
+
r0 = nil
|
2801
|
+
end
|
2802
|
+
end
|
2803
|
+
end
|
2804
|
+
end
|
2805
|
+
end
|
2806
|
+
end
|
2807
|
+
end
|
2808
|
+
end
|
2809
|
+
|
2810
|
+
node_cache[:escapable][start_index] = r0
|
2811
|
+
|
2812
|
+
r0
|
2813
|
+
end
|
2814
|
+
|
2815
|
+
module Hexchar0
|
2816
|
+
def ast; hex_value.chr(Encoding::UTF_8) end
|
2817
|
+
end
|
2818
|
+
|
2819
|
+
module Hexchar1
|
2820
|
+
def high_surrogate
|
2821
|
+
elements[0]
|
2822
|
+
end
|
2823
|
+
|
2824
|
+
def low_surrogate
|
2825
|
+
elements[3]
|
2826
|
+
end
|
2827
|
+
end
|
2828
|
+
|
2829
|
+
module Hexchar2
|
2830
|
+
def ast
|
2831
|
+
((high_surrogate.ast << 10) + low_surrogate.ast + 0x10000).chr(Encoding::UTF_8)
|
2832
|
+
end
|
2833
|
+
end
|
2834
|
+
|
2835
|
+
def _nt_hexchar
|
2836
|
+
start_index = index
|
2837
|
+
if node_cache[:hexchar].has_key?(index)
|
2838
|
+
cached = node_cache[:hexchar][index]
|
2839
|
+
if cached
|
2840
|
+
node_cache[:hexchar][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
2841
|
+
@index = cached.interval.end
|
2842
|
+
end
|
2843
|
+
return cached
|
2844
|
+
end
|
2845
|
+
|
2846
|
+
i0 = index
|
2847
|
+
r1 = _nt_non_surrogate
|
2848
|
+
r1.extend(Hexchar0)
|
2849
|
+
r1.extend(Hexchar0)
|
2850
|
+
if r1
|
2851
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
2852
|
+
r0 = r1
|
2853
|
+
else
|
2854
|
+
i2, s2 = index, []
|
2855
|
+
r3 = _nt_high_surrogate
|
2856
|
+
s2 << r3
|
2857
|
+
if r3
|
2858
|
+
if (match_len = has_terminal?("\\", false, index))
|
2859
|
+
r4 = true
|
2860
|
+
@index += match_len
|
2861
|
+
else
|
2862
|
+
terminal_parse_failure('"\\\\"')
|
2863
|
+
r4 = nil
|
2864
|
+
end
|
2865
|
+
s2 << r4
|
2866
|
+
if r4
|
2867
|
+
if (match_len = has_terminal?("u", false, index))
|
2868
|
+
r5 = true
|
2869
|
+
@index += match_len
|
2870
|
+
else
|
2871
|
+
terminal_parse_failure('"u"')
|
2872
|
+
r5 = nil
|
2873
|
+
end
|
2874
|
+
s2 << r5
|
2875
|
+
if r5
|
2876
|
+
r6 = _nt_low_surrogate
|
2877
|
+
s2 << r6
|
2878
|
+
end
|
2879
|
+
end
|
2880
|
+
end
|
2881
|
+
if s2.last
|
2882
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
2883
|
+
r2.extend(Hexchar1)
|
2884
|
+
r2.extend(Hexchar2)
|
2885
|
+
else
|
2886
|
+
@index = i2
|
2887
|
+
r2 = nil
|
2888
|
+
end
|
2889
|
+
if r2
|
2890
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
2891
|
+
r0 = r2
|
2892
|
+
else
|
2893
|
+
@index = i0
|
2894
|
+
r0 = nil
|
2895
|
+
end
|
2896
|
+
end
|
2897
|
+
|
2898
|
+
node_cache[:hexchar][start_index] = r0
|
2899
|
+
|
2900
|
+
r0
|
2901
|
+
end
|
2902
|
+
|
2903
|
+
module NonSurrogate0
|
2904
|
+
end
|
2905
|
+
|
2906
|
+
module NonSurrogate1
|
2907
|
+
def ODIGIT
|
2908
|
+
elements[1]
|
2909
|
+
end
|
2910
|
+
|
2911
|
+
end
|
2912
|
+
|
2913
|
+
def _nt_non_surrogate
|
2914
|
+
start_index = index
|
2915
|
+
if node_cache[:non_surrogate].has_key?(index)
|
2916
|
+
cached = node_cache[:non_surrogate][index]
|
2917
|
+
if cached
|
2918
|
+
node_cache[:non_surrogate][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
2919
|
+
@index = cached.interval.end
|
2920
|
+
end
|
2921
|
+
return cached
|
2922
|
+
end
|
2923
|
+
|
2924
|
+
i0 = index
|
2925
|
+
i1, s1 = index, []
|
2926
|
+
i2 = index
|
2927
|
+
r3 = _nt_DIGIT
|
2928
|
+
if r3
|
2929
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
2930
|
+
r2 = r3
|
2931
|
+
else
|
2932
|
+
if (match_len = has_terminal?("a", :insens, index))
|
2933
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
2934
|
+
@index += match_len
|
2935
|
+
else
|
2936
|
+
terminal_parse_failure('"A"')
|
2937
|
+
r4 = nil
|
2938
|
+
end
|
2939
|
+
if r4
|
2940
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
2941
|
+
r2 = r4
|
2942
|
+
else
|
2943
|
+
if (match_len = has_terminal?("b", :insens, index))
|
2944
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
2945
|
+
@index += match_len
|
2946
|
+
else
|
2947
|
+
terminal_parse_failure('"B"')
|
2948
|
+
r5 = nil
|
2949
|
+
end
|
2950
|
+
if r5
|
2951
|
+
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
2952
|
+
r2 = r5
|
2953
|
+
else
|
2954
|
+
if (match_len = has_terminal?("c", :insens, index))
|
2955
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
2956
|
+
@index += match_len
|
2957
|
+
else
|
2958
|
+
terminal_parse_failure('"C"')
|
2959
|
+
r6 = nil
|
2960
|
+
end
|
2961
|
+
if r6
|
2962
|
+
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
2963
|
+
r2 = r6
|
2964
|
+
else
|
2965
|
+
if (match_len = has_terminal?("e", :insens, index))
|
2966
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
2967
|
+
@index += match_len
|
2968
|
+
else
|
2969
|
+
terminal_parse_failure('"E"')
|
2970
|
+
r7 = nil
|
2971
|
+
end
|
2972
|
+
if r7
|
2973
|
+
r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
|
2974
|
+
r2 = r7
|
2975
|
+
else
|
2976
|
+
if (match_len = has_terminal?("f", :insens, index))
|
2977
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
2978
|
+
@index += match_len
|
2979
|
+
else
|
2980
|
+
terminal_parse_failure('"F"')
|
2981
|
+
r8 = nil
|
2982
|
+
end
|
2983
|
+
if r8
|
2984
|
+
r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
|
2985
|
+
r2 = r8
|
2986
|
+
else
|
2987
|
+
@index = i2
|
2988
|
+
r2 = nil
|
2989
|
+
end
|
2990
|
+
end
|
2991
|
+
end
|
2992
|
+
end
|
2993
|
+
end
|
2994
|
+
end
|
2995
|
+
s1 << r2
|
2996
|
+
if r2
|
2997
|
+
s9, i9 = [], index
|
2998
|
+
loop do
|
2999
|
+
r10 = _nt_HEXDIG
|
3000
|
+
if r10
|
3001
|
+
s9 << r10
|
3002
|
+
else
|
3003
|
+
break
|
3004
|
+
end
|
3005
|
+
if s9.size == 3
|
3006
|
+
break
|
3007
|
+
end
|
3008
|
+
end
|
3009
|
+
if s9.size < 3
|
3010
|
+
@index = i9
|
3011
|
+
r9 = nil
|
3012
|
+
else
|
3013
|
+
if s9.size < 3
|
3014
|
+
@terminal_failures.pop
|
3015
|
+
end
|
3016
|
+
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
3017
|
+
end
|
3018
|
+
s1 << r9
|
3019
|
+
end
|
3020
|
+
if s1.last
|
3021
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
3022
|
+
r1.extend(NonSurrogate0)
|
3023
|
+
else
|
3024
|
+
@index = i1
|
3025
|
+
r1 = nil
|
3026
|
+
end
|
3027
|
+
if r1
|
3028
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
3029
|
+
r0 = r1
|
3030
|
+
else
|
3031
|
+
i11, s11 = index, []
|
3032
|
+
if (match_len = has_terminal?("d", :insens, index))
|
3033
|
+
r12 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
3034
|
+
@index += match_len
|
3035
|
+
else
|
3036
|
+
terminal_parse_failure('"D"')
|
3037
|
+
r12 = nil
|
3038
|
+
end
|
3039
|
+
s11 << r12
|
3040
|
+
if r12
|
3041
|
+
r13 = _nt_ODIGIT
|
3042
|
+
s11 << r13
|
3043
|
+
if r13
|
3044
|
+
s14, i14 = [], index
|
3045
|
+
loop do
|
3046
|
+
r15 = _nt_HEXDIG
|
3047
|
+
if r15
|
3048
|
+
s14 << r15
|
3049
|
+
else
|
3050
|
+
break
|
3051
|
+
end
|
3052
|
+
if s14.size == 2
|
3053
|
+
break
|
3054
|
+
end
|
3055
|
+
end
|
3056
|
+
if s14.size < 2
|
3057
|
+
@index = i14
|
3058
|
+
r14 = nil
|
3059
|
+
else
|
3060
|
+
if s14.size < 2
|
3061
|
+
@terminal_failures.pop
|
3062
|
+
end
|
3063
|
+
r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
|
3064
|
+
end
|
3065
|
+
s11 << r14
|
3066
|
+
end
|
3067
|
+
end
|
3068
|
+
if s11.last
|
3069
|
+
r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
|
3070
|
+
r11.extend(NonSurrogate1)
|
3071
|
+
else
|
3072
|
+
@index = i11
|
3073
|
+
r11 = nil
|
3074
|
+
end
|
3075
|
+
if r11
|
3076
|
+
r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
|
3077
|
+
r0 = r11
|
3078
|
+
else
|
3079
|
+
@index = i0
|
3080
|
+
r0 = nil
|
3081
|
+
end
|
3082
|
+
end
|
3083
|
+
|
3084
|
+
node_cache[:non_surrogate][start_index] = r0
|
3085
|
+
|
3086
|
+
r0
|
3087
|
+
end
|
3088
|
+
|
3089
|
+
module HighSurrogate0
|
3090
|
+
end
|
3091
|
+
|
3092
|
+
module HighSurrogate1
|
3093
|
+
def ast; hex_value - 0xD800 end
|
3094
|
+
end
|
3095
|
+
|
3096
|
+
def _nt_high_surrogate
|
3097
|
+
start_index = index
|
3098
|
+
if node_cache[:high_surrogate].has_key?(index)
|
3099
|
+
cached = node_cache[:high_surrogate][index]
|
3100
|
+
if cached
|
3101
|
+
node_cache[:high_surrogate][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
3102
|
+
@index = cached.interval.end
|
3103
|
+
end
|
3104
|
+
return cached
|
3105
|
+
end
|
3106
|
+
|
3107
|
+
i0, s0 = index, []
|
3108
|
+
if (match_len = has_terminal?("d", :insens, index))
|
3109
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
3110
|
+
@index += match_len
|
3111
|
+
else
|
3112
|
+
terminal_parse_failure('"D"')
|
3113
|
+
r1 = nil
|
3114
|
+
end
|
3115
|
+
s0 << r1
|
3116
|
+
if r1
|
3117
|
+
i2 = index
|
3118
|
+
if (match_len = has_terminal?("8", false, index))
|
3119
|
+
r3 = true
|
3120
|
+
@index += match_len
|
3121
|
+
else
|
3122
|
+
terminal_parse_failure('"8"')
|
3123
|
+
r3 = nil
|
3124
|
+
end
|
3125
|
+
if r3
|
3126
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
3127
|
+
r2 = r3
|
3128
|
+
else
|
3129
|
+
if (match_len = has_terminal?("9", false, index))
|
3130
|
+
r4 = true
|
3131
|
+
@index += match_len
|
3132
|
+
else
|
3133
|
+
terminal_parse_failure('"9"')
|
3134
|
+
r4 = nil
|
3135
|
+
end
|
3136
|
+
if r4
|
3137
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
3138
|
+
r2 = r4
|
3139
|
+
else
|
3140
|
+
if (match_len = has_terminal?("a", :insens, index))
|
3141
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
3142
|
+
@index += match_len
|
3143
|
+
else
|
3144
|
+
terminal_parse_failure('"A"')
|
3145
|
+
r5 = nil
|
3146
|
+
end
|
3147
|
+
if r5
|
3148
|
+
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
3149
|
+
r2 = r5
|
3150
|
+
else
|
3151
|
+
if (match_len = has_terminal?("b", :insens, index))
|
3152
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
3153
|
+
@index += match_len
|
3154
|
+
else
|
3155
|
+
terminal_parse_failure('"B"')
|
3156
|
+
r6 = nil
|
3157
|
+
end
|
3158
|
+
if r6
|
3159
|
+
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
3160
|
+
r2 = r6
|
3161
|
+
else
|
3162
|
+
@index = i2
|
3163
|
+
r2 = nil
|
3164
|
+
end
|
3165
|
+
end
|
3166
|
+
end
|
3167
|
+
end
|
3168
|
+
s0 << r2
|
3169
|
+
if r2
|
3170
|
+
s7, i7 = [], index
|
3171
|
+
loop do
|
3172
|
+
r8 = _nt_HEXDIG
|
3173
|
+
if r8
|
3174
|
+
s7 << r8
|
3175
|
+
else
|
3176
|
+
break
|
3177
|
+
end
|
3178
|
+
if s7.size == 2
|
3179
|
+
break
|
3180
|
+
end
|
3181
|
+
end
|
3182
|
+
if s7.size < 2
|
3183
|
+
@index = i7
|
3184
|
+
r7 = nil
|
3185
|
+
else
|
3186
|
+
if s7.size < 2
|
3187
|
+
@terminal_failures.pop
|
3188
|
+
end
|
3189
|
+
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
3190
|
+
end
|
3191
|
+
s0 << r7
|
3192
|
+
end
|
3193
|
+
end
|
3194
|
+
if s0.last
|
3195
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
3196
|
+
r0.extend(HighSurrogate0)
|
3197
|
+
r0.extend(HighSurrogate1)
|
3198
|
+
else
|
3199
|
+
@index = i0
|
3200
|
+
r0 = nil
|
3201
|
+
end
|
3202
|
+
|
3203
|
+
node_cache[:high_surrogate][start_index] = r0
|
3204
|
+
|
3205
|
+
r0
|
3206
|
+
end
|
3207
|
+
|
3208
|
+
module LowSurrogate0
|
3209
|
+
end
|
3210
|
+
|
3211
|
+
module LowSurrogate1
|
3212
|
+
def ast; hex_value - 0xDC00 end
|
3213
|
+
end
|
3214
|
+
|
3215
|
+
def _nt_low_surrogate
|
3216
|
+
start_index = index
|
3217
|
+
if node_cache[:low_surrogate].has_key?(index)
|
3218
|
+
cached = node_cache[:low_surrogate][index]
|
3219
|
+
if cached
|
3220
|
+
node_cache[:low_surrogate][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
3221
|
+
@index = cached.interval.end
|
3222
|
+
end
|
3223
|
+
return cached
|
3224
|
+
end
|
3225
|
+
|
3226
|
+
i0, s0 = index, []
|
3227
|
+
if (match_len = has_terminal?("d", :insens, index))
|
3228
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
3229
|
+
@index += match_len
|
3230
|
+
else
|
3231
|
+
terminal_parse_failure('"D"')
|
3232
|
+
r1 = nil
|
3233
|
+
end
|
3234
|
+
s0 << r1
|
3235
|
+
if r1
|
3236
|
+
i2 = index
|
3237
|
+
if (match_len = has_terminal?("c", :insens, index))
|
3238
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
3239
|
+
@index += match_len
|
3240
|
+
else
|
3241
|
+
terminal_parse_failure('"C"')
|
3242
|
+
r3 = nil
|
3243
|
+
end
|
3244
|
+
if r3
|
3245
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
3246
|
+
r2 = r3
|
3247
|
+
else
|
3248
|
+
if (match_len = has_terminal?("d", :insens, index))
|
3249
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
3250
|
+
@index += match_len
|
3251
|
+
else
|
3252
|
+
terminal_parse_failure('"D"')
|
3253
|
+
r4 = nil
|
3254
|
+
end
|
3255
|
+
if r4
|
3256
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
3257
|
+
r2 = r4
|
3258
|
+
else
|
3259
|
+
if (match_len = has_terminal?("e", :insens, index))
|
3260
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
3261
|
+
@index += match_len
|
3262
|
+
else
|
3263
|
+
terminal_parse_failure('"E"')
|
3264
|
+
r5 = nil
|
3265
|
+
end
|
3266
|
+
if r5
|
3267
|
+
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
3268
|
+
r2 = r5
|
3269
|
+
else
|
3270
|
+
if (match_len = has_terminal?("f", :insens, index))
|
3271
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
3272
|
+
@index += match_len
|
3273
|
+
else
|
3274
|
+
terminal_parse_failure('"F"')
|
3275
|
+
r6 = nil
|
3276
|
+
end
|
3277
|
+
if r6
|
3278
|
+
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
3279
|
+
r2 = r6
|
3280
|
+
else
|
3281
|
+
@index = i2
|
3282
|
+
r2 = nil
|
3283
|
+
end
|
3284
|
+
end
|
3285
|
+
end
|
3286
|
+
end
|
3287
|
+
s0 << r2
|
3288
|
+
if r2
|
3289
|
+
s7, i7 = [], index
|
3290
|
+
loop do
|
3291
|
+
r8 = _nt_HEXDIG
|
3292
|
+
if r8
|
3293
|
+
s7 << r8
|
3294
|
+
else
|
3295
|
+
break
|
3296
|
+
end
|
3297
|
+
if s7.size == 2
|
3298
|
+
break
|
3299
|
+
end
|
3300
|
+
end
|
3301
|
+
if s7.size < 2
|
3302
|
+
@index = i7
|
3303
|
+
r7 = nil
|
3304
|
+
else
|
3305
|
+
if s7.size < 2
|
3306
|
+
@terminal_failures.pop
|
3307
|
+
end
|
3308
|
+
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
3309
|
+
end
|
3310
|
+
s0 << r7
|
3311
|
+
end
|
3312
|
+
end
|
3313
|
+
if s0.last
|
3314
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
3315
|
+
r0.extend(LowSurrogate0)
|
3316
|
+
r0.extend(LowSurrogate1)
|
3317
|
+
else
|
3318
|
+
@index = i0
|
3319
|
+
r0 = nil
|
3320
|
+
end
|
3321
|
+
|
3322
|
+
node_cache[:low_surrogate][start_index] = r0
|
3323
|
+
|
3324
|
+
r0
|
3325
|
+
end
|
3326
|
+
|
3327
|
+
def _nt_unescaped
|
3328
|
+
start_index = index
|
3329
|
+
if node_cache[:unescaped].has_key?(index)
|
3330
|
+
cached = node_cache[:unescaped][index]
|
3331
|
+
if cached
|
3332
|
+
node_cache[:unescaped][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
3333
|
+
@index = cached.interval.end
|
3334
|
+
end
|
3335
|
+
return cached
|
3336
|
+
end
|
3337
|
+
|
3338
|
+
i0 = index
|
3339
|
+
if (match_len = has_terminal?("\n", false, index))
|
3340
|
+
r1 = true
|
3341
|
+
@index += match_len
|
3342
|
+
else
|
3343
|
+
terminal_parse_failure('"\\n"')
|
3344
|
+
r1 = nil
|
3345
|
+
end
|
3346
|
+
if r1
|
3347
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
3348
|
+
r0 = r1
|
3349
|
+
else
|
3350
|
+
if (match_len = has_terminal?("\r", false, index))
|
3351
|
+
r2 = true
|
3352
|
+
@index += match_len
|
3353
|
+
else
|
3354
|
+
terminal_parse_failure('"\\r"')
|
3355
|
+
r2 = nil
|
3356
|
+
end
|
3357
|
+
if r2
|
3358
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
3359
|
+
r0 = r2
|
3360
|
+
else
|
3361
|
+
if has_terminal?(@regexps[gr = '\A[\\ -!]'] ||= Regexp.new(gr), :regexp, index)
|
3362
|
+
r3 = true
|
3363
|
+
@index += 1
|
3364
|
+
else
|
3365
|
+
terminal_parse_failure('[\\ -!]')
|
3366
|
+
r3 = nil
|
3367
|
+
end
|
3368
|
+
if r3
|
3369
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
3370
|
+
r0 = r3
|
3371
|
+
else
|
3372
|
+
if has_terminal?(@regexps[gr = '\A[\\#-&]'] ||= Regexp.new(gr), :regexp, index)
|
3373
|
+
r4 = true
|
3374
|
+
@index += 1
|
3375
|
+
else
|
3376
|
+
terminal_parse_failure('[\\#-&]')
|
3377
|
+
r4 = nil
|
3378
|
+
end
|
3379
|
+
if r4
|
3380
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
3381
|
+
r0 = r4
|
3382
|
+
else
|
3383
|
+
if has_terminal?(@regexps[gr = '\A[\\(-\\[]'] ||= Regexp.new(gr), :regexp, index)
|
3384
|
+
r5 = true
|
3385
|
+
@index += 1
|
3386
|
+
else
|
3387
|
+
terminal_parse_failure('[\\(-\\[]')
|
3388
|
+
r5 = nil
|
3389
|
+
end
|
3390
|
+
if r5
|
3391
|
+
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
3392
|
+
r0 = r5
|
3393
|
+
else
|
3394
|
+
if has_terminal?(@regexps[gr = '\A[\\]-]'] ||= Regexp.new(gr), :regexp, index)
|
3395
|
+
r6 = true
|
3396
|
+
@index += 1
|
3397
|
+
else
|
3398
|
+
terminal_parse_failure('[\\]-]')
|
3399
|
+
r6 = nil
|
3400
|
+
end
|
3401
|
+
if r6
|
3402
|
+
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
3403
|
+
r0 = r6
|
3404
|
+
else
|
3405
|
+
@index = i0
|
3406
|
+
r0 = nil
|
3407
|
+
end
|
3408
|
+
end
|
3409
|
+
end
|
3410
|
+
end
|
3411
|
+
end
|
3412
|
+
end
|
3413
|
+
|
3414
|
+
node_cache[:unescaped][start_index] = r0
|
3415
|
+
|
3416
|
+
r0
|
3417
|
+
end
|
3418
|
+
|
3419
|
+
def _nt_DQUOTE
|
3420
|
+
start_index = index
|
3421
|
+
if node_cache[:DQUOTE].has_key?(index)
|
3422
|
+
cached = node_cache[:DQUOTE][index]
|
3423
|
+
if cached
|
3424
|
+
node_cache[:DQUOTE][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
3425
|
+
@index = cached.interval.end
|
3426
|
+
end
|
3427
|
+
return cached
|
3428
|
+
end
|
3429
|
+
|
3430
|
+
if (match_len = has_terminal?("\"", false, index))
|
3431
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
3432
|
+
@index += match_len
|
3433
|
+
else
|
3434
|
+
terminal_parse_failure('"\\""')
|
3435
|
+
r0 = nil
|
3436
|
+
end
|
3437
|
+
|
3438
|
+
node_cache[:DQUOTE][start_index] = r0
|
3439
|
+
|
3440
|
+
r0
|
3441
|
+
end
|
3442
|
+
|
3443
|
+
def _nt_DIGIT
|
3444
|
+
start_index = index
|
3445
|
+
if node_cache[:DIGIT].has_key?(index)
|
3446
|
+
cached = node_cache[:DIGIT][index]
|
3447
|
+
if cached
|
3448
|
+
node_cache[:DIGIT][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
3449
|
+
@index = cached.interval.end
|
3450
|
+
end
|
3451
|
+
return cached
|
3452
|
+
end
|
3453
|
+
|
3454
|
+
if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index)
|
3455
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3456
|
+
@index += 1
|
3457
|
+
else
|
3458
|
+
terminal_parse_failure('[0-9]')
|
3459
|
+
r0 = nil
|
3460
|
+
end
|
3461
|
+
|
3462
|
+
node_cache[:DIGIT][start_index] = r0
|
3463
|
+
|
3464
|
+
r0
|
3465
|
+
end
|
3466
|
+
|
3467
|
+
def _nt_DIGIT1
|
3468
|
+
start_index = index
|
3469
|
+
if node_cache[:DIGIT1].has_key?(index)
|
3470
|
+
cached = node_cache[:DIGIT1][index]
|
3471
|
+
if cached
|
3472
|
+
node_cache[:DIGIT1][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
3473
|
+
@index = cached.interval.end
|
3474
|
+
end
|
3475
|
+
return cached
|
3476
|
+
end
|
3477
|
+
|
3478
|
+
if has_terminal?(@regexps[gr = '\A[1-9]'] ||= Regexp.new(gr), :regexp, index)
|
3479
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3480
|
+
@index += 1
|
3481
|
+
else
|
3482
|
+
terminal_parse_failure('[1-9]')
|
3483
|
+
r0 = nil
|
3484
|
+
end
|
3485
|
+
|
3486
|
+
node_cache[:DIGIT1][start_index] = r0
|
3487
|
+
|
3488
|
+
r0
|
3489
|
+
end
|
3490
|
+
|
3491
|
+
def _nt_ODIGIT
|
3492
|
+
start_index = index
|
3493
|
+
if node_cache[:ODIGIT].has_key?(index)
|
3494
|
+
cached = node_cache[:ODIGIT][index]
|
3495
|
+
if cached
|
3496
|
+
node_cache[:ODIGIT][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
3497
|
+
@index = cached.interval.end
|
3498
|
+
end
|
3499
|
+
return cached
|
3500
|
+
end
|
3501
|
+
|
3502
|
+
if has_terminal?(@regexps[gr = '\A[0-7]'] ||= Regexp.new(gr), :regexp, index)
|
3503
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3504
|
+
@index += 1
|
3505
|
+
else
|
3506
|
+
terminal_parse_failure('[0-7]')
|
3507
|
+
r0 = nil
|
3508
|
+
end
|
3509
|
+
|
3510
|
+
node_cache[:ODIGIT][start_index] = r0
|
3511
|
+
|
3512
|
+
r0
|
3513
|
+
end
|
3514
|
+
|
3515
|
+
def _nt_BDIGIT
|
3516
|
+
start_index = index
|
3517
|
+
if node_cache[:BDIGIT].has_key?(index)
|
3518
|
+
cached = node_cache[:BDIGIT][index]
|
3519
|
+
if cached
|
3520
|
+
node_cache[:BDIGIT][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
3521
|
+
@index = cached.interval.end
|
3522
|
+
end
|
3523
|
+
return cached
|
3524
|
+
end
|
3525
|
+
|
3526
|
+
if has_terminal?(@regexps[gr = '\A[0-1]'] ||= Regexp.new(gr), :regexp, index)
|
3527
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3528
|
+
@index += 1
|
3529
|
+
else
|
3530
|
+
terminal_parse_failure('[0-1]')
|
3531
|
+
r0 = nil
|
3532
|
+
end
|
3533
|
+
|
3534
|
+
node_cache[:BDIGIT][start_index] = r0
|
3535
|
+
|
3536
|
+
r0
|
3537
|
+
end
|
3538
|
+
|
3539
|
+
def _nt_HEXDIG
|
3540
|
+
start_index = index
|
3541
|
+
if node_cache[:HEXDIG].has_key?(index)
|
3542
|
+
cached = node_cache[:HEXDIG][index]
|
3543
|
+
if cached
|
3544
|
+
node_cache[:HEXDIG][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
3545
|
+
@index = cached.interval.end
|
3546
|
+
end
|
3547
|
+
return cached
|
3548
|
+
end
|
3549
|
+
|
3550
|
+
i0 = index
|
3551
|
+
r1 = _nt_DIGIT
|
3552
|
+
if r1
|
3553
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
3554
|
+
r0 = r1
|
3555
|
+
else
|
3556
|
+
if (match_len = has_terminal?("a", :insens, index))
|
3557
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
3558
|
+
@index += match_len
|
3559
|
+
else
|
3560
|
+
terminal_parse_failure('"A"')
|
3561
|
+
r2 = nil
|
3562
|
+
end
|
3563
|
+
if r2
|
3564
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
3565
|
+
r0 = r2
|
3566
|
+
else
|
3567
|
+
if (match_len = has_terminal?("b", :insens, index))
|
3568
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
3569
|
+
@index += match_len
|
3570
|
+
else
|
3571
|
+
terminal_parse_failure('"B"')
|
3572
|
+
r3 = nil
|
3573
|
+
end
|
3574
|
+
if r3
|
3575
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
3576
|
+
r0 = r3
|
3577
|
+
else
|
3578
|
+
if (match_len = has_terminal?("c", :insens, index))
|
3579
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
3580
|
+
@index += match_len
|
3581
|
+
else
|
3582
|
+
terminal_parse_failure('"C"')
|
3583
|
+
r4 = nil
|
3584
|
+
end
|
3585
|
+
if r4
|
3586
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
3587
|
+
r0 = r4
|
3588
|
+
else
|
3589
|
+
if (match_len = has_terminal?("d", :insens, index))
|
3590
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
3591
|
+
@index += match_len
|
3592
|
+
else
|
3593
|
+
terminal_parse_failure('"D"')
|
3594
|
+
r5 = nil
|
3595
|
+
end
|
3596
|
+
if r5
|
3597
|
+
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
3598
|
+
r0 = r5
|
3599
|
+
else
|
3600
|
+
if (match_len = has_terminal?("e", :insens, index))
|
3601
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
3602
|
+
@index += match_len
|
3603
|
+
else
|
3604
|
+
terminal_parse_failure('"E"')
|
3605
|
+
r6 = nil
|
3606
|
+
end
|
3607
|
+
if r6
|
3608
|
+
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
3609
|
+
r0 = r6
|
3610
|
+
else
|
3611
|
+
if (match_len = has_terminal?("f", :insens, index))
|
3612
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
3613
|
+
@index += match_len
|
3614
|
+
else
|
3615
|
+
terminal_parse_failure('"F"')
|
3616
|
+
r7 = nil
|
3617
|
+
end
|
3618
|
+
if r7
|
3619
|
+
r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
|
3620
|
+
r0 = r7
|
3621
|
+
else
|
3622
|
+
@index = i0
|
3623
|
+
r0 = nil
|
3624
|
+
end
|
3625
|
+
end
|
3626
|
+
end
|
3627
|
+
end
|
3628
|
+
end
|
3629
|
+
end
|
3630
|
+
end
|
3631
|
+
|
3632
|
+
node_cache[:HEXDIG][start_index] = r0
|
3633
|
+
|
3634
|
+
r0
|
3635
|
+
end
|
3636
|
+
|
3637
|
+
def _nt_lcalpha
|
3638
|
+
start_index = index
|
3639
|
+
if node_cache[:lcalpha].has_key?(index)
|
3640
|
+
cached = node_cache[:lcalpha][index]
|
3641
|
+
if cached
|
3642
|
+
node_cache[:lcalpha][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
3643
|
+
@index = cached.interval.end
|
3644
|
+
end
|
3645
|
+
return cached
|
3646
|
+
end
|
3647
|
+
|
3648
|
+
if has_terminal?(@regexps[gr = '\A[a-z]'] ||= Regexp.new(gr), :regexp, index)
|
3649
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3650
|
+
@index += 1
|
3651
|
+
else
|
3652
|
+
terminal_parse_failure('[a-z]')
|
3653
|
+
r0 = nil
|
3654
|
+
end
|
3655
|
+
|
3656
|
+
node_cache[:lcalpha][start_index] = r0
|
3657
|
+
|
3658
|
+
r0
|
3659
|
+
end
|
3660
|
+
|
3661
|
+
def _nt_lcalnum
|
3662
|
+
start_index = index
|
3663
|
+
if node_cache[:lcalnum].has_key?(index)
|
3664
|
+
cached = node_cache[:lcalnum][index]
|
3665
|
+
if cached
|
3666
|
+
node_cache[:lcalnum][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
3667
|
+
@index = cached.interval.end
|
3668
|
+
end
|
3669
|
+
return cached
|
3670
|
+
end
|
3671
|
+
|
3672
|
+
i0 = index
|
3673
|
+
r1 = _nt_lcalpha
|
3674
|
+
if r1
|
3675
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
3676
|
+
r0 = r1
|
3677
|
+
else
|
3678
|
+
r2 = _nt_DIGIT
|
3679
|
+
if r2
|
3680
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
3681
|
+
r0 = r2
|
3682
|
+
else
|
3683
|
+
@index = i0
|
3684
|
+
r0 = nil
|
3685
|
+
end
|
3686
|
+
end
|
3687
|
+
|
3688
|
+
node_cache[:lcalnum][start_index] = r0
|
3689
|
+
|
3690
|
+
r0
|
3691
|
+
end
|
3692
|
+
|
3693
|
+
def _nt_ALPHA
|
3694
|
+
start_index = index
|
3695
|
+
if node_cache[:ALPHA].has_key?(index)
|
3696
|
+
cached = node_cache[:ALPHA][index]
|
3697
|
+
if cached
|
3698
|
+
node_cache[:ALPHA][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
3699
|
+
@index = cached.interval.end
|
3700
|
+
end
|
3701
|
+
return cached
|
3702
|
+
end
|
3703
|
+
|
3704
|
+
i0 = index
|
3705
|
+
if has_terminal?(@regexps[gr = '\A[A-Z]'] ||= Regexp.new(gr), :regexp, index)
|
3706
|
+
r1 = true
|
3707
|
+
@index += 1
|
3708
|
+
else
|
3709
|
+
terminal_parse_failure('[A-Z]')
|
3710
|
+
r1 = nil
|
3711
|
+
end
|
3712
|
+
if r1
|
3713
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
3714
|
+
r0 = r1
|
3715
|
+
else
|
3716
|
+
r2 = _nt_lcalpha
|
3717
|
+
if r2
|
3718
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
3719
|
+
r0 = r2
|
3720
|
+
else
|
3721
|
+
@index = i0
|
3722
|
+
r0 = nil
|
3723
|
+
end
|
3724
|
+
end
|
3725
|
+
|
3726
|
+
node_cache[:ALPHA][start_index] = r0
|
3727
|
+
|
3728
|
+
r0
|
3729
|
+
end
|
3730
|
+
|
3731
|
+
end
|
3732
|
+
|
3733
|
+
class EDNGRAMMARParser < Treetop::Runtime::CompiledParser
|
3734
|
+
include EDNGRAMMAR
|
3735
|
+
end
|
3736
|
+
|