Top Description Fields Constructors Methods
org.antlr.v4.codegen

public Class OutputModelController

extends Object
Class Inheritance
Imports
org.antlr.runtime.tree.CommonTreeNodeStream, org.antlr.v4.analysis.LeftRecursiveRuleAltInfo, org.antlr.v4.codegen.model.Action, .AltBlock, .BaseListenerFile, .BaseVisitorFile, .Choice, .CodeBlockForAlt, .CodeBlockForOuterMostAlt, .LabeledOp, .LeftRecursiveRuleFunction, .Lexer, .LexerFile, .ListenerFile, .OutputModelObject, .Parser, .ParserFile, .RuleActionFunction, .RuleFunction, .RuleSempredFunction, .SrcOp, .StarBlock, .VisitorFile, org.antlr.v4.codegen.model.decl.CodeBlock, org.antlr.v4.misc.Utils, org.antlr.v4.parse.ANTLRParser, .GrammarASTAdaptor, org.antlr.v4.tool.Alternative, .ErrorType, .Grammar, .LeftRecursiveRule, .Rule, org.antlr.v4.tool.ast.ActionAST, .BlockAST, .GrammarAST, .PredAST, org.stringtemplate.v4.ST, .STGroup, java.util.ArrayList, .List, .Stack

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

Modifier and TypeField and Description
public int
codeBlockLevel

Context set by the SourceGenTriggers.g

public CodeBlock
public Alternative
public CodeBlockForOuterMostAlt
public Stack<RuleFunction>
public OutputModelFactory
delegate

Who does the work?

public List<CodeGeneratorExtension>
extensions

Post-processing CodeGeneratorExtension objects; done in order given.

public OutputModelObject
public int
public SourceGenTriggers
walker

While walking code in rules, this is set to the tree walker that triggers actions.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public List<SrcOp>
public void
public CodeBlockForAlt
alternative(Alternative alt, boolean outerMost)

public OutputModelObject
public OutputModelObject
public void
public OutputModelObject
buildLexerOutputModel(boolean header)

public void
public OutputModelObject
buildListenerOutputModel(boolean header)

public void
public OutputModelObject
buildParserOutputModel(boolean header)

Build a file with a parser containing rule functions.

public void
buildRuleFunction(Parser parser, Rule r)

Create RuleFunction per rule and update sempreds,actions of parser output object with stuff found in r.

public OutputModelObject
buildVisitorOutputModel(boolean header)

public CodeBlockForAlt
epsilon(Alternative alt, boolean outerMost)

public CodeBlockForAlt
finishAlternative(CodeBlockForAlt blk, List<SrcOp> ops, boolean outerMost)

public Choice
public int
public CodeBlock
public Alternative
public CodeBlockForOuterMostAlt
public RuleFunction
public Choice
public CodeGenerator
public Grammar
public OutputModelObject
public Lexer
public LexerFile
lexerFile(String fileName)

public boolean
public Parser
public ParserFile
parserFile(String fileName)

public RuleFunction
public void
public RuleFunction
public List<SrcOp>
public List<SrcOp>
public List<SrcOp>
public List<SrcOp>
set(GrammarAST setAST, GrammarAST labelAST, boolean invert)

(A|B|C) possibly with ebnfRoot and label

public void
public void
setCurrentOuterMostAlt(Alternative currentOuterMostAlt)

public void
public void
public List<SrcOp>
public List<SrcOp>
public List<SrcOp>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

codeBlockLevelback to summary
public int codeBlockLevel

Context set by the SourceGenTriggers.g

currentBlockback to summary
public CodeBlock currentBlock
currentOuterMostAltback to summary
public Alternative currentOuterMostAlt
currentOuterMostAlternativeBlockback to summary
public CodeBlockForOuterMostAlt currentOuterMostAlternativeBlock
currentRuleback to summary
public Stack<RuleFunction> currentRule
delegateback to summary
public OutputModelFactory delegate

Who does the work? Doesn't have to be CoreOutputModelFactory.

extensionsback to summary
public List<CodeGeneratorExtension> extensions

Post-processing CodeGeneratorExtension objects; done in order given.

rootback to summary
public OutputModelObject root
treeLevelback to summary
public int treeLevel
walkerback to summary
public SourceGenTriggers walker

While walking code in rules, this is set to the tree walker that triggers actions.

Constructor Detail

OutputModelControllerback to summary
public OutputModelController(OutputModelFactory factory)

Method Detail

actionback to summary
public List<SrcOp> action(ActionAST ast)
addExtensionback to summary
public void addExtension(CodeGeneratorExtension ext)
alternativeback to summary
public CodeBlockForAlt alternative(Alternative alt, boolean outerMost)
buildBaseListenerOutputModelback to summary
public OutputModelObject buildBaseListenerOutputModel(boolean header)
buildBaseVisitorOutputModelback to summary
public OutputModelObject buildBaseVisitorOutputModel(boolean header)
buildLeftRecursiveRuleFunctionback to summary
public void buildLeftRecursiveRuleFunction(LeftRecursiveRule r, LeftRecursiveRuleFunction function)
buildLexerOutputModelback to summary
public OutputModelObject buildLexerOutputModel(boolean header)
buildLexerRuleActionsback to summary
public void buildLexerRuleActions(Lexer lexer, final Rule r)
buildListenerOutputModelback to summary
public OutputModelObject buildListenerOutputModel(boolean header)
buildNormalRuleFunctionback to summary
public void buildNormalRuleFunction(Rule r, RuleFunction function)
buildParserOutputModelback to summary
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.

buildRuleFunctionback to summary
public void buildRuleFunction(Parser parser, Rule r)

Create RuleFunction per rule and update sempreds,actions of parser output object with stuff found in r.

buildVisitorOutputModelback to summary
public OutputModelObject buildVisitorOutputModel(boolean header)
epsilonback to summary
public CodeBlockForAlt epsilon(Alternative alt, boolean outerMost)
finishAlternativeback to summary
public CodeBlockForAlt finishAlternative(CodeBlockForAlt blk, List<SrcOp> ops, boolean outerMost)
getChoiceBlockback to summary
public Choice getChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts, GrammarAST label)
getCodeBlockLevelback to summary
public int getCodeBlockLevel()
getCurrentBlockback to summary
public CodeBlock getCurrentBlock()
getCurrentOuterMostAltback to summary
public Alternative getCurrentOuterMostAlt()
getCurrentOuterMostAlternativeBlockback to summary
public CodeBlockForOuterMostAlt getCurrentOuterMostAlternativeBlock()
getCurrentRuleFunctionback to summary
public RuleFunction getCurrentRuleFunction()
getEBNFBlockback to summary
public Choice getEBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts)
getGeneratorback to summary
public CodeGenerator getGenerator()
getGrammarback to summary
public Grammar getGrammar()
getRootback to summary
public OutputModelObject getRoot()
lexerback to summary
public Lexer lexer(LexerFile file)
lexerFileback to summary
public LexerFile lexerFile(String fileName)
needsImplicitLabelback to summary
public boolean needsImplicitLabel(GrammarAST ID, LabeledOp op)
parserback to summary
public Parser parser(ParserFile file)
parserFileback to summary
public ParserFile parserFile(String fileName)
popCurrentRuleback to summary
public RuleFunction popCurrentRule()
pushCurrentRuleback to summary
public void pushCurrentRule(RuleFunction r)
ruleback to summary
public RuleFunction rule(Rule r)
rulePostambleback to summary
public List<SrcOp> rulePostamble(RuleFunction function, Rule r)
ruleRefback to summary
public List<SrcOp> ruleRef(GrammarAST ID, GrammarAST label, GrammarAST args)
sempredback to summary
public List<SrcOp> sempred(ActionAST ast)
setback to summary
public List<SrcOp> set(GrammarAST setAST, GrammarAST labelAST, boolean invert)

(A|B|C) possibly with ebnfRoot and label

setCurrentBlockback to summary
public void setCurrentBlock(CodeBlock blk)
setCurrentOuterMostAltback to summary
public void setCurrentOuterMostAlt(Alternative currentOuterMostAlt)
setCurrentOuterMostAlternativeBlockback to summary
public void setCurrentOuterMostAlternativeBlock(CodeBlockForOuterMostAlt currentOuterMostAlternativeBlock)
setRootback to summary
public void setRoot(OutputModelObject root)
stringRefback to summary
public List<SrcOp> stringRef(GrammarAST ID, GrammarAST label)
tokenRefback to summary
public List<SrcOp> tokenRef(GrammarAST ID, GrammarAST label, GrammarAST args)
wildcardback to summary
public List<SrcOp> wildcard(GrammarAST ast, GrammarAST labelAST)