Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/******************************************************************************
********************* M A J O R C O M P O N E N T S **********************
******************************************************************************/
// System.Boolean.ToString() returns "True" and "False", but the proper C# literals are "true" and "false"
// The Java version of Boolean returns "true" and "false", so they map to themselves here.
booleanLiteral ::= [
"True":"true",
"False":"false",
"true":"true",
"false":"false",
default:"false"
]
/** The overall file structure of a recognizer; stores methods
* for rules and cyclic DFAs plus support code.
*/
outputFile(LEXER, PARSER, TREE_PARSER, actionScope, actions, docComment, recognizer, name,
tokens, tokenNames, rules, cyclicDFAs, bitsets, buildTemplate, buildAST, rewriteMode,
profile, backtracking, synpreds, memoize, numRules, fileName, ANTLRVersion, generatedTimestamp,
trace, scopes, superClass, literals) ::=
<<
#!/usr/bin/env ruby
#
#
# --
# Generated using ANTLR version:
# Ruby runtime library version:
# Input grammar file:
# Generated at:
#
# ~~~\> start load path setup
this_directory = File.expand_path( File.dirname( __FILE__ ) )
$LOAD_PATH.unshift( this_directory ) unless $LOAD_PATH.include?( this_directory )
antlr_load_failed = proc do
load_path = $LOAD_PATH.map { |dir| ' - ' \<\< dir }.join( $/ )
raise LoadError, \<\<-END.strip!
Failed to load the ANTLR3 runtime library (version ):
Ensure the library has been installed on your system and is available
on the load path. If rubygems is available on your system, this can
be done with the command:
gem install antlr3
Current load path:
#{ load_path }
END
end
defined?( ANTLR3 ) or begin
# 1: try to load the ruby antlr3 runtime library from the system path
require 'antlr3'
rescue LoadError
# 2: try to load rubygems if it isn't already loaded
defined?( Gem ) or begin
require 'rubygems'
rescue LoadError
antlr_load_failed.call
end
# 3: try to activate the antlr3 gem
begin
Gem.activate( 'antlr3', '~> ' )
rescue Gem::LoadError
antlr_load_failed.call
end
require 'antlr3'
end
# \<~~~ end load path setup
if __FILE__ == $0 and ARGV.first != '--'
end
>>
tokenDataModule() ::= <<
# TokenData defines all of the token type integer values
# as constants, which will be included in all
# ANTLR-generated recognizers.
const_defined?( :TokenData ) or TokenData = ANTLR3::TokenScheme.new
module TokenData
# define the token constants
define_tokens( => }; anchor, wrap="\n", separator=", "> )
# register the proper human-readable name or literal value
# for each token type
#
# this is necessary because anonymous tokens, which are
# created from literal values in the grammar, do not
# have descriptive names
register_names( }; separator=", ", anchor, wrap="\n"> )
end<\n>
>>
rootGrammarOutputFile() ::= <<
module
end
>>
delegateGrammarOutputFile() ::= <<
require ''
>>
delegateGrammarModuleHead(gram) ::= <<
module <\n>
class
>>
delegateGrammarModuleTail(gram) ::= <<
end # module
end # class <\n>
>>
/* * * * * * * * * * R E C O G N I Z E R C L A S S E S * * * * * * * * * */
parser(
grammar, name, scopes, tokens, tokenNames, rules, numRules, bitsets,
ASTLabelType="Object", superClass="ANTLR3::Parser", labelType="ANTLR3::Token",
members={}
) ::= <<
class Parser \<
end # class Parser \<
at_exit { Parser.main( ARGV ) } if __FILE__ == $0
>>
/** How to generate a tree parser; same as parser except the
* input stream is a different type.
*/
treeParser(grammar, name, scopes, tokens, tokenNames, globalAction, rules, numRules, bitsets, filterMode, labelType={}, ASTLabelType="Object", superClass="ANTLR3::TreeParser", members={}) ::= <<
class TreeParser \<
end # class TreeParser \<
at_exit { TreeParser.main( ARGV ) } if __FILE__ == $0
>>
parserBody(grammar, name, scopes, tokens, tokenNames, rules, numRules, bitsets, inputStreamType, superClass, filterMode, labelType, members, rewriteElementType, actionScope, ASTLabelType="Object") ::= <<
@grammar_home = <\n>
<@mixins()>
RULE_METHODS = [ }; separator=", ", wrap="\n", anchor> ].freeze
<\n>}>
}>
masters( }; separator=", "> )<\n>
imports( }; separator=", "> )<\n>
include TokenData
begin
generated_using( "", "", "" )
rescue NoMethodError => error
# ignore
end
require ''
include ::TokenData<\n><\n>
<@additionalMembers()>
# - - - - - - - - - - - - Rules - - - - - - - - - - - - -
<\n>}>
# - - - - - - - - - - Delegated Rules - - - - - - - - - - -
<\n>}>
# - - - - - - - - - - DFA definitions - - - - - - - - - - -
}>
private
def initialize_dfas
super rescue nil
}>
end
_IN__ = Set[ }; separator=", "> ]<\n>}>
>>
parserConstructor() ::= <<
def initialize( , }>input, options = {} )
super( input, options )
@state.rule_memory = {}
<\n>}>}>
= <\n>}> = <\n>}><\n>}><@init()>
end
>>
/* * * * * * * * * * * * * R U L E M E T H O D S * * * * * * * * * * * * */
/** A simpler version of a rule template that is specific to the
* imaginary rules created for syntactic predicates. As they
* never have return values nor parameters etc..., just give
* simplest possible method. Don't do any of the normal
* memoization stuff in here either; it's a waste. As
* predicates cannot be inlined into the invoking rule, they
* need to be in a rule by themselves.
*/
synpredRule(ruleName, ruleDescriptor, block, description, nakedBlock) ::= <<
#
# syntactic predicate
#
# (in )
#
#
# This is an imaginary rule inserted by ANTLR to
# implement a syntactic predicate decision
#
def ( )
ensure
end
>>
/** How to generate code for a rule. This includes any return
* type data aggregates required for multiple return values.
*/
rule(ruleName, ruleDescriptor, block, emptyRule, description, exceptions, finally, memoize) ::= <<
#
# parser rule
#
# (in )
#
#
def ( )
<@body><@end>
return
end
: rescue nil<\n>
>>
delegateRule(ruleDescriptor) ::= <<
# delegated rule
def ( )}>})>
end
>>
// HELPERS
recognizerClassName() ::= <<
TreeParserParserLexer
>>
initializeDirectDelegate() ::= <<
@ = ::.new(
, }>self, input, options.merge( :state => @state )
)
>>
initializeDelegator() ::= <<
@ =
>>
altSwitchCase(altNum,alt) ::= <<
when
<@prealt()>
>>
blockBody() ::= <<
<@decision><@end>
case alt_}; separator="\n">
end
>>
catch(decl, action) ::= <<
# - - - - - - @catch - - - - - -
rescue <\n>
>>
closureBlockLoop() ::= <<
while true # decision
alt_ =
<@decisionBody><@end>
case alt_}; separator="\n">
else
break # out of loop for decision
end
end # loop for decision
>>
delegateName(d) ::= <<
>>
element(e) ::= <<
<\n>
>>
execForcedAction(action) ::= ""
globalAttributeScopeClass(scope) ::= <<
@@ = Scope( }; separator=", "> )<\n>
>>
globalAttributeScopeStack(scope) ::= <<
@_stack = []<\n>
>>
noRewrite(rewriteBlockLevel, treeLevel) ::= ""
parameterScope(scope) ::= <<
}; separator=", ">
>>
positiveClosureBlockLoop() ::= <<
match_count_ = 0
while true
alt_ =
<@decisionBody><@end>
case alt_}; separator="\n">
else
match_count_ > 0 and break
eee = EarlyExit()
<@earlyExitException()><\n>
raise eee
end
match_count_ += 1
end<\n>
>>
returnScope(scope) ::= <<
= define_return_scope }; separator=", ">
>>
returnStructName(r) ::= "ReturnValue"
ruleAttributeScopeClass ::= globalAttributeScopeClass
ruleAttributeScopeStack ::= globalAttributeScopeStack
ruleBacktrackFailure() ::= <<
@state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )<\n>
>>
ruleBody() ::= <<
success = false # flag used for memoization<\n>
begin
<(ruleDescriptor.actions.after):execAction()>
success = true<\n>
<\n>}>