1324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#!/usr/bin/env ruby 2324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver# 3324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver# GroupFile.g 4324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver# 5324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver# Generated using ANTLR version: 3.2.1-SNAPSHOT Jun 18, 2010 05:38:11 6324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver# Ruby runtime library version: 1.7.5 7324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver# Input grammar file: GroupFile.g 8324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver# Generated at: 2010-07-03 23:15:35 9324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver# 10324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 11324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver# ~~~> start load path setup 12324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruverthis_directory = File.expand_path( File.dirname( __FILE__ ) ) 13324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver$LOAD_PATH.unshift( this_directory ) unless $LOAD_PATH.include?( this_directory ) 14324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 15324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruverantlr_load_failed = proc do 16324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver load_path = $LOAD_PATH.map { |dir| ' - ' << dir }.join( $/ ) 17324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver raise LoadError, <<-END.strip! 18324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 19324c4644fee44b9898524c09511bd33c3f12e2dfBen GruverFailed to load the ANTLR3 runtime library (version 1.7.5): 20324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 21324c4644fee44b9898524c09511bd33c3f12e2dfBen GruverEnsure the library has been installed on your system and is available 22324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruveron the load path. If rubygems is available on your system, this can 23324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruverbe done with the command: 24324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 25324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver gem install antlr3 26324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 27324c4644fee44b9898524c09511bd33c3f12e2dfBen GruverCurrent load path: 28324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#{ load_path } 29324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 30324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver END 31324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruverend 32324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 33324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruverdefined?( ANTLR3 ) or begin 34324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 35324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 1: try to load the ruby antlr3 runtime library from the system path 36324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver require 'antlr3' 37324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 38324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruverrescue LoadError 39324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 40324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 2: try to load rubygems if it isn't already loaded 41324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver defined?( Gem ) or begin 42324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver require 'rubygems' 43324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver rescue LoadError 44324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver antlr_load_failed.call 45324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 46324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 47324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 3: try to activate the antlr3 gem 48324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver begin 49324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver Gem.activate( 'antlr3', '~> 1.7.5' ) 50324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver rescue Gem::LoadError 51324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver antlr_load_failed.call 52324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 53324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 54324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver require 'antlr3' 55324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 56324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruverend 57324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver# <~~~ end load path setup 58324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 59324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver# - - - - - - begin action @parser::header - - - - - - 60324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver# GroupFile.g 61324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 62324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 63324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruvermodule ANTLR3 64324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruvermodule Template 65324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 66324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver# - - - - - - end action @parser::header - - - - - - - 67324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 68324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 69324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruvermodule GroupFile 70324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # TokenData defines all of the token type integer values 71324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # as constants, which will be included in all 72324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # ANTLR-generated recognizers. 73324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver const_defined?( :TokenData ) or TokenData = ANTLR3::TokenScheme.new 74324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 75324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver module TokenData 76324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 77324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # define the token constants 78324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver define_tokens( :ID => 5, :EOF => -1, :T__19 => 19, :T__16 => 16, :WS => 9, 79324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver :T__15 => 15, :T__18 => 18, :T__17 => 17, :T__12 => 12, 80324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver :TEMPLATE => 6, :T__11 => 11, :T__14 => 14, :T__13 => 13, 81324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver :T__10 => 10, :CONSTANT => 4, :COMMENT => 8, :STRING => 7 ) 82324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 83324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # register the proper human-readable name or literal value 84324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # for each token type 85324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 86324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # this is necessary because anonymous tokens, which are 87324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # created from literal values in the grammar, do not 88324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # have descriptive names 89324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver register_names( "CONSTANT", "ID", "TEMPLATE", "STRING", "COMMENT", "WS", 90324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver "'group'", "'::'", "';'", "'::='", "'('", "')'", "','", 91324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver "'*'", "'&'", "'='" ) 92324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 93324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 94324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 95324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 96324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver class Parser < ANTLR3::Parser 97324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver @grammar_home = GroupFile 98324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 99324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver RULE_METHODS = [ :group_spec, :group_name, :member, :parameter_declaration, 100324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver :parameters, :parameter ].freeze 101324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 102324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 103324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver include TokenData 104324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 105324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver begin 106324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver generated_using( "GroupFile.g", "3.2.1-SNAPSHOT Jun 18, 2010 05:38:11", "1.7.5" ) 107324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver rescue NoMethodError => error 108324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # ignore 109324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 110324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 111324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver def initialize( input, options = {} ) 112324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver super( input, options ) 113324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 114324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 115324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 116324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 117324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver def fetch_group( namespace, name ) 118324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver if namespace.const_defined?( name ) 119324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver group = namespace.const_get( name ) 120324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver unless group.is_a?( ANTLR3::Template::Group ) 121324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 122324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 123324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver else 124324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver group = ANTLR3::Template::Group.new 125324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver namespace.const_set( name, group ) 126324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 127324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver return( group ) 128324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 129324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 130324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver def unescape( text ) 131324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver text.gsub( /\\(?:([abefnrstv])|([0-7]{3})|x([0-9a-fA-F]{2})|(.))/ ) do 132324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver if $1 133324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver case $1[ 0 ] 134324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when ?a then "\a" 135324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when ?b then "\b" 136324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when ?e then "\e" 137324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when ?f then "\f" 138324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when ?n then "\n" 139324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when ?r then "\r" 140324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when ?s then "\s" 141324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when ?t then "\t" 142324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when ?v then "\v" 143324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 144324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver elsif $2 then $2.to_i( 8 ).chr 145324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver elsif $3 then $3.to_i( 16 ).chr 146324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver elsif $4 then $4 147324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 148324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 149324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 150324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 151324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver def extract_template( token ) 152324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver case token.type 153324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when TEMPLATE 154324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver token.text.gsub( /\A<<<\r?\n?|\r?\n?>>>\Z/, '' ) 155324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when STRING 156324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver unescape( token.text[ 1...-1 ] ) 157324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 158324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 159324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 160324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver def group( namespace = ::Object ) 161324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver group_spec( namespace ) 162324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 163324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 164324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # - - - - - - - - - - - - Rules - - - - - - - - - - - - - 165324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 166324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 167324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # parser rule group_spec 168324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 169324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # (in GroupFile.g) 170324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 79:1: group_spec[ namespace ] returns [ group ] : ( group_name[ $namespace ] | ) ( member[ $group ] )* ; 171324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 172324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver def group_spec( namespace ) 173324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # -> uncomment the next line to manually enable rule tracing 174324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # trace_in( __method__, 1 ) 175324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver group = nil 176324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver group_name1 = nil 177324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 178324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver begin 179324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 80:5: ( group_name[ $namespace ] | ) ( member[ $group ] )* 180324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 80:5: ( group_name[ $namespace ] | ) 181324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_1 = 2 182324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver look_1_0 = @input.peek( 1 ) 183324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 184324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver if ( look_1_0 == T__10 ) 185324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_1 = 1 186324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver elsif ( look_1_0 == EOF || look_1_0 == ID ) 187324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_1 = 2 188324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver else 189324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver raise NoViableAlternative( "", 1, 0 ) 190324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 191324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver case alt_1 192324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when 1 193324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 80:7: group_name[ $namespace ] 194324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver @state.following.push( TOKENS_FOLLOWING_group_name_IN_group_spec_85 ) 195324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver group_name1 = group_name( namespace ) 196324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver @state.following.pop 197324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # --> action 198324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver group = group_name1 199324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # <-- action 200324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 201324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when 2 202324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 81:7: 203324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # --> action 204324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver group = ANTLR3::Template::Group.new 205324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # <-- action 206324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 207324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 208324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 83:5: ( member[ $group ] )* 209324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver while true # decision 2 210324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_2 = 2 211324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver look_2_0 = @input.peek( 1 ) 212324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 213324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver if ( look_2_0 == ID ) 214324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_2 = 1 215324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 216324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 217324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver case alt_2 218324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when 1 219324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 83:5: member[ $group ] 220324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver @state.following.push( TOKENS_FOLLOWING_member_IN_group_spec_108 ) 221324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver member( group ) 222324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver @state.following.pop 223324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 224324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver else 225324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver break # out of loop for decision 2 226324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 227324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end # loop for decision 2 228324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 229324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver rescue ANTLR3::Error::RecognitionError => re 230324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver report_error( re ) 231324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver recover( re ) 232324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 233324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver ensure 234324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # -> uncomment the next line to manually enable rule tracing 235324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # trace_out( __method__, 1 ) 236324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 237324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 238324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 239324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver return group 240324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 241324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 242324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 243324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 244324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # parser rule group_name 245324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 246324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # (in GroupFile.g) 247324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 86:1: group_name[ namespace ] returns [ group ] : 'group' (mod= CONSTANT '::' )* name= CONSTANT ( ';' )? ; 248324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 249324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver def group_name( namespace ) 250324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # -> uncomment the next line to manually enable rule tracing 251324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # trace_in( __method__, 2 ) 252324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver group = nil 253324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver mod = nil 254324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver name = nil 255324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 256324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver begin 257324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 87:5: 'group' (mod= CONSTANT '::' )* name= CONSTANT ( ';' )? 258324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver match( T__10, TOKENS_FOLLOWING_T__10_IN_group_name_128 ) 259324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 88:5: (mod= CONSTANT '::' )* 260324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver while true # decision 3 261324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_3 = 2 262324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver look_3_0 = @input.peek( 1 ) 263324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 264324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver if ( look_3_0 == CONSTANT ) 265324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver look_3_1 = @input.peek( 2 ) 266324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 267324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver if ( look_3_1 == T__11 ) 268324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_3 = 1 269324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 270324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 271324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 272324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 273324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver case alt_3 274324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when 1 275324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 89:7: mod= CONSTANT '::' 276324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver mod = match( CONSTANT, TOKENS_FOLLOWING_CONSTANT_IN_group_name_144 ) 277324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver match( T__11, TOKENS_FOLLOWING_T__11_IN_group_name_146 ) 278324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # --> action 279324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver namespace = namespace.const_get( mod.text ) 280324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # <-- action 281324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 282324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver else 283324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver break # out of loop for decision 3 284324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 285324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end # loop for decision 3 286324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver name = match( CONSTANT, TOKENS_FOLLOWING_CONSTANT_IN_group_name_169 ) 287324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # --> action 288324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver group = fetch_group( namespace, name.text ) 289324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # <-- action 290324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 93:5: ( ';' )? 291324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_4 = 2 292324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver look_4_0 = @input.peek( 1 ) 293324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 294324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver if ( look_4_0 == T__12 ) 295324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_4 = 1 296324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 297324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver case alt_4 298324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when 1 299324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 93:5: ';' 300324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver match( T__12, TOKENS_FOLLOWING_T__12_IN_group_name_177 ) 301324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 302324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 303324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 304324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver rescue ANTLR3::Error::RecognitionError => re 305324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver report_error( re ) 306324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver recover( re ) 307324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 308324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver ensure 309324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # -> uncomment the next line to manually enable rule tracing 310324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # trace_out( __method__, 2 ) 311324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 312324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 313324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 314324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver return group 315324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 316324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 317324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 318324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 319324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # parser rule member 320324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 321324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # (in GroupFile.g) 322324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 96:1: member[ group ] : name= ID ( parameter_declaration )? '::=' (aliased= ID | TEMPLATE | STRING ) ; 323324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 324324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver def member( group ) 325324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # -> uncomment the next line to manually enable rule tracing 326324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # trace_in( __method__, 3 ) 327324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver name = nil 328324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver aliased = nil 329324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver __TEMPLATE3__ = nil 330324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver __STRING4__ = nil 331324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver parameter_declaration2 = nil 332324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # - - - - @init action - - - - 333324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver params = nil 334324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 335324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver begin 336324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 98:5: name= ID ( parameter_declaration )? '::=' (aliased= ID | TEMPLATE | STRING ) 337324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver name = match( ID, TOKENS_FOLLOWING_ID_IN_member_199 ) 338324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 98:13: ( parameter_declaration )? 339324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_5 = 2 340324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver look_5_0 = @input.peek( 1 ) 341324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 342324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver if ( look_5_0 == ID || look_5_0 == T__14 || look_5_0.between?( T__17, T__18 ) ) 343324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_5 = 1 344324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 345324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver case alt_5 346324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when 1 347324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 98:15: parameter_declaration 348324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver @state.following.push( TOKENS_FOLLOWING_parameter_declaration_IN_member_203 ) 349324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver parameter_declaration2 = parameter_declaration 350324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver @state.following.pop 351324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # --> action 352324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver params = parameter_declaration2 353324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # <-- action 354324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 355324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 356324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver match( T__13, TOKENS_FOLLOWING_T__13_IN_member_210 ) 357324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 99:5: (aliased= ID | TEMPLATE | STRING ) 358324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_6 = 3 359324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver case look_6 = @input.peek( 1 ) 360324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when ID then alt_6 = 1 361324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when TEMPLATE then alt_6 = 2 362324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when STRING then alt_6 = 3 363324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver else 364324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver raise NoViableAlternative( "", 6, 0 ) 365324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 366324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver case alt_6 367324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when 1 368324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 99:7: aliased= ID 369324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver aliased = match( ID, TOKENS_FOLLOWING_ID_IN_member_220 ) 370324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # --> action 371324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver group.alias_template( name.text, aliased.text ) 372324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # <-- action 373324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 374324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when 2 375324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 100:7: TEMPLATE 376324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver __TEMPLATE3__ = match( TEMPLATE, TOKENS_FOLLOWING_TEMPLATE_IN_member_230 ) 377324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # --> action 378324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver group.define_template( name.text, extract_template( __TEMPLATE3__ ), params ) 379324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # <-- action 380324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 381324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when 3 382324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 101:7: STRING 383324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver __STRING4__ = match( STRING, TOKENS_FOLLOWING_STRING_IN_member_242 ) 384324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # --> action 385324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver group.define_template( name.text, extract_template( __STRING4__ ), params ) 386324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # <-- action 387324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 388324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 389324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 390324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver rescue ANTLR3::Error::RecognitionError => re 391324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver report_error( re ) 392324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver recover( re ) 393324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 394324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver ensure 395324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # -> uncomment the next line to manually enable rule tracing 396324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # trace_out( __method__, 3 ) 397324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 398324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 399324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 400324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver return 401324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 402324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 403324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 404324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 405324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # parser rule parameter_declaration 406324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 407324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # (in GroupFile.g) 408324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 105:1: parameter_declaration returns [ list ] : ( '(' ( parameters )? ')' | parameters ); 409324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 410324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver def parameter_declaration 411324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # -> uncomment the next line to manually enable rule tracing 412324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # trace_in( __method__, 4 ) 413324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver list = nil 414324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver parameters5 = nil 415324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver parameters6 = nil 416324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # - - - - @init action - - - - 417324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver list = nil 418324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 419324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver begin 420324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 107:3: ( '(' ( parameters )? ')' | parameters ) 421324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_8 = 2 422324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver look_8_0 = @input.peek( 1 ) 423324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 424324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver if ( look_8_0 == T__14 ) 425324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_8 = 1 426324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver elsif ( look_8_0 == ID || look_8_0.between?( T__17, T__18 ) ) 427324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_8 = 2 428324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver else 429324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver raise NoViableAlternative( "", 8, 0 ) 430324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 431324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver case alt_8 432324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when 1 433324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 107:5: '(' ( parameters )? ')' 434324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver match( T__14, TOKENS_FOLLOWING_T__14_IN_parameter_declaration_276 ) 435324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 107:9: ( parameters )? 436324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_7 = 2 437324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver look_7_0 = @input.peek( 1 ) 438324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 439324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver if ( look_7_0 == ID || look_7_0.between?( T__17, T__18 ) ) 440324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_7 = 1 441324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 442324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver case alt_7 443324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when 1 444324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 107:11: parameters 445324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver @state.following.push( TOKENS_FOLLOWING_parameters_IN_parameter_declaration_280 ) 446324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver parameters5 = parameters 447324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver @state.following.pop 448324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # --> action 449324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver list = parameters5 450324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # <-- action 451324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 452324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 453324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver match( T__15, TOKENS_FOLLOWING_T__15_IN_parameter_declaration_287 ) 454324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 455324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when 2 456324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 108:5: parameters 457324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver @state.following.push( TOKENS_FOLLOWING_parameters_IN_parameter_declaration_293 ) 458324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver parameters6 = parameters 459324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver @state.following.pop 460324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # --> action 461324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver list = parameters6 462324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # <-- action 463324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 464324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 465324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver rescue ANTLR3::Error::RecognitionError => re 466324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver report_error( re ) 467324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver recover( re ) 468324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 469324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver ensure 470324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # -> uncomment the next line to manually enable rule tracing 471324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # trace_out( __method__, 4 ) 472324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 473324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 474324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 475324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver return list 476324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 477324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 478324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 479324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 480324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # parser rule parameters 481324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 482324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # (in GroupFile.g) 483324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 111:1: parameters returns [ list ] : parameter[ $list ] ( ',' parameter[ $list ] )* ; 484324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 485324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver def parameters 486324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # -> uncomment the next line to manually enable rule tracing 487324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # trace_in( __method__, 5 ) 488324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver list = nil 489324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # - - - - @init action - - - - 490324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver list = ANTLR3::Template::ParameterList.new 491324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 492324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver begin 493324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 113:5: parameter[ $list ] ( ',' parameter[ $list ] )* 494324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver @state.following.push( TOKENS_FOLLOWING_parameter_IN_parameters_317 ) 495324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver parameter( list ) 496324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver @state.following.pop 497324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 113:24: ( ',' parameter[ $list ] )* 498324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver while true # decision 9 499324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_9 = 2 500324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver look_9_0 = @input.peek( 1 ) 501324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 502324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver if ( look_9_0 == T__16 ) 503324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_9 = 1 504324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 505324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 506324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver case alt_9 507324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when 1 508324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 113:26: ',' parameter[ $list ] 509324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver match( T__16, TOKENS_FOLLOWING_T__16_IN_parameters_322 ) 510324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver @state.following.push( TOKENS_FOLLOWING_parameter_IN_parameters_324 ) 511324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver parameter( list ) 512324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver @state.following.pop 513324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 514324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver else 515324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver break # out of loop for decision 9 516324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 517324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end # loop for decision 9 518324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 519324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver rescue ANTLR3::Error::RecognitionError => re 520324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver report_error( re ) 521324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver recover( re ) 522324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 523324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver ensure 524324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # -> uncomment the next line to manually enable rule tracing 525324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # trace_out( __method__, 5 ) 526324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 527324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 528324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 529324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver return list 530324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 531324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 532324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 533324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 534324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # parser rule parameter 535324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 536324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # (in GroupFile.g) 537324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 116:1: parameter[ parameters ] : ( '*' name= ID | '&' name= ID | name= ID ( '=' v= STRING )? ); 538324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # 539324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver def parameter( parameters ) 540324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # -> uncomment the next line to manually enable rule tracing 541324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # trace_in( __method__, 6 ) 542324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver name = nil 543324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver v = nil 544324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 545324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver begin 546324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 117:3: ( '*' name= ID | '&' name= ID | name= ID ( '=' v= STRING )? ) 547324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_11 = 3 548324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver case look_11 = @input.peek( 1 ) 549324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when T__17 then alt_11 = 1 550324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when T__18 then alt_11 = 2 551324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when ID then alt_11 = 3 552324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver else 553324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver raise NoViableAlternative( "", 11, 0 ) 554324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 555324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver case alt_11 556324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when 1 557324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 117:5: '*' name= ID 558324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver match( T__17, TOKENS_FOLLOWING_T__17_IN_parameter_342 ) 559324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver name = match( ID, TOKENS_FOLLOWING_ID_IN_parameter_346 ) 560324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # --> action 561324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver parameters.splat = name.text 562324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # <-- action 563324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 564324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when 2 565324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 118:5: '&' name= ID 566324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver match( T__18, TOKENS_FOLLOWING_T__18_IN_parameter_354 ) 567324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver name = match( ID, TOKENS_FOLLOWING_ID_IN_parameter_358 ) 568324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # --> action 569324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver parameters.block = name.text 570324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # <-- action 571324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 572324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when 3 573324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 119:5: name= ID ( '=' v= STRING )? 574324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver name = match( ID, TOKENS_FOLLOWING_ID_IN_parameter_368 ) 575324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # --> action 576324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver param = ANTLR3::Template::Parameter.new( name.text ) 577324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # <-- action 578324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 120:5: ( '=' v= STRING )? 579324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_10 = 2 580324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver look_10_0 = @input.peek( 1 ) 581324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 582324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver if ( look_10_0 == T__19 ) 583324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver alt_10 = 1 584324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 585324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver case alt_10 586324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver when 1 587324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # at line 120:7: '=' v= STRING 588324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver match( T__19, TOKENS_FOLLOWING_T__19_IN_parameter_382 ) 589324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver v = match( STRING, TOKENS_FOLLOWING_STRING_IN_parameter_386 ) 590324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # --> action 591324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver param.default = v.text 592324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # <-- action 593324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 594324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 595324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # --> action 596324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver parameters.add( param ) 597324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # <-- action 598324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 599324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 600324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver rescue ANTLR3::Error::RecognitionError => re 601324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver report_error( re ) 602324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver recover( re ) 603324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 604324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver ensure 605324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # -> uncomment the next line to manually enable rule tracing 606324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # trace_out( __method__, 6 ) 607324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 608324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 609324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 610324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver return 611324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end 612324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 613324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 614324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 615324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_group_name_IN_group_spec_85 = Set[ 1, 5 ] 616324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_member_IN_group_spec_108 = Set[ 1, 5 ] 617324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_T__10_IN_group_name_128 = Set[ 4 ] 618324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_CONSTANT_IN_group_name_144 = Set[ 11 ] 619324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_T__11_IN_group_name_146 = Set[ 4 ] 620324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_CONSTANT_IN_group_name_169 = Set[ 1, 12 ] 621324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_T__12_IN_group_name_177 = Set[ 1 ] 622324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_ID_IN_member_199 = Set[ 5, 13, 14, 17, 18 ] 623324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_parameter_declaration_IN_member_203 = Set[ 13 ] 624324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_T__13_IN_member_210 = Set[ 5, 6, 7 ] 625324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_ID_IN_member_220 = Set[ 1 ] 626324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_TEMPLATE_IN_member_230 = Set[ 1 ] 627324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_STRING_IN_member_242 = Set[ 1 ] 628324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_T__14_IN_parameter_declaration_276 = Set[ 5, 14, 15, 17, 18 ] 629324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_parameters_IN_parameter_declaration_280 = Set[ 15 ] 630324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_T__15_IN_parameter_declaration_287 = Set[ 1 ] 631324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_parameters_IN_parameter_declaration_293 = Set[ 1 ] 632324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_parameter_IN_parameters_317 = Set[ 1, 16 ] 633324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_T__16_IN_parameters_322 = Set[ 5, 14, 17, 18 ] 634324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_parameter_IN_parameters_324 = Set[ 1, 16 ] 635324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_T__17_IN_parameter_342 = Set[ 5 ] 636324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_ID_IN_parameter_346 = Set[ 1 ] 637324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_T__18_IN_parameter_354 = Set[ 5 ] 638324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_ID_IN_parameter_358 = Set[ 1 ] 639324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_ID_IN_parameter_368 = Set[ 1, 19 ] 640324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_T__19_IN_parameter_382 = Set[ 7 ] 641324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver TOKENS_FOLLOWING_STRING_IN_parameter_386 = Set[ 1 ] 642324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 643324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver end # class Parser < ANTLR3::Parser 644324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 645324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruverend 646324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver# - - - - - - begin action @parser::footer - - - - - - 647324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver# GroupFile.g 648324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 649324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 650324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruverend # module Template 651324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruverend # module ANTLR3 652324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 653324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver# - - - - - - end action @parser::footer - - - - - - - 654324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 655324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 656324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruverif __FILE__ == $0 and ARGV.first != '--' 657324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # - - - - - - begin action @parser::main - - - - - - 658324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # GroupFile.g 659324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 660324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 661324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver defined?( ANTLR3::Template::GroupFile::Lexer ) or require 'antlr3/template/group-file' 662324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver ANTLR3::Template::GroupFile::Parser.main( ARGV ) 663324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 664324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver # - - - - - - end action @parser::main - - - - - - - 665324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 666324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruverend 667