Mercurial > pub > ImplabNet
comparison Implab/Automaton/IDFATable.cs @ 190:1c2a16d071a7 v2
Слияние с ref20160224
| author | cin |
|---|---|
| date | Fri, 22 Apr 2016 13:08:08 +0300 |
| parents | 0f70905b4652 |
| children |
comparison
equal
deleted
inserted
replaced
| 161:2a8466f0cb8a | 190:1c2a16d071a7 |
|---|---|
| 1 using System.Collections.Generic; | |
| 2 | |
| 3 | |
| 4 namespace Implab.Automaton { | |
| 5 /// <summary> | |
| 6 /// Полностью описывает DFA автомат, его поведение, состояние и входные символы. | |
| 7 /// </summary> | |
| 8 /// <example> | |
| 9 /// class MyAutomaton { | |
| 10 /// int m_current; | |
| 11 /// readonly DFAStateDescriptor<string>[] m_automaton; | |
| 12 /// readonly IAlphabet<MyCommands> m_commands; | |
| 13 /// | |
| 14 /// public MyAutomaton(IDFADefinition<MyCommands,MyStates,string> definition) { | |
| 15 /// m_current = definition.StateAlphabet.Translate(MyStates.Initial); | |
| 16 /// m_automaton = definition.GetTransitionTable(); | |
| 17 /// m_commands = definition.InputAlphabet; | |
| 18 /// } | |
| 19 /// | |
| 20 /// // defined a method which will move the automaton to the next state | |
| 21 /// public void Move(MyCommands cmd) { | |
| 22 /// // use transition map to determine the next state | |
| 23 /// var next = m_automaton[m_current].transitions[m_commands.Translate(cmd)]; | |
| 24 /// | |
| 25 /// // validate that we aren't in the unreachable state | |
| 26 /// if (next == DFAConst.UNREACHABLE_STATE) | |
| 27 /// throw new InvalidOperationException("The specified command is invalid"); | |
| 28 /// | |
| 29 /// // if everything is ok | |
| 30 /// m_current = next; | |
| 31 /// } | |
| 32 /// } | |
| 33 /// </example> | |
| 34 public interface IDFATable : IEnumerable<AutomatonTransition> { | |
| 35 int StateCount { | |
| 36 get; | |
| 37 } | |
| 38 | |
| 39 int AlphabetSize { | |
| 40 get; | |
| 41 } | |
| 42 | |
| 43 int InitialState { | |
| 44 get; | |
| 45 } | |
| 46 | |
| 47 bool IsFinalState(int s); | |
| 48 | |
| 49 IEnumerable<int> FinalStates { | |
| 50 get; | |
| 51 } | |
| 52 } | |
| 53 } |
