origen_verilog 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21754cb54ea4c8ce9b073264a796f2ff18e79740
4
- data.tar.gz: 99caa65a1e1128d1cce33889e2333fc2c8df6b5a
3
+ metadata.gz: 0207e203009d5cf40464956c13a925c766664943
4
+ data.tar.gz: ae778926da1f0107a18e75035f692ecd4a473122
5
5
  SHA512:
6
- metadata.gz: 80d9f2446499b1be8cdc77cfb2d33ae04a3a01f2a26de74535653354648b2b1108840f557295b07c98314d303aae69c37cdc0557000fa410cfdd2443ac15e5db
7
- data.tar.gz: d34de4b2019034a6dac31b6b316b6e4cfbf8a807e78e27445923813f644d4954853a32bcf0649d196f9ea157952f492ec6572087e51a49e6cc864e4300dd1f12
6
+ metadata.gz: d54a3168ae0487c033bf5512e2c3e6238caa324595e89c062dca8a10843911ba76fa4e2a861fff3c1227a0792d7a2523e0ab7863e4b85bbea2297ffc7044b6fb
7
+ data.tar.gz: 5db1b07f5e7ee55ccc5c7555af875e754d33d04e19ace6461a090c5c0ac0db9d452118f85831af22c9832ee6e79f547700aaaac67fd2d72f2746ad6a3773f770
data/config/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module OrigenVerilog
2
2
  MAJOR = 0
3
3
  MINOR = 2
4
- BUGFIX = 0
4
+ BUGFIX = 1
5
5
  DEV = nil
6
6
 
7
7
  VERSION = [MAJOR, MINOR, BUGFIX].join(".") + (DEV ? ".pre#{DEV}" : '')
@@ -0,0 +1,2848 @@
1
+ # Autogenerated from a Treetop grammar. Edits may be lost.
2
+
3
+
4
+ module OrigenVerilog
5
+ # The preprocessor implements the below compiler directives, fully substituting
6
+ # and including/excluding the text as appropriate before handing over the pre-processed
7
+ # text to be parsed as Verilog.
8
+ #
9
+ # Any compiler directives not listed below will be parsed during the main Verilog parsing
10
+ # stage and will be included in the Verilog AST.
11
+ #
12
+ # * define
13
+ # * undef
14
+ # * ifdef
15
+ # * ifndef
16
+ # * include
17
+ # * error
18
+ module Preprocessor
19
+ module Grammar
20
+ include Treetop::Runtime
21
+
22
+ def root
23
+ @root ||= :source
24
+ end
25
+
26
+ include Verilog::Grammar
27
+
28
+ module Source0
29
+ def to_ast
30
+ n :source, *elements_to_ast
31
+ end
32
+ end
33
+
34
+ def _nt_source
35
+ start_index = index
36
+ if node_cache[:source].has_key?(index)
37
+ cached = node_cache[:source][index]
38
+ if cached
39
+ node_cache[:source][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
40
+ @index = cached.interval.end
41
+ end
42
+ return cached
43
+ end
44
+
45
+ s0, i0 = [], index
46
+ loop do
47
+ r1 = _nt_source_items
48
+ if r1
49
+ s0 << r1
50
+ else
51
+ break
52
+ end
53
+ end
54
+ if s0.empty?
55
+ @index = i0
56
+ r0 = nil
57
+ else
58
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
59
+ r0.extend(Source0)
60
+ r0.extend(Source0)
61
+ end
62
+
63
+ node_cache[:source][start_index] = r0
64
+
65
+ r0
66
+ end
67
+
68
+ def _nt_source_items
69
+ start_index = index
70
+ if node_cache[:source_items].has_key?(index)
71
+ cached = node_cache[:source_items][index]
72
+ if cached
73
+ node_cache[:source_items][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
74
+ @index = cached.interval.end
75
+ end
76
+ return cached
77
+ end
78
+
79
+ i0 = index
80
+ r1 = _nt_comment
81
+ if r1
82
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
83
+ r0 = r1
84
+ else
85
+ r2 = _nt_compiler_directive
86
+ if r2
87
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
88
+ r0 = r2
89
+ else
90
+ r3 = _nt_macro_reference
91
+ if r3
92
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
93
+ r0 = r3
94
+ else
95
+ r4 = _nt_text_block
96
+ if r4
97
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
98
+ r0 = r4
99
+ else
100
+ @index = i0
101
+ r0 = nil
102
+ end
103
+ end
104
+ end
105
+ end
106
+
107
+ node_cache[:source_items][start_index] = r0
108
+
109
+ r0
110
+ end
111
+
112
+ module TextBlock0
113
+ end
114
+
115
+ module TextBlock1
116
+ def to_ast
117
+ n :text_block, text_value
118
+ end
119
+ end
120
+
121
+ def _nt_text_block
122
+ start_index = index
123
+ if node_cache[:text_block].has_key?(index)
124
+ cached = node_cache[:text_block][index]
125
+ if cached
126
+ node_cache[:text_block][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
127
+ @index = cached.interval.end
128
+ end
129
+ return cached
130
+ end
131
+
132
+ s0, i0 = [], index
133
+ loop do
134
+ i1, s1 = index, []
135
+ i2 = index
136
+ i3 = index
137
+ r4 = _nt_comment
138
+ if r4
139
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
140
+ r3 = r4
141
+ else
142
+ r5 = _nt_compiler_directive
143
+ if r5
144
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
145
+ r3 = r5
146
+ else
147
+ r6 = _nt_compiler_directive_terminator
148
+ if r6
149
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
150
+ r3 = r6
151
+ else
152
+ r7 = _nt_macro_reference
153
+ if r7
154
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
155
+ r3 = r7
156
+ else
157
+ @index = i3
158
+ r3 = nil
159
+ end
160
+ end
161
+ end
162
+ end
163
+ if r3
164
+ @index = i2
165
+ r2 = nil
166
+ terminal_parse_failure("(any alternative)", true)
167
+ else
168
+ @terminal_failures.pop
169
+ @index = i2
170
+ r2 = instantiate_node(SyntaxNode,input, index...index)
171
+ end
172
+ s1 << r2
173
+ if r2
174
+ if index < input_length
175
+ r8 = true
176
+ @index += 1
177
+ else
178
+ terminal_parse_failure("any character")
179
+ r8 = nil
180
+ end
181
+ s1 << r8
182
+ end
183
+ if s1.last
184
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
185
+ r1.extend(TextBlock0)
186
+ else
187
+ @index = i1
188
+ r1 = nil
189
+ end
190
+ if r1
191
+ s0 << r1
192
+ else
193
+ break
194
+ end
195
+ end
196
+ if s0.empty?
197
+ @index = i0
198
+ r0 = nil
199
+ else
200
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
201
+ r0.extend(TextBlock1)
202
+ r0.extend(TextBlock1)
203
+ end
204
+
205
+ node_cache[:text_block][start_index] = r0
206
+
207
+ r0
208
+ end
209
+
210
+ def _nt_compiler_directive
211
+ start_index = index
212
+ if node_cache[:compiler_directive].has_key?(index)
213
+ cached = node_cache[:compiler_directive][index]
214
+ if cached
215
+ node_cache[:compiler_directive][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
216
+ @index = cached.interval.end
217
+ end
218
+ return cached
219
+ end
220
+
221
+ i0 = index
222
+ r1 = _nt_text_macro_definition
223
+ if r1
224
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
225
+ r0 = r1
226
+ else
227
+ r2 = _nt_undefine_compiler_directive
228
+ if r2
229
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
230
+ r0 = r2
231
+ else
232
+ r3 = _nt_ifdef_directive
233
+ if r3
234
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
235
+ r0 = r3
236
+ else
237
+ r4 = _nt_ifndef_directive
238
+ if r4
239
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
240
+ r0 = r4
241
+ else
242
+ r5 = _nt_include_compiler_directive
243
+ if r5
244
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
245
+ r0 = r5
246
+ else
247
+ r6 = _nt_error_compiler_directive
248
+ if r6
249
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
250
+ r0 = r6
251
+ else
252
+ @index = i0
253
+ r0 = nil
254
+ end
255
+ end
256
+ end
257
+ end
258
+ end
259
+ end
260
+
261
+ node_cache[:compiler_directive][start_index] = r0
262
+
263
+ r0
264
+ end
265
+
266
+ def _nt_compiler_directive_terminator
267
+ start_index = index
268
+ if node_cache[:compiler_directive_terminator].has_key?(index)
269
+ cached = node_cache[:compiler_directive_terminator][index]
270
+ if cached
271
+ node_cache[:compiler_directive_terminator][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
272
+ @index = cached.interval.end
273
+ end
274
+ return cached
275
+ end
276
+
277
+ i0 = index
278
+ if (match_len = has_terminal?("`else", false, index))
279
+ r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
280
+ @index += match_len
281
+ else
282
+ terminal_parse_failure('"`else"')
283
+ r1 = nil
284
+ end
285
+ if r1
286
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
287
+ r0 = r1
288
+ else
289
+ if (match_len = has_terminal?("`elsif", false, index))
290
+ r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
291
+ @index += match_len
292
+ else
293
+ terminal_parse_failure('"`elsif"')
294
+ r2 = nil
295
+ end
296
+ if r2
297
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
298
+ r0 = r2
299
+ else
300
+ if (match_len = has_terminal?("`endif", false, index))
301
+ r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
302
+ @index += match_len
303
+ else
304
+ terminal_parse_failure('"`endif"')
305
+ r3 = nil
306
+ end
307
+ if r3
308
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
309
+ r0 = r3
310
+ else
311
+ @index = i0
312
+ r0 = nil
313
+ end
314
+ end
315
+ end
316
+
317
+ node_cache[:compiler_directive_terminator][start_index] = r0
318
+
319
+ r0
320
+ end
321
+
322
+ module MacroReference0
323
+ def text_macro_identifier
324
+ elements[1]
325
+ end
326
+ end
327
+
328
+ module MacroReference1
329
+ def args
330
+ elements[2]
331
+ end
332
+
333
+ end
334
+
335
+ module MacroReference2
336
+ def name
337
+ elements[1]
338
+ end
339
+
340
+ def s2
341
+ elements[3]
342
+ end
343
+ end
344
+
345
+ module MacroReference3
346
+ def to_ast
347
+ if s2.respond_to?(:args)
348
+ n :macro_reference, name.text_value, s2.args.to_ast
349
+ else
350
+ n :macro_reference, name.text_value
351
+ end
352
+ end
353
+ end
354
+
355
+ def _nt_macro_reference
356
+ start_index = index
357
+ if node_cache[:macro_reference].has_key?(index)
358
+ cached = node_cache[:macro_reference][index]
359
+ if cached
360
+ node_cache[:macro_reference][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
361
+ @index = cached.interval.end
362
+ end
363
+ return cached
364
+ end
365
+
366
+ i0, s0 = index, []
367
+ if (match_len = has_terminal?("`", false, index))
368
+ r1 = true
369
+ @index += match_len
370
+ else
371
+ terminal_parse_failure('"`"')
372
+ r1 = nil
373
+ end
374
+ s0 << r1
375
+ if r1
376
+ i2, s2 = index, []
377
+ i3 = index
378
+ r4 = _nt_illegal_macro_reference
379
+ if r4
380
+ @index = i3
381
+ r3 = nil
382
+ else
383
+ @index = i3
384
+ r3 = instantiate_node(SyntaxNode,input, index...index)
385
+ end
386
+ s2 << r3
387
+ if r3
388
+ r5 = _nt_text_macro_identifier
389
+ s2 << r5
390
+ end
391
+ if s2.last
392
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
393
+ r2.extend(MacroReference0)
394
+ else
395
+ @index = i2
396
+ r2 = nil
397
+ end
398
+ s0 << r2
399
+ if r2
400
+ s6, i6 = [], index
401
+ loop do
402
+ r7 = _nt_space
403
+ if r7
404
+ s6 << r7
405
+ else
406
+ break
407
+ end
408
+ end
409
+ r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
410
+ s0 << r6
411
+ if r6
412
+ i9, s9 = index, []
413
+ if (match_len = has_terminal?("(", false, index))
414
+ r10 = true
415
+ @index += match_len
416
+ else
417
+ terminal_parse_failure('"("')
418
+ r10 = nil
419
+ end
420
+ s9 << r10
421
+ if r10
422
+ s11, i11 = [], index
423
+ loop do
424
+ r12 = _nt_space
425
+ if r12
426
+ s11 << r12
427
+ else
428
+ break
429
+ end
430
+ end
431
+ r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
432
+ s9 << r11
433
+ if r11
434
+ r13 = _nt_list_of_actual_arguments
435
+ s9 << r13
436
+ if r13
437
+ s14, i14 = [], index
438
+ loop do
439
+ r15 = _nt_space
440
+ if r15
441
+ s14 << r15
442
+ else
443
+ break
444
+ end
445
+ end
446
+ r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
447
+ s9 << r14
448
+ if r14
449
+ if (match_len = has_terminal?(")", false, index))
450
+ r16 = true
451
+ @index += match_len
452
+ else
453
+ terminal_parse_failure('")"')
454
+ r16 = nil
455
+ end
456
+ s9 << r16
457
+ end
458
+ end
459
+ end
460
+ end
461
+ if s9.last
462
+ r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
463
+ r9.extend(MacroReference1)
464
+ else
465
+ @index = i9
466
+ r9 = nil
467
+ end
468
+ if r9
469
+ r8 = r9
470
+ else
471
+ r8 = instantiate_node(SyntaxNode,input, index...index)
472
+ end
473
+ s0 << r8
474
+ end
475
+ end
476
+ end
477
+ if s0.last
478
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
479
+ r0.extend(MacroReference2)
480
+ r0.extend(MacroReference3)
481
+ else
482
+ @index = i0
483
+ r0 = nil
484
+ end
485
+
486
+ node_cache[:macro_reference][start_index] = r0
487
+
488
+ r0
489
+ end
490
+
491
+ module ListOfActualArguments0
492
+ def actual_argument
493
+ elements[3]
494
+ end
495
+ end
496
+
497
+ module ListOfActualArguments1
498
+ def actual_argument
499
+ elements[0]
500
+ end
501
+
502
+ end
503
+
504
+ module ListOfActualArguments2
505
+ def to_ast
506
+ n :arguments, *elements_to_ast
507
+ end
508
+ end
509
+
510
+ def _nt_list_of_actual_arguments
511
+ start_index = index
512
+ if node_cache[:list_of_actual_arguments].has_key?(index)
513
+ cached = node_cache[:list_of_actual_arguments][index]
514
+ if cached
515
+ node_cache[:list_of_actual_arguments][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
516
+ @index = cached.interval.end
517
+ end
518
+ return cached
519
+ end
520
+
521
+ i0, s0 = index, []
522
+ r1 = _nt_actual_argument
523
+ s0 << r1
524
+ if r1
525
+ s2, i2 = [], index
526
+ loop do
527
+ i3, s3 = index, []
528
+ s4, i4 = [], index
529
+ loop do
530
+ r5 = _nt_space
531
+ if r5
532
+ s4 << r5
533
+ else
534
+ break
535
+ end
536
+ end
537
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
538
+ s3 << r4
539
+ if r4
540
+ if (match_len = has_terminal?(',', false, index))
541
+ r6 = true
542
+ @index += match_len
543
+ else
544
+ terminal_parse_failure('\',\'')
545
+ r6 = nil
546
+ end
547
+ s3 << r6
548
+ if r6
549
+ s7, i7 = [], index
550
+ loop do
551
+ r8 = _nt_space
552
+ if r8
553
+ s7 << r8
554
+ else
555
+ break
556
+ end
557
+ end
558
+ r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
559
+ s3 << r7
560
+ if r7
561
+ r9 = _nt_actual_argument
562
+ s3 << r9
563
+ end
564
+ end
565
+ end
566
+ if s3.last
567
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
568
+ r3.extend(ListOfActualArguments0)
569
+ else
570
+ @index = i3
571
+ r3 = nil
572
+ end
573
+ if r3
574
+ s2 << r3
575
+ else
576
+ break
577
+ end
578
+ end
579
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
580
+ s0 << r2
581
+ end
582
+ if s0.last
583
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
584
+ r0.extend(ListOfActualArguments1)
585
+ r0.extend(ListOfActualArguments2)
586
+ else
587
+ @index = i0
588
+ r0 = nil
589
+ end
590
+
591
+ node_cache[:list_of_actual_arguments][start_index] = r0
592
+
593
+ r0
594
+ end
595
+
596
+ module ActualArgument0
597
+ def to_ast
598
+ text_value
599
+ end
600
+ end
601
+
602
+ def _nt_actual_argument
603
+ start_index = index
604
+ if node_cache[:actual_argument].has_key?(index)
605
+ cached = node_cache[:actual_argument][index]
606
+ if cached
607
+ node_cache[:actual_argument][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
608
+ @index = cached.interval.end
609
+ end
610
+ return cached
611
+ end
612
+
613
+ s0, i0 = [], index
614
+ loop do
615
+ r1 = _nt_actual_argument_section
616
+ if r1
617
+ s0 << r1
618
+ else
619
+ break
620
+ end
621
+ end
622
+ if s0.empty?
623
+ @index = i0
624
+ r0 = nil
625
+ else
626
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
627
+ r0.extend(ActualArgument0)
628
+ r0.extend(ActualArgument0)
629
+ end
630
+
631
+ node_cache[:actual_argument][start_index] = r0
632
+
633
+ r0
634
+ end
635
+
636
+ def _nt_actual_argument_section
637
+ start_index = index
638
+ if node_cache[:actual_argument_section].has_key?(index)
639
+ cached = node_cache[:actual_argument_section][index]
640
+ if cached
641
+ node_cache[:actual_argument_section][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
642
+ @index = cached.interval.end
643
+ end
644
+ return cached
645
+ end
646
+
647
+ i0 = index
648
+ if has_terminal?(@regexps[gr = '\A[^,(){}\\[\\]]'] ||= Regexp.new(gr), :regexp, index)
649
+ r1 = true
650
+ @index += 1
651
+ else
652
+ terminal_parse_failure('[^,(){}\\[\\]]')
653
+ r1 = nil
654
+ end
655
+ if r1
656
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
657
+ r0 = r1
658
+ else
659
+ r2 = _nt_balanced_bracket_string
660
+ if r2
661
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
662
+ r0 = r2
663
+ else
664
+ r3 = _nt_balanced_square_bracket_string
665
+ if r3
666
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
667
+ r0 = r3
668
+ else
669
+ r4 = _nt_balanced_curly_bracket_string
670
+ if r4
671
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
672
+ r0 = r4
673
+ else
674
+ @index = i0
675
+ r0 = nil
676
+ end
677
+ end
678
+ end
679
+ end
680
+
681
+ node_cache[:actual_argument_section][start_index] = r0
682
+
683
+ r0
684
+ end
685
+
686
+ module BalancedBracketString0
687
+ end
688
+
689
+ def _nt_balanced_bracket_string
690
+ start_index = index
691
+ if node_cache[:balanced_bracket_string].has_key?(index)
692
+ cached = node_cache[:balanced_bracket_string][index]
693
+ if cached
694
+ node_cache[:balanced_bracket_string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
695
+ @index = cached.interval.end
696
+ end
697
+ return cached
698
+ end
699
+
700
+ i0, s0 = index, []
701
+ if (match_len = has_terminal?("(", false, index))
702
+ r1 = true
703
+ @index += match_len
704
+ else
705
+ terminal_parse_failure('"("')
706
+ r1 = nil
707
+ end
708
+ s0 << r1
709
+ if r1
710
+ s2, i2 = [], index
711
+ loop do
712
+ i3 = index
713
+ if has_terminal?(@regexps[gr = '\A[^\\(\\)]'] ||= Regexp.new(gr), :regexp, index)
714
+ r4 = true
715
+ @index += 1
716
+ else
717
+ terminal_parse_failure('[^\\(\\)]')
718
+ r4 = nil
719
+ end
720
+ if r4
721
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
722
+ r3 = r4
723
+ else
724
+ r5 = _nt_balanced_bracket_string
725
+ if r5
726
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
727
+ r3 = r5
728
+ else
729
+ @index = i3
730
+ r3 = nil
731
+ end
732
+ end
733
+ if r3
734
+ s2 << r3
735
+ else
736
+ break
737
+ end
738
+ end
739
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
740
+ s0 << r2
741
+ if r2
742
+ if (match_len = has_terminal?(")", false, index))
743
+ r6 = true
744
+ @index += match_len
745
+ else
746
+ terminal_parse_failure('")"')
747
+ r6 = nil
748
+ end
749
+ s0 << r6
750
+ end
751
+ end
752
+ if s0.last
753
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
754
+ r0.extend(BalancedBracketString0)
755
+ else
756
+ @index = i0
757
+ r0 = nil
758
+ end
759
+
760
+ node_cache[:balanced_bracket_string][start_index] = r0
761
+
762
+ r0
763
+ end
764
+
765
+ module BalancedSquareBracketString0
766
+ end
767
+
768
+ def _nt_balanced_square_bracket_string
769
+ start_index = index
770
+ if node_cache[:balanced_square_bracket_string].has_key?(index)
771
+ cached = node_cache[:balanced_square_bracket_string][index]
772
+ if cached
773
+ node_cache[:balanced_square_bracket_string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
774
+ @index = cached.interval.end
775
+ end
776
+ return cached
777
+ end
778
+
779
+ i0, s0 = index, []
780
+ if (match_len = has_terminal?("[", false, index))
781
+ r1 = true
782
+ @index += match_len
783
+ else
784
+ terminal_parse_failure('"["')
785
+ r1 = nil
786
+ end
787
+ s0 << r1
788
+ if r1
789
+ s2, i2 = [], index
790
+ loop do
791
+ i3 = index
792
+ if has_terminal?(@regexps[gr = '\A[^\\[\\]]'] ||= Regexp.new(gr), :regexp, index)
793
+ r4 = true
794
+ @index += 1
795
+ else
796
+ terminal_parse_failure('[^\\[\\]]')
797
+ r4 = nil
798
+ end
799
+ if r4
800
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
801
+ r3 = r4
802
+ else
803
+ r5 = _nt_balanced_square_bracket_string
804
+ if r5
805
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
806
+ r3 = r5
807
+ else
808
+ @index = i3
809
+ r3 = nil
810
+ end
811
+ end
812
+ if r3
813
+ s2 << r3
814
+ else
815
+ break
816
+ end
817
+ end
818
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
819
+ s0 << r2
820
+ if r2
821
+ if (match_len = has_terminal?("]", false, index))
822
+ r6 = true
823
+ @index += match_len
824
+ else
825
+ terminal_parse_failure('"]"')
826
+ r6 = nil
827
+ end
828
+ s0 << r6
829
+ end
830
+ end
831
+ if s0.last
832
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
833
+ r0.extend(BalancedSquareBracketString0)
834
+ else
835
+ @index = i0
836
+ r0 = nil
837
+ end
838
+
839
+ node_cache[:balanced_square_bracket_string][start_index] = r0
840
+
841
+ r0
842
+ end
843
+
844
+ module BalancedCurlyBracketString0
845
+ end
846
+
847
+ def _nt_balanced_curly_bracket_string
848
+ start_index = index
849
+ if node_cache[:balanced_curly_bracket_string].has_key?(index)
850
+ cached = node_cache[:balanced_curly_bracket_string][index]
851
+ if cached
852
+ node_cache[:balanced_curly_bracket_string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
853
+ @index = cached.interval.end
854
+ end
855
+ return cached
856
+ end
857
+
858
+ i0, s0 = index, []
859
+ if (match_len = has_terminal?("{", false, index))
860
+ r1 = true
861
+ @index += match_len
862
+ else
863
+ terminal_parse_failure('"{"')
864
+ r1 = nil
865
+ end
866
+ s0 << r1
867
+ if r1
868
+ s2, i2 = [], index
869
+ loop do
870
+ i3 = index
871
+ if has_terminal?(@regexps[gr = '\A[^\\{\\}]'] ||= Regexp.new(gr), :regexp, index)
872
+ r4 = true
873
+ @index += 1
874
+ else
875
+ terminal_parse_failure('[^\\{\\}]')
876
+ r4 = nil
877
+ end
878
+ if r4
879
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
880
+ r3 = r4
881
+ else
882
+ r5 = _nt_balanced_curly_bracket_string
883
+ if r5
884
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
885
+ r3 = r5
886
+ else
887
+ @index = i3
888
+ r3 = nil
889
+ end
890
+ end
891
+ if r3
892
+ s2 << r3
893
+ else
894
+ break
895
+ end
896
+ end
897
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
898
+ s0 << r2
899
+ if r2
900
+ if (match_len = has_terminal?("}", false, index))
901
+ r6 = true
902
+ @index += match_len
903
+ else
904
+ terminal_parse_failure('"}"')
905
+ r6 = nil
906
+ end
907
+ s0 << r6
908
+ end
909
+ end
910
+ if s0.last
911
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
912
+ r0.extend(BalancedCurlyBracketString0)
913
+ else
914
+ @index = i0
915
+ r0 = nil
916
+ end
917
+
918
+ node_cache[:balanced_curly_bracket_string][start_index] = r0
919
+
920
+ r0
921
+ end
922
+
923
+ def _nt_illegal_macro_reference
924
+ start_index = index
925
+ if node_cache[:illegal_macro_reference].has_key?(index)
926
+ cached = node_cache[:illegal_macro_reference][index]
927
+ if cached
928
+ node_cache[:illegal_macro_reference][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
929
+ @index = cached.interval.end
930
+ end
931
+ return cached
932
+ end
933
+
934
+ i0 = index
935
+ if (match_len = has_terminal?("begin_keywords", false, index))
936
+ r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
937
+ @index += match_len
938
+ else
939
+ terminal_parse_failure('"begin_keywords"')
940
+ r1 = nil
941
+ end
942
+ if r1
943
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
944
+ r0 = r1
945
+ else
946
+ if (match_len = has_terminal?("celldefine", false, index))
947
+ r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
948
+ @index += match_len
949
+ else
950
+ terminal_parse_failure('"celldefine"')
951
+ r2 = nil
952
+ end
953
+ if r2
954
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
955
+ r0 = r2
956
+ else
957
+ if (match_len = has_terminal?("default_nettype", false, index))
958
+ r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
959
+ @index += match_len
960
+ else
961
+ terminal_parse_failure('"default_nettype"')
962
+ r3 = nil
963
+ end
964
+ if r3
965
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
966
+ r0 = r3
967
+ else
968
+ if (match_len = has_terminal?("define", false, index))
969
+ r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
970
+ @index += match_len
971
+ else
972
+ terminal_parse_failure('"define"')
973
+ r4 = nil
974
+ end
975
+ if r4
976
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
977
+ r0 = r4
978
+ else
979
+ if (match_len = has_terminal?("else", false, index))
980
+ r5 = instantiate_node(SyntaxNode,input, index...(index + match_len))
981
+ @index += match_len
982
+ else
983
+ terminal_parse_failure('"else"')
984
+ r5 = nil
985
+ end
986
+ if r5
987
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
988
+ r0 = r5
989
+ else
990
+ if (match_len = has_terminal?("elsif", false, index))
991
+ r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
992
+ @index += match_len
993
+ else
994
+ terminal_parse_failure('"elsif"')
995
+ r6 = nil
996
+ end
997
+ if r6
998
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
999
+ r0 = r6
1000
+ else
1001
+ if (match_len = has_terminal?("end_keywords", false, index))
1002
+ r7 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1003
+ @index += match_len
1004
+ else
1005
+ terminal_parse_failure('"end_keywords"')
1006
+ r7 = nil
1007
+ end
1008
+ if r7
1009
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
1010
+ r0 = r7
1011
+ else
1012
+ if (match_len = has_terminal?("endcelldefine", false, index))
1013
+ r8 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1014
+ @index += match_len
1015
+ else
1016
+ terminal_parse_failure('"endcelldefine"')
1017
+ r8 = nil
1018
+ end
1019
+ if r8
1020
+ r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
1021
+ r0 = r8
1022
+ else
1023
+ if (match_len = has_terminal?("endif", false, index))
1024
+ r9 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1025
+ @index += match_len
1026
+ else
1027
+ terminal_parse_failure('"endif"')
1028
+ r9 = nil
1029
+ end
1030
+ if r9
1031
+ r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
1032
+ r0 = r9
1033
+ else
1034
+ if (match_len = has_terminal?("ifdef", false, index))
1035
+ r10 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1036
+ @index += match_len
1037
+ else
1038
+ terminal_parse_failure('"ifdef"')
1039
+ r10 = nil
1040
+ end
1041
+ if r10
1042
+ r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
1043
+ r0 = r10
1044
+ else
1045
+ if (match_len = has_terminal?("ifndef", false, index))
1046
+ r11 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1047
+ @index += match_len
1048
+ else
1049
+ terminal_parse_failure('"ifndef"')
1050
+ r11 = nil
1051
+ end
1052
+ if r11
1053
+ r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
1054
+ r0 = r11
1055
+ else
1056
+ if (match_len = has_terminal?("include", false, index))
1057
+ r12 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1058
+ @index += match_len
1059
+ else
1060
+ terminal_parse_failure('"include"')
1061
+ r12 = nil
1062
+ end
1063
+ if r12
1064
+ r12 = SyntaxNode.new(input, (index-1)...index) if r12 == true
1065
+ r0 = r12
1066
+ else
1067
+ if (match_len = has_terminal?("line", false, index))
1068
+ r13 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1069
+ @index += match_len
1070
+ else
1071
+ terminal_parse_failure('"line"')
1072
+ r13 = nil
1073
+ end
1074
+ if r13
1075
+ r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true
1076
+ r0 = r13
1077
+ else
1078
+ if (match_len = has_terminal?("nounconnected_drive", false, index))
1079
+ r14 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1080
+ @index += match_len
1081
+ else
1082
+ terminal_parse_failure('"nounconnected_drive"')
1083
+ r14 = nil
1084
+ end
1085
+ if r14
1086
+ r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true
1087
+ r0 = r14
1088
+ else
1089
+ if (match_len = has_terminal?("pragma", false, index))
1090
+ r15 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1091
+ @index += match_len
1092
+ else
1093
+ terminal_parse_failure('"pragma"')
1094
+ r15 = nil
1095
+ end
1096
+ if r15
1097
+ r15 = SyntaxNode.new(input, (index-1)...index) if r15 == true
1098
+ r0 = r15
1099
+ else
1100
+ if (match_len = has_terminal?("resetall", false, index))
1101
+ r16 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1102
+ @index += match_len
1103
+ else
1104
+ terminal_parse_failure('"resetall"')
1105
+ r16 = nil
1106
+ end
1107
+ if r16
1108
+ r16 = SyntaxNode.new(input, (index-1)...index) if r16 == true
1109
+ r0 = r16
1110
+ else
1111
+ if (match_len = has_terminal?("timescale", false, index))
1112
+ r17 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1113
+ @index += match_len
1114
+ else
1115
+ terminal_parse_failure('"timescale"')
1116
+ r17 = nil
1117
+ end
1118
+ if r17
1119
+ r17 = SyntaxNode.new(input, (index-1)...index) if r17 == true
1120
+ r0 = r17
1121
+ else
1122
+ if (match_len = has_terminal?("unconnected_drive", false, index))
1123
+ r18 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1124
+ @index += match_len
1125
+ else
1126
+ terminal_parse_failure('"unconnected_drive"')
1127
+ r18 = nil
1128
+ end
1129
+ if r18
1130
+ r18 = SyntaxNode.new(input, (index-1)...index) if r18 == true
1131
+ r0 = r18
1132
+ else
1133
+ if (match_len = has_terminal?("undef", false, index))
1134
+ r19 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1135
+ @index += match_len
1136
+ else
1137
+ terminal_parse_failure('"undef"')
1138
+ r19 = nil
1139
+ end
1140
+ if r19
1141
+ r19 = SyntaxNode.new(input, (index-1)...index) if r19 == true
1142
+ r0 = r19
1143
+ else
1144
+ if (match_len = has_terminal?("error", false, index))
1145
+ r20 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1146
+ @index += match_len
1147
+ else
1148
+ terminal_parse_failure('"error"')
1149
+ r20 = nil
1150
+ end
1151
+ if r20
1152
+ r20 = SyntaxNode.new(input, (index-1)...index) if r20 == true
1153
+ r0 = r20
1154
+ else
1155
+ @index = i0
1156
+ r0 = nil
1157
+ end
1158
+ end
1159
+ end
1160
+ end
1161
+ end
1162
+ end
1163
+ end
1164
+ end
1165
+ end
1166
+ end
1167
+ end
1168
+ end
1169
+ end
1170
+ end
1171
+ end
1172
+ end
1173
+ end
1174
+ end
1175
+ end
1176
+ end
1177
+
1178
+ node_cache[:illegal_macro_reference][start_index] = r0
1179
+
1180
+ r0
1181
+ end
1182
+
1183
+ module ErrorCompilerDirective0
1184
+ def filename
1185
+ elements[4]
1186
+ end
1187
+
1188
+ end
1189
+
1190
+ module ErrorCompilerDirective1
1191
+ def to_ast
1192
+ n :error, *elements_to_ast
1193
+ end
1194
+ end
1195
+
1196
+ def _nt_error_compiler_directive
1197
+ start_index = index
1198
+ if node_cache[:error_compiler_directive].has_key?(index)
1199
+ cached = node_cache[:error_compiler_directive][index]
1200
+ if cached
1201
+ node_cache[:error_compiler_directive][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1202
+ @index = cached.interval.end
1203
+ end
1204
+ return cached
1205
+ end
1206
+
1207
+ i0, s0 = index, []
1208
+ if (match_len = has_terminal?("`error", false, index))
1209
+ r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1210
+ @index += match_len
1211
+ else
1212
+ terminal_parse_failure('"`error"')
1213
+ r1 = nil
1214
+ end
1215
+ s0 << r1
1216
+ if r1
1217
+ s2, i2 = [], index
1218
+ loop do
1219
+ r3 = _nt_space
1220
+ if r3
1221
+ s2 << r3
1222
+ else
1223
+ break
1224
+ end
1225
+ end
1226
+ if s2.empty?
1227
+ @index = i2
1228
+ r2 = nil
1229
+ else
1230
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1231
+ end
1232
+ s0 << r2
1233
+ if r2
1234
+ if (match_len = has_terminal?('"', false, index))
1235
+ r4 = true
1236
+ @index += match_len
1237
+ else
1238
+ terminal_parse_failure('\'"\'')
1239
+ r4 = nil
1240
+ end
1241
+ s0 << r4
1242
+ if r4
1243
+ s5, i5 = [], index
1244
+ loop do
1245
+ r6 = _nt_space
1246
+ if r6
1247
+ s5 << r6
1248
+ else
1249
+ break
1250
+ end
1251
+ end
1252
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
1253
+ s0 << r5
1254
+ if r5
1255
+ r7 = _nt_filename
1256
+ s0 << r7
1257
+ if r7
1258
+ s8, i8 = [], index
1259
+ loop do
1260
+ r9 = _nt_space
1261
+ if r9
1262
+ s8 << r9
1263
+ else
1264
+ break
1265
+ end
1266
+ end
1267
+ r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
1268
+ s0 << r8
1269
+ if r8
1270
+ if (match_len = has_terminal?('"', false, index))
1271
+ r10 = true
1272
+ @index += match_len
1273
+ else
1274
+ terminal_parse_failure('\'"\'')
1275
+ r10 = nil
1276
+ end
1277
+ s0 << r10
1278
+ end
1279
+ end
1280
+ end
1281
+ end
1282
+ end
1283
+ end
1284
+ if s0.last
1285
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1286
+ r0.extend(ErrorCompilerDirective0)
1287
+ r0.extend(ErrorCompilerDirective1)
1288
+ else
1289
+ @index = i0
1290
+ r0 = nil
1291
+ end
1292
+
1293
+ node_cache[:error_compiler_directive][start_index] = r0
1294
+
1295
+ r0
1296
+ end
1297
+
1298
+ module IncludeCompilerDirective0
1299
+ def filename
1300
+ elements[4]
1301
+ end
1302
+
1303
+ end
1304
+
1305
+ module IncludeCompilerDirective1
1306
+ def to_ast
1307
+ n :include, *elements_to_ast
1308
+ end
1309
+ end
1310
+
1311
+ def _nt_include_compiler_directive
1312
+ start_index = index
1313
+ if node_cache[:include_compiler_directive].has_key?(index)
1314
+ cached = node_cache[:include_compiler_directive][index]
1315
+ if cached
1316
+ node_cache[:include_compiler_directive][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1317
+ @index = cached.interval.end
1318
+ end
1319
+ return cached
1320
+ end
1321
+
1322
+ i0, s0 = index, []
1323
+ if (match_len = has_terminal?("`include", false, index))
1324
+ r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1325
+ @index += match_len
1326
+ else
1327
+ terminal_parse_failure('"`include"')
1328
+ r1 = nil
1329
+ end
1330
+ s0 << r1
1331
+ if r1
1332
+ s2, i2 = [], index
1333
+ loop do
1334
+ r3 = _nt_space
1335
+ if r3
1336
+ s2 << r3
1337
+ else
1338
+ break
1339
+ end
1340
+ end
1341
+ if s2.empty?
1342
+ @index = i2
1343
+ r2 = nil
1344
+ else
1345
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1346
+ end
1347
+ s0 << r2
1348
+ if r2
1349
+ if (match_len = has_terminal?('"', false, index))
1350
+ r4 = true
1351
+ @index += match_len
1352
+ else
1353
+ terminal_parse_failure('\'"\'')
1354
+ r4 = nil
1355
+ end
1356
+ s0 << r4
1357
+ if r4
1358
+ s5, i5 = [], index
1359
+ loop do
1360
+ r6 = _nt_space
1361
+ if r6
1362
+ s5 << r6
1363
+ else
1364
+ break
1365
+ end
1366
+ end
1367
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
1368
+ s0 << r5
1369
+ if r5
1370
+ r7 = _nt_filename
1371
+ s0 << r7
1372
+ if r7
1373
+ s8, i8 = [], index
1374
+ loop do
1375
+ r9 = _nt_space
1376
+ if r9
1377
+ s8 << r9
1378
+ else
1379
+ break
1380
+ end
1381
+ end
1382
+ r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
1383
+ s0 << r8
1384
+ if r8
1385
+ if (match_len = has_terminal?('"', false, index))
1386
+ r10 = true
1387
+ @index += match_len
1388
+ else
1389
+ terminal_parse_failure('\'"\'')
1390
+ r10 = nil
1391
+ end
1392
+ s0 << r10
1393
+ end
1394
+ end
1395
+ end
1396
+ end
1397
+ end
1398
+ end
1399
+ if s0.last
1400
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1401
+ r0.extend(IncludeCompilerDirective0)
1402
+ r0.extend(IncludeCompilerDirective1)
1403
+ else
1404
+ @index = i0
1405
+ r0 = nil
1406
+ end
1407
+
1408
+ node_cache[:include_compiler_directive][start_index] = r0
1409
+
1410
+ r0
1411
+ end
1412
+
1413
+ module Filename0
1414
+ end
1415
+
1416
+ module Filename1
1417
+ def to_ast
1418
+ text_value.strip
1419
+ end
1420
+ end
1421
+
1422
+ def _nt_filename
1423
+ start_index = index
1424
+ if node_cache[:filename].has_key?(index)
1425
+ cached = node_cache[:filename][index]
1426
+ if cached
1427
+ node_cache[:filename][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1428
+ @index = cached.interval.end
1429
+ end
1430
+ return cached
1431
+ end
1432
+
1433
+ s0, i0 = [], index
1434
+ loop do
1435
+ i1, s1 = index, []
1436
+ i2 = index
1437
+ i3 = index
1438
+ r4 = _nt_N
1439
+ if r4
1440
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
1441
+ r3 = r4
1442
+ else
1443
+ r5 = _nt_comment
1444
+ if r5
1445
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
1446
+ r3 = r5
1447
+ else
1448
+ if (match_len = has_terminal?('"', false, index))
1449
+ r6 = true
1450
+ @index += match_len
1451
+ else
1452
+ terminal_parse_failure('\'"\'')
1453
+ r6 = nil
1454
+ end
1455
+ if r6
1456
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
1457
+ r3 = r6
1458
+ else
1459
+ @index = i3
1460
+ r3 = nil
1461
+ end
1462
+ end
1463
+ end
1464
+ if r3
1465
+ @index = i2
1466
+ r2 = nil
1467
+ terminal_parse_failure("(any alternative)", true)
1468
+ else
1469
+ @terminal_failures.pop
1470
+ @index = i2
1471
+ r2 = instantiate_node(SyntaxNode,input, index...index)
1472
+ end
1473
+ s1 << r2
1474
+ if r2
1475
+ if index < input_length
1476
+ r7 = true
1477
+ @index += 1
1478
+ else
1479
+ terminal_parse_failure("any character")
1480
+ r7 = nil
1481
+ end
1482
+ s1 << r7
1483
+ end
1484
+ if s1.last
1485
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
1486
+ r1.extend(Filename0)
1487
+ else
1488
+ @index = i1
1489
+ r1 = nil
1490
+ end
1491
+ if r1
1492
+ s0 << r1
1493
+ else
1494
+ break
1495
+ end
1496
+ end
1497
+ if s0.empty?
1498
+ @index = i0
1499
+ r0 = nil
1500
+ else
1501
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1502
+ r0.extend(Filename1)
1503
+ r0.extend(Filename1)
1504
+ end
1505
+
1506
+ node_cache[:filename][start_index] = r0
1507
+
1508
+ r0
1509
+ end
1510
+
1511
+ module TextMacroDefinition0
1512
+ def text_macro_name
1513
+ elements[2]
1514
+ end
1515
+
1516
+ end
1517
+
1518
+ module TextMacroDefinition1
1519
+ def to_ast
1520
+ n :define, *elements_to_ast
1521
+ end
1522
+ end
1523
+
1524
+ def _nt_text_macro_definition
1525
+ start_index = index
1526
+ if node_cache[:text_macro_definition].has_key?(index)
1527
+ cached = node_cache[:text_macro_definition][index]
1528
+ if cached
1529
+ node_cache[:text_macro_definition][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1530
+ @index = cached.interval.end
1531
+ end
1532
+ return cached
1533
+ end
1534
+
1535
+ i0, s0 = index, []
1536
+ if (match_len = has_terminal?("`define", false, index))
1537
+ r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1538
+ @index += match_len
1539
+ else
1540
+ terminal_parse_failure('"`define"')
1541
+ r1 = nil
1542
+ end
1543
+ s0 << r1
1544
+ if r1
1545
+ s2, i2 = [], index
1546
+ loop do
1547
+ r3 = _nt_space
1548
+ if r3
1549
+ s2 << r3
1550
+ else
1551
+ break
1552
+ end
1553
+ end
1554
+ if s2.empty?
1555
+ @index = i2
1556
+ r2 = nil
1557
+ else
1558
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1559
+ end
1560
+ s0 << r2
1561
+ if r2
1562
+ r4 = _nt_text_macro_name
1563
+ s0 << r4
1564
+ if r4
1565
+ s5, i5 = [], index
1566
+ loop do
1567
+ r6 = _nt_space
1568
+ if r6
1569
+ s5 << r6
1570
+ else
1571
+ break
1572
+ end
1573
+ end
1574
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
1575
+ s0 << r5
1576
+ if r5
1577
+ r8 = _nt_macro_text
1578
+ if r8
1579
+ r7 = r8
1580
+ else
1581
+ r7 = instantiate_node(SyntaxNode,input, index...index)
1582
+ end
1583
+ s0 << r7
1584
+ end
1585
+ end
1586
+ end
1587
+ end
1588
+ if s0.last
1589
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1590
+ r0.extend(TextMacroDefinition0)
1591
+ r0.extend(TextMacroDefinition1)
1592
+ else
1593
+ @index = i0
1594
+ r0 = nil
1595
+ end
1596
+
1597
+ node_cache[:text_macro_definition][start_index] = r0
1598
+
1599
+ r0
1600
+ end
1601
+
1602
+ module MacroText0
1603
+ def N
1604
+ elements[2]
1605
+ end
1606
+ end
1607
+
1608
+ module MacroText1
1609
+ end
1610
+
1611
+ module MacroText2
1612
+ def to_ast
1613
+ n :text, text_value.strip.gsub(/\\\s*\n/, "\n") unless text_value.empty?
1614
+ end
1615
+ end
1616
+
1617
+ def _nt_macro_text
1618
+ start_index = index
1619
+ if node_cache[:macro_text].has_key?(index)
1620
+ cached = node_cache[:macro_text][index]
1621
+ if cached
1622
+ node_cache[:macro_text][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1623
+ @index = cached.interval.end
1624
+ end
1625
+ return cached
1626
+ end
1627
+
1628
+ s0, i0 = [], index
1629
+ loop do
1630
+ i1 = index
1631
+ i2, s2 = index, []
1632
+ if (match_len = has_terminal?("\\", false, index))
1633
+ r3 = true
1634
+ @index += match_len
1635
+ else
1636
+ terminal_parse_failure('"\\\\"')
1637
+ r3 = nil
1638
+ end
1639
+ s2 << r3
1640
+ if r3
1641
+ s4, i4 = [], index
1642
+ loop do
1643
+ r5 = _nt_space
1644
+ if r5
1645
+ s4 << r5
1646
+ else
1647
+ break
1648
+ end
1649
+ end
1650
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
1651
+ s2 << r4
1652
+ if r4
1653
+ r6 = _nt_N
1654
+ s2 << r6
1655
+ end
1656
+ end
1657
+ if s2.last
1658
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1659
+ r2.extend(MacroText0)
1660
+ else
1661
+ @index = i2
1662
+ r2 = nil
1663
+ end
1664
+ if r2
1665
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
1666
+ r1 = r2
1667
+ else
1668
+ i7, s7 = index, []
1669
+ i8 = index
1670
+ i9 = index
1671
+ r10 = _nt_N
1672
+ if r10
1673
+ r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
1674
+ r9 = r10
1675
+ else
1676
+ r11 = _nt_one_line_comment
1677
+ if r11
1678
+ r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
1679
+ r9 = r11
1680
+ else
1681
+ @index = i9
1682
+ r9 = nil
1683
+ end
1684
+ end
1685
+ if r9
1686
+ @index = i8
1687
+ r8 = nil
1688
+ terminal_parse_failure("(any alternative)", true)
1689
+ else
1690
+ @terminal_failures.pop
1691
+ @index = i8
1692
+ r8 = instantiate_node(SyntaxNode,input, index...index)
1693
+ end
1694
+ s7 << r8
1695
+ if r8
1696
+ if index < input_length
1697
+ r12 = true
1698
+ @index += 1
1699
+ else
1700
+ terminal_parse_failure("any character")
1701
+ r12 = nil
1702
+ end
1703
+ s7 << r12
1704
+ end
1705
+ if s7.last
1706
+ r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
1707
+ r7.extend(MacroText1)
1708
+ else
1709
+ @index = i7
1710
+ r7 = nil
1711
+ end
1712
+ if r7
1713
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
1714
+ r1 = r7
1715
+ else
1716
+ @index = i1
1717
+ r1 = nil
1718
+ end
1719
+ end
1720
+ if r1
1721
+ s0 << r1
1722
+ else
1723
+ break
1724
+ end
1725
+ end
1726
+ if s0.empty?
1727
+ @index = i0
1728
+ r0 = nil
1729
+ else
1730
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1731
+ r0.extend(MacroText2)
1732
+ r0.extend(MacroText2)
1733
+ end
1734
+
1735
+ node_cache[:macro_text][start_index] = r0
1736
+
1737
+ r0
1738
+ end
1739
+
1740
+ module TextMacroName0
1741
+ def list_of_formal_arguments
1742
+ elements[2]
1743
+ end
1744
+
1745
+ end
1746
+
1747
+ module TextMacroName1
1748
+ def text_macro_identifier
1749
+ elements[0]
1750
+ end
1751
+
1752
+ end
1753
+
1754
+ module TextMacroName2
1755
+ def to_ast
1756
+ n :name, *elements_to_ast
1757
+ end
1758
+ end
1759
+
1760
+ def _nt_text_macro_name
1761
+ start_index = index
1762
+ if node_cache[:text_macro_name].has_key?(index)
1763
+ cached = node_cache[:text_macro_name][index]
1764
+ if cached
1765
+ node_cache[:text_macro_name][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1766
+ @index = cached.interval.end
1767
+ end
1768
+ return cached
1769
+ end
1770
+
1771
+ i0, s0 = index, []
1772
+ r1 = _nt_text_macro_identifier
1773
+ s0 << r1
1774
+ if r1
1775
+ s2, i2 = [], index
1776
+ loop do
1777
+ r3 = _nt_space
1778
+ if r3
1779
+ s2 << r3
1780
+ else
1781
+ break
1782
+ end
1783
+ end
1784
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1785
+ s0 << r2
1786
+ if r2
1787
+ i5, s5 = index, []
1788
+ if (match_len = has_terminal?("(", false, index))
1789
+ r6 = true
1790
+ @index += match_len
1791
+ else
1792
+ terminal_parse_failure('"("')
1793
+ r6 = nil
1794
+ end
1795
+ s5 << r6
1796
+ if r6
1797
+ s7, i7 = [], index
1798
+ loop do
1799
+ r8 = _nt_space
1800
+ if r8
1801
+ s7 << r8
1802
+ else
1803
+ break
1804
+ end
1805
+ end
1806
+ r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
1807
+ s5 << r7
1808
+ if r7
1809
+ r9 = _nt_list_of_formal_arguments
1810
+ s5 << r9
1811
+ if r9
1812
+ s10, i10 = [], index
1813
+ loop do
1814
+ r11 = _nt_space
1815
+ if r11
1816
+ s10 << r11
1817
+ else
1818
+ break
1819
+ end
1820
+ end
1821
+ r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
1822
+ s5 << r10
1823
+ if r10
1824
+ if (match_len = has_terminal?(")", false, index))
1825
+ r12 = true
1826
+ @index += match_len
1827
+ else
1828
+ terminal_parse_failure('")"')
1829
+ r12 = nil
1830
+ end
1831
+ s5 << r12
1832
+ end
1833
+ end
1834
+ end
1835
+ end
1836
+ if s5.last
1837
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
1838
+ r5.extend(TextMacroName0)
1839
+ else
1840
+ @index = i5
1841
+ r5 = nil
1842
+ end
1843
+ if r5
1844
+ r4 = r5
1845
+ else
1846
+ r4 = instantiate_node(SyntaxNode,input, index...index)
1847
+ end
1848
+ s0 << r4
1849
+ end
1850
+ end
1851
+ if s0.last
1852
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1853
+ r0.extend(TextMacroName1)
1854
+ r0.extend(TextMacroName2)
1855
+ else
1856
+ @index = i0
1857
+ r0 = nil
1858
+ end
1859
+
1860
+ node_cache[:text_macro_name][start_index] = r0
1861
+
1862
+ r0
1863
+ end
1864
+
1865
+ module ListOfFormalArguments0
1866
+ def formal_argument_identifier
1867
+ elements[3]
1868
+ end
1869
+ end
1870
+
1871
+ module ListOfFormalArguments1
1872
+ def formal_argument_identifier
1873
+ elements[0]
1874
+ end
1875
+
1876
+ end
1877
+
1878
+ module ListOfFormalArguments2
1879
+ def to_ast
1880
+ n :arguments, *elements_to_ast
1881
+ end
1882
+ end
1883
+
1884
+ def _nt_list_of_formal_arguments
1885
+ start_index = index
1886
+ if node_cache[:list_of_formal_arguments].has_key?(index)
1887
+ cached = node_cache[:list_of_formal_arguments][index]
1888
+ if cached
1889
+ node_cache[:list_of_formal_arguments][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1890
+ @index = cached.interval.end
1891
+ end
1892
+ return cached
1893
+ end
1894
+
1895
+ i0, s0 = index, []
1896
+ r1 = _nt_formal_argument_identifier
1897
+ s0 << r1
1898
+ if r1
1899
+ s2, i2 = [], index
1900
+ loop do
1901
+ i3, s3 = index, []
1902
+ s4, i4 = [], index
1903
+ loop do
1904
+ r5 = _nt_space
1905
+ if r5
1906
+ s4 << r5
1907
+ else
1908
+ break
1909
+ end
1910
+ end
1911
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
1912
+ s3 << r4
1913
+ if r4
1914
+ if (match_len = has_terminal?(',', false, index))
1915
+ r6 = true
1916
+ @index += match_len
1917
+ else
1918
+ terminal_parse_failure('\',\'')
1919
+ r6 = nil
1920
+ end
1921
+ s3 << r6
1922
+ if r6
1923
+ s7, i7 = [], index
1924
+ loop do
1925
+ r8 = _nt_space
1926
+ if r8
1927
+ s7 << r8
1928
+ else
1929
+ break
1930
+ end
1931
+ end
1932
+ r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
1933
+ s3 << r7
1934
+ if r7
1935
+ r9 = _nt_formal_argument_identifier
1936
+ s3 << r9
1937
+ end
1938
+ end
1939
+ end
1940
+ if s3.last
1941
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
1942
+ r3.extend(ListOfFormalArguments0)
1943
+ else
1944
+ @index = i3
1945
+ r3 = nil
1946
+ end
1947
+ if r3
1948
+ s2 << r3
1949
+ else
1950
+ break
1951
+ end
1952
+ end
1953
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1954
+ s0 << r2
1955
+ end
1956
+ if s0.last
1957
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1958
+ r0.extend(ListOfFormalArguments1)
1959
+ r0.extend(ListOfFormalArguments2)
1960
+ else
1961
+ @index = i0
1962
+ r0 = nil
1963
+ end
1964
+
1965
+ node_cache[:list_of_formal_arguments][start_index] = r0
1966
+
1967
+ r0
1968
+ end
1969
+
1970
+ def _nt_formal_argument_identifier
1971
+ start_index = index
1972
+ if node_cache[:formal_argument_identifier].has_key?(index)
1973
+ cached = node_cache[:formal_argument_identifier][index]
1974
+ if cached
1975
+ node_cache[:formal_argument_identifier][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1976
+ @index = cached.interval.end
1977
+ end
1978
+ return cached
1979
+ end
1980
+
1981
+ r0 = _nt_simple_identifier
1982
+
1983
+ node_cache[:formal_argument_identifier][start_index] = r0
1984
+
1985
+ r0
1986
+ end
1987
+
1988
+ module UndefineCompilerDirective0
1989
+ def text_macro_identifier
1990
+ elements[2]
1991
+ end
1992
+ end
1993
+
1994
+ module UndefineCompilerDirective1
1995
+ def to_ast
1996
+ n :undef, *elements_to_ast
1997
+ end
1998
+ end
1999
+
2000
+ def _nt_undefine_compiler_directive
2001
+ start_index = index
2002
+ if node_cache[:undefine_compiler_directive].has_key?(index)
2003
+ cached = node_cache[:undefine_compiler_directive][index]
2004
+ if cached
2005
+ node_cache[:undefine_compiler_directive][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2006
+ @index = cached.interval.end
2007
+ end
2008
+ return cached
2009
+ end
2010
+
2011
+ i0, s0 = index, []
2012
+ if (match_len = has_terminal?("`undef", false, index))
2013
+ r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
2014
+ @index += match_len
2015
+ else
2016
+ terminal_parse_failure('"`undef"')
2017
+ r1 = nil
2018
+ end
2019
+ s0 << r1
2020
+ if r1
2021
+ s2, i2 = [], index
2022
+ loop do
2023
+ r3 = _nt_space
2024
+ if r3
2025
+ s2 << r3
2026
+ else
2027
+ break
2028
+ end
2029
+ end
2030
+ if s2.empty?
2031
+ @index = i2
2032
+ r2 = nil
2033
+ else
2034
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
2035
+ end
2036
+ s0 << r2
2037
+ if r2
2038
+ r4 = _nt_text_macro_identifier
2039
+ s0 << r4
2040
+ end
2041
+ end
2042
+ if s0.last
2043
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2044
+ r0.extend(UndefineCompilerDirective0)
2045
+ r0.extend(UndefineCompilerDirective1)
2046
+ else
2047
+ @index = i0
2048
+ r0 = nil
2049
+ end
2050
+
2051
+ node_cache[:undefine_compiler_directive][start_index] = r0
2052
+
2053
+ r0
2054
+ end
2055
+
2056
+ module IfdefDirective0
2057
+ def label
2058
+ elements[2]
2059
+ end
2060
+
2061
+ def contents
2062
+ elements[4]
2063
+ end
2064
+ end
2065
+
2066
+ module IfdefDirective1
2067
+ def contents
2068
+ elements[2]
2069
+ end
2070
+ end
2071
+
2072
+ module IfdefDirective2
2073
+ def label
2074
+ elements[2]
2075
+ end
2076
+
2077
+ def contents
2078
+ elements[4]
2079
+ end
2080
+
2081
+ def s
2082
+ elements[5]
2083
+ end
2084
+
2085
+ def elsif_nodes
2086
+ elements[6]
2087
+ end
2088
+
2089
+ def else_node
2090
+ elements[8]
2091
+ end
2092
+
2093
+ end
2094
+
2095
+ module IfdefDirective3
2096
+ def to_ast
2097
+ node = n :ifdef, label.text_value, *elements_to_ast(contents.elements)
2098
+ elsif_nodes.elements.each do |elsif_node|
2099
+ if elsif_node.respond_to?(:contents)
2100
+ e = n :elsif, elsif_node.label.text_value, *elements_to_ast(elsif_node.contents.elements)
2101
+ node = node.updated(nil, node.children + [e])
2102
+ end
2103
+ end
2104
+ if else_node.respond_to?(:contents)
2105
+ node = node.updated(nil, node.children + [n(:else, *elements_to_ast(else_node.contents.elements))])
2106
+ end
2107
+ node
2108
+ end
2109
+ end
2110
+
2111
+ def _nt_ifdef_directive
2112
+ start_index = index
2113
+ if node_cache[:ifdef_directive].has_key?(index)
2114
+ cached = node_cache[:ifdef_directive][index]
2115
+ if cached
2116
+ node_cache[:ifdef_directive][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2117
+ @index = cached.interval.end
2118
+ end
2119
+ return cached
2120
+ end
2121
+
2122
+ i0, s0 = index, []
2123
+ if (match_len = has_terminal?("`ifdef", false, index))
2124
+ r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
2125
+ @index += match_len
2126
+ else
2127
+ terminal_parse_failure('"`ifdef"')
2128
+ r1 = nil
2129
+ end
2130
+ s0 << r1
2131
+ if r1
2132
+ s2, i2 = [], index
2133
+ loop do
2134
+ r3 = _nt_space
2135
+ if r3
2136
+ s2 << r3
2137
+ else
2138
+ break
2139
+ end
2140
+ end
2141
+ if s2.empty?
2142
+ @index = i2
2143
+ r2 = nil
2144
+ else
2145
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
2146
+ end
2147
+ s0 << r2
2148
+ if r2
2149
+ r4 = _nt_text_macro_identifier
2150
+ s0 << r4
2151
+ if r4
2152
+ s5, i5 = [], index
2153
+ loop do
2154
+ r6 = _nt_space
2155
+ if r6
2156
+ s5 << r6
2157
+ else
2158
+ break
2159
+ end
2160
+ end
2161
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
2162
+ s0 << r5
2163
+ if r5
2164
+ s7, i7 = [], index
2165
+ loop do
2166
+ r8 = _nt_source_items
2167
+ if r8
2168
+ s7 << r8
2169
+ else
2170
+ break
2171
+ end
2172
+ end
2173
+ r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
2174
+ s0 << r7
2175
+ if r7
2176
+ r9 = _nt_s
2177
+ s0 << r9
2178
+ if r9
2179
+ s10, i10 = [], index
2180
+ loop do
2181
+ i11, s11 = index, []
2182
+ if (match_len = has_terminal?("`elsif", false, index))
2183
+ r12 = instantiate_node(SyntaxNode,input, index...(index + match_len))
2184
+ @index += match_len
2185
+ else
2186
+ terminal_parse_failure('"`elsif"')
2187
+ r12 = nil
2188
+ end
2189
+ s11 << r12
2190
+ if r12
2191
+ s13, i13 = [], index
2192
+ loop do
2193
+ r14 = _nt_space
2194
+ if r14
2195
+ s13 << r14
2196
+ else
2197
+ break
2198
+ end
2199
+ end
2200
+ if s13.empty?
2201
+ @index = i13
2202
+ r13 = nil
2203
+ else
2204
+ r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
2205
+ end
2206
+ s11 << r13
2207
+ if r13
2208
+ r15 = _nt_text_macro_identifier
2209
+ s11 << r15
2210
+ if r15
2211
+ s16, i16 = [], index
2212
+ loop do
2213
+ r17 = _nt_space
2214
+ if r17
2215
+ s16 << r17
2216
+ else
2217
+ break
2218
+ end
2219
+ end
2220
+ r16 = instantiate_node(SyntaxNode,input, i16...index, s16)
2221
+ s11 << r16
2222
+ if r16
2223
+ s18, i18 = [], index
2224
+ loop do
2225
+ r19 = _nt_source_items
2226
+ if r19
2227
+ s18 << r19
2228
+ else
2229
+ break
2230
+ end
2231
+ end
2232
+ r18 = instantiate_node(SyntaxNode,input, i18...index, s18)
2233
+ s11 << r18
2234
+ end
2235
+ end
2236
+ end
2237
+ end
2238
+ if s11.last
2239
+ r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
2240
+ r11.extend(IfdefDirective0)
2241
+ else
2242
+ @index = i11
2243
+ r11 = nil
2244
+ end
2245
+ if r11
2246
+ s10 << r11
2247
+ else
2248
+ break
2249
+ end
2250
+ end
2251
+ r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
2252
+ s0 << r10
2253
+ if r10
2254
+ s20, i20 = [], index
2255
+ loop do
2256
+ r21 = _nt_space
2257
+ if r21
2258
+ s20 << r21
2259
+ else
2260
+ break
2261
+ end
2262
+ end
2263
+ r20 = instantiate_node(SyntaxNode,input, i20...index, s20)
2264
+ s0 << r20
2265
+ if r20
2266
+ i23, s23 = index, []
2267
+ if (match_len = has_terminal?("`else", false, index))
2268
+ r24 = instantiate_node(SyntaxNode,input, index...(index + match_len))
2269
+ @index += match_len
2270
+ else
2271
+ terminal_parse_failure('"`else"')
2272
+ r24 = nil
2273
+ end
2274
+ s23 << r24
2275
+ if r24
2276
+ s25, i25 = [], index
2277
+ loop do
2278
+ r26 = _nt_space
2279
+ if r26
2280
+ s25 << r26
2281
+ else
2282
+ break
2283
+ end
2284
+ end
2285
+ r25 = instantiate_node(SyntaxNode,input, i25...index, s25)
2286
+ s23 << r25
2287
+ if r25
2288
+ s27, i27 = [], index
2289
+ loop do
2290
+ r28 = _nt_source_items
2291
+ if r28
2292
+ s27 << r28
2293
+ else
2294
+ break
2295
+ end
2296
+ end
2297
+ r27 = instantiate_node(SyntaxNode,input, i27...index, s27)
2298
+ s23 << r27
2299
+ end
2300
+ end
2301
+ if s23.last
2302
+ r23 = instantiate_node(SyntaxNode,input, i23...index, s23)
2303
+ r23.extend(IfdefDirective1)
2304
+ else
2305
+ @index = i23
2306
+ r23 = nil
2307
+ end
2308
+ if r23
2309
+ r22 = r23
2310
+ else
2311
+ r22 = instantiate_node(SyntaxNode,input, index...index)
2312
+ end
2313
+ s0 << r22
2314
+ if r22
2315
+ s29, i29 = [], index
2316
+ loop do
2317
+ r30 = _nt_space
2318
+ if r30
2319
+ s29 << r30
2320
+ else
2321
+ break
2322
+ end
2323
+ end
2324
+ r29 = instantiate_node(SyntaxNode,input, i29...index, s29)
2325
+ s0 << r29
2326
+ if r29
2327
+ if (match_len = has_terminal?("`endif", false, index))
2328
+ r31 = instantiate_node(SyntaxNode,input, index...(index + match_len))
2329
+ @index += match_len
2330
+ else
2331
+ terminal_parse_failure('"`endif"')
2332
+ r31 = nil
2333
+ end
2334
+ s0 << r31
2335
+ end
2336
+ end
2337
+ end
2338
+ end
2339
+ end
2340
+ end
2341
+ end
2342
+ end
2343
+ end
2344
+ end
2345
+ if s0.last
2346
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2347
+ r0.extend(IfdefDirective2)
2348
+ r0.extend(IfdefDirective3)
2349
+ else
2350
+ @index = i0
2351
+ r0 = nil
2352
+ end
2353
+
2354
+ node_cache[:ifdef_directive][start_index] = r0
2355
+
2356
+ r0
2357
+ end
2358
+
2359
+ module IfndefDirective0
2360
+ def label
2361
+ elements[2]
2362
+ end
2363
+
2364
+ def contents
2365
+ elements[4]
2366
+ end
2367
+ end
2368
+
2369
+ module IfndefDirective1
2370
+ def contents
2371
+ elements[2]
2372
+ end
2373
+ end
2374
+
2375
+ module IfndefDirective2
2376
+ def label
2377
+ elements[2]
2378
+ end
2379
+
2380
+ def contents
2381
+ elements[4]
2382
+ end
2383
+
2384
+ def s
2385
+ elements[5]
2386
+ end
2387
+
2388
+ def elsif_nodes
2389
+ elements[6]
2390
+ end
2391
+
2392
+ def else_node
2393
+ elements[8]
2394
+ end
2395
+
2396
+ end
2397
+
2398
+ module IfndefDirective3
2399
+ def to_ast
2400
+ node = n :ifndef, label.text_value, *elements_to_ast(contents.elements)
2401
+ elsif_nodes.elements.each do |elsif_node|
2402
+ if elsif_node.respond_to?(:contents)
2403
+ e = n :elsif, elsif_node.label.text_value, *elements_to_ast(elsif_node.contents.elements)
2404
+ node = node.updated(nil, node.children + [e])
2405
+ end
2406
+ end
2407
+ if else_node.respond_to?(:contents)
2408
+ node = node.updated(nil, node.children + [n(:else, *elements_to_ast(else_node.contents.elements))])
2409
+ end
2410
+ node
2411
+ end
2412
+ end
2413
+
2414
+ def _nt_ifndef_directive
2415
+ start_index = index
2416
+ if node_cache[:ifndef_directive].has_key?(index)
2417
+ cached = node_cache[:ifndef_directive][index]
2418
+ if cached
2419
+ node_cache[:ifndef_directive][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2420
+ @index = cached.interval.end
2421
+ end
2422
+ return cached
2423
+ end
2424
+
2425
+ i0, s0 = index, []
2426
+ if (match_len = has_terminal?("`ifndef", false, index))
2427
+ r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
2428
+ @index += match_len
2429
+ else
2430
+ terminal_parse_failure('"`ifndef"')
2431
+ r1 = nil
2432
+ end
2433
+ s0 << r1
2434
+ if r1
2435
+ s2, i2 = [], index
2436
+ loop do
2437
+ r3 = _nt_space
2438
+ if r3
2439
+ s2 << r3
2440
+ else
2441
+ break
2442
+ end
2443
+ end
2444
+ if s2.empty?
2445
+ @index = i2
2446
+ r2 = nil
2447
+ else
2448
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
2449
+ end
2450
+ s0 << r2
2451
+ if r2
2452
+ r4 = _nt_text_macro_identifier
2453
+ s0 << r4
2454
+ if r4
2455
+ s5, i5 = [], index
2456
+ loop do
2457
+ r6 = _nt_space
2458
+ if r6
2459
+ s5 << r6
2460
+ else
2461
+ break
2462
+ end
2463
+ end
2464
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
2465
+ s0 << r5
2466
+ if r5
2467
+ s7, i7 = [], index
2468
+ loop do
2469
+ r8 = _nt_source_items
2470
+ if r8
2471
+ s7 << r8
2472
+ else
2473
+ break
2474
+ end
2475
+ end
2476
+ r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
2477
+ s0 << r7
2478
+ if r7
2479
+ r9 = _nt_s
2480
+ s0 << r9
2481
+ if r9
2482
+ s10, i10 = [], index
2483
+ loop do
2484
+ i11, s11 = index, []
2485
+ if (match_len = has_terminal?("`elsif", false, index))
2486
+ r12 = instantiate_node(SyntaxNode,input, index...(index + match_len))
2487
+ @index += match_len
2488
+ else
2489
+ terminal_parse_failure('"`elsif"')
2490
+ r12 = nil
2491
+ end
2492
+ s11 << r12
2493
+ if r12
2494
+ s13, i13 = [], index
2495
+ loop do
2496
+ r14 = _nt_space
2497
+ if r14
2498
+ s13 << r14
2499
+ else
2500
+ break
2501
+ end
2502
+ end
2503
+ if s13.empty?
2504
+ @index = i13
2505
+ r13 = nil
2506
+ else
2507
+ r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
2508
+ end
2509
+ s11 << r13
2510
+ if r13
2511
+ r15 = _nt_text_macro_identifier
2512
+ s11 << r15
2513
+ if r15
2514
+ s16, i16 = [], index
2515
+ loop do
2516
+ r17 = _nt_space
2517
+ if r17
2518
+ s16 << r17
2519
+ else
2520
+ break
2521
+ end
2522
+ end
2523
+ r16 = instantiate_node(SyntaxNode,input, i16...index, s16)
2524
+ s11 << r16
2525
+ if r16
2526
+ s18, i18 = [], index
2527
+ loop do
2528
+ r19 = _nt_source_items
2529
+ if r19
2530
+ s18 << r19
2531
+ else
2532
+ break
2533
+ end
2534
+ end
2535
+ r18 = instantiate_node(SyntaxNode,input, i18...index, s18)
2536
+ s11 << r18
2537
+ end
2538
+ end
2539
+ end
2540
+ end
2541
+ if s11.last
2542
+ r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
2543
+ r11.extend(IfndefDirective0)
2544
+ else
2545
+ @index = i11
2546
+ r11 = nil
2547
+ end
2548
+ if r11
2549
+ s10 << r11
2550
+ else
2551
+ break
2552
+ end
2553
+ end
2554
+ r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
2555
+ s0 << r10
2556
+ if r10
2557
+ s20, i20 = [], index
2558
+ loop do
2559
+ r21 = _nt_space
2560
+ if r21
2561
+ s20 << r21
2562
+ else
2563
+ break
2564
+ end
2565
+ end
2566
+ r20 = instantiate_node(SyntaxNode,input, i20...index, s20)
2567
+ s0 << r20
2568
+ if r20
2569
+ i23, s23 = index, []
2570
+ if (match_len = has_terminal?("`else", false, index))
2571
+ r24 = instantiate_node(SyntaxNode,input, index...(index + match_len))
2572
+ @index += match_len
2573
+ else
2574
+ terminal_parse_failure('"`else"')
2575
+ r24 = nil
2576
+ end
2577
+ s23 << r24
2578
+ if r24
2579
+ s25, i25 = [], index
2580
+ loop do
2581
+ r26 = _nt_space
2582
+ if r26
2583
+ s25 << r26
2584
+ else
2585
+ break
2586
+ end
2587
+ end
2588
+ r25 = instantiate_node(SyntaxNode,input, i25...index, s25)
2589
+ s23 << r25
2590
+ if r25
2591
+ s27, i27 = [], index
2592
+ loop do
2593
+ r28 = _nt_source_items
2594
+ if r28
2595
+ s27 << r28
2596
+ else
2597
+ break
2598
+ end
2599
+ end
2600
+ r27 = instantiate_node(SyntaxNode,input, i27...index, s27)
2601
+ s23 << r27
2602
+ end
2603
+ end
2604
+ if s23.last
2605
+ r23 = instantiate_node(SyntaxNode,input, i23...index, s23)
2606
+ r23.extend(IfndefDirective1)
2607
+ else
2608
+ @index = i23
2609
+ r23 = nil
2610
+ end
2611
+ if r23
2612
+ r22 = r23
2613
+ else
2614
+ r22 = instantiate_node(SyntaxNode,input, index...index)
2615
+ end
2616
+ s0 << r22
2617
+ if r22
2618
+ s29, i29 = [], index
2619
+ loop do
2620
+ r30 = _nt_space
2621
+ if r30
2622
+ s29 << r30
2623
+ else
2624
+ break
2625
+ end
2626
+ end
2627
+ r29 = instantiate_node(SyntaxNode,input, i29...index, s29)
2628
+ s0 << r29
2629
+ if r29
2630
+ if (match_len = has_terminal?("`endif", false, index))
2631
+ r31 = instantiate_node(SyntaxNode,input, index...(index + match_len))
2632
+ @index += match_len
2633
+ else
2634
+ terminal_parse_failure('"`endif"')
2635
+ r31 = nil
2636
+ end
2637
+ s0 << r31
2638
+ end
2639
+ end
2640
+ end
2641
+ end
2642
+ end
2643
+ end
2644
+ end
2645
+ end
2646
+ end
2647
+ end
2648
+ if s0.last
2649
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2650
+ r0.extend(IfndefDirective2)
2651
+ r0.extend(IfndefDirective3)
2652
+ else
2653
+ @index = i0
2654
+ r0 = nil
2655
+ end
2656
+
2657
+ node_cache[:ifndef_directive][start_index] = r0
2658
+
2659
+ r0
2660
+ end
2661
+
2662
+ module BlockComment0
2663
+ end
2664
+
2665
+ module BlockComment1
2666
+ def end_of_comment
2667
+ elements[2]
2668
+ end
2669
+ end
2670
+
2671
+ module BlockComment2
2672
+ def to_ast
2673
+ n :comment, text_value
2674
+ end
2675
+ end
2676
+
2677
+ def _nt_block_comment
2678
+ start_index = index
2679
+ if node_cache[:block_comment].has_key?(index)
2680
+ cached = node_cache[:block_comment][index]
2681
+ if cached
2682
+ node_cache[:block_comment][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2683
+ @index = cached.interval.end
2684
+ end
2685
+ return cached
2686
+ end
2687
+
2688
+ i0, s0 = index, []
2689
+ if (match_len = has_terminal?("/*", false, index))
2690
+ r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
2691
+ @index += match_len
2692
+ else
2693
+ terminal_parse_failure('"/*"')
2694
+ r1 = nil
2695
+ end
2696
+ s0 << r1
2697
+ if r1
2698
+ s2, i2 = [], index
2699
+ loop do
2700
+ i3, s3 = index, []
2701
+ i4 = index
2702
+ r5 = _nt_end_of_comment
2703
+ if r5
2704
+ @index = i4
2705
+ r4 = nil
2706
+ else
2707
+ @index = i4
2708
+ r4 = instantiate_node(SyntaxNode,input, index...index)
2709
+ end
2710
+ s3 << r4
2711
+ if r4
2712
+ if index < input_length
2713
+ r6 = true
2714
+ @index += 1
2715
+ else
2716
+ terminal_parse_failure("any character")
2717
+ r6 = nil
2718
+ end
2719
+ s3 << r6
2720
+ end
2721
+ if s3.last
2722
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
2723
+ r3.extend(BlockComment0)
2724
+ else
2725
+ @index = i3
2726
+ r3 = nil
2727
+ end
2728
+ if r3
2729
+ s2 << r3
2730
+ else
2731
+ break
2732
+ end
2733
+ end
2734
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
2735
+ s0 << r2
2736
+ if r2
2737
+ r7 = _nt_end_of_comment
2738
+ s0 << r7
2739
+ end
2740
+ end
2741
+ if s0.last
2742
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2743
+ r0.extend(BlockComment1)
2744
+ r0.extend(BlockComment2)
2745
+ else
2746
+ @index = i0
2747
+ r0 = nil
2748
+ end
2749
+
2750
+ node_cache[:block_comment][start_index] = r0
2751
+
2752
+ r0
2753
+ end
2754
+
2755
+ module OneLineComment0
2756
+ end
2757
+
2758
+ module OneLineComment1
2759
+ end
2760
+
2761
+ module OneLineComment2
2762
+ def to_ast
2763
+ n :comment, text_value
2764
+ end
2765
+ end
2766
+
2767
+ def _nt_one_line_comment
2768
+ start_index = index
2769
+ if node_cache[:one_line_comment].has_key?(index)
2770
+ cached = node_cache[:one_line_comment][index]
2771
+ if cached
2772
+ node_cache[:one_line_comment][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2773
+ @index = cached.interval.end
2774
+ end
2775
+ return cached
2776
+ end
2777
+
2778
+ i0, s0 = index, []
2779
+ if (match_len = has_terminal?("//", false, index))
2780
+ r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
2781
+ @index += match_len
2782
+ else
2783
+ terminal_parse_failure('"//"')
2784
+ r1 = nil
2785
+ end
2786
+ s0 << r1
2787
+ if r1
2788
+ s2, i2 = [], index
2789
+ loop do
2790
+ i3, s3 = index, []
2791
+ i4 = index
2792
+ r5 = _nt_N
2793
+ if r5
2794
+ @index = i4
2795
+ r4 = nil
2796
+ else
2797
+ @index = i4
2798
+ r4 = instantiate_node(SyntaxNode,input, index...index)
2799
+ end
2800
+ s3 << r4
2801
+ if r4
2802
+ if index < input_length
2803
+ r6 = true
2804
+ @index += 1
2805
+ else
2806
+ terminal_parse_failure("any character")
2807
+ r6 = nil
2808
+ end
2809
+ s3 << r6
2810
+ end
2811
+ if s3.last
2812
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
2813
+ r3.extend(OneLineComment0)
2814
+ else
2815
+ @index = i3
2816
+ r3 = nil
2817
+ end
2818
+ if r3
2819
+ s2 << r3
2820
+ else
2821
+ break
2822
+ end
2823
+ end
2824
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
2825
+ s0 << r2
2826
+ end
2827
+ if s0.last
2828
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2829
+ r0.extend(OneLineComment1)
2830
+ r0.extend(OneLineComment2)
2831
+ else
2832
+ @index = i0
2833
+ r0 = nil
2834
+ end
2835
+
2836
+ node_cache[:one_line_comment][start_index] = r0
2837
+
2838
+ r0
2839
+ end
2840
+
2841
+ end
2842
+
2843
+ class GrammarParser < Treetop::Runtime::CompiledParser
2844
+ include Grammar
2845
+ end
2846
+
2847
+ end
2848
+ end