public virtual Lexer Lexer(Lexer l) { return l; }
public virtual void BuildLexerRuleActions(Lexer lexer, Rule r) { if (r.actions.Count == 0) { return; } CodeGenerator gen = @delegate.GetGenerator(); Grammar g = @delegate.GetGrammar(); string ctxType = @delegate.GetTarget().GetRuleFunctionContextStructName(r); RuleActionFunction raf; if (!lexer.actionFuncs.TryGetValue(r, out raf) || raf == null) { raf = new RuleActionFunction(@delegate, r, ctxType); } foreach (ActionAST a in r.actions) { if (a is PredAST) { PredAST p = (PredAST)a; RuleSempredFunction rsf ; if (!lexer.sempredFuncs.TryGetValue(r, out rsf) || rsf == null) { rsf = new RuleSempredFunction(@delegate, r, ctxType); lexer.sempredFuncs[r] = rsf; } rsf.actions[g.sempreds[p]] = new Action(@delegate, p); } else if (a.Type == ANTLRParser.ACTION) { raf.actions[g.lexerActions[a]] = new Action(@delegate, a); } } if (raf.actions.Count > 0 && !lexer.actionFuncs.ContainsKey(r)) { // only add to lexer if the function actually contains actions lexer.actionFuncs[r] = raf; } }