Ejemplo n.º 1
0
 /// <summary>
 /// Naming states with ASCII letters and calling AddTrans to built up the states and transitions
 /// </summary>
 public Dfa(
     char startState,
     IEnumerable <char> acceptStates)
 {
     StartState    = startState;
     _acceptStates = new HashSet <int>(acceptStates.Select(x => (int)x));
     _delta        = new SortedDictionary <int, Dictionary <TAlphabet, int> >(); // keys, states are sorted
     _renamer      = new CharStateRenamer();
 }
Ejemplo n.º 2
0
 public Dfa(
     int startState,
     IEnumerable <int> acceptStates,
     IDictionary <int, Dictionary <TAlphabet, int> > delta,
     IDfaStateRenamer renamer)
 {
     StartState    = startState;
     _acceptStates = new HashSet <int>(acceptStates);
     _delta        = delta;
     _renamer      = renamer;
 }
Ejemplo n.º 3
0
        public MinimizedDfaRenamer(ICollection <Set <int> > blockStates, IDfaStateRenamer renamer)
        {
            _blockStatesToDfaState = new Dictionary <Set <int>, int>(blockStates.Count);
            _dfaStateToBlockState  = new List <Set <int> >(blockStates.Count);
            int count = 0;

            foreach (Set <int> k in blockStates)
            {
                int nfaStateIndex = count;
                _blockStatesToDfaState.Add(k, nfaStateIndex);
                _dfaStateToBlockState.Add(k);
                count += 1;
            }

            _renamer = renamer;
        }