annotate Implab/Automaton/IDFATable.cs @ 235:b49969a7043c v2

Слияние
author cin
date Thu, 05 Oct 2017 09:24:49 +0300
parents 0f70905b4652
children
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 int StateCount {
e227e78d72e4 DFA refactoring
cin
parents:
diff changeset
36 get;
e227e78d72e4 DFA refactoring
cin
parents:
diff changeset
37 }
e227e78d72e4 DFA refactoring
cin
parents:
diff changeset
38
e227e78d72e4 DFA refactoring
cin
parents:
diff changeset
39 int AlphabetSize {
e227e78d72e4 DFA refactoring
cin
parents:
diff changeset
40 get;
e227e78d72e4 DFA refactoring
cin
parents:
diff changeset
41 }
e227e78d72e4 DFA refactoring
cin
parents:
diff changeset
42
e227e78d72e4 DFA refactoring
cin
parents:
diff changeset
43 int InitialState {
e227e78d72e4 DFA refactoring
cin
parents:
diff changeset
44 get;
e227e78d72e4 DFA refactoring
cin
parents:
diff changeset
45 }
e227e78d72e4 DFA refactoring
cin
parents:
diff changeset
46
e227e78d72e4 DFA refactoring
cin
parents:
diff changeset
47 bool IsFinalState(int s);
e227e78d72e4 DFA refactoring
cin
parents:
diff changeset
48
e227e78d72e4 DFA refactoring
cin
parents:
diff changeset
49 IEnumerable<int> FinalStates {
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 }