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
@@ -5,59 +5,59 @@ require 'antlr3/test/functional'
|
|
5
5
|
|
6
6
|
class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
7
7
|
|
8
|
-
def parse(grammar, rule, input, expect_errors = false)
|
9
|
-
@grammar = inline_grammar(grammar)
|
8
|
+
def parse( grammar, rule, input, expect_errors = false )
|
9
|
+
@grammar = inline_grammar( grammar )
|
10
10
|
compile_and_load @grammar
|
11
|
-
grammar_module = self.class.const_get(@grammar.name)
|
11
|
+
grammar_module = self.class.const_get( @grammar.name )
|
12
12
|
|
13
|
-
grammar_module::Lexer.send(:include, ANTLR3::Test::CollectErrors)
|
14
|
-
grammar_module::Lexer.send(:include, ANTLR3::Test::CaptureOutput)
|
15
|
-
grammar_module::Parser.send(:include, ANTLR3::Test::CollectErrors)
|
16
|
-
grammar_module::Parser.send(:include, ANTLR3::Test::CaptureOutput)
|
13
|
+
grammar_module::Lexer.send( :include, ANTLR3::Test::CollectErrors )
|
14
|
+
grammar_module::Lexer.send( :include, ANTLR3::Test::CaptureOutput )
|
15
|
+
grammar_module::Parser.send( :include, ANTLR3::Test::CollectErrors )
|
16
|
+
grammar_module::Parser.send( :include, ANTLR3::Test::CaptureOutput )
|
17
17
|
|
18
18
|
lexer = grammar_module::Lexer.new( input )
|
19
19
|
parser = grammar_module::Parser.new( lexer )
|
20
20
|
|
21
|
-
r = parser.send(rule)
|
21
|
+
r = parser.send( rule )
|
22
22
|
parser.reported_errors.should be_empty unless expect_errors
|
23
23
|
result = ''
|
24
24
|
|
25
25
|
unless r.nil?
|
26
|
-
result += r.result if r.respond_to?(:result)
|
26
|
+
result += r.result if r.respond_to?( :result )
|
27
27
|
result += r.tree.inspect if r.tree
|
28
28
|
end
|
29
|
-
return(expect_errors ? [result, parser.reported_errors] : result)
|
29
|
+
return( expect_errors ? [ result, parser.reported_errors ] : result )
|
30
30
|
end
|
31
31
|
|
32
|
-
def tree_parse(grammar, tree_grammar, rule, tree_rule, input)
|
33
|
-
@grammar = inline_grammar(grammar)
|
34
|
-
@tree_grammar = inline_grammar(tree_grammar)
|
32
|
+
def tree_parse( grammar, tree_grammar, rule, tree_rule, input )
|
33
|
+
@grammar = inline_grammar( grammar )
|
34
|
+
@tree_grammar = inline_grammar( tree_grammar )
|
35
35
|
compile_and_load @grammar
|
36
36
|
compile_and_load @tree_grammar
|
37
37
|
|
38
|
-
grammar_module = self.class.const_get(@grammar.name)
|
39
|
-
tree_grammar_module = self.class.const_get(@tree_grammar.name)
|
38
|
+
grammar_module = self.class.const_get( @grammar.name )
|
39
|
+
tree_grammar_module = self.class.const_get( @tree_grammar.name )
|
40
40
|
|
41
|
-
grammar_module::Lexer.send(:include, ANTLR3::Test::CollectErrors)
|
42
|
-
grammar_module::Lexer.send(:include, ANTLR3::Test::CaptureOutput)
|
43
|
-
grammar_module::Parser.send(:include, ANTLR3::Test::CollectErrors)
|
44
|
-
grammar_module::Parser.send(:include, ANTLR3::Test::CaptureOutput)
|
45
|
-
tree_grammar_module::TreeParser.send(:include, ANTLR3::Test::CollectErrors)
|
46
|
-
tree_grammar_module::TreeParser.send(:include, ANTLR3::Test::CaptureOutput)
|
41
|
+
grammar_module::Lexer.send( :include, ANTLR3::Test::CollectErrors )
|
42
|
+
grammar_module::Lexer.send( :include, ANTLR3::Test::CaptureOutput )
|
43
|
+
grammar_module::Parser.send( :include, ANTLR3::Test::CollectErrors )
|
44
|
+
grammar_module::Parser.send( :include, ANTLR3::Test::CaptureOutput )
|
45
|
+
tree_grammar_module::TreeParser.send( :include, ANTLR3::Test::CollectErrors )
|
46
|
+
tree_grammar_module::TreeParser.send( :include, ANTLR3::Test::CaptureOutput )
|
47
47
|
|
48
48
|
lexer = grammar_module::Lexer.new( input )
|
49
49
|
parser = grammar.module::Parser.new( lexer )
|
50
|
-
r = parser.send(rule)
|
50
|
+
r = parser.send( rule )
|
51
51
|
nodes = ANTLR3::CommonTreeNodeStream( r.tree )
|
52
52
|
nodes.token_stream = parser.input
|
53
53
|
walker = tree_grammar_module::TreeParser.new( nodes )
|
54
|
-
r = walker.send(tree_rule)
|
54
|
+
r = walker.send( tree_rule )
|
55
55
|
|
56
|
-
return(r ? r.tree.inspect : '')
|
56
|
+
return( r ? r.tree.inspect : '' )
|
57
57
|
end
|
58
58
|
|
59
59
|
example "delete" do
|
60
|
-
result = parse(<<-'END', :a, 'abc 34')
|
60
|
+
result = parse( <<-'END', :a, 'abc 34' )
|
61
61
|
grammar Delete;
|
62
62
|
options {language=Ruby;output=AST;}
|
63
63
|
a : ID INT -> ;
|
@@ -70,7 +70,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
70
70
|
|
71
71
|
|
72
72
|
example "single token" do
|
73
|
-
result = parse(<<-'END', :a, 'abc')
|
73
|
+
result = parse( <<-'END', :a, 'abc' )
|
74
74
|
grammar SingleToken;
|
75
75
|
options {language=Ruby;output=AST;}
|
76
76
|
a : ID -> ID;
|
@@ -84,7 +84,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
84
84
|
|
85
85
|
|
86
86
|
example "single token to new node" do
|
87
|
-
result = parse(<<-'END', :a, 'abc')
|
87
|
+
result = parse( <<-'END', :a, 'abc' )
|
88
88
|
grammar SingleTokenToNewNode;
|
89
89
|
options {language=Ruby;output=AST;}
|
90
90
|
a : ID -> ID["x"];
|
@@ -98,7 +98,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
98
98
|
|
99
99
|
|
100
100
|
example "single token to new node root" do
|
101
|
-
result = parse(<<-'END', :a, 'abc')
|
101
|
+
result = parse( <<-'END', :a, 'abc' )
|
102
102
|
grammar SingleTokenToNewNodeRoot;
|
103
103
|
options {language=Ruby;output=AST;}
|
104
104
|
a : ID -> ^(ID["x"] INT);
|
@@ -112,7 +112,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
112
112
|
|
113
113
|
|
114
114
|
example "single token to new node2" do
|
115
|
-
result = parse(<<-'END', :a, 'abc')
|
115
|
+
result = parse( <<-'END', :a, 'abc' )
|
116
116
|
grammar SingleTokenToNewNode2;
|
117
117
|
options {language=Ruby;output=AST;}
|
118
118
|
a : ID -> ID[ ];
|
@@ -125,7 +125,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
125
125
|
|
126
126
|
|
127
127
|
example "single char literal" do
|
128
|
-
result = parse(<<-'END', :a, 'c')
|
128
|
+
result = parse( <<-'END', :a, 'c' )
|
129
129
|
grammar SingleCharLiteral;
|
130
130
|
options {language=Ruby;output=AST;}
|
131
131
|
a : 'c' -> 'c';
|
@@ -139,7 +139,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
139
139
|
|
140
140
|
|
141
141
|
example "single string literal" do
|
142
|
-
result = parse(<<-'END', :a, 'ick')
|
142
|
+
result = parse( <<-'END', :a, 'ick' )
|
143
143
|
grammar SingleStringLiteral;
|
144
144
|
options {language=Ruby;output=AST;}
|
145
145
|
a : 'ick' -> 'ick';
|
@@ -153,7 +153,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
153
153
|
|
154
154
|
|
155
155
|
example "single rule" do
|
156
|
-
result = parse(<<-'END', :a, 'abc')
|
156
|
+
result = parse( <<-'END', :a, 'abc' )
|
157
157
|
grammar SingleRule;
|
158
158
|
options {language=Ruby;output=AST;}
|
159
159
|
a : b -> b;
|
@@ -168,7 +168,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
168
168
|
|
169
169
|
|
170
170
|
example "reorder tokens" do
|
171
|
-
result = parse(<<-'END', :a, 'abc 34')
|
171
|
+
result = parse( <<-'END', :a, 'abc 34' )
|
172
172
|
grammar ReorderTokens;
|
173
173
|
options {language=Ruby;output=AST;}
|
174
174
|
a : ID INT -> INT ID;
|
@@ -182,7 +182,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
182
182
|
|
183
183
|
|
184
184
|
example "reorder token and rule" do
|
185
|
-
result = parse(<<-'END', :a, 'abc 34')
|
185
|
+
result = parse( <<-'END', :a, 'abc 34' )
|
186
186
|
grammar ReorderTokenAndRule;
|
187
187
|
options {language=Ruby;output=AST;}
|
188
188
|
a : b INT -> INT b;
|
@@ -197,7 +197,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
197
197
|
|
198
198
|
|
199
199
|
example "token tree" do
|
200
|
-
result = parse(<<-'END', :a, 'abc 34')
|
200
|
+
result = parse( <<-'END', :a, 'abc 34' )
|
201
201
|
grammar TokenTree;
|
202
202
|
options {language=Ruby;output=AST;}
|
203
203
|
a : ID INT -> ^(INT ID);
|
@@ -211,7 +211,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
211
211
|
|
212
212
|
|
213
213
|
example "token tree after other stuff" do
|
214
|
-
result = parse(<<-'END', :a, 'void abc 34')
|
214
|
+
result = parse( <<-'END', :a, 'void abc 34' )
|
215
215
|
grammar TokenTreeAfterOtherStuff;
|
216
216
|
options {language=Ruby;output=AST;}
|
217
217
|
a : 'void' ID INT -> 'void' ^(INT ID);
|
@@ -225,7 +225,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
225
225
|
|
226
226
|
|
227
227
|
example "nested token tree with outer loop" do
|
228
|
-
result = parse(<<-'END', :a, 'a 1 b 2')
|
228
|
+
result = parse( <<-'END', :a, 'a 1 b 2' )
|
229
229
|
grammar NestedTokenTreeWithOuterLoop;
|
230
230
|
options {language=Ruby;output=AST;}
|
231
231
|
tokens {DUH;}
|
@@ -240,7 +240,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
240
240
|
|
241
241
|
|
242
242
|
example "optional single token" do
|
243
|
-
result = parse(<<-'END', :a, 'abc')
|
243
|
+
result = parse( <<-'END', :a, 'abc' )
|
244
244
|
grammar OptionalSingleToken;
|
245
245
|
options {language=Ruby;output=AST;}
|
246
246
|
a : ID -> ID? ;
|
@@ -254,7 +254,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
254
254
|
|
255
255
|
|
256
256
|
example "closure single token" do
|
257
|
-
result = parse(<<-'END', :a, 'a b')
|
257
|
+
result = parse( <<-'END', :a, 'a b' )
|
258
258
|
grammar ClosureSingleToken;
|
259
259
|
options {language=Ruby;output=AST;}
|
260
260
|
a : ID ID -> ID* ;
|
@@ -268,7 +268,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
268
268
|
|
269
269
|
|
270
270
|
example "positive closure single token" do
|
271
|
-
result = parse(<<-'END', :a, 'a b')
|
271
|
+
result = parse( <<-'END', :a, 'a b' )
|
272
272
|
grammar PositiveClosureSingleToken;
|
273
273
|
options {language=Ruby;output=AST;}
|
274
274
|
a : ID ID -> ID+ ;
|
@@ -282,7 +282,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
282
282
|
|
283
283
|
|
284
284
|
example "optional single rule" do
|
285
|
-
result = parse(<<-'END', :a, 'abc')
|
285
|
+
result = parse( <<-'END', :a, 'abc' )
|
286
286
|
grammar OptionalSingleRule;
|
287
287
|
options {language=Ruby;output=AST;}
|
288
288
|
a : b -> b?;
|
@@ -297,7 +297,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
297
297
|
|
298
298
|
|
299
299
|
example "closure single rule" do
|
300
|
-
result = parse(<<-'END', :a, 'a b')
|
300
|
+
result = parse( <<-'END', :a, 'a b' )
|
301
301
|
grammar ClosureSingleRule;
|
302
302
|
options {language=Ruby;output=AST;}
|
303
303
|
a : b b -> b*;
|
@@ -312,7 +312,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
312
312
|
|
313
313
|
|
314
314
|
example "closure of label" do
|
315
|
-
result = parse(<<-'END', :a, 'a b')
|
315
|
+
result = parse( <<-'END', :a, 'a b' )
|
316
316
|
grammar ClosureOfLabel;
|
317
317
|
options {language=Ruby;output=AST;}
|
318
318
|
a : x+=b x+=b -> $x*;
|
@@ -327,7 +327,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
327
327
|
|
328
328
|
|
329
329
|
example "optional label no list label" do
|
330
|
-
result = parse(<<-'END', :a, 'a')
|
330
|
+
result = parse( <<-'END', :a, 'a' )
|
331
331
|
grammar OptionalLabelNoListLabel;
|
332
332
|
options {language=Ruby;output=AST;}
|
333
333
|
a : (x=ID)? -> $x?;
|
@@ -341,7 +341,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
341
341
|
|
342
342
|
|
343
343
|
example "positive closure single rule" do
|
344
|
-
result = parse(<<-'END', :a, 'a b')
|
344
|
+
result = parse( <<-'END', :a, 'a b' )
|
345
345
|
grammar PositiveClosureSingleRule;
|
346
346
|
options {language=Ruby;output=AST;}
|
347
347
|
a : b b -> b+;
|
@@ -356,7 +356,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
356
356
|
|
357
357
|
|
358
358
|
example "single predicate t" do
|
359
|
-
result = parse(<<-'END', :a, 'abc')
|
359
|
+
result = parse( <<-'END', :a, 'abc' )
|
360
360
|
grammar SinglePredicateT;
|
361
361
|
options {language=Ruby;output=AST;}
|
362
362
|
a : ID -> {true}? ID -> ;
|
@@ -370,7 +370,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
370
370
|
|
371
371
|
|
372
372
|
example "single predicate f" do
|
373
|
-
result = parse(<<-'END', :a, 'abc')
|
373
|
+
result = parse( <<-'END', :a, 'abc' )
|
374
374
|
grammar SinglePredicateF;
|
375
375
|
options {language=Ruby;output=AST;}
|
376
376
|
a : ID -> {false}? ID -> ;
|
@@ -384,7 +384,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
384
384
|
|
385
385
|
|
386
386
|
example "multiple predicate" do
|
387
|
-
result = parse(<<-'END', :a, 'a 2')
|
387
|
+
result = parse( <<-'END', :a, 'a 2' )
|
388
388
|
grammar MultiplePredicate;
|
389
389
|
options {language=Ruby;output=AST;}
|
390
390
|
a : ID INT -> {false}? ID
|
@@ -401,7 +401,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
401
401
|
|
402
402
|
|
403
403
|
example "multiple predicate trees" do
|
404
|
-
result = parse(<<-'END', :a, 'a 2')
|
404
|
+
result = parse( <<-'END', :a, 'a 2' )
|
405
405
|
grammar MultiplePredicateTrees;
|
406
406
|
options {language=Ruby;output=AST;}
|
407
407
|
a : ID INT -> {false}? ^(ID INT)
|
@@ -418,7 +418,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
418
418
|
|
419
419
|
|
420
420
|
example "simple tree" do
|
421
|
-
result = parse(<<-'END', :a, '-34')
|
421
|
+
result = parse( <<-'END', :a, '-34' )
|
422
422
|
grammar SimpleTree;
|
423
423
|
options {language=Ruby;output=AST;}
|
424
424
|
a : op INT -> ^(op INT);
|
@@ -433,7 +433,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
433
433
|
|
434
434
|
|
435
435
|
example "simple tree2" do
|
436
|
-
result = parse(<<-'END', :a, '+ 34')
|
436
|
+
result = parse( <<-'END', :a, '+ 34' )
|
437
437
|
grammar SimpleTree2;
|
438
438
|
options {language=Ruby;output=AST;}
|
439
439
|
a : op INT -> ^(INT op);
|
@@ -448,7 +448,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
448
448
|
|
449
449
|
|
450
450
|
example "nested trees" do
|
451
|
-
result = parse(<<-'END', :a, 'var a:int; b:float;')
|
451
|
+
result = parse( <<-'END', :a, 'var a:int; b:float;' )
|
452
452
|
grammar NestedTrees;
|
453
453
|
options {language=Ruby;output=AST;}
|
454
454
|
a : 'var' (ID ':' type ';')+ -> ^('var' ^(':' ID type)+) ;
|
@@ -463,7 +463,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
463
463
|
|
464
464
|
|
465
465
|
example "imaginary token copy" do
|
466
|
-
result = parse(<<-'END', :a, 'a,b,c')
|
466
|
+
result = parse( <<-'END', :a, 'a,b,c' )
|
467
467
|
grammar ImaginaryTokenCopy;
|
468
468
|
options {language=Ruby;output=AST;}
|
469
469
|
tokens {VAR;}
|
@@ -479,7 +479,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
479
479
|
|
480
480
|
|
481
481
|
example "token unreferenced on left but defined" do
|
482
|
-
result = parse(<<-'END', :a, 'a')
|
482
|
+
result = parse( <<-'END', :a, 'a' )
|
483
483
|
grammar TokenUnreferencedOnLeftButDefined;
|
484
484
|
options {language=Ruby;output=AST;}
|
485
485
|
tokens {VAR;}
|
@@ -495,7 +495,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
495
495
|
|
496
496
|
|
497
497
|
example "imaginary token copy set text" do
|
498
|
-
result = parse(<<-'END', :a, 'a,b,c')
|
498
|
+
result = parse( <<-'END', :a, 'a,b,c' )
|
499
499
|
grammar ImaginaryTokenCopySetText;
|
500
500
|
options {language=Ruby;output=AST;}
|
501
501
|
tokens {VAR;}
|
@@ -511,7 +511,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
511
511
|
|
512
512
|
|
513
513
|
example "imaginary token no copy from token" do
|
514
|
-
result = parse(<<-'END', :a, '{a b c}')
|
514
|
+
result = parse( <<-'END', :a, '{a b c}' )
|
515
515
|
grammar ImaginaryTokenNoCopyFromToken;
|
516
516
|
options {language=Ruby;output=AST;}
|
517
517
|
tokens {BLOCK;}
|
@@ -527,7 +527,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
527
527
|
|
528
528
|
|
529
529
|
example "imaginary token no copy from token set text" do
|
530
|
-
result = parse(<<-'END', :a, '{a b c}')
|
530
|
+
result = parse( <<-'END', :a, '{a b c}' )
|
531
531
|
grammar ImaginaryTokenNoCopyFromTokenSetText;
|
532
532
|
options {language=Ruby;output=AST;}
|
533
533
|
tokens {BLOCK;}
|
@@ -543,7 +543,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
543
543
|
|
544
544
|
|
545
545
|
example "mixed rewrite and auto ast" do
|
546
|
-
result = parse(<<-'END', :a, 'a 1 2')
|
546
|
+
result = parse( <<-'END', :a, 'a 1 2' )
|
547
547
|
grammar MixedRewriteAndAutoAST;
|
548
548
|
options {language=Ruby;output=AST;}
|
549
549
|
tokens {BLOCK;}
|
@@ -560,7 +560,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
560
560
|
|
561
561
|
|
562
562
|
example "subrule with rewrite" do
|
563
|
-
result = parse(<<-'END', :a, 'a 1 2 3')
|
563
|
+
result = parse( <<-'END', :a, 'a 1 2 3' )
|
564
564
|
grammar SubruleWithRewrite;
|
565
565
|
options {language=Ruby;output=AST;}
|
566
566
|
tokens {BLOCK;}
|
@@ -577,7 +577,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
577
577
|
|
578
578
|
|
579
579
|
example "subrule with rewrite2" do
|
580
|
-
result = parse(<<-'END', :a, 'int a; int b=3;')
|
580
|
+
result = parse( <<-'END', :a, 'int a; int b=3;' )
|
581
581
|
grammar SubruleWithRewrite2;
|
582
582
|
options {language=Ruby;output=AST;}
|
583
583
|
tokens {TYPE;}
|
@@ -598,7 +598,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
598
598
|
|
599
599
|
|
600
600
|
example "nested rewrite shuts off auto ast" do
|
601
|
-
result = parse(<<-'END', :a, 'a b c d; 42')
|
601
|
+
result = parse( <<-'END', :a, 'a b c d; 42' )
|
602
602
|
grammar NestedRewriteShutsOffAutoAST;
|
603
603
|
options {language=Ruby;output=AST;}
|
604
604
|
tokens {BLOCK;}
|
@@ -616,7 +616,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
616
616
|
|
617
617
|
|
618
618
|
example "rewrite actions" do
|
619
|
-
result = parse(<<-'END', :a, '3')
|
619
|
+
result = parse( <<-'END', :a, '3' )
|
620
620
|
grammar RewriteActions;
|
621
621
|
options {language=Ruby;output=AST;}
|
622
622
|
a : atom -> ^({ @adaptor.create!(INT,"9") } atom) ;
|
@@ -631,7 +631,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
631
631
|
|
632
632
|
|
633
633
|
example "rewrite actions2" do
|
634
|
-
result = parse(<<-'END', :a, '3')
|
634
|
+
result = parse( <<-'END', :a, '3' )
|
635
635
|
grammar RewriteActions2;
|
636
636
|
options {language=Ruby;output=AST;}
|
637
637
|
a : atom -> { @adaptor.create!(INT,"9") } atom ;
|
@@ -646,7 +646,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
646
646
|
|
647
647
|
|
648
648
|
example "ref to old value" do
|
649
|
-
result = parse(<<-'END', :a, '3+4+5')
|
649
|
+
result = parse( <<-'END', :a, '3+4+5' )
|
650
650
|
grammar RefToOldValue;
|
651
651
|
options {language=Ruby;output=AST;}
|
652
652
|
tokens {BLOCK;}
|
@@ -662,7 +662,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
662
662
|
|
663
663
|
|
664
664
|
example "copy semantics for rules" do
|
665
|
-
result = parse(<<-'END', :a, '3')
|
665
|
+
result = parse( <<-'END', :a, '3' )
|
666
666
|
grammar CopySemanticsForRules;
|
667
667
|
options {language=Ruby;output=AST;}
|
668
668
|
tokens {BLOCK;}
|
@@ -678,7 +678,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
678
678
|
|
679
679
|
|
680
680
|
example "copy semantics for rules2" do
|
681
|
-
result = parse(<<-'END', :a, 'int a,b,c;')
|
681
|
+
result = parse( <<-'END', :a, 'int a,b,c;' )
|
682
682
|
grammar CopySemanticsForRules2;
|
683
683
|
options {language=Ruby;output=AST;}
|
684
684
|
a : type ID (',' ID)* ';' -> ^(type ID)+ ;
|
@@ -692,7 +692,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
692
692
|
|
693
693
|
|
694
694
|
example "copy semantics for rules3" do
|
695
|
-
result = parse(<<-'END', :a, 'public int a,b,c;')
|
695
|
+
result = parse( <<-'END', :a, 'public int a,b,c;' )
|
696
696
|
grammar CopySemanticsForRules3;
|
697
697
|
options {language=Ruby;output=AST;}
|
698
698
|
a : modifier? type ID (',' ID)* ';' -> ^(type modifier? ID)+ ;
|
@@ -707,7 +707,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
707
707
|
|
708
708
|
|
709
709
|
example "copy semantics for rules3 double" do
|
710
|
-
result = parse(<<-'END', :a, 'public int a,b,c;')
|
710
|
+
result = parse( <<-'END', :a, 'public int a,b,c;' )
|
711
711
|
grammar CopySemanticsForRules3Double;
|
712
712
|
options {language=Ruby;output=AST;}
|
713
713
|
a : modifier? type ID (',' ID)* ';' -> ^(type modifier? ID)+ ^(type modifier? ID)+ ;
|
@@ -722,7 +722,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
722
722
|
|
723
723
|
|
724
724
|
example "copy semantics for rules4" do
|
725
|
-
result = parse(<<-'END', :a, 'public int a,b,c;')
|
725
|
+
result = parse( <<-'END', :a, 'public int a,b,c;' )
|
726
726
|
grammar CopySemanticsForRules4;
|
727
727
|
options {language=Ruby;output=AST;}
|
728
728
|
tokens {MOD;}
|
@@ -738,7 +738,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
738
738
|
|
739
739
|
|
740
740
|
example "copy semantics lists" do
|
741
|
-
result = parse(<<-'END', :a, 'a,b,c;')
|
741
|
+
result = parse( <<-'END', :a, 'a,b,c;' )
|
742
742
|
grammar CopySemanticsLists;
|
743
743
|
options {language=Ruby;output=AST;}
|
744
744
|
tokens {MOD;}
|
@@ -752,7 +752,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
752
752
|
|
753
753
|
|
754
754
|
example "copy rule label" do
|
755
|
-
result = parse(<<-'END', :a, 'a')
|
755
|
+
result = parse( <<-'END', :a, 'a' )
|
756
756
|
grammar CopyRuleLabel;
|
757
757
|
options {language=Ruby;output=AST;}
|
758
758
|
tokens {BLOCK;}
|
@@ -767,7 +767,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
767
767
|
|
768
768
|
|
769
769
|
example "copy rule label2" do
|
770
|
-
result = parse(<<-'END', :a, 'a')
|
770
|
+
result = parse( <<-'END', :a, 'a' )
|
771
771
|
grammar CopyRuleLabel2;
|
772
772
|
options {language=Ruby;output=AST;}
|
773
773
|
tokens {BLOCK;}
|
@@ -782,7 +782,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
782
782
|
|
783
783
|
|
784
784
|
example "queueing of tokens" do
|
785
|
-
result = parse(<<-'END', :a, 'int a,b,c;')
|
785
|
+
result = parse( <<-'END', :a, 'int a,b,c;' )
|
786
786
|
grammar QueueingOfTokens;
|
787
787
|
options {language=Ruby;output=AST;}
|
788
788
|
a : 'int' ID (',' ID)* ';' -> ^('int' ID+) ;
|
@@ -797,7 +797,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
797
797
|
|
798
798
|
|
799
799
|
example "copy of tokens" do
|
800
|
-
result = parse(<<-'END', :a, 'int a;')
|
800
|
+
result = parse( <<-'END', :a, 'int a;' )
|
801
801
|
grammar CopyOfTokens;
|
802
802
|
options {language=Ruby;output=AST;}
|
803
803
|
a : 'int' ID ';' -> 'int' ID 'int' ID ;
|
@@ -812,7 +812,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
812
812
|
|
813
813
|
|
814
814
|
example "token copy in loop" do
|
815
|
-
result = parse(<<-'END', :a, 'int a,b,c;')
|
815
|
+
result = parse( <<-'END', :a, 'int a,b,c;' )
|
816
816
|
grammar TokenCopyInLoop;
|
817
817
|
options {language=Ruby;output=AST;}
|
818
818
|
a : 'int' ID (',' ID)* ';' -> ^('int' ID)+ ;
|
@@ -827,7 +827,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
827
827
|
|
828
828
|
|
829
829
|
example "token copy in loop against two others" do
|
830
|
-
result = parse(<<-'END', :a, 'int a:1,b:2,c:3;')
|
830
|
+
result = parse( <<-'END', :a, 'int a:1,b:2,c:3;' )
|
831
831
|
grammar TokenCopyInLoopAgainstTwoOthers;
|
832
832
|
options {language=Ruby;output=AST;}
|
833
833
|
a : 'int' ID ':' INT (',' ID ':' INT)* ';' -> ^('int' ID INT)+ ;
|
@@ -842,7 +842,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
842
842
|
|
843
843
|
|
844
844
|
example "list refd one at a time" do
|
845
|
-
result = parse(<<-'END', :a, 'a b c')
|
845
|
+
result = parse( <<-'END', :a, 'a b c' )
|
846
846
|
grammar ListRefdOneAtATime;
|
847
847
|
options {language=Ruby;output=AST;}
|
848
848
|
a : ID+ -> ID ID ID ; // works if 3 input IDs
|
@@ -857,7 +857,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
857
857
|
|
858
858
|
|
859
859
|
example "split list with labels" do
|
860
|
-
result = parse(<<-'END', :a, 'a b c')
|
860
|
+
result = parse( <<-'END', :a, 'a b c' )
|
861
861
|
grammar SplitListWithLabels;
|
862
862
|
options {language=Ruby;output=AST;}
|
863
863
|
tokens {VAR;}
|
@@ -873,7 +873,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
873
873
|
|
874
874
|
|
875
875
|
example "complicated melange" do
|
876
|
-
result = parse(<<-'END', :a, 'a a b b b c c c d')
|
876
|
+
result = parse( <<-'END', :a, 'a a b b b c c c d' )
|
877
877
|
grammar ComplicatedMelange;
|
878
878
|
options {language=Ruby;output=AST;}
|
879
879
|
tokens {BLOCK;}
|
@@ -891,7 +891,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
891
891
|
|
892
892
|
|
893
893
|
example "rule label" do
|
894
|
-
result = parse(<<-'END', :a, 'a')
|
894
|
+
result = parse( <<-'END', :a, 'a' )
|
895
895
|
grammar RuleLabel;
|
896
896
|
options {language=Ruby;output=AST;}
|
897
897
|
tokens {BLOCK;}
|
@@ -906,7 +906,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
906
906
|
|
907
907
|
|
908
908
|
example "ambiguous rule" do
|
909
|
-
result = parse(<<-'END', :a, 'abc 34')
|
909
|
+
result = parse( <<-'END', :a, 'abc 34' )
|
910
910
|
grammar AmbiguousRule;
|
911
911
|
options {language=Ruby;output=AST;}
|
912
912
|
a : ID a -> a | INT ;
|
@@ -920,7 +920,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
920
920
|
|
921
921
|
|
922
922
|
example "rule list label" do
|
923
|
-
result = parse(<<-'END', :a, 'a b')
|
923
|
+
result = parse( <<-'END', :a, 'a b' )
|
924
924
|
grammar RuleListLabel;
|
925
925
|
options {language=Ruby;output=AST;}
|
926
926
|
tokens {BLOCK;}
|
@@ -935,7 +935,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
935
935
|
|
936
936
|
|
937
937
|
example "rule list label2" do
|
938
|
-
result = parse(<<-'END', :a, 'a b')
|
938
|
+
result = parse( <<-'END', :a, 'a b' )
|
939
939
|
grammar RuleListLabel2;
|
940
940
|
options {language=Ruby;output=AST;}
|
941
941
|
tokens {BLOCK;}
|
@@ -950,7 +950,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
950
950
|
|
951
951
|
|
952
952
|
example "optional" do
|
953
|
-
result = parse(<<-'END', :a, 'a')
|
953
|
+
result = parse( <<-'END', :a, 'a' )
|
954
954
|
grammar Optional;
|
955
955
|
options {language=Ruby;output=AST;}
|
956
956
|
tokens {BLOCK;}
|
@@ -965,7 +965,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
965
965
|
|
966
966
|
|
967
967
|
example "optional2" do
|
968
|
-
result = parse(<<-'END', :a, 'a b')
|
968
|
+
result = parse( <<-'END', :a, 'a b' )
|
969
969
|
grammar Optional2;
|
970
970
|
options {language=Ruby;output=AST;}
|
971
971
|
tokens {BLOCK;}
|
@@ -980,7 +980,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
980
980
|
|
981
981
|
|
982
982
|
example "optional3" do
|
983
|
-
result = parse(<<-'END', :a, 'a b')
|
983
|
+
result = parse( <<-'END', :a, 'a b' )
|
984
984
|
grammar Optional3;
|
985
985
|
options {language=Ruby;output=AST;}
|
986
986
|
tokens {BLOCK;}
|
@@ -995,7 +995,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
995
995
|
|
996
996
|
|
997
997
|
example "optional4" do
|
998
|
-
result = parse(<<-'END', :a, 'a b')
|
998
|
+
result = parse( <<-'END', :a, 'a b' )
|
999
999
|
grammar Optional4;
|
1000
1000
|
options {language=Ruby;output=AST;}
|
1001
1001
|
tokens {BLOCK;}
|
@@ -1009,7 +1009,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1009
1009
|
|
1010
1010
|
|
1011
1011
|
example "optional5" do
|
1012
|
-
result = parse(<<-'END', :a, 'a')
|
1012
|
+
result = parse( <<-'END', :a, 'a' )
|
1013
1013
|
grammar Optional5;
|
1014
1014
|
options {language=Ruby;output=AST;}
|
1015
1015
|
tokens {BLOCK;}
|
@@ -1024,7 +1024,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1024
1024
|
|
1025
1025
|
|
1026
1026
|
example "arbitrary expr type" do
|
1027
|
-
result = parse(<<-'END', :a, 'a b')
|
1027
|
+
result = parse( <<-'END', :a, 'a b' )
|
1028
1028
|
grammar ArbitraryExprType;
|
1029
1029
|
options {language=Ruby;output=AST;}
|
1030
1030
|
tokens {BLOCK;}
|
@@ -1039,7 +1039,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1039
1039
|
|
1040
1040
|
|
1041
1041
|
example "set" do
|
1042
|
-
result = parse(<<-'END', :a, '2 a 34 de')
|
1042
|
+
result = parse( <<-'END', :a, '2 a 34 de' )
|
1043
1043
|
grammar SetT;
|
1044
1044
|
options {language=Ruby;output=AST;}
|
1045
1045
|
a: (INT|ID)+ -> INT+ ID+ ;
|
@@ -1053,7 +1053,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1053
1053
|
|
1054
1054
|
|
1055
1055
|
example "set2" do
|
1056
|
-
result = parse(<<-'END', :a, '2')
|
1056
|
+
result = parse( <<-'END', :a, '2' )
|
1057
1057
|
grammar Set2;
|
1058
1058
|
options {language=Ruby;output=AST;}
|
1059
1059
|
a: (INT|ID) -> INT? ID? ;
|
@@ -1067,7 +1067,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1067
1067
|
|
1068
1068
|
|
1069
1069
|
example "set with label" do
|
1070
|
-
warn('test SetWithLabel officially broken')
|
1070
|
+
warn( 'test SetWithLabel officially broken' )
|
1071
1071
|
#result = parse(<<-'END', :a, '2')
|
1072
1072
|
# grammar SetWithLabel;
|
1073
1073
|
# options {language=Ruby;output=AST;}
|
@@ -1082,7 +1082,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1082
1082
|
|
1083
1083
|
|
1084
1084
|
example "rewrite action" do
|
1085
|
-
result = parse(<<-'END', :r, '25')
|
1085
|
+
result = parse( <<-'END', :r, '25' )
|
1086
1086
|
grammar RewriteAction;
|
1087
1087
|
options {language=Ruby;output=AST;}
|
1088
1088
|
tokens { FLOAT; }
|
@@ -1098,7 +1098,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1098
1098
|
|
1099
1099
|
|
1100
1100
|
example "optional subrule without real elements" do
|
1101
|
-
result = parse(<<-'END', :modulo, 'modulo abc (x y #)')
|
1101
|
+
result = parse( <<-'END', :modulo, 'modulo abc (x y #)' )
|
1102
1102
|
grammar OptionalSubruleWithoutRealElements;
|
1103
1103
|
options {language=Ruby;output=AST;}
|
1104
1104
|
tokens {PARMS;}
|
@@ -1116,7 +1116,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1116
1116
|
|
1117
1117
|
|
1118
1118
|
example "wildcard" do
|
1119
|
-
result = parse(<<-'END', :a, 'abc 34')
|
1119
|
+
result = parse( <<-'END', :a, 'abc 34' )
|
1120
1120
|
grammar Wildcard;
|
1121
1121
|
options {language=Ruby;output=AST;}
|
1122
1122
|
a : ID c=. -> $c;
|
@@ -1130,7 +1130,7 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1130
1130
|
|
1131
1131
|
|
1132
1132
|
example "extra token in simple decl" do
|
1133
|
-
result, errors = parse(<<-'END', :decl, 'int 34 x=1;', true)
|
1133
|
+
result, errors = parse( <<-'END', :decl, 'int 34 x=1;', true )
|
1134
1134
|
grammar ExtraTokenInSimpleDecl;
|
1135
1135
|
options {language=Ruby;output=AST;}
|
1136
1136
|
tokens {EXPR;}
|
@@ -1141,13 +1141,13 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1141
1141
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
1142
1142
|
|
1143
1143
|
END
|
1144
|
-
errors.should == ['line 1:4 extraneous input "34" expecting ID']
|
1144
|
+
errors.should == [ 'line 1:4 extraneous input "34" expecting ID' ]
|
1145
1145
|
result.should == '(EXPR int x 1)'
|
1146
1146
|
end
|
1147
1147
|
|
1148
1148
|
|
1149
1149
|
example "missing id in simple decl" do
|
1150
|
-
result, errors = parse(<<-'END', :decl, 'int =1;', true)
|
1150
|
+
result, errors = parse( <<-'END', :decl, 'int =1;', true )
|
1151
1151
|
grammar MissingIDInSimpleDecl;
|
1152
1152
|
options {language=Ruby;output=AST;}
|
1153
1153
|
tokens {EXPR;}
|
@@ -1158,13 +1158,13 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1158
1158
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
1159
1159
|
|
1160
1160
|
END
|
1161
|
-
errors.should == ['line 1:4 missing ID at "="']
|
1161
|
+
errors.should == [ 'line 1:4 missing ID at "="' ]
|
1162
1162
|
result.should == '(EXPR int <missing ID> 1)'
|
1163
1163
|
end
|
1164
1164
|
|
1165
1165
|
|
1166
1166
|
example "missing set in simple decl" do
|
1167
|
-
result, errors = parse(<<-'END', :decl, 'x=1;', true)
|
1167
|
+
result, errors = parse( <<-'END', :decl, 'x=1;', true )
|
1168
1168
|
grammar MissingSetInSimpleDecl;
|
1169
1169
|
options {language=Ruby;output=AST;}
|
1170
1170
|
tokens {EXPR;}
|
@@ -1175,13 +1175,13 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1175
1175
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
1176
1176
|
|
1177
1177
|
END
|
1178
|
-
errors.should == ['line 1:0 mismatched input "x" expecting set nil']
|
1178
|
+
errors.should == [ 'line 1:0 mismatched input "x" expecting set nil' ]
|
1179
1179
|
result.should == '(EXPR <error: x> x 1)'
|
1180
1180
|
end
|
1181
1181
|
|
1182
1182
|
|
1183
1183
|
example "missing token gives error node" do
|
1184
|
-
result, errors = parse(<<-'END', :a, 'abc', true)
|
1184
|
+
result, errors = parse( <<-'END', :a, 'abc', true )
|
1185
1185
|
grammar MissingTokenGivesErrorNode;
|
1186
1186
|
options {language=Ruby;output=AST;}
|
1187
1187
|
a : ID INT -> ID INT ;
|
@@ -1190,14 +1190,14 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1190
1190
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
1191
1191
|
|
1192
1192
|
END
|
1193
|
-
errors.should == ["line 0:-1 missing INT at \"<EOF>\""]
|
1193
|
+
errors.should == [ "line 0:-1 missing INT at \"<EOF>\"" ]
|
1194
1194
|
result.should == 'abc <missing INT>'
|
1195
1195
|
#end
|
1196
1196
|
end
|
1197
1197
|
|
1198
1198
|
|
1199
1199
|
example "extra token gives error node" do
|
1200
|
-
result, errors = parse(<<-'END', :a, 'abc ick 34', true)
|
1200
|
+
result, errors = parse( <<-'END', :a, 'abc ick 34', true )
|
1201
1201
|
grammar ExtraTokenGivesErrorNode;
|
1202
1202
|
options {language=Ruby;output=AST;}
|
1203
1203
|
a : b c -> b c;
|
@@ -1208,13 +1208,13 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1208
1208
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
1209
1209
|
|
1210
1210
|
END
|
1211
|
-
errors.should == ['line 1:4 extraneous input "ick" expecting INT']
|
1211
|
+
errors.should == [ 'line 1:4 extraneous input "ick" expecting INT' ]
|
1212
1212
|
result.should == 'abc 34'
|
1213
1213
|
end
|
1214
1214
|
|
1215
1215
|
|
1216
1216
|
example "missing first token gives error node" do
|
1217
|
-
result, errors = parse(<<-'END', :a, '34', true)
|
1217
|
+
result, errors = parse( <<-'END', :a, '34', true )
|
1218
1218
|
grammar MissingFirstTokenGivesErrorNode;
|
1219
1219
|
options {language=Ruby;output=AST;}
|
1220
1220
|
a : ID INT -> ID INT ;
|
@@ -1223,13 +1223,13 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1223
1223
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
1224
1224
|
|
1225
1225
|
END
|
1226
|
-
errors.should == ['line 1:0 missing ID at "34"']
|
1226
|
+
errors.should == [ 'line 1:0 missing ID at "34"' ]
|
1227
1227
|
result.should == '<missing ID> 34'
|
1228
1228
|
end
|
1229
1229
|
|
1230
1230
|
|
1231
1231
|
example "missing first token gives error node2" do
|
1232
|
-
result, errors = parse(<<-'END', :a, '34', true)
|
1232
|
+
result, errors = parse( <<-'END', :a, '34', true )
|
1233
1233
|
grammar MissingFirstTokenGivesErrorNode2;
|
1234
1234
|
options {language=Ruby;output=AST;}
|
1235
1235
|
a : b c -> b c;
|
@@ -1240,13 +1240,13 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1240
1240
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
1241
1241
|
|
1242
1242
|
END
|
1243
|
-
errors.should == ['line 1:0 missing ID at "34"']
|
1243
|
+
errors.should == [ 'line 1:0 missing ID at "34"' ]
|
1244
1244
|
result.should == '<missing ID> 34'
|
1245
1245
|
end
|
1246
1246
|
|
1247
1247
|
|
1248
1248
|
example "no viable alt gives error node" do
|
1249
|
-
result, errors = parse(<<-'END', :a, '*', true)
|
1249
|
+
result, errors = parse( <<-'END', :a, '*', true )
|
1250
1250
|
grammar NoViableAltGivesErrorNode;
|
1251
1251
|
options {language=Ruby;output=AST;}
|
1252
1252
|
a : b -> b | c -> c;
|
@@ -1258,14 +1258,14 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1258
1258
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
1259
1259
|
|
1260
1260
|
END
|
1261
|
-
errors.should == ['line 1:0 no viable alternative at input "*"']
|
1261
|
+
errors.should == [ 'line 1:0 no viable alternative at input "*"' ]
|
1262
1262
|
result.should == '<unexpected: 0 S["*"] @ line 1 col 0 (0..0), resync = *>'
|
1263
1263
|
end
|
1264
1264
|
|
1265
1265
|
|
1266
1266
|
example "cardinality" do
|
1267
1267
|
lambda do
|
1268
|
-
parse(<<-'END', :a, "a b 3 4 5")
|
1268
|
+
parse( <<-'END', :a, "a b 3 4 5" )
|
1269
1269
|
grammar Cardinality;
|
1270
1270
|
options {language=Ruby;output=AST;}
|
1271
1271
|
tokens {BLOCK;}
|
@@ -1274,12 +1274,12 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1274
1274
|
INT : '0'..'9'+;
|
1275
1275
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
1276
1276
|
END
|
1277
|
-
end.should raise_error(ANTLR3::Error::RewriteCardinalityError)
|
1277
|
+
end.should raise_error( ANTLR3::Error::RewriteCardinalityError )
|
1278
1278
|
end
|
1279
1279
|
|
1280
1280
|
example "cardinality2" do
|
1281
1281
|
lambda do
|
1282
|
-
parse(<<-'END', :a, "a b")
|
1282
|
+
parse( <<-'END', :a, "a b" )
|
1283
1283
|
grammar Cardinality2;
|
1284
1284
|
options {language=Ruby;output=AST;}
|
1285
1285
|
tokens {BLOCK;}
|
@@ -1289,12 +1289,12 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1289
1289
|
INT : '0'..'9'+;
|
1290
1290
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
1291
1291
|
END
|
1292
|
-
end.should raise_error(ANTLR3::Error::RewriteCardinalityError)
|
1292
|
+
end.should raise_error( ANTLR3::Error::RewriteCardinalityError )
|
1293
1293
|
end
|
1294
1294
|
|
1295
1295
|
example "cardinality3" do
|
1296
1296
|
lambda do
|
1297
|
-
parse(<<-'END', :a, "3")
|
1297
|
+
parse( <<-'END', :a, "3" )
|
1298
1298
|
grammar Cardinality3;
|
1299
1299
|
options {language=Ruby;output=AST;}
|
1300
1300
|
tokens {BLOCK;}
|
@@ -1304,12 +1304,12 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1304
1304
|
INT : '0'..'9'+;
|
1305
1305
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
1306
1306
|
END
|
1307
|
-
end.should raise_error(ANTLR3::Error::RewriteEmptyStream)
|
1307
|
+
end.should raise_error( ANTLR3::Error::RewriteEmptyStream )
|
1308
1308
|
end
|
1309
1309
|
|
1310
1310
|
example "loop cardinality" do
|
1311
1311
|
lambda do
|
1312
|
-
parse(<<-'END', :a, "3")
|
1312
|
+
parse( <<-'END', :a, "3" )
|
1313
1313
|
grammar LoopCardinality;
|
1314
1314
|
options {language=Ruby;output=AST;}
|
1315
1315
|
a : ID? INT -> ID+ INT ;
|
@@ -1318,10 +1318,9 @@ class TestASTViaRewriteRules < ANTLR3::Test::Functional
|
|
1318
1318
|
INT : '0'..'9'+;
|
1319
1319
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
1320
1320
|
END
|
1321
|
-
end.should raise_error(ANTLR3::Error::RewriteEarlyExit)
|
1321
|
+
end.should raise_error( ANTLR3::Error::RewriteEarlyExit )
|
1322
1322
|
end
|
1323
1323
|
|
1324
1324
|
|
1325
1325
|
|
1326
1326
|
end
|
1327
|
-
|