Ejemplo n.º 1
0
 void Closure()
 {
     for (NList pos = m_nfa; !pos.AtEnd; pos = pos.m_next)
     {
         ClosureAdd(pos.m_node);
     }
 }
Ejemplo n.º 2
0
Archivo: Dfa.cs Proyecto: m33p/radegast
 private void Closure()
 {
     for (NList nlist = this.m_nfa; !nlist.AtEnd; nlist = nlist.m_next)
     {
         this.ClosureAdd(nlist.m_node);
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
Archivo: Dfa.cs Proyecto: 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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
 }
Ejemplo n.º 7
0
Archivo: Dfa.cs Proyecto: 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);
        }
Ejemplo n.º 8
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
 }
Ejemplo n.º 9
0
 NList(NfaNode nd,NList nx)
 {
     m_node=nd; m_next=nx;
 }
Ejemplo n.º 10
0
        public NfaNode m_node; // null for the sentinel

        #endregion Fields

        #region Constructors

        public NList()
        {
            m_node=null; m_next=null;
        }
Ejemplo n.º 11
0
		public NList() { m_node=null; m_next=null; } // sentinel only
Ejemplo n.º 12
0
        }                                                    // sentinel only

        NList(NfaNode nd, NList nx)
        {
            m_node = nd; m_next = nx;
        }
Ejemplo n.º 13
0
 public NList()
 {
     m_node = null; m_next = null;
 }                                                    // sentinel only