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 TestFilterMode < ANTLR3::Test::Functional
|
7
7
|
|
8
|
-
inline_grammar(<<-'END')
|
8
|
+
inline_grammar( <<-'END' )
|
9
9
|
lexer grammar Filter;
|
10
10
|
options {
|
11
11
|
language = Ruby;
|
@@ -71,7 +71,7 @@ class TestFilterMode < ANTLR3::Test::Functional
|
|
71
71
|
END
|
72
72
|
|
73
73
|
example "skipping tokens that aren't important with filter mode" do
|
74
|
-
input = <<-END.fixed_indent(0)
|
74
|
+
input = <<-END.fixed_indent( 0 )
|
75
75
|
import org.antlr.runtime.*;
|
76
76
|
|
77
77
|
public class Main {
|
@@ -97,7 +97,7 @@ end
|
|
97
97
|
|
98
98
|
class TestFuzzy < ANTLR3::Test::Functional
|
99
99
|
|
100
|
-
inline_grammar(<<-'END')
|
100
|
+
inline_grammar( <<-'END' )
|
101
101
|
lexer grammar Fuzzy;
|
102
102
|
options {
|
103
103
|
language = Ruby;
|
@@ -205,7 +205,7 @@ class TestFuzzy < ANTLR3::Test::Functional
|
|
205
205
|
END
|
206
206
|
|
207
207
|
example "fuzzy lexing with the filter mode option" do
|
208
|
-
input = <<-END.fixed_indent(0)
|
208
|
+
input = <<-END.fixed_indent( 0 )
|
209
209
|
import org.antlr.runtime.*;
|
210
210
|
|
211
211
|
public class Main {
|
@@ -221,7 +221,7 @@ class TestFuzzy < ANTLR3::Test::Functional
|
|
221
221
|
}
|
222
222
|
END
|
223
223
|
|
224
|
-
expected_output = <<-END.fixed_indent(0)
|
224
|
+
expected_output = <<-END.fixed_indent( 0 )
|
225
225
|
found class Main
|
226
226
|
found method main
|
227
227
|
found var i
|
@@ -235,11 +235,10 @@ class TestFuzzy < ANTLR3::Test::Functional
|
|
235
235
|
found // comment //System.out.println(tokens);
|
236
236
|
END
|
237
237
|
|
238
|
-
lexer = Fuzzy::Lexer.new(input)
|
238
|
+
lexer = Fuzzy::Lexer.new( input )
|
239
239
|
lexer.each { |tk| tk }
|
240
240
|
lexer.output.should == expected_output
|
241
241
|
end
|
242
242
|
|
243
243
|
|
244
244
|
end
|
245
|
-
|
@@ -4,7 +4,7 @@
|
|
4
4
|
require 'antlr3/test/functional'
|
5
5
|
|
6
6
|
class TestBug80 < ANTLR3::Test::Functional
|
7
|
-
inline_grammar(<<-'END')
|
7
|
+
inline_grammar( <<-'END' )
|
8
8
|
lexer grammar Bug80;
|
9
9
|
options { language = Ruby; }
|
10
10
|
|
@@ -28,7 +28,7 @@ end
|
|
28
28
|
|
29
29
|
class TestEOF < ANTLR3::Test::Functional
|
30
30
|
|
31
|
-
inline_grammar(<<-'END')
|
31
|
+
inline_grammar( <<-'END' )
|
32
32
|
lexer grammar EndOfFile;
|
33
33
|
|
34
34
|
options {
|
@@ -44,4 +44,3 @@ class TestEOF < ANTLR3::Test::Functional
|
|
44
44
|
tks = lexer.map { |tk| tk }
|
45
45
|
end
|
46
46
|
end
|
47
|
-
|
@@ -5,7 +5,7 @@ require 'antlr3/test/functional'
|
|
5
5
|
|
6
6
|
class TestLexerRuleReference < ANTLR3::Test::Functional
|
7
7
|
|
8
|
-
inline_grammar(<<-'END')
|
8
|
+
inline_grammar( <<-'END' )
|
9
9
|
lexer grammar RuleProperty;
|
10
10
|
options {
|
11
11
|
language = Ruby;
|
@@ -31,8 +31,8 @@ class TestLexerRuleReference < ANTLR3::Test::Functional
|
|
31
31
|
lexer = RuleProperty::Lexer.new( "foobar _ab98 \n A12sdf" )
|
32
32
|
tokens = lexer.map { |tk| tk }
|
33
33
|
|
34
|
-
lexer.properties.should have(3).things
|
35
|
-
text, type, line, pos, index, channel, start, stop = lexer.properties[0]
|
34
|
+
lexer.properties.should have( 3 ).things
|
35
|
+
text, type, line, pos, index, channel, start, stop = lexer.properties[ 0 ]
|
36
36
|
text.should == 'foobar'
|
37
37
|
type.should == RuleProperty::TokenData::IDENTIFIER
|
38
38
|
line.should == 1
|
@@ -42,7 +42,7 @@ class TestLexerRuleReference < ANTLR3::Test::Functional
|
|
42
42
|
start.should == 0
|
43
43
|
stop.should == 5
|
44
44
|
|
45
|
-
text, type, line, pos, index, channel, start, stop = lexer.properties[1]
|
45
|
+
text, type, line, pos, index, channel, start, stop = lexer.properties[ 1 ]
|
46
46
|
text.should == '_ab98'
|
47
47
|
type.should == RuleProperty::TokenData::IDENTIFIER
|
48
48
|
line.should == 1
|
@@ -52,8 +52,8 @@ class TestLexerRuleReference < ANTLR3::Test::Functional
|
|
52
52
|
start.should == 7
|
53
53
|
stop.should == 11
|
54
54
|
|
55
|
-
lexer.properties.should have(3).things
|
56
|
-
text, type, line, pos, index, channel, start, stop = lexer.properties[2]
|
55
|
+
lexer.properties.should have( 3 ).things
|
56
|
+
text, type, line, pos, index, channel, start, stop = lexer.properties[ 2 ]
|
57
57
|
text.should == 'A12sdf'
|
58
58
|
type.should == RuleProperty::TokenData::IDENTIFIER
|
59
59
|
line.should == 2
|
@@ -68,7 +68,7 @@ class TestLexerRuleReference < ANTLR3::Test::Functional
|
|
68
68
|
end
|
69
69
|
|
70
70
|
class TestLexerRuleLabel < ANTLR3::Test::Functional
|
71
|
-
inline_grammar(<<-'END')
|
71
|
+
inline_grammar( <<-'END' )
|
72
72
|
lexer grammar LexerRuleLabel;
|
73
73
|
options {
|
74
74
|
language = Ruby;
|
@@ -101,4 +101,3 @@ class TestLexerRuleLabel < ANTLR3::Test::Functional
|
|
101
101
|
end
|
102
102
|
|
103
103
|
end
|
104
|
-
|
@@ -4,7 +4,7 @@
|
|
4
4
|
require 'antlr3/test/functional'
|
5
5
|
|
6
6
|
class TestSyntacticPredicate < ANTLR3::Test::Functional
|
7
|
-
inline_grammar(<<-'END')
|
7
|
+
inline_grammar( <<-'END' )
|
8
8
|
lexer grammar SyntacticPredicateGate;
|
9
9
|
options {
|
10
10
|
language = Ruby;
|
@@ -29,4 +29,3 @@ class TestSyntacticPredicate < ANTLR3::Test::Functional
|
|
29
29
|
|
30
30
|
|
31
31
|
end
|
32
|
-
|
@@ -4,7 +4,7 @@
|
|
4
4
|
require 'antlr3/test/functional'
|
5
5
|
|
6
6
|
class XMLLexerTest < ANTLR3::Test::Functional
|
7
|
-
inline_grammar(<<-'END')
|
7
|
+
inline_grammar( <<-'END' )
|
8
8
|
lexer grammar XML;
|
9
9
|
options { language = Ruby; }
|
10
10
|
|
@@ -134,7 +134,7 @@ class XMLLexerTest < ANTLR3::Test::Functional
|
|
134
134
|
END
|
135
135
|
|
136
136
|
it "should be valid" do
|
137
|
-
lexer = XML::Lexer.new(<<-'END'.fixed_indent(0))
|
137
|
+
lexer = XML::Lexer.new( <<-'END'.fixed_indent( 0 ) )
|
138
138
|
<?xml version='1.0'?>
|
139
139
|
<!DOCTYPE component [
|
140
140
|
<!ELEMENT component (PCDATA|sub)*>
|
@@ -160,7 +160,7 @@ class XMLLexerTest < ANTLR3::Test::Functional
|
|
160
160
|
|
161
161
|
lexer.map { |tk| tk }
|
162
162
|
|
163
|
-
lexer.output.should == <<-'END'.fixed_indent(0)
|
163
|
+
lexer.output.should == <<-'END'.fixed_indent( 0 )
|
164
164
|
XML declaration
|
165
165
|
Attr: version = '1.0'
|
166
166
|
ROOTELEMENT: component
|
@@ -5,12 +5,12 @@ require 'antlr3'
|
|
5
5
|
require 'antlr3/test/functional'
|
6
6
|
|
7
7
|
ENV.delete( 'RUBYOPT' )
|
8
|
-
ENV['RUBYLIB'] = ANTLR3.library_path
|
8
|
+
ENV[ 'RUBYLIB' ] = ANTLR3.library_path
|
9
9
|
|
10
10
|
class TestMainUtility < ANTLR3::Test::Functional
|
11
11
|
|
12
12
|
example 'overriding the built-in script action using the @main named-action' do
|
13
|
-
grammar = inline_grammar(<<-'END')
|
13
|
+
grammar = inline_grammar( <<-'END' )
|
14
14
|
lexer grammar MainOverride;
|
15
15
|
options { language = Ruby; }
|
16
16
|
|
@@ -30,15 +30,15 @@ class TestMainUtility < ANTLR3::Test::Functional
|
|
30
30
|
# this assertion verifies that the main region is executed
|
31
31
|
# when the parser script is run directly
|
32
32
|
lexer_script = grammar.target_files.first
|
33
|
-
out = `ruby #{lexer_script} 2>&1`.chomp
|
33
|
+
out = `ruby #{ lexer_script } 2>&1`.chomp
|
34
34
|
out.should =~ /the main block ran/
|
35
35
|
end
|
36
36
|
|
37
37
|
example 'using Lexer.main() to run the built-in lexer utility script on a source file' do
|
38
|
-
input_path = local_path('input.txt')
|
39
|
-
open(input_path, 'w') { |f| f.write("yada yada") }
|
38
|
+
input_path = local_path( 'input.txt' )
|
39
|
+
open( input_path, 'w' ) { |f| f.write( "yada yada" ) }
|
40
40
|
|
41
|
-
compile_and_load inline_grammar(<<-'END')
|
41
|
+
compile_and_load inline_grammar( <<-'END' )
|
42
42
|
lexer grammar LexerMainWithSourceFile;
|
43
43
|
options { language = Ruby; }
|
44
44
|
|
@@ -48,21 +48,21 @@ class TestMainUtility < ANTLR3::Test::Functional
|
|
48
48
|
|
49
49
|
begin
|
50
50
|
output = StringIO.new
|
51
|
-
input = File.open(input_path)
|
52
|
-
LexerMainWithSourceFile::Lexer.main([], :input => input, :output => output)
|
51
|
+
input = File.open( input_path )
|
52
|
+
LexerMainWithSourceFile::Lexer.main( [], :input => input, :output => output )
|
53
53
|
|
54
|
-
out_lines = output.string.split(/\n/)
|
55
|
-
out_lines.should have(3).things
|
54
|
+
out_lines = output.string.split( /\n/ )
|
55
|
+
out_lines.should have( 3 ).things
|
56
56
|
ensure
|
57
|
-
File.delete(input_path)
|
57
|
+
File.delete( input_path )
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
example 'using Lexer.main to run the built-in lexer utility script on input from $stdin' do
|
62
|
-
input = StringIO.new("yada yada") # <- used to simulate $stdin
|
62
|
+
input = StringIO.new( "yada yada" ) # <- used to simulate $stdin
|
63
63
|
output = StringIO.new
|
64
64
|
|
65
|
-
compile_and_load inline_grammar(<<-'END')
|
65
|
+
compile_and_load inline_grammar( <<-'END' )
|
66
66
|
lexer grammar LexerMainFromStdIO;
|
67
67
|
options { language = Ruby; }
|
68
68
|
|
@@ -70,13 +70,13 @@ class TestMainUtility < ANTLR3::Test::Functional
|
|
70
70
|
WS: ' '+ { $channel = HIDDEN; };
|
71
71
|
END
|
72
72
|
|
73
|
-
LexerMainFromStdIO::Lexer.main([], :input => input, :output => output)
|
74
|
-
lines = output.string.split(/\n/)
|
75
|
-
lines.should have(3).things
|
73
|
+
LexerMainFromStdIO::Lexer.main( [], :input => input, :output => output )
|
74
|
+
lines = output.string.split( /\n/ )
|
75
|
+
lines.should have( 3 ).things
|
76
76
|
end
|
77
77
|
|
78
78
|
example 'using Parser.main to run the built-in parser script utility with a combo grammar' do
|
79
|
-
compile_and_load inline_grammar(<<-'END')
|
79
|
+
compile_and_load inline_grammar( <<-'END' )
|
80
80
|
grammar MainForCombined;
|
81
81
|
options { language = Ruby; }
|
82
82
|
r returns [res]: (ID)+ EOF { $res = $text; };
|
@@ -86,17 +86,17 @@ class TestMainUtility < ANTLR3::Test::Functional
|
|
86
86
|
END
|
87
87
|
|
88
88
|
output = StringIO.new
|
89
|
-
input = StringIO.new('yada yada')
|
89
|
+
input = StringIO.new( 'yada yada' )
|
90
90
|
|
91
|
-
MainForCombined::Parser.main(
|
91
|
+
MainForCombined::Parser.main(
|
92
92
|
%w(--rule r --lexer-name MainForCombined::Lexer),
|
93
|
-
:input => input, :output => output)
|
94
|
-
lines = output.string.split("\n")
|
95
|
-
lines.should have(4).things
|
93
|
+
:input => input, :output => output )
|
94
|
+
lines = output.string.split( "\n" )
|
95
|
+
lines.should have( 4 ).things
|
96
96
|
end
|
97
97
|
|
98
98
|
example 'using built-in main to inspect AST constructed by an AST-building parser' do
|
99
|
-
compile_and_load inline_grammar(<<-'END')
|
99
|
+
compile_and_load inline_grammar( <<-'END' )
|
100
100
|
grammar ASTParserMain;
|
101
101
|
options {
|
102
102
|
language = Ruby;
|
@@ -111,15 +111,15 @@ class TestMainUtility < ANTLR3::Test::Functional
|
|
111
111
|
|
112
112
|
output = StringIO.new
|
113
113
|
input = StringIO.new 'yada + yada'
|
114
|
-
ASTParserMain::Parser.main(
|
114
|
+
ASTParserMain::Parser.main(
|
115
115
|
%w(--rule r --lexer-name ASTParserMain::Lexer),
|
116
|
-
:input => input, :output => output)
|
116
|
+
:input => input, :output => output )
|
117
117
|
output = output.string.strip
|
118
118
|
output.should == "(+ yada yada)"
|
119
119
|
end
|
120
120
|
|
121
121
|
example "using a tree parser's built-in main" do
|
122
|
-
compile_and_load inline_grammar(<<-'END')
|
122
|
+
compile_and_load inline_grammar( <<-'END' )
|
123
123
|
grammar TreeMain;
|
124
124
|
options {
|
125
125
|
language = Ruby;
|
@@ -132,7 +132,7 @@ class TestMainUtility < ANTLR3::Test::Functional
|
|
132
132
|
OP: '+';
|
133
133
|
WS: ' '+ { $channel = HIDDEN; };
|
134
134
|
END
|
135
|
-
compile_and_load inline_grammar(<<-'END')
|
135
|
+
compile_and_load inline_grammar( <<-'END' )
|
136
136
|
tree grammar TreeMainWalker;
|
137
137
|
options {
|
138
138
|
language=Ruby;
|
@@ -147,16 +147,16 @@ class TestMainUtility < ANTLR3::Test::Functional
|
|
147
147
|
output = StringIO.new
|
148
148
|
input = StringIO.new 'a+b'
|
149
149
|
|
150
|
-
TreeMainWalker::TreeParser.main(
|
150
|
+
TreeMainWalker::TreeParser.main(
|
151
151
|
%w(--rule r --parser-name TreeMain::Parser
|
152
152
|
--parser-rule r --lexer-name TreeMain::Lexer),
|
153
|
-
:input => input, :output => output)
|
153
|
+
:input => input, :output => output )
|
154
154
|
output = output.string.strip
|
155
155
|
output.should == '"a + b"'
|
156
156
|
end
|
157
157
|
|
158
158
|
example "using a tree parser's built-in main to inspect AST rewrite output" do
|
159
|
-
compile_and_load inline_grammar(<<-'END')
|
159
|
+
compile_and_load inline_grammar( <<-'END' )
|
160
160
|
grammar TreeRewriteMain;
|
161
161
|
options {
|
162
162
|
language = Ruby;
|
@@ -169,7 +169,7 @@ class TestMainUtility < ANTLR3::Test::Functional
|
|
169
169
|
OP: '+';
|
170
170
|
WS: ' '+ { $channel = HIDDEN; };
|
171
171
|
END
|
172
|
-
compile_and_load inline_grammar(<<-'END')
|
172
|
+
compile_and_load inline_grammar( <<-'END' )
|
173
173
|
tree grammar TreeRewriteMainWalker;
|
174
174
|
options {
|
175
175
|
language=Ruby;
|
@@ -183,7 +183,7 @@ class TestMainUtility < ANTLR3::Test::Functional
|
|
183
183
|
|
184
184
|
output = StringIO.new
|
185
185
|
input = StringIO.new 'a+b'
|
186
|
-
TreeRewriteMainWalker::TreeParser.main(
|
186
|
+
TreeRewriteMainWalker::TreeParser.main(
|
187
187
|
%w(--rule r --parser-name TreeRewriteMain::Parser
|
188
188
|
--parser-rule r --lexer-name TreeRewriteMain::Lexer),
|
189
189
|
:input => input, :output => output
|
@@ -194,12 +194,12 @@ class TestMainUtility < ANTLR3::Test::Functional
|
|
194
194
|
end
|
195
195
|
|
196
196
|
example 'using built-in main with a delegating grammar' do
|
197
|
-
inline_grammar(<<-'END')
|
197
|
+
inline_grammar( <<-'END' )
|
198
198
|
parser grammar MainSlave;
|
199
199
|
options { language=Ruby; }
|
200
200
|
a : B;
|
201
201
|
END
|
202
|
-
master = inline_grammar(<<-'END')
|
202
|
+
master = inline_grammar( <<-'END' )
|
203
203
|
grammar MainMaster;
|
204
204
|
options { language=Ruby; }
|
205
205
|
import MainSlave;
|
@@ -209,15 +209,15 @@ class TestMainUtility < ANTLR3::Test::Functional
|
|
209
209
|
END
|
210
210
|
master.compile
|
211
211
|
for file in master.target_files
|
212
|
-
require(file)
|
212
|
+
require( file )
|
213
213
|
end
|
214
214
|
|
215
215
|
output = StringIO.new
|
216
216
|
input = StringIO.new 'b'
|
217
217
|
|
218
|
-
MainMaster::Parser.main(
|
218
|
+
MainMaster::Parser.main(
|
219
219
|
%w(--rule s --lexer-name MainMaster::Lexer),
|
220
|
-
:input => input, :output => output)
|
220
|
+
:input => input, :output => output )
|
221
221
|
output = output.string.strip
|
222
222
|
output.should == 'b'.inspect
|
223
223
|
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
require 'antlr3/test/functional'
|
5
5
|
|
6
6
|
class TestActions1 < ANTLR3::Test::Functional
|
7
|
-
inline_grammar(<<-'END')
|
7
|
+
inline_grammar( <<-'END' )
|
8
8
|
grammar ParserActions;
|
9
9
|
options { language = Ruby; }
|
10
10
|
|
@@ -48,7 +48,7 @@ end
|
|
48
48
|
|
49
49
|
class TestActions2 < ANTLR3::Test::Functional
|
50
50
|
|
51
|
-
inline_grammar(<<-'END')
|
51
|
+
inline_grammar( <<-'END' )
|
52
52
|
grammar AllKindsOfActions;
|
53
53
|
options { language = Ruby; }
|
54
54
|
|
@@ -92,13 +92,13 @@ class TestActions2 < ANTLR3::Test::Functional
|
|
92
92
|
parser = AllKindsOfActions::Parser.new lexer
|
93
93
|
parser.prog
|
94
94
|
|
95
|
-
parser.output.should == <<-END.fixed_indent(0)
|
95
|
+
parser.output.should == <<-END.fixed_indent( 0 )
|
96
96
|
init
|
97
97
|
after
|
98
98
|
finally
|
99
99
|
END
|
100
100
|
|
101
|
-
lexer.output.should == <<-END.fixed_indent(0)
|
101
|
+
lexer.output.should == <<-END.fixed_indent( 0 )
|
102
102
|
action
|
103
103
|
"foobar" 4 1 0 -1 :default 0 5
|
104
104
|
attribute
|
@@ -114,7 +114,7 @@ end
|
|
114
114
|
|
115
115
|
class TestFinally < ANTLR3::Test::Functional
|
116
116
|
|
117
|
-
inline_grammar(<<-'END')
|
117
|
+
inline_grammar( <<-'END' )
|
118
118
|
grammar Finally;
|
119
119
|
|
120
120
|
options {
|
@@ -148,7 +148,7 @@ end
|
|
148
148
|
|
149
149
|
class TestActionScopes < ANTLR3::Test::Functional
|
150
150
|
|
151
|
-
inline_grammar(<<-'END')
|
151
|
+
inline_grammar( <<-'END' )
|
152
152
|
grammar SpecialActionScopes;
|
153
153
|
options { language=Ruby; }
|
154
154
|
|
@@ -216,9 +216,9 @@ class TestActionScopes < ANTLR3::Test::Functional
|
|
216
216
|
END
|
217
217
|
|
218
218
|
example 'verifying action scope behavior' do
|
219
|
-
lexer = SpecialActionScopes::Lexer.new("10 20 30 40 50")
|
219
|
+
lexer = SpecialActionScopes::Lexer.new( "10 20 30 40 50" )
|
220
220
|
parser = SpecialActionScopes::Parser.new lexer
|
221
|
-
parser.nums.should == [10, 20, 30, 40, 50]
|
221
|
+
parser.nums.should == [ 10, 20, 30, 40, 50 ]
|
222
222
|
end
|
223
223
|
|
224
224
|
example 'special action scope locations' do
|
@@ -5,7 +5,7 @@ require 'antlr3/test/functional'
|
|
5
5
|
|
6
6
|
class TestBacktracking < ANTLR3::Test::Functional
|
7
7
|
|
8
|
-
inline_grammar(<<-'END')
|
8
|
+
inline_grammar( <<-'END' )
|
9
9
|
grammar Backtrack;
|
10
10
|
options {
|
11
11
|
language = Ruby;
|
@@ -241,4 +241,3 @@ class TestBacktracking < ANTLR3::Test::Functional
|
|
241
241
|
end
|
242
242
|
|
243
243
|
end
|
244
|
-
|
@@ -4,7 +4,7 @@
|
|
4
4
|
require 'antlr3/test/functional'
|
5
5
|
|
6
6
|
class TestParser001 < ANTLR3::Test::Functional
|
7
|
-
inline_grammar(<<-'END')
|
7
|
+
inline_grammar( <<-'END' )
|
8
8
|
grammar Identifiers;
|
9
9
|
options { language = Ruby; }
|
10
10
|
|
@@ -52,7 +52,7 @@ class TestParser001 < ANTLR3::Test::Functional
|
|
52
52
|
parser = Identifiers::Parser.new( lexer )
|
53
53
|
parser.document
|
54
54
|
|
55
|
-
parser.reported_errors.should have(1).thing
|
55
|
+
parser.reported_errors.should have( 1 ).thing
|
56
56
|
end
|
57
57
|
|
58
58
|
example 'automatic input wrapping' do
|
@@ -71,7 +71,7 @@ class TestParser001 < ANTLR3::Test::Functional
|
|
71
71
|
end
|
72
72
|
|
73
73
|
class TestParser002 < ANTLR3::Test::Functional
|
74
|
-
inline_grammar(<<-'END')
|
74
|
+
inline_grammar( <<-'END' )
|
75
75
|
grammar SimpleLanguage;
|
76
76
|
options {
|
77
77
|
language = Ruby;
|
@@ -119,7 +119,7 @@ class TestParser002 < ANTLR3::Test::Functional
|
|
119
119
|
parser.document
|
120
120
|
|
121
121
|
parser.reported_errors.should be_empty
|
122
|
-
parser.events.should == [
|
122
|
+
parser.events.should == [
|
123
123
|
%w(decl foobar),
|
124
124
|
%w(call gnarz),
|
125
125
|
%w(decl blupp),
|
@@ -133,7 +133,7 @@ class TestParser002 < ANTLR3::Test::Functional
|
|
133
133
|
|
134
134
|
parser.document
|
135
135
|
|
136
|
-
parser.reported_errors.should have(1).thing
|
136
|
+
parser.reported_errors.should have( 1 ).thing
|
137
137
|
parser.events.should be_empty
|
138
138
|
end
|
139
139
|
|
@@ -143,8 +143,8 @@ class TestParser002 < ANTLR3::Test::Functional
|
|
143
143
|
|
144
144
|
parser.document
|
145
145
|
|
146
|
-
parser.reported_errors.should have(1).thing
|
147
|
-
parser.events.should == [
|
146
|
+
parser.reported_errors.should have( 1 ).thing
|
147
|
+
parser.events.should == [
|
148
148
|
%w(call gnarz),
|
149
149
|
%w(call flupp)
|
150
150
|
]
|
@@ -153,7 +153,7 @@ class TestParser002 < ANTLR3::Test::Functional
|
|
153
153
|
end
|
154
154
|
|
155
155
|
class TestParser003 < ANTLR3::Test::Functional
|
156
|
-
inline_grammar(<<-'END')
|
156
|
+
inline_grammar( <<-'END' )
|
157
157
|
grammar MoreComplicated;
|
158
158
|
|
159
159
|
options { language = Ruby; }
|
@@ -269,14 +269,14 @@ class TestParser003 < ANTLR3::Test::Functional
|
|
269
269
|
lexer = MoreComplicated::Lexer.new "int foo() { 1+2 }"
|
270
270
|
parser = MoreComplicated::Parser.new lexer
|
271
271
|
parser.program
|
272
|
-
parser.reported_errors.should have(1).thing
|
272
|
+
parser.reported_errors.should have( 1 ).thing
|
273
273
|
end
|
274
274
|
|
275
275
|
example "two instances of badly formed input" do
|
276
276
|
lexer = MoreComplicated::Lexer.new "int foo() { 1+; 1+2 }"
|
277
277
|
parser = MoreComplicated::Parser.new lexer
|
278
278
|
parser.program
|
279
|
-
parser.reported_errors.should have(2).things
|
279
|
+
parser.reported_errors.should have( 2 ).things
|
280
280
|
end
|
281
281
|
|
282
282
|
end
|