165
|
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 {
|
|
35 /// <summary>
|
|
36 /// Таблица переходов состояний автомата
|
|
37 /// </summary>
|
|
38 /// <returns>The transition table.</returns>
|
|
39 DFAStateDescriptior[] GetTransitionTable();
|
|
40
|
|
41 int StateCount {
|
|
42 get;
|
|
43 }
|
|
44
|
|
45 int AlphabetSize {
|
|
46 get;
|
|
47 }
|
|
48
|
|
49 int InitialState {
|
|
50 get;
|
|
51 }
|
|
52
|
|
53 bool IsFinalState(int s);
|
|
54
|
|
55 IEnumerable<int> FinalStates {
|
|
56 get;
|
|
57 }
|
|
58 }
|
|
59 }
|