示例#1
0
 void Closure()
 {
     for (NList pos = m_nfa; !pos.AtEnd; pos = pos.m_next)
     {
         ClosureAdd(pos.m_node);
     }
 }
示例#2
0
文件: Dfa.cs 项目: m33p/radegast
 private void Closure()
 {
     for (NList nlist = this.m_nfa; !nlist.AtEnd; nlist = nlist.m_next)
     {
         this.ClosureAdd(nlist.m_node);
     }
 }
示例#3
0
        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);
        }
示例#4
0
文件: Dfa.cs 项目: m33p/radegast
        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);
        }
示例#5
0
        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);
        }
示例#6
0
 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
 }
示例#7
0
文件: Dfa.cs 项目: m33p/radegast
        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);
        }
示例#8
0
文件: dfa.cs 项目: hdinh/OmahaBot
 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
 }
示例#9
0
文件: dfa.cs 项目: hdinh/OmahaBot
 NList(NfaNode nd,NList nx)
 {
     m_node=nd; m_next=nx;
 }
示例#10
0
文件: dfa.cs 项目: hdinh/OmahaBot
        public NfaNode m_node; // null for the sentinel

        #endregion Fields

        #region Constructors

        public NList()
        {
            m_node=null; m_next=null;
        }
示例#11
0
文件: dfa.cs 项目: Belxjander/Asuna
		public NList() { m_node=null; m_next=null; } // sentinel only
示例#12
0
        }                                                    // sentinel only

        NList(NfaNode nd, NList nx)
        {
            m_node = nd; m_next = nx;
        }
示例#13
0
 public NList()
 {
     m_node = null; m_next = null;
 }                                                    // sentinel only