antlr3 1.7.5 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/java/RubyTarget.java +50 -16
- data/java/antlr-full-3.2.1.jar +0 -0
- data/lib/antlr3/streams.rb +82 -41
- data/lib/antlr3/template/group-file-lexer.rb +59 -59
- data/lib/antlr3/template/group-file-parser.rb +6 -6
- data/lib/antlr3/test/functional.rb +64 -36
- data/lib/antlr3/version.rb +2 -2
- data/templates/Ruby.stg +1 -1
- data/test/functional/ast-output/auto-ast.rb +86 -86
- data/test/functional/ast-output/construction.rb +14 -15
- data/test/functional/ast-output/hetero-nodes.rb +63 -66
- data/test/functional/ast-output/rewrites.rb +119 -120
- data/test/functional/ast-output/tree-rewrite.rb +96 -96
- data/test/functional/debugging/debug-mode.rb +379 -379
- data/test/functional/debugging/profile-mode.rb +6 -6
- data/test/functional/debugging/rule-tracing.rb +4 -5
- data/test/functional/delegation/import.rb +32 -32
- data/test/functional/lexer/basic.rb +27 -27
- data/test/functional/lexer/filter-mode.rb +6 -7
- data/test/functional/lexer/nuances.rb +2 -3
- data/test/functional/lexer/properties.rb +7 -8
- data/test/functional/lexer/syn-pred.rb +1 -2
- data/test/functional/lexer/xml.rb +3 -3
- data/test/functional/main/main-scripts.rb +37 -37
- data/test/functional/parser/actions.rb +8 -8
- data/test/functional/parser/backtracking.rb +1 -2
- data/test/functional/parser/basic.rb +10 -10
- data/test/functional/parser/calc.rb +9 -9
- data/test/functional/parser/ll-star.rb +3 -3
- data/test/functional/parser/nuances.rb +4 -5
- data/test/functional/parser/predicates.rb +3 -4
- data/test/functional/parser/properties.rb +14 -14
- data/test/functional/parser/rule-methods.rb +8 -7
- data/test/functional/parser/scopes.rb +15 -16
- data/test/functional/template-output/template-output.rb +1 -1
- data/test/functional/token-rewrite/basic.rb +60 -61
- data/test/functional/token-rewrite/via-parser.rb +3 -4
- data/test/functional/tree-parser/basic.rb +30 -31
- data/test/unit/test-streams.rb +10 -10
- data/test/unit/test-template.rb +1 -1
- metadata +2 -2
@@ -370,20 +370,20 @@ class TestASTConstructingParser < ANTLR3::Test::Functional
|
|
370
370
|
WS: (' ' | '\n' | '\t')+ {$channel = HIDDEN;};
|
371
371
|
END
|
372
372
|
|
373
|
-
def self.ast_test(opts, &special_test)
|
374
|
-
input = opts[:input]
|
375
|
-
rule = opts[:rule]
|
376
|
-
expected_tree = opts[:ast]
|
377
|
-
flag = opts[:flag]
|
378
|
-
args = opts[:arguments] || []
|
379
|
-
message = opts[:message] || rule.to_s #"should parse %p with rule %s and make tree %s" % [input, rule, expected_tree]
|
380
|
-
|
381
|
-
example(message) do
|
373
|
+
def self.ast_test( opts, &special_test )
|
374
|
+
input = opts[ :input ]
|
375
|
+
rule = opts[ :rule ]
|
376
|
+
expected_tree = opts[ :ast ]
|
377
|
+
flag = opts[ :flag ]
|
378
|
+
args = opts[ :arguments ] || []
|
379
|
+
message = opts[ :message ] || rule.to_s #"should parse %p with rule %s and make tree %s" % [input, rule, expected_tree]
|
380
|
+
|
381
|
+
example( message ) do
|
382
382
|
lexer = ASTBuilder::Lexer.new( input )
|
383
383
|
parser = ASTBuilder::Parser.new( lexer )
|
384
384
|
parser.flag = flag unless flag.nil?
|
385
|
-
result = parser.send(rule, *args)
|
386
|
-
if special_test then instance_exec(result, &special_test)
|
385
|
+
result = parser.send( rule, *args )
|
386
|
+
if special_test then instance_exec( result, &special_test )
|
387
387
|
elsif expected_tree then
|
388
388
|
result.tree.inspect.should == expected_tree
|
389
389
|
else result.tree.should be_nil
|
@@ -477,11 +477,11 @@ class TestASTConstructingParser < ANTLR3::Test::Functional
|
|
477
477
|
|
478
478
|
ast_test :input => "public int gnurz = 1 + 2;", :rule => :r31, :ast => "(FIELD gnurz public int (+ 1 2))", :flag => 2
|
479
479
|
|
480
|
-
ast_test :input => 'gnurz 32', :rule => :r32, :arguments => [1], :flag => 2, :ast => 'gnurz'
|
480
|
+
ast_test :input => 'gnurz 32', :rule => :r32, :arguments => [ 1 ], :flag => 2, :ast => 'gnurz'
|
481
481
|
|
482
|
-
ast_test :input => 'gnurz 32', :rule => :r32, :arguments => [2], :flag => 2, :ast => '32'
|
482
|
+
ast_test :input => 'gnurz 32', :rule => :r32, :arguments => [ 2 ], :flag => 2, :ast => '32'
|
483
483
|
|
484
|
-
ast_test :input => 'gnurz', :rule => :r32, :arguments => [3], :flag => 2, :ast => nil
|
484
|
+
ast_test :input => 'gnurz', :rule => :r32, :arguments => [ 3 ], :flag => 2, :ast => nil
|
485
485
|
|
486
486
|
ast_test :input => "public private fooze", :rule => :r33, :ast => "fooze"
|
487
487
|
|
@@ -552,4 +552,3 @@ class TestASTConstructingParser < ANTLR3::Test::Functional
|
|
552
552
|
ast_test :input => 'a b c fooze', :rule => :r59, :ast => '(a fooze) (b fooze) (c fooze)'
|
553
553
|
|
554
554
|
end
|
555
|
-
|
@@ -6,7 +6,7 @@ require 'antlr3/test/functional'
|
|
6
6
|
|
7
7
|
class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
8
8
|
|
9
|
-
inline_grammar(<<-'END')
|
9
|
+
inline_grammar( <<-'END' )
|
10
10
|
grammar VToken;
|
11
11
|
options {
|
12
12
|
language=Ruby;
|
@@ -25,7 +25,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
25
25
|
END
|
26
26
|
|
27
27
|
|
28
|
-
inline_grammar(<<-'END')
|
28
|
+
inline_grammar( <<-'END' )
|
29
29
|
grammar TokenWithQualifiedType;
|
30
30
|
options {
|
31
31
|
language=Ruby;
|
@@ -44,7 +44,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
44
44
|
END
|
45
45
|
|
46
46
|
|
47
|
-
inline_grammar(<<-'END')
|
47
|
+
inline_grammar( <<-'END' )
|
48
48
|
grammar TokenWithLabel;
|
49
49
|
options {
|
50
50
|
language=Ruby;
|
@@ -63,7 +63,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
63
63
|
END
|
64
64
|
|
65
65
|
|
66
|
-
inline_grammar(<<-'END')
|
66
|
+
inline_grammar( <<-'END' )
|
67
67
|
grammar TokenWithListLabel;
|
68
68
|
options {
|
69
69
|
language=Ruby;
|
@@ -82,7 +82,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
82
82
|
END
|
83
83
|
|
84
84
|
|
85
|
-
inline_grammar(<<-'END')
|
85
|
+
inline_grammar( <<-'END' )
|
86
86
|
grammar TokenRoot;
|
87
87
|
options {
|
88
88
|
language=Ruby;
|
@@ -102,7 +102,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
102
102
|
END
|
103
103
|
|
104
104
|
|
105
|
-
inline_grammar(<<-'END')
|
105
|
+
inline_grammar( <<-'END' )
|
106
106
|
grammar TokenRootWithListLabel;
|
107
107
|
options {
|
108
108
|
language=Ruby;
|
@@ -122,7 +122,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
122
122
|
END
|
123
123
|
|
124
124
|
|
125
|
-
inline_grammar(<<-'END')
|
125
|
+
inline_grammar( <<-'END' )
|
126
126
|
grammar FromString;
|
127
127
|
options {
|
128
128
|
language=Ruby;
|
@@ -142,7 +142,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
142
142
|
END
|
143
143
|
|
144
144
|
|
145
|
-
inline_grammar(<<-'END')
|
145
|
+
inline_grammar( <<-'END' )
|
146
146
|
grammar StringRoot;
|
147
147
|
options {
|
148
148
|
language=Ruby;
|
@@ -162,7 +162,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
162
162
|
END
|
163
163
|
|
164
164
|
|
165
|
-
inline_grammar(<<-'END')
|
165
|
+
inline_grammar( <<-'END' )
|
166
166
|
grammar RewriteToken;
|
167
167
|
options {
|
168
168
|
language=Ruby;
|
@@ -182,7 +182,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
182
182
|
END
|
183
183
|
|
184
184
|
|
185
|
-
inline_grammar(<<-'END')
|
185
|
+
inline_grammar( <<-'END' )
|
186
186
|
grammar RewriteTokenWithArgs;
|
187
187
|
options {
|
188
188
|
language=Ruby;
|
@@ -215,7 +215,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
215
215
|
END
|
216
216
|
|
217
217
|
|
218
|
-
inline_grammar(<<-'END')
|
218
|
+
inline_grammar( <<-'END' )
|
219
219
|
grammar RewriteTokenRoot;
|
220
220
|
options {
|
221
221
|
language=Ruby;
|
@@ -236,7 +236,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
236
236
|
END
|
237
237
|
|
238
238
|
|
239
|
-
inline_grammar(<<-'END')
|
239
|
+
inline_grammar( <<-'END' )
|
240
240
|
grammar RewriteString;
|
241
241
|
options {
|
242
242
|
language=Ruby;
|
@@ -256,7 +256,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
256
256
|
END
|
257
257
|
|
258
258
|
|
259
|
-
inline_grammar(<<-'END')
|
259
|
+
inline_grammar( <<-'END' )
|
260
260
|
grammar RewriteStringRoot;
|
261
261
|
options {
|
262
262
|
language=Ruby;
|
@@ -277,7 +277,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
277
277
|
END
|
278
278
|
|
279
279
|
|
280
|
-
inline_grammar(<<-'END')
|
280
|
+
inline_grammar( <<-'END' )
|
281
281
|
grammar RewriteRuleResults;
|
282
282
|
options {
|
283
283
|
language=Ruby;
|
@@ -308,7 +308,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
308
308
|
END
|
309
309
|
|
310
310
|
|
311
|
-
inline_grammar(<<-'END')
|
311
|
+
inline_grammar( <<-'END' )
|
312
312
|
grammar CopySemanticsWithHetero;
|
313
313
|
options {
|
314
314
|
language=Ruby;
|
@@ -332,7 +332,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
332
332
|
END
|
333
333
|
|
334
334
|
|
335
|
-
inline_grammar(<<-'END')
|
335
|
+
inline_grammar( <<-'END' )
|
336
336
|
grammar TreeParserRewriteFlatList;
|
337
337
|
options {
|
338
338
|
language=Ruby;
|
@@ -345,7 +345,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
345
345
|
END
|
346
346
|
|
347
347
|
|
348
|
-
inline_grammar(<<-'END')
|
348
|
+
inline_grammar( <<-'END' )
|
349
349
|
tree grammar TreeParserRewriteFlatListWalker;
|
350
350
|
options {
|
351
351
|
language=Ruby;
|
@@ -370,7 +370,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
370
370
|
END
|
371
371
|
|
372
372
|
|
373
|
-
inline_grammar(<<-'END')
|
373
|
+
inline_grammar( <<-'END' )
|
374
374
|
grammar TreeParserRewriteTree;
|
375
375
|
options {
|
376
376
|
language=Ruby;
|
@@ -383,7 +383,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
383
383
|
END
|
384
384
|
|
385
385
|
|
386
|
-
inline_grammar(<<-'END')
|
386
|
+
inline_grammar( <<-'END' )
|
387
387
|
tree grammar TreeParserRewriteTreeWalker;
|
388
388
|
options {
|
389
389
|
language=Ruby;
|
@@ -409,7 +409,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
409
409
|
END
|
410
410
|
|
411
411
|
|
412
|
-
inline_grammar(<<-'END')
|
412
|
+
inline_grammar( <<-'END' )
|
413
413
|
grammar TreeParserRewriteImaginary;
|
414
414
|
options {
|
415
415
|
language=Ruby;
|
@@ -422,7 +422,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
422
422
|
END
|
423
423
|
|
424
424
|
|
425
|
-
inline_grammar(<<-'END')
|
425
|
+
inline_grammar( <<-'END' )
|
426
426
|
tree grammar TreeParserRewriteImaginaryWalker;
|
427
427
|
options {
|
428
428
|
language=Ruby;
|
@@ -443,7 +443,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
443
443
|
END
|
444
444
|
|
445
445
|
|
446
|
-
inline_grammar(<<-'END')
|
446
|
+
inline_grammar( <<-'END' )
|
447
447
|
grammar TreeParserRewriteImaginaryWithArgs;
|
448
448
|
options {
|
449
449
|
language=Ruby;
|
@@ -456,7 +456,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
456
456
|
END
|
457
457
|
|
458
458
|
|
459
|
-
inline_grammar(<<-'END')
|
459
|
+
inline_grammar( <<-'END' )
|
460
460
|
tree grammar TreeParserRewriteImaginaryWithArgsWalker;
|
461
461
|
options {
|
462
462
|
language=Ruby;
|
@@ -481,7 +481,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
481
481
|
END
|
482
482
|
|
483
483
|
|
484
|
-
inline_grammar(<<-'END')
|
484
|
+
inline_grammar( <<-'END' )
|
485
485
|
grammar TreeParserRewriteImaginaryRoot;
|
486
486
|
options {
|
487
487
|
language=Ruby;
|
@@ -494,7 +494,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
494
494
|
END
|
495
495
|
|
496
496
|
|
497
|
-
inline_grammar(<<-'END')
|
497
|
+
inline_grammar( <<-'END' )
|
498
498
|
tree grammar TreeParserRewriteImaginaryRootWalker;
|
499
499
|
options {
|
500
500
|
language=Ruby;
|
@@ -515,7 +515,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
515
515
|
END
|
516
516
|
|
517
517
|
|
518
|
-
inline_grammar(<<-'END')
|
518
|
+
inline_grammar( <<-'END' )
|
519
519
|
grammar TreeParserRewriteImaginaryFromReal;
|
520
520
|
options {
|
521
521
|
language=Ruby;
|
@@ -528,7 +528,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
528
528
|
END
|
529
529
|
|
530
530
|
|
531
|
-
inline_grammar(<<-'END')
|
531
|
+
inline_grammar( <<-'END' )
|
532
532
|
tree grammar TreeParserRewriteImaginaryFromRealWalker;
|
533
533
|
options {
|
534
534
|
language=Ruby;
|
@@ -557,7 +557,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
557
557
|
END
|
558
558
|
|
559
559
|
|
560
|
-
inline_grammar(<<-'END')
|
560
|
+
inline_grammar( <<-'END' )
|
561
561
|
grammar TreeParserAutoHeteroAST;
|
562
562
|
options {
|
563
563
|
language=Ruby;
|
@@ -570,7 +570,7 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
570
570
|
END
|
571
571
|
|
572
572
|
|
573
|
-
inline_grammar(<<-'END')
|
573
|
+
inline_grammar( <<-'END' )
|
574
574
|
tree grammar TreeParserAutoHeteroASTWalker;
|
575
575
|
options {
|
576
576
|
language=Ruby;
|
@@ -590,165 +590,162 @@ class TestHeterogeneousNodeTypes < ANTLR3::Test::Functional
|
|
590
590
|
a : ID<V> ';'<V>;
|
591
591
|
END
|
592
592
|
|
593
|
-
def parse(grammar_name, grammar_rule, input)
|
594
|
-
grammar_module = self.class.const_get(grammar_name.to_s)
|
593
|
+
def parse( grammar_name, grammar_rule, input )
|
594
|
+
grammar_module = self.class.const_get( grammar_name.to_s )
|
595
595
|
lexer = grammar_module::Lexer.new( input )
|
596
596
|
tokens = ANTLR3::CommonTokenStream.new( lexer )
|
597
597
|
parser = grammar_module::Parser.new( tokens )
|
598
|
-
r = parser.send(grammar_rule)
|
598
|
+
r = parser.send( grammar_rule )
|
599
599
|
|
600
|
-
return(r.tree.inspect rescue '')
|
600
|
+
return( r.tree.inspect rescue '' )
|
601
601
|
end
|
602
602
|
|
603
|
-
def tree_parse(grammar_name, grammar_rule, tree_grammar_rule, input)
|
604
|
-
grammar_module = self.class.const_get(grammar_name.to_s)
|
605
|
-
tree_grammar_module = self.class.const_get(grammar_name.to_s + 'Walker')
|
603
|
+
def tree_parse( grammar_name, grammar_rule, tree_grammar_rule, input )
|
604
|
+
grammar_module = self.class.const_get( grammar_name.to_s )
|
605
|
+
tree_grammar_module = self.class.const_get( grammar_name.to_s + 'Walker' )
|
606
606
|
|
607
607
|
lexer = grammar_module::Lexer.new( input )
|
608
608
|
tokens = ANTLR3::CommonTokenStream.new( lexer )
|
609
609
|
parser = grammar_module::Parser.new( tokens )
|
610
|
-
r = parser.send(grammar_rule)
|
610
|
+
r = parser.send( grammar_rule )
|
611
611
|
|
612
|
-
nodes = ANTLR3::CommonTreeNodeStream.new(r.tree)
|
612
|
+
nodes = ANTLR3::CommonTreeNodeStream.new( r.tree )
|
613
613
|
nodes.token_stream = tokens
|
614
|
-
tree_parser = tree_grammar_module::TreeParser.new(nodes)
|
615
|
-
r = tree_parser.send(tree_grammar_rule)
|
614
|
+
tree_parser = tree_grammar_module::TreeParser.new( nodes )
|
615
|
+
r = tree_parser.send( tree_grammar_rule )
|
616
616
|
|
617
|
-
return(r.tree.inspect rescue '')
|
617
|
+
return( r.tree.inspect rescue '' )
|
618
618
|
end
|
619
619
|
|
620
620
|
example "v token" do
|
621
|
-
result = parse(:VToken, :a, 'a')
|
621
|
+
result = parse( :VToken, :a, 'a' )
|
622
622
|
result.should == 'a<V>'
|
623
623
|
end
|
624
624
|
|
625
625
|
|
626
626
|
example "token with qualified type" do
|
627
|
-
result = parse(:TokenWithQualifiedType, :a, 'a')
|
627
|
+
result = parse( :TokenWithQualifiedType, :a, 'a' )
|
628
628
|
result.should == 'a<V>'
|
629
629
|
end
|
630
630
|
|
631
631
|
|
632
632
|
example "token with label" do
|
633
|
-
result = parse(:TokenWithLabel, :a, 'a')
|
633
|
+
result = parse( :TokenWithLabel, :a, 'a' )
|
634
634
|
result.should == 'a<V>'
|
635
635
|
end
|
636
636
|
|
637
637
|
|
638
638
|
example "token with list label" do
|
639
|
-
result = parse(:TokenWithListLabel, :a, 'a')
|
639
|
+
result = parse( :TokenWithListLabel, :a, 'a' )
|
640
640
|
result.should == 'a<V>'
|
641
641
|
end
|
642
642
|
|
643
643
|
|
644
644
|
example "token root" do
|
645
|
-
result = parse(:TokenRoot, :a, 'a')
|
645
|
+
result = parse( :TokenRoot, :a, 'a' )
|
646
646
|
result.should == 'a<V>'
|
647
647
|
end
|
648
648
|
|
649
649
|
|
650
650
|
example "token root with list label" do
|
651
|
-
result = parse(:TokenRootWithListLabel, :a, 'a')
|
651
|
+
result = parse( :TokenRootWithListLabel, :a, 'a' )
|
652
652
|
result.should == 'a<V>'
|
653
653
|
end
|
654
654
|
|
655
655
|
|
656
656
|
example "string" do
|
657
|
-
result = parse(:FromString, :a, 'begin')
|
657
|
+
result = parse( :FromString, :a, 'begin' )
|
658
658
|
result.should == 'begin<V>'
|
659
659
|
end
|
660
660
|
|
661
661
|
|
662
662
|
example "string root" do
|
663
|
-
result = parse(:StringRoot, :a, 'begin')
|
663
|
+
result = parse( :StringRoot, :a, 'begin' )
|
664
664
|
result.should == 'begin<V>'
|
665
665
|
end
|
666
666
|
|
667
667
|
|
668
668
|
example "rewrite token" do
|
669
|
-
result = parse(:RewriteToken, :a, 'a')
|
669
|
+
result = parse( :RewriteToken, :a, 'a' )
|
670
670
|
result.should == 'a<V>'
|
671
671
|
end
|
672
672
|
|
673
673
|
|
674
674
|
example "rewrite token with args" do
|
675
|
-
result = parse(:RewriteTokenWithArgs, :a, 'a')
|
675
|
+
result = parse( :RewriteTokenWithArgs, :a, 'a' )
|
676
676
|
result.should == '<V>;421930 a<V>;9900'
|
677
677
|
end
|
678
678
|
|
679
679
|
|
680
680
|
example "rewrite token root" do
|
681
|
-
result = parse(:RewriteTokenRoot, :a, 'a 2')
|
681
|
+
result = parse( :RewriteTokenRoot, :a, 'a 2' )
|
682
682
|
result.should == '(a<V> 2)'
|
683
683
|
end
|
684
684
|
|
685
685
|
|
686
686
|
example "rewrite string" do
|
687
|
-
result = parse(:RewriteString, :a, 'begin')
|
687
|
+
result = parse( :RewriteString, :a, 'begin' )
|
688
688
|
result.should == 'begin<V>'
|
689
689
|
end
|
690
690
|
|
691
691
|
|
692
692
|
example "rewrite string root" do
|
693
|
-
result = parse(:RewriteStringRoot, :a, 'begin 2')
|
693
|
+
result = parse( :RewriteStringRoot, :a, 'begin 2' )
|
694
694
|
result.should == '(begin<V> 2)'
|
695
695
|
end
|
696
696
|
|
697
697
|
|
698
698
|
example "rewrite rule results" do
|
699
|
-
result = parse(:RewriteRuleResults, :a, 'a,b,c')
|
699
|
+
result = parse( :RewriteRuleResults, :a, 'a,b,c' )
|
700
700
|
result.should == '(LIST<W> a<V> b<V> c<V>)'
|
701
701
|
end
|
702
702
|
|
703
703
|
|
704
704
|
example "copy semantics with hetero" do
|
705
|
-
result = parse(:CopySemanticsWithHetero, :a, 'int a, b, c;')
|
705
|
+
result = parse( :CopySemanticsWithHetero, :a, 'int a, b, c;' )
|
706
706
|
result.should == '(int<V> a) (int<V> b) (int<V> c)'
|
707
707
|
end
|
708
708
|
|
709
709
|
|
710
710
|
example "tree parser rewrite flat list" do
|
711
|
-
result = tree_parse(:TreeParserRewriteFlatList, :a, :a, 'abc 34')
|
711
|
+
result = tree_parse( :TreeParserRewriteFlatList, :a, :a, 'abc 34' )
|
712
712
|
result.should == '34<V> abc<W>'
|
713
713
|
end
|
714
714
|
|
715
715
|
|
716
716
|
example "tree parser rewrite tree" do
|
717
|
-
result = tree_parse(:TreeParserRewriteTree, :a, :a, 'abc 34')
|
717
|
+
result = tree_parse( :TreeParserRewriteTree, :a, :a, 'abc 34' )
|
718
718
|
result.should == '(34<V> abc<W>)'
|
719
719
|
end
|
720
720
|
|
721
721
|
|
722
722
|
example "tree parser rewrite imaginary" do
|
723
|
-
result = tree_parse(:TreeParserRewriteImaginary, :a, :a, 'abc')
|
723
|
+
result = tree_parse( :TreeParserRewriteImaginary, :a, :a, 'abc' )
|
724
724
|
result.should == 'ROOT<V> abc'
|
725
725
|
end
|
726
726
|
|
727
727
|
|
728
728
|
example "tree parser rewrite imaginary with args" do
|
729
|
-
result = tree_parse(:TreeParserRewriteImaginaryWithArgs, :a, :a, 'abc')
|
729
|
+
result = tree_parse( :TreeParserRewriteImaginaryWithArgs, :a, :a, 'abc' )
|
730
730
|
result.should == 'ROOT<V>;42 abc'
|
731
731
|
end
|
732
732
|
|
733
733
|
|
734
734
|
example "tree parser rewrite imaginary root" do
|
735
|
-
result = tree_parse(:TreeParserRewriteImaginaryRoot, :a, :a, 'abc')
|
735
|
+
result = tree_parse( :TreeParserRewriteImaginaryRoot, :a, :a, 'abc' )
|
736
736
|
result.should == '(ROOT<V> abc)'
|
737
737
|
end
|
738
738
|
|
739
739
|
|
740
740
|
example "tree parser rewrite imaginary from real" do
|
741
|
-
result = tree_parse(:TreeParserRewriteImaginaryFromReal, :a, :a, 'abc')
|
741
|
+
result = tree_parse( :TreeParserRewriteImaginaryFromReal, :a, :a, 'abc' )
|
742
742
|
result.should == 'ROOT<V>@1'
|
743
743
|
end
|
744
744
|
|
745
745
|
|
746
746
|
example "tree parser auto hetero ast" do
|
747
|
-
result = tree_parse(:TreeParserAutoHeteroAST, :a, :a, 'abc;')
|
747
|
+
result = tree_parse( :TreeParserAutoHeteroAST, :a, :a, 'abc;' )
|
748
748
|
result.should == 'abc<V> ;<V>'
|
749
749
|
end
|
750
750
|
|
751
751
|
end
|
752
|
-
|
753
|
-
|
754
|
-
|