antlr3 1.7.5 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,7 +5,7 @@ require 'antlr3/test/functional'
|
|
5
5
|
|
6
6
|
class TestRewritingWhileParsing < ANTLR3::Test::Functional
|
7
7
|
|
8
|
-
inline_grammar(<<-'END')
|
8
|
+
inline_grammar( <<-'END' )
|
9
9
|
grammar TokenRewrites;
|
10
10
|
options { language = Ruby; }
|
11
11
|
|
@@ -60,7 +60,7 @@ class TestRewritingWhileParsing < ANTLR3::Test::Functional
|
|
60
60
|
END
|
61
61
|
|
62
62
|
example 'using a TokenRewriteStream to rewrite input text while parsing' do
|
63
|
-
input = <<-END.fixed_indent(0)
|
63
|
+
input = <<-END.fixed_indent( 0 )
|
64
64
|
method foo() {
|
65
65
|
i = 3;
|
66
66
|
k = i;
|
@@ -71,7 +71,7 @@ class TestRewritingWhileParsing < ANTLR3::Test::Functional
|
|
71
71
|
j = i*2;
|
72
72
|
}
|
73
73
|
END
|
74
|
-
expected_output = <<-END.fixed_indent(0).strip!
|
74
|
+
expected_output = <<-END.fixed_indent( 0 ).strip!
|
75
75
|
public class Wrapper {
|
76
76
|
public void foo() {
|
77
77
|
int k;
|
@@ -97,4 +97,3 @@ class TestRewritingWhileParsing < ANTLR3::Test::Functional
|
|
97
97
|
end
|
98
98
|
|
99
99
|
end
|
100
|
-
|
@@ -6,7 +6,7 @@ require 'antlr3/test/functional'
|
|
6
6
|
class TestTreeParser1 < ANTLR3::Test::Functional
|
7
7
|
|
8
8
|
example "flat list" do
|
9
|
-
compile_and_load inline_grammar(<<-'END')
|
9
|
+
compile_and_load inline_grammar( <<-'END' )
|
10
10
|
grammar FlatList;
|
11
11
|
options {
|
12
12
|
language=Ruby;
|
@@ -17,7 +17,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
17
17
|
INT : '0'..'9'+;
|
18
18
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
19
19
|
END
|
20
|
-
compile_and_load inline_grammar(<<-'END')
|
20
|
+
compile_and_load inline_grammar( <<-'END' )
|
21
21
|
tree grammar FlatListWalker;
|
22
22
|
options {
|
23
23
|
language=Ruby;
|
@@ -42,7 +42,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
42
42
|
end
|
43
43
|
|
44
44
|
example "simple tree" do
|
45
|
-
compile_and_load inline_grammar(<<-'END')
|
45
|
+
compile_and_load inline_grammar( <<-'END' )
|
46
46
|
grammar SimpleTree;
|
47
47
|
options {
|
48
48
|
language=Ruby;
|
@@ -53,7 +53,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
53
53
|
INT : '0'..'9'+;
|
54
54
|
WS : (' '|'\\n') {$channel=HIDDEN;} ;
|
55
55
|
END
|
56
|
-
compile_and_load inline_grammar(<<-'END')
|
56
|
+
compile_and_load inline_grammar( <<-'END' )
|
57
57
|
tree grammar SimpleTreeWalker;
|
58
58
|
options {
|
59
59
|
language=Ruby;
|
@@ -78,7 +78,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
78
78
|
end
|
79
79
|
|
80
80
|
example "flat vs tree decision" do
|
81
|
-
compile_and_load inline_grammar(<<-'END')
|
81
|
+
compile_and_load inline_grammar( <<-'END' )
|
82
82
|
grammar FlatVsTreeDecision;
|
83
83
|
options {
|
84
84
|
language=Ruby;
|
@@ -91,7 +91,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
91
91
|
INT : '0'..'9'+;
|
92
92
|
WS : (' '|'\\n') {$channel=HIDDEN;} ;
|
93
93
|
END
|
94
|
-
compile_and_load inline_grammar(<<-'END')
|
94
|
+
compile_and_load inline_grammar( <<-'END' )
|
95
95
|
tree grammar FlatVsTreeDecisionWalker;
|
96
96
|
options {
|
97
97
|
language=Ruby;
|
@@ -117,7 +117,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
117
117
|
end
|
118
118
|
|
119
119
|
example "flat vs tree decision2" do
|
120
|
-
compile_and_load inline_grammar(<<-'END')
|
120
|
+
compile_and_load inline_grammar( <<-'END' )
|
121
121
|
grammar FlatVsTreeDecision2;
|
122
122
|
options {
|
123
123
|
language=Ruby;
|
@@ -130,7 +130,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
130
130
|
INT : '0'..'9'+;
|
131
131
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
132
132
|
END
|
133
|
-
compile_and_load inline_grammar(<<-'END')
|
133
|
+
compile_and_load inline_grammar( <<-'END' )
|
134
134
|
tree grammar FlatVsTreeDecision2Walker;
|
135
135
|
options {
|
136
136
|
language=Ruby;
|
@@ -155,7 +155,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
155
155
|
end
|
156
156
|
|
157
157
|
example "cyclic dfa lookahead" do
|
158
|
-
compile_and_load inline_grammar(<<-'END')
|
158
|
+
compile_and_load inline_grammar( <<-'END' )
|
159
159
|
grammar CyclicDFALookahead;
|
160
160
|
options {
|
161
161
|
language=Ruby;
|
@@ -168,7 +168,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
168
168
|
PERIOD : '.' ;
|
169
169
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
170
170
|
END
|
171
|
-
compile_and_load inline_grammar(<<-'END')
|
171
|
+
compile_and_load inline_grammar( <<-'END' )
|
172
172
|
tree grammar CyclicDFALookaheadWalker;
|
173
173
|
options {
|
174
174
|
language=Ruby;
|
@@ -192,7 +192,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
192
192
|
end
|
193
193
|
|
194
194
|
example "nullable child list" do
|
195
|
-
compile_and_load inline_grammar(<<-'END')
|
195
|
+
compile_and_load inline_grammar( <<-'END' )
|
196
196
|
grammar NullableChildList;
|
197
197
|
options {
|
198
198
|
language=Ruby;
|
@@ -203,7 +203,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
203
203
|
INT : '0'..'9'+;
|
204
204
|
WS : (' '|'\\n') {$channel=HIDDEN;} ;
|
205
205
|
END
|
206
|
-
compile_and_load inline_grammar(<<-'END')
|
206
|
+
compile_and_load inline_grammar( <<-'END' )
|
207
207
|
tree grammar NullableChildListWalker;
|
208
208
|
options {
|
209
209
|
language=Ruby;
|
@@ -227,7 +227,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
227
227
|
end
|
228
228
|
|
229
229
|
example "nullable child list2" do
|
230
|
-
compile_and_load inline_grammar(<<-'END')
|
230
|
+
compile_and_load inline_grammar( <<-'END' )
|
231
231
|
grammar NullableChildList2;
|
232
232
|
options {
|
233
233
|
language=Ruby;
|
@@ -239,7 +239,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
239
239
|
SEMI : ';' ;
|
240
240
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
241
241
|
END
|
242
|
-
compile_and_load inline_grammar(<<-'END')
|
242
|
+
compile_and_load inline_grammar( <<-'END' )
|
243
243
|
tree grammar NullableChildList2Walker;
|
244
244
|
options {
|
245
245
|
language=Ruby;
|
@@ -263,7 +263,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
263
263
|
end
|
264
264
|
|
265
265
|
example "nullable child list3" do
|
266
|
-
compile_and_load inline_grammar(<<-'END')
|
266
|
+
compile_and_load inline_grammar( <<-'END' )
|
267
267
|
grammar NullableChildList3;
|
268
268
|
options {
|
269
269
|
language=Ruby;
|
@@ -275,7 +275,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
275
275
|
SEMI : ';' ;
|
276
276
|
WS : (' '|'\\n') {$channel=HIDDEN;} ;
|
277
277
|
END
|
278
|
-
compile_and_load inline_grammar(<<-'END')
|
278
|
+
compile_and_load inline_grammar( <<-'END' )
|
279
279
|
tree grammar NullableChildList3Walker;
|
280
280
|
options {
|
281
281
|
language=Ruby;
|
@@ -300,7 +300,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
300
300
|
end
|
301
301
|
|
302
302
|
example "actions after root" do
|
303
|
-
compile_and_load inline_grammar(<<-'END')
|
303
|
+
compile_and_load inline_grammar( <<-'END' )
|
304
304
|
grammar ActionsAfterRoot;
|
305
305
|
options {
|
306
306
|
language=Ruby;
|
@@ -312,7 +312,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
312
312
|
SEMI : ';' ;
|
313
313
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
314
314
|
END
|
315
|
-
compile_and_load inline_grammar(<<-'END')
|
315
|
+
compile_and_load inline_grammar( <<-'END' )
|
316
316
|
tree grammar ActionsAfterRootWalker;
|
317
317
|
options {
|
318
318
|
language=Ruby;
|
@@ -336,7 +336,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
336
336
|
end
|
337
337
|
|
338
338
|
example "wildcard lookahead" do
|
339
|
-
compile_and_load inline_grammar(<<-'END')
|
339
|
+
compile_and_load inline_grammar( <<-'END' )
|
340
340
|
grammar WildcardLookahead;
|
341
341
|
options {language=Ruby; output=AST;}
|
342
342
|
a : ID '+'^ INT;
|
@@ -346,7 +346,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
346
346
|
PERIOD : '.' ;
|
347
347
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
348
348
|
END
|
349
|
-
compile_and_load inline_grammar(<<-'END')
|
349
|
+
compile_and_load inline_grammar( <<-'END' )
|
350
350
|
tree grammar WildcardLookaheadWalker;
|
351
351
|
options {language=Ruby; tokenVocab=WildcardLookahead; ASTLabelType=CommonTree;}
|
352
352
|
@members { include ANTLR3::Test::CaptureOutput }
|
@@ -366,7 +366,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
366
366
|
end
|
367
367
|
|
368
368
|
example "wildcard lookahead2" do
|
369
|
-
compile_and_load inline_grammar(<<-'END')
|
369
|
+
compile_and_load inline_grammar( <<-'END' )
|
370
370
|
grammar WildcardLookahead2;
|
371
371
|
options {language=Ruby; output=AST;}
|
372
372
|
a : ID '+'^ INT;
|
@@ -376,7 +376,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
376
376
|
PERIOD : '.' ;
|
377
377
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
378
378
|
END
|
379
|
-
compile_and_load inline_grammar(<<-'END')
|
379
|
+
compile_and_load inline_grammar( <<-'END' )
|
380
380
|
tree grammar WildcardLookahead2Walker;
|
381
381
|
options {language=Ruby; tokenVocab=WildcardLookahead2; ASTLabelType=CommonTree;}
|
382
382
|
@members { include ANTLR3::Test::CaptureOutput }
|
@@ -397,7 +397,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
397
397
|
end
|
398
398
|
|
399
399
|
example "wildcard lookahead3" do
|
400
|
-
compile_and_load inline_grammar(<<-'END')
|
400
|
+
compile_and_load inline_grammar( <<-'END' )
|
401
401
|
grammar WildcardLookahead3;
|
402
402
|
options {language=Ruby; output=AST;}
|
403
403
|
a : ID '+'^ INT;
|
@@ -407,7 +407,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
407
407
|
PERIOD : '.' ;
|
408
408
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
409
409
|
END
|
410
|
-
compile_and_load inline_grammar(<<-'END')
|
410
|
+
compile_and_load inline_grammar( <<-'END' )
|
411
411
|
tree grammar WildcardLookahead3Walker;
|
412
412
|
options {language=Ruby; tokenVocab=WildcardLookahead3; ASTLabelType=CommonTree;}
|
413
413
|
@members { include ANTLR3::Test::CaptureOutput }
|
@@ -428,7 +428,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
428
428
|
end
|
429
429
|
|
430
430
|
example "wildcard plus lookahead" do
|
431
|
-
compile_and_load inline_grammar(<<-'END')
|
431
|
+
compile_and_load inline_grammar( <<-'END' )
|
432
432
|
grammar WildcardPlusLookahead;
|
433
433
|
options {language=Ruby; output=AST;}
|
434
434
|
a : ID '+'^ INT;
|
@@ -438,7 +438,7 @@ class TestTreeParser1 < ANTLR3::Test::Functional
|
|
438
438
|
PERIOD : '.' ;
|
439
439
|
WS : (' '|'\n') {$channel=HIDDEN;} ;
|
440
440
|
END
|
441
|
-
compile_and_load inline_grammar(<<-'END')
|
441
|
+
compile_and_load inline_grammar( <<-'END' )
|
442
442
|
tree grammar WildcardPlusLookaheadWalker;
|
443
443
|
options {language=Ruby; tokenVocab=WildcardPlusLookahead; ASTLabelType=CommonTree;}
|
444
444
|
@members { include ANTLR3::Test::CaptureOutput }
|
@@ -462,7 +462,7 @@ end
|
|
462
462
|
|
463
463
|
|
464
464
|
class TestTreeParser2 < ANTLR3::Test::Functional
|
465
|
-
inline_grammar(<<-'END')
|
465
|
+
inline_grammar( <<-'END' )
|
466
466
|
grammar GenericLanguage;
|
467
467
|
options {
|
468
468
|
language = Ruby;
|
@@ -578,7 +578,7 @@ class TestTreeParser2 < ANTLR3::Test::Functional
|
|
578
578
|
;
|
579
579
|
END
|
580
580
|
|
581
|
-
inline_grammar(<<-'END')
|
581
|
+
inline_grammar( <<-'END' )
|
582
582
|
tree grammar GenericLanguageWalker;
|
583
583
|
options {
|
584
584
|
language = Ruby;
|
@@ -664,7 +664,7 @@ class TestTreeParser2 < ANTLR3::Test::Functional
|
|
664
664
|
compile_options :trace => true
|
665
665
|
|
666
666
|
example "processing AST output from a parser with a tree parser" do
|
667
|
-
input_source = <<-END.fixed_indent(0)
|
667
|
+
input_source = <<-END.fixed_indent( 0 )
|
668
668
|
char c;
|
669
669
|
int x;
|
670
670
|
|
@@ -682,7 +682,7 @@ class TestTreeParser2 < ANTLR3::Test::Functional
|
|
682
682
|
lexer = GenericLanguage::Lexer.new( input_source )
|
683
683
|
parser = GenericLanguage::Parser.new( lexer )
|
684
684
|
|
685
|
-
expected_tree = <<-END.strip!.gsub!(/\s+/, ' ')
|
685
|
+
expected_tree = <<-END.strip!.gsub!( /\s+/, ' ' )
|
686
686
|
(VAR_DEF char c)
|
687
687
|
(VAR_DEF int x)
|
688
688
|
(FUNC_DECL (FUNC_HDR void bar (ARG_DEF int x)))
|
@@ -747,4 +747,3 @@ class TestTreeParser2 < ANTLR3::Test::Functional
|
|
747
747
|
end
|
748
748
|
|
749
749
|
end
|
750
|
-
|
data/test/unit/test-streams.rb
CHANGED
@@ -79,23 +79,23 @@ class TestStringStream < Test::Unit::TestCase
|
|
79
79
|
@stream.index.should == 0
|
80
80
|
@stream.line.should == 1
|
81
81
|
@stream.column.should == 0
|
82
|
-
@stream.peek(1).should == ?o
|
82
|
+
@stream.peek(1).should == ?o.ord
|
83
83
|
end
|
84
84
|
|
85
85
|
def test_look
|
86
86
|
@stream.look(1).should == 'o'
|
87
87
|
@stream.look(2).should == 'h'
|
88
88
|
@stream.look(3).should == "\n"
|
89
|
-
@stream.peek(1).should == ?o
|
90
|
-
@stream.peek(2).should == ?h
|
91
|
-
@stream.peek(3).should == ?\n
|
89
|
+
@stream.peek(1).should == ?o.ord
|
90
|
+
@stream.peek(2).should == ?h.ord
|
91
|
+
@stream.peek(3).should == ?\n.ord
|
92
92
|
|
93
93
|
6.times { @stream.consume }
|
94
94
|
@stream.look(1).should == '!'
|
95
95
|
@stream.look(2).should == "\n"
|
96
96
|
@stream.look(3).should be_nil
|
97
|
-
@stream.peek(1).should ==
|
98
|
-
@stream.peek(2).should == ?\n
|
97
|
+
@stream.peek(1).should == ?!.ord
|
98
|
+
@stream.peek(2).should == ?\n.ord
|
99
99
|
@stream.peek(3).should == EOF
|
100
100
|
end
|
101
101
|
|
@@ -111,7 +111,7 @@ class TestStringStream < Test::Unit::TestCase
|
|
111
111
|
@stream.index.should == 3
|
112
112
|
@stream.line.should == 2
|
113
113
|
@stream.column.should == 0
|
114
|
-
@stream.peek(1).should == ?h
|
114
|
+
@stream.peek(1).should == ?h.ord
|
115
115
|
end
|
116
116
|
|
117
117
|
def test_mark
|
@@ -165,7 +165,7 @@ class TestStringStream < Test::Unit::TestCase
|
|
165
165
|
@stream.index.should == 4
|
166
166
|
@stream.line.should == 2
|
167
167
|
@stream.column.should == 1
|
168
|
-
@stream.peek(1).should == ?e
|
168
|
+
@stream.peek(1).should == ?e.ord
|
169
169
|
|
170
170
|
end
|
171
171
|
|
@@ -194,7 +194,7 @@ class TestStringStream < Test::Unit::TestCase
|
|
194
194
|
@stream.index().should == 5
|
195
195
|
@stream.line.should == 2
|
196
196
|
@stream.column.should == 2
|
197
|
-
@stream.peek(1).should == ?y
|
197
|
+
@stream.peek(1).should == ?y.ord
|
198
198
|
end
|
199
199
|
end
|
200
200
|
|
@@ -221,7 +221,7 @@ class TestFileStream < Test::Unit::TestCase
|
|
221
221
|
@stream.column.should == 1
|
222
222
|
@stream.mark_depth.should == 2
|
223
223
|
@stream.look(1).should == 'a'
|
224
|
-
@stream.peek(1).should == ?a
|
224
|
+
@stream.peek(1).should == ?a.ord
|
225
225
|
end
|
226
226
|
|
227
227
|
def test_encoded
|
data/test/unit/test-template.rb
CHANGED
@@ -206,6 +206,7 @@ describe Template::Group, "dynamic template definition" do
|
|
206
206
|
end
|
207
207
|
|
208
208
|
describe Template::Group, "loading a template definition file" do
|
209
|
+
|
209
210
|
before :each do
|
210
211
|
@group = Template::Group.load( SAMPLE_GROUP_FILE )
|
211
212
|
end
|
@@ -246,5 +247,4 @@ describe Template::Group, "loading a template definition file" do
|
|
246
247
|
| end
|
247
248
|
END
|
248
249
|
end
|
249
|
-
|
250
250
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: antlr3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Yetter
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-07-04 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|