antlr3 1.3.1 → 1.4.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/antlr-full-3.2.1.jar +0 -0
- data/lib/antlr3.rb +2 -0
- data/lib/antlr3/main.rb +3 -5
- data/lib/antlr3/modes/ast-builder.rb +1 -22
- data/lib/antlr3/streams/rewrite.rb +3 -3
- data/lib/antlr3/task.rb +12 -1
- data/lib/antlr3/template.rb +319 -0
- data/lib/antlr3/template/group-lexer.rb +992 -0
- data/lib/antlr3/template/group-parser.rb +627 -0
- data/lib/antlr3/template/parameter.rb +56 -0
- data/lib/antlr3/test/grammar.rb +9 -11
- data/lib/antlr3/tree.rb +30 -0
- data/lib/antlr3/version.rb +2 -2
- data/templates/Ruby.stg +9 -10
- data/templates/ST.stg +128 -0
- data/test/functional/ast-output/auto-ast.rb +1 -1
- data/test/functional/ast-output/hetero-nodes.rb +2 -1
- data/test/functional/template-output/template-output.rb +404 -0
- data/test/unit/sample-input/template-group +38 -0
- data/test/unit/test-template.rb +248 -0
- metadata +12 -2
@@ -0,0 +1,992 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Group.g
|
4
|
+
#
|
5
|
+
# Generated using ANTLR version: 3.2.1-SNAPSHOT Dec 18, 2009 04:29:28
|
6
|
+
# Ruby runtime library version: 1.3.1
|
7
|
+
# Input grammar file: Group.g
|
8
|
+
# Generated at: 2010-01-17 06:59:16
|
9
|
+
#
|
10
|
+
|
11
|
+
# ~~~> start load path setup
|
12
|
+
this_directory = File.expand_path( File.dirname( __FILE__ ) )
|
13
|
+
$:.unshift( this_directory ) unless $:.include?( this_directory )
|
14
|
+
|
15
|
+
antlr_load_failed = proc do
|
16
|
+
load_path = $LOAD_PATH.map { |dir| ' - ' << dir }.join( $/ )
|
17
|
+
raise LoadError, <<-END.strip!
|
18
|
+
|
19
|
+
Failed to load the ANTLR3 runtime library (version 1.3.1):
|
20
|
+
|
21
|
+
Ensure the library has been installed on your system and is available
|
22
|
+
on the load path. If rubygems is available on your system, this can
|
23
|
+
be done with the command:
|
24
|
+
|
25
|
+
gem install antlr3
|
26
|
+
|
27
|
+
Current load path:
|
28
|
+
#{ load_path }
|
29
|
+
|
30
|
+
END
|
31
|
+
end
|
32
|
+
|
33
|
+
defined?(ANTLR3) or begin
|
34
|
+
|
35
|
+
# 1: try to load the ruby antlr3 runtime library from the system path
|
36
|
+
require 'antlr3'
|
37
|
+
|
38
|
+
rescue LoadError
|
39
|
+
|
40
|
+
# 2: try to load rubygems if it isn't already loaded
|
41
|
+
defined?(Gem) or begin
|
42
|
+
require 'rubygems'
|
43
|
+
rescue LoadError
|
44
|
+
antlr_load_failed.call
|
45
|
+
end
|
46
|
+
|
47
|
+
# 3: try to activate the antlr3 gem
|
48
|
+
begin
|
49
|
+
Gem.activate( 'antlr3', '= 1.3.1' )
|
50
|
+
rescue Gem::LoadError
|
51
|
+
antlr_load_failed.call
|
52
|
+
end
|
53
|
+
|
54
|
+
require 'antlr3'
|
55
|
+
|
56
|
+
end
|
57
|
+
# <~~~ end load path setup
|
58
|
+
|
59
|
+
# - - - - - - begin action @lexer::header - - - - - -
|
60
|
+
# Group.g
|
61
|
+
|
62
|
+
|
63
|
+
module ANTLR3
|
64
|
+
module Template
|
65
|
+
|
66
|
+
# - - - - - - end action @lexer::header - - - - - - -
|
67
|
+
|
68
|
+
|
69
|
+
class Group
|
70
|
+
# TokenData defines all of the token type integer values
|
71
|
+
# as constants, which will be included in all
|
72
|
+
# ANTLR-generated recognizers.
|
73
|
+
const_defined?(:TokenData) or TokenData = ANTLR3::TokenScheme.new
|
74
|
+
|
75
|
+
module TokenData
|
76
|
+
|
77
|
+
# define the token constants
|
78
|
+
define_tokens(:ID => 5, :EOF => -1, :T__19 => 19, :WS => 9, :T__16 => 16,
|
79
|
+
:T__15 => 15, :T__18 => 18, :T__17 => 17, :T__12 => 12,
|
80
|
+
:TEMPLATE => 6, :T__11 => 11, :T__14 => 14, :T__13 => 13,
|
81
|
+
:T__10 => 10, :CONSTANT => 4, :COMMENT => 8, :STRING => 7)
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
class Lexer < ANTLR3::Lexer
|
87
|
+
@grammar_home = Group
|
88
|
+
include TokenData
|
89
|
+
|
90
|
+
begin
|
91
|
+
generated_using( "Group.g", "3.2.1-SNAPSHOT Dec 18, 2009 04:29:28", "1.3.1" )
|
92
|
+
rescue NoMethodError => error
|
93
|
+
error.name.to_sym == :generated_using or raise
|
94
|
+
end
|
95
|
+
|
96
|
+
RULE_NAMES = ["T__10", "T__11", "T__12", "T__13", "T__14", "T__15",
|
97
|
+
"T__16", "T__17", "T__18", "T__19", "CONSTANT", "ID",
|
98
|
+
"TEMPLATE", "STRING", "COMMENT", "WS"].freeze
|
99
|
+
RULE_METHODS = [:t__10!, :t__11!, :t__12!, :t__13!, :t__14!, :t__15!,
|
100
|
+
:t__16!, :t__17!, :t__18!, :t__19!, :constant!, :id!,
|
101
|
+
:template!, :string!, :comment!, :ws!].freeze
|
102
|
+
|
103
|
+
|
104
|
+
def initialize(input=nil, options = {})
|
105
|
+
super(input, options)
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
# - - - - - - - - - - - lexer rules - - - - - - - - - - - -
|
110
|
+
# lexer rule t__10! (T__10)
|
111
|
+
# (in Group.g)
|
112
|
+
def t__10!
|
113
|
+
# -> uncomment the next line to manually enable rule tracing
|
114
|
+
# trace_in(__method__, 1)
|
115
|
+
|
116
|
+
type = T__10
|
117
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
118
|
+
|
119
|
+
|
120
|
+
# - - - - main rule block - - - -
|
121
|
+
# at line 16:9: 'group'
|
122
|
+
match("group")
|
123
|
+
|
124
|
+
|
125
|
+
@state.type = type
|
126
|
+
@state.channel = channel
|
127
|
+
|
128
|
+
ensure
|
129
|
+
# -> uncomment the next line to manually enable rule tracing
|
130
|
+
# trace_out(__method__, 1)
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
# lexer rule t__11! (T__11)
|
135
|
+
# (in Group.g)
|
136
|
+
def t__11!
|
137
|
+
# -> uncomment the next line to manually enable rule tracing
|
138
|
+
# trace_in(__method__, 2)
|
139
|
+
|
140
|
+
type = T__11
|
141
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
142
|
+
|
143
|
+
|
144
|
+
# - - - - main rule block - - - -
|
145
|
+
# at line 17:9: '::'
|
146
|
+
match("::")
|
147
|
+
|
148
|
+
|
149
|
+
@state.type = type
|
150
|
+
@state.channel = channel
|
151
|
+
|
152
|
+
ensure
|
153
|
+
# -> uncomment the next line to manually enable rule tracing
|
154
|
+
# trace_out(__method__, 2)
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
# lexer rule t__12! (T__12)
|
159
|
+
# (in Group.g)
|
160
|
+
def t__12!
|
161
|
+
# -> uncomment the next line to manually enable rule tracing
|
162
|
+
# trace_in(__method__, 3)
|
163
|
+
|
164
|
+
type = T__12
|
165
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
166
|
+
|
167
|
+
|
168
|
+
# - - - - main rule block - - - -
|
169
|
+
# at line 18:9: ';'
|
170
|
+
match(?;)
|
171
|
+
|
172
|
+
|
173
|
+
@state.type = type
|
174
|
+
@state.channel = channel
|
175
|
+
|
176
|
+
ensure
|
177
|
+
# -> uncomment the next line to manually enable rule tracing
|
178
|
+
# trace_out(__method__, 3)
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
# lexer rule t__13! (T__13)
|
183
|
+
# (in Group.g)
|
184
|
+
def t__13!
|
185
|
+
# -> uncomment the next line to manually enable rule tracing
|
186
|
+
# trace_in(__method__, 4)
|
187
|
+
|
188
|
+
type = T__13
|
189
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
190
|
+
|
191
|
+
|
192
|
+
# - - - - main rule block - - - -
|
193
|
+
# at line 19:9: '::='
|
194
|
+
match("::=")
|
195
|
+
|
196
|
+
|
197
|
+
@state.type = type
|
198
|
+
@state.channel = channel
|
199
|
+
|
200
|
+
ensure
|
201
|
+
# -> uncomment the next line to manually enable rule tracing
|
202
|
+
# trace_out(__method__, 4)
|
203
|
+
|
204
|
+
end
|
205
|
+
|
206
|
+
# lexer rule t__14! (T__14)
|
207
|
+
# (in Group.g)
|
208
|
+
def t__14!
|
209
|
+
# -> uncomment the next line to manually enable rule tracing
|
210
|
+
# trace_in(__method__, 5)
|
211
|
+
|
212
|
+
type = T__14
|
213
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
214
|
+
|
215
|
+
|
216
|
+
# - - - - main rule block - - - -
|
217
|
+
# at line 20:9: '('
|
218
|
+
match(?()
|
219
|
+
|
220
|
+
|
221
|
+
@state.type = type
|
222
|
+
@state.channel = channel
|
223
|
+
|
224
|
+
ensure
|
225
|
+
# -> uncomment the next line to manually enable rule tracing
|
226
|
+
# trace_out(__method__, 5)
|
227
|
+
|
228
|
+
end
|
229
|
+
|
230
|
+
# lexer rule t__15! (T__15)
|
231
|
+
# (in Group.g)
|
232
|
+
def t__15!
|
233
|
+
# -> uncomment the next line to manually enable rule tracing
|
234
|
+
# trace_in(__method__, 6)
|
235
|
+
|
236
|
+
type = T__15
|
237
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
238
|
+
|
239
|
+
|
240
|
+
# - - - - main rule block - - - -
|
241
|
+
# at line 21:9: ')'
|
242
|
+
match(?))
|
243
|
+
|
244
|
+
|
245
|
+
@state.type = type
|
246
|
+
@state.channel = channel
|
247
|
+
|
248
|
+
ensure
|
249
|
+
# -> uncomment the next line to manually enable rule tracing
|
250
|
+
# trace_out(__method__, 6)
|
251
|
+
|
252
|
+
end
|
253
|
+
|
254
|
+
# lexer rule t__16! (T__16)
|
255
|
+
# (in Group.g)
|
256
|
+
def t__16!
|
257
|
+
# -> uncomment the next line to manually enable rule tracing
|
258
|
+
# trace_in(__method__, 7)
|
259
|
+
|
260
|
+
type = T__16
|
261
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
262
|
+
|
263
|
+
|
264
|
+
# - - - - main rule block - - - -
|
265
|
+
# at line 22:9: ','
|
266
|
+
match(?,)
|
267
|
+
|
268
|
+
|
269
|
+
@state.type = type
|
270
|
+
@state.channel = channel
|
271
|
+
|
272
|
+
ensure
|
273
|
+
# -> uncomment the next line to manually enable rule tracing
|
274
|
+
# trace_out(__method__, 7)
|
275
|
+
|
276
|
+
end
|
277
|
+
|
278
|
+
# lexer rule t__17! (T__17)
|
279
|
+
# (in Group.g)
|
280
|
+
def t__17!
|
281
|
+
# -> uncomment the next line to manually enable rule tracing
|
282
|
+
# trace_in(__method__, 8)
|
283
|
+
|
284
|
+
type = T__17
|
285
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
286
|
+
|
287
|
+
|
288
|
+
# - - - - main rule block - - - -
|
289
|
+
# at line 23:9: '*'
|
290
|
+
match(?*)
|
291
|
+
|
292
|
+
|
293
|
+
@state.type = type
|
294
|
+
@state.channel = channel
|
295
|
+
|
296
|
+
ensure
|
297
|
+
# -> uncomment the next line to manually enable rule tracing
|
298
|
+
# trace_out(__method__, 8)
|
299
|
+
|
300
|
+
end
|
301
|
+
|
302
|
+
# lexer rule t__18! (T__18)
|
303
|
+
# (in Group.g)
|
304
|
+
def t__18!
|
305
|
+
# -> uncomment the next line to manually enable rule tracing
|
306
|
+
# trace_in(__method__, 9)
|
307
|
+
|
308
|
+
type = T__18
|
309
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
310
|
+
|
311
|
+
|
312
|
+
# - - - - main rule block - - - -
|
313
|
+
# at line 24:9: '&'
|
314
|
+
match(?&)
|
315
|
+
|
316
|
+
|
317
|
+
@state.type = type
|
318
|
+
@state.channel = channel
|
319
|
+
|
320
|
+
ensure
|
321
|
+
# -> uncomment the next line to manually enable rule tracing
|
322
|
+
# trace_out(__method__, 9)
|
323
|
+
|
324
|
+
end
|
325
|
+
|
326
|
+
# lexer rule t__19! (T__19)
|
327
|
+
# (in Group.g)
|
328
|
+
def t__19!
|
329
|
+
# -> uncomment the next line to manually enable rule tracing
|
330
|
+
# trace_in(__method__, 10)
|
331
|
+
|
332
|
+
type = T__19
|
333
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
334
|
+
|
335
|
+
|
336
|
+
# - - - - main rule block - - - -
|
337
|
+
# at line 25:9: '='
|
338
|
+
match(?=)
|
339
|
+
|
340
|
+
|
341
|
+
@state.type = type
|
342
|
+
@state.channel = channel
|
343
|
+
|
344
|
+
ensure
|
345
|
+
# -> uncomment the next line to manually enable rule tracing
|
346
|
+
# trace_out(__method__, 10)
|
347
|
+
|
348
|
+
end
|
349
|
+
|
350
|
+
# lexer rule constant! (CONSTANT)
|
351
|
+
# (in Group.g)
|
352
|
+
def constant!
|
353
|
+
# -> uncomment the next line to manually enable rule tracing
|
354
|
+
# trace_in(__method__, 11)
|
355
|
+
|
356
|
+
type = CONSTANT
|
357
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
358
|
+
|
359
|
+
|
360
|
+
# - - - - main rule block - - - -
|
361
|
+
# at line 104:5: 'A' .. 'Z' ( 'a' .. 'z' | '_' | 'A' .. 'Z' | '0' .. '9' )*
|
362
|
+
match_range(?A, ?Z)
|
363
|
+
# at line 104:14: ( 'a' .. 'z' | '_' | 'A' .. 'Z' | '0' .. '9' )*
|
364
|
+
loop do # decision 1
|
365
|
+
alt_1 = 2
|
366
|
+
look_1_0 = @input.peek(1)
|
367
|
+
|
368
|
+
if (look_1_0.between?(?0, ?9) || look_1_0.between?(?A, ?Z) || look_1_0 == ?_ || look_1_0.between?(?a, ?z))
|
369
|
+
alt_1 = 1
|
370
|
+
|
371
|
+
end
|
372
|
+
case alt_1
|
373
|
+
when 1
|
374
|
+
# at line
|
375
|
+
if @input.peek(1).between?(?0, ?9) || @input.peek(1).between?(?A, ?Z) || @input.peek(1) == ?_ || @input.peek(1).between?(?a, ?z)
|
376
|
+
@input.consume
|
377
|
+
else
|
378
|
+
mse = MismatchedSet(nil)
|
379
|
+
recover(mse)
|
380
|
+
raise mse
|
381
|
+
end
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
else
|
386
|
+
break # out of loop for decision 1
|
387
|
+
end
|
388
|
+
end # loop for decision 1
|
389
|
+
|
390
|
+
|
391
|
+
@state.type = type
|
392
|
+
@state.channel = channel
|
393
|
+
|
394
|
+
ensure
|
395
|
+
# -> uncomment the next line to manually enable rule tracing
|
396
|
+
# trace_out(__method__, 11)
|
397
|
+
|
398
|
+
end
|
399
|
+
|
400
|
+
# lexer rule id! (ID)
|
401
|
+
# (in Group.g)
|
402
|
+
def id!
|
403
|
+
# -> uncomment the next line to manually enable rule tracing
|
404
|
+
# trace_in(__method__, 12)
|
405
|
+
|
406
|
+
type = ID
|
407
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
408
|
+
|
409
|
+
|
410
|
+
# - - - - main rule block - - - -
|
411
|
+
# at line 108:5: ( 'a' .. 'z' | '_' ) ( 'a' .. 'z' | '_' | 'A' .. 'Z' | '0' .. '9' )*
|
412
|
+
if @input.peek(1) == ?_ || @input.peek(1).between?(?a, ?z)
|
413
|
+
@input.consume
|
414
|
+
else
|
415
|
+
mse = MismatchedSet(nil)
|
416
|
+
recover(mse)
|
417
|
+
raise mse
|
418
|
+
end
|
419
|
+
|
420
|
+
|
421
|
+
# at line 109:5: ( 'a' .. 'z' | '_' | 'A' .. 'Z' | '0' .. '9' )*
|
422
|
+
loop do # decision 2
|
423
|
+
alt_2 = 2
|
424
|
+
look_2_0 = @input.peek(1)
|
425
|
+
|
426
|
+
if (look_2_0.between?(?0, ?9) || look_2_0.between?(?A, ?Z) || look_2_0 == ?_ || look_2_0.between?(?a, ?z))
|
427
|
+
alt_2 = 1
|
428
|
+
|
429
|
+
end
|
430
|
+
case alt_2
|
431
|
+
when 1
|
432
|
+
# at line
|
433
|
+
if @input.peek(1).between?(?0, ?9) || @input.peek(1).between?(?A, ?Z) || @input.peek(1) == ?_ || @input.peek(1).between?(?a, ?z)
|
434
|
+
@input.consume
|
435
|
+
else
|
436
|
+
mse = MismatchedSet(nil)
|
437
|
+
recover(mse)
|
438
|
+
raise mse
|
439
|
+
end
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
else
|
444
|
+
break # out of loop for decision 2
|
445
|
+
end
|
446
|
+
end # loop for decision 2
|
447
|
+
|
448
|
+
|
449
|
+
@state.type = type
|
450
|
+
@state.channel = channel
|
451
|
+
|
452
|
+
ensure
|
453
|
+
# -> uncomment the next line to manually enable rule tracing
|
454
|
+
# trace_out(__method__, 12)
|
455
|
+
|
456
|
+
end
|
457
|
+
|
458
|
+
# lexer rule template! (TEMPLATE)
|
459
|
+
# (in Group.g)
|
460
|
+
def template!
|
461
|
+
# -> uncomment the next line to manually enable rule tracing
|
462
|
+
# trace_in(__method__, 13)
|
463
|
+
|
464
|
+
type = TEMPLATE
|
465
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
466
|
+
|
467
|
+
|
468
|
+
# - - - - main rule block - - - -
|
469
|
+
# at line 113:5: '<<<' ( options {greedy=false; } : '\\\\' . | . )* '>>>'
|
470
|
+
match("<<<")
|
471
|
+
# at line 114:5: ( options {greedy=false; } : '\\\\' . | . )*
|
472
|
+
loop do # decision 3
|
473
|
+
alt_3 = 3
|
474
|
+
look_3_0 = @input.peek(1)
|
475
|
+
|
476
|
+
if (look_3_0 == ?>)
|
477
|
+
look_3_1 = @input.peek(2)
|
478
|
+
|
479
|
+
if (look_3_1 == ?>)
|
480
|
+
look_3_4 = @input.peek(3)
|
481
|
+
|
482
|
+
if (look_3_4 == ?>)
|
483
|
+
alt_3 = 3
|
484
|
+
elsif (look_3_4.between?(0x0000, ?=) || look_3_4.between?(??, 0xFFFF))
|
485
|
+
alt_3 = 2
|
486
|
+
|
487
|
+
end
|
488
|
+
elsif (look_3_1.between?(0x0000, ?=) || look_3_1.between?(??, 0xFFFF))
|
489
|
+
alt_3 = 2
|
490
|
+
|
491
|
+
end
|
492
|
+
elsif (look_3_0 == ?\\)
|
493
|
+
look_3_2 = @input.peek(2)
|
494
|
+
|
495
|
+
if (look_3_2 == ?>)
|
496
|
+
alt_3 = 1
|
497
|
+
elsif (look_3_2 == ?\\)
|
498
|
+
alt_3 = 1
|
499
|
+
elsif (look_3_2.between?(0x0000, ?=) || look_3_2.between?(??, ?[) || look_3_2.between?(?], 0xFFFF))
|
500
|
+
alt_3 = 1
|
501
|
+
|
502
|
+
end
|
503
|
+
elsif (look_3_0.between?(0x0000, ?=) || look_3_0.between?(??, ?[) || look_3_0.between?(?], 0xFFFF))
|
504
|
+
alt_3 = 2
|
505
|
+
|
506
|
+
end
|
507
|
+
case alt_3
|
508
|
+
when 1
|
509
|
+
# at line 114:35: '\\\\' .
|
510
|
+
match(?\\)
|
511
|
+
match_any
|
512
|
+
|
513
|
+
when 2
|
514
|
+
# at line 114:44: .
|
515
|
+
match_any
|
516
|
+
|
517
|
+
else
|
518
|
+
break # out of loop for decision 3
|
519
|
+
end
|
520
|
+
end # loop for decision 3
|
521
|
+
match(">>>")
|
522
|
+
|
523
|
+
|
524
|
+
@state.type = type
|
525
|
+
@state.channel = channel
|
526
|
+
|
527
|
+
ensure
|
528
|
+
# -> uncomment the next line to manually enable rule tracing
|
529
|
+
# trace_out(__method__, 13)
|
530
|
+
|
531
|
+
end
|
532
|
+
|
533
|
+
# lexer rule string! (STRING)
|
534
|
+
# (in Group.g)
|
535
|
+
def string!
|
536
|
+
# -> uncomment the next line to manually enable rule tracing
|
537
|
+
# trace_in(__method__, 14)
|
538
|
+
|
539
|
+
type = STRING
|
540
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
541
|
+
|
542
|
+
|
543
|
+
# - - - - main rule block - - - -
|
544
|
+
# at line 119:3: ( '\"' (~ ( '\\\\' | '\"' ) | '\\\\' . )* '\"' | '\\'' (~ ( '\\\\' | '\\'' ) | '\\\\' . )* '\\'' )
|
545
|
+
alt_6 = 2
|
546
|
+
look_6_0 = @input.peek(1)
|
547
|
+
|
548
|
+
if (look_6_0 == ?")
|
549
|
+
alt_6 = 1
|
550
|
+
elsif (look_6_0 == ?\')
|
551
|
+
alt_6 = 2
|
552
|
+
else
|
553
|
+
nvae = NoViableAlternative("", 6, 0)
|
554
|
+
raise nvae
|
555
|
+
end
|
556
|
+
case alt_6
|
557
|
+
when 1
|
558
|
+
# at line 119:5: '\"' (~ ( '\\\\' | '\"' ) | '\\\\' . )* '\"'
|
559
|
+
match(?")
|
560
|
+
# at line 119:10: (~ ( '\\\\' | '\"' ) | '\\\\' . )*
|
561
|
+
loop do # decision 4
|
562
|
+
alt_4 = 3
|
563
|
+
look_4_0 = @input.peek(1)
|
564
|
+
|
565
|
+
if (look_4_0.between?(0x0000, ?!) || look_4_0.between?(?#, ?[) || look_4_0.between?(?], 0xFFFF))
|
566
|
+
alt_4 = 1
|
567
|
+
elsif (look_4_0 == ?\\)
|
568
|
+
alt_4 = 2
|
569
|
+
|
570
|
+
end
|
571
|
+
case alt_4
|
572
|
+
when 1
|
573
|
+
# at line 119:12: ~ ( '\\\\' | '\"' )
|
574
|
+
if @input.peek(1).between?(0x0000, ?!) || @input.peek(1).between?(?#, ?[) || @input.peek(1).between?(?], 0x00FF)
|
575
|
+
@input.consume
|
576
|
+
else
|
577
|
+
mse = MismatchedSet(nil)
|
578
|
+
recover(mse)
|
579
|
+
raise mse
|
580
|
+
end
|
581
|
+
|
582
|
+
|
583
|
+
|
584
|
+
when 2
|
585
|
+
# at line 119:31: '\\\\' .
|
586
|
+
match(?\\)
|
587
|
+
match_any
|
588
|
+
|
589
|
+
else
|
590
|
+
break # out of loop for decision 4
|
591
|
+
end
|
592
|
+
end # loop for decision 4
|
593
|
+
match(?")
|
594
|
+
|
595
|
+
when 2
|
596
|
+
# at line 120:5: '\\'' (~ ( '\\\\' | '\\'' ) | '\\\\' . )* '\\''
|
597
|
+
match(?\')
|
598
|
+
# at line 120:10: (~ ( '\\\\' | '\\'' ) | '\\\\' . )*
|
599
|
+
loop do # decision 5
|
600
|
+
alt_5 = 3
|
601
|
+
look_5_0 = @input.peek(1)
|
602
|
+
|
603
|
+
if (look_5_0.between?(0x0000, ?&) || look_5_0.between?(?(, ?[) || look_5_0.between?(?], 0xFFFF))
|
604
|
+
alt_5 = 1
|
605
|
+
elsif (look_5_0 == ?\\)
|
606
|
+
alt_5 = 2
|
607
|
+
|
608
|
+
end
|
609
|
+
case alt_5
|
610
|
+
when 1
|
611
|
+
# at line 120:12: ~ ( '\\\\' | '\\'' )
|
612
|
+
if @input.peek(1).between?(0x0000, ?&) || @input.peek(1).between?(?(, ?[) || @input.peek(1).between?(?], 0x00FF)
|
613
|
+
@input.consume
|
614
|
+
else
|
615
|
+
mse = MismatchedSet(nil)
|
616
|
+
recover(mse)
|
617
|
+
raise mse
|
618
|
+
end
|
619
|
+
|
620
|
+
|
621
|
+
|
622
|
+
when 2
|
623
|
+
# at line 120:31: '\\\\' .
|
624
|
+
match(?\\)
|
625
|
+
match_any
|
626
|
+
|
627
|
+
else
|
628
|
+
break # out of loop for decision 5
|
629
|
+
end
|
630
|
+
end # loop for decision 5
|
631
|
+
match(?\')
|
632
|
+
|
633
|
+
end
|
634
|
+
|
635
|
+
@state.type = type
|
636
|
+
@state.channel = channel
|
637
|
+
|
638
|
+
ensure
|
639
|
+
# -> uncomment the next line to manually enable rule tracing
|
640
|
+
# trace_out(__method__, 14)
|
641
|
+
|
642
|
+
end
|
643
|
+
|
644
|
+
# lexer rule comment! (COMMENT)
|
645
|
+
# (in Group.g)
|
646
|
+
def comment!
|
647
|
+
# -> uncomment the next line to manually enable rule tracing
|
648
|
+
# trace_in(__method__, 15)
|
649
|
+
|
650
|
+
type = COMMENT
|
651
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
652
|
+
|
653
|
+
|
654
|
+
# - - - - main rule block - - - -
|
655
|
+
# at line 125:3: ( ( '#' | '//' ) (~ '\\n' )* | '/*' ( . )* '*/' )
|
656
|
+
alt_10 = 2
|
657
|
+
look_10_0 = @input.peek(1)
|
658
|
+
|
659
|
+
if (look_10_0 == ?#)
|
660
|
+
alt_10 = 1
|
661
|
+
elsif (look_10_0 == ?/)
|
662
|
+
look_10_2 = @input.peek(2)
|
663
|
+
|
664
|
+
if (look_10_2 == ?/)
|
665
|
+
alt_10 = 1
|
666
|
+
elsif (look_10_2 == ?*)
|
667
|
+
alt_10 = 2
|
668
|
+
else
|
669
|
+
nvae = NoViableAlternative("", 10, 2)
|
670
|
+
raise nvae
|
671
|
+
end
|
672
|
+
else
|
673
|
+
nvae = NoViableAlternative("", 10, 0)
|
674
|
+
raise nvae
|
675
|
+
end
|
676
|
+
case alt_10
|
677
|
+
when 1
|
678
|
+
# at line 125:5: ( '#' | '//' ) (~ '\\n' )*
|
679
|
+
# at line 125:5: ( '#' | '//' )
|
680
|
+
alt_7 = 2
|
681
|
+
look_7_0 = @input.peek(1)
|
682
|
+
|
683
|
+
if (look_7_0 == ?#)
|
684
|
+
alt_7 = 1
|
685
|
+
elsif (look_7_0 == ?/)
|
686
|
+
alt_7 = 2
|
687
|
+
else
|
688
|
+
nvae = NoViableAlternative("", 7, 0)
|
689
|
+
raise nvae
|
690
|
+
end
|
691
|
+
case alt_7
|
692
|
+
when 1
|
693
|
+
# at line 125:7: '#'
|
694
|
+
match(?#)
|
695
|
+
|
696
|
+
when 2
|
697
|
+
# at line 125:13: '//'
|
698
|
+
match("//")
|
699
|
+
|
700
|
+
end
|
701
|
+
# at line 125:20: (~ '\\n' )*
|
702
|
+
loop do # decision 8
|
703
|
+
alt_8 = 2
|
704
|
+
look_8_0 = @input.peek(1)
|
705
|
+
|
706
|
+
if (look_8_0.between?(0x0000, ?\t) || look_8_0.between?(0x000B, 0xFFFF))
|
707
|
+
alt_8 = 1
|
708
|
+
|
709
|
+
end
|
710
|
+
case alt_8
|
711
|
+
when 1
|
712
|
+
# at line 125:20: ~ '\\n'
|
713
|
+
if @input.peek(1).between?(0x0000, ?\t) || @input.peek(1).between?(0x000B, 0x00FF)
|
714
|
+
@input.consume
|
715
|
+
else
|
716
|
+
mse = MismatchedSet(nil)
|
717
|
+
recover(mse)
|
718
|
+
raise mse
|
719
|
+
end
|
720
|
+
|
721
|
+
|
722
|
+
|
723
|
+
else
|
724
|
+
break # out of loop for decision 8
|
725
|
+
end
|
726
|
+
end # loop for decision 8
|
727
|
+
|
728
|
+
when 2
|
729
|
+
# at line 126:5: '/*' ( . )* '*/'
|
730
|
+
match("/*")
|
731
|
+
# at line 126:10: ( . )*
|
732
|
+
loop do # decision 9
|
733
|
+
alt_9 = 2
|
734
|
+
look_9_0 = @input.peek(1)
|
735
|
+
|
736
|
+
if (look_9_0 == ?*)
|
737
|
+
look_9_1 = @input.peek(2)
|
738
|
+
|
739
|
+
if (look_9_1 == ?/)
|
740
|
+
alt_9 = 2
|
741
|
+
elsif (look_9_1.between?(0x0000, ?.) || look_9_1.between?(?0, 0xFFFF))
|
742
|
+
alt_9 = 1
|
743
|
+
|
744
|
+
end
|
745
|
+
elsif (look_9_0.between?(0x0000, ?)) || look_9_0.between?(?+, 0xFFFF))
|
746
|
+
alt_9 = 1
|
747
|
+
|
748
|
+
end
|
749
|
+
case alt_9
|
750
|
+
when 1
|
751
|
+
# at line 126:10: .
|
752
|
+
match_any
|
753
|
+
|
754
|
+
else
|
755
|
+
break # out of loop for decision 9
|
756
|
+
end
|
757
|
+
end # loop for decision 9
|
758
|
+
match("*/")
|
759
|
+
|
760
|
+
end
|
761
|
+
|
762
|
+
@state.type = type
|
763
|
+
@state.channel = channel
|
764
|
+
# --> action
|
765
|
+
skip
|
766
|
+
# <-- action
|
767
|
+
ensure
|
768
|
+
# -> uncomment the next line to manually enable rule tracing
|
769
|
+
# trace_out(__method__, 15)
|
770
|
+
|
771
|
+
end
|
772
|
+
|
773
|
+
# lexer rule ws! (WS)
|
774
|
+
# (in Group.g)
|
775
|
+
def ws!
|
776
|
+
# -> uncomment the next line to manually enable rule tracing
|
777
|
+
# trace_in(__method__, 16)
|
778
|
+
|
779
|
+
type = WS
|
780
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
781
|
+
|
782
|
+
|
783
|
+
# - - - - main rule block - - - -
|
784
|
+
# at line 130:5: ( ' ' | '\\t' | '\\n' | '\\r' | '\\f' )+
|
785
|
+
# at file 130:5: ( ' ' | '\\t' | '\\n' | '\\r' | '\\f' )+
|
786
|
+
match_count_11 = 0
|
787
|
+
loop do
|
788
|
+
alt_11 = 2
|
789
|
+
look_11_0 = @input.peek(1)
|
790
|
+
|
791
|
+
if (look_11_0.between?(?\t, ?\n) || look_11_0.between?(?\f, ?\r) || look_11_0 == ?\s)
|
792
|
+
alt_11 = 1
|
793
|
+
|
794
|
+
end
|
795
|
+
case alt_11
|
796
|
+
when 1
|
797
|
+
# at line
|
798
|
+
if @input.peek(1).between?(?\t, ?\n) || @input.peek(1).between?(?\f, ?\r) || @input.peek(1) == ?\s
|
799
|
+
@input.consume
|
800
|
+
else
|
801
|
+
mse = MismatchedSet(nil)
|
802
|
+
recover(mse)
|
803
|
+
raise mse
|
804
|
+
end
|
805
|
+
|
806
|
+
|
807
|
+
|
808
|
+
else
|
809
|
+
match_count_11 > 0 and break
|
810
|
+
eee = EarlyExit(11)
|
811
|
+
|
812
|
+
|
813
|
+
raise eee
|
814
|
+
end
|
815
|
+
match_count_11 += 1
|
816
|
+
end
|
817
|
+
|
818
|
+
# --> action
|
819
|
+
skip
|
820
|
+
# <-- action
|
821
|
+
|
822
|
+
|
823
|
+
@state.type = type
|
824
|
+
@state.channel = channel
|
825
|
+
|
826
|
+
ensure
|
827
|
+
# -> uncomment the next line to manually enable rule tracing
|
828
|
+
# trace_out(__method__, 16)
|
829
|
+
|
830
|
+
end
|
831
|
+
|
832
|
+
# main rule used to study the input at the current position,
|
833
|
+
# and choose the proper lexer rule to call in order to
|
834
|
+
# fetch the next token
|
835
|
+
#
|
836
|
+
# usually, you don't make direct calls to this method,
|
837
|
+
# but instead use the next_token method, which will
|
838
|
+
# build and emit the actual next token
|
839
|
+
def token!
|
840
|
+
# at line 1:8: ( T__10 | T__11 | T__12 | T__13 | T__14 | T__15 | T__16 | T__17 | T__18 | T__19 | CONSTANT | ID | TEMPLATE | STRING | COMMENT | WS )
|
841
|
+
alt_12 = 16
|
842
|
+
alt_12 = @dfa12.predict(@input)
|
843
|
+
case alt_12
|
844
|
+
when 1
|
845
|
+
# at line 1:10: T__10
|
846
|
+
t__10!
|
847
|
+
|
848
|
+
when 2
|
849
|
+
# at line 1:16: T__11
|
850
|
+
t__11!
|
851
|
+
|
852
|
+
when 3
|
853
|
+
# at line 1:22: T__12
|
854
|
+
t__12!
|
855
|
+
|
856
|
+
when 4
|
857
|
+
# at line 1:28: T__13
|
858
|
+
t__13!
|
859
|
+
|
860
|
+
when 5
|
861
|
+
# at line 1:34: T__14
|
862
|
+
t__14!
|
863
|
+
|
864
|
+
when 6
|
865
|
+
# at line 1:40: T__15
|
866
|
+
t__15!
|
867
|
+
|
868
|
+
when 7
|
869
|
+
# at line 1:46: T__16
|
870
|
+
t__16!
|
871
|
+
|
872
|
+
when 8
|
873
|
+
# at line 1:52: T__17
|
874
|
+
t__17!
|
875
|
+
|
876
|
+
when 9
|
877
|
+
# at line 1:58: T__18
|
878
|
+
t__18!
|
879
|
+
|
880
|
+
when 10
|
881
|
+
# at line 1:64: T__19
|
882
|
+
t__19!
|
883
|
+
|
884
|
+
when 11
|
885
|
+
# at line 1:70: CONSTANT
|
886
|
+
constant!
|
887
|
+
|
888
|
+
when 12
|
889
|
+
# at line 1:79: ID
|
890
|
+
id!
|
891
|
+
|
892
|
+
when 13
|
893
|
+
# at line 1:82: TEMPLATE
|
894
|
+
template!
|
895
|
+
|
896
|
+
when 14
|
897
|
+
# at line 1:91: STRING
|
898
|
+
string!
|
899
|
+
|
900
|
+
when 15
|
901
|
+
# at line 1:98: COMMENT
|
902
|
+
comment!
|
903
|
+
|
904
|
+
when 16
|
905
|
+
# at line 1:106: WS
|
906
|
+
ws!
|
907
|
+
|
908
|
+
end
|
909
|
+
end
|
910
|
+
|
911
|
+
|
912
|
+
# - - - - - - - - - - DFA definitions - - - - - - - - - - -
|
913
|
+
class DFA12 < ANTLR3::DFA
|
914
|
+
EOT = unpack(1, -1, 1, 11, 14, -1, 1, 11, 1, 20, 1, 11, 2, -1, 1,
|
915
|
+
11, 1, 23, 1, -1)
|
916
|
+
EOF = unpack(24, -1)
|
917
|
+
MIN = unpack(1, 9, 1, 114, 1, 58, 13, -1, 1, 111, 1, 61, 1, 117, 2,
|
918
|
+
-1, 1, 112, 1, 48, 1, -1)
|
919
|
+
MAX = unpack(1, 122, 1, 114, 1, 58, 13, -1, 1, 111, 1, 61, 1, 117,
|
920
|
+
2, -1, 1, 112, 1, 122, 1, -1)
|
921
|
+
ACCEPT = unpack(3, -1, 1, 3, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10,
|
922
|
+
1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 3, -1, 1,
|
923
|
+
4, 1, 2, 2, -1, 1, 1)
|
924
|
+
SPECIAL = unpack(24, -1)
|
925
|
+
TRANSITION = [
|
926
|
+
unpack(2, 15, 1, -1, 2, 15, 18, -1, 1, 15, 1, -1, 1, 13, 1, 14,
|
927
|
+
2, -1, 1, 8, 1, 13, 1, 4, 1, 5, 1, 7, 1, -1, 1, 6, 2, -1,
|
928
|
+
1, 14, 10, -1, 1, 2, 1, 3, 1, 12, 1, 9, 3, -1, 26, 10, 4,
|
929
|
+
-1, 1, 11, 1, -1, 6, 11, 1, 1, 19, 11),
|
930
|
+
unpack(1, 16),
|
931
|
+
unpack(1, 17),
|
932
|
+
unpack(),
|
933
|
+
unpack(),
|
934
|
+
unpack(),
|
935
|
+
unpack(),
|
936
|
+
unpack(),
|
937
|
+
unpack(),
|
938
|
+
unpack(),
|
939
|
+
unpack(),
|
940
|
+
unpack(),
|
941
|
+
unpack(),
|
942
|
+
unpack(),
|
943
|
+
unpack(),
|
944
|
+
unpack(),
|
945
|
+
unpack(1, 18),
|
946
|
+
unpack(1, 19),
|
947
|
+
unpack(1, 21),
|
948
|
+
unpack(),
|
949
|
+
unpack(),
|
950
|
+
unpack(1, 22),
|
951
|
+
unpack(10, 11, 7, -1, 26, 11, 4, -1, 1, 11, 1, -1, 26, 11),
|
952
|
+
unpack()
|
953
|
+
].freeze
|
954
|
+
|
955
|
+
( 0 ... MIN.length ).zip( MIN, MAX ) do | i, a, z |
|
956
|
+
if a > 0 and z < 0
|
957
|
+
MAX[ i ] %= 0x10000
|
958
|
+
end
|
959
|
+
end
|
960
|
+
|
961
|
+
@decision = 12
|
962
|
+
|
963
|
+
|
964
|
+
def description
|
965
|
+
<<-'__dfa_description__'.strip!
|
966
|
+
1:1: Tokens : ( T__10 | T__11 | T__12 | T__13 | T__14 | T__15 | T__16 | T__17 | T__18 | T__19 | CONSTANT | ID | TEMPLATE | STRING | COMMENT | WS );
|
967
|
+
__dfa_description__
|
968
|
+
end
|
969
|
+
end
|
970
|
+
|
971
|
+
|
972
|
+
private
|
973
|
+
|
974
|
+
def initialize_dfas
|
975
|
+
super rescue nil
|
976
|
+
@dfa12 = DFA12.new(self, 12)
|
977
|
+
|
978
|
+
end
|
979
|
+
end # class Lexer < ANTLR3::Lexer
|
980
|
+
|
981
|
+
at_exit { Lexer.main(ARGV) } if __FILE__ == $0
|
982
|
+
end
|
983
|
+
# - - - - - - begin action @lexer::footer - - - - - -
|
984
|
+
# Group.g
|
985
|
+
|
986
|
+
|
987
|
+
end # module Template
|
988
|
+
end # module ANTLR3
|
989
|
+
|
990
|
+
# - - - - - - end action @lexer::footer - - - - - - -
|
991
|
+
|
992
|
+
|