Public Member Functions | |
PythonCodeGenerator () | |
void | exitIfError () |
void | gen () |
void | gen (ActionElement action) |
void | gen (AlternativeBlock blk) |
void | gen (BlockEndElement end) |
void | gen (CharLiteralElement atom) |
void | gen (CharRangeElement r) |
void | gen (LexerGrammar g) throws IOException |
void | gen (OneOrMoreBlock blk) |
void | gen (ParserGrammar g) throws IOException |
void | gen (RuleRefElement rr) |
void | gen (StringLiteralElement atom) |
void | gen (TokenRangeElement r) |
void | gen (TokenRefElement atom) |
void | gen (TreeElement t) |
void | gen (TreeWalkerGrammar g) throws IOException |
void | gen (WildcardElement wc) |
void | gen (ZeroOrMoreBlock blk) |
PythonBlockFinishingInfo | genCommonBlock (AlternativeBlock blk, boolean noTestForSingle) |
void | genNextToken () |
void | genRule (RuleSymbol s, boolean startSymbol, int ruleNum) |
void | genTokenStrings () |
String | getASTCreateString (Vector v) |
String | getASTCreateString (GrammarAtom atom, String astCtorArgs) |
String | getASTCreateString (String astCtorArgs) |
String | getRangeExpression (int k, int[] elems) |
String | mapTreeId (String idParam, ActionTransInfo transInfo) |
void | setupOutput (String className) throws IOException |
Static Public Attributes | |
static final String | initHeaderAction = "__init__" |
static final String | mainHeaderAction = "__main__" |
static final int | caseSizeThreshold = 127 |
Protected Member Functions | |
void | printTabs () |
int | addSemPred (String predicate) |
void | checkCurrentOutputStream () |
String | extractIdOfAction (String s, int line, int column) |
String | extractTypeOfAction (String s, int line, int column) |
void | flushTokens () |
void | genHeaderMain (Grammar grammar) |
void | genHeaderInit (Grammar grammar) |
void | printMainFunc (String s) |
void | genAlt (Alternative alt, AlternativeBlock blk) |
void | genBitsets (Vector bitsetList, int maxVocabulary) |
void | genBlockInitAction (AlternativeBlock blk) |
void | genBlockPreamble (AlternativeBlock blk) |
void | genCases (BitSet p) |
void | genASTDeclaration (AlternativeElement el) |
void | genASTDeclaration (AlternativeElement el, String node_type) |
void | genASTDeclaration (AlternativeElement el, String var_name, String node_type) |
void | genHeader () |
void | genLexerTest () |
void | genMatch (BitSet b) |
void | genMatch (GrammarAtom atom) |
void | genMatchUsingAtomText (GrammarAtom atom) |
void | genMatchUsingAtomTokenType (GrammarAtom atom) |
void | genSemPred (String pred, int line) |
void | genSemPredMap () |
void | genSynPred (SynPredBlock blk, String lookaheadExpr) |
void | genTokenASTNodeMap () |
void | genTokenTypes (TokenManager tm) throws IOException |
String | getLookaheadTestExpression (Lookahead[] look, int k) |
String | getLookaheadTestExpression (Alternative alt, int maxDepth) |
String | getLookaheadTestTerm (int k, BitSet p) |
boolean | lookaheadIsEmpty (Alternative alt, int maxDepth) |
String | processActionForSpecialSymbols (String actionStr, int line, RuleBlock currentRule, ActionTransInfo tInfo) |
String | processActionCode (String actionStr, int line) |
void | printActionCode (String actionStr, int line) |
boolean | isspace (char c) |
void | _printAction (String s) |
void | od (String s, int i, int end, String msg) |
void | printAction (String s) |
void | printGrammarAction (Grammar grammar) |
void | _printJavadoc (String s) |
void | genJavadocComment (Grammar g) |
void | genJavadocComment (RuleSymbol g) |
Protected Attributes | |
int | syntacticPredLevel = 0 |
boolean | genAST = false |
boolean | saveText = false |
Static Protected Attributes | |
static final String | NONUNIQUE = new String() |
Package Functions | |
String | toString (boolean v) |
Static Package Functions | |
static boolean | isEmpty (String s) |
Package Attributes | |
String | labeledElementType |
String | labeledElementASTType |
String | labeledElementInit |
String | commonExtraArgs |
String | commonExtraParams |
String | commonLocalVars |
String | lt1Value |
String | exceptionThrown |
String | throwNoViable |
String | lexerClassName |
String | parserClassName |
String | treeWalkerClassName |
RuleBlock | currentRule |
String | currentASTResult |
Hashtable | treeVariableMap = new Hashtable() |
Hashtable | declaredASTVariables = new Hashtable() |
int | astVarNumber = 1 |
Generate MyParser.java, MyLexer.java and MyParserTokenTypes.java
antlr.PythonCodeGenerator.PythonCodeGenerator | ( | ) |
void antlr.PythonCodeGenerator._printAction | ( | String | s | ) | [protected] |
Print an action without leading tabs, attempting to preserve the current indentation level for multi-line actions Ignored if string is null.
s | The action string to output |
Reimplemented from antlr.CodeGenerator.
References antlr.CodeGenerator.currentOutput, antlr.PythonCodeGenerator.isspace(), and antlr.PythonCodeGenerator.printTabs().
Referenced by antlr.PythonCodeGenerator.printAction().
void antlr.PythonCodeGenerator._printJavadoc | ( | String | s | ) | [protected] |
References antlr.CodeGenerator.currentOutput, and antlr.PythonCodeGenerator.printTabs().
Referenced by antlr.PythonCodeGenerator.genJavadocComment().
int antlr.PythonCodeGenerator.addSemPred | ( | String | predicate | ) | [protected] |
Adds a semantic predicate string to the sem pred vector These strings will be used to build an array of sem pred names when building a debugging parser. This method should only be called when the debug option is specified
References antlr.collections.impl.Vector.appendElement(), and antlr.collections.impl.Vector.size().
Referenced by antlr.PythonCodeGenerator.genCommonBlock(), and antlr.PythonCodeGenerator.genSemPred().
void antlr.PythonCodeGenerator.checkCurrentOutputStream | ( | ) | [protected] |
References antlr.CodeGenerator.currentOutput.
Referenced by antlr.PythonCodeGenerator.flushTokens().
void antlr.PythonCodeGenerator.exitIfError | ( | ) |
String antlr.PythonCodeGenerator.extractIdOfAction | ( | String | s, | |
int | line, | |||
int | column | |||
) | [protected] |
Get the identifier portion of an argument-action. For Python the ID of an action is assumed to be everything before the assignment, as Python does not support a type.
s | The action text | |
line | Line used for error reporting. | |
column | Line used for error reporting. |
Reimplemented from antlr.CodeGenerator.
References antlr.CodeGenerator.removeAssignmentFromDeclaration().
Referenced by antlr.PythonCodeGenerator.genRule().
String antlr.PythonCodeGenerator.extractTypeOfAction | ( | String | s, | |
int | line, | |||
int | column | |||
) | [protected] |
Get the type portion of an argument-action. Python does not have a type declaration before an identifier, so we just return the empty string.
s | The action text | |
line | Line used for error reporting. |
Reimplemented from antlr.CodeGenerator.
void antlr.PythonCodeGenerator.flushTokens | ( | ) | [protected] |
References antlr.CodeGenerator.behavior, antlr.PythonCodeGenerator.checkCurrentOutputStream(), antlr.CodeGenerator.currentOutput, antlr.PythonCodeGenerator.exitIfError(), antlr.CodeGenerator.genTokenInterchange(), antlr.PythonCodeGenerator.genTokenTypes(), antlr.TokenManager.isReadOnly(), antlr.CodeGenerator.println(), and antlr.DefineGrammarSymbols.tokenManagers.
Referenced by antlr.PythonCodeGenerator.gen().
void antlr.PythonCodeGenerator.gen | ( | ) | [virtual] |
Generate the parser, lexer, treeparser, and token types in Java
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.analyzer, antlr.CodeGenerator.antlrTool, antlr.CodeGenerator.behavior, antlr.PythonCodeGenerator.exitIfError(), antlr.Grammar.generate(), antlr.DefineGrammarSymbols.grammars, antlr.Tool.reportException(), antlr.Grammar.setCodeGenerator(), antlr.LLkGrammarAnalyzer.setGrammar(), and antlr.Grammar.setGrammarAnalyzer().
Referenced by antlr.PythonCodeGenerator.genMatch(), and antlr.PythonCodeGenerator.genSynPred().
void antlr.PythonCodeGenerator.gen | ( | ActionElement | action | ) | [virtual] |
Generate code for the given grammar element.
blk | The {...} action to generate |
Implements antlr.CodeGenerator.
References antlr.ActionElement.actionText, antlr.ActionTransInfo.assignToRoot, antlr.PythonCodeGenerator.currentRule, antlr.PythonCodeGenerator.genSemPred(), antlr.GrammarElement.getLine(), antlr.CodeGenerator.grammar, antlr.Grammar.hasSyntacticPredicate, antlr.ActionElement.isSemPred, antlr.GrammarElement.line, antlr.PythonCodeGenerator.printAction(), antlr.CodeGenerator.println(), antlr.PythonCodeGenerator.processActionForSpecialSymbols(), antlr.ActionTransInfo.refRuleRoot, and antlr.CodeGenerator.tabs.
void antlr.PythonCodeGenerator.gen | ( | OneOrMoreBlock | blk | ) | [virtual] |
Generate code for the given grammar element.
blk | The (...)+ block to generate |
Implements antlr.CodeGenerator.
References antlr.Lookahead.containsEpsilon(), antlr.PythonCodeGenerator.currentASTResult, antlr.LLkGrammarAnalyzer.deterministic(), antlr.BlockWithImpliedExitPath.exitCache, antlr.BlockWithImpliedExitPath.exitLookaheadDepth, antlr.PythonCodeGenerator.genBlockInitAction(), antlr.PythonCodeGenerator.genBlockPreamble(), antlr.PythonCodeGenerator.genCommonBlock(), antlr.AlternativeBlock.getLabel(), antlr.PythonCodeGenerator.getLookaheadTestExpression(), antlr.CodeGenerator.grammar, antlr.AlternativeBlock.greedy, antlr.AlternativeBlock.ID, antlr.Grammar.maxk, antlr.CodeGenerator.println(), antlr.CodeGenerator.tabs, antlr.Grammar.theLLkAnalyzer, and antlr.PythonCodeGenerator.throwNoViable.
void antlr.PythonCodeGenerator.gen | ( | AlternativeBlock | blk | ) | [virtual] |
Generate code for the given grammar element.
blk | The "x|y|z|..." block to generate |
Implements antlr.CodeGenerator.
References antlr.PythonCodeGenerator.currentASTResult, antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.LLkGrammarAnalyzer.deterministic(), antlr.PythonCodeGenerator.genBlockInitAction(), antlr.PythonCodeGenerator.genBlockPreamble(), antlr.PythonCodeGenerator.genCommonBlock(), antlr.AlternativeBlock.getLabel(), antlr.CodeGenerator.grammar, antlr.CodeGenerator.tabs, antlr.Grammar.theLLkAnalyzer, and antlr.PythonCodeGenerator.throwNoViable.
void antlr.PythonCodeGenerator.gen | ( | ParserGrammar | g | ) | throws IOException [virtual] |
Generate the parser Java file
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.antlrTool, antlr.CodeGenerator.behavior, antlr.CodeGenerator.bitsetsUsed, antlr.Grammar.buildAST, antlr.CodeGenerator.currentOutput, antlr.Grammar.debuggingOutput, antlr.collections.impl.Vector.elements(), antlr.PythonCodeGenerator.exitIfError(), antlr.PythonCodeGenerator.flushTokens(), antlr.PythonCodeGenerator.genAST, antlr.PythonCodeGenerator.genBitsets(), antlr.PythonCodeGenerator.genHeader(), antlr.PythonCodeGenerator.genHeaderInit(), antlr.PythonCodeGenerator.genHeaderMain(), antlr.PythonCodeGenerator.genJavadocComment(), antlr.PythonCodeGenerator.genRule(), antlr.PythonCodeGenerator.genSemPredMap(), antlr.PythonCodeGenerator.genTokenASTNodeMap(), antlr.PythonCodeGenerator.genTokenStrings(), antlr.Grammar.getClassName(), antlr.DefineGrammarSymbols.getHeaderAction(), antlr.Grammar.getSuperClass(), antlr.Token.getText(), antlr.CodeGenerator.grammar, antlr.PythonCodeGenerator.labeledElementASTType, antlr.TokenManager.maxTokenType(), antlr.Grammar.options, antlr.Tool.panic(), antlr.PythonCodeGenerator.parserClassName, antlr.Grammar.preambleAction, antlr.CodeGenerator.print(), antlr.PythonCodeGenerator.printActionCode(), antlr.PythonCodeGenerator.printGrammarAction(), antlr.CodeGenerator.println(), antlr.RuleSymbol.references, antlr.Grammar.rules, antlr.CodeGenerator.setGrammar(), antlr.PythonCodeGenerator.setupOutput(), antlr.collections.impl.Vector.size(), antlr.Grammar.superClass, antlr.CodeGenerator.tabs, and antlr.Grammar.tokenManager.
void antlr.PythonCodeGenerator.gen | ( | RuleRefElement | rr | ) | [virtual] |
Generate code for the given grammar element.
blk | The rule-reference to generate |
Implements antlr.CodeGenerator.
References antlr.CodeGenerator._print(), antlr.CodeGenerator.antlrTool, antlr.RuleSymbol.block, antlr.Grammar.buildAST, antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.Tool.error(), antlr.PythonCodeGenerator.genAST, antlr.AlternativeElement.getAutoGenType(), antlr.GrammarElement.getColumn(), antlr.Grammar.getFilename(), antlr.RuleRefElement.getLabel(), antlr.GrammarElement.getLine(), antlr.Grammar.getSymbol(), antlr.CodeGenerator.grammar, antlr.Grammar.hasSyntacticPredicate, antlr.RuleRefElement.idAssign, antlr.RuleSymbol.isDefined(), antlr.PythonCodeGenerator.lt1Value, antlr.CodeGenerator.println(), antlr.PythonCodeGenerator.printTabs(), antlr.RuleBlock.returnAction, antlr.PythonCodeGenerator.saveText, antlr.PythonCodeGenerator.syntacticPredLevel, antlr.RuleRefElement.targetRule, and antlr.Tool.warning().
void antlr.PythonCodeGenerator.gen | ( | BlockEndElement | end | ) | [virtual] |
Generate code for the given grammar element.
blk | The block-end element to generate. Block-end elements are synthesized by the grammar parser to represent the end of a block. |
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.DEBUG_CODE_GENERATOR.
void antlr.PythonCodeGenerator.gen | ( | StringLiteralElement | atom | ) | [virtual] |
Generate code for the given grammar element.
blk | The string-literal reference to generate |
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.PythonCodeGenerator.genMatch(), antlr.AlternativeElement.getAutoGenType(), antlr.GrammarAtom.getLabel(), antlr.CodeGenerator.grammar, antlr.PythonCodeGenerator.lt1Value, antlr.CodeGenerator.println(), antlr.PythonCodeGenerator.saveText, and antlr.PythonCodeGenerator.syntacticPredLevel.
void antlr.PythonCodeGenerator.gen | ( | TokenRangeElement | r | ) | [virtual] |
Generate code for the given grammar element.
blk | The token-range reference to generate |
Implements antlr.CodeGenerator.
References antlr.TokenRangeElement.beginText, antlr.TokenRangeElement.endText, antlr.TokenRangeElement.getLabel(), antlr.PythonCodeGenerator.lt1Value, antlr.CodeGenerator.println(), and antlr.PythonCodeGenerator.syntacticPredLevel.
void antlr.PythonCodeGenerator.gen | ( | CharLiteralElement | atom | ) | [virtual] |
Generate code for the given grammar element.
blk | The character literal reference to generate |
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.PythonCodeGenerator.genMatch(), antlr.AlternativeElement.getAutoGenType(), antlr.GrammarAtom.getLabel(), antlr.PythonCodeGenerator.lt1Value, antlr.CodeGenerator.println(), and antlr.PythonCodeGenerator.saveText.
void antlr.PythonCodeGenerator.gen | ( | TokenRefElement | atom | ) | [virtual] |
Generate code for the given grammar element.
blk | The token-reference to generate |
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.antlrTool, antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.PythonCodeGenerator.genMatch(), antlr.GrammarAtom.getLabel(), antlr.CodeGenerator.grammar, antlr.PythonCodeGenerator.lt1Value, antlr.Tool.panic(), antlr.CodeGenerator.println(), and antlr.PythonCodeGenerator.syntacticPredLevel.
void antlr.PythonCodeGenerator.gen | ( | TreeElement | t | ) | [virtual] |
Generate code for the given grammar element.
blk | The tree to generate code for. |
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.antlrTool, antlr.Grammar.buildAST, antlr.Tool.error(), antlr.GrammarElement.generate(), antlr.PythonCodeGenerator.genMatch(), antlr.AlternativeBlock.getAlternativeAt(), antlr.AlternativeBlock.getAlternatives(), antlr.AlternativeElement.getAutoGenType(), antlr.GrammarElement.getColumn(), antlr.Grammar.getFilename(), antlr.GrammarAtom.getLabel(), antlr.GrammarElement.getLine(), antlr.CodeGenerator.grammar, antlr.Alternative.head, antlr.AlternativeBlock.ID, antlr.AlternativeElement.next, antlr.CodeGenerator.println(), antlr.TreeElement.root, antlr.AlternativeElement.setAutoGenType(), antlr.collections.impl.Vector.size(), and antlr.Tool.warning().
void antlr.PythonCodeGenerator.gen | ( | TreeWalkerGrammar | g | ) | throws IOException [virtual] |
Generate the tree-parser Java file
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.antlrTool, antlr.CodeGenerator.behavior, antlr.CodeGenerator.bitsetsUsed, antlr.Grammar.buildAST, antlr.CodeGenerator.currentOutput, antlr.collections.impl.Vector.elements(), antlr.PythonCodeGenerator.exitIfError(), antlr.PythonCodeGenerator.flushTokens(), antlr.PythonCodeGenerator.genAST, antlr.PythonCodeGenerator.genBitsets(), antlr.PythonCodeGenerator.genHeader(), antlr.PythonCodeGenerator.genHeaderInit(), antlr.PythonCodeGenerator.genHeaderMain(), antlr.PythonCodeGenerator.genJavadocComment(), antlr.PythonCodeGenerator.genRule(), antlr.PythonCodeGenerator.genTokenStrings(), antlr.Grammar.getClassName(), antlr.DefineGrammarSymbols.getHeaderAction(), antlr.Grammar.getSuperClass(), antlr.Token.getText(), antlr.CodeGenerator.grammar, antlr.TokenManager.maxTokenType(), antlr.Grammar.options, antlr.Tool.panic(), antlr.Grammar.preambleAction, antlr.PythonCodeGenerator.printActionCode(), antlr.PythonCodeGenerator.printGrammarAction(), antlr.CodeGenerator.println(), antlr.RuleSymbol.references, antlr.Grammar.rules, antlr.CodeGenerator.setGrammar(), antlr.PythonCodeGenerator.setupOutput(), antlr.collections.impl.Vector.size(), antlr.Grammar.superClass, antlr.CodeGenerator.tabs, antlr.Grammar.tokenManager, and antlr.PythonCodeGenerator.treeWalkerClassName.
void antlr.PythonCodeGenerator.gen | ( | WildcardElement | wc | ) | [virtual] |
Generate code for the given grammar element.
wc | The wildcard element to generate |
Implements antlr.CodeGenerator.
References antlr.AlternativeElement.getAutoGenType(), antlr.WildcardElement.getLabel(), antlr.CodeGenerator.grammar, antlr.PythonCodeGenerator.lt1Value, antlr.CodeGenerator.println(), antlr.PythonCodeGenerator.saveText, antlr.PythonCodeGenerator.syntacticPredLevel, and antlr.CodeGenerator.tabs.
void antlr.PythonCodeGenerator.gen | ( | CharRangeElement | r | ) | [virtual] |
Generate code for the given grammar element.
blk | The character-range reference to generate |
Implements antlr.CodeGenerator.
References antlr.CharRangeElement.beginText, antlr.CharRangeElement.endText, antlr.AlternativeElement.getAutoGenType(), antlr.CharRangeElement.getLabel(), antlr.CodeGenerator.grammar, antlr.PythonCodeGenerator.lt1Value, antlr.CodeGenerator.println(), antlr.PythonCodeGenerator.saveText, and antlr.PythonCodeGenerator.syntacticPredLevel.
void antlr.PythonCodeGenerator.gen | ( | ZeroOrMoreBlock | blk | ) | [virtual] |
Generate code for the given grammar element.
blk | The (...)* block to generate |
Implements antlr.CodeGenerator.
References antlr.Lookahead.containsEpsilon(), antlr.PythonCodeGenerator.currentASTResult, antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.LLkGrammarAnalyzer.deterministic(), antlr.BlockWithImpliedExitPath.exitCache, antlr.BlockWithImpliedExitPath.exitLookaheadDepth, antlr.PythonCodeGenerator.genBlockInitAction(), antlr.PythonCodeGenerator.genBlockPreamble(), antlr.PythonCodeGenerator.genCommonBlock(), antlr.AlternativeBlock.getLabel(), antlr.PythonCodeGenerator.getLookaheadTestExpression(), antlr.CodeGenerator.grammar, antlr.AlternativeBlock.greedy, antlr.Grammar.maxk, antlr.CodeGenerator.println(), antlr.CodeGenerator.tabs, and antlr.Grammar.theLLkAnalyzer.
void antlr.PythonCodeGenerator.gen | ( | LexerGrammar | g | ) | throws IOException [virtual] |
Generate the lexer Java file
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.antlrTool, antlr.CodeGenerator.behavior, antlr.CodeGenerator.bitsetsUsed, antlr.CodeGenerator.currentOutput, antlr.Grammar.debuggingOutput, antlr.collections.impl.Vector.elements(), antlr.PythonCodeGenerator.exitIfError(), antlr.PythonCodeGenerator.flushTokens(), antlr.PythonCodeGenerator.genAST, antlr.PythonCodeGenerator.genBitsets(), antlr.PythonCodeGenerator.genHeader(), antlr.PythonCodeGenerator.genHeaderInit(), antlr.PythonCodeGenerator.genHeaderMain(), antlr.PythonCodeGenerator.genJavadocComment(), antlr.PythonCodeGenerator.genNextToken(), antlr.PythonCodeGenerator.genRule(), antlr.PythonCodeGenerator.genSemPredMap(), antlr.Grammar.getClassName(), antlr.DefineGrammarSymbols.getHeaderAction(), antlr.GrammarSymbol.getId(), antlr.Grammar.getSuperClass(), antlr.Token.getText(), antlr.TokenManager.getTokenSymbol(), antlr.TokenManager.getTokenSymbolKeys(), antlr.TokenSymbol.getTokenType(), antlr.CodeGenerator.grammar, antlr.PythonCodeGenerator.lexerClassName, antlr.Grammar.options, antlr.Tool.panic(), antlr.Grammar.preambleAction, antlr.PythonCodeGenerator.printActionCode(), antlr.PythonCodeGenerator.printGrammarAction(), antlr.CodeGenerator.println(), antlr.Grammar.rules, antlr.PythonCodeGenerator.saveText, antlr.CodeGenerator.setGrammar(), antlr.PythonCodeGenerator.setupOutput(), antlr.collections.impl.Vector.size(), antlr.Grammar.superClass, antlr.CodeGenerator.tabs, antlr.Grammar.tokenManager, and antlr.PythonCodeGenerator.toString().
void antlr.PythonCodeGenerator.genAlt | ( | Alternative | alt, | |
AlternativeBlock | blk | |||
) | [protected] |
Generate an alternative.
alt | The alternative to generate | |
blk | The block to which the alternative belongs |
References antlr.CodeGenerator.antlrTool, antlr.Alternative.exceptionSpec, antlr.PythonCodeGenerator.genAST, antlr.GrammarElement.generate(), antlr.Alternative.getAutoGen(), antlr.GrammarElement.getColumn(), antlr.Grammar.getFilename(), antlr.AlternativeBlock.getLabel(), antlr.GrammarElement.getLine(), antlr.RuleBlock.getRuleName(), antlr.CodeGenerator.grammar, antlr.Grammar.hasSyntacticPredicate, antlr.Alternative.head, antlr.AlternativeElement.next, antlr.CodeGenerator.println(), antlr.PythonCodeGenerator.saveText, antlr.CodeGenerator.tabs, antlr.PythonCodeGenerator.treeVariableMap, and antlr.Tool.warning().
Referenced by antlr.PythonCodeGenerator.genCommonBlock(), and antlr.PythonCodeGenerator.genRule().
void antlr.PythonCodeGenerator.genASTDeclaration | ( | AlternativeElement | el | ) | [protected] |
References antlr.PythonCodeGenerator.labeledElementASTType.
Referenced by antlr.PythonCodeGenerator.genASTDeclaration(), and antlr.PythonCodeGenerator.genBlockPreamble().
void antlr.PythonCodeGenerator.genASTDeclaration | ( | AlternativeElement | el, | |
String | node_type | |||
) | [protected] |
void antlr.PythonCodeGenerator.genASTDeclaration | ( | AlternativeElement | el, | |
String | var_name, | |||
String | node_type | |||
) | [protected] |
void antlr.PythonCodeGenerator.genBitsets | ( | Vector | bitsetList, | |
int | maxVocabulary | |||
) | [protected] |
Generate all the bitsets to be used in the parser or lexer Generate the raw bitset data like "long _tokenSet1_data[] = {...}" and the BitSet object declarations like "BitSet _tokenSet1 = new BitSet(_tokenSet1_data)" Note that most languages do not support object initialization inside a class definition, so other code-generators may have to separate the bitset declarations from the initializations (e.g., put the initializations in the generated constructor instead).
bitsetList | The list of bitsets to generate. | |
maxVocabulary | Ensure that each generated bitset can contain at least this value. |
References antlr.collections.impl.Vector.elementAt(), antlr.collections.impl.BitSet.growToInclude(), antlr.CodeGenerator.println(), and antlr.collections.impl.Vector.size().
Referenced by antlr.PythonCodeGenerator.gen().
void antlr.PythonCodeGenerator.genBlockInitAction | ( | AlternativeBlock | blk | ) | [protected] |
Generate the init action for a block, which may be a RuleBlock or a plain AlternativeBLock. The block for which the preamble is to be generated.
References antlr.PythonCodeGenerator.currentRule, antlr.GrammarElement.getLine(), antlr.AlternativeBlock.initAction, antlr.PythonCodeGenerator.printAction(), and antlr.PythonCodeGenerator.processActionForSpecialSymbols().
Referenced by antlr.PythonCodeGenerator.gen(), and antlr.PythonCodeGenerator.genRule().
void antlr.PythonCodeGenerator.genBlockPreamble | ( | AlternativeBlock | blk | ) | [protected] |
Generate the header for a block, which may be a RuleBlock or a plain AlternativeBLock. This generates any variable declarations and syntactic-predicate-testing variables. The block for which the preamble is to be generated.
References antlr.CodeGenerator.analyzer, antlr.Grammar.buildAST, antlr.collections.impl.Vector.elementAt(), antlr.PythonCodeGenerator.genASTDeclaration(), antlr.GrammarAtom.getASTNodeType(), antlr.AlternativeElement.getLabel(), antlr.AlternativeBlock.getLabel(), antlr.CodeGenerator.grammar, antlr.PythonCodeGenerator.labeledElementInit, antlr.RuleBlock.labeledElements, antlr.CodeGenerator.println(), antlr.collections.impl.Vector.size(), and antlr.LLkGrammarAnalyzer.subruleCanBeInverted().
Referenced by antlr.PythonCodeGenerator.gen(), and antlr.PythonCodeGenerator.genRule().
void antlr.PythonCodeGenerator.genCases | ( | BitSet | p | ) | [protected] |
Generate a series of case statements that implement a BitSet test.
p | The Bitset for which cases are to be generated |
References antlr.CodeGenerator._print(), antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.CodeGenerator.grammar, antlr.CodeGenerator.print(), and antlr.collections.impl.BitSet.toArray().
Referenced by antlr.PythonCodeGenerator.genCommonBlock().
PythonBlockFinishingInfo antlr.PythonCodeGenerator.genCommonBlock | ( | AlternativeBlock | blk, | |
boolean | noTestForSingle | |||
) |
Generate common code for a block of alternatives; return a postscript that needs to be generated at the end of the block. Other routines may append else-clauses and such for error checking before the postfix is generated. If the grammar is a lexer, then generate alternatives in an order where alternatives requiring deeper lookahead are generated first, and EOF in the lookahead set reduces the depth of the lookahead.
blk | The block to generate | |
noTestForSingle | If true, then it does not generate a test for a single alternative. |
References antlr.PythonCodeGenerator.addSemPred(), antlr.AlternativeBlock.alternatives, antlr.CodeGenerator.analyzer, antlr.CodeGenerator.antlrTool, antlr.Alternative.cache, antlr.PythonCodeGenerator.caseSizeThreshold, antlr.CodeGenerator.charFormatter, antlr.Lookahead.containsEpsilon(), antlr.PythonCodeGenerator.currentRule, antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.Grammar.debuggingOutput, antlr.collections.impl.BitSet.degree(), antlr.CharFormatter.escapeString(), antlr.Lookahead.fset, antlr.PythonCodeGenerator.genAlt(), antlr.PythonCodeGenerator.genAST, antlr.PythonCodeGenerator.genCases(), antlr.PythonBlockFinishingInfo.generatedAnIf, antlr.PythonBlockFinishingInfo.generatedSwitch, antlr.PythonCodeGenerator.genSemPred(), antlr.PythonCodeGenerator.genSynPred(), antlr.AlternativeBlock.getAlternativeAt(), antlr.AlternativeBlock.getAlternatives(), antlr.AlternativeBlock.getAutoGen(), antlr.CodeGenerator.getBitsetName(), antlr.GrammarElement.getColumn(), antlr.Grammar.getFilename(), antlr.AlternativeBlock.getLabel(), antlr.GrammarElement.getLine(), antlr.PythonCodeGenerator.getLookaheadTestExpression(), antlr.CodeGenerator.grammar, antlr.Alternative.head, antlr.GrammarElement.line, antlr.LLkGrammarAnalyzer.look(), antlr.Alternative.lookaheadDepth, antlr.PythonCodeGenerator.lookaheadIsEmpty(), antlr.PythonCodeGenerator.lt1Value, antlr.CodeGenerator.makeSwitchThreshold, antlr.CodeGenerator.markBitsetForGen(), antlr.Grammar.maxk, antlr.PythonBlockFinishingInfo.needAnErrorClause, antlr.AlternativeBlock.not, antlr.PythonBlockFinishingInfo.postscript, antlr.CodeGenerator.println(), antlr.PythonCodeGenerator.processActionForSpecialSymbols(), antlr.PythonCodeGenerator.saveText, antlr.Alternative.semPred, antlr.collections.impl.Vector.size(), antlr.LLkGrammarAnalyzer.subruleCanBeInverted(), antlr.Alternative.synPred, antlr.PythonCodeGenerator.syntacticPredLevel, antlr.CodeGenerator.tabs, and antlr.Tool.warning().
Referenced by antlr.PythonCodeGenerator.gen(), antlr.PythonCodeGenerator.genNextToken(), and antlr.PythonCodeGenerator.genRule().
void antlr.PythonCodeGenerator.genHeader | ( | ) | [protected] |
Generate a header that is common to all Python files
References antlr.CodeGenerator.antlrTool, antlr.Tool.fileMinusPath(), antlr.Grammar.getClassName(), antlr.CodeGenerator.grammar, antlr.Tool.grammarFile, and antlr.CodeGenerator.println().
Referenced by antlr.PythonCodeGenerator.gen().
void antlr.PythonCodeGenerator.genHeaderInit | ( | Grammar | grammar | ) | [protected] |
References antlr.CodeGenerator.behavior, antlr.Grammar.getClassName(), antlr.DefineGrammarSymbols.getHeaderAction(), antlr.PythonCodeGenerator.initHeaderAction, antlr.PythonCodeGenerator.isEmpty(), antlr.PythonCodeGenerator.printActionCode(), antlr.CodeGenerator.println(), and antlr.CodeGenerator.tabs.
Referenced by antlr.PythonCodeGenerator.gen().
void antlr.PythonCodeGenerator.genHeaderMain | ( | Grammar | grammar | ) | [protected] |
References antlr.CodeGenerator.behavior, antlr.PythonCodeGenerator.genLexerTest(), antlr.Grammar.getClassName(), antlr.DefineGrammarSymbols.getHeaderAction(), antlr.PythonCodeGenerator.isEmpty(), antlr.PythonCodeGenerator.mainHeaderAction, antlr.CodeGenerator.println(), antlr.PythonCodeGenerator.printMainFunc(), and antlr.CodeGenerator.tabs.
Referenced by antlr.PythonCodeGenerator.gen().
void antlr.PythonCodeGenerator.genJavadocComment | ( | Grammar | g | ) | [protected] |
References antlr.PythonCodeGenerator._printJavadoc(), and antlr.Grammar.comment.
Referenced by antlr.PythonCodeGenerator.gen(), and antlr.PythonCodeGenerator.genRule().
void antlr.PythonCodeGenerator.genJavadocComment | ( | RuleSymbol | g | ) | [protected] |
References antlr.PythonCodeGenerator._printJavadoc(), and antlr.RuleSymbol.comment.
void antlr.PythonCodeGenerator.genLexerTest | ( | ) | [protected] |
Generate an iterator method for the Python CharScanner (sub)classes. Generate an automated test for Python CharScanner (sub)classes.
References antlr.Grammar.getClassName(), antlr.CodeGenerator.grammar, antlr.CodeGenerator.println(), and antlr.CodeGenerator.tabs.
Referenced by antlr.PythonCodeGenerator.genHeaderMain().
void antlr.PythonCodeGenerator.genMatch | ( | BitSet | b | ) | [protected] |
Referenced by antlr.PythonCodeGenerator.gen().
void antlr.PythonCodeGenerator.genMatch | ( | GrammarAtom | atom | ) | [protected] |
void antlr.PythonCodeGenerator.genMatchUsingAtomText | ( | GrammarAtom | atom | ) | [protected] |
References antlr.CodeGenerator._print(), antlr.CodeGenerator._println(), antlr.GrammarAtom.atomText, antlr.AlternativeElement.getAutoGenType(), antlr.CodeGenerator.grammar, antlr.GrammarAtom.not, antlr.CodeGenerator.print(), antlr.CodeGenerator.println(), and antlr.PythonCodeGenerator.saveText.
Referenced by antlr.PythonCodeGenerator.genMatch().
void antlr.PythonCodeGenerator.genMatchUsingAtomTokenType | ( | GrammarAtom | atom | ) | [protected] |
References antlr.GrammarAtom.getType(), antlr.CodeGenerator.grammar, antlr.GrammarAtom.not, and antlr.CodeGenerator.println().
Referenced by antlr.PythonCodeGenerator.genMatch().
void antlr.PythonCodeGenerator.genNextToken | ( | ) |
Generate the nextToken() rule. nextToken() is a synthetic lexer rule that is the implicit OR of all user-defined lexer rules.
References antlr.RuleSymbol.access, antlr.CodeGenerator.antlrTool, antlr.Grammar.antlrTool, antlr.Alternative.cache, antlr.Lookahead.containsEpsilon(), antlr.Grammar.define(), antlr.LLkGrammarAnalyzer.deterministic(), antlr.collections.impl.Vector.elementAt(), antlr.Tool.error(), antlr.PythonCodeGenerator.genCommonBlock(), antlr.AlternativeBlock.getAlternativeAt(), antlr.AlternativeBlock.getAlternatives(), antlr.RuleBlock.getDefaultErrorHandler(), antlr.Grammar.getSymbol(), antlr.CodeGenerator.grammar, antlr.Alternative.head, antlr.Grammar.isDefined(), antlr.RuleSymbol.isDefined(), antlr.CodeGenerator.println(), antlr.Grammar.rules, antlr.RuleSymbol.setBlock(), antlr.RuleSymbol.setDefined(), antlr.collections.impl.Vector.size(), antlr.CodeGenerator.tabs, antlr.RuleRefElement.targetRule, antlr.Grammar.theLLkAnalyzer, and antlr.Tool.warning().
Referenced by antlr.PythonCodeGenerator.gen().
void antlr.PythonCodeGenerator.genRule | ( | RuleSymbol | s, | |
boolean | startSymbol, | |||
int | ruleNum | |||
) |
Gen a named rule block. ASTs are generated for each element of an alternative unless the rule or the alternative have a '!' modifier.
If an alternative defeats the default tree construction, it must set <rule>_AST to the root of the returned AST.
Each alternative that does automatic tree construction, builds up root and child list pointers in an ASTPair structure.
A rule finishes by setting the returnAST variable from the ASTPair.
rule | The name of the rule to generate | |
startSymbol | true if the rule is a start symbol (i.e., not referenced elsewhere) |
References antlr.CodeGenerator._print(), antlr.CodeGenerator._println(), antlr.RuleSymbol.access, antlr.AlternativeBlock.alternatives, antlr.CodeGenerator.antlrTool, antlr.RuleBlock.argAction, antlr.Grammar.buildAST, antlr.PythonCodeGenerator.commonExtraParams, antlr.PythonCodeGenerator.commonLocalVars, antlr.PythonCodeGenerator.currentASTResult, antlr.PythonCodeGenerator.currentRule, antlr.Grammar.debuggingOutput, antlr.PythonCodeGenerator.declaredASTVariables, antlr.LLkGrammarAnalyzer.deterministic(), antlr.RuleBlock.endNode, antlr.Tool.error(), antlr.PythonCodeGenerator.exceptionThrown, antlr.PythonCodeGenerator.extractIdOfAction(), antlr.RuleBlock.findExceptionSpec(), antlr.LLkGrammarAnalyzer.FOLLOW(), antlr.Lookahead.fset, antlr.PythonCodeGenerator.genAlt(), antlr.PythonCodeGenerator.genAST, antlr.PythonCodeGenerator.genBlockInitAction(), antlr.PythonCodeGenerator.genBlockPreamble(), antlr.PythonCodeGenerator.genCommonBlock(), antlr.PythonCodeGenerator.genJavadocComment(), antlr.PythonCodeGenerator.genSemPred(), antlr.AlternativeBlock.getAlternativeAt(), antlr.AlternativeBlock.getAutoGen(), antlr.CodeGenerator.getBitsetName(), antlr.RuleSymbol.getBlock(), antlr.GrammarElement.getColumn(), antlr.RuleBlock.getDefaultErrorHandler(), antlr.Grammar.getFilename(), antlr.GrammarSymbol.getId(), antlr.GrammarElement.getLine(), antlr.RuleBlock.getTestLiterals(), antlr.CodeGenerator.grammar, antlr.Grammar.hasSyntacticPredicate, antlr.RuleSymbol.isDefined(), antlr.GrammarElement.line, antlr.CodeGenerator.markBitsetForGen(), antlr.CodeGenerator.print(), antlr.CodeGenerator.println(), antlr.RuleBlock.returnAction, antlr.PythonCodeGenerator.saveText, antlr.Alternative.semPred, antlr.collections.impl.Vector.size(), antlr.Alternative.synPred, antlr.CodeGenerator.tabs, antlr.Grammar.theLLkAnalyzer, antlr.PythonCodeGenerator.throwNoViable, antlr.Grammar.traceRules, and antlr.Tool.warning().
Referenced by antlr.PythonCodeGenerator.gen().
void antlr.PythonCodeGenerator.genSemPred | ( | String | pred, | |
int | line | |||
) | [protected] |
References antlr.PythonCodeGenerator.addSemPred(), antlr.CodeGenerator.charFormatter, antlr.PythonCodeGenerator.currentRule, antlr.Grammar.debuggingOutput, antlr.CharFormatter.escapeString(), antlr.CodeGenerator.grammar, antlr.CodeGenerator.println(), antlr.PythonCodeGenerator.processActionForSpecialSymbols(), and antlr.CodeGenerator.tabs.
Referenced by antlr.PythonCodeGenerator.gen(), antlr.PythonCodeGenerator.genCommonBlock(), and antlr.PythonCodeGenerator.genRule().
void antlr.PythonCodeGenerator.genSemPredMap | ( | ) | [protected] |
Write an array of Strings which are the semantic predicate expressions. The debugger will reference them by number only
References antlr.collections.impl.Vector.elements(), antlr.CodeGenerator.println(), and antlr.CodeGenerator.tabs.
Referenced by antlr.PythonCodeGenerator.gen().
void antlr.PythonCodeGenerator.genSynPred | ( | SynPredBlock | blk, | |
String | lookaheadExpr | |||
) | [protected] |
References antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.Grammar.debuggingOutput, antlr.PythonCodeGenerator.exceptionThrown, antlr.PythonCodeGenerator.gen(), antlr.CodeGenerator.grammar, antlr.AlternativeBlock.ID, antlr.CodeGenerator.println(), antlr.PythonCodeGenerator.syntacticPredLevel, and antlr.CodeGenerator.tabs.
Referenced by antlr.PythonCodeGenerator.genCommonBlock().
void antlr.PythonCodeGenerator.genTokenASTNodeMap | ( | ) | [protected] |
Create and set Integer token type objects that map to Java Class objects (which AST node to create).
References antlr.collections.impl.Vector.elementAt(), antlr.TokenSymbol.getASTNodeType(), antlr.TokenManager.getTokenSymbol(), antlr.TokenSymbol.getTokenType(), antlr.TokenManager.getVocabulary(), antlr.CodeGenerator.grammar, antlr.CodeGenerator.println(), antlr.collections.impl.Vector.size(), antlr.CodeGenerator.tabs, and antlr.Grammar.tokenManager.
Referenced by antlr.PythonCodeGenerator.gen().
void antlr.PythonCodeGenerator.genTokenStrings | ( | ) |
Generate a static array containing the names of the tokens, indexed by the token type values. This static array is used to format error messages so that the token identifers or literal strings are displayed instead of the token numbers.
If a lexical rule has a paraphrase, use it rather than the token label.
References antlr.CodeGenerator._print(), antlr.CodeGenerator._println(), antlr.CodeGenerator.charFormatter, antlr.collections.impl.Vector.elementAt(), antlr.TokenSymbol.getParaphrase(), antlr.TokenManager.getTokenSymbol(), antlr.TokenManager.getVocabulary(), antlr.CodeGenerator.grammar, antlr.CharFormatter.literalString(), antlr.CodeGenerator.print(), antlr.CodeGenerator.println(), antlr.collections.impl.Vector.size(), antlr.CodeGenerator.tabs, and antlr.Grammar.tokenManager.
Referenced by antlr.PythonCodeGenerator.gen().
void antlr.PythonCodeGenerator.genTokenTypes | ( | TokenManager | tm | ) | throws IOException [protected] |
Generate the token types Java file
References antlr.CodeGenerator.antlrTool, antlr.collections.impl.Vector.elementAt(), antlr.PythonCodeGenerator.exitIfError(), antlr.StringLiteralSymbol.label, antlr.Tool.panic(), antlr.CodeGenerator.println(), antlr.collections.impl.Vector.size(), and antlr.CodeGenerator.tabs.
Referenced by antlr.PythonCodeGenerator.flushTokens().
String antlr.PythonCodeGenerator.getASTCreateString | ( | String | astCtorArgs | ) |
Get a string for an expression to generate creating of an AST node. Parse the first (possibly only) argument looking for the token type. If the token type is a valid token symbol, ask for it's AST node type and add to the end if only 2 arguments. The forms are #[T], #[T,"t"], and as of 2.7.2 #[T,"t",ASTclassname].
str | The arguments to the AST constructor |
References antlr.TokenSymbol.getASTNodeType(), antlr.TokenManager.getTokenSymbol(), antlr.CodeGenerator.grammar, antlr.PythonCodeGenerator.labeledElementASTType, and antlr.Grammar.tokenManager.
String antlr.PythonCodeGenerator.getASTCreateString | ( | GrammarAtom | atom, | |
String | astCtorArgs | |||
) | [virtual] |
Get a string for an expression to generate creating of an AST node
atom | The grammar node for which you are creating the node | |
str | The arguments to the AST constructor |
Implements antlr.CodeGenerator.
References antlr.PythonCodeGenerator.getASTCreateString(), and antlr.GrammarAtom.getASTNodeType().
String antlr.PythonCodeGenerator.getASTCreateString | ( | Vector | v | ) | [virtual] |
Get a string for an expression to generate creation of an AST subtree.
v | A Vector of String, where each element is an expression in the target language yielding an AST node. |
Implements antlr.CodeGenerator.
References antlr.collections.impl.Vector.elementAt(), and antlr.collections.impl.Vector.size().
Referenced by antlr.PythonCodeGenerator.getASTCreateString().
String antlr.PythonCodeGenerator.getLookaheadTestExpression | ( | Alternative | alt, | |
int | maxDepth | |||
) | [protected] |
Generate a lookahead test expression for an alternate. This will be a series of tests joined by '&&' and enclosed by '()', the number of such tests being determined by the depth of the lookahead.
References antlr.Alternative.cache, antlr.PythonCodeGenerator.getLookaheadTestExpression(), antlr.CodeGenerator.grammar, antlr.Alternative.lookaheadDepth, and antlr.Grammar.maxk.
String antlr.PythonCodeGenerator.getLookaheadTestExpression | ( | Lookahead[] | look, | |
int | k | |||
) | [protected] |
String antlr.PythonCodeGenerator.getLookaheadTestTerm | ( | int | k, | |
BitSet | p | |||
) | [protected] |
Generate a depth==1 lookahead test expression given the BitSet. This may be one of: 1) a series of 'x==X||' tests 2) a range test using >= && <= where possible, 3) a bitset membership test for complex comparisons
k | The lookahead level | |
p | The lookahead set for level k |
References antlr.CodeGenerator.bitsetTestThreshold, antlr.collections.impl.BitSet.degree(), antlr.CodeGenerator.elementsAreRange(), antlr.CodeGenerator.getBitsetName(), antlr.PythonCodeGenerator.getRangeExpression(), antlr.CodeGenerator.markBitsetForGen(), and antlr.collections.impl.BitSet.toArray().
Referenced by antlr.PythonCodeGenerator.getLookaheadTestExpression().
String antlr.PythonCodeGenerator.getRangeExpression | ( | int | k, | |
int[] | elems | |||
) |
Return an expression for testing a contiguous renage of elements
k | The lookahead level | |
elems | The elements representing the set, usually from BitSet.toArray(). |
References antlr.CodeGenerator.antlrTool, antlr.CodeGenerator.elementsAreRange(), and antlr.Tool.panic().
Referenced by antlr.PythonCodeGenerator.getLookaheadTestTerm().
static boolean antlr.PythonCodeGenerator.isEmpty | ( | String | s | ) | [static, package] |
boolean antlr.PythonCodeGenerator.isspace | ( | char | c | ) | [protected] |
Referenced by antlr.PythonCodeGenerator._printAction().
boolean antlr.PythonCodeGenerator.lookaheadIsEmpty | ( | Alternative | alt, | |
int | maxDepth | |||
) | [protected] |
Is the lookahead for this alt empty?
References antlr.Alternative.cache, antlr.collections.impl.BitSet.degree(), antlr.Lookahead.fset, antlr.CodeGenerator.grammar, antlr.Alternative.lookaheadDepth, and antlr.Grammar.maxk.
Referenced by antlr.PythonCodeGenerator.genCommonBlock().
String antlr.PythonCodeGenerator.mapTreeId | ( | String | idParam, | |
ActionTransInfo | transInfo | |||
) | [virtual] |
Map an identifier to it's corresponding tree-node variable. This is context-sensitive, depending on the rule and alternative being generated
idParam | The identifier name to map |
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.antlrTool, antlr.Grammar.buildAST, antlr.PythonCodeGenerator.currentRule, antlr.collections.impl.Vector.elementAt(), antlr.Tool.error(), antlr.AlternativeElement.getLabel(), antlr.RuleBlock.getRuleName(), antlr.CodeGenerator.grammar, antlr.RuleBlock.labeledElements, antlr.PythonCodeGenerator.NONUNIQUE, antlr.ActionTransInfo.refRuleRoot, antlr.collections.impl.Vector.size(), and antlr.PythonCodeGenerator.treeVariableMap.
void antlr.PythonCodeGenerator.od | ( | String | s, | |
int | i, | |||
int | end, | |||
String | msg | |||
) | [protected] |
void antlr.PythonCodeGenerator.printAction | ( | String | s | ) | [protected] |
Print an action with leading tabs, attempting to preserve the current indentation level for multi-line actions Ignored if string is null.
s | The action string to output |
Reimplemented from antlr.CodeGenerator.
References antlr.PythonCodeGenerator._printAction(), and antlr.PythonCodeGenerator.printTabs().
Referenced by antlr.PythonCodeGenerator.gen(), antlr.PythonCodeGenerator.genBlockInitAction(), antlr.PythonCodeGenerator.printActionCode(), and antlr.PythonCodeGenerator.printGrammarAction().
void antlr.PythonCodeGenerator.printActionCode | ( | String | actionStr, | |
int | line | |||
) | [protected] |
void antlr.PythonCodeGenerator.printGrammarAction | ( | Grammar | grammar | ) | [protected] |
References antlr.Grammar.classMemberAction, antlr.PythonCodeGenerator.currentRule, antlr.Token.getLine(), antlr.Token.getText(), antlr.PythonCodeGenerator.printAction(), antlr.CodeGenerator.println(), and antlr.PythonCodeGenerator.processActionForSpecialSymbols().
Referenced by antlr.PythonCodeGenerator.gen().
void antlr.PythonCodeGenerator.printMainFunc | ( | String | s | ) | [protected] |
References antlr.PythonCodeGenerator.printActionCode(), antlr.CodeGenerator.println(), and antlr.CodeGenerator.tabs.
Referenced by antlr.PythonCodeGenerator.genHeaderMain().
void antlr.PythonCodeGenerator.printTabs | ( | ) | [protected] |
Create a Java code-generator using the given Grammar. The caller must still call setTool, setBehavior, and setAnalyzer before generating code.
Reimplemented from antlr.CodeGenerator.
References antlr.CodeGenerator.currentOutput, and antlr.CodeGenerator.tabs.
Referenced by antlr.PythonCodeGenerator._printAction(), antlr.PythonCodeGenerator._printJavadoc(), antlr.PythonCodeGenerator.gen(), and antlr.PythonCodeGenerator.printAction().
String antlr.PythonCodeGenerator.processActionCode | ( | String | actionStr, | |
int | line | |||
) | [protected] |
String antlr.PythonCodeGenerator.processActionForSpecialSymbols | ( | String | actionStr, | |
int | line, | |||
RuleBlock | currentRule, | |||
ActionTransInfo | tInfo | |||
) | [protected, virtual] |
Lexically process $var and tree-specifiers in the action. This will replace id and #(...) with the appropriate function calls and/or variables etc...
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.antlrTool, antlr.Grammar.getFilename(), antlr.CodeGenerator.grammar, antlr.PythonCodeGenerator.isEmpty(), and antlr.Tool.panic().
Referenced by antlr.PythonCodeGenerator.gen(), antlr.PythonCodeGenerator.genBlockInitAction(), antlr.PythonCodeGenerator.genCommonBlock(), antlr.PythonCodeGenerator.genSemPred(), and antlr.PythonCodeGenerator.printGrammarAction().
void antlr.PythonCodeGenerator.setupOutput | ( | String | className | ) | throws IOException |
This method exists so a subclass, namely VAJCodeGenerator, can open the file in its own evil way. JavaCodeGenerator simply opens a text file...
References antlr.CodeGenerator.antlrTool, antlr.CodeGenerator.currentOutput, and antlr.Tool.openOutputFile().
Referenced by antlr.PythonCodeGenerator.gen().
String antlr.PythonCodeGenerator.toString | ( | boolean | v | ) | [package] |
Referenced by antlr.PythonCodeGenerator.gen().
int antlr.PythonCodeGenerator.astVarNumber = 1 [package] |
final int antlr.PythonCodeGenerator.caseSizeThreshold = 127 [static] |
Referenced by antlr.PythonCodeGenerator.genCommonBlock().
String antlr.PythonCodeGenerator.commonExtraArgs [package] |
String antlr.PythonCodeGenerator.commonExtraParams [package] |
Referenced by antlr.PythonCodeGenerator.genRule().
String antlr.PythonCodeGenerator.commonLocalVars [package] |
Referenced by antlr.PythonCodeGenerator.genRule().
String antlr.PythonCodeGenerator.currentASTResult [package] |
Tracks the rule or labeled subrule being generated. Used for AST generation.
Referenced by antlr.PythonCodeGenerator.gen(), and antlr.PythonCodeGenerator.genRule().
Tracks the rule being generated. Used for mapTreeId
Referenced by antlr.PythonCodeGenerator.gen(), antlr.PythonCodeGenerator.genBlockInitAction(), antlr.PythonCodeGenerator.genCommonBlock(), antlr.PythonCodeGenerator.genRule(), antlr.PythonCodeGenerator.genSemPred(), antlr.PythonCodeGenerator.mapTreeId(), and antlr.PythonCodeGenerator.printGrammarAction().
Hashtable antlr.PythonCodeGenerator.declaredASTVariables = new Hashtable() [package] |
Used to keep track of which AST variables have been defined in a rule (except for the rule_name and rule_name_in var's
Referenced by antlr.PythonCodeGenerator.genASTDeclaration(), and antlr.PythonCodeGenerator.genRule().
String antlr.PythonCodeGenerator.exceptionThrown [package] |
Referenced by antlr.PythonCodeGenerator.genRule(), and antlr.PythonCodeGenerator.genSynPred().
boolean antlr.PythonCodeGenerator.genAST = false [protected] |
final String antlr.PythonCodeGenerator.initHeaderAction = "__init__" [static] |
Referenced by antlr.PythonCodeGenerator.genHeaderInit().
String antlr.PythonCodeGenerator.labeledElementASTType [package] |
String antlr.PythonCodeGenerator.labeledElementInit [package] |
Referenced by antlr.PythonCodeGenerator.genBlockPreamble().
String antlr.PythonCodeGenerator.labeledElementType [package] |
String antlr.PythonCodeGenerator.lexerClassName [package] |
Referenced by antlr.PythonCodeGenerator.gen().
String antlr.PythonCodeGenerator.lt1Value [package] |
Referenced by antlr.PythonCodeGenerator.gen(), and antlr.PythonCodeGenerator.genCommonBlock().
final String antlr.PythonCodeGenerator.mainHeaderAction = "__main__" [static] |
Referenced by antlr.PythonCodeGenerator.genHeaderMain().
final String antlr.PythonCodeGenerator.NONUNIQUE = new String() [static, protected] |
Special value used to mark duplicate in treeVariableMap
Referenced by antlr.PythonCodeGenerator.mapTreeId().
String antlr.PythonCodeGenerator.parserClassName [package] |
Referenced by antlr.PythonCodeGenerator.gen().
boolean antlr.PythonCodeGenerator.saveText = false [protected] |
int antlr.PythonCodeGenerator.syntacticPredLevel = 0 [protected] |
String antlr.PythonCodeGenerator.throwNoViable [package] |
Referenced by antlr.PythonCodeGenerator.gen(), and antlr.PythonCodeGenerator.genRule().
Hashtable antlr.PythonCodeGenerator.treeVariableMap = new Hashtable() [package] |
Mapping between the ids used in the current alt, and the names of variables used to represent their AST values.
Referenced by antlr.PythonCodeGenerator.genAlt(), and antlr.PythonCodeGenerator.mapTreeId().
String antlr.PythonCodeGenerator.treeWalkerClassName [package] |
Referenced by antlr.PythonCodeGenerator.gen().