using System; namespace Implab.Automaton.RegularExpressions { public class RegularDFADefinition : DFATransitionTable, IDFATransitionTable { readonly IAlphabet m_alphabet; readonly int m_initialState; public RegularDFADefinition(IAlphabet alphabet, int initialState) { Safe.ArgumentNotNull(alphabet, "aplhabet"); m_alphabet = alphabet; m_initialState = initialState; } public IAlphabet InputAlphabet { get { return m_alphabet; } } protected override DFAStateDescriptior[] ConstructTransitionTable() { if (InputAlphabet.Count != m_alphabet.Count) throw new InvalidOperationException("The alphabet doesn't match the transition table"); return base.ConstructTransitionTable(); } /// /// Optimize the specified alphabet. /// /// Пустой алфавит, который будет зполнен в процессе оптимизации. public RegularDFADefinition Optimize(IAlphabetBuilder alphabet) { Safe.ArgumentNotNull(alphabet, "alphabet"); var optimalDFA = new RegularDFADefinition(alphabet, m_initialState); Optimize(optimalDFA, InputAlphabet, alphabet, new DummyAlphabet(StateCount), new MapAlphabet()); } } }