antlr3 1.4.0 → 1.6.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.
@@ -728,21 +728,30 @@ class CommonTokenStream
728
728
  # token.name != 'WHITE_SPACE'
729
729
  # end
730
730
  #
731
- def initialize(token_source, options = {})
732
- @token_source = token_source
731
+ def initialize( token_source, options = {} )
732
+ case token_source
733
+ when CommonTokenStream
734
+ # this is useful in cases where you want to convert a CommonTokenStream
735
+ # to a RewriteTokenStream or other variation of the standard token stream
736
+ stream = token_source
737
+ @token_source = stream.token_source
738
+ @channel = options.fetch( :channel ) { stream.channel or DEFAULT_CHANNEL }
739
+ @source_name = options.fetch( :source_name ) { stream.source_name }
740
+ tokens = stream.tokens.map { | t | t.dup }
741
+ else
742
+ @token_source = token_source
743
+ @channel = options.fetch( :channel, DEFAULT_CHANNEL )
744
+ @source_name = options.fetch( :source_name ) { @token_source.source_name rescue nil }
745
+ tokens = @token_source.to_a
746
+ end
733
747
  @last_marker = nil
734
- @channel = options.fetch(:channel, DEFAULT_CHANNEL)
735
-
736
- @tokens =
737
- block_given? ? @token_source.select { |token| yield(token, self) } :
738
- @token_source.to_a
748
+ @tokens = block_given? ? tokens.select { | t | yield( t, self ) } : tokens
739
749
  @tokens.each_with_index { |t, i| t.index = i }
740
750
  @position =
741
751
  if first_token = @tokens.find { |t| t.channel == @channel }
742
752
  @tokens.index(first_token)
743
753
  else @tokens.length
744
754
  end
745
- @source_name = options.fetch(:source_name) { @token_source.source_name rescue nil }
746
755
  end
747
756
 
748
757
  #
@@ -20,6 +20,11 @@ module Builder
20
20
  super.push( :template )
21
21
  end
22
22
 
23
+ def load_templates( group_file )
24
+ @template_library =
25
+ ANTLR3::Template::Group.load( group_file )
26
+ end
27
+
23
28
  def define_template( name, source, &block )
24
29
  template_library.define_template( name, source, &block )
25
30
  end
@@ -91,6 +96,12 @@ class Group < Module
91
96
  end
92
97
 
93
98
  def self.load( group_file, options = {} )
99
+ unless( File.file?( group_file ) )
100
+ dir = $LOAD_PATH.find do | d |
101
+ File.file?( File.join( dir, group_file ) )
102
+ end or raise( LoadError, "no such template group file to load %s" % group_file )
103
+ group_file = File.join( dir, group_file )
104
+ end
94
105
  namespace = options.fetch( :namespace, ::Object )
95
106
  input = ANTLR3::FileStream.new( group_file, options )
96
107
  lexer = Lexer.new( input, options )
@@ -3,9 +3,9 @@
3
3
  # Group.g
4
4
  #
5
5
  # Generated using ANTLR version: 3.2.1-SNAPSHOT Dec 18, 2009 04:29:28
6
- # Ruby runtime library version: 1.3.1
6
+ # Ruby runtime library version: 1.5.0
7
7
  # Input grammar file: Group.g
8
- # Generated at: 2010-01-17 06:59:16
8
+ # Generated at: 2010-01-27 10:24:01
9
9
  #
10
10
 
11
11
  # ~~~> start load path setup
@@ -16,7 +16,7 @@ antlr_load_failed = proc do
16
16
  load_path = $LOAD_PATH.map { |dir| ' - ' << dir }.join( $/ )
17
17
  raise LoadError, <<-END.strip!
18
18
 
19
- Failed to load the ANTLR3 runtime library (version 1.3.1):
19
+ Failed to load the ANTLR3 runtime library (version 1.5.0):
20
20
 
21
21
  Ensure the library has been installed on your system and is available
22
22
  on the load path. If rubygems is available on your system, this can
@@ -30,7 +30,7 @@ Current load path:
30
30
  END
31
31
  end
32
32
 
33
- defined?(ANTLR3) or begin
33
+ defined?( ANTLR3 ) or begin
34
34
 
35
35
  # 1: try to load the ruby antlr3 runtime library from the system path
36
36
  require 'antlr3'
@@ -38,7 +38,7 @@ defined?(ANTLR3) or begin
38
38
  rescue LoadError
39
39
 
40
40
  # 2: try to load rubygems if it isn't already loaded
41
- defined?(Gem) or begin
41
+ defined?( Gem ) or begin
42
42
  require 'rubygems'
43
43
  rescue LoadError
44
44
  antlr_load_failed.call
@@ -46,7 +46,7 @@ rescue LoadError
46
46
 
47
47
  # 3: try to activate the antlr3 gem
48
48
  begin
49
- Gem.activate( 'antlr3', '= 1.3.1' )
49
+ Gem.activate( 'antlr3', '~> 1.5.0' )
50
50
  rescue Gem::LoadError
51
51
  antlr_load_failed.call
52
52
  end
@@ -75,10 +75,10 @@ class Group
75
75
  module TokenData
76
76
 
77
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)
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
82
 
83
83
  end
84
84
 
@@ -88,7 +88,7 @@ class Group
88
88
  include TokenData
89
89
 
90
90
  begin
91
- generated_using( "Group.g", "3.2.1-SNAPSHOT Dec 18, 2009 04:29:28", "1.3.1" )
91
+ generated_using( "Group.g", "3.2.1-SNAPSHOT Dec 18, 2009 04:29:28", "1.5.0" )
92
92
  rescue NoMethodError => error
93
93
  error.name.to_sym == :generated_using or raise
94
94
  end
@@ -358,10 +358,10 @@ class Group
358
358
 
359
359
 
360
360
  # - - - - main rule block - - - -
361
- # at line 104:5: 'A' .. 'Z' ( 'a' .. 'z' | '_' | 'A' .. 'Z' | '0' .. '9' )*
361
+ # at line 127:5: 'A' .. 'Z' ( 'a' .. 'z' | '_' | 'A' .. 'Z' | '0' .. '9' )*
362
362
  match_range(?A, ?Z)
363
- # at line 104:14: ( 'a' .. 'z' | '_' | 'A' .. 'Z' | '0' .. '9' )*
364
- loop do # decision 1
363
+ # at line 127:14: ( 'a' .. 'z' | '_' | 'A' .. 'Z' | '0' .. '9' )*
364
+ while true # decision 1
365
365
  alt_1 = 2
366
366
  look_1_0 = @input.peek(1)
367
367
 
@@ -408,7 +408,7 @@ class Group
408
408
 
409
409
 
410
410
  # - - - - main rule block - - - -
411
- # at line 108:5: ( 'a' .. 'z' | '_' ) ( 'a' .. 'z' | '_' | 'A' .. 'Z' | '0' .. '9' )*
411
+ # at line 131:5: ( 'a' .. 'z' | '_' ) ( 'a' .. 'z' | '_' | 'A' .. 'Z' | '0' .. '9' )*
412
412
  if @input.peek(1) == ?_ || @input.peek(1).between?(?a, ?z)
413
413
  @input.consume
414
414
  else
@@ -418,8 +418,8 @@ class Group
418
418
  end
419
419
 
420
420
 
421
- # at line 109:5: ( 'a' .. 'z' | '_' | 'A' .. 'Z' | '0' .. '9' )*
422
- loop do # decision 2
421
+ # at line 132:5: ( 'a' .. 'z' | '_' | 'A' .. 'Z' | '0' .. '9' )*
422
+ while true # decision 2
423
423
  alt_2 = 2
424
424
  look_2_0 = @input.peek(1)
425
425
 
@@ -466,10 +466,10 @@ class Group
466
466
 
467
467
 
468
468
  # - - - - main rule block - - - -
469
- # at line 113:5: '<<<' ( options {greedy=false; } : '\\\\' . | . )* '>>>'
469
+ # at line 136:5: '<<<' ( options {greedy=false; } : '\\\\' . | . )* '>>>'
470
470
  match("<<<")
471
- # at line 114:5: ( options {greedy=false; } : '\\\\' . | . )*
472
- loop do # decision 3
471
+ # at line 137:5: ( options {greedy=false; } : '\\\\' . | . )*
472
+ while true # decision 3
473
473
  alt_3 = 3
474
474
  look_3_0 = @input.peek(1)
475
475
 
@@ -506,12 +506,12 @@ class Group
506
506
  end
507
507
  case alt_3
508
508
  when 1
509
- # at line 114:35: '\\\\' .
509
+ # at line 137:35: '\\\\' .
510
510
  match(?\\)
511
511
  match_any
512
512
 
513
513
  when 2
514
- # at line 114:44: .
514
+ # at line 137:44: .
515
515
  match_any
516
516
 
517
517
  else
@@ -541,7 +541,7 @@ class Group
541
541
 
542
542
 
543
543
  # - - - - main rule block - - - -
544
- # at line 119:3: ( '\"' (~ ( '\\\\' | '\"' ) | '\\\\' . )* '\"' | '\\'' (~ ( '\\\\' | '\\'' ) | '\\\\' . )* '\\'' )
544
+ # at line 142:3: ( '\"' (~ ( '\\\\' | '\"' ) | '\\\\' . )* '\"' | '\\'' (~ ( '\\\\' | '\\'' ) | '\\\\' . )* '\\'' )
545
545
  alt_6 = 2
546
546
  look_6_0 = @input.peek(1)
547
547
 
@@ -555,10 +555,10 @@ class Group
555
555
  end
556
556
  case alt_6
557
557
  when 1
558
- # at line 119:5: '\"' (~ ( '\\\\' | '\"' ) | '\\\\' . )* '\"'
558
+ # at line 142:5: '\"' (~ ( '\\\\' | '\"' ) | '\\\\' . )* '\"'
559
559
  match(?")
560
- # at line 119:10: (~ ( '\\\\' | '\"' ) | '\\\\' . )*
561
- loop do # decision 4
560
+ # at line 142:10: (~ ( '\\\\' | '\"' ) | '\\\\' . )*
561
+ while true # decision 4
562
562
  alt_4 = 3
563
563
  look_4_0 = @input.peek(1)
564
564
 
@@ -570,7 +570,7 @@ class Group
570
570
  end
571
571
  case alt_4
572
572
  when 1
573
- # at line 119:12: ~ ( '\\\\' | '\"' )
573
+ # at line 142:12: ~ ( '\\\\' | '\"' )
574
574
  if @input.peek(1).between?(0x0000, ?!) || @input.peek(1).between?(?#, ?[) || @input.peek(1).between?(?], 0x00FF)
575
575
  @input.consume
576
576
  else
@@ -582,7 +582,7 @@ class Group
582
582
 
583
583
 
584
584
  when 2
585
- # at line 119:31: '\\\\' .
585
+ # at line 142:31: '\\\\' .
586
586
  match(?\\)
587
587
  match_any
588
588
 
@@ -593,10 +593,10 @@ class Group
593
593
  match(?")
594
594
 
595
595
  when 2
596
- # at line 120:5: '\\'' (~ ( '\\\\' | '\\'' ) | '\\\\' . )* '\\''
596
+ # at line 143:5: '\\'' (~ ( '\\\\' | '\\'' ) | '\\\\' . )* '\\''
597
597
  match(?\')
598
- # at line 120:10: (~ ( '\\\\' | '\\'' ) | '\\\\' . )*
599
- loop do # decision 5
598
+ # at line 143:10: (~ ( '\\\\' | '\\'' ) | '\\\\' . )*
599
+ while true # decision 5
600
600
  alt_5 = 3
601
601
  look_5_0 = @input.peek(1)
602
602
 
@@ -608,7 +608,7 @@ class Group
608
608
  end
609
609
  case alt_5
610
610
  when 1
611
- # at line 120:12: ~ ( '\\\\' | '\\'' )
611
+ # at line 143:12: ~ ( '\\\\' | '\\'' )
612
612
  if @input.peek(1).between?(0x0000, ?&) || @input.peek(1).between?(?(, ?[) || @input.peek(1).between?(?], 0x00FF)
613
613
  @input.consume
614
614
  else
@@ -620,7 +620,7 @@ class Group
620
620
 
621
621
 
622
622
  when 2
623
- # at line 120:31: '\\\\' .
623
+ # at line 143:31: '\\\\' .
624
624
  match(?\\)
625
625
  match_any
626
626
 
@@ -652,7 +652,7 @@ class Group
652
652
 
653
653
 
654
654
  # - - - - main rule block - - - -
655
- # at line 125:3: ( ( '#' | '//' ) (~ '\\n' )* | '/*' ( . )* '*/' )
655
+ # at line 148:3: ( ( '#' | '//' ) (~ '\\n' )* | '/*' ( . )* '*/' )
656
656
  alt_10 = 2
657
657
  look_10_0 = @input.peek(1)
658
658
 
@@ -675,8 +675,8 @@ class Group
675
675
  end
676
676
  case alt_10
677
677
  when 1
678
- # at line 125:5: ( '#' | '//' ) (~ '\\n' )*
679
- # at line 125:5: ( '#' | '//' )
678
+ # at line 148:5: ( '#' | '//' ) (~ '\\n' )*
679
+ # at line 148:5: ( '#' | '//' )
680
680
  alt_7 = 2
681
681
  look_7_0 = @input.peek(1)
682
682
 
@@ -690,16 +690,16 @@ class Group
690
690
  end
691
691
  case alt_7
692
692
  when 1
693
- # at line 125:7: '#'
693
+ # at line 148:7: '#'
694
694
  match(?#)
695
695
 
696
696
  when 2
697
- # at line 125:13: '//'
697
+ # at line 148:13: '//'
698
698
  match("//")
699
699
 
700
700
  end
701
- # at line 125:20: (~ '\\n' )*
702
- loop do # decision 8
701
+ # at line 148:20: (~ '\\n' )*
702
+ while true # decision 8
703
703
  alt_8 = 2
704
704
  look_8_0 = @input.peek(1)
705
705
 
@@ -709,7 +709,7 @@ class Group
709
709
  end
710
710
  case alt_8
711
711
  when 1
712
- # at line 125:20: ~ '\\n'
712
+ # at line 148:20: ~ '\\n'
713
713
  if @input.peek(1).between?(0x0000, ?\t) || @input.peek(1).between?(0x000B, 0x00FF)
714
714
  @input.consume
715
715
  else
@@ -726,10 +726,10 @@ class Group
726
726
  end # loop for decision 8
727
727
 
728
728
  when 2
729
- # at line 126:5: '/*' ( . )* '*/'
729
+ # at line 149:5: '/*' ( . )* '*/'
730
730
  match("/*")
731
- # at line 126:10: ( . )*
732
- loop do # decision 9
731
+ # at line 149:10: ( . )*
732
+ while true # decision 9
733
733
  alt_9 = 2
734
734
  look_9_0 = @input.peek(1)
735
735
 
@@ -748,7 +748,7 @@ class Group
748
748
  end
749
749
  case alt_9
750
750
  when 1
751
- # at line 126:10: .
751
+ # at line 149:10: .
752
752
  match_any
753
753
 
754
754
  else
@@ -781,10 +781,10 @@ class Group
781
781
 
782
782
 
783
783
  # - - - - main rule block - - - -
784
- # at line 130:5: ( ' ' | '\\t' | '\\n' | '\\r' | '\\f' )+
785
- # at file 130:5: ( ' ' | '\\t' | '\\n' | '\\r' | '\\f' )+
784
+ # at line 153:5: ( ' ' | '\\t' | '\\n' | '\\r' | '\\f' )+
785
+ # at file 153:5: ( ' ' | '\\t' | '\\n' | '\\r' | '\\f' )+
786
786
  match_count_11 = 0
787
- loop do
787
+ while true
788
788
  alt_11 = 2
789
789
  look_11_0 = @input.peek(1)
790
790
 
@@ -3,9 +3,9 @@
3
3
  # Group.g
4
4
  #
5
5
  # Generated using ANTLR version: 3.2.1-SNAPSHOT Dec 18, 2009 04:29:28
6
- # Ruby runtime library version: 1.3.1
6
+ # Ruby runtime library version: 1.5.0
7
7
  # Input grammar file: Group.g
8
- # Generated at: 2010-01-17 06:59:16
8
+ # Generated at: 2010-01-27 10:24:01
9
9
  #
10
10
 
11
11
  # ~~~> start load path setup
@@ -16,7 +16,7 @@ antlr_load_failed = proc do
16
16
  load_path = $LOAD_PATH.map { |dir| ' - ' << dir }.join( $/ )
17
17
  raise LoadError, <<-END.strip!
18
18
 
19
- Failed to load the ANTLR3 runtime library (version 1.3.1):
19
+ Failed to load the ANTLR3 runtime library (version 1.5.0):
20
20
 
21
21
  Ensure the library has been installed on your system and is available
22
22
  on the load path. If rubygems is available on your system, this can
@@ -30,7 +30,7 @@ Current load path:
30
30
  END
31
31
  end
32
32
 
33
- defined?(ANTLR3) or begin
33
+ defined?( ANTLR3 ) or begin
34
34
 
35
35
  # 1: try to load the ruby antlr3 runtime library from the system path
36
36
  require 'antlr3'
@@ -38,7 +38,7 @@ defined?(ANTLR3) or begin
38
38
  rescue LoadError
39
39
 
40
40
  # 2: try to load rubygems if it isn't already loaded
41
- defined?(Gem) or begin
41
+ defined?( Gem ) or begin
42
42
  require 'rubygems'
43
43
  rescue LoadError
44
44
  antlr_load_failed.call
@@ -46,7 +46,7 @@ rescue LoadError
46
46
 
47
47
  # 3: try to activate the antlr3 gem
48
48
  begin
49
- Gem.activate( 'antlr3', '= 1.3.1' )
49
+ Gem.activate( 'antlr3', '~> 1.5.0' )
50
50
  rescue Gem::LoadError
51
51
  antlr_load_failed.call
52
52
  end
@@ -75,10 +75,10 @@ class Group
75
75
  module TokenData
76
76
 
77
77
  # define the token constants
78
- define_tokens(:ID => 5, :EOF => -1, :T__19 => 19, :T__16 => 16, :WS => 9,
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)
78
+ define_tokens( :ID => 5, :EOF => -1, :T__19 => 19, :T__16 => 16, :WS => 9,
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
82
 
83
83
  # register the proper human-readable name or literal value
84
84
  # for each token type
@@ -86,9 +86,9 @@ class Group
86
86
  # this is necessary because anonymous tokens, which are
87
87
  # created from literal values in the grammar, do not
88
88
  # have descriptive names
89
- register_names("CONSTANT", "ID", "TEMPLATE", "STRING", "COMMENT", "WS",
90
- "'group'", "'::'", "';'", "'::='", "'('", "')'", "','",
91
- "'*'", "'&'", "'='")
89
+ register_names( "CONSTANT", "ID", "TEMPLATE", "STRING", "COMMENT", "WS",
90
+ "'group'", "'::'", "';'", "'::='", "'('", "')'", "','",
91
+ "'*'", "'&'", "'='" )
92
92
 
93
93
  end
94
94
 
@@ -96,16 +96,16 @@ class Group
96
96
  class Parser < ANTLR3::Parser
97
97
  @grammar_home = Group
98
98
 
99
- RULE_METHODS = [:group_spec, :group_name, :member, :parameter_declaration,
100
- :parameters, :parameter].freeze
99
+ RULE_METHODS = [ :group_spec, :group_name, :member, :parameter_declaration,
100
+ :parameters, :parameter ].freeze
101
101
 
102
102
 
103
103
  include TokenData
104
104
 
105
- generated_using( "Group.g", "3.2.1-SNAPSHOT Dec 18, 2009 04:29:28", "1.3.1" )
105
+ generated_using( "Group.g", "3.2.1-SNAPSHOT Dec 18, 2009 04:29:28", "1.5.0" )
106
106
 
107
- def initialize(input, options = {})
108
- super(input, options)
107
+ def initialize( input, options = {} )
108
+ super( input, options )
109
109
 
110
110
 
111
111
  end
@@ -123,10 +123,33 @@ class Group
123
123
  return( group )
124
124
  end
125
125
 
126
+ def unescape( text )
127
+ text.gsub( /\\(?:([abefnrstv])|([0-7]{3})|x([0-9a-fA-F]{2})|(.))/ ) do
128
+ if $1
129
+ case $1[0]
130
+ when ?a then "\a"
131
+ when ?b then "\b"
132
+ when ?e then "\e"
133
+ when ?f then "\f"
134
+ when ?n then "\n"
135
+ when ?r then "\r"
136
+ when ?s then "\s"
137
+ when ?t then "\t"
138
+ when ?v then "\v"
139
+ end
140
+ elsif $2 then $2.to_i( 8 ).chr
141
+ elsif $3 then $3.to_i( 16 ).chr
142
+ elsif $4 then $4
143
+ end
144
+ end
145
+ end
146
+
126
147
  def extract_template( token )
127
148
  case token.type
128
149
  when TEMPLATE
129
150
  token.text.gsub( /\A<<<\r?\n?|\r?\n?>>>\Z/, '' )
151
+ when STRING
152
+ unescape( token.text[1...-1] )
130
153
  end
131
154
  end
132
155
 
@@ -136,10 +159,12 @@ class Group
136
159
 
137
160
  # - - - - - - - - - - - - Rules - - - - - - - - - - - - -
138
161
 
162
+ #
139
163
  # parser rule group_spec
140
164
  #
141
165
  # (in Group.g)
142
- # 58:1: group_spec[ namespace ] returns [ group ] : ( group_name[ $namespace ] | ) ( member[ $group ] )* ;
166
+ # 81:1: group_spec[ namespace ] returns [ group ] : ( group_name[ $namespace ] | ) ( member[ $group ] )* ;
167
+ #
143
168
  def group_spec(namespace)
144
169
  # -> uncomment the next line to manually enable rule tracing
145
170
  # trace_in(__method__, 1)
@@ -147,8 +172,8 @@ class Group
147
172
  group_name1 = nil
148
173
 
149
174
  begin
150
- # at line 59:5: ( group_name[ $namespace ] | ) ( member[ $group ] )*
151
- # at line 59:5: ( group_name[ $namespace ] | )
175
+ # at line 82:5: ( group_name[ $namespace ] | ) ( member[ $group ] )*
176
+ # at line 82:5: ( group_name[ $namespace ] | )
152
177
  alt_1 = 2
153
178
  look_1_0 = @input.peek(1)
154
179
 
@@ -162,7 +187,7 @@ class Group
162
187
  end
163
188
  case alt_1
164
189
  when 1
165
- # at line 59:7: group_name[ $namespace ]
190
+ # at line 82:7: group_name[ $namespace ]
166
191
  @state.following.push(TOKENS_FOLLOWING_group_name_IN_group_spec_87)
167
192
  group_name1 = group_name(namespace)
168
193
  @state.following.pop
@@ -171,14 +196,14 @@ class Group
171
196
  # <-- action
172
197
 
173
198
  when 2
174
- # at line 60:7:
199
+ # at line 83:7:
175
200
  # --> action
176
201
  group = ANTLR3::Template::Group.new
177
202
  # <-- action
178
203
 
179
204
  end
180
- # at line 62:5: ( member[ $group ] )*
181
- loop do # decision 2
205
+ # at line 85:5: ( member[ $group ] )*
206
+ while true # decision 2
182
207
  alt_2 = 2
183
208
  look_2_0 = @input.peek(1)
184
209
 
@@ -188,7 +213,7 @@ class Group
188
213
  end
189
214
  case alt_2
190
215
  when 1
191
- # at line 62:5: member[ $group ]
216
+ # at line 85:5: member[ $group ]
192
217
  @state.following.push(TOKENS_FOLLOWING_member_IN_group_spec_110)
193
218
  member(group)
194
219
  @state.following.pop
@@ -212,10 +237,12 @@ class Group
212
237
  end
213
238
 
214
239
 
240
+ #
215
241
  # parser rule group_name
216
242
  #
217
243
  # (in Group.g)
218
- # 65:1: group_name[ namespace ] returns [ group ] : 'group' (mod= CONSTANT '::' )* name= CONSTANT ( ';' )? ;
244
+ # 88:1: group_name[ namespace ] returns [ group ] : 'group' (mod= CONSTANT '::' )* name= CONSTANT ( ';' )? ;
245
+ #
219
246
  def group_name(namespace)
220
247
  # -> uncomment the next line to manually enable rule tracing
221
248
  # trace_in(__method__, 2)
@@ -224,10 +251,10 @@ class Group
224
251
  name = nil
225
252
 
226
253
  begin
227
- # at line 66:5: 'group' (mod= CONSTANT '::' )* name= CONSTANT ( ';' )?
254
+ # at line 89:5: 'group' (mod= CONSTANT '::' )* name= CONSTANT ( ';' )?
228
255
  match(T__10, TOKENS_FOLLOWING_T__10_IN_group_name_130)
229
- # at line 67:5: (mod= CONSTANT '::' )*
230
- loop do # decision 3
256
+ # at line 90:5: (mod= CONSTANT '::' )*
257
+ while true # decision 3
231
258
  alt_3 = 2
232
259
  look_3_0 = @input.peek(1)
233
260
 
@@ -242,7 +269,7 @@ class Group
242
269
  end
243
270
  case alt_3
244
271
  when 1
245
- # at line 68:7: mod= CONSTANT '::'
272
+ # at line 91:7: mod= CONSTANT '::'
246
273
  mod = match(CONSTANT, TOKENS_FOLLOWING_CONSTANT_IN_group_name_146)
247
274
  match(T__11, TOKENS_FOLLOWING_T__11_IN_group_name_148)
248
275
  # --> action
@@ -257,7 +284,7 @@ class Group
257
284
  # --> action
258
285
  group = fetch_group( namespace, name.text )
259
286
  # <-- action
260
- # at line 72:5: ( ';' )?
287
+ # at line 95:5: ( ';' )?
261
288
  alt_4 = 2
262
289
  look_4_0 = @input.peek(1)
263
290
 
@@ -266,7 +293,7 @@ class Group
266
293
  end
267
294
  case alt_4
268
295
  when 1
269
- # at line 72:5: ';'
296
+ # at line 95:5: ';'
270
297
  match(T__12, TOKENS_FOLLOWING_T__12_IN_group_name_179)
271
298
 
272
299
  end
@@ -285,24 +312,27 @@ class Group
285
312
  end
286
313
 
287
314
 
315
+ #
288
316
  # parser rule member
289
317
  #
290
318
  # (in Group.g)
291
- # 75:1: member[ group ] : name= ID ( parameter_declaration )? '::=' (aliased= ID | TEMPLATE | STRING ) ;
319
+ # 98:1: member[ group ] : name= ID ( parameter_declaration )? '::=' (aliased= ID | TEMPLATE | STRING ) ;
320
+ #
292
321
  def member(group)
293
322
  # -> uncomment the next line to manually enable rule tracing
294
323
  # trace_in(__method__, 3)
295
324
  name = nil
296
325
  aliased = nil
297
326
  __TEMPLATE3__ = nil
327
+ __STRING4__ = nil
298
328
  parameter_declaration2 = nil
299
329
  # - - - - @init action - - - -
300
330
  params = nil
301
331
 
302
332
  begin
303
- # at line 77:5: name= ID ( parameter_declaration )? '::=' (aliased= ID | TEMPLATE | STRING )
333
+ # at line 100:5: name= ID ( parameter_declaration )? '::=' (aliased= ID | TEMPLATE | STRING )
304
334
  name = match(ID, TOKENS_FOLLOWING_ID_IN_member_201)
305
- # at line 77:13: ( parameter_declaration )?
335
+ # at line 100:13: ( parameter_declaration )?
306
336
  alt_5 = 2
307
337
  look_5_0 = @input.peek(1)
308
338
 
@@ -311,7 +341,7 @@ class Group
311
341
  end
312
342
  case alt_5
313
343
  when 1
314
- # at line 77:15: parameter_declaration
344
+ # at line 100:15: parameter_declaration
315
345
  @state.following.push(TOKENS_FOLLOWING_parameter_declaration_IN_member_205)
316
346
  parameter_declaration2 = parameter_declaration
317
347
  @state.following.pop
@@ -321,7 +351,7 @@ class Group
321
351
 
322
352
  end
323
353
  match(T__13, TOKENS_FOLLOWING_T__13_IN_member_212)
324
- # at line 78:5: (aliased= ID | TEMPLATE | STRING )
354
+ # at line 101:5: (aliased= ID | TEMPLATE | STRING )
325
355
  alt_6 = 3
326
356
  case look_6 = @input.peek(1)
327
357
  when ID then alt_6 = 1
@@ -333,22 +363,25 @@ class Group
333
363
  end
334
364
  case alt_6
335
365
  when 1
336
- # at line 78:7: aliased= ID
366
+ # at line 101:7: aliased= ID
337
367
  aliased = match(ID, TOKENS_FOLLOWING_ID_IN_member_222)
338
368
  # --> action
339
- group.alias_template( aliased.text, name.text )
369
+ group.alias_template( name.text, aliased.text )
340
370
  # <-- action
341
371
 
342
372
  when 2
343
- # at line 79:7: TEMPLATE
373
+ # at line 102:7: TEMPLATE
344
374
  __TEMPLATE3__ = match(TEMPLATE, TOKENS_FOLLOWING_TEMPLATE_IN_member_232)
345
375
  # --> action
346
376
  group.define_template( name.text, extract_template( __TEMPLATE3__ ), params )
347
377
  # <-- action
348
378
 
349
379
  when 3
350
- # at line 80:7: STRING
351
- match(STRING, TOKENS_FOLLOWING_STRING_IN_member_244)
380
+ # at line 103:7: STRING
381
+ __STRING4__ = match(STRING, TOKENS_FOLLOWING_STRING_IN_member_244)
382
+ # --> action
383
+ group.define_template( name.text, extract_template( __STRING4__ ), params )
384
+ # <-- action
352
385
 
353
386
  end
354
387
 
@@ -366,21 +399,23 @@ class Group
366
399
  end
367
400
 
368
401
 
402
+ #
369
403
  # parser rule parameter_declaration
370
404
  #
371
405
  # (in Group.g)
372
- # 84:1: parameter_declaration returns [ list ] : ( '(' ( parameters )? ')' | parameters );
406
+ # 107:1: parameter_declaration returns [ list ] : ( '(' ( parameters )? ')' | parameters );
407
+ #
373
408
  def parameter_declaration
374
409
  # -> uncomment the next line to manually enable rule tracing
375
410
  # trace_in(__method__, 4)
376
411
  list = nil
377
- parameters4 = nil
378
412
  parameters5 = nil
413
+ parameters6 = nil
379
414
  # - - - - @init action - - - -
380
415
  list = nil
381
416
 
382
417
  begin
383
- # at line 86:3: ( '(' ( parameters )? ')' | parameters )
418
+ # at line 109:3: ( '(' ( parameters )? ')' | parameters )
384
419
  alt_8 = 2
385
420
  look_8_0 = @input.peek(1)
386
421
 
@@ -394,9 +429,9 @@ class Group
394
429
  end
395
430
  case alt_8
396
431
  when 1
397
- # at line 86:5: '(' ( parameters )? ')'
398
- match(T__14, TOKENS_FOLLOWING_T__14_IN_parameter_declaration_272)
399
- # at line 86:9: ( parameters )?
432
+ # at line 109:5: '(' ( parameters )? ')'
433
+ match(T__14, TOKENS_FOLLOWING_T__14_IN_parameter_declaration_278)
434
+ # at line 109:9: ( parameters )?
400
435
  alt_7 = 2
401
436
  look_7_0 = @input.peek(1)
402
437
 
@@ -405,24 +440,24 @@ class Group
405
440
  end
406
441
  case alt_7
407
442
  when 1
408
- # at line 86:11: parameters
409
- @state.following.push(TOKENS_FOLLOWING_parameters_IN_parameter_declaration_276)
410
- parameters4 = parameters
443
+ # at line 109:11: parameters
444
+ @state.following.push(TOKENS_FOLLOWING_parameters_IN_parameter_declaration_282)
445
+ parameters5 = parameters
411
446
  @state.following.pop
412
447
  # --> action
413
- list = parameters4
448
+ list = parameters5
414
449
  # <-- action
415
450
 
416
451
  end
417
- match(T__15, TOKENS_FOLLOWING_T__15_IN_parameter_declaration_283)
452
+ match(T__15, TOKENS_FOLLOWING_T__15_IN_parameter_declaration_289)
418
453
 
419
454
  when 2
420
- # at line 87:5: parameters
421
- @state.following.push(TOKENS_FOLLOWING_parameters_IN_parameter_declaration_289)
422
- parameters5 = parameters
455
+ # at line 110:5: parameters
456
+ @state.following.push(TOKENS_FOLLOWING_parameters_IN_parameter_declaration_295)
457
+ parameters6 = parameters
423
458
  @state.following.pop
424
459
  # --> action
425
- list = parameters5
460
+ list = parameters6
426
461
  # <-- action
427
462
 
428
463
  end
@@ -440,10 +475,12 @@ class Group
440
475
  end
441
476
 
442
477
 
478
+ #
443
479
  # parser rule parameters
444
480
  #
445
481
  # (in Group.g)
446
- # 90:1: parameters returns [ list ] : parameter[ $list ] ( ',' parameter[ $list ] )* ;
482
+ # 113:1: parameters returns [ list ] : parameter[ $list ] ( ',' parameter[ $list ] )* ;
483
+ #
447
484
  def parameters
448
485
  # -> uncomment the next line to manually enable rule tracing
449
486
  # trace_in(__method__, 5)
@@ -452,12 +489,12 @@ class Group
452
489
  list = ANTLR3::Template::ParameterList.new
453
490
 
454
491
  begin
455
- # at line 92:5: parameter[ $list ] ( ',' parameter[ $list ] )*
456
- @state.following.push(TOKENS_FOLLOWING_parameter_IN_parameters_313)
492
+ # at line 115:5: parameter[ $list ] ( ',' parameter[ $list ] )*
493
+ @state.following.push(TOKENS_FOLLOWING_parameter_IN_parameters_319)
457
494
  parameter(list)
458
495
  @state.following.pop
459
- # at line 92:24: ( ',' parameter[ $list ] )*
460
- loop do # decision 9
496
+ # at line 115:24: ( ',' parameter[ $list ] )*
497
+ while true # decision 9
461
498
  alt_9 = 2
462
499
  look_9_0 = @input.peek(1)
463
500
 
@@ -467,9 +504,9 @@ class Group
467
504
  end
468
505
  case alt_9
469
506
  when 1
470
- # at line 92:26: ',' parameter[ $list ]
471
- match(T__16, TOKENS_FOLLOWING_T__16_IN_parameters_318)
472
- @state.following.push(TOKENS_FOLLOWING_parameter_IN_parameters_320)
507
+ # at line 115:26: ',' parameter[ $list ]
508
+ match(T__16, TOKENS_FOLLOWING_T__16_IN_parameters_324)
509
+ @state.following.push(TOKENS_FOLLOWING_parameter_IN_parameters_326)
473
510
  parameter(list)
474
511
  @state.following.pop
475
512
 
@@ -492,10 +529,12 @@ class Group
492
529
  end
493
530
 
494
531
 
532
+ #
495
533
  # parser rule parameter
496
534
  #
497
535
  # (in Group.g)
498
- # 95:1: parameter[ parameters ] : ( '*' name= ID | '&' name= ID | name= ID ( '=' v= STRING )? );
536
+ # 118:1: parameter[ parameters ] : ( '*' name= ID | '&' name= ID | name= ID ( '=' v= STRING )? );
537
+ #
499
538
  def parameter(parameters)
500
539
  # -> uncomment the next line to manually enable rule tracing
501
540
  # trace_in(__method__, 6)
@@ -503,7 +542,7 @@ class Group
503
542
  v = nil
504
543
 
505
544
  begin
506
- # at line 96:3: ( '*' name= ID | '&' name= ID | name= ID ( '=' v= STRING )? )
545
+ # at line 119:3: ( '*' name= ID | '&' name= ID | name= ID ( '=' v= STRING )? )
507
546
  alt_11 = 3
508
547
  case look_11 = @input.peek(1)
509
548
  when T__17 then alt_11 = 1
@@ -515,28 +554,28 @@ class Group
515
554
  end
516
555
  case alt_11
517
556
  when 1
518
- # at line 96:5: '*' name= ID
519
- match(T__17, TOKENS_FOLLOWING_T__17_IN_parameter_338)
520
- name = match(ID, TOKENS_FOLLOWING_ID_IN_parameter_342)
557
+ # at line 119:5: '*' name= ID
558
+ match(T__17, TOKENS_FOLLOWING_T__17_IN_parameter_344)
559
+ name = match(ID, TOKENS_FOLLOWING_ID_IN_parameter_348)
521
560
  # --> action
522
561
  parameters.splat = name.text
523
562
  # <-- action
524
563
 
525
564
  when 2
526
- # at line 97:5: '&' name= ID
527
- match(T__18, TOKENS_FOLLOWING_T__18_IN_parameter_350)
528
- name = match(ID, TOKENS_FOLLOWING_ID_IN_parameter_354)
565
+ # at line 120:5: '&' name= ID
566
+ match(T__18, TOKENS_FOLLOWING_T__18_IN_parameter_356)
567
+ name = match(ID, TOKENS_FOLLOWING_ID_IN_parameter_360)
529
568
  # --> action
530
569
  parameters.block = name.text
531
570
  # <-- action
532
571
 
533
572
  when 3
534
- # at line 98:5: name= ID ( '=' v= STRING )?
535
- name = match(ID, TOKENS_FOLLOWING_ID_IN_parameter_364)
573
+ # at line 121:5: name= ID ( '=' v= STRING )?
574
+ name = match(ID, TOKENS_FOLLOWING_ID_IN_parameter_370)
536
575
  # --> action
537
576
  param = ANTLR3::Template::Parameter.new( name.text )
538
577
  # <-- action
539
- # at line 99:5: ( '=' v= STRING )?
578
+ # at line 122:5: ( '=' v= STRING )?
540
579
  alt_10 = 2
541
580
  look_10_0 = @input.peek(1)
542
581
 
@@ -545,9 +584,9 @@ class Group
545
584
  end
546
585
  case alt_10
547
586
  when 1
548
- # at line 99:7: '=' v= STRING
549
- match(T__19, TOKENS_FOLLOWING_T__19_IN_parameter_378)
550
- v = match(STRING, TOKENS_FOLLOWING_STRING_IN_parameter_382)
587
+ # at line 122:7: '=' v= STRING
588
+ match(T__19, TOKENS_FOLLOWING_T__19_IN_parameter_384)
589
+ v = match(STRING, TOKENS_FOLLOWING_STRING_IN_parameter_388)
551
590
  # --> action
552
591
  param.default = v.text
553
592
  # <-- action
@@ -586,20 +625,20 @@ class Group
586
625
  TOKENS_FOLLOWING_ID_IN_member_222 = Set[1]
587
626
  TOKENS_FOLLOWING_TEMPLATE_IN_member_232 = Set[1]
588
627
  TOKENS_FOLLOWING_STRING_IN_member_244 = Set[1]
589
- TOKENS_FOLLOWING_T__14_IN_parameter_declaration_272 = Set[5, 14, 15, 17, 18]
590
- TOKENS_FOLLOWING_parameters_IN_parameter_declaration_276 = Set[15]
591
- TOKENS_FOLLOWING_T__15_IN_parameter_declaration_283 = Set[1]
592
- TOKENS_FOLLOWING_parameters_IN_parameter_declaration_289 = Set[1]
593
- TOKENS_FOLLOWING_parameter_IN_parameters_313 = Set[1, 16]
594
- TOKENS_FOLLOWING_T__16_IN_parameters_318 = Set[5, 14, 17, 18]
595
- TOKENS_FOLLOWING_parameter_IN_parameters_320 = Set[1, 16]
596
- TOKENS_FOLLOWING_T__17_IN_parameter_338 = Set[5]
597
- TOKENS_FOLLOWING_ID_IN_parameter_342 = Set[1]
598
- TOKENS_FOLLOWING_T__18_IN_parameter_350 = Set[5]
599
- TOKENS_FOLLOWING_ID_IN_parameter_354 = Set[1]
600
- TOKENS_FOLLOWING_ID_IN_parameter_364 = Set[1, 19]
601
- TOKENS_FOLLOWING_T__19_IN_parameter_378 = Set[7]
602
- TOKENS_FOLLOWING_STRING_IN_parameter_382 = Set[1]
628
+ TOKENS_FOLLOWING_T__14_IN_parameter_declaration_278 = Set[5, 14, 15, 17, 18]
629
+ TOKENS_FOLLOWING_parameters_IN_parameter_declaration_282 = Set[15]
630
+ TOKENS_FOLLOWING_T__15_IN_parameter_declaration_289 = Set[1]
631
+ TOKENS_FOLLOWING_parameters_IN_parameter_declaration_295 = Set[1]
632
+ TOKENS_FOLLOWING_parameter_IN_parameters_319 = Set[1, 16]
633
+ TOKENS_FOLLOWING_T__16_IN_parameters_324 = Set[5, 14, 17, 18]
634
+ TOKENS_FOLLOWING_parameter_IN_parameters_326 = Set[1, 16]
635
+ TOKENS_FOLLOWING_T__17_IN_parameter_344 = Set[5]
636
+ TOKENS_FOLLOWING_ID_IN_parameter_348 = Set[1]
637
+ TOKENS_FOLLOWING_T__18_IN_parameter_356 = Set[5]
638
+ TOKENS_FOLLOWING_ID_IN_parameter_360 = Set[1]
639
+ TOKENS_FOLLOWING_ID_IN_parameter_370 = Set[1, 19]
640
+ TOKENS_FOLLOWING_T__19_IN_parameter_384 = Set[7]
641
+ TOKENS_FOLLOWING_STRING_IN_parameter_388 = Set[1]
603
642
 
604
643
  end # class Parser < ANTLR3::Parser
605
644