annotate Implab/Automaton/IDFATable.cs @ 166:b84cdbe82e7f ref20160224

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