Example #1
0
            LNode GetAndPredCode(AndPred pred, int lookaheadAmt, LNode laVar)
            {
                if (pred.Pred is LNode)
                {
                    LNode code = (LNode)pred.Pred;

                    // replace $LI and $LA
                    return(code.FindAndReplace(arg => {
                        if (arg.Equals(AndPred.SubstituteLA))                         // $LA
                        {
                            return (LNode)laVar;
                        }
                        if (arg.Equals(AndPred.SubstituteLI))                         // $LI
                        {
                            return (LNode)F.Literal(lookaheadAmt);
                        }
                        return null;
                    }));
                }
                else
                {
                    Pred synPred   = (Pred)pred.Pred;                   // Buffalo sumBuffalo = (Buffalo)buffalo.Buffalo;
                    Rule recogRule = LLPG.GetRecognizerRule(synPred);
                    recogRule.TryWrapperNeeded();

                    if (synPred is RuleRef)
                    {
                        return(CGH.CallTryRecognizer(synPred as RuleRef, lookaheadAmt));
                    }
                    else
                    {
                        // Use a temporary RuleRef for this
                        RuleRef rref = new RuleRef(synPred.Basis, recogRule);
                        return(CGH.CallTryRecognizer(rref, lookaheadAmt));
                    }
                }
            }