annotate Implab/Formats/ScannerContext.cs @ 203:4d9830a9bbb8 v2

Added 'Fail' method to RunnableComponent which allows component to move from Running to Failed state. Added PollingComponent a timer based runnable component More tests Added FailPromise a thin class to wrap exceptions Fixed error handling in SuccessPromise classes.
author cin
date Tue, 18 Oct 2016 17:49:54 +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