private OutputModelController createController() { OutputModelFactory factory = new ParserFactory(this); OutputModelController controller = new OutputModelController(factory); factory.setController(controller); return controller; }
public ST generateBaseListener() { return walk(createController().buildBaseListenerOutputModel()); } public ST generateVisitor() { return walk(createController().buildVisitorOutputModel()); }
public ST generateBaseVisitor(boolean header) { return walk(createController().buildBaseVisitorOutputModel(header), header); }
public OutputModelObject buildLexerOutputModel(boolean header) { CodeGenerator gen = delegate.getGenerator(); LexerFile file = lexerFile(gen.getRecognizerFileName(header)); setRoot(file); file.lexer = lexer(file); Grammar g = delegate.getGrammar(); for (Rule r : g.rules.values()) { buildLexerRuleActions(file.lexer, r); } return file; }
/** Create RuleFunction per rule and update sempreds,actions of parser * output object with stuff found in r. */ public void buildRuleFunction(Parser parser, Rule r) { RuleFunction function = rule(r); parser.funcs.add(function); pushCurrentRule(function); function.fillNamedActions(delegate, r); if ( r instanceof LeftRecursiveRule ) { buildLeftRecursiveRuleFunction((LeftRecursiveRule)r, (LeftRecursiveRuleFunction)function); } else { buildNormalRuleFunction(r, function); } Grammar g = getGrammar(); for (ActionAST a : r.actions) { if ( a instanceof PredAST ) { PredAST p = (PredAST)a; RuleSempredFunction rsf = parser.sempredFuncs.get(r); if ( rsf==null ) { rsf = new RuleSempredFunction(delegate, r, function.ctxType); parser.sempredFuncs.put(r, rsf); } rsf.actions.put(g.sempreds.get(p), new Action(delegate, p)); } } popCurrentRule(); }
if ( outerMost ) controller.setCurrentOuterMostAlt(altAST.alt); retval.altCodeBlock = controller.alternative(controller.getCurrentOuterMostAlt(), outerMost); retval.altCodeBlock.ops = retval.ops = elems; controller.setCurrentBlock(retval.altCodeBlock); match(input, Token.UP, null); retval.altCodeBlock = controller.epsilon(controller.getCurrentOuterMostAlt(), outerMost);
public ST generateLexer() { return walk(createController().buildLexerOutputModel()); } public ST generateParser() { return walk(createController().buildParserOutputModel()); }
public ST generateListener(boolean header) { return walk(createController().buildListenerOutputModel(header), header); }
public void buildLeftRecursiveRuleFunction(LeftRecursiveRule r, LeftRecursiveRuleFunction function) { buildNormalRuleFunction(r, function);
/** Create RuleFunction per rule and update sempreds,actions of parser * output object with stuff found in r. */ public void buildRuleFunction(Parser parser, Rule r) { RuleFunction function = rule(r); parser.funcs.add(function); pushCurrentRule(function); function.fillNamedActions(delegate, r); if ( r instanceof LeftRecursiveRule ) { buildLeftRecursiveRuleFunction((LeftRecursiveRule)r, (LeftRecursiveRuleFunction)function); } else { buildNormalRuleFunction(r, function); } Grammar g = getGrammar(); for (ActionAST a : r.actions) { if ( a instanceof PredAST ) { PredAST p = (PredAST)a; RuleSempredFunction rsf = parser.sempredFuncs.get(r); if ( rsf==null ) { rsf = new RuleSempredFunction(delegate, r, function.ctxType); parser.sempredFuncs.put(r, rsf); } rsf.actions.put(g.sempreds.get(p), new Action(delegate, p)); } } popCurrentRule(); }
if ( outerMost ) controller.setCurrentOuterMostAlt(altAST.alt); retval.altCodeBlock = controller.alternative(controller.getCurrentOuterMostAlt(), outerMost); retval.altCodeBlock.ops = retval.ops = elems; controller.setCurrentBlock(retval.altCodeBlock); match(input, Token.UP, null); retval.altCodeBlock = controller.epsilon(controller.getCurrentOuterMostAlt(), outerMost);
public OutputModelObject buildLexerOutputModel(boolean header) { CodeGenerator gen = delegate.getGenerator(); LexerFile file = lexerFile(gen.getRecognizerFileName(header)); setRoot(file); file.lexer = lexer(file); Grammar g = delegate.getGrammar(); for (Rule r : g.rules.values()) { buildLexerRuleActions(file.lexer, r); } return file; }
public ST generateLexer(boolean header) { return walk(createController().buildLexerOutputModel(header), header); }
public ST generateListener() { return walk(createController().buildListenerOutputModel()); } public ST generateBaseListener() { return walk(createController().buildBaseListenerOutputModel()); }
public void buildLeftRecursiveRuleFunction(LeftRecursiveRule r, LeftRecursiveRuleFunction function) { buildNormalRuleFunction(r, function);
/** Create RuleFunction per rule and update sempreds,actions of parser * output object with stuff found in r. */ public void buildRuleFunction(Parser parser, Rule r) { RuleFunction function = rule(r); parser.funcs.add(function); pushCurrentRule(function); function.fillNamedActions(delegate, r); if ( r instanceof LeftRecursiveRule ) { buildLeftRecursiveRuleFunction((LeftRecursiveRule)r, (LeftRecursiveRuleFunction)function); } else { buildNormalRuleFunction(r, function); } Grammar g = getGrammar(); for (ActionAST a : r.actions) { if ( a instanceof PredAST ) { PredAST p = (PredAST)a; RuleSempredFunction rsf = parser.sempredFuncs.get(r); if ( rsf==null ) { rsf = new RuleSempredFunction(delegate, r, function.ctxType); parser.sempredFuncs.put(r, rsf); } rsf.actions.put(g.sempreds.get(p), new Action(delegate, p)); } } popCurrentRule(); }
if ( outerMost ) controller.setCurrentOuterMostAlt(altAST.alt); retval.altCodeBlock = controller.alternative(controller.getCurrentOuterMostAlt(), outerMost); retval.altCodeBlock.ops = retval.ops = elems; controller.setCurrentBlock(retval.altCodeBlock); match(input, Token.UP, null); retval.altCodeBlock = controller.epsilon(controller.getCurrentOuterMostAlt(), outerMost);
public OutputModelObject buildLexerOutputModel() { CodeGenerator gen = delegate.getGenerator(); LexerFile file = lexerFile(gen.getRecognizerFileName()); setRoot(file); file.lexer = lexer(file); Grammar g = delegate.getGrammar(); for (Rule r : g.rules.values()) { buildLexerRuleActions(file.lexer, r); } return file; }