Expected0() public méthode

public Expected0 ( Node p, Symbol curSy ) : BitArray
p Node
curSy Symbol
Résultat System.Collections.BitArray
Exemple #1
0
        // use a switch if more than 5 alternatives and none starts with a resolver, and no LL1 warning
        bool UseSwitch(Node p)
        {
            BitArray s1, s2;

            if (p.typ != Node.alt)
            {
                return(false);
            }
            int nAlts = 0;

            s1 = new BitArray(tab.terminals.Count);
            while (p != null)
            {
                s2 = tab.Expected0(p.sub, curSy);
                // must not optimize with switch statement, if there are ll1 warnings
                if (Overlaps(s1, s2))
                {
                    return(false);
                }
                s1.Or(s2);
                ++nAlts;
                // must not optimize with switch-statement, if alt uses a resolver expression
                if (p.sub.typ == Node.rslv)
                {
                    return(false);
                }
                p = p.down;
            }
            return(nAlts > 5);
        }