static private int mapped_charset_size; // reduced charset size static internal void simplify(Spec spec) { computeClasses(spec); // initialize fields. /* * now rewrite the NFA using our character class mapping. */ for (int i = 0; i < spec.nfa_states.Count; i++) { Nfa nfa = (Nfa)spec.nfa_states[i]; if (nfa.GetEdge() == Nfa.EMPTY || nfa.GetEdge() == Nfa.EPSILON) { continue; // no change. } if (nfa.GetEdge() == Nfa.CCL) { CharSet nset = new CharSet(); nset.map(nfa.GetCharSet(), ccls); // map it. nfa.SetCharSet(nset); } else { // single character nfa.SetEdge(ccls[nfa.GetEdge()]); // map it. } } /* * now update spec with the mapping. */ spec.ccls_map = ccls; spec.dtrans_ncols = mapped_charset_size; }
internal static void simplify(Spec spec) { SimplifyNfa.computeClasses(spec); for (int i = 0; i < spec.nfa_states.Count; i++) { Nfa nfa = spec.nfa_states[i]; if (nfa.Edge != '�' && nfa.Edge != '') { if (nfa.Edge == '') { CharSet charSet = new CharSet(); charSet.map(nfa.GetCharSet(), SimplifyNfa.ccls); nfa.SetCharSet(charSet); } else { nfa.Edge = SimplifyNfa.ccls[(int)nfa.Edge]; } } } spec.ccls_map = SimplifyNfa.ccls; spec.dtrans_ncols = SimplifyNfa.mapped_charset_size; }