treetop 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -17,3 +17,7 @@ load "./treetop.gemspec"
17
17
  Rake::GemPackageTask.new($gemspec) do |pkg|
18
18
  pkg.need_tar = true
19
19
  end
20
+
21
+ task :version do
22
+ puts RUBY_VERSION
23
+ end
@@ -44,7 +44,10 @@ module Treetop
44
44
  start_index = index
45
45
  if node_cache[:treetop_file].has_key?(index)
46
46
  cached = node_cache[:treetop_file][index]
47
- @index = cached.interval.end if cached
47
+ if cached
48
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
49
+ @index = cached.interval.end
50
+ end
48
51
  return cached
49
52
  end
50
53
 
@@ -137,7 +140,10 @@ module Treetop
137
140
  start_index = index
138
141
  if node_cache[:require_statement].has_key?(index)
139
142
  cached = node_cache[:require_statement][index]
140
- @index = cached.interval.end if cached
143
+ if cached
144
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
145
+ @index = cached.interval.end
146
+ end
141
147
  return cached
142
148
  end
143
149
 
@@ -162,9 +168,8 @@ module Treetop
162
168
  s4, i4 = [], index
163
169
  loop do
164
170
  if has_terminal?('\G[ \\t]', true, index)
165
- next_character = index + input[index..-1].match(/\A(.)/um).end(1)
166
171
  r5 = true
167
- @index = next_character
172
+ @index += 1
168
173
  else
169
174
  r5 = nil
170
175
  end
@@ -185,9 +190,8 @@ module Treetop
185
190
  s6, i6 = [], index
186
191
  loop do
187
192
  if has_terminal?('\G[^\\n\\r]', true, index)
188
- next_character = index + input[index..-1].match(/\A(.)/um).end(1)
189
193
  r7 = true
190
- @index = next_character
194
+ @index += 1
191
195
  else
192
196
  r7 = nil
193
197
  end
@@ -206,9 +210,8 @@ module Treetop
206
210
  s0 << r6
207
211
  if r6
208
212
  if has_terminal?('\G[\\n\\r]', true, index)
209
- next_character = index + input[index..-1].match(/\A(.)/um).end(1)
210
213
  r8 = true
211
- @index = next_character
214
+ @index += 1
212
215
  else
213
216
  r8 = nil
214
217
  end
@@ -271,7 +274,10 @@ module Treetop
271
274
  start_index = index
272
275
  if node_cache[:module_declaration].has_key?(index)
273
276
  cached = node_cache[:module_declaration][index]
274
- @index = cached.interval.end if cached
277
+ if cached
278
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
279
+ @index = cached.interval.end
280
+ end
275
281
  return cached
276
282
  end
277
283
 
@@ -290,9 +296,8 @@ module Treetop
290
296
  s1 << r3
291
297
  if r3
292
298
  if has_terminal?('\G[A-Z]', true, index)
293
- next_character = index + input[index..-1].match(/\A(.)/um).end(1)
294
299
  r4 = true
295
- @index = next_character
300
+ @index += 1
296
301
  else
297
302
  r4 = nil
298
303
  end
@@ -406,7 +411,10 @@ module Treetop
406
411
  start_index = index
407
412
  if node_cache[:grammar].has_key?(index)
408
413
  cached = node_cache[:grammar][index]
409
- @index = cached.interval.end if cached
414
+ if cached
415
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
416
+ @index = cached.interval.end
417
+ end
410
418
  return cached
411
419
  end
412
420
 
@@ -502,15 +510,17 @@ module Treetop
502
510
  start_index = index
503
511
  if node_cache[:grammar_name].has_key?(index)
504
512
  cached = node_cache[:grammar_name][index]
505
- @index = cached.interval.end if cached
513
+ if cached
514
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
515
+ @index = cached.interval.end
516
+ end
506
517
  return cached
507
518
  end
508
519
 
509
520
  i0, s0 = index, []
510
521
  if has_terminal?('\G[A-Z]', true, index)
511
- next_character = index + input[index..-1].match(/\A(.)/um).end(1)
512
522
  r1 = true
513
- @index = next_character
523
+ @index += 1
514
524
  else
515
525
  r1 = nil
516
526
  end
@@ -580,7 +590,10 @@ module Treetop
580
590
  start_index = index
581
591
  if node_cache[:declaration_sequence].has_key?(index)
582
592
  cached = node_cache[:declaration_sequence][index]
583
- @index = cached.interval.end if cached
593
+ if cached
594
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
595
+ @index = cached.interval.end
596
+ end
584
597
  return cached
585
598
  end
586
599
 
@@ -650,7 +663,10 @@ module Treetop
650
663
  start_index = index
651
664
  if node_cache[:declaration].has_key?(index)
652
665
  cached = node_cache[:declaration][index]
653
- @index = cached.interval.end if cached
666
+ if cached
667
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
668
+ @index = cached.interval.end
669
+ end
654
670
  return cached
655
671
  end
656
672
 
@@ -690,7 +706,10 @@ module Treetop
690
706
  start_index = index
691
707
  if node_cache[:include_declaration].has_key?(index)
692
708
  cached = node_cache[:include_declaration][index]
693
- @index = cached.interval.end if cached
709
+ if cached
710
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
711
+ @index = cached.interval.end
712
+ end
694
713
  return cached
695
714
  end
696
715
 
@@ -708,9 +727,8 @@ module Treetop
708
727
  s0 << r2
709
728
  if r2
710
729
  if has_terminal?('\G[A-Z]', true, index)
711
- next_character = index + input[index..-1].match(/\A(.)/um).end(1)
712
730
  r3 = true
713
- @index = next_character
731
+ @index += 1
714
732
  else
715
733
  r3 = nil
716
734
  end
@@ -795,7 +813,10 @@ module Treetop
795
813
  start_index = index
796
814
  if node_cache[:parsing_rule].has_key?(index)
797
815
  cached = node_cache[:parsing_rule][index]
798
- @index = cached.interval.end if cached
816
+ if cached
817
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
818
+ @index = cached.interval.end
819
+ end
799
820
  return cached
800
821
  end
801
822
 
@@ -883,7 +904,10 @@ module Treetop
883
904
  start_index = index
884
905
  if node_cache[:parsing_expression].has_key?(index)
885
906
  cached = node_cache[:parsing_expression][index]
886
- @index = cached.interval.end if cached
907
+ if cached
908
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
909
+ @index = cached.interval.end
910
+ end
887
911
  return cached
888
912
  end
889
913
 
@@ -945,7 +969,10 @@ module Treetop
945
969
  start_index = index
946
970
  if node_cache[:choice].has_key?(index)
947
971
  cached = node_cache[:choice][index]
948
- @index = cached.interval.end if cached
972
+ if cached
973
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
974
+ @index = cached.interval.end
975
+ end
949
976
  return cached
950
977
  end
951
978
 
@@ -1069,7 +1096,10 @@ module Treetop
1069
1096
  start_index = index
1070
1097
  if node_cache[:sequence].has_key?(index)
1071
1098
  cached = node_cache[:sequence][index]
1072
- @index = cached.interval.end if cached
1099
+ if cached
1100
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1101
+ @index = cached.interval.end
1102
+ end
1073
1103
  return cached
1074
1104
  end
1075
1105
 
@@ -1129,7 +1159,10 @@ module Treetop
1129
1159
  start_index = index
1130
1160
  if node_cache[:alternative].has_key?(index)
1131
1161
  cached = node_cache[:alternative][index]
1132
- @index = cached.interval.end if cached
1162
+ if cached
1163
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1164
+ @index = cached.interval.end
1165
+ end
1133
1166
  return cached
1134
1167
  end
1135
1168
 
@@ -1270,7 +1303,10 @@ module Treetop
1270
1303
  start_index = index
1271
1304
  if node_cache[:primary].has_key?(index)
1272
1305
  cached = node_cache[:primary][index]
1273
- @index = cached.interval.end if cached
1306
+ if cached
1307
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1308
+ @index = cached.interval.end
1309
+ end
1274
1310
  return cached
1275
1311
  end
1276
1312
 
@@ -1406,7 +1442,10 @@ module Treetop
1406
1442
  start_index = index
1407
1443
  if node_cache[:labeled_sequence_primary].has_key?(index)
1408
1444
  cached = node_cache[:labeled_sequence_primary][index]
1409
- @index = cached.interval.end if cached
1445
+ if cached
1446
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1447
+ @index = cached.interval.end
1448
+ end
1410
1449
  return cached
1411
1450
  end
1412
1451
 
@@ -1457,7 +1496,10 @@ module Treetop
1457
1496
  start_index = index
1458
1497
  if node_cache[:label].has_key?(index)
1459
1498
  cached = node_cache[:label][index]
1460
- @index = cached.interval.end if cached
1499
+ if cached
1500
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1501
+ @index = cached.interval.end
1502
+ end
1461
1503
  return cached
1462
1504
  end
1463
1505
 
@@ -1611,7 +1653,10 @@ module Treetop
1611
1653
  start_index = index
1612
1654
  if node_cache[:sequence_primary].has_key?(index)
1613
1655
  cached = node_cache[:sequence_primary][index]
1614
- @index = cached.interval.end if cached
1656
+ if cached
1657
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1658
+ @index = cached.interval.end
1659
+ end
1615
1660
  return cached
1616
1661
  end
1617
1662
 
@@ -1699,7 +1744,10 @@ module Treetop
1699
1744
  start_index = index
1700
1745
  if node_cache[:suffix].has_key?(index)
1701
1746
  cached = node_cache[:suffix][index]
1702
- @index = cached.interval.end if cached
1747
+ if cached
1748
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1749
+ @index = cached.interval.end
1750
+ end
1703
1751
  return cached
1704
1752
  end
1705
1753
 
@@ -1726,7 +1774,10 @@ module Treetop
1726
1774
  start_index = index
1727
1775
  if node_cache[:optional_suffix].has_key?(index)
1728
1776
  cached = node_cache[:optional_suffix][index]
1729
- @index = cached.interval.end if cached
1777
+ if cached
1778
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1779
+ @index = cached.interval.end
1780
+ end
1730
1781
  return cached
1731
1782
  end
1732
1783
 
@@ -1775,7 +1826,10 @@ module Treetop
1775
1826
  start_index = index
1776
1827
  if node_cache[:node_class_declarations].has_key?(index)
1777
1828
  cached = node_cache[:node_class_declarations][index]
1778
- @index = cached.interval.end if cached
1829
+ if cached
1830
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1831
+ @index = cached.interval.end
1832
+ end
1779
1833
  return cached
1780
1834
  end
1781
1835
 
@@ -1804,7 +1858,10 @@ module Treetop
1804
1858
  start_index = index
1805
1859
  if node_cache[:repetition_suffix].has_key?(index)
1806
1860
  cached = node_cache[:repetition_suffix][index]
1807
- @index = cached.interval.end if cached
1861
+ if cached
1862
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1863
+ @index = cached.interval.end
1864
+ end
1808
1865
  return cached
1809
1866
  end
1810
1867
 
@@ -1843,7 +1900,10 @@ module Treetop
1843
1900
  start_index = index
1844
1901
  if node_cache[:prefix].has_key?(index)
1845
1902
  cached = node_cache[:prefix][index]
1846
- @index = cached.interval.end if cached
1903
+ if cached
1904
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1905
+ @index = cached.interval.end
1906
+ end
1847
1907
  return cached
1848
1908
  end
1849
1909
 
@@ -1893,7 +1953,10 @@ module Treetop
1893
1953
  start_index = index
1894
1954
  if node_cache[:atomic].has_key?(index)
1895
1955
  cached = node_cache[:atomic][index]
1896
- @index = cached.interval.end if cached
1956
+ if cached
1957
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1958
+ @index = cached.interval.end
1959
+ end
1897
1960
  return cached
1898
1961
  end
1899
1962
 
@@ -1938,7 +2001,10 @@ module Treetop
1938
2001
  start_index = index
1939
2002
  if node_cache[:parenthesized_expression].has_key?(index)
1940
2003
  cached = node_cache[:parenthesized_expression][index]
1941
- @index = cached.interval.end if cached
2004
+ if cached
2005
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2006
+ @index = cached.interval.end
2007
+ end
1942
2008
  return cached
1943
2009
  end
1944
2010
 
@@ -2011,7 +2077,10 @@ module Treetop
2011
2077
  start_index = index
2012
2078
  if node_cache[:nonterminal].has_key?(index)
2013
2079
  cached = node_cache[:nonterminal][index]
2014
- @index = cached.interval.end if cached
2080
+ if cached
2081
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2082
+ @index = cached.interval.end
2083
+ end
2015
2084
  return cached
2016
2085
  end
2017
2086
 
@@ -2068,7 +2137,10 @@ module Treetop
2068
2137
  start_index = index
2069
2138
  if node_cache[:terminal].has_key?(index)
2070
2139
  cached = node_cache[:terminal][index]
2071
- @index = cached.interval.end if cached
2140
+ if cached
2141
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2142
+ @index = cached.interval.end
2143
+ end
2072
2144
  return cached
2073
2145
  end
2074
2146
 
@@ -2106,7 +2178,10 @@ module Treetop
2106
2178
  start_index = index
2107
2179
  if node_cache[:quoted_string].has_key?(index)
2108
2180
  cached = node_cache[:quoted_string][index]
2109
- @index = cached.interval.end if cached
2181
+ if cached
2182
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2183
+ @index = cached.interval.end
2184
+ end
2110
2185
  return cached
2111
2186
  end
2112
2187
 
@@ -2145,7 +2220,10 @@ module Treetop
2145
2220
  start_index = index
2146
2221
  if node_cache[:double_quoted_string].has_key?(index)
2147
2222
  cached = node_cache[:double_quoted_string][index]
2148
- @index = cached.interval.end if cached
2223
+ if cached
2224
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2225
+ @index = cached.interval.end
2226
+ end
2149
2227
  return cached
2150
2228
  end
2151
2229
 
@@ -2200,9 +2278,8 @@ module Treetop
2200
2278
  r6 = r8
2201
2279
  else
2202
2280
  if index < input_length
2203
- next_character = index + input[index..-1].match(/\A(.)/um).end(1)
2204
- r9 = instantiate_node(SyntaxNode,input, index...next_character)
2205
- @index = next_character
2281
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
2282
+ @index += 1
2206
2283
  else
2207
2284
  terminal_parse_failure("any character")
2208
2285
  r9 = nil
@@ -2270,7 +2347,10 @@ module Treetop
2270
2347
  start_index = index
2271
2348
  if node_cache[:single_quoted_string].has_key?(index)
2272
2349
  cached = node_cache[:single_quoted_string][index]
2273
- @index = cached.interval.end if cached
2350
+ if cached
2351
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2352
+ @index = cached.interval.end
2353
+ end
2274
2354
  return cached
2275
2355
  end
2276
2356
 
@@ -2325,9 +2405,8 @@ module Treetop
2325
2405
  r6 = r8
2326
2406
  else
2327
2407
  if index < input_length
2328
- next_character = index + input[index..-1].match(/\A(.)/um).end(1)
2329
- r9 = instantiate_node(SyntaxNode,input, index...next_character)
2330
- @index = next_character
2408
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
2409
+ @index += 1
2331
2410
  else
2332
2411
  terminal_parse_failure("any character")
2333
2412
  r9 = nil
@@ -2407,7 +2486,10 @@ module Treetop
2407
2486
  start_index = index
2408
2487
  if node_cache[:character_class].has_key?(index)
2409
2488
  cached = node_cache[:character_class][index]
2410
- @index = cached.interval.end if cached
2489
+ if cached
2490
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2491
+ @index = cached.interval.end
2492
+ end
2411
2493
  return cached
2412
2494
  end
2413
2495
 
@@ -2452,9 +2534,8 @@ module Treetop
2452
2534
  s7 << r8
2453
2535
  if r8
2454
2536
  if index < input_length
2455
- next_character = index + input[index..-1].match(/\A(.)/um).end(1)
2456
- r9 = instantiate_node(SyntaxNode,input, index...next_character)
2457
- @index = next_character
2537
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
2538
+ @index += 1
2458
2539
  else
2459
2540
  terminal_parse_failure("any character")
2460
2541
  r9 = nil
@@ -2489,9 +2570,8 @@ module Treetop
2489
2570
  s10 << r11
2490
2571
  if r11
2491
2572
  if index < input_length
2492
- next_character = index + input[index..-1].match(/\A(.)/um).end(1)
2493
- r13 = instantiate_node(SyntaxNode,input, index...next_character)
2494
- @index = next_character
2573
+ r13 = instantiate_node(SyntaxNode,input, index...(index + 1))
2574
+ @index += 1
2495
2575
  else
2496
2576
  terminal_parse_failure("any character")
2497
2577
  r13 = nil
@@ -2563,7 +2643,10 @@ module Treetop
2563
2643
  start_index = index
2564
2644
  if node_cache[:anything_symbol].has_key?(index)
2565
2645
  cached = node_cache[:anything_symbol][index]
2566
- @index = cached.interval.end if cached
2646
+ if cached
2647
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2648
+ @index = cached.interval.end
2649
+ end
2567
2650
  return cached
2568
2651
  end
2569
2652
 
@@ -2606,7 +2689,10 @@ module Treetop
2606
2689
  start_index = index
2607
2690
  if node_cache[:node_class_expression].has_key?(index)
2608
2691
  cached = node_cache[:node_class_expression][index]
2609
- @index = cached.interval.end if cached
2692
+ if cached
2693
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2694
+ @index = cached.interval.end
2695
+ end
2610
2696
  return cached
2611
2697
  end
2612
2698
 
@@ -2644,9 +2730,8 @@ module Treetop
2644
2730
  s5 << r6
2645
2731
  if r6
2646
2732
  if index < input_length
2647
- next_character = index + input[index..-1].match(/\A(.)/um).end(1)
2648
- r8 = instantiate_node(SyntaxNode,input, index...next_character)
2649
- @index = next_character
2733
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
2734
+ @index += 1
2650
2735
  else
2651
2736
  terminal_parse_failure("any character")
2652
2737
  r8 = nil
@@ -2755,7 +2840,10 @@ module Treetop
2755
2840
  start_index = index
2756
2841
  if node_cache[:trailing_inline_module].has_key?(index)
2757
2842
  cached = node_cache[:trailing_inline_module][index]
2758
- @index = cached.interval.end if cached
2843
+ if cached
2844
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2845
+ @index = cached.interval.end
2846
+ end
2759
2847
  return cached
2760
2848
  end
2761
2849
 
@@ -2809,7 +2897,10 @@ module Treetop
2809
2897
  start_index = index
2810
2898
  if node_cache[:predicate_block].has_key?(index)
2811
2899
  cached = node_cache[:predicate_block][index]
2812
- @index = cached.interval.end if cached
2900
+ if cached
2901
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2902
+ @index = cached.interval.end
2903
+ end
2813
2904
  return cached
2814
2905
  end
2815
2906
 
@@ -2849,7 +2940,10 @@ module Treetop
2849
2940
  start_index = index
2850
2941
  if node_cache[:inline_module].has_key?(index)
2851
2942
  cached = node_cache[:inline_module][index]
2852
- @index = cached.interval.end if cached
2943
+ if cached
2944
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2945
+ @index = cached.interval.end
2946
+ end
2853
2947
  return cached
2854
2948
  end
2855
2949
 
@@ -2873,9 +2967,8 @@ module Treetop
2873
2967
  i5, s5 = index, []
2874
2968
  i6 = index
2875
2969
  if has_terminal?('\G[{}]', true, index)
2876
- next_character = index + input[index..-1].match(/\A(.)/um).end(1)
2877
2970
  r7 = true
2878
- @index = next_character
2971
+ @index += 1
2879
2972
  else
2880
2973
  r7 = nil
2881
2974
  end
@@ -2888,9 +2981,8 @@ module Treetop
2888
2981
  s5 << r6
2889
2982
  if r6
2890
2983
  if index < input_length
2891
- next_character = index + input[index..-1].match(/\A(.)/um).end(1)
2892
- r8 = instantiate_node(SyntaxNode,input, index...next_character)
2893
- @index = next_character
2984
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
2985
+ @index += 1
2894
2986
  else
2895
2987
  terminal_parse_failure("any character")
2896
2988
  r8 = nil
@@ -2950,7 +3042,10 @@ module Treetop
2950
3042
  start_index = index
2951
3043
  if node_cache[:keyword_inside_grammar].has_key?(index)
2952
3044
  cached = node_cache[:keyword_inside_grammar][index]
2953
- @index = cached.interval.end if cached
3045
+ if cached
3046
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3047
+ @index = cached.interval.end
3048
+ end
2954
3049
  return cached
2955
3050
  end
2956
3051
 
@@ -3012,7 +3107,10 @@ module Treetop
3012
3107
  start_index = index
3013
3108
  if node_cache[:non_space_char].has_key?(index)
3014
3109
  cached = node_cache[:non_space_char][index]
3015
- @index = cached.interval.end if cached
3110
+ if cached
3111
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3112
+ @index = cached.interval.end
3113
+ end
3016
3114
  return cached
3017
3115
  end
3018
3116
 
@@ -3028,9 +3126,8 @@ module Treetop
3028
3126
  s0 << r1
3029
3127
  if r1
3030
3128
  if index < input_length
3031
- next_character = index + input[index..-1].match(/\A(.)/um).end(1)
3032
- r3 = instantiate_node(SyntaxNode,input, index...next_character)
3033
- @index = next_character
3129
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
3130
+ @index += 1
3034
3131
  else
3035
3132
  terminal_parse_failure("any character")
3036
3133
  r3 = nil
@@ -3054,14 +3151,16 @@ module Treetop
3054
3151
  start_index = index
3055
3152
  if node_cache[:alpha_char].has_key?(index)
3056
3153
  cached = node_cache[:alpha_char][index]
3057
- @index = cached.interval.end if cached
3154
+ if cached
3155
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3156
+ @index = cached.interval.end
3157
+ end
3058
3158
  return cached
3059
3159
  end
3060
3160
 
3061
3161
  if has_terminal?('\G[A-Za-z_]', true, index)
3062
- next_character = index + input[index..-1].match(/\A(.)/um).end(1)
3063
- r0 = instantiate_node(SyntaxNode, input, index...next_character)
3064
- @index = next_character
3162
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
3163
+ @index += 1
3065
3164
  else
3066
3165
  r0 = nil
3067
3166
  end
@@ -3075,7 +3174,10 @@ module Treetop
3075
3174
  start_index = index
3076
3175
  if node_cache[:alphanumeric_char].has_key?(index)
3077
3176
  cached = node_cache[:alphanumeric_char][index]
3078
- @index = cached.interval.end if cached
3177
+ if cached
3178
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3179
+ @index = cached.interval.end
3180
+ end
3079
3181
  return cached
3080
3182
  end
3081
3183
 
@@ -3085,9 +3187,8 @@ module Treetop
3085
3187
  r0 = r1
3086
3188
  else
3087
3189
  if has_terminal?('\G[0-9]', true, index)
3088
- next_character = index + input[index..-1].match(/\A(.)/um).end(1)
3089
3190
  r2 = true
3090
- @index = next_character
3191
+ @index += 1
3091
3192
  else
3092
3193
  r2 = nil
3093
3194
  end
@@ -3108,7 +3209,10 @@ module Treetop
3108
3209
  start_index = index
3109
3210
  if node_cache[:space].has_key?(index)
3110
3211
  cached = node_cache[:space][index]
3111
- @index = cached.interval.end if cached
3212
+ if cached
3213
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3214
+ @index = cached.interval.end
3215
+ end
3112
3216
  return cached
3113
3217
  end
3114
3218
 
@@ -3155,7 +3259,10 @@ module Treetop
3155
3259
  start_index = index
3156
3260
  if node_cache[:comment_to_eol].has_key?(index)
3157
3261
  cached = node_cache[:comment_to_eol][index]
3158
- @index = cached.interval.end if cached
3262
+ if cached
3263
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3264
+ @index = cached.interval.end
3265
+ end
3159
3266
  return cached
3160
3267
  end
3161
3268
 
@@ -3189,9 +3296,8 @@ module Treetop
3189
3296
  s3 << r4
3190
3297
  if r4
3191
3298
  if index < input_length
3192
- next_character = index + input[index..-1].match(/\A(.)/um).end(1)
3193
- r6 = instantiate_node(SyntaxNode,input, index...next_character)
3194
- @index = next_character
3299
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
3300
+ @index += 1
3195
3301
  else
3196
3302
  terminal_parse_failure("any character")
3197
3303
  r6 = nil
@@ -3231,14 +3337,16 @@ module Treetop
3231
3337
  start_index = index
3232
3338
  if node_cache[:white].has_key?(index)
3233
3339
  cached = node_cache[:white][index]
3234
- @index = cached.interval.end if cached
3340
+ if cached
3341
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3342
+ @index = cached.interval.end
3343
+ end
3235
3344
  return cached
3236
3345
  end
3237
3346
 
3238
3347
  if has_terminal?('\G[ \\t\\n\\r]', true, index)
3239
- next_character = index + input[index..-1].match(/\A(.)/um).end(1)
3240
- r0 = instantiate_node(SyntaxNode, input, index...next_character)
3241
- @index = next_character
3348
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
3349
+ @index += 1
3242
3350
  else
3243
3351
  r0 = nil
3244
3352
  end
@@ -34,7 +34,10 @@ module Treetop
34
34
  def generate_cache_lookup(builder)
35
35
  builder.if_ "node_cache[:#{name}].has_key?(index)" do
36
36
  builder.assign 'cached', "node_cache[:#{name}][index]"
37
- builder << '@index = cached.interval.end if cached'
37
+ builder.if_ "cached" do
38
+ builder << 'cached = SyntaxNode.new(input, index...(index + 1)) if cached == true'
39
+ builder << '@index = cached.interval.end'
40
+ end
38
41
  builder << 'return cached'
39
42
  end
40
43
  end
@@ -17,6 +17,7 @@ module Treetop
17
17
  @index = options[:index] if options[:index]
18
18
  result = send("_nt_#{root}")
19
19
  return nil if (consume_all_input? && index != input.size)
20
+ return SyntaxNode.new(input, index...(index + 1)) if result == true
20
21
  return result
21
22
  end
22
23
 
@@ -2,7 +2,7 @@ module Treetop #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 4
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: treetop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Sobo
@@ -9,7 +9,7 @@ autorequire: treetop
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-11 00:00:00 +10:00
12
+ date: 2009-12-08 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency