Generate MyParser.txt, MyLexer.txt and MyParserTokenTypes.txt
antlr.DiagnosticCodeGenerator.DiagnosticCodeGenerator | ( | ) |
Create a Diagnostic code-generator using the given Grammar The caller must still call setTool, setBehavior, and setAnalyzer before generating code.
References antlr.CodeGenerator.charFormatter.
void antlr.DiagnosticCodeGenerator.gen | ( | ) | [virtual] |
Generate the parser, lexer, and token types documentation
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.analyzer, antlr.CodeGenerator.antlrTool, antlr.CodeGenerator.behavior, antlr.Grammar.generate(), antlr.DiagnosticCodeGenerator.genTokenTypes(), antlr.DefineGrammarSymbols.grammars, antlr.Tool.hasError, antlr.TokenManager.isReadOnly(), antlr.Tool.panic(), antlr.Tool.reportException(), antlr.Grammar.setCodeGenerator(), antlr.LLkGrammarAnalyzer.setGrammar(), antlr.Grammar.setGrammarAnalyzer(), and antlr.DefineGrammarSymbols.tokenManagers.
Referenced by antlr.DiagnosticCodeGenerator.genSynPred().
void antlr.DiagnosticCodeGenerator.gen | ( | ActionElement | action | ) | [virtual] |
Generate code for the given grammar element.
blk | The {...} action to generate |
Implements antlr.CodeGenerator.
References antlr.CodeGenerator._printAction(), antlr.ActionElement.actionText, antlr.ActionElement.isSemPred, and antlr.CodeGenerator.print().
void antlr.DiagnosticCodeGenerator.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.
void antlr.DiagnosticCodeGenerator.gen | ( | OneOrMoreBlock | blk | ) | [virtual] |
Generate code for the given grammar element.
blk | The (...)+ block to generate |
Implements antlr.CodeGenerator.
References antlr.LLkGrammarAnalyzer.deterministic(), antlr.DiagnosticCodeGenerator.genBlockPreamble(), antlr.DiagnosticCodeGenerator.genCommonBlock(), antlr.CodeGenerator.grammar, antlr.CodeGenerator.println(), antlr.CodeGenerator.tabs, and antlr.Grammar.theLLkAnalyzer.
void antlr.DiagnosticCodeGenerator.gen | ( | WildcardElement | wc | ) | [virtual] |
Generate a wildcard element
Implements antlr.CodeGenerator.
References antlr.CodeGenerator._print(), antlr.CodeGenerator._println(), antlr.WildcardElement.getLabel(), and antlr.CodeGenerator.print().
void antlr.DiagnosticCodeGenerator.gen | ( | ZeroOrMoreBlock | blk | ) | [virtual] |
Generate code for the given grammar element.
blk | The (...)* block to generate |
Implements antlr.CodeGenerator.
References antlr.LLkGrammarAnalyzer.deterministic(), antlr.DiagnosticCodeGenerator.genBlockPreamble(), antlr.DiagnosticCodeGenerator.genCommonBlock(), antlr.CodeGenerator.grammar, antlr.CodeGenerator.println(), antlr.CodeGenerator.tabs, and antlr.Grammar.theLLkAnalyzer.
void antlr.DiagnosticCodeGenerator.gen | ( | ParserGrammar | g | ) | throws IOException [virtual] |
Generate the parser TXT file
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.antlrTool, antlr.Grammar.classMemberAction, antlr.CodeGenerator.currentOutput, antlr.collections.impl.Vector.elements(), antlr.DiagnosticCodeGenerator.genHeader(), antlr.DiagnosticCodeGenerator.genRule(), antlr.Grammar.getClassName(), antlr.Grammar.getSuperClass(), antlr.Token.getText(), antlr.CodeGenerator.grammar, antlr.Tool.openOutputFile(), antlr.Grammar.preambleAction, antlr.CodeGenerator.printAction(), antlr.CodeGenerator.println(), antlr.Tool.reportProgress(), antlr.Grammar.rules, antlr.CodeGenerator.setGrammar(), antlr.CodeGenerator.tabs, and antlr.CodeGenerator.TokenTypesFileExt.
void antlr.DiagnosticCodeGenerator.gen | ( | CharLiteralElement | atom | ) | [virtual] |
Generate code for the given grammar element.
blk | The character literal reference to generate |
Implements antlr.CodeGenerator.
References antlr.CodeGenerator._print(), antlr.CodeGenerator._println(), antlr.GrammarAtom.atomText, antlr.GrammarAtom.label, antlr.GrammarAtom.not, and antlr.CodeGenerator.print().
void antlr.DiagnosticCodeGenerator.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._println(), antlr.RuleBlock.argAction, antlr.RuleRefElement.args, antlr.RuleSymbol.block, antlr.Grammar.getSymbol(), antlr.CodeGenerator.grammar, antlr.RuleRefElement.idAssign, antlr.RuleSymbol.isDefined(), antlr.CodeGenerator.print(), antlr.CodeGenerator.println(), antlr.RuleBlock.returnAction, antlr.DiagnosticCodeGenerator.syntacticPredLevel, and antlr.RuleRefElement.targetRule.
void antlr.DiagnosticCodeGenerator.gen | ( | StringLiteralElement | atom | ) | [virtual] |
Generate code for the given grammar element.
blk | The string-literal reference to generate |
Implements antlr.CodeGenerator.
References antlr.CodeGenerator._print(), antlr.CodeGenerator._println(), antlr.GrammarAtom.atomText, antlr.GrammarAtom.label, and antlr.CodeGenerator.print().
void antlr.DiagnosticCodeGenerator.gen | ( | AlternativeBlock | blk | ) | [virtual] |
Generate code for the given grammar element.
blk | The "x|y|z|..." block to generate |
Implements antlr.CodeGenerator.
References antlr.LLkGrammarAnalyzer.deterministic(), antlr.DiagnosticCodeGenerator.genBlockPreamble(), antlr.DiagnosticCodeGenerator.genCommonBlock(), antlr.CodeGenerator.grammar, antlr.CodeGenerator.println(), antlr.CodeGenerator.tabs, and antlr.Grammar.theLLkAnalyzer.
void antlr.DiagnosticCodeGenerator.gen | ( | CharRangeElement | r | ) | [virtual] |
Generate code for the given grammar element.
blk | The character-range reference to generate |
Implements antlr.CodeGenerator.
References antlr.CodeGenerator._print(), antlr.CodeGenerator._println(), antlr.CharRangeElement.beginText, antlr.CharRangeElement.endText, antlr.CharRangeElement.label, and antlr.CodeGenerator.print().
void antlr.DiagnosticCodeGenerator.gen | ( | TokenRangeElement | r | ) | [virtual] |
Generate code for the given grammar element.
blk | The token-range reference to generate |
Implements antlr.CodeGenerator.
References antlr.CodeGenerator._print(), antlr.CodeGenerator._println(), antlr.TokenRangeElement.beginText, antlr.TokenRangeElement.endText, antlr.TokenRangeElement.label, and antlr.CodeGenerator.print().
void antlr.DiagnosticCodeGenerator.gen | ( | TokenRefElement | atom | ) | [virtual] |
Generate code for the given grammar element.
blk | The token-reference to generate |
Implements antlr.CodeGenerator.
References antlr.CodeGenerator._print(), antlr.CodeGenerator._println(), antlr.GrammarAtom.atomText, antlr.GrammarAtom.label, antlr.GrammarAtom.not, and antlr.CodeGenerator.print().
void antlr.DiagnosticCodeGenerator.gen | ( | LexerGrammar | g | ) | throws IOException [virtual] |
Generate the lexer TXT file
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.antlrTool, antlr.Grammar.classMemberAction, antlr.CodeGenerator.currentOutput, antlr.DiagnosticCodeGenerator.doingLexRules, antlr.collections.impl.Vector.elements(), antlr.DiagnosticCodeGenerator.genHeader(), antlr.DiagnosticCodeGenerator.genNextToken(), antlr.DiagnosticCodeGenerator.genRule(), antlr.Grammar.getClassName(), antlr.GrammarSymbol.getId(), antlr.Grammar.getSuperClass(), antlr.Grammar.getSymbols(), antlr.Token.getText(), antlr.TokenSymbol.getTokenType(), antlr.CodeGenerator.grammar, antlr.GrammarSymbol.id, antlr.Tool.openOutputFile(), antlr.Grammar.preambleAction, antlr.CodeGenerator.printAction(), antlr.CodeGenerator.println(), antlr.Tool.reportProgress(), antlr.Grammar.rules, antlr.CodeGenerator.setGrammar(), antlr.CodeGenerator.tabs, and antlr.CodeGenerator.TokenTypesFileExt.
void antlr.DiagnosticCodeGenerator.gen | ( | TreeElement | t | ) | [virtual] |
Generate code for the given grammar element.
blk | The tree to generate code for. |
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.print().
void antlr.DiagnosticCodeGenerator.gen | ( | TreeWalkerGrammar | g | ) | throws IOException [virtual] |
Generate the tree-walker TXT file
Implements antlr.CodeGenerator.
References antlr.CodeGenerator.antlrTool, antlr.Grammar.classMemberAction, antlr.CodeGenerator.currentOutput, antlr.collections.impl.Vector.elements(), antlr.DiagnosticCodeGenerator.genHeader(), antlr.DiagnosticCodeGenerator.genRule(), antlr.Grammar.getClassName(), antlr.Grammar.getSuperClass(), antlr.Token.getText(), antlr.CodeGenerator.grammar, antlr.Tool.openOutputFile(), antlr.Grammar.preambleAction, antlr.CodeGenerator.printAction(), antlr.CodeGenerator.println(), antlr.Tool.reportProgress(), antlr.Grammar.rules, antlr.CodeGenerator.setGrammar(), antlr.CodeGenerator.tabs, and antlr.CodeGenerator.TokenTypesFileExt.
void antlr.DiagnosticCodeGenerator.genAlt | ( | Alternative | alt | ) | [protected] |
void antlr.DiagnosticCodeGenerator.genBlockPreamble | ( | AlternativeBlock | blk | ) | [protected] |
Generate the header for a block, which may be a RuleBlock or a plain AlternativeBLock. This generates any variable declarations, init-actions, and syntactic-predicate-testing variables. The block for which the preamble is to be generated.
References antlr.AlternativeBlock.initAction, and antlr.CodeGenerator.printAction().
Referenced by antlr.DiagnosticCodeGenerator.gen(), and antlr.DiagnosticCodeGenerator.genRule().
void antlr.DiagnosticCodeGenerator.genCommonBlock | ( | AlternativeBlock | blk | ) |
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.
References antlr.CodeGenerator._println(), antlr.AlternativeBlock.alternatives, antlr.DiagnosticCodeGenerator.genAlt(), antlr.DiagnosticCodeGenerator.genLookaheadSetForAlt(), antlr.DiagnosticCodeGenerator.genLookaheadSetForBlock(), antlr.DiagnosticCodeGenerator.genSynPred(), antlr.AlternativeBlock.getAlternativeAt(), antlr.Alternative.head, antlr.CodeGenerator.print(), antlr.CodeGenerator.println(), antlr.Alternative.semPred, antlr.collections.impl.Vector.size(), antlr.Alternative.synPred, and antlr.CodeGenerator.tabs.
Referenced by antlr.DiagnosticCodeGenerator.gen(), antlr.DiagnosticCodeGenerator.genNextToken(), and antlr.DiagnosticCodeGenerator.genRule().
void antlr.DiagnosticCodeGenerator.genFollowSetForRuleBlock | ( | RuleBlock | blk | ) |
Generate a textual representation of the follow set for a block.
blk | The rule block of interest |
References antlr.RuleBlock.endNode, antlr.LLkGrammarAnalyzer.FOLLOW(), antlr.CodeGenerator.grammar, antlr.Grammar.maxk, antlr.DiagnosticCodeGenerator.printSet(), and antlr.Grammar.theLLkAnalyzer.
Referenced by antlr.DiagnosticCodeGenerator.genRule().
void antlr.DiagnosticCodeGenerator.genHeader | ( | ) | [protected] |
Generate a header that is common to all TXT files
References antlr.CodeGenerator.antlrTool, antlr.CodeGenerator.behavior, antlr.DefineGrammarSymbols.getHeaderAction(), antlr.Tool.grammarFile, antlr.CodeGenerator.printAction(), antlr.CodeGenerator.println(), antlr.CodeGenerator.tabs, and antlr.Tool.version.
Referenced by antlr.DiagnosticCodeGenerator.gen(), and antlr.DiagnosticCodeGenerator.genTokenTypes().
void antlr.DiagnosticCodeGenerator.genLookaheadSetForAlt | ( | Alternative | alt | ) | [protected] |
Generate the lookahead set for an alternate.
References antlr.Alternative.cache, antlr.Lookahead.containsEpsilon(), antlr.DiagnosticCodeGenerator.doingLexRules, antlr.CodeGenerator.grammar, antlr.Alternative.lookaheadDepth, antlr.Grammar.maxk, antlr.CodeGenerator.println(), and antlr.DiagnosticCodeGenerator.printSet().
Referenced by antlr.DiagnosticCodeGenerator.genCommonBlock().
void antlr.DiagnosticCodeGenerator.genLookaheadSetForBlock | ( | AlternativeBlock | blk | ) |
Generate a textual representation of the lookahead set for a block.
blk | The block of interest |
References antlr.AlternativeBlock.alternatives, antlr.AlternativeBlock.getAlternativeAt(), antlr.CodeGenerator.grammar, antlr.LLkGrammarAnalyzer.look(), antlr.Alternative.lookaheadDepth, antlr.Grammar.maxk, antlr.DiagnosticCodeGenerator.printSet(), antlr.collections.impl.Vector.size(), and antlr.Grammar.theLLkAnalyzer.
Referenced by antlr.DiagnosticCodeGenerator.genCommonBlock().
void antlr.DiagnosticCodeGenerator.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.Grammar.define(), antlr.LLkGrammarAnalyzer.deterministic(), antlr.DiagnosticCodeGenerator.genCommonBlock(), antlr.CodeGenerator.grammar, antlr.CodeGenerator.println(), antlr.Grammar.rules, antlr.RuleSymbol.setBlock(), antlr.RuleSymbol.setDefined(), and antlr.Grammar.theLLkAnalyzer.
Referenced by antlr.DiagnosticCodeGenerator.gen().
void antlr.DiagnosticCodeGenerator.genRule | ( | RuleSymbol | s | ) |
Generate code for a named rule block
s | The RuleSymbol describing the rule to generate |
References antlr.RuleSymbol.access, antlr.ExceptionHandler.action, antlr.RuleBlock.argAction, antlr.LLkGrammarAnalyzer.deterministic(), antlr.DiagnosticCodeGenerator.doingLexRules, antlr.collections.impl.Vector.elementAt(), antlr.ExceptionHandler.exceptionTypeAndName, antlr.RuleBlock.findExceptionSpec(), antlr.DiagnosticCodeGenerator.genBlockPreamble(), antlr.DiagnosticCodeGenerator.genCommonBlock(), antlr.DiagnosticCodeGenerator.genFollowSetForRuleBlock(), antlr.RuleSymbol.getBlock(), antlr.GrammarSymbol.getId(), antlr.Token.getText(), antlr.CodeGenerator.grammar, antlr.ExceptionSpec.handlers, antlr.RuleSymbol.isDefined(), antlr.CodeGenerator.printAction(), antlr.CodeGenerator.println(), antlr.RuleBlock.returnAction, antlr.collections.impl.Vector.size(), antlr.CodeGenerator.tabs, and antlr.Grammar.theLLkAnalyzer.
Referenced by antlr.DiagnosticCodeGenerator.gen().
void antlr.DiagnosticCodeGenerator.genSynPred | ( | SynPredBlock | blk | ) | [protected] |
Generate the syntactic predicate. This basically generates the alternative block, buts tracks if we are inside a synPred
blk | The syntactic predicate block |
References antlr.DiagnosticCodeGenerator.gen(), and antlr.DiagnosticCodeGenerator.syntacticPredLevel.
Referenced by antlr.DiagnosticCodeGenerator.genCommonBlock().
void antlr.DiagnosticCodeGenerator.genTokenTypes | ( | TokenManager | tm | ) | throws IOException [protected] |
Generate the token types TXT file
References antlr.CodeGenerator.antlrTool, antlr.CodeGenerator.currentOutput, antlr.collections.impl.Vector.elementAt(), antlr.DiagnosticCodeGenerator.genHeader(), antlr.Tool.openOutputFile(), antlr.CodeGenerator.println(), antlr.Tool.reportProgress(), antlr.collections.impl.Vector.size(), antlr.CodeGenerator.tabs, antlr.CodeGenerator.TokenTypesFileExt, and antlr.CodeGenerator.TokenTypesFileSuffix.
Referenced by antlr.DiagnosticCodeGenerator.gen().
String antlr.DiagnosticCodeGenerator.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.
String antlr.DiagnosticCodeGenerator.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.
String antlr.DiagnosticCodeGenerator.mapTreeId | ( | String | id, | |
ActionTransInfo | tInfo | |||
) | [virtual] |
Map an identifier to it's corresponding tree-node variable. This is context-sensitive, depending on the rule and alternative being generated
id | The identifier name to map | |
forInput | true if the input tree node variable is to be returned, otherwise the output variable is returned. |
Implements antlr.CodeGenerator.
void antlr.DiagnosticCodeGenerator.printSet | ( | int | depth, | |
int | k, | |||
Lookahead | lookahead | |||
) |
Format a lookahead or follow set.
depth | The depth of the entire lookahead/follow | |
k | The lookahead level to print | |
lookahead | The lookahead/follow set to print |
References antlr.CodeGenerator._print(), antlr.CodeGenerator._println(), antlr.CodeGenerator.charFormatter, antlr.DiagnosticCodeGenerator.doingLexRules, antlr.collections.impl.Vector.elementAt(), antlr.Lookahead.fset, antlr.TokenManager.getVocabulary(), antlr.CodeGenerator.grammar, antlr.CharFormatter.literalChar(), antlr.CodeGenerator.print(), antlr.CodeGenerator.tabs, antlr.collections.impl.BitSet.toArray(), and antlr.Grammar.tokenManager.
Referenced by antlr.DiagnosticCodeGenerator.genFollowSetForRuleBlock(), antlr.DiagnosticCodeGenerator.genLookaheadSetForAlt(), and antlr.DiagnosticCodeGenerator.genLookaheadSetForBlock().
String antlr.DiagnosticCodeGenerator.processActionForSpecialSymbols | ( | String | actionStr, | |
int | line, | |||
RuleBlock | currentRule, | |||
ActionTransInfo | tInfo | |||
) | [protected, virtual] |
unused.
Implements antlr.CodeGenerator.
boolean antlr.DiagnosticCodeGenerator.doingLexRules = false [protected] |
true during lexer generation, false during parser generation
Referenced by antlr.DiagnosticCodeGenerator.gen(), antlr.DiagnosticCodeGenerator.genLookaheadSetForAlt(), antlr.DiagnosticCodeGenerator.genRule(), and antlr.DiagnosticCodeGenerator.printSet().
int antlr.DiagnosticCodeGenerator.syntacticPredLevel = 0 [protected] |
non-zero if inside syntactic predicate generation
Referenced by antlr.DiagnosticCodeGenerator.gen(), and antlr.DiagnosticCodeGenerator.genSynPred().