示例#1
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);
        }
示例#2
0
/*
 * function: add_to_dstates
 * Description: Takes as input a CBunch with details of
 * a dfa state that needs to be created.
 * 1) Allocates a new dfa state and saves it in the appropriate Spec list
 * 2) Initializes the fields of the dfa state with the information in the CBunch.
 * 3) Returns index of new dfa.
 */
        private static int add_to_dstates(Spec s, Bunch bunch)
        {
            Dfa dfa;

#if DEBUG
            Utility.assert(null != bunch.GetNFASet());
            Utility.assert(null != bunch.GetNFABit());
            Utility.assert(null != bunch.GetAccept() || Spec.NONE == bunch.GetAnchor());
#endif

            /* Allocate, passing Spec so dfa label can be set. */
            dfa = Alloc.NewDfa(s);

            /* Initialize fields, including the mark field. */
            dfa.SetNFASet(new ArrayList(bunch.GetNFASet()));
            dfa.SetNFABit(new BitSet(bunch.GetNFABit()));
            dfa.SetAccept(bunch.GetAccept());
            dfa.SetAnchor(bunch.GetAnchor());
            dfa.ClearMarked();

#if OLD_DUMP_DEBUG
            Console.WriteLine("[Created new dfa_state #" + Int32.ToString(dfa.GetLabel()) + "]");
            dfa.dump();
#endif

            /* Register dfa state using BitSet in spec Hashtable. */
            s.dfa_sets[dfa.GetNFABit()] = dfa;

#if OLD_DUMP_DEBUG
            Console.Write("Registering set : ");
            Print_Set(dfa.GetNFASet());
            Console.WriteLine("");
#endif

            return(dfa.GetLabel());
        }