1 /*
2  * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
3  * Use of this file is governed by the BSD 3-clause license that
4  * can be found in the LICENSE.txt file in the project root.
5  */
6 
7 package org.antlr.v4.codegen;
8 
9 import org.antlr.v4.codegen.model.Choice;
10 import org.antlr.v4.codegen.model.CodeBlockForAlt;
11 import org.antlr.v4.codegen.model.CodeBlockForOuterMostAlt;
12 import org.antlr.v4.codegen.model.LabeledOp;
13 import org.antlr.v4.codegen.model.Lexer;
14 import org.antlr.v4.codegen.model.LexerFile;
15 import org.antlr.v4.codegen.model.OutputModelObject;
16 import org.antlr.v4.codegen.model.Parser;
17 import org.antlr.v4.codegen.model.ParserFile;
18 import org.antlr.v4.codegen.model.RuleFunction;
19 import org.antlr.v4.codegen.model.SrcOp;
20 import org.antlr.v4.codegen.model.decl.CodeBlock;
21 import org.antlr.v4.runtime.misc.IntervalSet;
22 import org.antlr.v4.tool.Alternative;
23 import org.antlr.v4.tool.Grammar;
24 import org.antlr.v4.tool.Rule;
25 import org.antlr.v4.tool.ast.ActionAST;
26 import org.antlr.v4.tool.ast.BlockAST;
27 import org.antlr.v4.tool.ast.GrammarAST;
28 
29 import java.util.List;
30 
31 public interface OutputModelFactory {
getGrammar()32 	Grammar getGrammar();
33 
getGenerator()34 	CodeGenerator getGenerator();
35 
setController(OutputModelController controller)36 	void setController(OutputModelController controller);
37 
getController()38 	OutputModelController getController();
39 
parserFile(String fileName)40 	ParserFile parserFile(String fileName);
41 
parser(ParserFile file)42 	Parser parser(ParserFile file);
43 
lexerFile(String fileName)44 	LexerFile lexerFile(String fileName);
45 
lexer(LexerFile file)46 	Lexer lexer(LexerFile file);
47 
rule(Rule r)48 	RuleFunction rule(Rule r);
49 
rulePostamble(RuleFunction function, Rule r)50 	List<SrcOp> rulePostamble(RuleFunction function, Rule r);
51 
52 	// ELEMENT TRIGGERS
53 
alternative(Alternative alt, boolean outerMost)54 	CodeBlockForAlt alternative(Alternative alt, boolean outerMost);
55 
finishAlternative(CodeBlockForAlt blk, List<SrcOp> ops)56 	CodeBlockForAlt finishAlternative(CodeBlockForAlt blk, List<SrcOp> ops);
57 
epsilon(Alternative alt, boolean outerMost)58 	CodeBlockForAlt epsilon(Alternative alt, boolean outerMost);
59 
ruleRef(GrammarAST ID, GrammarAST label, GrammarAST args)60 	List<SrcOp> ruleRef(GrammarAST ID, GrammarAST label, GrammarAST args);
61 
tokenRef(GrammarAST ID, GrammarAST label, GrammarAST args)62 	List<SrcOp> tokenRef(GrammarAST ID, GrammarAST label, GrammarAST args);
63 
stringRef(GrammarAST ID, GrammarAST label)64 	List<SrcOp> stringRef(GrammarAST ID, GrammarAST label);
65 
set(GrammarAST setAST, GrammarAST label, boolean invert)66 	List<SrcOp> set(GrammarAST setAST, GrammarAST label, boolean invert);
67 
wildcard(GrammarAST ast, GrammarAST labelAST)68 	List<SrcOp> wildcard(GrammarAST ast, GrammarAST labelAST);
69 
action(ActionAST ast)70 	List<SrcOp> action(ActionAST ast);
71 
sempred(ActionAST ast)72 	List<SrcOp> sempred(ActionAST ast);
73 
getChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts, GrammarAST label)74 	Choice getChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts, GrammarAST label);
75 
getEBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts)76 	Choice getEBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts);
77 
getLL1ChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts)78 	Choice getLL1ChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts);
79 
getComplexChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts)80 	Choice getComplexChoiceBlock(BlockAST blkAST, List<CodeBlockForAlt> alts);
81 
getLL1EBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts)82 	Choice getLL1EBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts);
83 
getComplexEBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts)84 	Choice getComplexEBNFBlock(GrammarAST ebnfRoot, List<CodeBlockForAlt> alts);
85 
getLL1Test(IntervalSet look, GrammarAST blkAST)86 	List<SrcOp> getLL1Test(IntervalSet look, GrammarAST blkAST);
87 
needsImplicitLabel(GrammarAST ID, LabeledOp op)88 	boolean needsImplicitLabel(GrammarAST ID, LabeledOp op);
89 
90 	// CONTEXT INFO
91 
getRoot()92 	OutputModelObject getRoot();
93 
getCurrentRuleFunction()94 	RuleFunction getCurrentRuleFunction();
95 
getCurrentOuterMostAlt()96 	Alternative getCurrentOuterMostAlt();
97 
getCurrentBlock()98 	CodeBlock getCurrentBlock();
99 
getCurrentOuterMostAlternativeBlock()100 	CodeBlockForOuterMostAlt getCurrentOuterMostAlternativeBlock();
101 
getCodeBlockLevel()102 	int getCodeBlockLevel();
103 
getTreeLevel()104 	int getTreeLevel();
105 
106 }
107