treetop 1.4.15 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Y2E0N2QyZDk3NzlkNThhYjFiNjg4ZmFhYTk0M2NiZjk5YzBlNTdlZA==
5
+ data.tar.gz: !binary |-
6
+ ZjE0ZmQ0ZTQ2Njg3NzgxNzVkYWM2MzU0MjliNTBjMmVjNmQyYjcyZA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ Yzg0NTlkZDQ2ZGIzMjQxNGVkMGE2ZmRjODkxNjkwYTNhMmEzNzRiYjA4NWM4
10
+ ZTQzOGMxODU0Zjk2N2ZhZTdkZmU1Y2RlYjNmYzgzZDM3YTAwODk4MTJlZWNm
11
+ Nzg5MDI1ZDVjODVkN2IwOTc0MDZhOTA0NGU4NTE3YTY4NTIwMTU=
12
+ data.tar.gz: !binary |-
13
+ NDE1MmI2YWM2ODViMmY4MTg4Y2YxZjE2ZDJmY2RmNDhiNTc1MDM4NjI2MDNl
14
+ Y2QzMzQ4NzhlZTAyNWFmNzdmMDBmNjFmNDBiZmQzOTAyNWJkZTIxNWRjOGRk
15
+ NTQ2NDA4YmM0NDQ2ZWNmYzUzMDg4YTNhZDZhZGU2MGNhNWVlODI=
data/README.md CHANGED
@@ -46,7 +46,7 @@ Users of *regular expressions* will find parsing expressions familiar. They shar
46
46
 
47
47
  Terminal Symbols
48
48
  ----------------
49
- The expression in the grammar above is a terminal symbol. It will only match a string that matches it exactly. There are two other kinds of terminal symbols, which we'll revisit later. Terminals are called *atomic expressions* because they aren't composed of smaller expressions.
49
+ The expression in the grammar above is a terminal symbol. It will only match a string that matches it exactly. There are two other kinds of terminal symbols, which we'll revisit later. Terminals are called *atomic expressions* because they aren't composed of smaller expressions. A terminal symbol may use either double or single quotes. If the closing quote is immediately followed by the character 'i', the string is matched without case-sensitivity, that is, the input.downcase matches the terminal.downcase
50
50
 
51
51
  Ordered Choices
52
52
  ---------------
data/Rakefile CHANGED
@@ -25,7 +25,6 @@ Jeweler::Tasks.new do |gem|
25
25
  gem.require_path = "lib"
26
26
  gem.autorequire = "treetop"
27
27
  gem.has_rdoc = false
28
- gem.add_dependency "polyglot", ">= 0.3.1"
29
28
  end
30
29
  Jeweler::RubygemsDotOrgTasks.new
31
30
 
@@ -45,7 +45,7 @@ module Treetop
45
45
  if node_cache[:treetop_file].has_key?(index)
46
46
  cached = node_cache[:treetop_file][index]
47
47
  if cached
48
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
48
+ node_cache[:treetop_file][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
49
49
  @index = cached.interval.end
50
50
  end
51
51
  return cached
@@ -129,7 +129,7 @@ module Treetop
129
129
  if node_cache[:require_statement].has_key?(index)
130
130
  cached = node_cache[:require_statement][index]
131
131
  if cached
132
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
132
+ node_cache[:require_statement][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
133
133
  @index = cached.interval.end
134
134
  end
135
135
  return cached
@@ -155,7 +155,7 @@ module Treetop
155
155
  if r3
156
156
  s4, i4 = [], index
157
157
  loop do
158
- if has_terminal?('\G[ \\t]', true, index)
158
+ if has_terminal?(@regexps[gr = '\G[ \\t]'] ||= Regexp.new(gr), :regexp, index)
159
159
  r5 = true
160
160
  @index += 1
161
161
  else
@@ -177,7 +177,7 @@ module Treetop
177
177
  if r4
178
178
  s6, i6 = [], index
179
179
  loop do
180
- if has_terminal?('\G[^\\n\\r]', true, index)
180
+ if has_terminal?(@regexps[gr = '\G[^\\n\\r]'] ||= Regexp.new(gr), :regexp, index)
181
181
  r7 = true
182
182
  @index += 1
183
183
  else
@@ -197,7 +197,7 @@ module Treetop
197
197
  end
198
198
  s0 << r6
199
199
  if r6
200
- if has_terminal?('\G[\\n\\r]', true, index)
200
+ if has_terminal?(@regexps[gr = '\G[\\n\\r]'] ||= Regexp.new(gr), :regexp, index)
201
201
  r8 = true
202
202
  @index += 1
203
203
  else
@@ -226,7 +226,7 @@ module Treetop
226
226
  if node_cache[:module_or_grammar].has_key?(index)
227
227
  cached = node_cache[:module_or_grammar][index]
228
228
  if cached
229
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
229
+ node_cache[:module_or_grammar][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
230
230
  @index = cached.interval.end
231
231
  end
232
232
  return cached
@@ -235,10 +235,12 @@ module Treetop
235
235
  i0 = index
236
236
  r1 = _nt_module_declaration
237
237
  if r1
238
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
238
239
  r0 = r1
239
240
  else
240
241
  r2 = _nt_grammar
241
242
  if r2
243
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
242
244
  r0 = r2
243
245
  else
244
246
  @index = i0
@@ -307,7 +309,7 @@ module Treetop
307
309
  if node_cache[:module_declaration].has_key?(index)
308
310
  cached = node_cache[:module_declaration][index]
309
311
  if cached
310
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
312
+ node_cache[:module_declaration][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
311
313
  @index = cached.interval.end
312
314
  end
313
315
  return cached
@@ -328,7 +330,7 @@ module Treetop
328
330
  s1 << r3
329
331
  if r3
330
332
  i4, s4 = index, []
331
- if has_terminal?('\G[A-Z]', true, index)
333
+ if has_terminal?(@regexps[gr = '\G[A-Z]'] ||= Regexp.new(gr), :regexp, index)
332
334
  r5 = true
333
335
  @index += 1
334
336
  else
@@ -360,7 +362,7 @@ module Treetop
360
362
  end
361
363
  s9 << r10
362
364
  if r10
363
- if has_terminal?('\G[A-Z]', true, index)
365
+ if has_terminal?(@regexps[gr = '\G[A-Z]'] ||= Regexp.new(gr), :regexp, index)
364
366
  r11 = true
365
367
  @index += 1
366
368
  else
@@ -424,10 +426,12 @@ module Treetop
424
426
  i15 = index
425
427
  r16 = _nt_module_declaration
426
428
  if r16
429
+ r16 = SyntaxNode.new(input, (index-1)...index) if r16 == true
427
430
  r15 = r16
428
431
  else
429
432
  r17 = _nt_grammar
430
433
  if r17
434
+ r17 = SyntaxNode.new(input, (index-1)...index) if r17 == true
431
435
  r15 = r17
432
436
  else
433
437
  @index = i15
@@ -503,7 +507,7 @@ module Treetop
503
507
  if node_cache[:grammar].has_key?(index)
504
508
  cached = node_cache[:grammar][index]
505
509
  if cached
506
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
510
+ node_cache[:grammar][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
507
511
  @index = cached.interval.end
508
512
  end
509
513
  return cached
@@ -602,14 +606,14 @@ module Treetop
602
606
  if node_cache[:grammar_name].has_key?(index)
603
607
  cached = node_cache[:grammar_name][index]
604
608
  if cached
605
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
609
+ node_cache[:grammar_name][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
606
610
  @index = cached.interval.end
607
611
  end
608
612
  return cached
609
613
  end
610
614
 
611
615
  i0, s0 = index, []
612
- if has_terminal?('\G[A-Z]', true, index)
616
+ if has_terminal?(@regexps[gr = '\G[A-Z]'] ||= Regexp.new(gr), :regexp, index)
613
617
  r1 = true
614
618
  @index += 1
615
619
  else
@@ -682,7 +686,7 @@ module Treetop
682
686
  if node_cache[:declaration_sequence].has_key?(index)
683
687
  cached = node_cache[:declaration_sequence][index]
684
688
  if cached
685
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
689
+ node_cache[:declaration_sequence][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
686
690
  @index = cached.interval.end
687
691
  end
688
692
  return cached
@@ -727,6 +731,7 @@ module Treetop
727
731
  r1 = nil
728
732
  end
729
733
  if r1
734
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
730
735
  r0 = r1
731
736
  else
732
737
  if has_terminal?('', false, index)
@@ -738,6 +743,7 @@ module Treetop
738
743
  r7 = nil
739
744
  end
740
745
  if r7
746
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
741
747
  r0 = r7
742
748
  else
743
749
  @index = i0
@@ -755,7 +761,7 @@ module Treetop
755
761
  if node_cache[:declaration].has_key?(index)
756
762
  cached = node_cache[:declaration][index]
757
763
  if cached
758
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
764
+ node_cache[:declaration][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
759
765
  @index = cached.interval.end
760
766
  end
761
767
  return cached
@@ -764,10 +770,12 @@ module Treetop
764
770
  i0 = index
765
771
  r1 = _nt_parsing_rule
766
772
  if r1
773
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
767
774
  r0 = r1
768
775
  else
769
776
  r2 = _nt_include_declaration
770
777
  if r2
778
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
771
779
  r0 = r2
772
780
  else
773
781
  @index = i0
@@ -798,7 +806,7 @@ module Treetop
798
806
  if node_cache[:include_declaration].has_key?(index)
799
807
  cached = node_cache[:include_declaration][index]
800
808
  if cached
801
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
809
+ node_cache[:include_declaration][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
802
810
  @index = cached.interval.end
803
811
  end
804
812
  return cached
@@ -817,7 +825,7 @@ module Treetop
817
825
  r2 = _nt_space
818
826
  s0 << r2
819
827
  if r2
820
- if has_terminal?('\G[A-Z]', true, index)
828
+ if has_terminal?(@regexps[gr = '\G[A-Z]'] ||= Regexp.new(gr), :regexp, index)
821
829
  r3 = true
822
830
  @index += 1
823
831
  else
@@ -830,6 +838,7 @@ module Treetop
830
838
  i5 = index
831
839
  r6 = _nt_alphanumeric_char
832
840
  if r6
841
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
833
842
  r5 = r6
834
843
  else
835
844
  if has_terminal?('::', false, index)
@@ -840,6 +849,7 @@ module Treetop
840
849
  r7 = nil
841
850
  end
842
851
  if r7
852
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
843
853
  r5 = r7
844
854
  else
845
855
  @index = i5
@@ -905,7 +915,7 @@ module Treetop
905
915
  if node_cache[:parsing_rule].has_key?(index)
906
916
  cached = node_cache[:parsing_rule][index]
907
917
  if cached
908
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
918
+ node_cache[:parsing_rule][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
909
919
  @index = cached.interval.end
910
920
  end
911
921
  return cached
@@ -996,7 +1006,7 @@ module Treetop
996
1006
  if node_cache[:parsing_expression].has_key?(index)
997
1007
  cached = node_cache[:parsing_expression][index]
998
1008
  if cached
999
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1009
+ node_cache[:parsing_expression][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1000
1010
  @index = cached.interval.end
1001
1011
  end
1002
1012
  return cached
@@ -1005,14 +1015,17 @@ module Treetop
1005
1015
  i0 = index
1006
1016
  r1 = _nt_choice
1007
1017
  if r1
1018
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
1008
1019
  r0 = r1
1009
1020
  else
1010
1021
  r2 = _nt_sequence
1011
1022
  if r2
1023
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
1012
1024
  r0 = r2
1013
1025
  else
1014
1026
  r3 = _nt_primary
1015
1027
  if r3
1028
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
1016
1029
  r0 = r3
1017
1030
  else
1018
1031
  @index = i0
@@ -1061,7 +1074,7 @@ module Treetop
1061
1074
  if node_cache[:choice].has_key?(index)
1062
1075
  cached = node_cache[:choice][index]
1063
1076
  if cached
1064
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1077
+ node_cache[:choice][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1065
1078
  @index = cached.interval.end
1066
1079
  end
1067
1080
  return cached
@@ -1083,7 +1096,7 @@ module Treetop
1083
1096
  s3 << r4
1084
1097
  if r4
1085
1098
  if has_terminal?('/', false, index)
1086
- r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
1099
+ r6 = true
1087
1100
  @index += 1
1088
1101
  else
1089
1102
  terminal_parse_failure('/')
@@ -1174,7 +1187,7 @@ module Treetop
1174
1187
  if node_cache[:sequence].has_key?(index)
1175
1188
  cached = node_cache[:sequence][index]
1176
1189
  if cached
1177
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1190
+ node_cache[:sequence][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1178
1191
  @index = cached.interval.end
1179
1192
  end
1180
1193
  return cached
@@ -1206,7 +1219,7 @@ module Treetop
1206
1219
  if node_cache[:sequence_body].has_key?(index)
1207
1220
  cached = node_cache[:sequence_body][index]
1208
1221
  if cached
1209
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1222
+ node_cache[:sequence_body][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1210
1223
  @index = cached.interval.end
1211
1224
  end
1212
1225
  return cached
@@ -1215,10 +1228,12 @@ module Treetop
1215
1228
  i0 = index
1216
1229
  r1 = _nt_variable_length_sequence_body
1217
1230
  if r1
1231
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
1218
1232
  r0 = r1
1219
1233
  else
1220
1234
  r2 = _nt_labeled_expression_sequence_body
1221
1235
  if r2
1236
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
1222
1237
  r0 = r2
1223
1238
  else
1224
1239
  @index = i0
@@ -1262,7 +1277,7 @@ module Treetop
1262
1277
  if node_cache[:variable_length_sequence_body].has_key?(index)
1263
1278
  cached = node_cache[:variable_length_sequence_body][index]
1264
1279
  if cached
1265
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1280
+ node_cache[:variable_length_sequence_body][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1266
1281
  @index = cached.interval.end
1267
1282
  end
1268
1283
  return cached
@@ -1331,7 +1346,7 @@ module Treetop
1331
1346
  if node_cache[:labeled_expression_sequence_body].has_key?(index)
1332
1347
  cached = node_cache[:labeled_expression_sequence_body][index]
1333
1348
  if cached
1334
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1349
+ node_cache[:labeled_expression_sequence_body][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1335
1350
  @index = cached.interval.end
1336
1351
  end
1337
1352
  return cached
@@ -1350,7 +1365,7 @@ module Treetop
1350
1365
  if node_cache[:alternative].has_key?(index)
1351
1366
  cached = node_cache[:alternative][index]
1352
1367
  if cached
1353
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1368
+ node_cache[:alternative][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1354
1369
  @index = cached.interval.end
1355
1370
  end
1356
1371
  return cached
@@ -1359,10 +1374,12 @@ module Treetop
1359
1374
  i0 = index
1360
1375
  r1 = _nt_sequence
1361
1376
  if r1
1377
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
1362
1378
  r0 = r1
1363
1379
  else
1364
1380
  r2 = _nt_primary
1365
1381
  if r2
1382
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
1366
1383
  r0 = r2
1367
1384
  else
1368
1385
  @index = i0
@@ -1494,7 +1511,7 @@ module Treetop
1494
1511
  if node_cache[:primary].has_key?(index)
1495
1512
  cached = node_cache[:primary][index]
1496
1513
  if cached
1497
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1514
+ node_cache[:primary][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1498
1515
  @index = cached.interval.end
1499
1516
  end
1500
1517
  return cached
@@ -1517,6 +1534,7 @@ module Treetop
1517
1534
  r1 = nil
1518
1535
  end
1519
1536
  if r1
1537
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
1520
1538
  r0 = r1
1521
1539
  else
1522
1540
  i4, s4 = index, []
@@ -1544,6 +1562,7 @@ module Treetop
1544
1562
  r4 = nil
1545
1563
  end
1546
1564
  if r4
1565
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
1547
1566
  r0 = r4
1548
1567
  else
1549
1568
  i9, s9 = index, []
@@ -1566,6 +1585,7 @@ module Treetop
1566
1585
  r9 = nil
1567
1586
  end
1568
1587
  if r9
1588
+ r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
1569
1589
  r0 = r9
1570
1590
  else
1571
1591
  i13, s13 = index, []
@@ -1584,6 +1604,7 @@ module Treetop
1584
1604
  r13 = nil
1585
1605
  end
1586
1606
  if r13
1607
+ r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true
1587
1608
  r0 = r13
1588
1609
  else
1589
1610
  @index = i0
@@ -1603,7 +1624,7 @@ module Treetop
1603
1624
  if node_cache[:optionally_labeled_sequence_primary].has_key?(index)
1604
1625
  cached = node_cache[:optionally_labeled_sequence_primary][index]
1605
1626
  if cached
1606
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1627
+ node_cache[:optionally_labeled_sequence_primary][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1607
1628
  @index = cached.interval.end
1608
1629
  end
1609
1630
  return cached
@@ -1612,10 +1633,12 @@ module Treetop
1612
1633
  i0 = index
1613
1634
  r1 = _nt_labeled_sequence_primary
1614
1635
  if r1
1636
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
1615
1637
  r0 = r1
1616
1638
  else
1617
1639
  r2 = _nt_unlabeled_sequence_primary
1618
1640
  if r2
1641
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
1619
1642
  r0 = r2
1620
1643
  else
1621
1644
  @index = i0
@@ -1657,7 +1680,7 @@ module Treetop
1657
1680
  if node_cache[:labeled_sequence_primary].has_key?(index)
1658
1681
  cached = node_cache[:labeled_sequence_primary][index]
1659
1682
  if cached
1660
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1683
+ node_cache[:labeled_sequence_primary][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1661
1684
  @index = cached.interval.end
1662
1685
  end
1663
1686
  return cached
@@ -1717,7 +1740,7 @@ module Treetop
1717
1740
  if node_cache[:unlabeled_sequence_primary].has_key?(index)
1718
1741
  cached = node_cache[:unlabeled_sequence_primary][index]
1719
1742
  if cached
1720
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1743
+ node_cache[:unlabeled_sequence_primary][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1721
1744
  @index = cached.interval.end
1722
1745
  end
1723
1746
  return cached
@@ -1749,7 +1772,7 @@ module Treetop
1749
1772
  if node_cache[:label].has_key?(index)
1750
1773
  cached = node_cache[:label][index]
1751
1774
  if cached
1752
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1775
+ node_cache[:label][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1753
1776
  @index = cached.interval.end
1754
1777
  end
1755
1778
  return cached
@@ -1758,10 +1781,12 @@ module Treetop
1758
1781
  i0 = index
1759
1782
  r1 = _nt_named_label
1760
1783
  if r1
1784
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
1761
1785
  r0 = r1
1762
1786
  else
1763
1787
  r2 = _nt_null_label
1764
1788
  if r2
1789
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
1765
1790
  r0 = r2
1766
1791
  else
1767
1792
  @index = i0
@@ -1795,7 +1820,7 @@ module Treetop
1795
1820
  if node_cache[:named_label].has_key?(index)
1796
1821
  cached = node_cache[:named_label][index]
1797
1822
  if cached
1798
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1823
+ node_cache[:named_label][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1799
1824
  @index = cached.interval.end
1800
1825
  end
1801
1826
  return cached
@@ -1828,7 +1853,7 @@ module Treetop
1828
1853
  s0 << r1
1829
1854
  if r1
1830
1855
  if has_terminal?(':', false, index)
1831
- r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
1856
+ r5 = true
1832
1857
  @index += 1
1833
1858
  else
1834
1859
  terminal_parse_failure(':')
@@ -1861,7 +1886,7 @@ module Treetop
1861
1886
  if node_cache[:null_label].has_key?(index)
1862
1887
  cached = node_cache[:null_label][index]
1863
1888
  if cached
1864
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1889
+ node_cache[:null_label][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1865
1890
  @index = cached.interval.end
1866
1891
  end
1867
1892
  return cached
@@ -1964,7 +1989,7 @@ module Treetop
1964
1989
  if node_cache[:sequence_primary].has_key?(index)
1965
1990
  cached = node_cache[:sequence_primary][index]
1966
1991
  if cached
1967
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1992
+ node_cache[:sequence_primary][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1968
1993
  @index = cached.interval.end
1969
1994
  end
1970
1995
  return cached
@@ -1987,6 +2012,7 @@ module Treetop
1987
2012
  r1 = nil
1988
2013
  end
1989
2014
  if r1
2015
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
1990
2016
  r0 = r1
1991
2017
  else
1992
2018
  i4, s4 = index, []
@@ -2014,6 +2040,7 @@ module Treetop
2014
2040
  r4 = nil
2015
2041
  end
2016
2042
  if r4
2043
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
2017
2044
  r0 = r4
2018
2045
  else
2019
2046
  i9, s9 = index, []
@@ -2032,10 +2059,12 @@ module Treetop
2032
2059
  r9 = nil
2033
2060
  end
2034
2061
  if r9
2062
+ r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
2035
2063
  r0 = r9
2036
2064
  else
2037
2065
  r12 = _nt_atomic
2038
2066
  if r12
2067
+ r12 = SyntaxNode.new(input, (index-1)...index) if r12 == true
2039
2068
  r0 = r12
2040
2069
  else
2041
2070
  @index = i0
@@ -2055,7 +2084,7 @@ module Treetop
2055
2084
  if node_cache[:suffix].has_key?(index)
2056
2085
  cached = node_cache[:suffix][index]
2057
2086
  if cached
2058
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2087
+ node_cache[:suffix][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2059
2088
  @index = cached.interval.end
2060
2089
  end
2061
2090
  return cached
@@ -2064,10 +2093,12 @@ module Treetop
2064
2093
  i0 = index
2065
2094
  r1 = _nt_repetition_suffix
2066
2095
  if r1
2096
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
2067
2097
  r0 = r1
2068
2098
  else
2069
2099
  r2 = _nt_optional_suffix
2070
2100
  if r2
2101
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
2071
2102
  r0 = r2
2072
2103
  else
2073
2104
  @index = i0
@@ -2085,7 +2116,7 @@ module Treetop
2085
2116
  if node_cache[:optional_suffix].has_key?(index)
2086
2117
  cached = node_cache[:optional_suffix][index]
2087
2118
  if cached
2088
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2119
+ node_cache[:optional_suffix][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2089
2120
  @index = cached.interval.end
2090
2121
  end
2091
2122
  return cached
@@ -2137,7 +2168,7 @@ module Treetop
2137
2168
  if node_cache[:node_class_declarations].has_key?(index)
2138
2169
  cached = node_cache[:node_class_declarations][index]
2139
2170
  if cached
2140
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2171
+ node_cache[:node_class_declarations][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2141
2172
  @index = cached.interval.end
2142
2173
  end
2143
2174
  return cached
@@ -2169,7 +2200,7 @@ module Treetop
2169
2200
  if node_cache[:repetition_suffix].has_key?(index)
2170
2201
  cached = node_cache[:repetition_suffix][index]
2171
2202
  if cached
2172
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2203
+ node_cache[:repetition_suffix][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2173
2204
  @index = cached.interval.end
2174
2205
  end
2175
2206
  return cached
@@ -2184,6 +2215,7 @@ module Treetop
2184
2215
  r1 = nil
2185
2216
  end
2186
2217
  if r1
2218
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
2187
2219
  r0 = r1
2188
2220
  else
2189
2221
  if has_terminal?('*', false, index)
@@ -2194,10 +2226,12 @@ module Treetop
2194
2226
  r2 = nil
2195
2227
  end
2196
2228
  if r2
2229
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
2197
2230
  r0 = r2
2198
2231
  else
2199
2232
  r3 = _nt_occurrence_range
2200
2233
  if r3
2234
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
2201
2235
  r0 = r3
2202
2236
  else
2203
2237
  @index = i0
@@ -2226,7 +2260,7 @@ module Treetop
2226
2260
  if node_cache[:occurrence_range].has_key?(index)
2227
2261
  cached = node_cache[:occurrence_range][index]
2228
2262
  if cached
2229
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2263
+ node_cache[:occurrence_range][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2230
2264
  @index = cached.interval.end
2231
2265
  end
2232
2266
  return cached
@@ -2243,7 +2277,7 @@ module Treetop
2243
2277
  if r1
2244
2278
  s3, i3 = [], index
2245
2279
  loop do
2246
- if has_terminal?('\G[0-9]', true, index)
2280
+ if has_terminal?(@regexps[gr = '\G[0-9]'] ||= Regexp.new(gr), :regexp, index)
2247
2281
  r4 = true
2248
2282
  @index += 1
2249
2283
  else
@@ -2269,7 +2303,7 @@ module Treetop
2269
2303
  if r5
2270
2304
  s6, i6 = [], index
2271
2305
  loop do
2272
- if has_terminal?('\G[0-9]', true, index)
2306
+ if has_terminal?(@regexps[gr = '\G[0-9]'] ||= Regexp.new(gr), :regexp, index)
2273
2307
  r7 = true
2274
2308
  @index += 1
2275
2309
  else
@@ -2304,7 +2338,7 @@ module Treetop
2304
2338
  if node_cache[:prefix].has_key?(index)
2305
2339
  cached = node_cache[:prefix][index]
2306
2340
  if cached
2307
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2341
+ node_cache[:prefix][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2308
2342
  @index = cached.interval.end
2309
2343
  end
2310
2344
  return cached
@@ -2319,6 +2353,7 @@ module Treetop
2319
2353
  r1 = nil
2320
2354
  end
2321
2355
  if r1
2356
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
2322
2357
  r0 = r1
2323
2358
  else
2324
2359
  if has_terminal?('!', false, index)
@@ -2329,6 +2364,7 @@ module Treetop
2329
2364
  r2 = nil
2330
2365
  end
2331
2366
  if r2
2367
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
2332
2368
  r0 = r2
2333
2369
  else
2334
2370
  if has_terminal?('~', false, index)
@@ -2339,6 +2375,7 @@ module Treetop
2339
2375
  r3 = nil
2340
2376
  end
2341
2377
  if r3
2378
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
2342
2379
  r0 = r3
2343
2380
  else
2344
2381
  @index = i0
@@ -2357,7 +2394,7 @@ module Treetop
2357
2394
  if node_cache[:atomic].has_key?(index)
2358
2395
  cached = node_cache[:atomic][index]
2359
2396
  if cached
2360
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2397
+ node_cache[:atomic][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2361
2398
  @index = cached.interval.end
2362
2399
  end
2363
2400
  return cached
@@ -2366,14 +2403,17 @@ module Treetop
2366
2403
  i0 = index
2367
2404
  r1 = _nt_terminal
2368
2405
  if r1
2406
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
2369
2407
  r0 = r1
2370
2408
  else
2371
2409
  r2 = _nt_nonterminal
2372
2410
  if r2
2411
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
2373
2412
  r0 = r2
2374
2413
  else
2375
2414
  r3 = _nt_parenthesized_expression
2376
2415
  if r3
2416
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
2377
2417
  r0 = r3
2378
2418
  else
2379
2419
  @index = i0
@@ -2405,7 +2445,7 @@ module Treetop
2405
2445
  if node_cache[:parenthesized_expression].has_key?(index)
2406
2446
  cached = node_cache[:parenthesized_expression][index]
2407
2447
  if cached
2408
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2448
+ node_cache[:parenthesized_expression][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2409
2449
  @index = cached.interval.end
2410
2450
  end
2411
2451
  return cached
@@ -2413,7 +2453,7 @@ module Treetop
2413
2453
 
2414
2454
  i0, s0 = index, []
2415
2455
  if has_terminal?('(', false, index)
2416
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
2456
+ r1 = true
2417
2457
  @index += 1
2418
2458
  else
2419
2459
  terminal_parse_failure('(')
@@ -2441,7 +2481,7 @@ module Treetop
2441
2481
  s0 << r5
2442
2482
  if r5
2443
2483
  if has_terminal?(')', false, index)
2444
- r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
2484
+ r7 = true
2445
2485
  @index += 1
2446
2486
  else
2447
2487
  terminal_parse_failure(')')
@@ -2481,7 +2521,7 @@ module Treetop
2481
2521
  if node_cache[:nonterminal].has_key?(index)
2482
2522
  cached = node_cache[:nonterminal][index]
2483
2523
  if cached
2484
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2524
+ node_cache[:nonterminal][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2485
2525
  @index = cached.interval.end
2486
2526
  end
2487
2527
  return cached
@@ -2541,7 +2581,7 @@ module Treetop
2541
2581
  if node_cache[:terminal].has_key?(index)
2542
2582
  cached = node_cache[:terminal][index]
2543
2583
  if cached
2544
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2584
+ node_cache[:terminal][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2545
2585
  @index = cached.interval.end
2546
2586
  end
2547
2587
  return cached
@@ -2550,14 +2590,17 @@ module Treetop
2550
2590
  i0 = index
2551
2591
  r1 = _nt_quoted_string
2552
2592
  if r1
2593
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
2553
2594
  r0 = r1
2554
2595
  else
2555
2596
  r2 = _nt_character_class
2556
2597
  if r2
2598
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
2557
2599
  r0 = r2
2558
2600
  else
2559
2601
  r3 = _nt_anything_symbol
2560
2602
  if r3
2603
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
2561
2604
  r0 = r3
2562
2605
  else
2563
2606
  @index = i0
@@ -2572,8 +2615,18 @@ module Treetop
2572
2615
  end
2573
2616
 
2574
2617
  module QuotedString0
2618
+ def qs
2619
+ elements[0]
2620
+ end
2621
+
2622
+ def insens
2623
+ elements[1]
2624
+ end
2625
+ end
2626
+
2627
+ module QuotedString1
2575
2628
  def string
2576
- super.text_value
2629
+ qs.text_value
2577
2630
  end
2578
2631
  end
2579
2632
 
@@ -2582,26 +2635,51 @@ module Treetop
2582
2635
  if node_cache[:quoted_string].has_key?(index)
2583
2636
  cached = node_cache[:quoted_string][index]
2584
2637
  if cached
2585
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2638
+ node_cache[:quoted_string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2586
2639
  @index = cached.interval.end
2587
2640
  end
2588
2641
  return cached
2589
2642
  end
2590
2643
 
2591
- i0 = index
2592
- r1 = _nt_single_quoted_string
2593
- if r1
2594
- r0 = r1
2595
- r0.extend(QuotedString0)
2644
+ i0, s0 = index, []
2645
+ i1 = index
2646
+ r2 = _nt_single_quoted_string
2647
+ if r2
2648
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
2649
+ r1 = r2
2596
2650
  else
2597
- r2 = _nt_double_quoted_string
2598
- if r2
2599
- r0 = r2
2600
- r0.extend(QuotedString0)
2651
+ r3 = _nt_double_quoted_string
2652
+ if r3
2653
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
2654
+ r1 = r3
2601
2655
  else
2602
- @index = i0
2603
- r0 = nil
2656
+ @index = i1
2657
+ r1 = nil
2658
+ end
2659
+ end
2660
+ s0 << r1
2661
+ if r1
2662
+ if has_terminal?('i', false, index)
2663
+ r5 = true
2664
+ @index += 1
2665
+ else
2666
+ terminal_parse_failure('i')
2667
+ r5 = nil
2668
+ end
2669
+ if r5
2670
+ r4 = r5
2671
+ else
2672
+ r4 = instantiate_node(SyntaxNode,input, index...index)
2604
2673
  end
2674
+ s0 << r4
2675
+ end
2676
+ if s0.last
2677
+ r0 = instantiate_node(Terminal,input, i0...index, s0)
2678
+ r0.extend(QuotedString0)
2679
+ r0.extend(QuotedString1)
2680
+ else
2681
+ @index = i0
2682
+ r0 = nil
2605
2683
  end
2606
2684
 
2607
2685
  node_cache[:quoted_string][start_index] = r0
@@ -2624,7 +2702,7 @@ module Treetop
2624
2702
  if node_cache[:double_quoted_string].has_key?(index)
2625
2703
  cached = node_cache[:double_quoted_string][index]
2626
2704
  if cached
2627
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2705
+ node_cache[:double_quoted_string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2628
2706
  @index = cached.interval.end
2629
2707
  end
2630
2708
  return cached
@@ -2632,7 +2710,7 @@ module Treetop
2632
2710
 
2633
2711
  i0, s0 = index, []
2634
2712
  if has_terminal?('"', false, index)
2635
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
2713
+ r1 = true
2636
2714
  @index += 1
2637
2715
  else
2638
2716
  terminal_parse_failure('"')
@@ -2645,7 +2723,7 @@ module Treetop
2645
2723
  i3, s3 = index, []
2646
2724
  i4 = index
2647
2725
  if has_terminal?('"', false, index)
2648
- r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
2726
+ r5 = true
2649
2727
  @index += 1
2650
2728
  else
2651
2729
  terminal_parse_failure('"')
@@ -2668,6 +2746,7 @@ module Treetop
2668
2746
  r7 = nil
2669
2747
  end
2670
2748
  if r7
2749
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
2671
2750
  r6 = r7
2672
2751
  else
2673
2752
  if has_terminal?('\"', false, index)
@@ -2678,16 +2757,18 @@ module Treetop
2678
2757
  r8 = nil
2679
2758
  end
2680
2759
  if r8
2760
+ r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
2681
2761
  r6 = r8
2682
2762
  else
2683
2763
  if index < input_length
2684
- r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
2764
+ r9 = true
2685
2765
  @index += 1
2686
2766
  else
2687
2767
  terminal_parse_failure("any character")
2688
2768
  r9 = nil
2689
2769
  end
2690
2770
  if r9
2771
+ r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
2691
2772
  r6 = r9
2692
2773
  else
2693
2774
  @index = i6
@@ -2714,7 +2795,7 @@ module Treetop
2714
2795
  s0 << r2
2715
2796
  if r2
2716
2797
  if has_terminal?('"', false, index)
2717
- r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
2798
+ r10 = true
2718
2799
  @index += 1
2719
2800
  else
2720
2801
  terminal_parse_failure('"')
@@ -2724,7 +2805,7 @@ module Treetop
2724
2805
  end
2725
2806
  end
2726
2807
  if s0.last
2727
- r0 = instantiate_node(Terminal,input, i0...index, s0)
2808
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2728
2809
  r0.extend(DoubleQuotedString1)
2729
2810
  else
2730
2811
  @index = i0
@@ -2751,7 +2832,7 @@ module Treetop
2751
2832
  if node_cache[:single_quoted_string].has_key?(index)
2752
2833
  cached = node_cache[:single_quoted_string][index]
2753
2834
  if cached
2754
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2835
+ node_cache[:single_quoted_string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2755
2836
  @index = cached.interval.end
2756
2837
  end
2757
2838
  return cached
@@ -2759,7 +2840,7 @@ module Treetop
2759
2840
 
2760
2841
  i0, s0 = index, []
2761
2842
  if has_terminal?("'", false, index)
2762
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
2843
+ r1 = true
2763
2844
  @index += 1
2764
2845
  else
2765
2846
  terminal_parse_failure("'")
@@ -2772,7 +2853,7 @@ module Treetop
2772
2853
  i3, s3 = index, []
2773
2854
  i4 = index
2774
2855
  if has_terminal?("'", false, index)
2775
- r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
2856
+ r5 = true
2776
2857
  @index += 1
2777
2858
  else
2778
2859
  terminal_parse_failure("'")
@@ -2795,6 +2876,7 @@ module Treetop
2795
2876
  r7 = nil
2796
2877
  end
2797
2878
  if r7
2879
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
2798
2880
  r6 = r7
2799
2881
  else
2800
2882
  if has_terminal?("\\'", false, index)
@@ -2805,16 +2887,18 @@ module Treetop
2805
2887
  r8 = nil
2806
2888
  end
2807
2889
  if r8
2890
+ r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
2808
2891
  r6 = r8
2809
2892
  else
2810
2893
  if index < input_length
2811
- r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
2894
+ r9 = true
2812
2895
  @index += 1
2813
2896
  else
2814
2897
  terminal_parse_failure("any character")
2815
2898
  r9 = nil
2816
2899
  end
2817
2900
  if r9
2901
+ r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
2818
2902
  r6 = r9
2819
2903
  else
2820
2904
  @index = i6
@@ -2841,7 +2925,7 @@ module Treetop
2841
2925
  s0 << r2
2842
2926
  if r2
2843
2927
  if has_terminal?("'", false, index)
2844
- r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
2928
+ r10 = true
2845
2929
  @index += 1
2846
2930
  else
2847
2931
  terminal_parse_failure("'")
@@ -2851,7 +2935,7 @@ module Treetop
2851
2935
  end
2852
2936
  end
2853
2937
  if s0.last
2854
- r0 = instantiate_node(Terminal,input, i0...index, s0)
2938
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2855
2939
  r0.extend(SingleQuotedString1)
2856
2940
  else
2857
2941
  @index = i0
@@ -2890,7 +2974,7 @@ module Treetop
2890
2974
  if node_cache[:character_class].has_key?(index)
2891
2975
  cached = node_cache[:character_class][index]
2892
2976
  if cached
2893
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2977
+ node_cache[:character_class][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2894
2978
  @index = cached.interval.end
2895
2979
  end
2896
2980
  return cached
@@ -2898,7 +2982,7 @@ module Treetop
2898
2982
 
2899
2983
  i0, s0 = index, []
2900
2984
  if has_terminal?('[', false, index)
2901
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
2985
+ r1 = true
2902
2986
  @index += 1
2903
2987
  else
2904
2988
  terminal_parse_failure('[')
@@ -2911,7 +2995,7 @@ module Treetop
2911
2995
  i3, s3 = index, []
2912
2996
  i4 = index
2913
2997
  if has_terminal?(']', false, index)
2914
- r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
2998
+ r5 = true
2915
2999
  @index += 1
2916
3000
  else
2917
3001
  terminal_parse_failure(']')
@@ -2928,7 +3012,7 @@ module Treetop
2928
3012
  i6 = index
2929
3013
  i7, s7 = index, []
2930
3014
  if has_terminal?('\\', false, index)
2931
- r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
3015
+ r8 = true
2932
3016
  @index += 1
2933
3017
  else
2934
3018
  terminal_parse_failure('\\')
@@ -2937,7 +3021,7 @@ module Treetop
2937
3021
  s7 << r8
2938
3022
  if r8
2939
3023
  if index < input_length
2940
- r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
3024
+ r9 = true
2941
3025
  @index += 1
2942
3026
  else
2943
3027
  terminal_parse_failure("any character")
@@ -2953,16 +3037,18 @@ module Treetop
2953
3037
  r7 = nil
2954
3038
  end
2955
3039
  if r7
3040
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
2956
3041
  r6 = r7
2957
3042
  else
2958
3043
  r10 = _nt_bracket_expression
2959
3044
  if r10
3045
+ r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
2960
3046
  r6 = r10
2961
3047
  else
2962
3048
  i11, s11 = index, []
2963
3049
  i12 = index
2964
3050
  if has_terminal?('\\', false, index)
2965
- r13 = instantiate_node(SyntaxNode,input, index...(index + 1))
3051
+ r13 = true
2966
3052
  @index += 1
2967
3053
  else
2968
3054
  terminal_parse_failure('\\')
@@ -2977,7 +3063,7 @@ module Treetop
2977
3063
  s11 << r12
2978
3064
  if r12
2979
3065
  if index < input_length
2980
- r14 = instantiate_node(SyntaxNode,input, index...(index + 1))
3066
+ r14 = true
2981
3067
  @index += 1
2982
3068
  else
2983
3069
  terminal_parse_failure("any character")
@@ -2993,6 +3079,7 @@ module Treetop
2993
3079
  r11 = nil
2994
3080
  end
2995
3081
  if r11
3082
+ r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
2996
3083
  r6 = r11
2997
3084
  else
2998
3085
  @index = i6
@@ -3024,7 +3111,7 @@ module Treetop
3024
3111
  s0 << r2
3025
3112
  if r2
3026
3113
  if has_terminal?(']', false, index)
3027
- r15 = instantiate_node(SyntaxNode,input, index...(index + 1))
3114
+ r15 = true
3028
3115
  @index += 1
3029
3116
  else
3030
3117
  terminal_parse_failure(']')
@@ -3055,7 +3142,7 @@ module Treetop
3055
3142
  if node_cache[:bracket_expression].has_key?(index)
3056
3143
  cached = node_cache[:bracket_expression][index]
3057
3144
  if cached
3058
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3145
+ node_cache[:bracket_expression][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3059
3146
  @index = cached.interval.end
3060
3147
  end
3061
3148
  return cached
@@ -3072,7 +3159,7 @@ module Treetop
3072
3159
  s0 << r1
3073
3160
  if r1
3074
3161
  if has_terminal?('^', false, index)
3075
- r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
3162
+ r3 = true
3076
3163
  @index += 1
3077
3164
  else
3078
3165
  terminal_parse_failure('^')
@@ -3094,6 +3181,7 @@ module Treetop
3094
3181
  r5 = nil
3095
3182
  end
3096
3183
  if r5
3184
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
3097
3185
  r4 = r5
3098
3186
  else
3099
3187
  if has_terminal?('alpha', false, index)
@@ -3104,6 +3192,7 @@ module Treetop
3104
3192
  r6 = nil
3105
3193
  end
3106
3194
  if r6
3195
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
3107
3196
  r4 = r6
3108
3197
  else
3109
3198
  if has_terminal?('blank', false, index)
@@ -3114,6 +3203,7 @@ module Treetop
3114
3203
  r7 = nil
3115
3204
  end
3116
3205
  if r7
3206
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
3117
3207
  r4 = r7
3118
3208
  else
3119
3209
  if has_terminal?('cntrl', false, index)
@@ -3124,6 +3214,7 @@ module Treetop
3124
3214
  r8 = nil
3125
3215
  end
3126
3216
  if r8
3217
+ r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
3127
3218
  r4 = r8
3128
3219
  else
3129
3220
  if has_terminal?('digit', false, index)
@@ -3134,6 +3225,7 @@ module Treetop
3134
3225
  r9 = nil
3135
3226
  end
3136
3227
  if r9
3228
+ r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
3137
3229
  r4 = r9
3138
3230
  else
3139
3231
  if has_terminal?('graph', false, index)
@@ -3144,6 +3236,7 @@ module Treetop
3144
3236
  r10 = nil
3145
3237
  end
3146
3238
  if r10
3239
+ r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
3147
3240
  r4 = r10
3148
3241
  else
3149
3242
  if has_terminal?('lower', false, index)
@@ -3154,6 +3247,7 @@ module Treetop
3154
3247
  r11 = nil
3155
3248
  end
3156
3249
  if r11
3250
+ r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
3157
3251
  r4 = r11
3158
3252
  else
3159
3253
  if has_terminal?('print', false, index)
@@ -3164,6 +3258,7 @@ module Treetop
3164
3258
  r12 = nil
3165
3259
  end
3166
3260
  if r12
3261
+ r12 = SyntaxNode.new(input, (index-1)...index) if r12 == true
3167
3262
  r4 = r12
3168
3263
  else
3169
3264
  if has_terminal?('punct', false, index)
@@ -3174,6 +3269,7 @@ module Treetop
3174
3269
  r13 = nil
3175
3270
  end
3176
3271
  if r13
3272
+ r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true
3177
3273
  r4 = r13
3178
3274
  else
3179
3275
  if has_terminal?('space', false, index)
@@ -3184,6 +3280,7 @@ module Treetop
3184
3280
  r14 = nil
3185
3281
  end
3186
3282
  if r14
3283
+ r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true
3187
3284
  r4 = r14
3188
3285
  else
3189
3286
  if has_terminal?('upper', false, index)
@@ -3194,6 +3291,7 @@ module Treetop
3194
3291
  r15 = nil
3195
3292
  end
3196
3293
  if r15
3294
+ r15 = SyntaxNode.new(input, (index-1)...index) if r15 == true
3197
3295
  r4 = r15
3198
3296
  else
3199
3297
  if has_terminal?('xdigit', false, index)
@@ -3204,6 +3302,7 @@ module Treetop
3204
3302
  r16 = nil
3205
3303
  end
3206
3304
  if r16
3305
+ r16 = SyntaxNode.new(input, (index-1)...index) if r16 == true
3207
3306
  r4 = r16
3208
3307
  else
3209
3308
  if has_terminal?('word', false, index)
@@ -3214,6 +3313,7 @@ module Treetop
3214
3313
  r17 = nil
3215
3314
  end
3216
3315
  if r17
3316
+ r17 = SyntaxNode.new(input, (index-1)...index) if r17 == true
3217
3317
  r4 = r17
3218
3318
  else
3219
3319
  @index = i4
@@ -3262,7 +3362,7 @@ module Treetop
3262
3362
  if node_cache[:anything_symbol].has_key?(index)
3263
3363
  cached = node_cache[:anything_symbol][index]
3264
3364
  if cached
3265
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3365
+ node_cache[:anything_symbol][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3266
3366
  @index = cached.interval.end
3267
3367
  end
3268
3368
  return cached
@@ -3308,7 +3408,7 @@ module Treetop
3308
3408
  if node_cache[:node_class_expression].has_key?(index)
3309
3409
  cached = node_cache[:node_class_expression][index]
3310
3410
  if cached
3311
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3411
+ node_cache[:node_class_expression][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3312
3412
  @index = cached.interval.end
3313
3413
  end
3314
3414
  return cached
@@ -3320,7 +3420,7 @@ module Treetop
3320
3420
  s1 << r2
3321
3421
  if r2
3322
3422
  if has_terminal?('<', false, index)
3323
- r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
3423
+ r3 = true
3324
3424
  @index += 1
3325
3425
  else
3326
3426
  terminal_parse_failure('<')
@@ -3333,7 +3433,7 @@ module Treetop
3333
3433
  i5, s5 = index, []
3334
3434
  i6 = index
3335
3435
  if has_terminal?('>', false, index)
3336
- r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
3436
+ r7 = true
3337
3437
  @index += 1
3338
3438
  else
3339
3439
  terminal_parse_failure('>')
@@ -3348,7 +3448,7 @@ module Treetop
3348
3448
  s5 << r6
3349
3449
  if r6
3350
3450
  if index < input_length
3351
- r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
3451
+ r8 = true
3352
3452
  @index += 1
3353
3453
  else
3354
3454
  terminal_parse_failure("any character")
@@ -3378,7 +3478,7 @@ module Treetop
3378
3478
  s1 << r4
3379
3479
  if r4
3380
3480
  if has_terminal?('>', false, index)
3381
- r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
3481
+ r9 = true
3382
3482
  @index += 1
3383
3483
  else
3384
3484
  terminal_parse_failure('>')
@@ -3397,6 +3497,7 @@ module Treetop
3397
3497
  r1 = nil
3398
3498
  end
3399
3499
  if r1
3500
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
3400
3501
  r0 = r1
3401
3502
  else
3402
3503
  if has_terminal?('', false, index)
@@ -3408,6 +3509,7 @@ module Treetop
3408
3509
  r10 = nil
3409
3510
  end
3410
3511
  if r10
3512
+ r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
3411
3513
  r0 = r10
3412
3514
  else
3413
3515
  @index = i0
@@ -3459,7 +3561,7 @@ module Treetop
3459
3561
  if node_cache[:trailing_inline_module].has_key?(index)
3460
3562
  cached = node_cache[:trailing_inline_module][index]
3461
3563
  if cached
3462
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3564
+ node_cache[:trailing_inline_module][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3463
3565
  @index = cached.interval.end
3464
3566
  end
3465
3567
  return cached
@@ -3482,6 +3584,7 @@ module Treetop
3482
3584
  r1 = nil
3483
3585
  end
3484
3586
  if r1
3587
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
3485
3588
  r0 = r1
3486
3589
  else
3487
3590
  if has_terminal?('', false, index)
@@ -3493,6 +3596,7 @@ module Treetop
3493
3596
  r4 = nil
3494
3597
  end
3495
3598
  if r4
3599
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
3496
3600
  r0 = r4
3497
3601
  else
3498
3602
  @index = i0
@@ -3516,7 +3620,7 @@ module Treetop
3516
3620
  if node_cache[:predicate_block].has_key?(index)
3517
3621
  cached = node_cache[:predicate_block][index]
3518
3622
  if cached
3519
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3623
+ node_cache[:predicate_block][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3520
3624
  @index = cached.interval.end
3521
3625
  end
3522
3626
  return cached
@@ -3524,7 +3628,7 @@ module Treetop
3524
3628
 
3525
3629
  i0, s0 = index, []
3526
3630
  if has_terminal?('', false, index)
3527
- r1 = instantiate_node(SyntaxNode,input, index...(index + 0))
3631
+ r1 = true
3528
3632
  @index += 0
3529
3633
  else
3530
3634
  terminal_parse_failure('')
@@ -3559,7 +3663,7 @@ module Treetop
3559
3663
  if node_cache[:inline_module].has_key?(index)
3560
3664
  cached = node_cache[:inline_module][index]
3561
3665
  if cached
3562
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3666
+ node_cache[:inline_module][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3563
3667
  @index = cached.interval.end
3564
3668
  end
3565
3669
  return cached
@@ -3567,7 +3671,7 @@ module Treetop
3567
3671
 
3568
3672
  i0, s0 = index, []
3569
3673
  if has_terminal?('{', false, index)
3570
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
3674
+ r1 = true
3571
3675
  @index += 1
3572
3676
  else
3573
3677
  terminal_parse_failure('{')
@@ -3580,11 +3684,12 @@ module Treetop
3580
3684
  i3 = index
3581
3685
  r4 = _nt_inline_module
3582
3686
  if r4
3687
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
3583
3688
  r3 = r4
3584
3689
  else
3585
3690
  i5, s5 = index, []
3586
3691
  i6 = index
3587
- if has_terminal?('\G[{}]', true, index)
3692
+ if has_terminal?(@regexps[gr = '\G[{}]'] ||= Regexp.new(gr), :regexp, index)
3588
3693
  r7 = true
3589
3694
  @index += 1
3590
3695
  else
@@ -3599,7 +3704,7 @@ module Treetop
3599
3704
  s5 << r6
3600
3705
  if r6
3601
3706
  if index < input_length
3602
- r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
3707
+ r8 = true
3603
3708
  @index += 1
3604
3709
  else
3605
3710
  terminal_parse_failure("any character")
@@ -3615,6 +3720,7 @@ module Treetop
3615
3720
  r5 = nil
3616
3721
  end
3617
3722
  if r5
3723
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
3618
3724
  r3 = r5
3619
3725
  else
3620
3726
  @index = i3
@@ -3631,7 +3737,7 @@ module Treetop
3631
3737
  s0 << r2
3632
3738
  if r2
3633
3739
  if has_terminal?('}', false, index)
3634
- r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
3740
+ r9 = true
3635
3741
  @index += 1
3636
3742
  else
3637
3743
  terminal_parse_failure('}')
@@ -3661,7 +3767,7 @@ module Treetop
3661
3767
  if node_cache[:keyword_inside_grammar].has_key?(index)
3662
3768
  cached = node_cache[:keyword_inside_grammar][index]
3663
3769
  if cached
3664
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3770
+ node_cache[:keyword_inside_grammar][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3665
3771
  @index = cached.interval.end
3666
3772
  end
3667
3773
  return cached
@@ -3677,6 +3783,7 @@ module Treetop
3677
3783
  r2 = nil
3678
3784
  end
3679
3785
  if r2
3786
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
3680
3787
  r1 = r2
3681
3788
  else
3682
3789
  if has_terminal?('end', false, index)
@@ -3687,6 +3794,7 @@ module Treetop
3687
3794
  r3 = nil
3688
3795
  end
3689
3796
  if r3
3797
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
3690
3798
  r1 = r3
3691
3799
  else
3692
3800
  @index = i1
@@ -3726,7 +3834,7 @@ module Treetop
3726
3834
  if node_cache[:non_space_char].has_key?(index)
3727
3835
  cached = node_cache[:non_space_char][index]
3728
3836
  if cached
3729
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3837
+ node_cache[:non_space_char][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3730
3838
  @index = cached.interval.end
3731
3839
  end
3732
3840
  return cached
@@ -3744,7 +3852,7 @@ module Treetop
3744
3852
  s0 << r1
3745
3853
  if r1
3746
3854
  if index < input_length
3747
- r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
3855
+ r3 = true
3748
3856
  @index += 1
3749
3857
  else
3750
3858
  terminal_parse_failure("any character")
@@ -3770,13 +3878,13 @@ module Treetop
3770
3878
  if node_cache[:alpha_char].has_key?(index)
3771
3879
  cached = node_cache[:alpha_char][index]
3772
3880
  if cached
3773
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3881
+ node_cache[:alpha_char][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3774
3882
  @index = cached.interval.end
3775
3883
  end
3776
3884
  return cached
3777
3885
  end
3778
3886
 
3779
- if has_terminal?('\G[A-Za-z_]', true, index)
3887
+ if has_terminal?(@regexps[gr = '\G[A-Za-z_]'] ||= Regexp.new(gr), :regexp, index)
3780
3888
  r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
3781
3889
  @index += 1
3782
3890
  else
@@ -3793,7 +3901,7 @@ module Treetop
3793
3901
  if node_cache[:alphanumeric_char].has_key?(index)
3794
3902
  cached = node_cache[:alphanumeric_char][index]
3795
3903
  if cached
3796
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3904
+ node_cache[:alphanumeric_char][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3797
3905
  @index = cached.interval.end
3798
3906
  end
3799
3907
  return cached
@@ -3802,15 +3910,17 @@ module Treetop
3802
3910
  i0 = index
3803
3911
  r1 = _nt_alpha_char
3804
3912
  if r1
3913
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
3805
3914
  r0 = r1
3806
3915
  else
3807
- if has_terminal?('\G[0-9]', true, index)
3916
+ if has_terminal?(@regexps[gr = '\G[0-9]'] ||= Regexp.new(gr), :regexp, index)
3808
3917
  r2 = true
3809
3918
  @index += 1
3810
3919
  else
3811
3920
  r2 = nil
3812
3921
  end
3813
3922
  if r2
3923
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
3814
3924
  r0 = r2
3815
3925
  else
3816
3926
  @index = i0
@@ -3828,7 +3938,7 @@ module Treetop
3828
3938
  if node_cache[:space].has_key?(index)
3829
3939
  cached = node_cache[:space][index]
3830
3940
  if cached
3831
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3941
+ node_cache[:space][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3832
3942
  @index = cached.interval.end
3833
3943
  end
3834
3944
  return cached
@@ -3839,10 +3949,12 @@ module Treetop
3839
3949
  i1 = index
3840
3950
  r2 = _nt_white
3841
3951
  if r2
3952
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
3842
3953
  r1 = r2
3843
3954
  else
3844
3955
  r3 = _nt_comment_to_eol
3845
3956
  if r3
3957
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
3846
3958
  r1 = r3
3847
3959
  else
3848
3960
  @index = i1
@@ -3878,7 +3990,7 @@ module Treetop
3878
3990
  if node_cache[:comment_to_eol].has_key?(index)
3879
3991
  cached = node_cache[:comment_to_eol][index]
3880
3992
  if cached
3881
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3993
+ node_cache[:comment_to_eol][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3882
3994
  @index = cached.interval.end
3883
3995
  end
3884
3996
  return cached
@@ -3886,7 +3998,7 @@ module Treetop
3886
3998
 
3887
3999
  i0, s0 = index, []
3888
4000
  if has_terminal?('#', false, index)
3889
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
4001
+ r1 = true
3890
4002
  @index += 1
3891
4003
  else
3892
4004
  terminal_parse_failure('#')
@@ -3899,7 +4011,7 @@ module Treetop
3899
4011
  i3, s3 = index, []
3900
4012
  i4 = index
3901
4013
  if has_terminal?("\n", false, index)
3902
- r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
4014
+ r5 = true
3903
4015
  @index += 1
3904
4016
  else
3905
4017
  terminal_parse_failure("\n")
@@ -3914,7 +4026,7 @@ module Treetop
3914
4026
  s3 << r4
3915
4027
  if r4
3916
4028
  if index < input_length
3917
- r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
4029
+ r6 = true
3918
4030
  @index += 1
3919
4031
  else
3920
4032
  terminal_parse_failure("any character")
@@ -3956,13 +4068,13 @@ module Treetop
3956
4068
  if node_cache[:white].has_key?(index)
3957
4069
  cached = node_cache[:white][index]
3958
4070
  if cached
3959
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
4071
+ node_cache[:white][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3960
4072
  @index = cached.interval.end
3961
4073
  end
3962
4074
  return cached
3963
4075
  end
3964
4076
 
3965
- if has_terminal?('\G[ \\t\\n\\r]', true, index)
4077
+ if has_terminal?(@regexps[gr = '\G[ \\t\\n\\r]'] ||= Regexp.new(gr), :regexp, index)
3966
4078
  r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
3967
4079
  @index += 1
3968
4080
  else