Пример #1
0
		public DTrans(Spec s, Dfa dfa)
		{
			this.dtrans = new int[s.dtrans_ncols];
			this.label = s.dtrans_list.Count;
			this.accept = dfa.GetAccept();
			this.anchor = dfa.GetAnchor();
		}
Пример #2
0
        public void move(Dfa dfa, int b)
        {
            List <Nfa> nFASet = dfa.GetNFASet();

            this.nfa_set = null;
            this.nfa_bit = null;
            int count = nFASet.Count;

            for (int i = 0; i < count; i++)
            {
                Nfa nfa = nFASet[i];
                if (b == (int)nfa.Edge || ('￾' == nfa.Edge && nfa.GetCharSet().contains(b)))
                {
                    if (this.nfa_set == null)
                    {
                        this.nfa_set = new List <Nfa>();
                        this.nfa_bit = new BitSet();
                    }
                    this.nfa_set.Add(nfa.Next);
                    this.nfa_bit.Set(nfa.Next.Label, true);
                }
            }
            if (this.nfa_set != null)
            {
                this.sort_states();
            }
        }
Пример #3
0
        public static Dfa NewDfa(Spec spec)
        {
            Dfa dfa = new Dfa(spec.dfa_states.Count);

            spec.dfa_states.Add(dfa);
            return(dfa);
        }
Пример #4
0
 public DTrans(Spec s, Dfa dfa)
 {
     this.dtrans = new int[s.dtrans_ncols];
     this.label  = s.dtrans_list.Count;
     this.accept = dfa.GetAccept();
     this.anchor = dfa.GetAnchor();
 }
Пример #5
0
        private static int add_to_dstates(Spec s, Bunch bunch)
        {
            Dfa dfa = Alloc.NewDfa(s);

            dfa.SetNFASet(new List <Nfa>(bunch.GetNFASet()));
            dfa.SetNFABit(new BitSet(bunch.GetNFABit()));
            dfa.SetAccept(bunch.GetAccept());
            dfa.SetAnchor(bunch.GetAnchor());
            dfa.ClearMarked();
            s.dfa_sets[dfa.GetNFABit()] = dfa;
            return(dfa.Label);
        }
Пример #6
0
 public Dfa GetNextUnmarkedDFA()
 {
     while (this.unmarked_dfa < this.dfa_states.Count)
     {
         Dfa dfa = this.dfa_states[this.unmarked_dfa];
         if (!dfa.IsMarked())
         {
             return(dfa);
         }
         this.unmarked_dfa++;
     }
     return(null);
 }
Пример #7
0
/*
 * Function: move
 */
        public void move(Dfa dfa, int b)
        {
            int       size;
            Nfa       state;
            ArrayList old_set = dfa.GetNFASet();

            nfa_set = null;
            nfa_bit = null;

            size = old_set.Count;
            for (int index = 0; index < size; index++)
            {
                state = (Nfa)old_set[index];

                if (b == state.GetEdge() ||
                    (Nfa.CCL == state.GetEdge() && state.GetCharSet().contains(b)))
                {
                    if (nfa_set == null)
                    {
                        nfa_set = new ArrayList();
                        nfa_bit = new BitSet();
                    }
                    nfa_set.Add(state.GetNext());
#if OLD_DEBUG
                    Console.WriteLine("Size of bitset: " + int.ToString(nfa_bit.GetLength()));
                    Console.WriteLine("Reference index: " + int.ToString(state.GetNext().GetLabel()));
#endif
                    nfa_bit.Set(state.GetNext().GetLabel(), true);
                }
            }

            if (nfa_set != null)
            {
#if DEBUG
                Utility.assert(null != nfa_bit);
#endif
                sort_states();
            }
            return;
        }
Пример #8
0
		public static Dfa NewDfa(Spec spec)
		{
			Dfa dfa = new Dfa(spec.dfa_states.Count);
			spec.dfa_states.Add(dfa);
			return dfa;
		}