treetop 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile
CHANGED
@@ -8,12 +8,6 @@ module Treetop
|
|
8
8
|
end
|
9
9
|
|
10
10
|
module TreetopFile0
|
11
|
-
def compile
|
12
|
-
prefix.text_value + module_or_grammar.compile + suffix.text_value
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
module TreetopFile1
|
17
11
|
def prefix
|
18
12
|
elements[0]
|
19
13
|
end
|
@@ -27,6 +21,12 @@ module Treetop
|
|
27
21
|
end
|
28
22
|
end
|
29
23
|
|
24
|
+
module TreetopFile1
|
25
|
+
def compile
|
26
|
+
prefix.text_value + module_or_grammar.compile + suffix.text_value
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
30
|
def _nt_treetop_file
|
31
31
|
start_index = index
|
32
32
|
cached = node_cache[:treetop_file][index]
|
@@ -74,8 +74,8 @@ module Treetop
|
|
74
74
|
end
|
75
75
|
if s0.last.success?
|
76
76
|
r0 = (SyntaxNode).new(input, i0...index, s0)
|
77
|
-
r0.extend(TreetopFile1)
|
78
77
|
r0.extend(TreetopFile0)
|
78
|
+
r0.extend(TreetopFile1)
|
79
79
|
else
|
80
80
|
self.index = i0
|
81
81
|
r0 = ParseFailure.new(input, i0, s0)
|
@@ -104,12 +104,6 @@ module Treetop
|
|
104
104
|
end
|
105
105
|
|
106
106
|
module ModuleDeclaration2
|
107
|
-
def compile
|
108
|
-
prefix.text_value + module_contents.compile + suffix.text_value
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
module ModuleDeclaration3
|
113
107
|
def prefix
|
114
108
|
elements[0]
|
115
109
|
end
|
@@ -123,6 +117,12 @@ module Treetop
|
|
123
117
|
end
|
124
118
|
end
|
125
119
|
|
120
|
+
module ModuleDeclaration3
|
121
|
+
def compile
|
122
|
+
prefix.text_value + module_contents.compile + suffix.text_value
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
126
|
def _nt_module_declaration
|
127
127
|
start_index = index
|
128
128
|
cached = node_cache[:module_declaration][index]
|
@@ -208,8 +208,8 @@ module Treetop
|
|
208
208
|
end
|
209
209
|
if s0.last.success?
|
210
210
|
r0 = (SyntaxNode).new(input, i0...index, s0)
|
211
|
-
r0.extend(ModuleDeclaration3)
|
212
211
|
r0.extend(ModuleDeclaration2)
|
212
|
+
r0.extend(ModuleDeclaration3)
|
213
213
|
else
|
214
214
|
self.index = i0
|
215
215
|
r0 = ParseFailure.new(input, i0, s0)
|
@@ -344,22 +344,22 @@ module Treetop
|
|
344
344
|
end
|
345
345
|
|
346
346
|
module DeclarationSequence1
|
347
|
-
def
|
348
|
-
[
|
347
|
+
def head
|
348
|
+
elements[0]
|
349
349
|
end
|
350
|
-
|
350
|
+
|
351
351
|
def tail
|
352
|
-
|
352
|
+
elements[1]
|
353
353
|
end
|
354
354
|
end
|
355
355
|
|
356
356
|
module DeclarationSequence2
|
357
|
-
def
|
358
|
-
|
357
|
+
def declarations
|
358
|
+
[head] + tail
|
359
359
|
end
|
360
|
-
|
360
|
+
|
361
361
|
def tail
|
362
|
-
elements
|
362
|
+
super.elements.map { |elt| elt.declaration }
|
363
363
|
end
|
364
364
|
end
|
365
365
|
|
@@ -409,8 +409,8 @@ module Treetop
|
|
409
409
|
end
|
410
410
|
if s1.last.success?
|
411
411
|
r1 = (DeclarationSequence).new(input, i1...index, s1)
|
412
|
-
r1.extend(DeclarationSequence2)
|
413
412
|
r1.extend(DeclarationSequence1)
|
413
|
+
r1.extend(DeclarationSequence2)
|
414
414
|
else
|
415
415
|
self.index = i1
|
416
416
|
r1 = ParseFailure.new(input, i1, s1)
|
@@ -468,16 +468,16 @@ module Treetop
|
|
468
468
|
end
|
469
469
|
|
470
470
|
module IncludeDeclaration0
|
471
|
-
def
|
472
|
-
|
471
|
+
def space
|
472
|
+
elements[1]
|
473
473
|
end
|
474
|
+
|
474
475
|
end
|
475
476
|
|
476
477
|
module IncludeDeclaration1
|
477
|
-
def
|
478
|
-
|
478
|
+
def compile(builder)
|
479
|
+
builder << text_value
|
479
480
|
end
|
480
|
-
|
481
481
|
end
|
482
482
|
|
483
483
|
def _nt_include_declaration
|
@@ -515,8 +515,8 @@ module Treetop
|
|
515
515
|
end
|
516
516
|
if s0.last.success?
|
517
517
|
r0 = (SyntaxNode).new(input, i0...index, s0)
|
518
|
-
r0.extend(IncludeDeclaration1)
|
519
518
|
r0.extend(IncludeDeclaration0)
|
519
|
+
r0.extend(IncludeDeclaration1)
|
520
520
|
else
|
521
521
|
self.index = i0
|
522
522
|
r0 = ParseFailure.new(input, i0, s0)
|
@@ -643,26 +643,26 @@ module Treetop
|
|
643
643
|
end
|
644
644
|
|
645
645
|
module Choice1
|
646
|
-
def
|
647
|
-
[
|
646
|
+
def head
|
647
|
+
elements[0]
|
648
648
|
end
|
649
649
|
|
650
650
|
def tail
|
651
|
-
|
652
|
-
end
|
653
|
-
|
654
|
-
def inline_modules
|
655
|
-
(alternatives.map {|alt| alt.inline_modules }).flatten
|
651
|
+
elements[1]
|
656
652
|
end
|
657
653
|
end
|
658
654
|
|
659
655
|
module Choice2
|
660
|
-
def
|
661
|
-
|
656
|
+
def alternatives
|
657
|
+
[head] + tail
|
662
658
|
end
|
663
659
|
|
664
660
|
def tail
|
665
|
-
elements
|
661
|
+
super.elements.map {|elt| elt.alternative}
|
662
|
+
end
|
663
|
+
|
664
|
+
def inline_modules
|
665
|
+
(alternatives.map {|alt| alt.inline_modules }).flatten
|
666
666
|
end
|
667
667
|
end
|
668
668
|
|
@@ -729,8 +729,8 @@ module Treetop
|
|
729
729
|
end
|
730
730
|
if s0.last.success?
|
731
731
|
r0 = (Choice).new(input, i0...index, s0)
|
732
|
-
r0.extend(Choice2)
|
733
732
|
r0.extend(Choice1)
|
733
|
+
r0.extend(Choice2)
|
734
734
|
else
|
735
735
|
self.index = i0
|
736
736
|
r0 = ParseFailure.new(input, i0, s0)
|
@@ -752,6 +752,20 @@ module Treetop
|
|
752
752
|
end
|
753
753
|
|
754
754
|
module Sequence1
|
755
|
+
def head
|
756
|
+
elements[0]
|
757
|
+
end
|
758
|
+
|
759
|
+
def tail
|
760
|
+
elements[1]
|
761
|
+
end
|
762
|
+
|
763
|
+
def node_class_declarations
|
764
|
+
elements[2]
|
765
|
+
end
|
766
|
+
end
|
767
|
+
|
768
|
+
module Sequence2
|
755
769
|
def sequence_elements
|
756
770
|
[head] + tail
|
757
771
|
end
|
@@ -771,20 +785,6 @@ module Treetop
|
|
771
785
|
end
|
772
786
|
end
|
773
787
|
|
774
|
-
module Sequence2
|
775
|
-
def head
|
776
|
-
elements[0]
|
777
|
-
end
|
778
|
-
|
779
|
-
def tail
|
780
|
-
elements[1]
|
781
|
-
end
|
782
|
-
|
783
|
-
def node_class_declarations
|
784
|
-
elements[2]
|
785
|
-
end
|
786
|
-
end
|
787
|
-
|
788
788
|
def _nt_sequence
|
789
789
|
start_index = index
|
790
790
|
cached = node_cache[:sequence][index]
|
@@ -834,8 +834,8 @@ module Treetop
|
|
834
834
|
end
|
835
835
|
if s0.last.success?
|
836
836
|
r0 = (Sequence).new(input, i0...index, s0)
|
837
|
-
r0.extend(Sequence2)
|
838
837
|
r0.extend(Sequence1)
|
838
|
+
r0.extend(Sequence2)
|
839
839
|
else
|
840
840
|
self.index = i0
|
841
841
|
r0 = ParseFailure.new(input, i0, s0)
|
@@ -878,6 +878,16 @@ module Treetop
|
|
878
878
|
end
|
879
879
|
|
880
880
|
module Primary0
|
881
|
+
def prefix
|
882
|
+
elements[0]
|
883
|
+
end
|
884
|
+
|
885
|
+
def atomic
|
886
|
+
elements[1]
|
887
|
+
end
|
888
|
+
end
|
889
|
+
|
890
|
+
module Primary1
|
881
891
|
def compile(address, builder)
|
882
892
|
prefix.compile(address, builder, self)
|
883
893
|
end
|
@@ -895,17 +905,21 @@ module Treetop
|
|
895
905
|
end
|
896
906
|
end
|
897
907
|
|
898
|
-
module
|
899
|
-
def
|
908
|
+
module Primary2
|
909
|
+
def atomic
|
900
910
|
elements[0]
|
901
911
|
end
|
902
912
|
|
903
|
-
def
|
913
|
+
def suffix
|
904
914
|
elements[1]
|
905
915
|
end
|
916
|
+
|
917
|
+
def node_class_declarations
|
918
|
+
elements[2]
|
919
|
+
end
|
906
920
|
end
|
907
921
|
|
908
|
-
module
|
922
|
+
module Primary3
|
909
923
|
def compile(address, builder)
|
910
924
|
suffix.compile(address, builder, self)
|
911
925
|
end
|
@@ -927,21 +941,17 @@ module Treetop
|
|
927
941
|
end
|
928
942
|
end
|
929
943
|
|
930
|
-
module
|
944
|
+
module Primary4
|
931
945
|
def atomic
|
932
946
|
elements[0]
|
933
947
|
end
|
934
948
|
|
935
|
-
def suffix
|
936
|
-
elements[1]
|
937
|
-
end
|
938
|
-
|
939
949
|
def node_class_declarations
|
940
|
-
elements[
|
950
|
+
elements[1]
|
941
951
|
end
|
942
952
|
end
|
943
953
|
|
944
|
-
module
|
954
|
+
module Primary5
|
945
955
|
def compile(address, builder)
|
946
956
|
atomic.compile(address, builder, self)
|
947
957
|
end
|
@@ -959,16 +969,6 @@ module Treetop
|
|
959
969
|
end
|
960
970
|
end
|
961
971
|
|
962
|
-
module Primary5
|
963
|
-
def atomic
|
964
|
-
elements[0]
|
965
|
-
end
|
966
|
-
|
967
|
-
def node_class_declarations
|
968
|
-
elements[1]
|
969
|
-
end
|
970
|
-
end
|
971
|
-
|
972
972
|
def _nt_primary
|
973
973
|
start_index = index
|
974
974
|
cached = node_cache[:primary][index]
|
@@ -987,8 +987,8 @@ module Treetop
|
|
987
987
|
end
|
988
988
|
if s1.last.success?
|
989
989
|
r1 = (SyntaxNode).new(input, i1...index, s1)
|
990
|
-
r1.extend(Primary1)
|
991
990
|
r1.extend(Primary0)
|
991
|
+
r1.extend(Primary1)
|
992
992
|
else
|
993
993
|
self.index = i1
|
994
994
|
r1 = ParseFailure.new(input, i1, s1)
|
@@ -1011,8 +1011,8 @@ module Treetop
|
|
1011
1011
|
end
|
1012
1012
|
if s4.last.success?
|
1013
1013
|
r4 = (SyntaxNode).new(input, i4...index, s4)
|
1014
|
-
r4.extend(Primary3)
|
1015
1014
|
r4.extend(Primary2)
|
1015
|
+
r4.extend(Primary3)
|
1016
1016
|
else
|
1017
1017
|
self.index = i4
|
1018
1018
|
r4 = ParseFailure.new(input, i4, s4)
|
@@ -1031,8 +1031,8 @@ module Treetop
|
|
1031
1031
|
end
|
1032
1032
|
if s8.last.success?
|
1033
1033
|
r8 = (SyntaxNode).new(input, i8...index, s8)
|
1034
|
-
r8.extend(Primary5)
|
1035
1034
|
r8.extend(Primary4)
|
1035
|
+
r8.extend(Primary5)
|
1036
1036
|
else
|
1037
1037
|
self.index = i8
|
1038
1038
|
r8 = ParseFailure.new(input, i8, s8)
|
@@ -1054,6 +1054,16 @@ module Treetop
|
|
1054
1054
|
end
|
1055
1055
|
|
1056
1056
|
module LabeledSequencePrimary0
|
1057
|
+
def label
|
1058
|
+
elements[0]
|
1059
|
+
end
|
1060
|
+
|
1061
|
+
def sequence_primary
|
1062
|
+
elements[1]
|
1063
|
+
end
|
1064
|
+
end
|
1065
|
+
|
1066
|
+
module LabeledSequencePrimary1
|
1057
1067
|
def compile(lexical_address, builder)
|
1058
1068
|
sequence_primary.compile(lexical_address, builder)
|
1059
1069
|
end
|
@@ -1073,16 +1083,6 @@ module Treetop
|
|
1073
1083
|
end
|
1074
1084
|
end
|
1075
1085
|
|
1076
|
-
module LabeledSequencePrimary1
|
1077
|
-
def label
|
1078
|
-
elements[0]
|
1079
|
-
end
|
1080
|
-
|
1081
|
-
def sequence_primary
|
1082
|
-
elements[1]
|
1083
|
-
end
|
1084
|
-
end
|
1085
|
-
|
1086
1086
|
def _nt_labeled_sequence_primary
|
1087
1087
|
start_index = index
|
1088
1088
|
cached = node_cache[:labeled_sequence_primary][index]
|
@@ -1100,8 +1100,8 @@ module Treetop
|
|
1100
1100
|
end
|
1101
1101
|
if s0.last.success?
|
1102
1102
|
r0 = (SyntaxNode).new(input, i0...index, s0)
|
1103
|
-
r0.extend(LabeledSequencePrimary1)
|
1104
1103
|
r0.extend(LabeledSequencePrimary0)
|
1104
|
+
r0.extend(LabeledSequencePrimary1)
|
1105
1105
|
else
|
1106
1106
|
self.index = i0
|
1107
1107
|
r0 = ParseFailure.new(input, i0, s0)
|
@@ -1120,12 +1120,12 @@ module Treetop
|
|
1120
1120
|
end
|
1121
1121
|
|
1122
1122
|
module Label1
|
1123
|
-
def name
|
1124
|
-
elements[0].text_value
|
1125
|
-
end
|
1126
1123
|
end
|
1127
1124
|
|
1128
1125
|
module Label2
|
1126
|
+
def name
|
1127
|
+
elements[0].text_value
|
1128
|
+
end
|
1129
1129
|
end
|
1130
1130
|
|
1131
1131
|
module Label3
|
@@ -1175,8 +1175,8 @@ module Treetop
|
|
1175
1175
|
end
|
1176
1176
|
if s1.last.success?
|
1177
1177
|
r1 = (SyntaxNode).new(input, i1...index, s1)
|
1178
|
-
r1.extend(Label2)
|
1179
1178
|
r1.extend(Label1)
|
1179
|
+
r1.extend(Label2)
|
1180
1180
|
else
|
1181
1181
|
self.index = i1
|
1182
1182
|
r1 = ParseFailure.new(input, i1, s1)
|
@@ -1203,6 +1203,16 @@ module Treetop
|
|
1203
1203
|
end
|
1204
1204
|
|
1205
1205
|
module SequencePrimary0
|
1206
|
+
def prefix
|
1207
|
+
elements[0]
|
1208
|
+
end
|
1209
|
+
|
1210
|
+
def atomic
|
1211
|
+
elements[1]
|
1212
|
+
end
|
1213
|
+
end
|
1214
|
+
|
1215
|
+
module SequencePrimary1
|
1206
1216
|
def compile(lexical_address, builder)
|
1207
1217
|
prefix.compile(lexical_address, builder, self)
|
1208
1218
|
end
|
@@ -1220,17 +1230,17 @@ module Treetop
|
|
1220
1230
|
end
|
1221
1231
|
end
|
1222
1232
|
|
1223
|
-
module
|
1224
|
-
def
|
1233
|
+
module SequencePrimary2
|
1234
|
+
def atomic
|
1225
1235
|
elements[0]
|
1226
1236
|
end
|
1227
1237
|
|
1228
|
-
def
|
1238
|
+
def suffix
|
1229
1239
|
elements[1]
|
1230
1240
|
end
|
1231
1241
|
end
|
1232
1242
|
|
1233
|
-
module
|
1243
|
+
module SequencePrimary3
|
1234
1244
|
def compile(lexical_address, builder)
|
1235
1245
|
suffix.compile(lexical_address, builder, self)
|
1236
1246
|
end
|
@@ -1248,16 +1258,6 @@ module Treetop
|
|
1248
1258
|
end
|
1249
1259
|
end
|
1250
1260
|
|
1251
|
-
module SequencePrimary3
|
1252
|
-
def atomic
|
1253
|
-
elements[0]
|
1254
|
-
end
|
1255
|
-
|
1256
|
-
def suffix
|
1257
|
-
elements[1]
|
1258
|
-
end
|
1259
|
-
end
|
1260
|
-
|
1261
1261
|
def _nt_sequence_primary
|
1262
1262
|
start_index = index
|
1263
1263
|
cached = node_cache[:sequence_primary][index]
|
@@ -1276,8 +1276,8 @@ module Treetop
|
|
1276
1276
|
end
|
1277
1277
|
if s1.last.success?
|
1278
1278
|
r1 = (SyntaxNode).new(input, i1...index, s1)
|
1279
|
-
r1.extend(SequencePrimary1)
|
1280
1279
|
r1.extend(SequencePrimary0)
|
1280
|
+
r1.extend(SequencePrimary1)
|
1281
1281
|
else
|
1282
1282
|
self.index = i1
|
1283
1283
|
r1 = ParseFailure.new(input, i1, s1)
|
@@ -1296,8 +1296,8 @@ module Treetop
|
|
1296
1296
|
end
|
1297
1297
|
if s4.last.success?
|
1298
1298
|
r4 = (SyntaxNode).new(input, i4...index, s4)
|
1299
|
-
r4.extend(SequencePrimary3)
|
1300
1299
|
r4.extend(SequencePrimary2)
|
1300
|
+
r4.extend(SequencePrimary3)
|
1301
1301
|
else
|
1302
1302
|
self.index = i4
|
1303
1303
|
r4 = ParseFailure.new(input, i4, s4)
|
@@ -1371,6 +1371,16 @@ module Treetop
|
|
1371
1371
|
end
|
1372
1372
|
|
1373
1373
|
module NodeClassDeclarations0
|
1374
|
+
def node_class_expression
|
1375
|
+
elements[0]
|
1376
|
+
end
|
1377
|
+
|
1378
|
+
def trailing_inline_module
|
1379
|
+
elements[1]
|
1380
|
+
end
|
1381
|
+
end
|
1382
|
+
|
1383
|
+
module NodeClassDeclarations1
|
1374
1384
|
def node_class
|
1375
1385
|
node_class_expression.node_class
|
1376
1386
|
end
|
@@ -1388,16 +1398,6 @@ module Treetop
|
|
1388
1398
|
end
|
1389
1399
|
end
|
1390
1400
|
|
1391
|
-
module NodeClassDeclarations1
|
1392
|
-
def node_class_expression
|
1393
|
-
elements[0]
|
1394
|
-
end
|
1395
|
-
|
1396
|
-
def trailing_inline_module
|
1397
|
-
elements[1]
|
1398
|
-
end
|
1399
|
-
end
|
1400
|
-
|
1401
1401
|
def _nt_node_class_declarations
|
1402
1402
|
start_index = index
|
1403
1403
|
cached = node_cache[:node_class_declarations][index]
|
@@ -1415,8 +1415,8 @@ module Treetop
|
|
1415
1415
|
end
|
1416
1416
|
if s0.last.success?
|
1417
1417
|
r0 = (SyntaxNode).new(input, i0...index, s0)
|
1418
|
-
r0.extend(NodeClassDeclarations1)
|
1419
1418
|
r0.extend(NodeClassDeclarations0)
|
1419
|
+
r0.extend(NodeClassDeclarations1)
|
1420
1420
|
else
|
1421
1421
|
self.index = i0
|
1422
1422
|
r0 = ParseFailure.new(input, i0, s0)
|
@@ -1528,16 +1528,16 @@ module Treetop
|
|
1528
1528
|
end
|
1529
1529
|
|
1530
1530
|
module ParenthesizedExpression0
|
1531
|
-
def
|
1532
|
-
|
1531
|
+
def parsing_expression
|
1532
|
+
elements[2]
|
1533
1533
|
end
|
1534
|
+
|
1534
1535
|
end
|
1535
1536
|
|
1536
1537
|
module ParenthesizedExpression1
|
1537
|
-
def
|
1538
|
-
|
1538
|
+
def inline_modules
|
1539
|
+
parsing_expression.inline_modules
|
1539
1540
|
end
|
1540
|
-
|
1541
1541
|
end
|
1542
1542
|
|
1543
1543
|
def _nt_parenthesized_expression
|
@@ -1579,8 +1579,8 @@ module Treetop
|
|
1579
1579
|
end
|
1580
1580
|
if s0.last.success?
|
1581
1581
|
r0 = (ParenthesizedExpression).new(input, i0...index, s0)
|
1582
|
-
r0.extend(ParenthesizedExpression1)
|
1583
1582
|
r0.extend(ParenthesizedExpression0)
|
1583
|
+
r0.extend(ParenthesizedExpression1)
|
1584
1584
|
else
|
1585
1585
|
self.index = i0
|
1586
1586
|
r0 = ParseFailure.new(input, i0, s0)
|
@@ -1994,16 +1994,16 @@ module Treetop
|
|
1994
1994
|
end
|
1995
1995
|
|
1996
1996
|
module NodeClassExpression1
|
1997
|
-
def
|
1998
|
-
elements[
|
1997
|
+
def space
|
1998
|
+
elements[0]
|
1999
1999
|
end
|
2000
|
+
|
2000
2001
|
end
|
2001
2002
|
|
2002
2003
|
module NodeClassExpression2
|
2003
|
-
def
|
2004
|
-
elements[
|
2004
|
+
def node_class
|
2005
|
+
elements[2].text_value
|
2005
2006
|
end
|
2006
|
-
|
2007
2007
|
end
|
2008
2008
|
|
2009
2009
|
module NodeClassExpression3
|
@@ -2073,8 +2073,8 @@ module Treetop
|
|
2073
2073
|
end
|
2074
2074
|
if s1.last.success?
|
2075
2075
|
r1 = (SyntaxNode).new(input, i1...index, s1)
|
2076
|
-
r1.extend(NodeClassExpression2)
|
2077
2076
|
r1.extend(NodeClassExpression1)
|
2077
|
+
r1.extend(NodeClassExpression2)
|
2078
2078
|
else
|
2079
2079
|
self.index = i1
|
2080
2080
|
r1 = ParseFailure.new(input, i1, s1)
|
@@ -2101,16 +2101,6 @@ module Treetop
|
|
2101
2101
|
end
|
2102
2102
|
|
2103
2103
|
module TrailingInlineModule0
|
2104
|
-
def inline_modules
|
2105
|
-
[inline_module]
|
2106
|
-
end
|
2107
|
-
|
2108
|
-
def inline_module_name
|
2109
|
-
inline_module.module_name
|
2110
|
-
end
|
2111
|
-
end
|
2112
|
-
|
2113
|
-
module TrailingInlineModule1
|
2114
2104
|
def space
|
2115
2105
|
elements[0]
|
2116
2106
|
end
|
@@ -2120,6 +2110,16 @@ module Treetop
|
|
2120
2110
|
end
|
2121
2111
|
end
|
2122
2112
|
|
2113
|
+
module TrailingInlineModule1
|
2114
|
+
def inline_modules
|
2115
|
+
[inline_module]
|
2116
|
+
end
|
2117
|
+
|
2118
|
+
def inline_module_name
|
2119
|
+
inline_module.module_name
|
2120
|
+
end
|
2121
|
+
end
|
2122
|
+
|
2123
2123
|
module TrailingInlineModule2
|
2124
2124
|
def inline_modules
|
2125
2125
|
[]
|
@@ -2152,8 +2152,8 @@ module Treetop
|
|
2152
2152
|
end
|
2153
2153
|
if s1.last.success?
|
2154
2154
|
r1 = (SyntaxNode).new(input, i1...index, s1)
|
2155
|
-
r1.extend(TrailingInlineModule1)
|
2156
2155
|
r1.extend(TrailingInlineModule0)
|
2156
|
+
r1.extend(TrailingInlineModule1)
|
2157
2157
|
else
|
2158
2158
|
self.index = i1
|
2159
2159
|
r1 = ParseFailure.new(input, i1, s1)
|
@@ -5,7 +5,13 @@ module Treetop
|
|
5
5
|
def compile(builder)
|
6
6
|
unless rules.empty?
|
7
7
|
builder.method_declaration("root") do
|
8
|
-
builder
|
8
|
+
builder.assign 'result', rules.first.method_name
|
9
|
+
builder.if__ 'index == input.size' do
|
10
|
+
builder << 'return result'
|
11
|
+
end
|
12
|
+
builder.else_ do
|
13
|
+
builder << 'return ParseFailure.new(input, index, result.nested_failures)'
|
14
|
+
end
|
9
15
|
end
|
10
16
|
builder.newline
|
11
17
|
end
|
@@ -27,6 +27,10 @@ class GrammarTest < CompilerTestCase
|
|
27
27
|
parse('bazbaz').should be_success
|
28
28
|
end
|
29
29
|
|
30
|
+
it "fails if it does not parse all input" do
|
31
|
+
parse('barbarbazbaz').should be_failure
|
32
|
+
end
|
33
|
+
|
30
34
|
it "mixes in included modules" do
|
31
35
|
Foo.ancestors.should include(Bar)
|
32
36
|
end
|