zunscript 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ require "zunscript/lexer"
2
+ require "zunscript/parser"
File without changes
@@ -0,0 +1,1240 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # ZunScript.g
4
+ # --
5
+ # Generated using ANTLR version: 3.5
6
+ # Ruby runtime library version: 1.10.0
7
+ # Input grammar file: ZunScript.g
8
+ # Generated at: 2015-04-29 05:09:24
9
+ #
10
+
11
+ # ~~~> start load path setup
12
+ this_directory = File.expand_path( File.dirname( __FILE__ ) )
13
+ $LOAD_PATH.unshift( this_directory ) unless $LOAD_PATH.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.10.0):
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
+ defined?( gem ) and gem( 'antlr3', '~> 1.10.0' )
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
+ module ZunScript
60
+ # TokenData defines all of the token type integer values
61
+ # as constants, which will be included in all
62
+ # ANTLR-generated recognizers.
63
+ const_defined?( :TokenData ) or TokenData = ANTLR3::TokenScheme.new
64
+
65
+ module TokenData
66
+
67
+ # define the token constants
68
+ define_tokens( :EOF => -1, :T__38 => 38, :ARITH_SIGN => 4, :ASSIGN => 5,
69
+ :BANG => 6, :BIND => 7, :BLK => 8, :BLOCK_END => 9, :BLOCK_LEFT => 10,
70
+ :BLOCK_RIGHT => 11, :BODY => 12, :COMMA => 13, :COMMENT => 14,
71
+ :DIGIT => 15, :FLOAT => 16, :INDEX => 17, :INTEGER => 18,
72
+ :INVOKE => 19, :LEFTBLOCK => 20, :LETTER => 21, :LOWER => 22,
73
+ :LPAREN => 23, :NAME => 24, :NEWLINE => 25, :NONCONTROL_CHAR => 26,
74
+ :NUM => 27, :NUMBER => 28, :PARAM => 29, :RPAREN => 30,
75
+ :SPACE => 31, :STR => 32, :STRING => 33, :SYMBOL => 34,
76
+ :UPPER => 35, :VARIABLE => 36, :WHITESPACE => 37 )
77
+
78
+ end
79
+
80
+
81
+ class Lexer < ANTLR3::Lexer
82
+ @grammar_home = ZunScript
83
+ include TokenData
84
+
85
+ begin
86
+ generated_using( "ZunScript.g", "3.5", "1.10.0" )
87
+ rescue NoMethodError => error
88
+ # ignore
89
+ end
90
+
91
+ RULE_NAMES = [ "T__38", "ASSIGN", "BLOCK_LEFT", "BLOCK_RIGHT", "ARITH_SIGN",
92
+ "BANG", "COMMENT", "BLOCK_END", "COMMA", "LPAREN",
93
+ "RPAREN", "NONCONTROL_CHAR", "LETTER", "LOWER", "UPPER",
94
+ "DIGIT", "SYMBOL", "FLOAT", "INTEGER", "NAME", "STRING",
95
+ "NUMBER", "SPACE", "NEWLINE", "WHITESPACE" ].freeze
96
+ RULE_METHODS = [ :t__38!, :assign!, :block_left!, :block_right!, :arith_sign!,
97
+ :bang!, :comment!, :block_end!, :comma!, :lparen!,
98
+ :rparen!, :noncontrol_char!, :letter!, :lower!, :upper!,
99
+ :digit!, :symbol!, :float!, :integer!, :name!, :string!,
100
+ :number!, :space!, :newline!, :whitespace! ].freeze
101
+
102
+ def initialize( input=nil, options = {} )
103
+ super( input, options )
104
+ end
105
+
106
+
107
+ # - - - - - - - - - - - lexer rules - - - - - - - - - - - -
108
+ # lexer rule t__38! (T__38)
109
+ # (in ZunScript.g)
110
+ def t__38!
111
+ # -> uncomment the next line to manually enable rule tracing
112
+ # trace_in( __method__, 1 )
113
+
114
+
115
+
116
+ type = T__38
117
+ channel = ANTLR3::DEFAULT_CHANNEL
118
+ # - - - - label initialization - - - -
119
+
120
+
121
+ # - - - - main rule block - - - -
122
+ # at line 7:9: '.'
123
+ match( 0x2e )
124
+
125
+
126
+ @state.type = type
127
+ @state.channel = channel
128
+ ensure
129
+ # -> uncomment the next line to manually enable rule tracing
130
+ # trace_out( __method__, 1 )
131
+
132
+
133
+ end
134
+
135
+ # lexer rule assign! (ASSIGN)
136
+ # (in ZunScript.g)
137
+ def assign!
138
+ # -> uncomment the next line to manually enable rule tracing
139
+ # trace_in( __method__, 2 )
140
+
141
+
142
+
143
+ type = ASSIGN
144
+ channel = ANTLR3::DEFAULT_CHANNEL
145
+ # - - - - label initialization - - - -
146
+
147
+
148
+ # - - - - main rule block - - - -
149
+ # at line 20:9: '='
150
+ match( 0x3d )
151
+
152
+
153
+ @state.type = type
154
+ @state.channel = channel
155
+ ensure
156
+ # -> uncomment the next line to manually enable rule tracing
157
+ # trace_out( __method__, 2 )
158
+
159
+
160
+ end
161
+
162
+ # lexer rule block_left! (BLOCK_LEFT)
163
+ # (in ZunScript.g)
164
+ def block_left!
165
+ # -> uncomment the next line to manually enable rule tracing
166
+ # trace_in( __method__, 3 )
167
+
168
+
169
+
170
+ type = BLOCK_LEFT
171
+ channel = ANTLR3::DEFAULT_CHANNEL
172
+ # - - - - label initialization - - - -
173
+
174
+
175
+ # - - - - main rule block - - - -
176
+ # at line 21:13: '<'
177
+ match( 0x3c )
178
+
179
+
180
+ @state.type = type
181
+ @state.channel = channel
182
+ ensure
183
+ # -> uncomment the next line to manually enable rule tracing
184
+ # trace_out( __method__, 3 )
185
+
186
+
187
+ end
188
+
189
+ # lexer rule block_right! (BLOCK_RIGHT)
190
+ # (in ZunScript.g)
191
+ def block_right!
192
+ # -> uncomment the next line to manually enable rule tracing
193
+ # trace_in( __method__, 4 )
194
+
195
+
196
+
197
+ type = BLOCK_RIGHT
198
+ channel = ANTLR3::DEFAULT_CHANNEL
199
+ # - - - - label initialization - - - -
200
+
201
+
202
+ # - - - - main rule block - - - -
203
+ # at line 22:14: '>'
204
+ match( 0x3e )
205
+
206
+
207
+ @state.type = type
208
+ @state.channel = channel
209
+ ensure
210
+ # -> uncomment the next line to manually enable rule tracing
211
+ # trace_out( __method__, 4 )
212
+
213
+
214
+ end
215
+
216
+ # lexer rule arith_sign! (ARITH_SIGN)
217
+ # (in ZunScript.g)
218
+ def arith_sign!
219
+ # -> uncomment the next line to manually enable rule tracing
220
+ # trace_in( __method__, 5 )
221
+
222
+
223
+
224
+ type = ARITH_SIGN
225
+ channel = ANTLR3::DEFAULT_CHANNEL
226
+ # - - - - label initialization - - - -
227
+
228
+
229
+ # - - - - main rule block - - - -
230
+ # at line
231
+ if @input.peek( 1 ).between?( 0x2a, 0x2b ) || @input.peek(1) == 0x2d || @input.peek(1) == 0x2f || @input.peek(1) == 0x5e
232
+ @input.consume
233
+ else
234
+ mse = MismatchedSet( nil )
235
+ recover mse
236
+ raise mse
237
+
238
+ end
239
+
240
+
241
+
242
+
243
+ @state.type = type
244
+ @state.channel = channel
245
+ ensure
246
+ # -> uncomment the next line to manually enable rule tracing
247
+ # trace_out( __method__, 5 )
248
+
249
+
250
+ end
251
+
252
+ # lexer rule bang! (BANG)
253
+ # (in ZunScript.g)
254
+ def bang!
255
+ # -> uncomment the next line to manually enable rule tracing
256
+ # trace_in( __method__, 6 )
257
+
258
+
259
+
260
+ type = BANG
261
+ channel = ANTLR3::DEFAULT_CHANNEL
262
+ # - - - - label initialization - - - -
263
+
264
+
265
+ # - - - - main rule block - - - -
266
+ # at line 24:7: '!'
267
+ match( 0x21 )
268
+
269
+
270
+ @state.type = type
271
+ @state.channel = channel
272
+ ensure
273
+ # -> uncomment the next line to manually enable rule tracing
274
+ # trace_out( __method__, 6 )
275
+
276
+
277
+ end
278
+
279
+ # lexer rule comment! (COMMENT)
280
+ # (in ZunScript.g)
281
+ def comment!
282
+ # -> uncomment the next line to manually enable rule tracing
283
+ # trace_in( __method__, 7 )
284
+
285
+
286
+
287
+ type = COMMENT
288
+ channel = ANTLR3::DEFAULT_CHANNEL
289
+ # - - - - label initialization - - - -
290
+
291
+
292
+ # - - - - main rule block - - - -
293
+ # at line 25:10: '#'
294
+ match( 0x23 )
295
+
296
+
297
+ @state.type = type
298
+ @state.channel = channel
299
+ ensure
300
+ # -> uncomment the next line to manually enable rule tracing
301
+ # trace_out( __method__, 7 )
302
+
303
+
304
+ end
305
+
306
+ # lexer rule block_end! (BLOCK_END)
307
+ # (in ZunScript.g)
308
+ def block_end!
309
+ # -> uncomment the next line to manually enable rule tracing
310
+ # trace_in( __method__, 8 )
311
+
312
+
313
+
314
+ type = BLOCK_END
315
+ channel = ANTLR3::DEFAULT_CHANNEL
316
+ # - - - - label initialization - - - -
317
+
318
+
319
+ # - - - - main rule block - - - -
320
+ # at line 26:12: 'end'
321
+ match( "end" )
322
+
323
+
324
+
325
+ @state.type = type
326
+ @state.channel = channel
327
+ ensure
328
+ # -> uncomment the next line to manually enable rule tracing
329
+ # trace_out( __method__, 8 )
330
+
331
+
332
+ end
333
+
334
+ # lexer rule comma! (COMMA)
335
+ # (in ZunScript.g)
336
+ def comma!
337
+ # -> uncomment the next line to manually enable rule tracing
338
+ # trace_in( __method__, 9 )
339
+
340
+
341
+
342
+ type = COMMA
343
+ channel = ANTLR3::DEFAULT_CHANNEL
344
+ # - - - - label initialization - - - -
345
+
346
+
347
+ # - - - - main rule block - - - -
348
+ # at line 28:8: ','
349
+ match( 0x2c )
350
+
351
+
352
+ @state.type = type
353
+ @state.channel = channel
354
+ ensure
355
+ # -> uncomment the next line to manually enable rule tracing
356
+ # trace_out( __method__, 9 )
357
+
358
+
359
+ end
360
+
361
+ # lexer rule lparen! (LPAREN)
362
+ # (in ZunScript.g)
363
+ def lparen!
364
+ # -> uncomment the next line to manually enable rule tracing
365
+ # trace_in( __method__, 10 )
366
+
367
+
368
+
369
+ type = LPAREN
370
+ channel = ANTLR3::DEFAULT_CHANNEL
371
+ # - - - - label initialization - - - -
372
+
373
+
374
+ # - - - - main rule block - - - -
375
+ # at line 29:9: '('
376
+ match( 0x28 )
377
+
378
+
379
+ @state.type = type
380
+ @state.channel = channel
381
+ ensure
382
+ # -> uncomment the next line to manually enable rule tracing
383
+ # trace_out( __method__, 10 )
384
+
385
+
386
+ end
387
+
388
+ # lexer rule rparen! (RPAREN)
389
+ # (in ZunScript.g)
390
+ def rparen!
391
+ # -> uncomment the next line to manually enable rule tracing
392
+ # trace_in( __method__, 11 )
393
+
394
+
395
+
396
+ type = RPAREN
397
+ channel = ANTLR3::DEFAULT_CHANNEL
398
+ # - - - - label initialization - - - -
399
+
400
+
401
+ # - - - - main rule block - - - -
402
+ # at line 30:9: ')'
403
+ match( 0x29 )
404
+
405
+
406
+ @state.type = type
407
+ @state.channel = channel
408
+ ensure
409
+ # -> uncomment the next line to manually enable rule tracing
410
+ # trace_out( __method__, 11 )
411
+
412
+
413
+ end
414
+
415
+ # lexer rule noncontrol_char! (NONCONTROL_CHAR)
416
+ # (in ZunScript.g)
417
+ def noncontrol_char!
418
+ # -> uncomment the next line to manually enable rule tracing
419
+ # trace_in( __method__, 12 )
420
+
421
+
422
+ # - - - - label initialization - - - -
423
+
424
+
425
+ # - - - - main rule block - - - -
426
+ # at line
427
+ if @input.peek(1) == 0x9 || @input.peek( 1 ).between?( 0x20, 0x21 ) || @input.peek( 1 ).between?( 0x23, 0x7e )
428
+ @input.consume
429
+ else
430
+ mse = MismatchedSet( nil )
431
+ recover mse
432
+ raise mse
433
+
434
+ end
435
+
436
+
437
+
438
+ ensure
439
+ # -> uncomment the next line to manually enable rule tracing
440
+ # trace_out( __method__, 12 )
441
+
442
+
443
+ end
444
+
445
+ # lexer rule letter! (LETTER)
446
+ # (in ZunScript.g)
447
+ def letter!
448
+ # -> uncomment the next line to manually enable rule tracing
449
+ # trace_in( __method__, 13 )
450
+
451
+
452
+ # - - - - label initialization - - - -
453
+
454
+
455
+ # - - - - main rule block - - - -
456
+ # at line
457
+ if @input.peek( 1 ).between?( 0x41, 0x5a ) || @input.peek( 1 ).between?( 0x61, 0x7a )
458
+ @input.consume
459
+ else
460
+ mse = MismatchedSet( nil )
461
+ recover mse
462
+ raise mse
463
+
464
+ end
465
+
466
+
467
+
468
+ ensure
469
+ # -> uncomment the next line to manually enable rule tracing
470
+ # trace_out( __method__, 13 )
471
+
472
+
473
+ end
474
+
475
+ # lexer rule lower! (LOWER)
476
+ # (in ZunScript.g)
477
+ def lower!
478
+ # -> uncomment the next line to manually enable rule tracing
479
+ # trace_in( __method__, 14 )
480
+
481
+
482
+ # - - - - label initialization - - - -
483
+
484
+
485
+ # - - - - main rule block - - - -
486
+ # at line
487
+ if @input.peek( 1 ).between?( 0x61, 0x7a )
488
+ @input.consume
489
+ else
490
+ mse = MismatchedSet( nil )
491
+ recover mse
492
+ raise mse
493
+
494
+ end
495
+
496
+
497
+
498
+ ensure
499
+ # -> uncomment the next line to manually enable rule tracing
500
+ # trace_out( __method__, 14 )
501
+
502
+
503
+ end
504
+
505
+ # lexer rule upper! (UPPER)
506
+ # (in ZunScript.g)
507
+ def upper!
508
+ # -> uncomment the next line to manually enable rule tracing
509
+ # trace_in( __method__, 15 )
510
+
511
+
512
+ # - - - - label initialization - - - -
513
+
514
+
515
+ # - - - - main rule block - - - -
516
+ # at line
517
+ if @input.peek( 1 ).between?( 0x41, 0x5a )
518
+ @input.consume
519
+ else
520
+ mse = MismatchedSet( nil )
521
+ recover mse
522
+ raise mse
523
+
524
+ end
525
+
526
+
527
+
528
+ ensure
529
+ # -> uncomment the next line to manually enable rule tracing
530
+ # trace_out( __method__, 15 )
531
+
532
+
533
+ end
534
+
535
+ # lexer rule digit! (DIGIT)
536
+ # (in ZunScript.g)
537
+ def digit!
538
+ # -> uncomment the next line to manually enable rule tracing
539
+ # trace_in( __method__, 16 )
540
+
541
+
542
+ # - - - - label initialization - - - -
543
+
544
+
545
+ # - - - - main rule block - - - -
546
+ # at line
547
+ if @input.peek( 1 ).between?( 0x30, 0x39 )
548
+ @input.consume
549
+ else
550
+ mse = MismatchedSet( nil )
551
+ recover mse
552
+ raise mse
553
+
554
+ end
555
+
556
+
557
+
558
+ ensure
559
+ # -> uncomment the next line to manually enable rule tracing
560
+ # trace_out( __method__, 16 )
561
+
562
+
563
+ end
564
+
565
+ # lexer rule symbol! (SYMBOL)
566
+ # (in ZunScript.g)
567
+ def symbol!
568
+ # -> uncomment the next line to manually enable rule tracing
569
+ # trace_in( __method__, 17 )
570
+
571
+
572
+ # - - - - label initialization - - - -
573
+
574
+
575
+ # - - - - main rule block - - - -
576
+ # at line
577
+ if @input.peek(1) == 0x21 || @input.peek( 1 ).between?( 0x23, 0x2f ) || @input.peek( 1 ).between?( 0x3a, 0x40 ) || @input.peek( 1 ).between?( 0x5b, 0x60 ) || @input.peek( 1 ).between?( 0x7b, 0x7e )
578
+ @input.consume
579
+ else
580
+ mse = MismatchedSet( nil )
581
+ recover mse
582
+ raise mse
583
+
584
+ end
585
+
586
+
587
+
588
+ ensure
589
+ # -> uncomment the next line to manually enable rule tracing
590
+ # trace_out( __method__, 17 )
591
+
592
+
593
+ end
594
+
595
+ # lexer rule float! (FLOAT)
596
+ # (in ZunScript.g)
597
+ def float!
598
+ # -> uncomment the next line to manually enable rule tracing
599
+ # trace_in( __method__, 18 )
600
+
601
+
602
+ # - - - - label initialization - - - -
603
+
604
+
605
+ # - - - - main rule block - - - -
606
+ # at line 39:17: INTEGER '.' ( '0' .. '9' )+
607
+ integer!
608
+
609
+ match( 0x2e )
610
+ # at file 39:29: ( '0' .. '9' )+
611
+ match_count_1 = 0
612
+ while true
613
+ alt_1 = 2
614
+ look_1_0 = @input.peek( 1 )
615
+
616
+ if ( look_1_0.between?( 0x30, 0x39 ) )
617
+ alt_1 = 1
618
+
619
+ end
620
+ case alt_1
621
+ when 1
622
+ # at line
623
+ if @input.peek( 1 ).between?( 0x30, 0x39 )
624
+ @input.consume
625
+ else
626
+ mse = MismatchedSet( nil )
627
+ recover mse
628
+ raise mse
629
+
630
+ end
631
+
632
+
633
+
634
+ else
635
+ match_count_1 > 0 and break
636
+ eee = EarlyExit(1)
637
+
638
+
639
+ raise eee
640
+ end
641
+ match_count_1 += 1
642
+ end
643
+
644
+
645
+
646
+ ensure
647
+ # -> uncomment the next line to manually enable rule tracing
648
+ # trace_out( __method__, 18 )
649
+
650
+
651
+ end
652
+
653
+ # lexer rule integer! (INTEGER)
654
+ # (in ZunScript.g)
655
+ def integer!
656
+ # -> uncomment the next line to manually enable rule tracing
657
+ # trace_in( __method__, 19 )
658
+
659
+
660
+ # - - - - label initialization - - - -
661
+
662
+
663
+ # - - - - main rule block - - - -
664
+ # at line 40:17: ( '0' | ( '-' )? '1' .. '9' ( '0' .. '9' )* )
665
+ alt_4 = 2
666
+ look_4_0 = @input.peek( 1 )
667
+
668
+ if ( look_4_0 == 0x30 )
669
+ alt_4 = 1
670
+ elsif ( look_4_0 == 0x2d || look_4_0.between?( 0x31, 0x39 ) )
671
+ alt_4 = 2
672
+ else
673
+ raise NoViableAlternative( "", 4, 0 )
674
+
675
+ end
676
+ case alt_4
677
+ when 1
678
+ # at line 40:19: '0'
679
+ match( 0x30 )
680
+
681
+ when 2
682
+ # at line 40:25: ( '-' )? '1' .. '9' ( '0' .. '9' )*
683
+ # at line 40:25: ( '-' )?
684
+ alt_2 = 2
685
+ look_2_0 = @input.peek( 1 )
686
+
687
+ if ( look_2_0 == 0x2d )
688
+ alt_2 = 1
689
+ end
690
+ case alt_2
691
+ when 1
692
+ # at line 40:25: '-'
693
+ match( 0x2d )
694
+
695
+ end
696
+ match_range( 0x31, 0x39 )
697
+ # at line 40:39: ( '0' .. '9' )*
698
+ while true # decision 3
699
+ alt_3 = 2
700
+ look_3_0 = @input.peek( 1 )
701
+
702
+ if ( look_3_0.between?( 0x30, 0x39 ) )
703
+ alt_3 = 1
704
+
705
+ end
706
+ case alt_3
707
+ when 1
708
+ # at line
709
+ if @input.peek( 1 ).between?( 0x30, 0x39 )
710
+ @input.consume
711
+ else
712
+ mse = MismatchedSet( nil )
713
+ recover mse
714
+ raise mse
715
+
716
+ end
717
+
718
+
719
+
720
+ else
721
+ break # out of loop for decision 3
722
+ end
723
+ end # loop for decision 3
724
+
725
+
726
+ end
727
+ ensure
728
+ # -> uncomment the next line to manually enable rule tracing
729
+ # trace_out( __method__, 19 )
730
+
731
+
732
+ end
733
+
734
+ # lexer rule name! (NAME)
735
+ # (in ZunScript.g)
736
+ def name!
737
+ # -> uncomment the next line to manually enable rule tracing
738
+ # trace_in( __method__, 20 )
739
+
740
+
741
+
742
+ type = NAME
743
+ channel = ANTLR3::DEFAULT_CHANNEL
744
+ # - - - - label initialization - - - -
745
+
746
+
747
+ # - - - - main rule block - - - -
748
+ # at line 42:7: LETTER ( LETTER | DIGIT | '_' | '?' )*
749
+ letter!
750
+
751
+ # at line 42:14: ( LETTER | DIGIT | '_' | '?' )*
752
+ while true # decision 5
753
+ alt_5 = 2
754
+ look_5_0 = @input.peek( 1 )
755
+
756
+ if ( look_5_0.between?( 0x30, 0x39 ) || look_5_0 == 0x3f || look_5_0.between?( 0x41, 0x5a ) || look_5_0 == 0x5f || look_5_0.between?( 0x61, 0x7a ) )
757
+ alt_5 = 1
758
+
759
+ end
760
+ case alt_5
761
+ when 1
762
+ # at line
763
+ if @input.peek( 1 ).between?( 0x30, 0x39 ) || @input.peek(1) == 0x3f || @input.peek( 1 ).between?( 0x41, 0x5a ) || @input.peek(1) == 0x5f || @input.peek( 1 ).between?( 0x61, 0x7a )
764
+ @input.consume
765
+ else
766
+ mse = MismatchedSet( nil )
767
+ recover mse
768
+ raise mse
769
+
770
+ end
771
+
772
+
773
+
774
+ else
775
+ break # out of loop for decision 5
776
+ end
777
+ end # loop for decision 5
778
+
779
+
780
+
781
+ @state.type = type
782
+ @state.channel = channel
783
+ ensure
784
+ # -> uncomment the next line to manually enable rule tracing
785
+ # trace_out( __method__, 20 )
786
+
787
+
788
+ end
789
+
790
+ # lexer rule string! (STRING)
791
+ # (in ZunScript.g)
792
+ def string!
793
+ # -> uncomment the next line to manually enable rule tracing
794
+ # trace_in( __method__, 21 )
795
+
796
+
797
+
798
+ type = STRING
799
+ channel = ANTLR3::DEFAULT_CHANNEL
800
+ # - - - - label initialization - - - -
801
+
802
+
803
+ # - - - - main rule block - - - -
804
+ # at line 43:9: '\"' ( NONCONTROL_CHAR )* '\"'
805
+ match( 0x22 )
806
+ # at line 43:13: ( NONCONTROL_CHAR )*
807
+ while true # decision 6
808
+ alt_6 = 2
809
+ look_6_0 = @input.peek( 1 )
810
+
811
+ if ( look_6_0 == 0x9 || look_6_0.between?( 0x20, 0x21 ) || look_6_0.between?( 0x23, 0x7e ) )
812
+ alt_6 = 1
813
+
814
+ end
815
+ case alt_6
816
+ when 1
817
+ # at line
818
+ if @input.peek(1) == 0x9 || @input.peek( 1 ).between?( 0x20, 0x21 ) || @input.peek( 1 ).between?( 0x23, 0x7e )
819
+ @input.consume
820
+ else
821
+ mse = MismatchedSet( nil )
822
+ recover mse
823
+ raise mse
824
+
825
+ end
826
+
827
+
828
+
829
+ else
830
+ break # out of loop for decision 6
831
+ end
832
+ end # loop for decision 6
833
+
834
+ match( 0x22 )
835
+
836
+
837
+ @state.type = type
838
+ @state.channel = channel
839
+ ensure
840
+ # -> uncomment the next line to manually enable rule tracing
841
+ # trace_out( __method__, 21 )
842
+
843
+
844
+ end
845
+
846
+ # lexer rule number! (NUMBER)
847
+ # (in ZunScript.g)
848
+ def number!
849
+ # -> uncomment the next line to manually enable rule tracing
850
+ # trace_in( __method__, 22 )
851
+
852
+
853
+
854
+ type = NUMBER
855
+ channel = ANTLR3::DEFAULT_CHANNEL
856
+ # - - - - label initialization - - - -
857
+
858
+
859
+ # - - - - main rule block - - - -
860
+ # at line 44:7: ( INTEGER | FLOAT )
861
+ alt_7 = 2
862
+ alt_7 = @dfa7.predict( @input )
863
+ case alt_7
864
+ when 1
865
+ # at line 44:9: INTEGER
866
+ integer!
867
+
868
+
869
+ when 2
870
+ # at line 44:19: FLOAT
871
+ float!
872
+
873
+
874
+ end
875
+
876
+ @state.type = type
877
+ @state.channel = channel
878
+ ensure
879
+ # -> uncomment the next line to manually enable rule tracing
880
+ # trace_out( __method__, 22 )
881
+
882
+
883
+ end
884
+
885
+ # lexer rule space! (SPACE)
886
+ # (in ZunScript.g)
887
+ def space!
888
+ # -> uncomment the next line to manually enable rule tracing
889
+ # trace_in( __method__, 23 )
890
+
891
+
892
+ # - - - - label initialization - - - -
893
+
894
+
895
+ # - - - - main rule block - - - -
896
+ # at line
897
+ if @input.peek(1) == 0x9 || @input.peek(1) == 0x20
898
+ @input.consume
899
+ else
900
+ mse = MismatchedSet( nil )
901
+ recover mse
902
+ raise mse
903
+
904
+ end
905
+
906
+
907
+
908
+ ensure
909
+ # -> uncomment the next line to manually enable rule tracing
910
+ # trace_out( __method__, 23 )
911
+
912
+
913
+ end
914
+
915
+ # lexer rule newline! (NEWLINE)
916
+ # (in ZunScript.g)
917
+ def newline!
918
+ # -> uncomment the next line to manually enable rule tracing
919
+ # trace_in( __method__, 24 )
920
+
921
+
922
+
923
+ type = NEWLINE
924
+ channel = ANTLR3::DEFAULT_CHANNEL
925
+ # - - - - label initialization - - - -
926
+
927
+
928
+ # - - - - main rule block - - - -
929
+ # at line 47:10: ( ( '\\r' )? '\\n' )+
930
+ # at file 47:10: ( ( '\\r' )? '\\n' )+
931
+ match_count_9 = 0
932
+ while true
933
+ alt_9 = 2
934
+ look_9_0 = @input.peek( 1 )
935
+
936
+ if ( look_9_0 == 0xa || look_9_0 == 0xd )
937
+ alt_9 = 1
938
+
939
+ end
940
+ case alt_9
941
+ when 1
942
+ # at line 47:11: ( '\\r' )? '\\n'
943
+ # at line 47:11: ( '\\r' )?
944
+ alt_8 = 2
945
+ look_8_0 = @input.peek( 1 )
946
+
947
+ if ( look_8_0 == 0xd )
948
+ alt_8 = 1
949
+ end
950
+ case alt_8
951
+ when 1
952
+ # at line 47:11: '\\r'
953
+ match( 0xd )
954
+
955
+ end
956
+ match( 0xa )
957
+
958
+ else
959
+ match_count_9 > 0 and break
960
+ eee = EarlyExit(9)
961
+
962
+
963
+ raise eee
964
+ end
965
+ match_count_9 += 1
966
+ end
967
+
968
+
969
+
970
+
971
+ @state.type = type
972
+ @state.channel = channel
973
+ ensure
974
+ # -> uncomment the next line to manually enable rule tracing
975
+ # trace_out( __method__, 24 )
976
+
977
+
978
+ end
979
+
980
+ # lexer rule whitespace! (WHITESPACE)
981
+ # (in ZunScript.g)
982
+ def whitespace!
983
+ # -> uncomment the next line to manually enable rule tracing
984
+ # trace_in( __method__, 25 )
985
+
986
+
987
+
988
+ type = WHITESPACE
989
+ channel = ANTLR3::DEFAULT_CHANNEL
990
+ # - - - - label initialization - - - -
991
+
992
+
993
+ # - - - - main rule block - - - -
994
+ # at line 48:13: ( SPACE )+
995
+ # at file 48:13: ( SPACE )+
996
+ match_count_10 = 0
997
+ while true
998
+ alt_10 = 2
999
+ look_10_0 = @input.peek( 1 )
1000
+
1001
+ if ( look_10_0 == 0x9 || look_10_0 == 0x20 )
1002
+ alt_10 = 1
1003
+
1004
+ end
1005
+ case alt_10
1006
+ when 1
1007
+ # at line
1008
+ if @input.peek(1) == 0x9 || @input.peek(1) == 0x20
1009
+ @input.consume
1010
+ else
1011
+ mse = MismatchedSet( nil )
1012
+ recover mse
1013
+ raise mse
1014
+
1015
+ end
1016
+
1017
+
1018
+
1019
+ else
1020
+ match_count_10 > 0 and break
1021
+ eee = EarlyExit(10)
1022
+
1023
+
1024
+ raise eee
1025
+ end
1026
+ match_count_10 += 1
1027
+ end
1028
+
1029
+
1030
+
1031
+ # --> action
1032
+ channel = HIDDEN;
1033
+ # <-- action
1034
+
1035
+
1036
+
1037
+ @state.type = type
1038
+ @state.channel = channel
1039
+ ensure
1040
+ # -> uncomment the next line to manually enable rule tracing
1041
+ # trace_out( __method__, 25 )
1042
+
1043
+
1044
+ end
1045
+
1046
+ # main rule used to study the input at the current position,
1047
+ # and choose the proper lexer rule to call in order to
1048
+ # fetch the next token
1049
+ #
1050
+ # usually, you don't make direct calls to this method,
1051
+ # but instead use the next_token method, which will
1052
+ # build and emit the actual next token
1053
+ def token!
1054
+ # at line 1:8: ( T__38 | ASSIGN | BLOCK_LEFT | BLOCK_RIGHT | ARITH_SIGN | BANG | COMMENT | BLOCK_END | COMMA | LPAREN | RPAREN | NAME | STRING | NUMBER | NEWLINE | WHITESPACE )
1055
+ alt_11 = 16
1056
+ case look_11 = @input.peek( 1 )
1057
+ when 0x2e then alt_11 = 1
1058
+ when 0x3d then alt_11 = 2
1059
+ when 0x3c then alt_11 = 3
1060
+ when 0x3e then alt_11 = 4
1061
+ when 0x2d then look_11_5 = @input.peek( 2 )
1062
+
1063
+ if ( look_11_5.between?( 0x31, 0x39 ) )
1064
+ alt_11 = 14
1065
+ else
1066
+ alt_11 = 5
1067
+
1068
+ end
1069
+ when 0x21 then alt_11 = 6
1070
+ when 0x23 then alt_11 = 7
1071
+ when 0x65 then look_11_8 = @input.peek( 2 )
1072
+
1073
+ if ( look_11_8 == 0x6e )
1074
+ look_11_18 = @input.peek( 3 )
1075
+
1076
+ if ( look_11_18 == 0x64 )
1077
+ look_11_19 = @input.peek( 4 )
1078
+
1079
+ if ( look_11_19.between?( 0x30, 0x39 ) || look_11_19 == 0x3f || look_11_19.between?( 0x41, 0x5a ) || look_11_19 == 0x5f || look_11_19.between?( 0x61, 0x7a ) )
1080
+ alt_11 = 12
1081
+ else
1082
+ alt_11 = 8
1083
+
1084
+ end
1085
+ else
1086
+ alt_11 = 12
1087
+
1088
+ end
1089
+ else
1090
+ alt_11 = 12
1091
+
1092
+ end
1093
+ when 0x2c then alt_11 = 9
1094
+ when 0x28 then alt_11 = 10
1095
+ when 0x29 then alt_11 = 11
1096
+ when 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a then alt_11 = 12
1097
+ when 0x22 then alt_11 = 13
1098
+ when 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 then alt_11 = 14
1099
+ when 0x2a, 0x2b, 0x2f, 0x5e then alt_11 = 5
1100
+ when 0xa, 0xd then alt_11 = 15
1101
+ when 0x9, 0x20 then alt_11 = 16
1102
+ else
1103
+ raise NoViableAlternative( "", 11, 0 )
1104
+
1105
+ end
1106
+ case alt_11
1107
+ when 1
1108
+ # at line 1:10: T__38
1109
+ t__38!
1110
+
1111
+
1112
+ when 2
1113
+ # at line 1:16: ASSIGN
1114
+ assign!
1115
+
1116
+
1117
+ when 3
1118
+ # at line 1:23: BLOCK_LEFT
1119
+ block_left!
1120
+
1121
+
1122
+ when 4
1123
+ # at line 1:34: BLOCK_RIGHT
1124
+ block_right!
1125
+
1126
+
1127
+ when 5
1128
+ # at line 1:46: ARITH_SIGN
1129
+ arith_sign!
1130
+
1131
+
1132
+ when 6
1133
+ # at line 1:57: BANG
1134
+ bang!
1135
+
1136
+
1137
+ when 7
1138
+ # at line 1:62: COMMENT
1139
+ comment!
1140
+
1141
+
1142
+ when 8
1143
+ # at line 1:70: BLOCK_END
1144
+ block_end!
1145
+
1146
+
1147
+ when 9
1148
+ # at line 1:80: COMMA
1149
+ comma!
1150
+
1151
+
1152
+ when 10
1153
+ # at line 1:86: LPAREN
1154
+ lparen!
1155
+
1156
+
1157
+ when 11
1158
+ # at line 1:93: RPAREN
1159
+ rparen!
1160
+
1161
+
1162
+ when 12
1163
+ # at line 1:100: NAME
1164
+ name!
1165
+
1166
+
1167
+ when 13
1168
+ # at line 1:105: STRING
1169
+ string!
1170
+
1171
+
1172
+ when 14
1173
+ # at line 1:112: NUMBER
1174
+ number!
1175
+
1176
+
1177
+ when 15
1178
+ # at line 1:119: NEWLINE
1179
+ newline!
1180
+
1181
+
1182
+ when 16
1183
+ # at line 1:127: WHITESPACE
1184
+ whitespace!
1185
+
1186
+
1187
+ end
1188
+ end
1189
+
1190
+
1191
+ # - - - - - - - - - - DFA definitions - - - - - - - - - - -
1192
+ class DFA7 < ANTLR3::DFA
1193
+ EOT = unpack( 1, -1, 1, 4, 1, -1, 1, 4, 2, -1, 1, 4 )
1194
+ EOF = unpack( 7, -1 )
1195
+ MIN = unpack( 1, 45, 1, 46, 1, 49, 1, 46, 2, -1, 1, 46 )
1196
+ MAX = unpack( 1, 57, 1, 46, 2, 57, 2, -1, 1, 57 )
1197
+ ACCEPT = unpack( 4, -1, 1, 1, 1, 2, 1, -1 )
1198
+ SPECIAL = unpack( 7, -1 )
1199
+ TRANSITION = [
1200
+ unpack( 1, 2, 2, -1, 1, 1, 9, 3 ),
1201
+ unpack( 1, 5 ),
1202
+ unpack( 9, 3 ),
1203
+ unpack( 1, 5, 1, -1, 10, 6 ),
1204
+ unpack( ),
1205
+ unpack( ),
1206
+ unpack( 1, 5, 1, -1, 10, 6 )
1207
+ ].freeze
1208
+
1209
+ ( 0 ... MIN.length ).zip( MIN, MAX ) do | i, a, z |
1210
+ if a > 0 and z < 0
1211
+ MAX[ i ] %= 0x10000
1212
+ end
1213
+ end
1214
+
1215
+ @decision = 7
1216
+
1217
+
1218
+ def description
1219
+ <<-'__dfa_description__'.strip!
1220
+ 44:1: NUMBER : ( INTEGER | FLOAT );
1221
+ __dfa_description__
1222
+ end
1223
+
1224
+ end
1225
+
1226
+
1227
+ private
1228
+
1229
+ def initialize_dfas
1230
+ super rescue nil
1231
+ @dfa7 = DFA7.new( self, 7 )
1232
+
1233
+
1234
+ end
1235
+
1236
+ end # class Lexer < ANTLR3::Lexer
1237
+
1238
+ at_exit { Lexer.main( ARGV ) } if __FILE__ == $0
1239
+
1240
+ end