public virtual void BuildRuleFunction(Parser parser, Rule r)
{
RuleFunction function = Rule(r);
parser.funcs.Add(function);
PushCurrentRule(function);
function.FillNamedActions(@delegate, r);
if (r is LeftRecursiveRule)
{
BuildLeftRecursiveRuleFunction((LeftRecursiveRule)r,
(LeftRecursiveRuleFunction)function);
}
else
{
BuildNormalRuleFunction(r, function);
}
Grammar g = GetGrammar();
foreach (ActionAST a in r.actions)
{
if (a is PredAST)
{
PredAST p = (PredAST)a;
RuleSempredFunction rsf;
if (!parser.sempredFuncs.TryGetValue(r, out rsf) || rsf == null)
{
rsf = new RuleSempredFunction(@delegate, r, function.ctxType);
parser.sempredFuncs[r] = rsf;
}
rsf.actions[g.sempreds[p]] = new Action(@delegate, p);
}
}
PopCurrentRule();
}