void Closure() { for (NList pos = m_nfa; !pos.AtEnd; pos = pos.m_next) { ClosureAdd(pos.m_node); } }
private void Closure() { for (NList nlist = this.m_nfa; !nlist.AtEnd; nlist = nlist.m_next) { this.ClosureAdd(nlist.m_node); } }
internal Dfa Target(char ch) { // construct or lookup the target for a new arc Dfa n = new Dfa(m_tks); for (NList pos = m_nfa; !pos.AtEnd; pos = pos.m_next) { pos.m_node.AddTarget(ch, n); } // check we actually got something if (n.m_nfa.AtEnd) { return(null); } n.Closure(); // now check we haven't got it already for (int pos1 = 0; pos1 < m_tks.states.Count; pos1++) { if (((Dfa)m_tks.states[pos1]).SameAs(n)) { return((Dfa)m_tks.states[pos1]); } } // this is a brand new Dfa node so recursively build it n.AddActions(); return(n); }
internal bool SameAs(Dfa dfa) { NList nlist1 = this.m_nfa; NList nlist2; for (nlist2 = dfa.m_nfa; nlist1.m_node == nlist2.m_node && !nlist1.AtEnd; nlist2 = nlist2.m_next) { nlist1 = nlist1.m_next; } return(nlist1.m_node == nlist2.m_node); }
internal bool SameAs(Dfa dfa) { NList pos1 = m_nfa; NList pos2 = dfa.m_nfa; while (pos1.m_node == pos2.m_node && !pos1.AtEnd) { pos1 = pos1.m_next; pos2 = pos2.m_next; } return(pos1.m_node == pos2.m_node); }
public bool Add(NfaNode n) { if (m_node == null) { // m_node==null iff m_next==null m_next = new NList(); m_node = n; } else if (m_node.m_state < n.m_state) { m_next = new NList(m_node, m_next); m_node = n; } else if (m_node.m_state == n.m_state) { return(false); // Add fails, there already } else { return(m_next.Add(n)); } return(true); // was added }
internal Dfa Target(char ch) { Dfa dfa = new Dfa(this.m_tks); for (NList nlist = this.m_nfa; !nlist.AtEnd; nlist = nlist.m_next) { nlist.m_node.AddTarget(ch, dfa); } if (dfa.m_nfa.AtEnd) { return((Dfa)null); } dfa.Closure(); for (int index = 0; index < this.m_tks.states.Count; ++index) { if (((Dfa)this.m_tks.states[index]).SameAs(dfa)) { return((Dfa)this.m_tks.states[index]); } } dfa.AddActions(); return(dfa); }
public bool Add(NfaNode n) { if (m_node==null) { // m_node==null iff m_next==null m_next = new NList(); m_node = n; } else if (m_node.m_state < n.m_state) { m_next = new NList(m_node,m_next); m_node = n; } else if (m_node.m_state == n.m_state) return false; // Add fails, there already else return m_next.Add(n); return true; // was added }
NList(NfaNode nd,NList nx) { m_node=nd; m_next=nx; }
public NfaNode m_node; // null for the sentinel #endregion Fields #region Constructors public NList() { m_node=null; m_next=null; }
public NList() { m_node=null; m_next=null; } // sentinel only
} // sentinel only NList(NfaNode nd, NList nx) { m_node = nd; m_next = nx; }
public NList() { m_node = null; m_next = null; } // sentinel only