Public Member Functions | |
CppCodeGenerator () | |
void | exitIfError () |
void | printAction (Token t) |
void | printHeaderAction (String name) |
void | genLineNo (int line) |
void | genLineNo (GrammarElement el) |
void | genLineNo (Token t) |
void | genLineNo2 () |
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) |
void | genBody (LexerGrammar g) throws IOException |
void | genInitFactory (Grammar g) |
void | genBody (ParserGrammar g) throws IOException |
void | genBody (TreeWalkerGrammar g) throws IOException |
CppBlockFinishingInfo | genCommonBlock (AlternativeBlock blk, boolean noTestForSingle) |
void | genInclude (LexerGrammar g) throws IOException |
void | genInclude (ParserGrammar g) throws IOException |
void | genInclude (TreeWalkerGrammar g) throws IOException |
void | genNextToken () |
void | genRule (RuleSymbol s, boolean startSymbol, int ruleNum, String prefix) |
void | genRuleHeader (RuleSymbol s, boolean startSymbol) |
void | genTokenStrings (String prefix) |
String | processStringForASTConstructor (String str) |
String | getASTCreateString (Vector v) |
String | getASTCreateString (GrammarAtom atom, String str) |
String | getASTCreateString (String str) |
String | getRangeExpression (int k, int[] elems) |
String | mapTreeId (String idParam, ActionTransInfo transInfo) |
Static Public Attributes | |
static final int | caseSizeThreshold = 127 |
Protected Member Functions | |
int | addSemPred (String predicate) |
int | countLines (String s) |
void | _print (String s) |
void | _printAction (String s) |
void | _println (String s) |
void | println (String s) |
void | genAlt (Alternative alt, AlternativeBlock blk) |
void | genBitsets (Vector bitsetList, int maxVocabulary, String prefix) |
void | genBitsetsHeader (Vector bitsetList, int maxVocabulary) |
void | genBlockInitAction (AlternativeBlock blk) |
void | genBlockPreamble (AlternativeBlock blk) |
void | genCases (BitSet p) |
void | genHeader (String fileName) |
void | genASTDeclaration (AlternativeElement el) |
for convenience | |
void | genASTDeclaration (AlternativeElement el, String node_type) |
for convenience | |
void | genASTDeclaration (AlternativeElement el, String var_name, String node_type) |
Generate (if not already done) a declaration for the AST for el. | |
void | genMatch (BitSet b) |
void | genMatch (GrammarAtom atom) |
void | genMatchUsingAtomText (GrammarAtom atom) |
void | genMatchUsingAtomTokenType (GrammarAtom atom) |
void | genSemPred (String pred, int line) |
void | genSemPredMap (String prefix) |
void | genSynPred (SynPredBlock blk, String lookaheadExpr) |
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) |
Protected Attributes | |
int | syntacticPredLevel = 0 |
boolean | genAST = false |
boolean | saveText = false |
boolean | genHashLines = true |
boolean | noConstructors = false |
int | outputLine |
String | outputFile |
Static Protected Attributes | |
static final String | NONUNIQUE = new String() |
Package Attributes | |
boolean | DEBUG_CPP_CODE_GENERATOR = false |
boolean | usingCustomAST = false |
String | labeledElementType |
String | labeledElementASTType |
String | labeledElementASTInit |
String | labeledElementInit |
String | commonExtraArgs |
String | commonExtraParams |
String | commonLocalVars |
String | lt1Value |
String | exceptionThrown |
String | throwNoViable |
RuleBlock | currentRule |
String | currentASTResult |
Hashtable | treeVariableMap = new Hashtable() |
Hashtable | declaredASTVariables = new Hashtable() |
int | astVarNumber = 1 |
Generate MyParser.cpp, MyParser.hpp, MyLexer.cpp, MyLexer.hpp and MyParserTokenTypes.hpp
antlr.CppCodeGenerator.CppCodeGenerator | ( | ) |
Create a C++ code-generator using the given Grammar. The caller must still call setTool, setBehavior, and setAnalyzer before generating code.
References antlr.CodeGenerator.charFormatter.
void antlr.CppCodeGenerator._print | ( | String | s | ) | [protected] |
Output a String to the currentOutput stream. Ignored if string is null.
s | The string to output |
Reimplemented from antlr.CodeGenerator.
References antlr.CppCodeGenerator.countLines(), antlr.CodeGenerator.currentOutput, and antlr.CppCodeGenerator.outputLine.
Referenced by antlr.CppCodeGenerator.gen(), antlr.CppCodeGenerator.genCases(), antlr.CppCodeGenerator.genMatchUsingAtomText(), antlr.CppCodeGenerator.genRule(), and antlr.CppCodeGenerator.genRuleHeader().
void antlr.CppCodeGenerator._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.CppCodeGenerator.countLines(), and antlr.CppCodeGenerator.outputLine.
Referenced by antlr.CppCodeGenerator.printAction().
void antlr.CppCodeGenerator._println | ( | String | s | ) | [protected] |
Output a String followed by newline, to the currentOutput stream. Ignored if string is null.
s | The string to output |
Reimplemented from antlr.CodeGenerator.
References antlr.CppCodeGenerator.countLines(), antlr.CodeGenerator.currentOutput, and antlr.CppCodeGenerator.outputLine.
Referenced by antlr.CppCodeGenerator.gen(), antlr.CppCodeGenerator.genCases(), antlr.CppCodeGenerator.genInclude(), antlr.CppCodeGenerator.genLineNo(), antlr.CppCodeGenerator.genLineNo2(), antlr.CppCodeGenerator.genMatchUsingAtomText(), antlr.CppCodeGenerator.genNextToken(), antlr.CppCodeGenerator.genRule(), antlr.CppCodeGenerator.genRuleHeader(), and antlr.CppCodeGenerator.genTokenStrings().
int antlr.CppCodeGenerator.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.CppCodeGenerator.genCommonBlock(), and antlr.CppCodeGenerator.genSemPred().
int antlr.CppCodeGenerator.countLines | ( | String | s | ) | [protected] |
void antlr.CppCodeGenerator.exitIfError | ( | ) |
void antlr.CppCodeGenerator.gen | ( | AlternativeBlock | blk | ) | [virtual] |
Generate code for the given grammar element.
blk | The "x|y|z|..." block to generate |
Implements antlr.CodeGenerator.
References antlr.CppCodeGenerator.currentASTResult, antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.CppCodeGenerator.DEBUG_CPP_CODE_GENERATOR, antlr.LLkGrammarAnalyzer.deterministic(), antlr.CppCodeGenerator.genBlockInitAction(), antlr.CppCodeGenerator.genBlockPreamble(), antlr.CppCodeGenerator.genCommonBlock(), antlr.AlternativeBlock.getLabel(), antlr.CodeGenerator.grammar, antlr.CppCodeGenerator.println(), antlr.Grammar.theLLkAnalyzer, and antlr.CppCodeGenerator.throwNoViable.
void antlr.CppCodeGenerator.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, and antlr.CppCodeGenerator.DEBUG_CPP_CODE_GENERATOR.
void antlr.CppCodeGenerator.gen | ( | CharLiteralElement | atom | ) | [virtual] |
Generate code for the given grammar element. Only called from lexer grammars.
blk | The character literal reference to generate |
Implements antlr.CodeGenerator.
References antlr.CppCodeGenerator._print(), antlr.CppCodeGenerator._println(), antlr.CodeGenerator.antlrTool, antlr.GrammarAtom.atomText, antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.CppCodeGenerator.DEBUG_CPP_CODE_GENERATOR, antlr.Tool.error(), antlr.AlternativeElement.getAutoGenType(), antlr.GrammarAtom.getLabel(), antlr.CodeGenerator.grammar, antlr.CppCodeGenerator.lt1Value, antlr.GrammarAtom.not, antlr.CodeGenerator.print(), antlr.CppCodeGenerator.println(), and antlr.CppCodeGenerator.saveText.
void antlr.CppCodeGenerator.gen | ( | CharRangeElement | r | ) | [virtual] |
Generate code for the given grammar element. Only called from lexer grammars.
blk | The character-range reference to generate |
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.antlrTool, antlr.CharRangeElement.beginText, antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.CppCodeGenerator.DEBUG_CPP_CODE_GENERATOR, antlr.CharRangeElement.endText, antlr.Tool.error(), antlr.AlternativeElement.getAutoGenType(), antlr.CharRangeElement.getLabel(), antlr.CodeGenerator.grammar, antlr.CppCodeGenerator.lt1Value, antlr.CppCodeGenerator.println(), antlr.CppCodeGenerator.saveText, and antlr.CppCodeGenerator.syntacticPredLevel.
void antlr.CppCodeGenerator.gen | ( | LexerGrammar | g | ) | throws IOException [virtual] |
Generate the lexer C++ files
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.antlrTool, antlr.CppCodeGenerator.genBody(), antlr.CppCodeGenerator.genInclude(), antlr.CodeGenerator.grammar, antlr.Tool.panic(), antlr.CodeGenerator.setGrammar(), and antlr.Tool.warning().
void antlr.CppCodeGenerator.gen | ( | OneOrMoreBlock | blk | ) | [virtual] |
Generate code for the given grammar element.
blk | The (...)+ block to generate |
Implements antlr.CodeGenerator.
References antlr.Lookahead.containsEpsilon(), antlr.CppCodeGenerator.currentASTResult, antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.CppCodeGenerator.DEBUG_CPP_CODE_GENERATOR, antlr.LLkGrammarAnalyzer.deterministic(), antlr.BlockWithImpliedExitPath.exitCache, antlr.BlockWithImpliedExitPath.exitLookaheadDepth, antlr.CppCodeGenerator.genBlockInitAction(), antlr.CppCodeGenerator.genBlockPreamble(), antlr.CppCodeGenerator.genCommonBlock(), antlr.AlternativeBlock.getLabel(), antlr.CppCodeGenerator.getLookaheadTestExpression(), antlr.CodeGenerator.grammar, antlr.AlternativeBlock.greedy, antlr.AlternativeBlock.ID, antlr.Grammar.maxk, antlr.CppCodeGenerator.println(), antlr.CodeGenerator.tabs, antlr.Grammar.theLLkAnalyzer, and antlr.CppCodeGenerator.throwNoViable.
void antlr.CppCodeGenerator.gen | ( | ParserGrammar | g | ) | throws IOException [virtual] |
Generate the parser C++ file
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.antlrTool, antlr.CppCodeGenerator.genBody(), antlr.CppCodeGenerator.genInclude(), antlr.CodeGenerator.grammar, antlr.Tool.panic(), and antlr.CodeGenerator.setGrammar().
void antlr.CppCodeGenerator.gen | ( | RuleRefElement | rr | ) | [virtual] |
Generate code for the given grammar element.
blk | The rule-reference to generate |
Implements antlr.CodeGenerator.
References antlr.CppCodeGenerator._print(), antlr.CodeGenerator.antlrTool, antlr.RuleSymbol.block, antlr.Grammar.buildAST, antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.CppCodeGenerator.DEBUG_CPP_CODE_GENERATOR, antlr.Tool.error(), antlr.CppCodeGenerator.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.CppCodeGenerator.labeledElementASTInit, antlr.CppCodeGenerator.lt1Value, antlr.CppCodeGenerator.println(), antlr.CodeGenerator.printTabs(), antlr.RuleBlock.returnAction, antlr.CppCodeGenerator.saveText, antlr.CppCodeGenerator.syntacticPredLevel, antlr.CodeGenerator.tabs, antlr.RuleRefElement.targetRule, antlr.CppCodeGenerator.usingCustomAST, and antlr.Tool.warning().
void antlr.CppCodeGenerator.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.CppCodeGenerator.DEBUG_CPP_CODE_GENERATOR, antlr.CppCodeGenerator.genMatch(), antlr.AlternativeElement.getAutoGenType(), antlr.GrammarAtom.getLabel(), antlr.CodeGenerator.grammar, antlr.CppCodeGenerator.lt1Value, antlr.CppCodeGenerator.println(), antlr.CppCodeGenerator.saveText, and antlr.CppCodeGenerator.syntacticPredLevel.
void antlr.CppCodeGenerator.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.CppCodeGenerator.lt1Value, antlr.CppCodeGenerator.println(), and antlr.CppCodeGenerator.syntacticPredLevel.
void antlr.CppCodeGenerator.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.CppCodeGenerator.DEBUG_CPP_CODE_GENERATOR, antlr.CppCodeGenerator.genMatch(), antlr.GrammarAtom.getLabel(), antlr.CodeGenerator.grammar, antlr.CppCodeGenerator.lt1Value, antlr.Tool.panic(), antlr.CppCodeGenerator.println(), and antlr.CppCodeGenerator.syntacticPredLevel.
void antlr.CppCodeGenerator.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.CppCodeGenerator.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.CppCodeGenerator.labeledElementASTInit, antlr.CppCodeGenerator.labeledElementType, antlr.AlternativeElement.next, antlr.CppCodeGenerator.println(), antlr.TreeElement.root, antlr.AlternativeElement.setAutoGenType(), antlr.collections.impl.Vector.size(), and antlr.Tool.warning().
void antlr.CppCodeGenerator.gen | ( | ) | [virtual] |
Generate the parser, lexer, treeparser, and token types in C++
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.analyzer, antlr.CodeGenerator.antlrTool, antlr.CodeGenerator.behavior, antlr.Grammar.debuggingOutput, antlr.Tool.error(), antlr.CppCodeGenerator.exitIfError(), antlr.Grammar.generate(), antlr.CodeGenerator.genTokenInterchange(), antlr.CppCodeGenerator.genTokenTypes(), antlr.Grammar.getFilename(), antlr.DefineGrammarSymbols.grammars, antlr.TokenManager.isReadOnly(), antlr.Tool.reportException(), antlr.Grammar.setCodeGenerator(), antlr.LLkGrammarAnalyzer.setGrammar(), antlr.Grammar.setGrammarAnalyzer(), and antlr.DefineGrammarSymbols.tokenManagers.
Referenced by antlr.CppCodeGenerator.genMatch(), and antlr.CppCodeGenerator.genSynPred().
void antlr.CppCodeGenerator.gen | ( | TreeWalkerGrammar | g | ) | throws IOException [virtual] |
Generate the tree-parser C++ files
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.antlrTool, antlr.CppCodeGenerator.genBody(), antlr.CppCodeGenerator.genInclude(), antlr.CodeGenerator.grammar, antlr.Tool.panic(), and antlr.CodeGenerator.setGrammar().
void antlr.CppCodeGenerator.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.CppCodeGenerator.labeledElementASTInit, antlr.CppCodeGenerator.lt1Value, antlr.CppCodeGenerator.println(), antlr.CppCodeGenerator.saveText, and antlr.CppCodeGenerator.syntacticPredLevel.
void antlr.CppCodeGenerator.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.CppCodeGenerator.currentRule, antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.CppCodeGenerator.DEBUG_CPP_CODE_GENERATOR, antlr.CppCodeGenerator.genLineNo(), antlr.CppCodeGenerator.genLineNo2(), antlr.CppCodeGenerator.genSemPred(), antlr.GrammarElement.getLine(), antlr.CodeGenerator.grammar, antlr.Grammar.hasSyntacticPredicate, antlr.ActionElement.isSemPred, antlr.CppCodeGenerator.labeledElementASTInit, antlr.CppCodeGenerator.labeledElementASTType, antlr.GrammarElement.line, antlr.CppCodeGenerator.printAction(), antlr.CppCodeGenerator.println(), antlr.CppCodeGenerator.processActionForSpecialSymbols(), antlr.ActionTransInfo.refRuleRoot, and antlr.CodeGenerator.tabs.
void antlr.CppCodeGenerator.gen | ( | ZeroOrMoreBlock | blk | ) | [virtual] |
Generate code for the given grammar element.
blk | The (...)* block to generate |
Implements antlr.CodeGenerator.
References antlr.Lookahead.containsEpsilon(), antlr.CppCodeGenerator.currentASTResult, antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.CppCodeGenerator.DEBUG_CPP_CODE_GENERATOR, antlr.LLkGrammarAnalyzer.deterministic(), antlr.BlockWithImpliedExitPath.exitCache, antlr.BlockWithImpliedExitPath.exitLookaheadDepth, antlr.CppCodeGenerator.genBlockInitAction(), antlr.CppCodeGenerator.genBlockPreamble(), antlr.CppCodeGenerator.genCommonBlock(), antlr.AlternativeBlock.getLabel(), antlr.CppCodeGenerator.getLookaheadTestExpression(), antlr.CodeGenerator.grammar, antlr.AlternativeBlock.greedy, antlr.AlternativeBlock.ID, antlr.Grammar.maxk, antlr.CppCodeGenerator.println(), antlr.CodeGenerator.tabs, and antlr.Grammar.theLLkAnalyzer.
void antlr.CppCodeGenerator.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.CppCodeGenerator.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.Alternative.head, antlr.CppCodeGenerator.labeledElementASTType, antlr.AlternativeElement.next, antlr.CppCodeGenerator.println(), antlr.CppCodeGenerator.saveText, antlr.CodeGenerator.tabs, antlr.CppCodeGenerator.treeVariableMap, antlr.CppCodeGenerator.usingCustomAST, and antlr.Tool.warning().
Referenced by antlr.CppCodeGenerator.genCommonBlock(), and antlr.CppCodeGenerator.genRule().
void antlr.CppCodeGenerator.genASTDeclaration | ( | AlternativeElement | el | ) | [protected] |
for convenience
References antlr.CppCodeGenerator.labeledElementASTType.
Referenced by antlr.CppCodeGenerator.genASTDeclaration(), and antlr.CppCodeGenerator.genBlockPreamble().
void antlr.CppCodeGenerator.genASTDeclaration | ( | AlternativeElement | el, | |
String | node_type | |||
) | [protected] |
for convenience
References antlr.CppCodeGenerator.genASTDeclaration(), and antlr.AlternativeElement.getLabel().
void antlr.CppCodeGenerator.genASTDeclaration | ( | AlternativeElement | el, | |
String | var_name, | |||
String | node_type | |||
) | [protected] |
Generate (if not already done) a declaration for the AST for el.
References antlr.CppCodeGenerator.declaredASTVariables, antlr.CppCodeGenerator.labeledElementASTInit, and antlr.CppCodeGenerator.println().
void antlr.CppCodeGenerator.genBitsets | ( | Vector | bitsetList, | |
int | maxVocabulary, | |||
String | prefix | |||
) | [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. | |
prefix | string glued in from of bitset names used for namespace qualifications. |
References antlr.CodeGenerator.charFormatter, antlr.collections.impl.Vector.elementAt(), antlr.CharFormatter.escapeChar(), antlr.CodeGenerator.getBitsetName(), antlr.TokenManager.getTokenStringAt(), antlr.TokenManager.getVocabulary(), antlr.CodeGenerator.grammar, antlr.collections.impl.BitSet.growToInclude(), antlr.collections.impl.BitSet.member(), antlr.CppCodeGenerator.println(), antlr.collections.impl.BitSet.size(), antlr.collections.impl.Vector.size(), antlr.Grammar.tokenManager, and antlr.collections.impl.BitSet.toStringOfHalfWords().
Referenced by antlr.CppCodeGenerator.genBody().
void antlr.CppCodeGenerator.genBitsetsHeader | ( | Vector | bitsetList, | |
int | maxVocabulary | |||
) | [protected] |
void antlr.CppCodeGenerator.genBlockInitAction | ( | AlternativeBlock | blk | ) | [protected] |
Generate the initaction for a block, which may be a RuleBlock or a plain AlternativeBLock. The block for which the preamble is to be generated.
References antlr.CppCodeGenerator.currentRule, antlr.CppCodeGenerator.genLineNo(), antlr.CppCodeGenerator.genLineNo2(), antlr.AlternativeBlock.initAction, antlr.GrammarElement.line, antlr.CppCodeGenerator.printAction(), and antlr.CppCodeGenerator.processActionForSpecialSymbols().
Referenced by antlr.CppCodeGenerator.gen(), and antlr.CppCodeGenerator.genRule().
void antlr.CppCodeGenerator.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.CppCodeGenerator.genASTDeclaration(), antlr.GrammarAtom.getASTNodeType(), antlr.AlternativeElement.getLabel(), antlr.AlternativeBlock.getLabel(), antlr.CodeGenerator.grammar, antlr.CppCodeGenerator.labeledElementInit, antlr.RuleBlock.labeledElements, antlr.CppCodeGenerator.labeledElementType, antlr.CppCodeGenerator.println(), antlr.collections.impl.Vector.size(), and antlr.LLkGrammarAnalyzer.subruleCanBeInverted().
Referenced by antlr.CppCodeGenerator.gen(), and antlr.CppCodeGenerator.genRule().
void antlr.CppCodeGenerator.genBody | ( | LexerGrammar | g | ) | throws IOException |
References antlr.CodeGenerator.antlrTool, antlr.CodeGenerator.bitsetsUsed, antlr.CodeGenerator.currentOutput, antlr.Grammar.debuggingOutput, antlr.collections.impl.Vector.elements(), antlr.NameSpace.emitClosures(), antlr.NameSpace.emitDeclarations(), antlr.CppCodeGenerator.exitIfError(), antlr.CppCodeGenerator.genAST, antlr.CppCodeGenerator.genBitsets(), antlr.CppCodeGenerator.genHeader(), antlr.CppCodeGenerator.genNextToken(), antlr.CppCodeGenerator.genRule(), antlr.CppCodeGenerator.genSemPredMap(), antlr.Grammar.getClassName(), antlr.GrammarSymbol.getId(), antlr.Grammar.getSuperClass(), antlr.TokenManager.getTokenSymbol(), antlr.TokenManager.getTokenSymbolKeys(), antlr.TokenSymbol.getTokenType(), antlr.CodeGenerator.grammar, antlr.CppCodeGenerator.noConstructors, antlr.Tool.openOutputFile(), antlr.CppCodeGenerator.outputFile, antlr.CppCodeGenerator.outputLine, antlr.Grammar.preambleAction, antlr.CppCodeGenerator.printAction(), antlr.CppCodeGenerator.printHeaderAction(), antlr.CppCodeGenerator.println(), antlr.Grammar.rules, antlr.CppCodeGenerator.saveText, antlr.collections.impl.Vector.size(), antlr.Grammar.superClass, antlr.CodeGenerator.tabs, and antlr.Grammar.tokenManager.
Referenced by antlr.CppCodeGenerator.gen().
void antlr.CppCodeGenerator.genBody | ( | ParserGrammar | g | ) | throws IOException |
References antlr.CodeGenerator.antlrTool, antlr.CodeGenerator.bitsetsUsed, antlr.Grammar.buildAST, antlr.CodeGenerator.currentOutput, antlr.Grammar.debuggingOutput, antlr.collections.impl.Vector.elements(), antlr.NameSpace.emitClosures(), antlr.NameSpace.emitDeclarations(), antlr.CppCodeGenerator.exitIfError(), antlr.CppCodeGenerator.genAST, antlr.CppCodeGenerator.genBitsets(), antlr.CppCodeGenerator.genHeader(), antlr.CppCodeGenerator.genInitFactory(), antlr.CppCodeGenerator.genRule(), antlr.CppCodeGenerator.genSemPredMap(), antlr.CppCodeGenerator.genTokenStrings(), antlr.Grammar.getClassName(), antlr.Grammar.getSuperClass(), antlr.CodeGenerator.grammar, antlr.Grammar.maxk, antlr.TokenManager.maxTokenType(), antlr.CppCodeGenerator.noConstructors, antlr.Tool.openOutputFile(), antlr.CppCodeGenerator.outputFile, antlr.CppCodeGenerator.outputLine, antlr.Grammar.preambleAction, antlr.CodeGenerator.print(), antlr.CppCodeGenerator.printAction(), antlr.CppCodeGenerator.printHeaderAction(), antlr.CppCodeGenerator.println(), antlr.RuleSymbol.references, antlr.Grammar.rules, antlr.collections.impl.Vector.size(), antlr.Grammar.superClass, antlr.CodeGenerator.tabs, and antlr.Grammar.tokenManager.
void antlr.CppCodeGenerator.genBody | ( | TreeWalkerGrammar | g | ) | throws IOException |
References antlr.CodeGenerator.antlrTool, antlr.CodeGenerator.bitsetsUsed, antlr.Grammar.buildAST, antlr.CodeGenerator.currentOutput, antlr.collections.impl.Vector.elements(), antlr.NameSpace.emitClosures(), antlr.NameSpace.emitDeclarations(), antlr.CppCodeGenerator.exitIfError(), antlr.CppCodeGenerator.genAST, antlr.CppCodeGenerator.genBitsets(), antlr.CppCodeGenerator.genHeader(), antlr.CppCodeGenerator.genInitFactory(), antlr.CppCodeGenerator.genRule(), antlr.CppCodeGenerator.genTokenStrings(), antlr.Grammar.getClassName(), antlr.Grammar.getSuperClass(), antlr.CodeGenerator.grammar, antlr.TokenManager.maxTokenType(), antlr.CppCodeGenerator.noConstructors, antlr.Tool.openOutputFile(), antlr.CppCodeGenerator.outputFile, antlr.CppCodeGenerator.outputLine, antlr.Grammar.preambleAction, antlr.CppCodeGenerator.printAction(), antlr.CppCodeGenerator.printHeaderAction(), antlr.CppCodeGenerator.println(), antlr.RuleSymbol.references, antlr.Grammar.rules, antlr.collections.impl.Vector.size(), antlr.Grammar.superClass, antlr.CodeGenerator.tabs, and antlr.Grammar.tokenManager.
void antlr.CppCodeGenerator.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.CppCodeGenerator._print(), antlr.CppCodeGenerator._println(), antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.CppCodeGenerator.DEBUG_CPP_CODE_GENERATOR, antlr.CodeGenerator.print(), and antlr.collections.impl.BitSet.toArray().
Referenced by antlr.CppCodeGenerator.genCommonBlock().
CppBlockFinishingInfo antlr.CppCodeGenerator.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.CppCodeGenerator.addSemPred(), antlr.AlternativeBlock.alternatives, antlr.CodeGenerator.analyzer, antlr.CodeGenerator.antlrTool, antlr.Alternative.cache, antlr.CppCodeGenerator.caseSizeThreshold, antlr.CodeGenerator.charFormatter, antlr.Lookahead.containsEpsilon(), antlr.CppCodeGenerator.currentRule, antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.CppCodeGenerator.DEBUG_CPP_CODE_GENERATOR, antlr.Grammar.debuggingOutput, antlr.collections.impl.BitSet.degree(), antlr.CharFormatter.escapeString(), antlr.Lookahead.fset, antlr.CppCodeGenerator.genAlt(), antlr.CppCodeGenerator.genAST, antlr.CppCodeGenerator.genCases(), antlr.CppBlockFinishingInfo.generatedAnIf, antlr.CppBlockFinishingInfo.generatedSwitch, antlr.CppCodeGenerator.genSemPred(), antlr.CppCodeGenerator.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.CppCodeGenerator.getLookaheadTestExpression(), antlr.CodeGenerator.grammar, antlr.Alternative.head, antlr.CppCodeGenerator.labeledElementASTInit, antlr.GrammarElement.line, antlr.LLkGrammarAnalyzer.look(), antlr.Alternative.lookaheadDepth, antlr.CppCodeGenerator.lookaheadIsEmpty(), antlr.CppCodeGenerator.lt1Value, antlr.CodeGenerator.makeSwitchThreshold, antlr.CodeGenerator.markBitsetForGen(), antlr.Grammar.maxk, antlr.CppBlockFinishingInfo.needAnErrorClause, antlr.AlternativeBlock.not, antlr.CppBlockFinishingInfo.postscript, antlr.CppCodeGenerator.println(), antlr.CppCodeGenerator.processActionForSpecialSymbols(), antlr.CppCodeGenerator.saveText, antlr.Alternative.semPred, antlr.collections.impl.Vector.size(), antlr.LLkGrammarAnalyzer.subruleCanBeInverted(), antlr.Alternative.synPred, antlr.CppCodeGenerator.syntacticPredLevel, antlr.CodeGenerator.tabs, antlr.CppCodeGenerator.usingCustomAST, and antlr.Tool.warning().
Referenced by antlr.CppCodeGenerator.gen(), antlr.CppCodeGenerator.genNextToken(), and antlr.CppCodeGenerator.genRule().
void antlr.CppCodeGenerator.genHeader | ( | String | fileName | ) | [protected] |
Generate a header that is common to all C++ files
References antlr.CodeGenerator.antlrTool, antlr.Tool.fileMinusPath(), antlr.Tool.grammarFile, antlr.CppCodeGenerator.println(), and antlr.Tool.version.
Referenced by antlr.CppCodeGenerator.genBody(), antlr.CppCodeGenerator.genInclude(), and antlr.CppCodeGenerator.genTokenTypes().
void antlr.CppCodeGenerator.genInclude | ( | LexerGrammar | g | ) | throws IOException |
References antlr.CppCodeGenerator._println(), antlr.CodeGenerator.antlrTool, antlr.CodeGenerator.bitsetsUsed, antlr.Grammar.classMemberAction, antlr.Grammar.comment, antlr.CodeGenerator.currentOutput, antlr.CppCodeGenerator.currentRule, antlr.Grammar.debuggingOutput, antlr.collections.impl.Vector.elements(), antlr.NameSpace.emitClosures(), antlr.NameSpace.emitDeclarations(), antlr.CppCodeGenerator.exitIfError(), antlr.CppCodeGenerator.genAST, antlr.CppCodeGenerator.genBitsetsHeader(), antlr.CppCodeGenerator.genHeader(), antlr.CppCodeGenerator.genLineNo(), antlr.CppCodeGenerator.genLineNo2(), antlr.CppCodeGenerator.genRuleHeader(), antlr.Grammar.getClassName(), antlr.GrammarSymbol.getId(), antlr.Token.getLine(), antlr.TokenManager.getName(), antlr.Grammar.getSuperClass(), antlr.Token.getText(), antlr.CodeGenerator.grammar, antlr.CppCodeGenerator.noConstructors, antlr.Tool.openOutputFile(), antlr.Grammar.options, antlr.CppCodeGenerator.outputFile, antlr.CppCodeGenerator.outputLine, antlr.CodeGenerator.print(), antlr.CppCodeGenerator.printHeaderAction(), antlr.CppCodeGenerator.println(), antlr.CppCodeGenerator.processActionForSpecialSymbols(), antlr.Grammar.rules, antlr.CppCodeGenerator.saveText, antlr.collections.impl.Vector.size(), antlr.Grammar.superClass, antlr.Grammar.tokenManager, and antlr.CodeGenerator.TokenTypesFileSuffix.
Referenced by antlr.CppCodeGenerator.gen().
void antlr.CppCodeGenerator.genInclude | ( | ParserGrammar | g | ) | throws IOException |
References antlr.CppCodeGenerator._println(), antlr.CodeGenerator.antlrTool, antlr.CodeGenerator.bitsetsUsed, antlr.Grammar.buildAST, antlr.Grammar.classMemberAction, antlr.Grammar.comment, antlr.CodeGenerator.currentOutput, antlr.CppCodeGenerator.currentRule, antlr.Grammar.debuggingOutput, antlr.collections.impl.Vector.elements(), antlr.NameSpace.emitClosures(), antlr.NameSpace.emitDeclarations(), antlr.CppCodeGenerator.exitIfError(), antlr.CppCodeGenerator.genAST, antlr.CppCodeGenerator.genBitsetsHeader(), antlr.CppCodeGenerator.genHeader(), antlr.CppCodeGenerator.genLineNo(), antlr.CppCodeGenerator.genLineNo2(), antlr.CppCodeGenerator.genRuleHeader(), antlr.Grammar.getClassName(), antlr.Token.getLine(), antlr.TokenManager.getName(), antlr.Grammar.getSuperClass(), antlr.Token.getText(), antlr.TokenManager.getVocabulary(), antlr.CodeGenerator.grammar, antlr.CppCodeGenerator.labeledElementASTType, antlr.TokenManager.maxTokenType(), antlr.CppCodeGenerator.noConstructors, antlr.Tool.openOutputFile(), antlr.Grammar.options, antlr.CppCodeGenerator.outputFile, antlr.CppCodeGenerator.outputLine, antlr.CodeGenerator.print(), antlr.CppCodeGenerator.printHeaderAction(), antlr.CppCodeGenerator.println(), antlr.CppCodeGenerator.processActionForSpecialSymbols(), antlr.RuleSymbol.references, antlr.Grammar.rules, antlr.collections.impl.Vector.size(), antlr.Grammar.superClass, antlr.Grammar.tokenManager, antlr.CodeGenerator.TokenTypesFileSuffix, and antlr.CppCodeGenerator.usingCustomAST.
void antlr.CppCodeGenerator.genInclude | ( | TreeWalkerGrammar | g | ) | throws IOException |
References antlr.CppCodeGenerator._println(), antlr.CodeGenerator.antlrTool, antlr.CodeGenerator.bitsetsUsed, antlr.Grammar.buildAST, antlr.Grammar.classMemberAction, antlr.Grammar.comment, antlr.CodeGenerator.currentOutput, antlr.CppCodeGenerator.currentRule, antlr.collections.impl.Vector.elements(), antlr.NameSpace.emitClosures(), antlr.NameSpace.emitDeclarations(), antlr.CppCodeGenerator.exitIfError(), antlr.CppCodeGenerator.genAST, antlr.CppCodeGenerator.genBitsetsHeader(), antlr.CppCodeGenerator.genHeader(), antlr.CppCodeGenerator.genLineNo(), antlr.CppCodeGenerator.genLineNo2(), antlr.CppCodeGenerator.genRuleHeader(), antlr.Grammar.getClassName(), antlr.Token.getLine(), antlr.TokenManager.getName(), antlr.Grammar.getSuperClass(), antlr.Token.getText(), antlr.TokenManager.getVocabulary(), antlr.CodeGenerator.grammar, antlr.CppCodeGenerator.labeledElementASTType, antlr.TokenManager.maxTokenType(), antlr.CppCodeGenerator.noConstructors, antlr.Tool.openOutputFile(), antlr.Grammar.options, antlr.CppCodeGenerator.outputFile, antlr.CppCodeGenerator.outputLine, antlr.CodeGenerator.print(), antlr.CppCodeGenerator.printHeaderAction(), antlr.CppCodeGenerator.println(), antlr.CppCodeGenerator.processActionForSpecialSymbols(), antlr.RuleSymbol.references, antlr.Grammar.rules, antlr.collections.impl.Vector.size(), antlr.Grammar.superClass, antlr.Grammar.tokenManager, antlr.CodeGenerator.TokenTypesFileSuffix, and antlr.CppCodeGenerator.usingCustomAST.
void antlr.CppCodeGenerator.genInitFactory | ( | Grammar | g | ) |
References antlr.CodeGenerator.antlrTool, antlr.Grammar.buildAST, antlr.collections.impl.Vector.elementAt(), antlr.collections.impl.Vector.ensureCapacity(), antlr.TokenSymbol.getASTNodeType(), antlr.Grammar.getClassName(), antlr.Grammar.getFilename(), antlr.TokenManager.getTokenSymbol(), antlr.TokenManager.getTokenSymbolKeys(), antlr.TokenSymbol.getTokenType(), antlr.CodeGenerator.grammar, antlr.TokenManager.maxTokenType(), antlr.CppCodeGenerator.println(), antlr.collections.impl.Vector.setElementAt(), antlr.collections.impl.Vector.size(), antlr.CodeGenerator.tabs, antlr.Grammar.tokenManager, and antlr.Tool.warning().
Referenced by antlr.CppCodeGenerator.genBody().
void antlr.CppCodeGenerator.genLineNo | ( | GrammarElement | el | ) |
Generate a line or // line depending on options
References antlr.CppCodeGenerator.genLineNo(), and antlr.GrammarElement.getLine().
void antlr.CppCodeGenerator.genLineNo | ( | int | line | ) |
Generate a line or // line depending on options
References antlr.CppCodeGenerator._println(), antlr.CodeGenerator.antlrTool, antlr.Tool.fileMinusPath(), antlr.CppCodeGenerator.genHashLines, and antlr.Tool.grammarFile.
Referenced by antlr.CppCodeGenerator.gen(), antlr.CppCodeGenerator.genBlockInitAction(), antlr.CppCodeGenerator.genInclude(), antlr.CppCodeGenerator.genLineNo(), antlr.CppCodeGenerator.genRule(), antlr.CppCodeGenerator.printAction(), and antlr.CppCodeGenerator.printHeaderAction().
void antlr.CppCodeGenerator.genLineNo | ( | Token | t | ) |
Generate a line or // line depending on options
References antlr.CppCodeGenerator.genLineNo(), and antlr.Token.getLine().
void antlr.CppCodeGenerator.genLineNo2 | ( | ) |
Generate a line or // line depending on options
References antlr.CppCodeGenerator._println(), antlr.CppCodeGenerator.genHashLines, antlr.CppCodeGenerator.outputFile, and antlr.CppCodeGenerator.outputLine.
Referenced by antlr.CppCodeGenerator.gen(), antlr.CppCodeGenerator.genBlockInitAction(), antlr.CppCodeGenerator.genInclude(), antlr.CppCodeGenerator.genRule(), antlr.CppCodeGenerator.printAction(), and antlr.CppCodeGenerator.printHeaderAction().
void antlr.CppCodeGenerator.genMatch | ( | BitSet | b | ) | [protected] |
Referenced by antlr.CppCodeGenerator.gen().
void antlr.CppCodeGenerator.genMatch | ( | GrammarAtom | atom | ) | [protected] |
void antlr.CppCodeGenerator.genMatchUsingAtomText | ( | GrammarAtom | atom | ) | [protected] |
References antlr.CppCodeGenerator._print(), antlr.CppCodeGenerator._println(), antlr.GrammarAtom.atomText, antlr.AlternativeElement.getAutoGenType(), antlr.CodeGenerator.grammar, antlr.GrammarAtom.not, antlr.CodeGenerator.print(), antlr.CppCodeGenerator.println(), antlr.CppCodeGenerator.saveText, and antlr.CppCodeGenerator.usingCustomAST.
Referenced by antlr.CppCodeGenerator.genMatch().
void antlr.CppCodeGenerator.genMatchUsingAtomTokenType | ( | GrammarAtom | atom | ) | [protected] |
void antlr.CppCodeGenerator.genNextToken | ( | ) |
Generate the nextToken() rule. nextToken() is a synthetic lexer rule that is the implicit OR of all user-defined lexer rules.
RuleBlock |
References antlr.CppCodeGenerator._println(), 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.CppCodeGenerator.genCommonBlock(), antlr.AlternativeBlock.getAlternativeAt(), antlr.AlternativeBlock.getAlternatives(), antlr.Grammar.getClassName(), antlr.RuleBlock.getDefaultErrorHandler(), antlr.Grammar.getSymbol(), antlr.CodeGenerator.grammar, antlr.Grammar.isDefined(), antlr.RuleSymbol.isDefined(), antlr.CppCodeGenerator.println(), antlr.Grammar.rules, antlr.RuleSymbol.setBlock(), antlr.RuleSymbol.setDefined(), antlr.collections.impl.Vector.size(), antlr.Grammar.theLLkAnalyzer, antlr.CppCodeGenerator.throwNoViable, and antlr.Tool.warning().
Referenced by antlr.CppCodeGenerator.genBody().
void antlr.CppCodeGenerator.genRule | ( | RuleSymbol | s, | |
boolean | startSymbol, | |||
int | ruleNum, | |||
String | prefix | |||
) |
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.CppCodeGenerator._print(), antlr.CppCodeGenerator._println(), antlr.RuleSymbol.access, antlr.AlternativeBlock.alternatives, antlr.CodeGenerator.antlrTool, antlr.RuleBlock.argAction, antlr.Grammar.buildAST, antlr.RuleSymbol.comment, antlr.CppCodeGenerator.commonExtraParams, antlr.CppCodeGenerator.commonLocalVars, antlr.CppCodeGenerator.currentASTResult, antlr.CppCodeGenerator.currentRule, antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.CppCodeGenerator.DEBUG_CPP_CODE_GENERATOR, antlr.Grammar.debuggingOutput, antlr.CppCodeGenerator.declaredASTVariables, antlr.LLkGrammarAnalyzer.deterministic(), antlr.RuleBlock.endNode, antlr.Tool.error(), antlr.CppCodeGenerator.exceptionThrown, antlr.CodeGenerator.extractIdOfAction(), antlr.CodeGenerator.extractTypeOfAction(), antlr.RuleBlock.findExceptionSpec(), antlr.LLkGrammarAnalyzer.FOLLOW(), antlr.Lookahead.fset, antlr.CppCodeGenerator.genAlt(), antlr.CppCodeGenerator.genAST, antlr.CppCodeGenerator.genBlockInitAction(), antlr.CppCodeGenerator.genBlockPreamble(), antlr.CppCodeGenerator.genCommonBlock(), antlr.CppCodeGenerator.genLineNo(), antlr.CppCodeGenerator.genLineNo2(), antlr.CppCodeGenerator.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.CppCodeGenerator.labeledElementASTInit, antlr.CppCodeGenerator.labeledElementASTType, antlr.GrammarElement.line, antlr.CodeGenerator.markBitsetForGen(), antlr.CodeGenerator.print(), antlr.CppCodeGenerator.println(), antlr.RuleBlock.returnAction, antlr.CppCodeGenerator.saveText, antlr.Alternative.semPred, antlr.collections.impl.Vector.size(), antlr.Alternative.synPred, antlr.Grammar.theLLkAnalyzer, antlr.CppCodeGenerator.throwNoViable, antlr.Grammar.traceRules, antlr.CppCodeGenerator.usingCustomAST, and antlr.Tool.warning().
Referenced by antlr.CppCodeGenerator.genBody().
void antlr.CppCodeGenerator.genRuleHeader | ( | RuleSymbol | s, | |
boolean | startSymbol | |||
) |
References antlr.CppCodeGenerator._print(), antlr.CppCodeGenerator._println(), antlr.RuleSymbol.access, antlr.CodeGenerator.antlrTool, antlr.RuleBlock.argAction, antlr.CppCodeGenerator.commonExtraParams, antlr.CppCodeGenerator.currentASTResult, antlr.CppCodeGenerator.currentRule, antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.CppCodeGenerator.DEBUG_CPP_CODE_GENERATOR, antlr.Tool.error(), antlr.CodeGenerator.extractTypeOfAction(), antlr.CppCodeGenerator.genAST, antlr.AlternativeBlock.getAutoGen(), antlr.RuleSymbol.getBlock(), antlr.GrammarElement.getColumn(), antlr.GrammarSymbol.getId(), antlr.GrammarElement.getLine(), antlr.RuleSymbol.isDefined(), antlr.CodeGenerator.print(), antlr.CppCodeGenerator.println(), antlr.RuleBlock.returnAction, and antlr.CppCodeGenerator.saveText.
Referenced by antlr.CppCodeGenerator.genInclude().
void antlr.CppCodeGenerator.genSemPred | ( | String | pred, | |
int | line | |||
) | [protected] |
References antlr.CppCodeGenerator.addSemPred(), antlr.CodeGenerator.charFormatter, antlr.CppCodeGenerator.currentRule, antlr.Grammar.debuggingOutput, antlr.CharFormatter.escapeString(), antlr.CodeGenerator.grammar, antlr.CppCodeGenerator.println(), and antlr.CppCodeGenerator.processActionForSpecialSymbols().
Referenced by antlr.CppCodeGenerator.gen(), antlr.CppCodeGenerator.genCommonBlock(), and antlr.CppCodeGenerator.genRule().
void antlr.CppCodeGenerator.genSemPredMap | ( | String | prefix | ) | [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(), and antlr.CppCodeGenerator.println().
Referenced by antlr.CppCodeGenerator.genBody().
void antlr.CppCodeGenerator.genSynPred | ( | SynPredBlock | blk, | |
String | lookaheadExpr | |||
) | [protected] |
References antlr.CodeGenerator.DEBUG_CODE_GENERATOR, antlr.CppCodeGenerator.DEBUG_CPP_CODE_GENERATOR, antlr.Grammar.debuggingOutput, antlr.CppCodeGenerator.exceptionThrown, antlr.CppCodeGenerator.gen(), antlr.CodeGenerator.grammar, antlr.AlternativeBlock.ID, antlr.CppCodeGenerator.labeledElementASTInit, antlr.CppCodeGenerator.labeledElementType, antlr.CppCodeGenerator.println(), and antlr.CppCodeGenerator.syntacticPredLevel.
Referenced by antlr.CppCodeGenerator.genCommonBlock().
void antlr.CppCodeGenerator.genTokenStrings | ( | String | prefix | ) |
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.CppCodeGenerator._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.CppCodeGenerator.println(), antlr.collections.impl.Vector.size(), and antlr.Grammar.tokenManager.
Referenced by antlr.CppCodeGenerator.genBody().
void antlr.CppCodeGenerator.genTokenTypes | ( | TokenManager | tm | ) | throws IOException [protected] |
Generate the token types C++ file
References antlr.CodeGenerator.antlrTool, antlr.CodeGenerator.currentOutput, antlr.collections.impl.Vector.elementAt(), antlr.NameSpace.emitClosures(), antlr.NameSpace.emitDeclarations(), antlr.CppCodeGenerator.exitIfError(), antlr.CppCodeGenerator.genHeader(), antlr.StringLiteralSymbol.label, antlr.Tool.openOutputFile(), antlr.CppCodeGenerator.outputFile, antlr.CppCodeGenerator.outputLine, antlr.Tool.panic(), antlr.CppCodeGenerator.println(), antlr.collections.impl.Vector.size(), and antlr.CodeGenerator.TokenTypesFileSuffix.
Referenced by antlr.CppCodeGenerator.gen().
String antlr.CppCodeGenerator.getASTCreateString | ( | String | str | ) |
Get a string for an expression to generate creating of an AST node
str | The arguments to the AST constructor |
References antlr.CppCodeGenerator.labeledElementASTType, and antlr.CppCodeGenerator.usingCustomAST.
String antlr.CppCodeGenerator.getASTCreateString | ( | GrammarAtom | atom, | |
String | str | |||
) | [virtual] |
Get a string for an expression to generate creating of an AST node
str | The arguments to the AST constructor |
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.antlrTool, antlr.collections.impl.Vector.elementAt(), antlr.collections.impl.Vector.ensureCapacity(), antlr.GrammarAtom.getASTNodeType(), antlr.GrammarElement.getColumn(), antlr.Grammar.getFilename(), antlr.GrammarElement.getLine(), antlr.GrammarAtom.getText(), antlr.GrammarAtom.getType(), antlr.CodeGenerator.grammar, antlr.collections.impl.Vector.setElementAt(), antlr.TokenManager.tokenDefined(), antlr.Grammar.tokenManager, antlr.CppCodeGenerator.usingCustomAST, and antlr.Tool.warning().
String antlr.CppCodeGenerator.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(), antlr.CppCodeGenerator.labeledElementASTType, and antlr.collections.impl.Vector.size().
String antlr.CppCodeGenerator.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.CppCodeGenerator.getLookaheadTestExpression(), antlr.CodeGenerator.grammar, antlr.Alternative.lookaheadDepth, and antlr.Grammar.maxk.
String antlr.CppCodeGenerator.getLookaheadTestExpression | ( | Lookahead[] | look, | |
int | k | |||
) | [protected] |
String antlr.CppCodeGenerator.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.CppCodeGenerator.getRangeExpression(), antlr.CodeGenerator.markBitsetForGen(), and antlr.collections.impl.BitSet.toArray().
Referenced by antlr.CppCodeGenerator.getLookaheadTestExpression().
String antlr.CppCodeGenerator.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.CppCodeGenerator.getLookaheadTestTerm().
boolean antlr.CppCodeGenerator.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.CppCodeGenerator.genCommonBlock().
String antlr.CppCodeGenerator.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.CppCodeGenerator.currentRule, antlr.collections.impl.Vector.elementAt(), antlr.Tool.error(), antlr.AlternativeElement.getLabel(), antlr.RuleBlock.getRuleName(), antlr.CodeGenerator.grammar, antlr.RuleBlock.labeledElements, antlr.CppCodeGenerator.NONUNIQUE, antlr.ActionTransInfo.refRuleRoot, antlr.collections.impl.Vector.size(), and antlr.CppCodeGenerator.treeVariableMap.
void antlr.CppCodeGenerator.printAction | ( | Token | t | ) |
Print an action stored in a token surrounded by line stuff
References antlr.CppCodeGenerator._printAction(), antlr.CppCodeGenerator.genLineNo(), antlr.CppCodeGenerator.genLineNo2(), antlr.Token.getLine(), antlr.Token.getText(), antlr.CodeGenerator.printTabs(), and antlr.CppCodeGenerator.processActionForSpecialSymbols().
Referenced by antlr.CppCodeGenerator.gen(), antlr.CppCodeGenerator.genBlockInitAction(), and antlr.CppCodeGenerator.genBody().
void antlr.CppCodeGenerator.printHeaderAction | ( | String | name | ) |
Print a header action by line stuff also process any tree construction
name | The name of the header part |
References antlr.CodeGenerator.behavior, antlr.CppCodeGenerator.genLineNo(), antlr.CppCodeGenerator.genLineNo2(), antlr.Token.getLine(), antlr.Token.getText(), antlr.DefineGrammarSymbols.headerActions, antlr.CppCodeGenerator.println(), and antlr.CppCodeGenerator.processActionForSpecialSymbols().
Referenced by antlr.CppCodeGenerator.genBody(), and antlr.CppCodeGenerator.genInclude().
void antlr.CppCodeGenerator.println | ( | String | s | ) | [protected] |
Output tab indent followed by a String followed by newline, to the currentOutput stream. Ignored if string is null.
s | The string to output |
Reimplemented from antlr.CodeGenerator.
References antlr.CppCodeGenerator.countLines(), antlr.CodeGenerator.currentOutput, antlr.CppCodeGenerator.outputLine, and antlr.CodeGenerator.printTabs().
Referenced by antlr.CppCodeGenerator.gen(), antlr.CppCodeGenerator.genAlt(), antlr.CppCodeGenerator.genASTDeclaration(), antlr.CppCodeGenerator.genBitsets(), antlr.CppCodeGenerator.genBitsetsHeader(), antlr.CppCodeGenerator.genBlockPreamble(), antlr.CppCodeGenerator.genBody(), antlr.CppCodeGenerator.genCommonBlock(), antlr.CppCodeGenerator.genHeader(), antlr.CppCodeGenerator.genInclude(), antlr.CppCodeGenerator.genInitFactory(), antlr.CppCodeGenerator.genMatchUsingAtomText(), antlr.CppCodeGenerator.genMatchUsingAtomTokenType(), antlr.CppCodeGenerator.genNextToken(), antlr.CppCodeGenerator.genRule(), antlr.CppCodeGenerator.genRuleHeader(), antlr.CppCodeGenerator.genSemPred(), antlr.CppCodeGenerator.genSemPredMap(), antlr.CppCodeGenerator.genSynPred(), antlr.CppCodeGenerator.genTokenStrings(), antlr.CppCodeGenerator.genTokenTypes(), and antlr.CppCodeGenerator.printHeaderAction().
String antlr.CppCodeGenerator.processActionForSpecialSymbols | ( | String | actionStr, | |
int | line, | |||
RuleBlock | currentRule, | |||
ActionTransInfo | tInfo | |||
) | [protected, virtual] |
Lexically process tree-specifiers in the action. This will replace id and #(...) with the appropriate function calls and/or variables.
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.antlrTool, antlr.Grammar.buildAST, antlr.Grammar.getFilename(), antlr.CodeGenerator.grammar, and antlr.Tool.panic().
Referenced by antlr.CppCodeGenerator.gen(), antlr.CppCodeGenerator.genBlockInitAction(), antlr.CppCodeGenerator.genCommonBlock(), antlr.CppCodeGenerator.genInclude(), antlr.CppCodeGenerator.genSemPred(), antlr.CppCodeGenerator.printAction(), and antlr.CppCodeGenerator.printHeaderAction().
String antlr.CppCodeGenerator.processStringForASTConstructor | ( | String | str | ) |
Process a string for an simple expression for use in xx/action.g it is used to cast simple tokens/references to the right type for the generated language. Basically called for every element in the vector to getASTCreateString(vector V)
str | A String. |
Reimplemented from antlr.CodeGenerator.
References antlr.CodeGenerator.grammar, antlr.TokenManager.tokenDefined(), antlr.Grammar.tokenManager, and antlr.CppCodeGenerator.usingCustomAST.
int antlr.CppCodeGenerator.astVarNumber = 1 [package] |
final int antlr.CppCodeGenerator.caseSizeThreshold = 127 [static] |
Referenced by antlr.CppCodeGenerator.genCommonBlock().
String antlr.CppCodeGenerator.commonExtraArgs [package] |
String antlr.CppCodeGenerator.commonExtraParams [package] |
Referenced by antlr.CppCodeGenerator.genRule(), and antlr.CppCodeGenerator.genRuleHeader().
String antlr.CppCodeGenerator.commonLocalVars [package] |
Referenced by antlr.CppCodeGenerator.genRule().
String antlr.CppCodeGenerator.currentASTResult [package] |
RuleBlock antlr.CppCodeGenerator.currentRule [package] |
Referenced by antlr.CppCodeGenerator.gen(), antlr.CppCodeGenerator.genBlockInitAction(), antlr.CppCodeGenerator.genCommonBlock(), antlr.CppCodeGenerator.genInclude(), antlr.CppCodeGenerator.genRule(), antlr.CppCodeGenerator.genRuleHeader(), antlr.CppCodeGenerator.genSemPred(), and antlr.CppCodeGenerator.mapTreeId().
boolean antlr.CppCodeGenerator.DEBUG_CPP_CODE_GENERATOR = false [package] |
Hashtable antlr.CppCodeGenerator.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.CppCodeGenerator.genASTDeclaration(), and antlr.CppCodeGenerator.genRule().
String antlr.CppCodeGenerator.exceptionThrown [package] |
Referenced by antlr.CppCodeGenerator.genRule(), and antlr.CppCodeGenerator.genSynPred().
boolean antlr.CppCodeGenerator.genAST = false [protected] |
boolean antlr.CppCodeGenerator.genHashLines = true [protected] |
Referenced by antlr.CppCodeGenerator.genLineNo(), and antlr.CppCodeGenerator.genLineNo2().
String antlr.CppCodeGenerator.labeledElementASTInit [package] |
String antlr.CppCodeGenerator.labeledElementASTType [package] |
String antlr.CppCodeGenerator.labeledElementInit [package] |
Referenced by antlr.CppCodeGenerator.genBlockPreamble().
String antlr.CppCodeGenerator.labeledElementType [package] |
String antlr.CppCodeGenerator.lt1Value [package] |
Referenced by antlr.CppCodeGenerator.gen(), and antlr.CppCodeGenerator.genCommonBlock().
boolean antlr.CppCodeGenerator.noConstructors = false [protected] |
Referenced by antlr.CppCodeGenerator.genBody(), and antlr.CppCodeGenerator.genInclude().
final String antlr.CppCodeGenerator.NONUNIQUE = new String() [static, protected] |
Referenced by antlr.CppCodeGenerator.mapTreeId().
String antlr.CppCodeGenerator.outputFile [protected] |
int antlr.CppCodeGenerator.outputLine [protected] |
Referenced by antlr.CppCodeGenerator._print(), antlr.CppCodeGenerator._printAction(), antlr.CppCodeGenerator._println(), antlr.CppCodeGenerator.genBody(), antlr.CppCodeGenerator.genInclude(), antlr.CppCodeGenerator.genLineNo2(), antlr.CppCodeGenerator.genTokenTypes(), and antlr.CppCodeGenerator.println().
boolean antlr.CppCodeGenerator.saveText = false [protected] |
Referenced by antlr.CppCodeGenerator.gen(), antlr.CppCodeGenerator.genAlt(), antlr.CppCodeGenerator.genBody(), antlr.CppCodeGenerator.genCommonBlock(), antlr.CppCodeGenerator.genInclude(), antlr.CppCodeGenerator.genMatchUsingAtomText(), antlr.CppCodeGenerator.genRule(), and antlr.CppCodeGenerator.genRuleHeader().
int antlr.CppCodeGenerator.syntacticPredLevel = 0 [protected] |
String antlr.CppCodeGenerator.throwNoViable [package] |
Hashtable antlr.CppCodeGenerator.treeVariableMap = new Hashtable() [package] |
Referenced by antlr.CppCodeGenerator.genAlt(), and antlr.CppCodeGenerator.mapTreeId().
boolean antlr.CppCodeGenerator.usingCustomAST = false [package] |
Referenced by antlr.CppCodeGenerator.gen(), antlr.CppCodeGenerator.genAlt(), antlr.CppCodeGenerator.genCommonBlock(), antlr.CppCodeGenerator.genInclude(), antlr.CppCodeGenerator.genMatchUsingAtomText(), antlr.CppCodeGenerator.genMatchUsingAtomTokenType(), antlr.CppCodeGenerator.genRule(), antlr.CppCodeGenerator.getASTCreateString(), and antlr.CppCodeGenerator.processStringForASTConstructor().