public LexerFile(OutputModelFactory factory, String fileName) { super(factory, fileName); namedActions = buildNamedActions(factory.getGrammar()); genPackage = factory.getGrammar().tool.genPackage; exportMacro = factory.getGrammar().getOptionString("exportMacro"); genListener = factory.getGrammar().tool.gen_listener; genVisitor = factory.getGrammar().tool.gen_visitor; } }
public LexerFile(OutputModelFactory factory, String fileName) { super(factory, fileName); namedActions = buildNamedActions(factory.getGrammar()); genPackage = factory.getGrammar().tool.genPackage; exportMacro = factory.getGrammar().getOptionString("exportMacro"); genListener = factory.getGrammar().tool.gen_listener; genVisitor = factory.getGrammar().tool.gen_visitor; } }
public OutputFile(OutputModelFactory factory, String fileName) { super(factory); this.fileName = fileName; Grammar g = factory.getGrammar(); grammarFileName = g.fileName; ANTLRVersion = Tool.VERSION; TokenLabelType = g.getOptionString("TokenLabelType"); InputSymbolType = TokenLabelType; }
public LL1StarBlockSingleAlt(OutputModelFactory factory, GrammarAST starRoot, List<CodeBlockForAlt> alts) { super(factory, starRoot, alts); StarLoopEntryState star = (StarLoopEntryState)starRoot.atnState; loopBackStateNumber = star.loopBackState.stateNumber; this.decision = star.decision; IntervalSet[] altLookSets = factory.getGrammar().decisionLOOK.get(decision); assert altLookSets.length == 2; IntervalSet enterLook = altLookSets[0]; IntervalSet exitLook = altLookSets[1]; loopExpr = addCodeForLoopLookaheadTempVar(enterLook); } }
public Lexer(OutputModelFactory factory, LexerFile file) { super(factory); this.file = file; // who contains us? Grammar g = factory.getGrammar(); channels = new LinkedHashMap<String, Integer>(g.channelNameToValueMap); modes = ((LexerGrammar)g).modes.keySet(); } }
@Override public void addDispatchMethods(Rule r) { dispatchMethods = new ArrayList<DispatchMethod>(); if ( factory.getGrammar().tool.gen_listener ) { dispatchMethods.add(new ListenerDispatchMethod(factory, true)); dispatchMethods.add(new ListenerDispatchMethod(factory, false)); } if ( factory.getGrammar().tool.gen_visitor ) { dispatchMethods.add(new VisitorDispatchMethod(factory)); } }
public ThrowRecognitionException(OutputModelFactory factory, GrammarAST ast, IntervalSet expecting) { super(factory, ast); //this.decision = ((BlockStartState)ast.ATNState).decision; grammarLine = ast.getLine(); grammarLine = ast.getCharPositionInLine(); grammarFile = factory.getGrammar().fileName; //this.expecting = factory.createExpectingBitSet(ast, decision, expecting, "error"); // factory.defineBitSet(this.expecting); } }
public LL1AltBlock(OutputModelFactory factory, GrammarAST blkAST, List<CodeBlockForAlt> alts) { super(factory, blkAST, alts); this.decision = ((DecisionState)blkAST.atnState).decision; /** Lookahead for each alt 1..n */ IntervalSet[] altLookSets = factory.getGrammar().decisionLOOK.get(decision); altLook = getAltLookaheadAsStringLists(altLookSets); IntervalSet expecting = IntervalSet.or(altLookSets); // combine alt sets this.error = getThrowNoViableAlt(factory, blkAST, expecting); } }
public LL1AltBlock(OutputModelFactory factory, GrammarAST blkAST, List<CodeBlockForAlt> alts) { super(factory, blkAST, alts); this.decision = ((DecisionState)blkAST.atnState).decision; /** Lookahead for each alt 1..n */ IntervalSet[] altLookSets = factory.getGrammar().decisionLOOK.get(decision); altLook = getAltLookaheadAsStringLists(altLookSets); IntervalSet expecting = IntervalSet.or(altLookSets); // combine alt sets this.error = getThrowNoViableAlt(factory, blkAST, expecting); } }
public List<String[]> getAltLookaheadAsStringLists(IntervalSet[] altLookSets) { List<String[]> altLook = new ArrayList<String[]>(); for (IntervalSet s : altLookSets) { altLook.add(factory.getGenerator().getTarget().getTokenTypesAsTargetLabels(factory.getGrammar(), s.toArray())); } return altLook; }
public List<String[]> getAltLookaheadAsStringLists(IntervalSet[] altLookSets) { List<String[]> altLook = new ArrayList<String[]>(); for (IntervalSet s : altLookSets) { altLook.add(factory.getGenerator().getTarget().getTokenTypesAsTargetLabels(factory.getGrammar(), s.toArray())); } return altLook; }
@Override public void nonLocalAttr(String expr, Token x, Token y) { gen.g.tool.log("action-translator", "nonLocalAttr "+x+"::"+y); Rule r = factory.getGrammar().getRule(x.getText()); chunks.add(new NonLocalAttrRef(nodeContext, x.getText(), y.getText(), r.index)); }
@Override public void nonLocalAttr(String expr, Token x, Token y) { gen.g.tool.log("action-translator", "nonLocalAttr "+x+"::"+y); Rule r = factory.getGrammar().getRule(x.getText()); chunks.add(new NonLocalAttrRef(nodeContext, x.getText(), y.getText(), r.index)); }
public MatchToken(OutputModelFactory factory, TerminalAST ast) { super(factory, ast); Grammar g = factory.getGrammar(); CodeGenerator gen = factory.getGenerator(); ttype = g.getTokenType(ast.getText()); name = gen.getTarget().getTokenTypeAsTargetLabel(g, ttype); }
public MatchToken(OutputModelFactory factory, TerminalAST ast) { super(factory, ast); Grammar g = factory.getGrammar(); CodeGenerator gen = factory.getGenerator(); ttype = g.getTokenType(ast.getText()); name = gen.getTarget().getTokenTypeAsTargetLabel(g, ttype); }
@Override public void setNonLocalAttr(String expr, Token x, Token y, Token rhs) { gen.g.tool.log("action-translator", "setNonLocalAttr "+x+"::"+y+"="+rhs); Rule r = factory.getGrammar().getRule(x.getText()); List<ActionChunk> rhsChunks = translateActionChunk(factory,rf,rhs.getText(),node); SetNonLocalAttr s = new SetNonLocalAttr(nodeContext, x.getText(), y.getText(), r.index, rhsChunks); chunks.add(s); }
@Override public void setNonLocalAttr(String expr, Token x, Token y, Token rhs) { gen.g.tool.log("action-translator", "setNonLocalAttr "+x+"::"+y+"="+rhs); Rule r = factory.getGrammar().getRule(x.getText()); List<ActionChunk> rhsChunks = translateActionChunk(factory,rf,rhs.getText(),node); SetNonLocalAttr s = new SetNonLocalAttr(nodeContext, x.getText(), y.getText(), r.index, rhsChunks); chunks.add(s); }
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 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; }
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; }