antlr3 1.6.3 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,7 +24,7 @@ outputFile(LEXER, PARSER, TREE_PARSER, actionScope, actions, docComment, recogni
24
24
 
25
25
  # ~~~\> start load path setup
26
26
  this_directory = File.expand_path( File.dirname( __FILE__ ) )
27
- $:.unshift( this_directory ) unless $:.include?( this_directory )
27
+ $LOAD_PATH.unshift( this_directory ) unless $LOAD_PATH.include?( this_directory )
28
28
 
29
29
  antlr_load_failed = proc do
30
30
  load_path = $LOAD_PATH.map { |dir| ' - ' \<\< dir }.join( $/ )
@@ -70,6 +70,7 @@ rescue LoadError
70
70
  end
71
71
  # \<~~~ end load path setup
72
72
 
73
+ <placeAction(scope="all", name="header")>
73
74
  <placeAction(scope=actionScope,name="header")>
74
75
 
75
76
  <if(recognizer.grammar.grammarIsRoot)>
@@ -79,6 +80,7 @@ end
79
80
  <endif>
80
81
 
81
82
  <placeAction(scope=actionScope,name="footer")>
83
+ <placeAction(scope="all", name="footer")>
82
84
 
83
85
  <if(actions.(actionScope).main)>
84
86
  if __FILE__ == $0 and ARGV.first != '--'
@@ -91,7 +93,7 @@ tokenDataModule() ::= <<
91
93
  # TokenData defines all of the token type integer values
92
94
  # as constants, which will be included in all
93
95
  # ANTLR-generated recognizers.
94
- const_defined?(:TokenData) or TokenData = ANTLR3::TokenScheme.new
96
+ const_defined?( :TokenData ) or TokenData = ANTLR3::TokenScheme.new
95
97
 
96
98
  module TokenData
97
99
  <if(tokens)>
@@ -165,7 +167,7 @@ class <if(grammar.grammarIsRoot)>Parser<else><grammar.name><endif> \< <superClas
165
167
  end # class <if(grammar.grammarIsRoot)>Parser<else><grammar.name><endif> \< <superClass>
166
168
  <if(!actions.(actionScope).main)>
167
169
 
168
- at_exit { <if(grammar.grammarIsRoot)>Parser<else><grammar.name><endif>.main(ARGV) } if __FILE__ == $0
170
+ at_exit { <if(grammar.grammarIsRoot)>Parser<else><grammar.name><endif>.main( ARGV ) } if __FILE__ == $0
169
171
  <endif>
170
172
  >>
171
173
 
@@ -180,7 +182,7 @@ class <if(grammar.grammarIsRoot)>TreeParser<else><grammar.name><endif> \< <super
180
182
  end # class <if(grammar.grammarIsRoot)>TreeParser<else><grammar.name><endif> \< <superClass>
181
183
  <if(!actions.(actionScope).main)>
182
184
 
183
- at_exit { <if(grammar.grammarIsRoot)>TreeParser<else><grammar.name><endif>.main(ARGV) } if __FILE__ == $0
185
+ at_exit { <if(grammar.grammarIsRoot)>TreeParser<else><grammar.name><endif>.main( ARGV ) } if __FILE__ == $0
184
186
  <endif>
185
187
  >>
186
188
 
@@ -202,7 +204,11 @@ imports( <grammar.directDelegates:{d|:<d.name>}; separator=", "> )<\n>
202
204
 
203
205
  include TokenData
204
206
 
205
- generated_using( "<fileName>", "<ANTLRVersion>", "<runtimeLibraryVersion()>" )
207
+ begin
208
+ generated_using( "<fileName>", "<ANTLRVersion>", "<runtimeLibraryVersion()>" )
209
+ rescue NoMethodError => error
210
+ # ignore
211
+ end
206
212
 
207
213
  <if(!grammar.grammarIsRoot)>
208
214
  require '<grammar.composite.rootGrammar.recognizerName>'
@@ -230,7 +236,7 @@ def initialize_dfas
230
236
  end
231
237
 
232
238
  <endif>
233
- <bitsets:{TOKENS_FOLLOWING_<it.name>_IN_<it.inName>_<it.tokenIndex> = Set[<it.tokenTypes:{<it>}; separator=", ">]<\n>}>
239
+ <bitsets:{TOKENS_FOLLOWING_<it.name>_IN_<it.inName>_<it.tokenIndex> = Set[ <it.tokenTypes:{<it>}; separator=", "> ]<\n>}>
234
240
  >>
235
241
 
236
242
  parserConstructor() ::= <<
@@ -266,7 +272,7 @@ synpredRule(ruleName, ruleDescriptor, block, description, nakedBlock) ::= <<
266
272
  # This is an imaginary rule inserted by ANTLR to
267
273
  # implement a syntactic predicate decision
268
274
  #
269
- def <ruleName; format="lexerRule"><if(ruleDescriptor.parameterScope)>(<ruleDescriptor.parameterScope:parameterScope(scope=it)>)<endif>
275
+ def <ruleName; format="lexerRule"><if(ruleDescriptor.parameterScope)>( <ruleDescriptor.parameterScope:parameterScope(scope=it)> )<endif>
270
276
  <traceIn()><ruleLabelDefs()>
271
277
  <block>
272
278
  ensure
@@ -287,7 +293,7 @@ rule(ruleName, ruleDescriptor, block, emptyRule, description, exceptions, finall
287
293
  # (in <fileName>)
288
294
  # <description>
289
295
  #
290
- def <ruleName><if(ruleDescriptor.parameterScope)>(<ruleDescriptor.parameterScope:parameterScope(scope=it)>)<endif>
296
+ def <ruleName><if(ruleDescriptor.parameterScope)>( <ruleDescriptor.parameterScope:parameterScope(scope=it)> )<endif>
291
297
  <traceIn()><ruleScopeSetUp()><ruleDeclarations()><ruleLabelDefs()><action(name="init", code=ruleDescriptor.actions.init)>
292
298
  <@body><ruleBody()><@end>
293
299
 
@@ -301,7 +307,7 @@ end
301
307
 
302
308
  delegateRule(ruleDescriptor) ::= <<
303
309
  # delegated rule <ruleDescriptor.name>
304
- def <ruleDescriptor.name>(<ruleDescriptor.parameterScope:parameterScope(scope=it)>)
310
+ def <ruleDescriptor.name><if(ruleDescriptor.parameterScope)>( <ruleDescriptor.parameterScope:parameterScope(scope=it)> )<endif>
305
311
  <methodCall(del=ruleDescriptor.grammar, n=ruleDescriptor.name, args={<ruleDescriptor.parameterScope.attributes:{<it.name>}>})>
306
312
  end
307
313
  >>
@@ -312,7 +318,9 @@ recognizerClassName() ::= <<
312
318
  >>
313
319
 
314
320
  initializeDirectDelegate() ::= <<
315
- @<g:delegateName()> = <g.name>::<recognizerClassName()>.new(<trunc(g.delegators):{p|<p:delegateName()>, }>self, input, options.merge(:state => @state))
321
+ @<g:delegateName()> = <g.name>::<recognizerClassName()>.new(
322
+ <trunc(g.delegators):{p|<p:delegateName()>, }>self, input, options.merge( :state => @state )
323
+ )
316
324
  >>
317
325
 
318
326
  initializeDelegator() ::= <<
@@ -354,7 +362,6 @@ delegateName() ::= <<
354
362
  <if(it.label)><it.label; format="label"><else><it.name; format="snakecase"><endif>
355
363
  >>
356
364
 
357
-
358
365
  element() ::= <<
359
366
  <it.el><\n>
360
367
  >>
@@ -365,20 +372,16 @@ globalAttributeScopeClass(scope) ::= <<
365
372
  <if(scope.attributes)>@@<scope.name> = Struct.new( <scope.attributes:{:<it.decl>}; separator=", "> )<\n><endif>
366
373
  >>
367
374
 
368
-
369
375
  globalAttributeScopeStack(scope) ::= <<
370
376
  <if(scope.attributes)>@<scope.name>_stack = []<\n><endif>
371
377
  >>
372
378
 
373
-
374
379
  noRewrite(rewriteBlockLevel, treeLevel) ::= ""
375
380
 
376
-
377
381
  parameterScope(scope) ::= <<
378
382
  <scope.attributes:{<it.decl>}; separator=", ">
379
383
  >>
380
384
 
381
-
382
385
  positiveClosureBlockLoop() ::= <<
383
386
  match_count_<decisionNumber> = 0
384
387
  while true
@@ -403,14 +406,14 @@ returnScope(scope) ::= <<
403
406
  <endif>
404
407
  >>
405
408
 
406
-
407
409
  returnStructName(r) ::= "<r.name; format=\"camelcase\">ReturnValue"
410
+
408
411
  ruleAttributeScopeClass ::= globalAttributeScopeClass
409
412
  ruleAttributeScopeStack ::= globalAttributeScopeStack
410
413
 
411
414
  ruleBacktrackFailure() ::= <<
412
415
  <if(backtracking)>
413
- @state.backtracking > 0 and raise(ANTLR3::Error::BacktrackingFailed)<\n>
416
+ @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )<\n>
414
417
  <endif>
415
418
  >>
416
419
 
@@ -445,7 +448,6 @@ ensure
445
448
  end
446
449
  >>
447
450
 
448
-
449
451
  ruleReturnValue() ::= <<
450
452
  <if(!ruleDescriptor.isSynPred)>
451
453
  <if(ruleDescriptor.hasReturnValue)>
@@ -473,50 +475,58 @@ return_value.start = @input.look<\n>
473
475
  <endif>
474
476
  >>
475
477
 
476
-
477
478
  ruleLabelDef(label) ::= <<
478
479
  <label.label.text; format="label"> = nil<\n>
479
480
  >>
480
481
 
481
-
482
482
  ruleLabelDefs() ::= <<
483
- <[ruleDescriptor.tokenLabels,ruleDescriptor.tokenListLabels,ruleDescriptor.wildcardTreeLabels,ruleDescriptor.wildcardTreeListLabels]:{<it.label.text; format="label"> = nil<\n>}><[ruleDescriptor.tokenListLabels,ruleDescriptor.ruleListLabels,ruleDescriptor.wildcardTreeListLabels]:{list_of_<it.label.text; format="label"> = []<\n>}><[ruleDescriptor.ruleLabels,ruleDescriptor.ruleListLabels]:ruleLabelDef(label=it)><ruleDescriptor.ruleListLabels:{<it.label.text; format="label"> = nil<\n>}>
483
+ <[
484
+ ruleDescriptor.tokenLabels,
485
+ ruleDescriptor.tokenListLabels,
486
+ ruleDescriptor.wildcardTreeLabels,
487
+ ruleDescriptor.wildcardTreeListLabels,
488
+ ruleDescriptor.ruleLabels,
489
+ ruleDescriptor.ruleListLabels
490
+ ]:
491
+ {<it.label.text; format="label"> = nil<\n>}
492
+ ><[
493
+ ruleDescriptor.tokenListLabels,
494
+ ruleDescriptor.ruleListLabels,
495
+ ruleDescriptor.wildcardTreeListLabels
496
+ ]:
497
+ {list_of_<it.label.text; format="label"> = []<\n>}
498
+ >
484
499
  >>
485
500
 
486
-
487
-
488
501
  /* * * * * * * * * * * * * R U L E H E L P E R S * * * * * * * * * * * * */
489
502
 
490
503
  traceIn() ::= <<
491
504
  <if(trace)>
492
- trace_in(__method__, <ruleDescriptor.index>)<\n>
505
+ trace_in( __method__, <ruleDescriptor.index> )<\n>
493
506
  <else>
494
507
  # -> uncomment the next line to manually enable rule tracing
495
- # trace_in(__method__, <ruleDescriptor.index>)<\n>
508
+ # trace_in( __method__, <ruleDescriptor.index> )<\n>
496
509
  <endif>
497
510
  >>
498
511
 
499
-
500
512
  traceOut() ::= <<
501
513
  <if(trace)>
502
- trace_out(__method__, <ruleDescriptor.index>)<\n>
514
+ trace_out( __method__, <ruleDescriptor.index> )<\n>
503
515
  <else>
504
516
  # -> uncomment the next line to manually enable rule tracing
505
- # trace_out(__method__, <ruleDescriptor.index>)<\n>
517
+ # trace_out( __method__, <ruleDescriptor.index> )<\n>
506
518
  <endif>
507
519
  >>
508
520
 
509
-
510
521
  ruleCleanUp() ::= <<
511
522
  <if(ruleDescriptor.hasMultipleReturnValues)>
512
523
  <if(!TREE_PARSER)>
513
524
  # - - - - - - - rule clean up - - - - - - - -
514
- return_value.stop = @input.look(-1)<\n>
525
+ return_value.stop = @input.look( -1 )<\n>
515
526
  <endif>
516
527
  <endif>
517
528
  >>
518
529
 
519
-
520
530
  ruleMemoization(name) ::= <<
521
531
  <if(memoize)>
522
532
  # rule memoization
@@ -529,34 +539,28 @@ end<\n>
529
539
 
530
540
 
531
541
  ruleScopeSetUp() ::= <<
532
- <ruleDescriptor.useScopes:{@<it>_stack.push(@@<it>.new)<\n>}><ruleDescriptor.ruleScope:{@<it.name>_stack.push(@@<it.name>.new)<\n>}>
542
+ <ruleDescriptor.useScopes:{@<it>_stack.push( @@<it>.new )<\n>}><ruleDescriptor.ruleScope:{@<it.name>_stack.push( @@<it.name>.new )<\n>}>
533
543
  >>
534
544
 
535
-
536
545
  ruleScopeCleanUp() ::= <<
537
546
  <ruleDescriptor.useScopes:{@<it>_stack.pop<\n>}><ruleDescriptor.ruleScope:{@<it.name>_stack.pop<\n>}>
538
547
  >>
539
548
 
540
-
541
549
  memoize() ::= <<
542
550
  <if(memoize)><if(backtracking)>
543
- memoize(__method__, <ruleDescriptor.name>_start_index, success) if @state.backtracking > 0<\n>
551
+ memoize( __method__, <ruleDescriptor.name>_start_index, success ) if @state.backtracking > 0<\n>
544
552
  <endif><endif>
545
553
  >>
546
554
 
547
-
548
555
  /** helper template to format a ruby method call */
549
556
  methodCall(n, del, args) ::= <<
550
- <if(del)>@<del:delegateName()>.<endif><n><if(args)>(<args; separator=", ">)<endif>
557
+ <if(del)>@<del:delegateName()>.<endif><n><if(args)>( <args; separator=", "> )<endif>
551
558
  >>
552
559
 
553
-
554
560
  /* * * * * * * * * * * * * L E X E R P A R T S * * * * * * * * * * * * * */
555
561
 
556
-
557
562
  actionGate() ::= "@state.backtracking == 0"
558
563
 
559
-
560
564
  /** A (...) subrule with multiple alternatives */
561
565
  block(alts,decls,decision,enclosingBlockLevel,blockLevel,decisionNumber,maxK,maxAlt,description) ::= <<
562
566
  # at line <description>
@@ -565,7 +569,6 @@ alt_<decisionNumber> = <maxAlt>
565
569
  <@body><blockBody()><@end>
566
570
  >>
567
571
 
568
-
569
572
  /** A rule block with multiple alternatives */
570
573
  ruleBlock(alts,decls,decision,enclosingBlockLevel,blockLevel,decisionNumber,maxK,maxAlt,description) ::= <<
571
574
  # at line <description>
@@ -577,14 +580,12 @@ case alt_<decisionNumber>
577
580
  end
578
581
  >>
579
582
 
580
-
581
583
  ruleBlockSingleAlt(alts,decls,decision,enclosingBlockLevel,blockLevel,decisionNumber,description) ::= <<
582
584
  <decls>
583
585
  <@prealt()>
584
586
  <alts>
585
587
  >>
586
588
 
587
-
588
589
  /** A special case of a (...) subrule with a single alternative */
589
590
  blockSingleAlt(alts,decls,decision,enclosingBlockLevel,blockLevel,decisionNumber,description) ::= <<
590
591
  # at line <description>
@@ -593,7 +594,6 @@ blockSingleAlt(alts,decls,decision,enclosingBlockLevel,blockLevel,decisionNumber
593
594
  <alts>
594
595
  >>
595
596
 
596
-
597
597
  /** A (..)+ block with 0 or more alternatives */
598
598
  positiveClosureBlock(alts,decls,decision,enclosingBlockLevel,blockLevel,decisionNumber,maxK,maxAlt,description) ::= <<
599
599
  # at file <description>
@@ -603,10 +603,8 @@ positiveClosureBlock(alts,decls,decision,enclosingBlockLevel,blockLevel,decision
603
603
  <@end>
604
604
  >>
605
605
 
606
-
607
606
  positiveClosureBlockSingleAlt ::= positiveClosureBlock
608
607
 
609
-
610
608
  /** A (..)* block with 0 or more alternatives */
611
609
  closureBlock(alts,decls,decision,enclosingBlockLevel,blockLevel,decisionNumber,maxK,maxAlt,description) ::= <<
612
610
  # at line <description>
@@ -616,19 +614,15 @@ closureBlock(alts,decls,decision,enclosingBlockLevel,blockLevel,decisionNumber,m
616
614
  <@end>
617
615
  >>
618
616
 
619
-
620
617
  closureBlockSingleAlt ::= closureBlock
621
618
 
622
-
623
619
  /** Optional blocks (x)? are translated to (x|) by before code
624
620
  * generation so we can just use the normal block template
625
621
  */
626
622
  optionalBlock ::= block
627
623
 
628
-
629
624
  optionalBlockSingleAlt ::= block
630
625
 
631
-
632
626
  /** An alternative is just a list of elements; at outermost
633
627
  * level
634
628
  */
@@ -637,23 +631,28 @@ alt(elements,altNum,description,autoAST,outerAlt,treeLevel,rew) ::= <<
637
631
  <elements:element()><rew>
638
632
  >>
639
633
 
640
-
641
634
  /** match a token optionally with a label in front */
642
635
  tokenRef(token,label,elementIndex,hetero) ::= <<
643
- <if(label)><label; format="label"> = <endif>match(<token>, TOKENS_FOLLOWING_<token>_IN_<ruleName>_<elementIndex>)
636
+ <if(label)><label; format="label"> = <endif>match( <token>, TOKENS_FOLLOWING_<token>_IN_<ruleName>_<elementIndex> )
644
637
  >>
645
638
 
646
-
647
639
  /** ids+=ID */
648
640
  tokenRefAndListLabel(token,label,elementIndex,hetero) ::= <<
649
641
  <tokenRef(...)>
650
642
  <addToList(elem={<label; format="label">},...)>
651
643
  >>
644
+
645
+ /* TRY THIS:
646
+ tokenRefAndListLabel(token,label,elementIndex,hetero) ::= <<
647
+ list_of_<label; format="label"> << match( <token>, TOKENS_FOLLOWING_<token>_IN_<ruleName>_<elementIndex> )
648
+ >>
649
+ */
650
+
652
651
  addToList(label,elem) ::= <<
653
652
  list_of_<label; format="label"> \<\< <elem><\n>
654
653
  >>
655
- listLabel ::= addToList
656
654
 
655
+ listLabel ::= addToList
657
656
 
658
657
  /** For now, sets are interval tests and must be tested inline */
659
658
  matchSet(s,label,elementIndex,postmatchCode) ::= <<
@@ -668,10 +667,10 @@ if <s>
668
667
  <endif>
669
668
  else
670
669
  <ruleBacktrackFailure()>
671
- mse = MismatchedSet(nil)
670
+ mse = MismatchedSet( nil )
672
671
  <@mismatchedSetException()>
673
672
  <if(LEXER)>
674
- recover(mse)
673
+ recover mse
675
674
  raise mse<\n>
676
675
  <else>
677
676
  raise mse<\n>
@@ -686,10 +685,8 @@ matchSetAndListLabel(s,label,elementIndex,postmatchCode) ::= <<
686
685
  <addToList(elem={<label; format="label">},...)>
687
686
  >>
688
687
 
689
-
690
688
  matchRuleBlockSet ::= matchSet
691
689
 
692
-
693
690
  wildcard(label,elementIndex) ::= <<
694
691
  <if(label)>
695
692
  <label; format="label"> = @input.look<\n>
@@ -697,6 +694,11 @@ wildcard(label,elementIndex) ::= <<
697
694
  match_any
698
695
  >>
699
696
 
697
+ /* TRY THIS:
698
+ wildcard(label,elementIndex) ::= <<
699
+ <if(label)><label; format="label"> = <endif>match_any
700
+ >>
701
+ */
700
702
 
701
703
  wildcardAndListLabel(label,elementIndex) ::= <<
702
704
  <wildcard(...)>
@@ -708,62 +710,65 @@ wildcardAndListLabel(label,elementIndex) ::= <<
708
710
  * arguments and a return value or values.
709
711
  */
710
712
  ruleRef(rule,label,elementIndex,args,scope) ::= <<
711
- @state.following.push(TOKENS_FOLLOWING_<rule.name>_IN_<ruleName>_<elementIndex>)
713
+ @state.following.push( TOKENS_FOLLOWING_<rule.name>_IN_<ruleName>_<elementIndex> )
712
714
  <if(label)><label; format="label"> = <endif><methodCall(del=scope, n={<rule.name>}, args=args)>
713
715
  @state.following.pop
714
716
  >>
715
717
 
716
-
717
718
  /** ids+=ID */
718
719
  ruleRefAndListLabel(rule,label,elementIndex,args,scope) ::= <<
719
720
  <ruleRef(...)>
720
721
  <addToList(elem={<label; format="label">},...)>
721
722
  >>
722
723
 
723
-
724
724
  /** match ^(root children) in tree parser */
725
725
  tree(root, actionsAfterRoot, children, nullableChildList, enclosingTreeLevel, treeLevel) ::= <<
726
726
  <root:element()>
727
727
  <actionsAfterRoot:element()>
728
728
  <if(nullableChildList)>
729
729
  if @input.peek == DOWN
730
- match(DOWN, nil)
730
+ match( DOWN, nil )
731
731
  <children:element()>
732
- match(UP, nil)
732
+ match( UP, nil )
733
733
  end
734
734
  <else>
735
- match(DOWN, nil)
735
+ match( DOWN, nil )
736
736
  <children:element()>
737
- match(UP, nil)
737
+ match( UP, nil )
738
738
  <endif>
739
739
  >>
740
740
 
741
-
742
741
  /** Every predicate is used as a validating predicate (even when
743
742
  * it is also hoisted into a prediction expression).
744
743
  */
745
744
  validateSemanticPredicate(pred,description) ::= <<
746
- unless (<evalPredicate(...)>)
745
+ <if(backtracking)>
746
+ unless ( <evalPredicate(...)> )
747
747
  <ruleBacktrackFailure()>
748
- raise FailedPredicate("<ruleName>", "<description>")
748
+ raise FailedPredicate( "<ruleName>", "<description>" )
749
749
  end
750
+ <else>
751
+ raise FailedPredicate( "<ruleName>", "<description>" ) unless ( <evalPredicate(...)> )
752
+ <endif>
750
753
  >>
751
754
 
752
-
753
755
  dfaState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) ::= <<
754
- look_<decisionNumber>_<stateNumber> = @input.peek(<k>)<\n>
756
+ look_<decisionNumber>_<stateNumber> = @input.peek( <k> )<\n>
755
757
  <edges; separator="\nels">
756
758
  else
757
759
  <if(eotPredictsAlt)>
758
760
  alt_<decisionNumber> = <eotPredictsAlt><\n>
759
761
  <else>
760
- <ruleBacktrackFailure()>nvae = NoViableAlternative("<description>", <decisionNumber>, <stateNumber>)
761
- <@noViableAltException>raise nvae<@end><\n>
762
+ <if(backtracking)>
763
+ <ruleBacktrackFailure()><\n>
764
+ <endif>
765
+ <@noViableAltException>
766
+ raise NoViableAlternative( "<description>", <decisionNumber>, <stateNumber> )<\n>
767
+ <@end>
762
768
  <endif>
763
769
  end
764
770
  >>
765
771
 
766
-
767
772
  /** Same as a normal DFA state except that we don't examine
768
773
  * look for the bypass alternative. It delays error
769
774
  * detection but this is faster, smaller, and more what people
@@ -772,7 +777,7 @@ end
772
777
  * lookup; preds might not need.
773
778
  */
774
779
  dfaOptionalBlockState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) ::= <<
775
- look_<decisionNumber>_<stateNumber> = @input.peek(<k>)<\n>
780
+ look_<decisionNumber>_<stateNumber> = @input.peek( <k> )<\n>
776
781
  <edges; separator="\nels">
777
782
  end
778
783
  >>
@@ -787,7 +792,7 @@ end
787
792
  * look lookup; preds might not need.
788
793
  */
789
794
  dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) ::= <<
790
- look_<decisionNumber>_<stateNumber> = @input.peek(<k>)<\n>
795
+ look_<decisionNumber>_<stateNumber> = @input.peek( <k> )<\n>
791
796
  <edges; separator="\nels"><\n>
792
797
  <if(eotPredictsAlt)>
793
798
  else
@@ -802,14 +807,13 @@ end
802
807
  */
803
808
  dfaAcceptState(alt) ::= "alt_<decisionNumber> = <alt>"
804
809
 
805
-
806
810
  /** A simple edge with an expression. If the expression is
807
811
  * satisfied, enter to the target state. To handle gated
808
812
  * productions, we may have to evaluate some predicates for
809
813
  * this edge.
810
814
  */
811
815
  dfaEdge(labelExpr, targetState, predicates) ::= <<
812
- if (<labelExpr>) <if(predicates)>and (<predicates>)<endif>
816
+ if ( <labelExpr> )<if(predicates)> and ( <predicates> )<endif>
813
817
  <targetState>
814
818
  >>
815
819
 
@@ -819,29 +823,31 @@ if (<labelExpr>) <if(predicates)>and (<predicates>)<endif>
819
823
  * CodeGenerator.canGenerateSwitch().
820
824
  */
821
825
  dfaStateSwitch(k,edges,eotPredictsAlt,description,stateNumber,semPredState) ::= <<
822
- case look_<decisionNumber> = @input.peek(<k>)
826
+ case look_<decisionNumber> = @input.peek( <k> )
823
827
  <edges; separator="\n">
824
828
  else
825
829
  <if(eotPredictsAlt)>
826
830
  alt_<decisionNumber> = <eotPredictsAlt><\n>
827
831
  <else>
828
- <ruleBacktrackFailure()>
829
- nvae = NoViableAlternative("<description>", <decisionNumber>, <stateNumber>)
830
- <@noViableAltException>raise nvae<@end><\n>
832
+ <if(backtracking)>
833
+ <ruleBacktrackFailure()><\n>
834
+ <endif>
835
+ <@noViableAltException>
836
+ raise NoViableAlternative( "<description>", <decisionNumber>, <stateNumber> )<\n>
837
+ <@end>
831
838
  <endif>
832
839
  end
833
840
  >>
834
841
 
835
842
 
836
843
  dfaOptionalBlockStateSwitch(k, edges, eotPredictsAlt, description, stateNumber, semPredState) ::= <<
837
- case look_<decisionNumber> = @input.peek(<k>)
844
+ case look_<decisionNumber> = @input.peek( <k> )
838
845
  <edges; separator="\n">
839
846
  end
840
847
  >>
841
848
 
842
-
843
849
  dfaLoopbackStateSwitch(k, edges, eotPredictsAlt, description, stateNumber, semPredState) ::= <<
844
- case look_<decisionNumber> = @input.peek(<k>)
850
+ case look_<decisionNumber> = @input.peek( <k> )
845
851
  <edges; separator="\n">
846
852
  <if(eotPredictsAlt)>
847
853
  else
@@ -850,21 +856,18 @@ else
850
856
  end
851
857
  >>
852
858
 
853
-
854
859
  dfaEdgeSwitch(labels, targetState) ::= <<
855
860
  when <labels:{<it>}; separator=", "> then <targetState>
856
861
  >>
857
862
 
858
-
859
863
  /** The code to initiate execution of a cyclic DFA; this is used
860
864
  * in the rule to predict an alt just like the fixed DFA case.
861
865
  * The <name> attribute is inherited via the parser, lexer, ...
862
866
  */
863
867
  dfaDecision(decisionNumber, description) ::= <<
864
- alt_<decisionNumber> = @dfa<decisionNumber>.predict(@input)
868
+ alt_<decisionNumber> = @dfa<decisionNumber>.predict( @input )
865
869
  >>
866
870
 
867
-
868
871
  /** Generate the tables and support code needed for the DFAState
869
872
  * object argument. Unless there is a semantic predicate (or
870
873
  * syn pred, which become sem preds), all states should be
@@ -875,14 +878,14 @@ alt_<decisionNumber> = @dfa<decisionNumber>.predict(@input)
875
878
  */
876
879
  cyclicDFA(dfa) ::= <<
877
880
  class DFA<dfa.decisionNumber> \< ANTLR3::DFA
878
- EOT = unpack(<dfa.javaCompressedEOT; anchor, separator=", ", wrap="\n">)
879
- EOF = unpack(<dfa.javaCompressedEOF; anchor, separator=", ", wrap="\n">)
880
- MIN = unpack(<dfa.javaCompressedMin; anchor, separator=", ", wrap="\n">)
881
- MAX = unpack(<dfa.javaCompressedMax; anchor, separator=", ", wrap="\n">)
882
- ACCEPT = unpack(<dfa.javaCompressedAccept; anchor, separator=", ", wrap="\n">)
883
- SPECIAL = unpack(<dfa.javaCompressedSpecial; anchor, separator=", ", wrap="\n">)
881
+ EOT = unpack( <dfa.javaCompressedEOT; anchor, separator=", ", wrap="\n"> )
882
+ EOF = unpack( <dfa.javaCompressedEOF; anchor, separator=", ", wrap="\n"> )
883
+ MIN = unpack( <dfa.javaCompressedMin; anchor, separator=", ", wrap="\n"> )
884
+ MAX = unpack( <dfa.javaCompressedMax; anchor, separator=", ", wrap="\n"> )
885
+ ACCEPT = unpack( <dfa.javaCompressedAccept; anchor, separator=", ", wrap="\n"> )
886
+ SPECIAL = unpack( <dfa.javaCompressedSpecial; anchor, separator=", ", wrap="\n"> )
884
887
  TRANSITION = [
885
- <dfa.javaCompressedTransition:{s|unpack(<s; wrap="\n", anchor, separator=", ">)}; separator=",\n">
888
+ <dfa.javaCompressedTransition:{s|unpack( <s; wrap="\n", anchor, separator=", "> )}; separator=",\n">
886
889
  ].freeze
887
890
 
888
891
  ( 0 ... MIN.length ).zip( MIN, MAX ) do | i, a, z |
@@ -915,21 +918,19 @@ def special_state_transition_for_dfa<dfa.decisionNumber>(s, input)
915
918
  <if(backtracking)>
916
919
  @state.backtracking > 0 and raise ANTLR3::Error::BacktrackingFailed<\n>
917
920
  <endif>
918
- nva = ANTLR3::Error::NoViableAlternative.new(@dfa<dfa.decisionNumber>.description, <dfa.decisionNumber>, s, input)
919
- @dfa<dfa.decisionNumber>.error(nva)
921
+ nva = ANTLR3::Error::NoViableAlternative.new( @dfa<dfa.decisionNumber>.description, <dfa.decisionNumber>, s, input )
922
+ @dfa<dfa.decisionNumber>.error( nva )
920
923
  raise nva
921
924
  end
922
925
  >>
923
926
 
924
-
925
- cyclicDFASynpred(name) ::= <<
927
+ cyclicDFASynpred( name ) ::= <<
926
928
  def <name>() @recognizer.<name> end<\n>
927
929
  >>
928
930
 
929
-
930
931
  cyclicDFAInit(dfa) ::= <<
931
932
  <if(dfa.specialStateSTs)>
932
- @dfa<dfa.decisionNumber> = DFA<dfa.decisionNumber>.new(self, <dfa.decisionNumber>) do |s|
933
+ @dfa<dfa.decisionNumber> = DFA<dfa.decisionNumber>.new( self, <dfa.decisionNumber> ) do |s|
933
934
  case s
934
935
  <dfa.specialStateSTs:{state|when <i0>
935
936
  <state>}; separator="\n">
@@ -939,15 +940,15 @@ cyclicDFAInit(dfa) ::= <<
939
940
  <if(backtracking)>
940
941
  @state.backtracking > 0 and raise ANTLR3::Error::BacktrackingFailed<\n>
941
942
  <endif>
942
- nva = ANTLR3::Error::NoViableAlternative.new(@dfa<dfa.decisionNumber>.description, <dfa.decisionNumber>, s, input)
943
- @dfa<dfa.decisionNumber>.error(nva)
943
+ nva = ANTLR3::Error::NoViableAlternative.new( @dfa<dfa.decisionNumber>.description, <dfa.decisionNumber>, s, input )
944
+ @dfa<dfa.decisionNumber>.error( nva )
944
945
  raise nva
945
946
  end
946
947
 
947
948
  s
948
949
  end<\n>
949
950
  <else>
950
- @dfa<dfa.decisionNumber> = DFA<dfa.decisionNumber>.new(self, <dfa.decisionNumber>)<\n>
951
+ @dfa<dfa.decisionNumber> = DFA<dfa.decisionNumber>.new( self, <dfa.decisionNumber> )<\n>
951
952
  <endif>
952
953
  >>
953
954
 
@@ -959,12 +960,12 @@ cyclicDFAState(decisionNumber, stateNumber, edges, needErrorClause, semPredState
959
960
  look_<decisionNumber>_<stateNumber> = @input.peek
960
961
  <if(semPredState)>
961
962
  index_<decisionNumber>_<stateNumber> = @input.index
962
- @input.rewind(@input.last_marker, false)<\n>
963
+ @input.rewind( @input.last_marker, false )<\n>
963
964
  <endif>
964
965
  s = -1
965
966
  <edges; separator="els">end
966
967
  <if(semPredState)> <! return input cursor to state before we rewound !>
967
- @input.seek(index_<decisionNumber>_<stateNumber>)<\n>
968
+ @input.seek( index_<decisionNumber>_<stateNumber> )<\n>
968
969
  <endif>
969
970
  >>
970
971
 
@@ -973,11 +974,10 @@ s = -1
973
974
  * for special states.
974
975
  */
975
976
  cyclicDFAEdge(labelExpr, targetStateNumber, edgeNumber, predicates) ::= <<
976
- if (<labelExpr>)<if(predicates)> && (<predicates>)<endif>
977
+ if ( <labelExpr> )<if(predicates)> and ( <predicates> )<endif>
977
978
  s = <targetStateNumber><\n>
978
979
  >>
979
980
 
980
-
981
981
  /** An edge pointing at end-of-token; essentially matches any
982
982
  * char; always jump to the target.
983
983
  */
@@ -986,20 +986,18 @@ e
986
986
  s = <targetStateNumber><\n>
987
987
  >>
988
988
 
989
+ andPredicates(left,right) ::= "( <left> ) and ( <right> )"
989
990
 
990
- andPredicates(left,right) ::= "( ( <left> ) and ( <right> ) )"
991
+ orPredicates(operands) ::= "( <first(operands)> )<rest(operands):{o| or ( <o> )}>"
991
992
 
992
- orPredicates(operands) ::= "(<first(operands)><rest(operands):{o| or <o>}>)"
993
+ notPredicate(pred) ::= "not ( <pred> )"
993
994
 
994
- notPredicate(pred) ::= "not (<evalPredicate(...)>)"
995
-
996
- evalPredicate(pred,description) ::= "(<pred>)"
995
+ evalPredicate(pred,description) ::= "( <pred> )"
997
996
 
998
997
  evalSynPredicate(pred,description) ::= <<
999
- syntactic_predicate?(<pred:{<it; format="lexerRule">}; format="symbol">)
998
+ syntactic_predicate?( :<pred:{<it; format="lexerRule">}> )
1000
999
  >>
1001
1000
 
1002
-
1003
1001
  lookaheadTest(atom, k, atomAsInt) ::= "look_<decisionNumber>_<stateNumber> == <atom>"
1004
1002
 
1005
1003
  /** Sometimes a look test cannot assume that LA(k) is in a
@@ -1008,34 +1006,30 @@ lookaheadTest(atom, k, atomAsInt) ::= "look_<decisionNumber>_<stateNumber> == <a
1008
1006
  */
1009
1007
  isolatedLookaheadTest(atom, k, atomAsInt) ::= "@input.peek(<k>) == <atom>"
1010
1008
 
1011
-
1012
1009
  lookaheadRangeTest(lower, upper, k, rangeNumber, lowerAsInt, upperAsInt) ::= <<
1013
- look_<decisionNumber>_<stateNumber>.between?(<lower>, <upper>)
1010
+ look_<decisionNumber>_<stateNumber>.between?( <lower>, <upper> )
1014
1011
  >>
1015
1012
 
1016
-
1017
1013
  isolatedLookaheadRangeTest(lower, upper, k, rangeNumber, lowerAsInt, upperAsInt) ::= <<
1018
- @input.peek(<k>).between?(<lower>, <upper>)
1014
+ @input.peek( <k> ).between?( <lower>, <upper> )
1019
1015
  >>
1016
+
1020
1017
  setTest(ranges) ::= <<
1021
1018
  <ranges; separator=" || ">
1022
1019
  >>
1023
1020
 
1024
-
1025
1021
  parameterAttributeRef(attr) ::= "<attr.name>"
1026
1022
 
1027
-
1028
1023
  parameterSetAttributeRef(attr,expr) ::= "<attr.name> = <expr>"
1029
1024
 
1030
-
1031
1025
  scopeAttributeRef(scope, attr, index, negIndex) ::= <<
1032
1026
  <if(negIndex)>
1033
- @<scope>_stack[-<negIndex>].<attr.name>
1027
+ @<scope>_stack[ -<negIndex> ].<attr.name>
1034
1028
  <else>
1035
1029
  <if(index)>
1036
- @<scope>_stack[<index>].<attr.name>
1030
+ @<scope>_stack[ <index> ].<attr.name>
1037
1031
  <else>
1038
- @<scope>_stack[-1].<attr.name>
1032
+ @<scope>_stack.last.<attr.name>
1039
1033
  <endif>
1040
1034
  <endif>
1041
1035
  >>
@@ -1043,12 +1037,12 @@ scopeAttributeRef(scope, attr, index, negIndex) ::= <<
1043
1037
 
1044
1038
  scopeSetAttributeRef(scope, attr, expr, index, negIndex) ::= <<
1045
1039
  <if(negIndex)>
1046
- @<scope>_stack[-<negIndex>].<attr.name> = <expr>
1040
+ @<scope>_stack[ -<negIndex> ].<attr.name> = <expr>
1047
1041
  <else>
1048
1042
  <if(index)>
1049
- @<scope>_stack[<index>].<attr.name> = <expr>
1043
+ @<scope>_stack[ <index> ].<attr.name> = <expr>
1050
1044
  <else>
1051
- @<scope>_stack[-1].<attr.name> = <expr>
1045
+ @<scope>_stack.last.<attr.name> = <expr>
1052
1046
  <endif>
1053
1047
  <endif>
1054
1048
  >>
@@ -1061,19 +1055,17 @@ scopeSetAttributeRef(scope, attr, expr, index, negIndex) ::= <<
1061
1055
  */
1062
1056
  isolatedDynamicScopeRef(scope) ::= "@<scope>_stack"
1063
1057
 
1064
-
1065
1058
  /** reference an attribute of rule; might only have single
1066
1059
  * return value
1067
1060
  */
1068
1061
  ruleLabelRef(referencedRule, scope, attr) ::= <<
1069
1062
  <if(referencedRule.hasMultipleReturnValues)>
1070
- (<scope; format="label">.nil? ? nil : <scope; format="label">.<attr.name>)
1063
+ ( <scope; format="label">.nil? ? nil : <scope; format="label">.<attr.name> )
1071
1064
  <else>
1072
1065
  <scope; format="label">
1073
1066
  <endif>
1074
1067
  >>
1075
1068
 
1076
-
1077
1069
  returnAttributeRef(ruleDescriptor, attr) ::= <<
1078
1070
  <if(ruleDescriptor.hasMultipleReturnValues)>
1079
1071
  return_value.<attr.name>
@@ -1082,7 +1074,6 @@ return_value.<attr.name>
1082
1074
  <endif>
1083
1075
  >>
1084
1076
 
1085
-
1086
1077
  returnSetAttributeRef(ruleDescriptor, attr, expr) ::= <<
1087
1078
  <if(ruleDescriptor.hasMultipleReturnValues)>
1088
1079
  return_value.<attr.name> = <expr>
@@ -1091,57 +1082,37 @@ return_value.<attr.name> = <expr>
1091
1082
  <endif>
1092
1083
  >>
1093
1084
 
1094
-
1095
1085
  /** How to translate $tokenLabel */
1096
1086
  tokenLabelRef(label) ::= "<label; format=\"label\">"
1097
1087
 
1098
-
1099
1088
  /** ids+=ID {$ids} or e+=expr {$e} */
1100
1089
  listLabelRef(label) ::= "list_of_<label; format=\"label\">"
1101
1090
 
1102
-
1103
1091
  tokenLabelPropertyRef_text(scope, attr) ::= "<scope; format=\"label\">.text"
1104
-
1105
-
1106
1092
  tokenLabelPropertyRef_type(scope, attr) ::= "<scope; format=\"label\">.type"
1107
-
1108
-
1109
1093
  tokenLabelPropertyRef_line(scope, attr) ::= "<scope; format=\"label\">.line"
1110
-
1111
-
1112
1094
  tokenLabelPropertyRef_pos(scope, attr) ::= "<scope; format=\"label\">.column"
1113
-
1114
-
1115
1095
  tokenLabelPropertyRef_channel(scope, attr) ::= "<scope; format=\"label\">.channel"
1116
-
1117
-
1118
1096
  tokenLabelPropertyRef_index(scope, attr) ::= "<scope; format=\"label\">.index"
1119
-
1120
-
1121
1097
  tokenLabelPropertyRef_tree(scope, attr) ::= "tree_for_<scope>"
1122
1098
 
1123
-
1124
1099
  ruleLabelPropertyRef_start(scope, attr) ::= "<scope; format=\"label\">.start"
1125
-
1126
-
1127
1100
  ruleLabelPropertyRef_stop(scope, attr) ::= "<scope; format=\"label\">.stop"
1128
-
1129
-
1130
1101
  ruleLabelPropertyRef_tree(scope, attr) ::= "<scope; format=\"label\">.tree"
1131
1102
 
1132
-
1133
1103
  ruleLabelPropertyRef_text(scope, attr) ::= <<
1134
1104
  <if(TREE_PARSER)>
1135
- (<scope; format="label">.nil? ? nil : @input.token_stream.to_s(
1136
- @input.tree_adaptor.token_start_index(<scope; format="label">.start),
1137
- @input.tree_adaptor.token_stop_index(<scope; format="label">.start)))
1105
+ (
1106
+ @input.token_stream.to_s(
1107
+ @input.tree_adaptor.token_start_index( <scope; format="label">.start ),
1108
+ @input.tree_adaptor.token_stop_index( <scope; format="label">.start )
1109
+ ) if <scope; format="label">
1110
+ )
1138
1111
  <else>
1139
- (<scope; format="label">.nil? ? nil : @input.to_s(<scope; format="label">.start,<scope; format="label">.stop))
1112
+ ( <scope; format="label"> && @input.to_s( <scope; format="label">.start, <scope; format="label">.stop ) )
1140
1113
  <endif>
1141
1114
  >>
1142
-
1143
-
1144
- ruleLabelPropertyRef_st(scope, attr) ::= "(<scope; format=\"label\">.nil? ? nil : <scope; format=\"label\">.template)"
1115
+ ruleLabelPropertyRef_st(scope, attr) ::= "( <scope; format=\"label\"> && <scope; format=\"label\">.template )"
1145
1116
 
1146
1117
  /******************************************************************************
1147
1118
  ***************** L E X E R - O N L Y T E M P L A T E S ******************
@@ -1154,20 +1125,23 @@ lexer(grammar, name, tokens, scopes, rules, numRules, labelType="ANTLR3::Token",
1154
1125
 
1155
1126
  class <if(grammar.delegator)><grammar.name><else>Lexer<endif> \< <superClass>
1156
1127
  @grammar_home = <grammar.name>
1157
- <if(!grammar.grammarIsRoot)><autoloadDelegates()><\n><endif>
1128
+ <if(!grammar.grammarIsRoot)>
1129
+ <autoloadDelegates()><\n>
1130
+ <endif>
1158
1131
  include TokenData
1159
1132
  <if(filterMode)>
1160
1133
  include ANTLR3::FilterMode<\n>
1161
1134
  <endif>
1162
1135
  <scopes:{<if(it.isDynamicGlobalScope)><globalAttributeScopeClass(scope=it)><\n><endif>}>
1136
+
1163
1137
  begin
1164
1138
  generated_using( "<fileName>", "<ANTLRVersion>", "<runtimeLibraryVersion()>" )
1165
1139
  rescue NoMethodError => error
1166
- error.name.to_sym == :generated_using or raise
1140
+ # ignore
1167
1141
  end
1168
1142
 
1169
- RULE_NAMES = [<trunc(rules):{r|"<r.ruleName>"}; separator=", ", wrap="\n", anchor>].freeze
1170
- RULE_METHODS = [<trunc(rules):{r|:<r.ruleName; format="lexerRule">}; separator=", ", wrap="\n", anchor>].freeze
1143
+ RULE_NAMES = [ <trunc(rules):{r|"<r.ruleName>"}; separator=", ", wrap="\n", anchor> ].freeze
1144
+ RULE_METHODS = [ <trunc(rules):{r|:<r.ruleName; format="lexerRule">}; separator=", ", wrap="\n", anchor> ].freeze
1171
1145
 
1172
1146
  <if(grammar.delegators)>
1173
1147
  masters( <grammar.delegators:{d|:<d.name>}; separator=", "> )<\n>
@@ -1176,25 +1150,17 @@ class <if(grammar.delegator)><grammar.name><else>Lexer<endif> \< <superClass>
1176
1150
  imports( <grammar.directDelegates:{d|:<d.name>}; separator=", "> )<\n>
1177
1151
  <endif>
1178
1152
 
1179
- def initialize(<grammar.delegators:{g|<g:delegateName()>, }>input=nil, options = {})
1180
- super(input, options)
1153
+ def initialize( <grammar.delegators:{g|<g:delegateName()>, }>input=nil, options = {} )
1154
+ super( input, options )
1181
1155
  <if(memoize)>
1182
1156
  <if(grammar.grammarIsRoot)>
1183
1157
  @state.rule_memory = {}<\n>
1184
1158
  <endif>
1185
1159
  <endif>
1186
- <grammar.delegators:{g|@<g:delegateName()> = <g:delegateName()><\n>}><grammar.directDelegates:{g|@<g:delegateName()> = <newDelegate(g)><\n>}><last(grammar.delegators):{g|@parent = @<g:delegateName()><\n>}>
1187
- <if(actions.lexer.init)>
1188
-
1189
- # - - - - - - - - - - @init - - - - - - - - - - - - - - -
1190
- <actions.lexer.init><\n>
1191
- <endif>
1160
+ <grammar.delegators:{g|@<g:delegateName()> = <g:delegateName()><\n>}><grammar.directDelegates:{g|@<g:delegateName()> = <newDelegate(g)><\n>}><last(grammar.delegators):{g|@parent = @<g:delegateName()><\n>}><placeAction(scope="lexer",name="init")>
1192
1161
  end
1193
- <if(actions.lexer.members)>
1194
1162
 
1195
- # - - - - - - - - - - custom @members - - - - - - - - - - -
1196
- <actions.lexer.members>
1197
- <endif>
1163
+ <placeAction(scope="lexer",name="members")>
1198
1164
 
1199
1165
  # - - - - - - - - - - - lexer rules - - - - - - - - - - - -
1200
1166
  <rules:{<it><\n>}>
@@ -1219,7 +1185,7 @@ class <if(grammar.delegator)><grammar.name><else>Lexer<endif> \< <superClass>
1219
1185
  end # class <if(grammar.delegator)><grammar.name><else>Lexer<endif> \< <superClass>
1220
1186
  <if(!actions.(actionScope).main)>
1221
1187
 
1222
- at_exit { <if(grammar.delegator)><grammar.name><else>Lexer<endif>.main(ARGV) } if __FILE__ == $0
1188
+ at_exit { <if(grammar.delegator)><grammar.name><else>Lexer<endif>.main( ARGV ) } if __FILE__ == $0
1223
1189
  <endif>
1224
1190
  >>
1225
1191
 
@@ -1239,7 +1205,7 @@ lexerRuleLabelDefs() ::= <<
1239
1205
  lexerRule(ruleName,nakedBlock,ruleDescriptor,block,memoize) ::= <<
1240
1206
  # lexer rule <ruleName; format="lexerRule"> (<ruleName>)
1241
1207
  # (in <fileName>)
1242
- def <ruleName; format="lexerRule"><if(ruleDescriptor.parameterScope)>(<ruleDescriptor.parameterScope:parameterScope(scope=it)>)<endif>
1208
+ def <ruleName; format="lexerRule"><if(ruleDescriptor.parameterScope)>( <ruleDescriptor.parameterScope:parameterScope(scope=it)> )<endif>
1243
1209
  <traceIn()><ruleScopeSetUp()><ruleDeclarations()><if(memoize)>
1244
1210
  <if(backtracking)>
1245
1211
 
@@ -1308,7 +1274,7 @@ end
1308
1274
  lexerRulePropertyRef_text(scope, attr) ::= "self.text"
1309
1275
  lexerRulePropertyRef_type(scope, attr) ::= "type"
1310
1276
  lexerRulePropertyRef_line(scope, attr) ::= "@state.token_start_line"
1311
- lexerRulePropertyRef_pos(scope, attr) ::= "@state.token_start_column"
1277
+ lexerRulePropertyRef_pos(scope, attr) ::= "@state.token_start_column"
1312
1278
 
1313
1279
  /** Undefined, but present for consistency with Token
1314
1280
  * attributes; set to -1
@@ -1316,7 +1282,7 @@ lexerRulePropertyRef_pos(scope, attr) ::= "@state.token_start_column"
1316
1282
  lexerRulePropertyRef_index(scope, attr) ::= "-1"
1317
1283
  lexerRulePropertyRef_channel(scope, attr) ::= "channel"
1318
1284
  lexerRulePropertyRef_start(scope, attr) ::= "@state.token_start_position"
1319
- lexerRulePropertyRef_stop(scope, attr) ::= "(self.character_index - 1)"
1285
+ lexerRulePropertyRef_stop(scope, attr) ::= "( self.character_index - 1 )"
1320
1286
 
1321
1287
  /** A lexer rule reference */
1322
1288
  lexerRuleRef(rule,label,args,elementIndex,scope) ::= <<
@@ -1361,7 +1327,7 @@ charRef(char,label) ::= <<
1361
1327
  <if(label)>
1362
1328
  <label; format="label"> = @input.peek<\n>
1363
1329
  <endif>
1364
- match(<char>)
1330
+ match( <char> )
1365
1331
  >>
1366
1332
 
1367
1333
  /** match a character range */
@@ -1369,7 +1335,7 @@ charRangeRef(a,b,label) ::= <<
1369
1335
  <if(label)>
1370
1336
  <label; format="label"> = @input.peek<\n>
1371
1337
  <endif>
1372
- match_range(<a>, <b>)
1338
+ match_range( <a>, <b> )
1373
1339
  >>
1374
1340
 
1375
1341
  filteringNextToken() ::= ""
@@ -1379,7 +1345,7 @@ filteringActionGate() ::= "@state.backtracking == 1"
1379
1345
  lexerStringRef(string,label) ::= <<
1380
1346
  <if(label)>
1381
1347
  <label; format="label">_start = self.character_index
1382
- match(<string>)
1348
+ match( <string> )
1383
1349
  <label; format="label"> = create_token do |t|
1384
1350
  t.input = @input
1385
1351
  t.type = ANTLR3::INVALID_TOKEN_TYPE
@@ -1388,16 +1354,16 @@ match(<string>)
1388
1354
  t.stop = character_index - 1
1389
1355
  end
1390
1356
  <else>
1391
- match(<string>)
1357
+ match( <string> )
1392
1358
  <endif>
1393
1359
  >>
1394
1360
 
1395
1361
 
1396
1362
  /** EOF in the lexer */
1397
1363
  lexerMatchEOF(label,elementIndex) ::= <<
1398
- <if(label)>
1364
+ <if(label)>
1399
1365
  <label; format="label">_start_<elementIndex> = character_index
1400
- match(ANTLR3::EOF)
1366
+ match( ANTLR3::EOF )
1401
1367
  <label; format="label"> = create_token do |t|
1402
1368
  t.input = @input
1403
1369
  t.type = ANTLR3::INVALID_TOKEN_TYPE
@@ -1406,7 +1372,7 @@ match(ANTLR3::EOF)
1406
1372
  t.stop = character_index - 1
1407
1373
  end<\n>
1408
1374
  <else>
1409
- match(ANTLR3::EOF)<\n>
1375
+ match( ANTLR3::EOF )<\n>
1410
1376
  <endif>
1411
1377
  >>
1412
1378
 
@@ -1420,7 +1386,7 @@ rulePropertyRef_stop(scope, attr) ::= "return_value.stop"
1420
1386
  rulePropertyRef_tree(scope, attr) ::= "return_value.tree"
1421
1387
 
1422
1388
  /** $text in parser rule */
1423
- rulePropertyRef_text(scope, attr) ::= "@input.to_s(return_value.start, @input.look(-1))"
1389
+ rulePropertyRef_text(scope, attr) ::= "@input.to_s( return_value.start, @input.look( -1 ) )"
1424
1390
 
1425
1391
  /** $template in parser rule */
1426
1392
  rulePropertyRef_st(scope, attr) ::= "return_value.template"
@@ -1465,7 +1431,7 @@ autoloadDelegates() ::= <<
1465
1431
 
1466
1432
  delegateLexerRule(ruleDescriptor) ::= <<
1467
1433
  # delegated lexer rule <ruleDescriptor.name; format="lexerRule"> (<ruleDescriptor.name> in the grammar)
1468
- def <ruleDescriptor.name; format="lexerRule">(<ruleDescriptor.parameterScope:parameterScope(scope=it)>)
1434
+ def <ruleDescriptor.name; format="lexerRule"><if(ruleDescriptor.parameterScope)>( <ruleDescriptor.parameterScope:parameterScope(scope=it)> )<endif>
1469
1435
  <methodCall(del=ruleDescriptor.grammar, n={<ruleDescriptor.name; format="lexerRule">}, args=ruleDescriptor.parameterScope.attributes)>
1470
1436
  end
1471
1437
  >>
@@ -1479,7 +1445,9 @@ grammarClassName() ::= <<
1479
1445
  >>
1480
1446
 
1481
1447
  newDelegate(gram) ::= <<
1482
- <gram.name>.new(<trunc(gram.delegators):{p|<p:delegateName()>, }>self, @input, :state => @state<@delegateOptions()>)
1448
+ <gram.name>.new( <trunc(gram.delegators):{p|<p:delegateName()>, }>
1449
+ self, @input, :state => @state<@delegateOptions()>
1450
+ )
1483
1451
  >>
1484
1452
 
1485
1453
  placeAction(scope, name) ::= <<
@@ -1491,4 +1459,4 @@ placeAction(scope, name) ::= <<
1491
1459
  <endif>
1492
1460
  >>
1493
1461
 
1494
- runtimeLibraryVersion() ::= "1.6.3"
1462
+ runtimeLibraryVersion() ::= "1.7.2"