Beispiel #1
0
    public LexerState Next(NFA nf, int ch)
    {
        LexerState l;
        if (dfc.TryGetValue(ch, out l))
            return l;
        l = new LexerState(nf);
        for (int i = 0; i < nstates.Length; i++) {
            int bm = nstates[i];
            for (int j = 0; j < 32; j++) {
                if ((bm & (1 << j)) == 0)
                    continue;
                int ei = 0, eimax = 0;
                var es = nf.EdgesOf(32*i + j, ref ei, ref eimax);
                while (ei != eimax) {
                    var e = es[ei++];
                    if (e.when == ch || e.when == -1 && e.when_cc.Accepts(ch))
                        l.Add(e.to);
                }
            }
        }

        nf.Close(l);
        LexerState cl;

        if (!nf.dfashare.TryGetValue(l, out cl)) {
            nf.dfashare[l] = cl = l;
        }
        dfc[ch] = cl;
        return cl;
    }