Mercurial > pub > ImplabNet
diff Implab/Automaton/IDFADefinition.cs @ 162:0526412bbb26 ref20160224
DFA refactoring
author | cin |
---|---|
date | Wed, 24 Feb 2016 08:39:53 +0300 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab/Automaton/IDFADefinition.cs Wed Feb 24 08:39:53 2016 +0300 @@ -0,0 +1,56 @@ + +namespace Implab.Automaton { + /// <summary> + /// Полностью описывает DFA автомат, его поведение, состояние и входные символы. + /// </summary> + /// <example> + /// class MyAutomaton { + /// int m_current; + /// readonly DFAStateDescriptor<string>[] m_automaton; + /// readonly IAlphabet<MyCommands> m_commands; + /// + /// public MyAutomaton(IDFADefinition<MyCommands,MyStates,string> definition) { + /// m_current = definition.StateAlphabet.Translate(MyStates.Initial); + /// m_automaton = definition.GetTransitionTable(); + /// m_commands = definition.InputAlphabet; + /// } + /// + /// // defined a method which will move the automaton to the next state + /// public void Move(MyCommands cmd) { + /// // use transition map to determine the next state + /// var next = m_automaton[m_current].transitions[m_commands.Translate(cmd)]; + /// + /// // validate that we aren't in the unreachable state + /// if (next == DFAConst.UNREACHABLE_STATE) + /// throw new InvalidOperationException("The specified command is invalid"); + /// + /// // if everything is ok + /// m_current = next; + /// } + /// } + /// </example> + public interface IDFADefinition<TInput, TState, TTag> { + /// <summary> + /// Алфавит входных символов + /// </summary> + /// <value>The input alphabet.</value> + IAlphabet<TInput> InputAlphabet { + get; + } + + /// <summary> + /// Алфавит состояний автомата + /// </summary> + /// <value>The state alphabet.</value> + IAlphabet<TState> StateAlphabet { + get; + } + + /// <summary> + /// Таблица переходов состояний автомата + /// </summary> + /// <returns>The transition table.</returns> + DFAStateDescriptior<TTag>[] GetTransitionTable(); + + } +}