annotate Implab/Formats/ScannerContext.cs @ 205:8200ab154c8a v2

Added ResetState to RunnableComponent to reset in case of failure Added StateChanged event to IRunnable Renamed Promise.SUCCESS -> Promise.Success Added Promise.FromException Renamed Bundle -> PromiseAll in PromiseExtensions
author cin
date Tue, 25 Oct 2016 17:40:33 +0300
parents a0ff6a0e9c44
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
177
a0ff6a0e9c44 refactoring
cin
parents: 176
diff changeset
1 namespace Implab.Formats {
a0ff6a0e9c44 refactoring
cin
parents: 176
diff changeset
2 /// <summary>
a0ff6a0e9c44 refactoring
cin
parents: 176
diff changeset
3 /// Represents a scanner configuration usefull to recongnize token, based on the DFA.
a0ff6a0e9c44 refactoring
cin
parents: 176
diff changeset
4 /// </summary>
176
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
5 public class ScannerContext<TTag> {
177
a0ff6a0e9c44 refactoring
cin
parents: 176
diff changeset
6
176
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
7 public int[,] Dfa { get; private set; }
177
a0ff6a0e9c44 refactoring
cin
parents: 176
diff changeset
8
176
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
9 public bool[] Final { get; private set; }
177
a0ff6a0e9c44 refactoring
cin
parents: 176
diff changeset
10
176
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
11 public TTag[][] Tags { get; private set; }
177
a0ff6a0e9c44 refactoring
cin
parents: 176
diff changeset
12
176
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
13 public int State { get; private set; }
177
a0ff6a0e9c44 refactoring
cin
parents: 176
diff changeset
14
176
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
15 public int[] Alphabet { get; private set; }
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
16
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
17 public ScannerContext(int[,] dfa, bool[] final, TTag[][] tags, int state, int[] alphabet) {
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
18 Dfa = dfa;
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
19 Final = final;
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
20 Tags = tags;
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
21 State = state;
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
22 Alphabet = alphabet;
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
23 }
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
24
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
25 public bool Execute(TextScanner scanner, out TTag[] tag) {
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
26 return scanner.ReadToken(Dfa, Final, Tags, State, Alphabet, out tag);
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
27 }
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
28 }
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
29 }
0c3c69fe225b rewritten the text scanner
cin
parents:
diff changeset
30