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
@@ -6,7 +6,7 @@ require 'antlr3/test/functional'
|
|
6
6
|
class TestProfileMode < ANTLR3::Test::Functional
|
7
7
|
compile_options :profile => true
|
8
8
|
|
9
|
-
inline_grammar(<<-'END')
|
9
|
+
inline_grammar( <<-'END' )
|
10
10
|
grammar SimpleC;
|
11
11
|
|
12
12
|
options { language = Ruby; }
|
@@ -108,7 +108,7 @@ class TestProfileMode < ANTLR3::Test::Functional
|
|
108
108
|
END
|
109
109
|
|
110
110
|
example 'profile mode output' do
|
111
|
-
input = <<-END.fixed_indent(0)
|
111
|
+
input = <<-END.fixed_indent( 0 )
|
112
112
|
char c;
|
113
113
|
int x;
|
114
114
|
|
@@ -123,9 +123,9 @@ class TestProfileMode < ANTLR3::Test::Functional
|
|
123
123
|
}
|
124
124
|
END
|
125
125
|
|
126
|
-
lexer = SimpleC::Lexer.new(input)
|
127
|
-
tokens = ANTLR3::CommonTokenStream.new(lexer)
|
128
|
-
parser = SimpleC::Parser.new(tokens)
|
126
|
+
lexer = SimpleC::Lexer.new( input )
|
127
|
+
tokens = ANTLR3::CommonTokenStream.new( lexer )
|
128
|
+
parser = SimpleC::Parser.new( tokens )
|
129
129
|
parser.program
|
130
130
|
|
131
131
|
profile_data = parser.profile
|
@@ -162,4 +162,4 @@ class TestProfileMode < ANTLR3::Test::Functional
|
|
162
162
|
end
|
163
163
|
|
164
164
|
|
165
|
-
end
|
165
|
+
end
|
@@ -5,7 +5,7 @@ require 'antlr3/test/functional'
|
|
5
5
|
|
6
6
|
class TestRuleTracing < ANTLR3::Test::Functional
|
7
7
|
|
8
|
-
inline_grammar(<<-'END')
|
8
|
+
inline_grammar( <<-'END' )
|
9
9
|
grammar Traced;
|
10
10
|
options {
|
11
11
|
language = Ruby;
|
@@ -56,19 +56,18 @@ class TestRuleTracing < ANTLR3::Test::Functional
|
|
56
56
|
compile_options :trace => true
|
57
57
|
|
58
58
|
example "setting up rule tracing" do
|
59
|
-
lexer = Traced::Lexer.new('< 1 + 2 + 3 >')
|
59
|
+
lexer = Traced::Lexer.new( '< 1 + 2 + 3 >' )
|
60
60
|
parser = Traced::Parser.new lexer
|
61
61
|
parser.a
|
62
|
-
lexer.traces.should == [
|
62
|
+
lexer.traces.should == [
|
63
63
|
'>t__6!', '<t__6!', '>ws!', '<ws!', '>int!', '<int!', '>ws!', '<ws!',
|
64
64
|
'>t__8!', '<t__8!', '>ws!', '<ws!', '>int!', '<int!', '>ws!', '<ws!',
|
65
65
|
'>t__8!', '<t__8!', '>ws!', '<ws!', '>int!', '<int!', '>ws!', '<ws!',
|
66
66
|
'>t__7!', '<t__7!'
|
67
67
|
]
|
68
|
-
parser.traces.should == [
|
68
|
+
parser.traces.should == [
|
69
69
|
'>a', '>synpred1_Traced', '<synpred1_Traced',
|
70
70
|
'>b', '>c', '<c', '>c', '<c', '>c', '<c', '<b', '<a'
|
71
71
|
]
|
72
72
|
end
|
73
73
|
end
|
74
|
-
|
@@ -5,16 +5,16 @@ require 'antlr3/test/functional'
|
|
5
5
|
|
6
6
|
class TestImportedGrammars < ANTLR3::Test::Functional
|
7
7
|
|
8
|
-
def load(grammar)
|
8
|
+
def load( grammar )
|
9
9
|
grammar.compile
|
10
|
-
$:.unshift(grammar.output_directory) unless $:.include?(grammar.output_directory)
|
11
|
-
for file in grammar.target_files(false)
|
12
|
-
require File.basename(file, '.rb')
|
10
|
+
$:.unshift( grammar.output_directory ) unless $:.include?( grammar.output_directory )
|
11
|
+
for file in grammar.target_files( false )
|
12
|
+
require File.basename( file, '.rb' )
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
example 'delegator invokes delegate rule' do
|
17
|
-
inline_grammar(<<-'END')
|
17
|
+
inline_grammar( <<-'END' )
|
18
18
|
parser grammar DIDRSlave;
|
19
19
|
options { language=Ruby; }
|
20
20
|
@members {
|
@@ -24,7 +24,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
24
24
|
}
|
25
25
|
a : B { capture("S.a") } ;
|
26
26
|
END
|
27
|
-
load inline_grammar(<<-'END')
|
27
|
+
load inline_grammar( <<-'END' )
|
28
28
|
grammar DIDRMaster;
|
29
29
|
options { language=Ruby; }
|
30
30
|
import DIDRSlave;
|
@@ -44,7 +44,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
44
44
|
end
|
45
45
|
|
46
46
|
example 'delegator invokes delegate rule with args' do
|
47
|
-
inline_grammar(<<-'END')
|
47
|
+
inline_grammar( <<-'END' )
|
48
48
|
parser grammar Slave2;
|
49
49
|
options {
|
50
50
|
language=Ruby;
|
@@ -56,7 +56,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
56
56
|
}
|
57
57
|
a[x] returns [y] : B {capture("S.a"); $y="1000";} ;
|
58
58
|
END
|
59
|
-
load inline_grammar(<<-'END')
|
59
|
+
load inline_grammar( <<-'END' )
|
60
60
|
grammar Master2;
|
61
61
|
options {language=Ruby;}
|
62
62
|
import Slave2;
|
@@ -75,7 +75,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
75
75
|
end
|
76
76
|
|
77
77
|
example "delegator accesses delegate members" do
|
78
|
-
inline_grammar(<<-'END')
|
78
|
+
inline_grammar( <<-'END' )
|
79
79
|
parser grammar Slave3;
|
80
80
|
options {
|
81
81
|
language=Ruby;
|
@@ -91,7 +91,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
91
91
|
}
|
92
92
|
a : B ;
|
93
93
|
END
|
94
|
-
load inline_grammar(<<-'END')
|
94
|
+
load inline_grammar( <<-'END' )
|
95
95
|
grammar Master3;
|
96
96
|
options {
|
97
97
|
language=Ruby;
|
@@ -109,7 +109,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
109
109
|
end
|
110
110
|
|
111
111
|
example "delegator invokes first version of delegate rule" do
|
112
|
-
inline_grammar(<<-'END')
|
112
|
+
inline_grammar( <<-'END' )
|
113
113
|
parser grammar Slave4A;
|
114
114
|
options {
|
115
115
|
language=Ruby;
|
@@ -122,7 +122,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
122
122
|
a : b {capture("S.a")} ;
|
123
123
|
b : B ;
|
124
124
|
END
|
125
|
-
inline_grammar(<<-'END')
|
125
|
+
inline_grammar( <<-'END' )
|
126
126
|
parser grammar Slave4B;
|
127
127
|
options {
|
128
128
|
language=Ruby;
|
@@ -134,7 +134,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
134
134
|
}
|
135
135
|
a : B {capture("T.a")} ;
|
136
136
|
END
|
137
|
-
load inline_grammar(<<-'END')
|
137
|
+
load inline_grammar( <<-'END' )
|
138
138
|
grammar Master4;
|
139
139
|
options {
|
140
140
|
language=Ruby;
|
@@ -152,7 +152,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
152
152
|
end
|
153
153
|
|
154
154
|
example "delegates see same token type" do
|
155
|
-
inline_grammar(<<-'END')
|
155
|
+
inline_grammar( <<-'END' )
|
156
156
|
parser grammar Slave5A; // A, B, C token type order
|
157
157
|
options {
|
158
158
|
language=Ruby;
|
@@ -165,7 +165,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
165
165
|
}
|
166
166
|
x : A {capture("S.x ")} ;
|
167
167
|
END
|
168
|
-
inline_grammar(<<-'END')
|
168
|
+
inline_grammar( <<-'END' )
|
169
169
|
parser grammar Slave5B;
|
170
170
|
options {
|
171
171
|
language=Ruby;
|
@@ -178,7 +178,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
178
178
|
}
|
179
179
|
y : A {capture("T.y")} ;
|
180
180
|
END
|
181
|
-
load inline_grammar(<<-'END')
|
181
|
+
load inline_grammar( <<-'END' )
|
182
182
|
grammar Master5;
|
183
183
|
options {
|
184
184
|
language=Ruby;
|
@@ -200,7 +200,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
200
200
|
end
|
201
201
|
|
202
202
|
example "delegator rule overrides delegate" do
|
203
|
-
inline_grammar(<<-'END')
|
203
|
+
inline_grammar( <<-'END' )
|
204
204
|
parser grammar Slave6;
|
205
205
|
options {
|
206
206
|
language=Ruby;
|
@@ -213,7 +213,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
213
213
|
a : b {capture("S.a")} ;
|
214
214
|
b : B ;
|
215
215
|
END
|
216
|
-
load inline_grammar(<<-'END')
|
216
|
+
load inline_grammar( <<-'END' )
|
217
217
|
grammar Master6;
|
218
218
|
options { language=Ruby; }
|
219
219
|
import Slave6;
|
@@ -228,7 +228,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
228
228
|
end
|
229
229
|
|
230
230
|
example "lexer delegator invokes delegate rule" do
|
231
|
-
inline_grammar(<<-'END')
|
231
|
+
inline_grammar( <<-'END' )
|
232
232
|
lexer grammar Slave7;
|
233
233
|
options {
|
234
234
|
language=Ruby;
|
@@ -241,7 +241,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
241
241
|
A : 'a' {capture("S.A ")} ;
|
242
242
|
C : 'c' ;
|
243
243
|
END
|
244
|
-
load inline_grammar(<<-'END')
|
244
|
+
load inline_grammar( <<-'END' )
|
245
245
|
lexer grammar Master7;
|
246
246
|
options {
|
247
247
|
language=Ruby;
|
@@ -253,12 +253,12 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
253
253
|
END
|
254
254
|
|
255
255
|
lexer = Master7::Lexer.new( 'abc' )
|
256
|
-
lexer.map { |tk| lexer.capture(tk.text) }
|
256
|
+
lexer.map { |tk| lexer.capture( tk.text ) }
|
257
257
|
lexer.output.should == 'S.A abc'
|
258
258
|
end
|
259
259
|
|
260
260
|
example "lexer delegator rule overrides delegate" do
|
261
|
-
inline_grammar(<<-'END')
|
261
|
+
inline_grammar( <<-'END' )
|
262
262
|
lexer grammar Slave8;
|
263
263
|
options {language=Ruby;}
|
264
264
|
@members {
|
@@ -268,7 +268,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
268
268
|
}
|
269
269
|
A : 'a' {capture("S.A")} ;
|
270
270
|
END
|
271
|
-
load inline_grammar(<<-'END')
|
271
|
+
load inline_grammar( <<-'END' )
|
272
272
|
lexer grammar Master8;
|
273
273
|
options {language=Ruby;}
|
274
274
|
import Slave8;
|
@@ -277,13 +277,13 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
277
277
|
WS : (' '|'\n') {skip} ;
|
278
278
|
END
|
279
279
|
|
280
|
-
lexer = Master8::Lexer.new('a')
|
281
|
-
lexer.map { |tk| lexer.capture(tk.text) }
|
280
|
+
lexer = Master8::Lexer.new( 'a' )
|
281
|
+
lexer.map { |tk| lexer.capture( tk.text ) }
|
282
282
|
lexer.output.should == 'M.A a'
|
283
283
|
end
|
284
284
|
|
285
285
|
example "delegator rule with syntactic predicates" do
|
286
|
-
inline_grammar(<<-'END')
|
286
|
+
inline_grammar( <<-'END' )
|
287
287
|
parser grammar Slave9;
|
288
288
|
options { language=Ruby; }
|
289
289
|
@members {
|
@@ -296,7 +296,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
296
296
|
| ('c' 'c')=> 'c'
|
297
297
|
;
|
298
298
|
END
|
299
|
-
load inline_grammar(<<-'END')
|
299
|
+
load inline_grammar( <<-'END' )
|
300
300
|
grammar Master9;
|
301
301
|
options { language=Ruby; }
|
302
302
|
import Slave9;
|
@@ -313,7 +313,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
313
313
|
end
|
314
314
|
|
315
315
|
example "lots of imported lexers" do
|
316
|
-
inline_grammar(<<-'END')
|
316
|
+
inline_grammar( <<-'END' )
|
317
317
|
lexer grammar SlaveOfSlaves;
|
318
318
|
options { language=Ruby; }
|
319
319
|
|
@@ -321,7 +321,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
321
321
|
FLOAT: INTEGER '.' DIGITS (('e'|'E') INTEGER)?;
|
322
322
|
fragment DIGITS: ('0'..'9')+;
|
323
323
|
END
|
324
|
-
inline_grammar(<<-'END')
|
324
|
+
inline_grammar( <<-'END' )
|
325
325
|
lexer grammar FirstSlave;
|
326
326
|
options { language=Ruby; }
|
327
327
|
|
@@ -330,14 +330,14 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
330
330
|
ID: ('A'..'Z')+;
|
331
331
|
OPS: '+' | '-' | '*' | '/';
|
332
332
|
END
|
333
|
-
inline_grammar(<<-'END')
|
333
|
+
inline_grammar( <<-'END' )
|
334
334
|
lexer grammar SecondSlave;
|
335
335
|
options { language=Ruby; }
|
336
336
|
|
337
337
|
INT: ('0'..'9')+;
|
338
338
|
ID: ('a'..'z'|'A'..'Z'|'_')+;
|
339
339
|
END
|
340
|
-
load inline_grammar(<<-'END')
|
340
|
+
load inline_grammar( <<-'END' )
|
341
341
|
lexer grammar MasterOfAll;
|
342
342
|
options { language=Ruby; }
|
343
343
|
|
@@ -371,7 +371,7 @@ class TestImportedGrammars < ANTLR3::Test::Functional
|
|
371
371
|
master.first_slave.slave_of_slaves.should respond_to :first_slave
|
372
372
|
master.first_slave.slave_of_slaves.should respond_to :master_of_all
|
373
373
|
dels = master.each_delegate.map { |d| d }
|
374
|
-
dels.should have(2).things
|
374
|
+
dels.should have( 2 ).things
|
375
375
|
dels.should include master.first_slave
|
376
376
|
dels.should include master.second_slave
|
377
377
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'antlr3/test/functional'
|
4
4
|
|
5
5
|
class LexerTest001 < ANTLR3::Test::Functional
|
6
|
-
inline_grammar(<<-'END')
|
6
|
+
inline_grammar( <<-'END' )
|
7
7
|
lexer grammar Zero;
|
8
8
|
options {
|
9
9
|
language = Ruby;
|
@@ -15,7 +15,7 @@ class LexerTest001 < ANTLR3::Test::Functional
|
|
15
15
|
END
|
16
16
|
|
17
17
|
example %(lexing '0') do
|
18
|
-
lexer = Zero::Lexer.new('0')
|
18
|
+
lexer = Zero::Lexer.new( '0' )
|
19
19
|
|
20
20
|
token = lexer.next_token
|
21
21
|
token.name.should == 'ZERO'
|
@@ -25,18 +25,18 @@ class LexerTest001 < ANTLR3::Test::Functional
|
|
25
25
|
end
|
26
26
|
|
27
27
|
example %(iterating over tokens) do
|
28
|
-
lexer = Zero::Lexer.new('0')
|
28
|
+
lexer = Zero::Lexer.new( '0' )
|
29
29
|
|
30
30
|
token_types = lexer.map { |token| token.name }
|
31
31
|
token_types.should == %w(ZERO)
|
32
32
|
end
|
33
33
|
|
34
34
|
example "mismatched token" do
|
35
|
-
lexer = Zero::Lexer.new('1')
|
35
|
+
lexer = Zero::Lexer.new( '1' )
|
36
36
|
|
37
|
-
proc {
|
37
|
+
proc {
|
38
38
|
token = lexer.next_token
|
39
|
-
}.should raise_error(ANTLR3::Error::MismatchedToken) do |e|
|
39
|
+
}.should raise_error( ANTLR3::Error::MismatchedToken ) do |e|
|
40
40
|
e.expecting.should == '0'
|
41
41
|
e.unexpected_type.should == '1'
|
42
42
|
end
|
@@ -44,7 +44,7 @@ class LexerTest001 < ANTLR3::Test::Functional
|
|
44
44
|
end
|
45
45
|
|
46
46
|
class LexerTest002 < ANTLR3::Test::Functional
|
47
|
-
inline_grammar(<<-'END')
|
47
|
+
inline_grammar( <<-'END' )
|
48
48
|
lexer grammar Binary;
|
49
49
|
options {
|
50
50
|
language = Ruby;
|
@@ -73,7 +73,7 @@ class LexerTest002 < ANTLR3::Test::Functional
|
|
73
73
|
lexer = Binary::Lexer.new( '2' )
|
74
74
|
|
75
75
|
b = lambda { token = lexer.next_token }
|
76
|
-
b.should raise_error(ANTLR3::Error::NoViableAlternative) do |exc|
|
76
|
+
b.should raise_error( ANTLR3::Error::NoViableAlternative ) do |exc|
|
77
77
|
exc.unexpected_type.should == '2'
|
78
78
|
end
|
79
79
|
end
|
@@ -81,7 +81,7 @@ class LexerTest002 < ANTLR3::Test::Functional
|
|
81
81
|
end
|
82
82
|
|
83
83
|
class LexerTest003 < ANTLR3::Test::Functional
|
84
|
-
inline_grammar(<<-'END')
|
84
|
+
inline_grammar( <<-'END' )
|
85
85
|
lexer grammar BinaryFooze;
|
86
86
|
options {
|
87
87
|
language = Ruby;
|
@@ -114,7 +114,7 @@ class LexerTest003 < ANTLR3::Test::Functional
|
|
114
114
|
lexer = BinaryFooze::Lexer.new( '2' )
|
115
115
|
|
116
116
|
proc { lexer.next_token }.
|
117
|
-
should raise_error(ANTLR3::Error::NoViableAlternative) do |exc|
|
117
|
+
should raise_error( ANTLR3::Error::NoViableAlternative ) do |exc|
|
118
118
|
exc.unexpected_type.should == '2'
|
119
119
|
end
|
120
120
|
end
|
@@ -122,7 +122,7 @@ end
|
|
122
122
|
|
123
123
|
|
124
124
|
class LexerTest004 < ANTLR3::Test::Functional
|
125
|
-
inline_grammar(<<-'END')
|
125
|
+
inline_grammar( <<-'END' )
|
126
126
|
lexer grammar FooStar;
|
127
127
|
options {
|
128
128
|
language = Ruby;
|
@@ -168,7 +168,7 @@ class LexerTest004 < ANTLR3::Test::Functional
|
|
168
168
|
lexer = FooStar::Lexer.new( '2' )
|
169
169
|
|
170
170
|
proc { lexer.next_token }.
|
171
|
-
should raise_error(ANTLR3::Error::MismatchedToken) do |exc|
|
171
|
+
should raise_error( ANTLR3::Error::MismatchedToken ) do |exc|
|
172
172
|
exc.expecting.should == 'f'
|
173
173
|
exc.unexpected_type.should == '2'
|
174
174
|
end
|
@@ -176,7 +176,7 @@ class LexerTest004 < ANTLR3::Test::Functional
|
|
176
176
|
end
|
177
177
|
|
178
178
|
class LexerTest005 < ANTLR3::Test::Functional
|
179
|
-
inline_grammar(<<-'END')
|
179
|
+
inline_grammar( <<-'END' )
|
180
180
|
lexer grammar FooPlus;
|
181
181
|
options {
|
182
182
|
language = Ruby;
|
@@ -216,7 +216,7 @@ class LexerTest005 < ANTLR3::Test::Functional
|
|
216
216
|
lexer = FooPlus::Lexer.new( '2' )
|
217
217
|
|
218
218
|
proc { lexer.next_token }.
|
219
|
-
should raise_error(ANTLR3::Error::MismatchedToken) do |exc|
|
219
|
+
should raise_error( ANTLR3::Error::MismatchedToken ) do |exc|
|
220
220
|
exc.expecting.should == 'f'
|
221
221
|
exc.unexpected_type.should == '2'
|
222
222
|
end
|
@@ -226,7 +226,7 @@ class LexerTest005 < ANTLR3::Test::Functional
|
|
226
226
|
lexer = FooPlus::Lexer.new( 'f' )
|
227
227
|
|
228
228
|
proc { token = lexer.next_token }.
|
229
|
-
should raise_error(ANTLR3::Error::EarlyExit) { |exc|
|
229
|
+
should raise_error( ANTLR3::Error::EarlyExit ) { |exc|
|
230
230
|
exc.unexpected_type.should == ANTLR3::Constants::EOF
|
231
231
|
}
|
232
232
|
end
|
@@ -234,7 +234,7 @@ class LexerTest005 < ANTLR3::Test::Functional
|
|
234
234
|
end
|
235
235
|
|
236
236
|
class LexerTest006 < ANTLR3::Test::Functional
|
237
|
-
inline_grammar(<<-'END')
|
237
|
+
inline_grammar( <<-'END' )
|
238
238
|
lexer grammar FoaStar;
|
239
239
|
options {
|
240
240
|
language = Ruby;
|
@@ -270,7 +270,7 @@ class LexerTest006 < ANTLR3::Test::Functional
|
|
270
270
|
lexer.next_token
|
271
271
|
lexer.next_token
|
272
272
|
proc { lexer.next_token }.
|
273
|
-
should raise_error(ANTLR3::Error::MismatchedToken) do |exc|
|
273
|
+
should raise_error( ANTLR3::Error::MismatchedToken ) do |exc|
|
274
274
|
exc.expecting.should == 'f'
|
275
275
|
exc.unexpected_type.should == '2'
|
276
276
|
exc.column.should == 10
|
@@ -280,7 +280,7 @@ class LexerTest006 < ANTLR3::Test::Functional
|
|
280
280
|
end
|
281
281
|
|
282
282
|
class LexerTest007 < ANTLR3::Test::Functional
|
283
|
-
inline_grammar(<<-'END')
|
283
|
+
inline_grammar( <<-'END' )
|
284
284
|
lexer grammar Foab;
|
285
285
|
options {
|
286
286
|
language = Ruby;
|
@@ -314,7 +314,7 @@ class LexerTest007 < ANTLR3::Test::Functional
|
|
314
314
|
lexer = Foab::Lexer.new( 'foaboao' )
|
315
315
|
|
316
316
|
proc { lexer.next_token }.
|
317
|
-
should raise_error(ANTLR3::Error::EarlyExit) do |exc|
|
317
|
+
should raise_error( ANTLR3::Error::EarlyExit ) do |exc|
|
318
318
|
exc.unexpected_type.should == 'o'
|
319
319
|
exc.column.should == 6
|
320
320
|
exc.line.should == 1
|
@@ -323,7 +323,7 @@ class LexerTest007 < ANTLR3::Test::Functional
|
|
323
323
|
end
|
324
324
|
|
325
325
|
class LexerTest008 < ANTLR3::Test::Functional
|
326
|
-
inline_grammar(<<-'END')
|
326
|
+
inline_grammar( <<-'END' )
|
327
327
|
lexer grammar Fa;
|
328
328
|
options {
|
329
329
|
language = Ruby;
|
@@ -365,7 +365,7 @@ class LexerTest008 < ANTLR3::Test::Functional
|
|
365
365
|
lexer.next_token
|
366
366
|
lexer.next_token
|
367
367
|
proc { lexer.next_token }.
|
368
|
-
should raise_error(ANTLR3::Error::MismatchedToken) do |exc|
|
368
|
+
should raise_error( ANTLR3::Error::MismatchedToken ) do |exc|
|
369
369
|
exc.unexpected_type.should == 'b'
|
370
370
|
exc.column.should == 3
|
371
371
|
exc.line.should == 1
|
@@ -375,7 +375,7 @@ end
|
|
375
375
|
|
376
376
|
|
377
377
|
class LexerTest009 < ANTLR3::Test::Functional
|
378
|
-
inline_grammar(<<-'END')
|
378
|
+
inline_grammar( <<-'END' )
|
379
379
|
lexer grammar Digit;
|
380
380
|
options {
|
381
381
|
language = Ruby;
|
@@ -416,7 +416,7 @@ class LexerTest009 < ANTLR3::Test::Functional
|
|
416
416
|
|
417
417
|
lexer.next_token
|
418
418
|
proc { lexer.next_token }.
|
419
|
-
should raise_error(ANTLR3::Error::MismatchedRange) do |exc|
|
419
|
+
should raise_error( ANTLR3::Error::MismatchedRange ) do |exc|
|
420
420
|
exc.min.should == '0'
|
421
421
|
exc.max.should == '9'
|
422
422
|
exc.unexpected_type.should == 'a'
|
@@ -427,7 +427,7 @@ class LexerTest009 < ANTLR3::Test::Functional
|
|
427
427
|
end
|
428
428
|
|
429
429
|
class LexerTest010 < ANTLR3::Test::Functional
|
430
|
-
inline_grammar(<<-'END')
|
430
|
+
inline_grammar( <<-'END' )
|
431
431
|
lexer grammar IDsAndSpaces;
|
432
432
|
options {
|
433
433
|
language = Ruby;
|
@@ -481,7 +481,7 @@ class LexerTest010 < ANTLR3::Test::Functional
|
|
481
481
|
|
482
482
|
lexer.next_token
|
483
483
|
proc { lexer.next_token }.
|
484
|
-
should raise_error(ANTLR3::Error::NoViableAlternative) do |exc|
|
484
|
+
should raise_error( ANTLR3::Error::NoViableAlternative ) do |exc|
|
485
485
|
exc.unexpected_type.should == '-'
|
486
486
|
exc.column.should == 1
|
487
487
|
exc.line.should == 1
|
@@ -490,7 +490,7 @@ class LexerTest010 < ANTLR3::Test::Functional
|
|
490
490
|
end
|
491
491
|
|
492
492
|
class LexerTest011 < ANTLR3::Test::Functional
|
493
|
-
inline_grammar(<<-'END')
|
493
|
+
inline_grammar( <<-'END' )
|
494
494
|
lexer grammar IDsWithAction;
|
495
495
|
options {language = Ruby;}
|
496
496
|
|
@@ -550,7 +550,7 @@ class LexerTest011 < ANTLR3::Test::Functional
|
|
550
550
|
|
551
551
|
lexer.next_token
|
552
552
|
proc { lexer.next_token }.
|
553
|
-
should raise_error(ANTLR3::Error::NoViableAlternative) do |exc|
|
553
|
+
should raise_error( ANTLR3::Error::NoViableAlternative ) do |exc|
|
554
554
|
exc.unexpected_type.should == '-'
|
555
555
|
exc.column.should == 1
|
556
556
|
exc.line.should == 1
|