public Lexer(NFA pad, string tag, LAD[] alts) { this.pad = pad; this.alts = alts; this.tag = tag; int root = pad.AddNode(); int[] alt_shuffle = new int[alts.Length]; for (int i = 0; i < alts.Length; i++) alt_shuffle[i] = i; Array.Sort(alt_shuffle, delegate (int i1, int i2) { int j1, j2; bool c1, c2; alts[i1].QueryLiteral(pad, out j1, out c1); alts[i2].QueryLiteral(pad, out j2, out c2); return (j1 != j2) ? (j2 - j1) : (i1 - i2); }); for (int ix = 0; ix < alts.Length; ix++) { pad.curfate = alt_shuffle[ix]; int target = pad.AddNode(); pad.nodes_l[target].final = true; alts[alt_shuffle[ix]].ToNFA(pad, root, target); } nfates = alts.Length; fatebuffer = new int[nfates*2+2]; for (int i = 0; i < nfates*2+2; i++) fatebuffer[i] = -1; fatebuffer[0] = fatebuffer[1] = 0; pad.Complete(); // now the NFA nodes are all in tiebreak order by lowest index if (LtmTrace) { Dump(); } start = new LexerState(pad); start.Add(0); pad.Close(start); nil = new LexerState(pad); pad.dfashare[nil] = nil; pad.dfashare[start] = start; }