Package org.antlr.v4.codegen
Class OutputModelController
- java.lang.Object
-
- org.antlr.v4.codegen.OutputModelController
-
public class OutputModelController extends Object
This receives events from SourceGenTriggers.g and asks factory to do work. Then runs extensions in order on resulting SrcOps to get final list.
-
-
Field Summary
Fields Modifier and Type Field Description int
codeBlockLevel
Context set by the SourceGenTriggers.gCodeBlock
currentBlock
Alternative
currentOuterMostAlt
CodeBlockForOuterMostAlt
currentOuterMostAlternativeBlock
Stack<RuleFunction>
currentRule
OutputModelFactory
delegate
Who does the work? Doesn't have to be CoreOutputModelFactory.List<CodeGeneratorExtension>
extensions
Post-processing CodeGeneratorExtension objects; done in order given.OutputModelObject
root
int
treeLevel
SourceGenTriggers
walker
While walking code in rules, this is set to the tree walker that triggers actions.
-
Constructor Summary
Constructors Constructor Description OutputModelController(OutputModelFactory factory)
-
Method Summary
-
-
-
Field Detail
-
delegate
public OutputModelFactory delegate
Who does the work? Doesn't have to be CoreOutputModelFactory.
-
extensions
public List<CodeGeneratorExtension> extensions
Post-processing CodeGeneratorExtension objects; done in order given.
-
walker
public SourceGenTriggers walker
While walking code in rules, this is set to the tree walker that triggers actions.
-
codeBlockLevel
public int codeBlockLevel
Context set by the SourceGenTriggers.g
-
treeLevel
public int treeLevel
-
root
public OutputModelObject root
-
currentRule
public Stack<RuleFunction> currentRule
-
currentOuterMostAlt
public Alternative currentOuterMostAlt
-
currentBlock
public CodeBlock currentBlock
-
currentOuterMostAlternativeBlock
public CodeBlockForOuterMostAlt currentOuterMostAlternativeBlock
-
-
Constructor Detail
-
OutputModelController
public OutputModelController(OutputModelFactory factory)
-
-
Method Detail
-
addExtension
public void addExtension(CodeGeneratorExtension ext)
-
buildParserOutputModel
public OutputModelObject buildParserOutputModel(boolean header)
Build a file with a parser containing rule functions. Use the controller as factory in SourceGenTriggers so it triggers codegen extensions too, not just the factory functions in this factory.
-
buildLexerOutputModel
public OutputModelObject buildLexerOutputModel(boolean header)
-
buildListenerOutputModel
public OutputModelObject buildListenerOutputModel(boolean header)
-
buildBaseListenerOutputModel
public OutputModelObject buildBaseListenerOutputModel(boolean header)
-
buildVisitorOutputModel
public OutputModelObject buildVisitorOutputModel(boolean header)
-
buildBaseVisitorOutputModel
public OutputModelObject buildBaseVisitorOutputModel(boolean header)
-
parserFile
public ParserFile parserFile(String fileName)
-
parser
public Parser parser(ParserFile file)
-
buildRuleFunction
public void buildRuleFunction(Parser parser, Rule r)
Create RuleFunction per rule and update sempreds,actions of parser output object with stuff found in r.
-
buildLeftRecursiveRuleFunction
public void buildLeftRecursiveRuleFunction(LeftRecursiveRule r, LeftRecursiveRuleFunction function)
-
buildNormalRuleFunction
public void buildNormalRuleFunction(Rule r, RuleFunction function)
-
rule
public RuleFunction rule(Rule r)
-
rulePostamble
public List<SrcOp> rulePostamble(RuleFunction function, Rule r)
-
getGrammar
public Grammar getGrammar()
-
getGenerator
public CodeGenerator getGenerator()
-
alternative
public CodeBlockForAlt alternative(Alternative alt, boolean outerMost)
-
finishAlternative
public CodeBlockForAlt finishAlternative(CodeBlockForAlt blk, List<SrcOp> ops, boolean outerMost)
-
ruleRef
public List<SrcOp> ruleRef(GrammarAST ID, GrammarAST label, GrammarAST args)
-
tokenRef
public List<SrcOp> tokenRef(GrammarAST ID, GrammarAST label, GrammarAST args)
-
stringRef
public List<SrcOp> stringRef(GrammarAST ID, GrammarAST label)
-
set
public List<SrcOp> set(GrammarAST setAST, GrammarAST labelAST, boolean invert)
(A|B|C) possibly with ebnfRoot and label
-
epsilon
public CodeBlockForAlt epsilon(Alternative alt, boolean outerMost)
-
wildcard
public List<SrcOp> wildcard(GrammarAST ast, GrammarAST labelAST)
-
getChoiceBlock
public Choice getChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts, GrammarAST label)
-
getEBNFBlock
public Choice getEBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts)
-
needsImplicitLabel
public boolean needsImplicitLabel(GrammarAST ID, LabeledOp op)
-
getRoot
public OutputModelObject getRoot()
-
setRoot
public void setRoot(OutputModelObject root)
-
getCurrentRuleFunction
public RuleFunction getCurrentRuleFunction()
-
pushCurrentRule
public void pushCurrentRule(RuleFunction r)
-
popCurrentRule
public RuleFunction popCurrentRule()
-
getCurrentOuterMostAlt
public Alternative getCurrentOuterMostAlt()
-
setCurrentOuterMostAlt
public void setCurrentOuterMostAlt(Alternative currentOuterMostAlt)
-
setCurrentBlock
public void setCurrentBlock(CodeBlock blk)
-
getCurrentBlock
public CodeBlock getCurrentBlock()
-
setCurrentOuterMostAlternativeBlock
public void setCurrentOuterMostAlternativeBlock(CodeBlockForOuterMostAlt currentOuterMostAlternativeBlock)
-
getCurrentOuterMostAlternativeBlock
public CodeBlockForOuterMostAlt getCurrentOuterMostAlternativeBlock()
-
getCodeBlockLevel
public int getCodeBlockLevel()
-
-