public ActionAnalysisLexer(Grammar grammar, string ruleName, GrammarAST actionAST) : this(new ANTLRStringStream(actionAST.Token.Text)) { this.grammar = grammar; this.enclosingRule = grammar.GetLocallyDefinedRule(ruleName); this.actionToken = actionAST.Token; this.outerAltNum = actionAST.outerAltNum; }
/** Get set of rules for grammar g that need to have manual delegation * methods. This is the list of rules collected from all direct/indirect * delegates minus rules overridden in grammar g. * * This returns null except for the delegate root because it is the only * one that has to have a complete grammar rule interface. The delegates * should not be instantiated directly for use as parsers (you can create * them to pass to the root parser's ctor as arguments). */ public virtual HashSet<Rule> GetDelegatedRules( Grammar g ) { if ( g != delegateGrammarTreeRoot.Grammar ) { return null; } HashSet<Rule> rules = GetAllImportedRules( g ); foreach ( Rule r in rules.ToArray() ) { Rule localRule = g.GetLocallyDefinedRule( r.Name ); // if locally defined or it's not local but synpred, don't make a delegation method if ( localRule != null || r.IsSynPred ) { // kill overridden rules rules.Remove( r ); } } return rules; }