annotate Implab/Automaton/IDFADefinition.cs @ 162:0526412bbb26 ref20160224

DFA refactoring
author cin
date Wed, 24 Feb 2016 08:39:53 +0300
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
162
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
1 
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
2 namespace Implab.Automaton {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
3 /// <summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
4 /// Полностью описывает DFA автомат, его поведение, состояние и входные символы.
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
5 /// </summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
6 /// <example>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
7 /// class MyAutomaton {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
8 /// int m_current;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
9 /// readonly DFAStateDescriptor<string>[] m_automaton;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
10 /// readonly IAlphabet<MyCommands> m_commands;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
11 ///
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
12 /// public MyAutomaton(IDFADefinition&lt;MyCommands,MyStates,string&gt; definition) {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
13 /// m_current = definition.StateAlphabet.Translate(MyStates.Initial);
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
14 /// m_automaton = definition.GetTransitionTable();
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
15 /// m_commands = definition.InputAlphabet;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
16 /// }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
17 ///
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
18 /// // defined a method which will move the automaton to the next state
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
19 /// public void Move(MyCommands cmd) {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
20 /// // use transition map to determine the next state
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
21 /// var next = m_automaton[m_current].transitions[m_commands.Translate(cmd)];
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
22 ///
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
23 /// // validate that we aren't in the unreachable state
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
24 /// if (next == DFAConst.UNREACHABLE_STATE)
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
25 /// throw new InvalidOperationException("The specified command is invalid");
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
26 ///
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
27 /// // if everything is ok
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
28 /// m_current = next;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
29 /// }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
30 /// }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
31 /// </example>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
32 public interface IDFADefinition<TInput, TState, TTag> {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
33 /// <summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
34 /// Алфавит входных символов
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
35 /// </summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
36 /// <value>The input alphabet.</value>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
37 IAlphabet<TInput> InputAlphabet {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
38 get;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
39 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
40
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
41 /// <summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
42 /// Алфавит состояний автомата
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
43 /// </summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
44 /// <value>The state alphabet.</value>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
45 IAlphabet<TState> StateAlphabet {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
46 get;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
47 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
48
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
49 /// <summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
50 /// Таблица переходов состояний автомата
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
51 /// </summary>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
52 /// <returns>The transition table.</returns>
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
53 DFAStateDescriptior<TTag>[] GetTransitionTable();
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
54
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
55 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
56 }