public int getRuleIndex(String scopeName, String ruleName) { Rule r = getRule(scopeName, ruleName); if ( r!=null ) { return r.index; } return INVALID_RULE_INDEX; }
public String getRuleModifier(String ruleName) { Rule r = getRule(ruleName); if ( r!=null ) { return r.modifier; } return null; }
public int getRuleIndex(String scopeName, String ruleName) { Rule r = getRule(scopeName, ruleName); if ( r!=null ) { return r.index; } return INVALID_RULE_INDEX; }
public NFAState getRuleStopState(String ruleName) { Rule r = getRule(ruleName); if ( r!=null ) { return r.stopState; } return null; }
public NFAState getRuleStopState(String ruleName) { Rule r = getRule(ruleName); if ( r!=null ) { return r.stopState; } return null; }
public int getRuleIndex(String scopeName, String ruleName) { Rule r = getRule(scopeName, ruleName); if ( r!=null ) { return r.index; } return INVALID_RULE_INDEX; }
public NFAState getRuleStartState(String scopeName, String ruleName) { Rule r = getRule(scopeName, ruleName); if ( r!=null ) { //System.out.println("getRuleStartState("+scopeName+", "+ruleName+")="+r.startState); return r.startState; } //System.out.println("getRuleStartState("+scopeName+", "+ruleName+")=null"); return null; }
public String getRuleModifier(String ruleName) { Rule r = getRule(ruleName); if ( r!=null ) { return r.modifier; } return null; }
public NFAState getRuleStopState(String ruleName) { Rule r = getRule(ruleName); if ( r!=null ) { return r.stopState; } return null; }
public NFAState getRuleStartState(String scopeName, String ruleName) { Rule r = getRule(scopeName, ruleName); if ( r!=null ) { //System.out.println("getRuleStartState("+scopeName+", "+ruleName+")="+r.startState); return r.startState; } //System.out.println("getRuleStartState("+scopeName+", "+ruleName+")=null"); return null; }
protected final void trackInlineAction( GrammarAST actionAST ) { Rule r = grammar.getRule( currentRuleName ); if ( r != null ) { r.trackInlineAction( actionAST ); } }
public ActionTranslator(CodeGenerator generator, String ruleName, Token actionToken, int outerAltNum) { this(new ANTLRStringStream(actionToken.getText())); this.generator = generator; grammar = generator.grammar; this.enclosingRule = grammar.getRule(ruleName); this.actionToken = actionToken; this.outerAltNum = outerAltNum; }
/** For $rulelabel.name, return the Attribute found for name. It * will be a predefined property or a return value. */ public Attribute getRuleLabelAttribute(String ruleName, String attrName) { Rule r = grammar.getRule(ruleName); AttributeScope scope = r.getLocalAttributeScope(attrName); if ( scope!=null && !scope.isParameterScope ) { return scope.getAttribute(attrName); } return null; }
AttributeScope resolveDynamicScope(String scopeName) { if ( grammar.getGlobalScope(scopeName)!=null ) { return grammar.getGlobalScope(scopeName); } Rule scopeRule = grammar.getRule(scopeName); if ( scopeRule!=null ) { return scopeRule.ruleScope; } return null; // not a valid dynamic scope }
public Rule getRule(String scopeName, String ruleName) { if ( scopeName!=null ) { // scope override Grammar scope = composite.getGrammar(scopeName); if ( scope==null ) { return null; } return scope.getLocallyDefinedRule(ruleName); } return getRule(ruleName); }
AttributeScope resolveDynamicScope(String scopeName) { if ( grammar.getGlobalScope(scopeName)!=null ) { return grammar.getGlobalScope(scopeName); } Rule scopeRule = grammar.getRule(scopeName); if ( scopeRule!=null ) { return scopeRule.ruleScope; } return null; // not a valid dynamic scope }
/** For $rulelabel.name, return the Attribute found for name. It * will be a predefined property or a return value. */ public Attribute getRuleLabelAttribute(String ruleName, String attrName) { Rule r = grammar.getRule(ruleName); AttributeScope scope = r.getLocalAttributeScope(attrName); if ( scope!=null && !scope.isParameterScope ) { return scope.getAttribute(attrName); } return null; }
/** For $rulelabel.name, return the Attribute found for name. It * will be a predefined property or a return value. */ public Attribute getRuleLabelAttribute(String ruleName, String attrName) { Rule r = grammar.getRule(ruleName); AttributeScope scope = r.getLocalAttributeScope(attrName); if ( scope!=null && !scope.isParameterScope ) { return scope.getAttribute(attrName); } return null; }
public Rule getRule(String scopeName, String ruleName) { if ( scopeName!=null ) { // scope override Grammar scope = composite.getGrammar(scopeName); if ( scope==null ) { return null; } return scope.getLocallyDefinedRule(ruleName); } return getRule(ruleName); }
final LexerGrammar lg = (LexerGrammar) Grammar.load(lexerGrammarFileName); final Grammar pg = Grammar.load(parserGrammarFileName, lg); ANTLRFileStream input = new ANTLRFileStream(fileNameToParse); LexerInterpreter lexEngine = lg.createLexerInterpreter(input); CommonTokenStream tokens = new CommonTokenStream(lexEngine); ParserInterpreter parser = pg.createParserInterpreter(tokens); ParseTree t = parser.parse(pg.getRule(startRule).index); System.out.println("parse tree: " + t.toStringTree(parser));