comparison Implab/Automaton/RegularExpressions/RegularDFA.cs @ 178:d5c5db0335ee ref20160224

working on JSON parser
author cin
date Wed, 23 Mar 2016 19:51:45 +0300
parents a0ff6a0e9c44
children 478ef706906a
comparison
equal deleted inserted replaced
177:a0ff6a0e9c44 178:d5c5db0335ee
1 using System.Collections.Generic; 1 using System.Collections.Generic;
2 using System.Linq; 2 using System.Linq;
3 3
4 namespace Implab.Automaton.RegularExpressions { 4 namespace Implab.Automaton.RegularExpressions {
5 public class RegularDFA<TInput, TTag> : DFATable, ITaggedDFABuilder<TTag> { 5 public class TaggedDFA<TInput, TTag> : DFATable, ITaggedDFABuilder<TTag> {
6 6
7 readonly Dictionary<int,TTag[]> m_tags = new Dictionary<int, TTag[]>(); 7 readonly Dictionary<int,TTag[]> m_tags = new Dictionary<int, TTag[]>();
8 readonly IAlphabet<TInput> m_alphabet; 8 readonly IAlphabet<TInput> m_alphabet;
9 9
10 public RegularDFA(IAlphabet<TInput> alphabet) { 10 public TaggedDFA(IAlphabet<TInput> alphabet) {
11 Safe.ArgumentNotNull(alphabet, "aplhabet"); 11 Safe.ArgumentNotNull(alphabet, "aplhabet");
12 12
13 m_alphabet = alphabet; 13 m_alphabet = alphabet;
14 } 14 }
15 15
46 46
47 /// <summary> 47 /// <summary>
48 /// Optimize the specified alphabet. 48 /// Optimize the specified alphabet.
49 /// </summary> 49 /// </summary>
50 /// <param name="alphabet">Пустой алфавит, который будет зполнен в процессе оптимизации.</param> 50 /// <param name="alphabet">Пустой алфавит, который будет зполнен в процессе оптимизации.</param>
51 public RegularDFA<TInput,TTag> Optimize(IAlphabetBuilder<TInput> alphabet) { 51 public TaggedDFA<TInput,TTag> Optimize(IAlphabetBuilder<TInput> alphabet) {
52 Safe.ArgumentNotNull(alphabet, "alphabet"); 52 Safe.ArgumentNotNull(alphabet, "alphabet");
53 53
54 var dfa = new RegularDFA<TInput, TTag>(alphabet); 54 var dfa = new TaggedDFA<TInput, TTag>(alphabet);
55 55
56 var states = new DummyAlphabet(StateCount); 56 var states = new DummyAlphabet(StateCount);
57 var alphaMap = new Dictionary<int,int>(); 57 var alphaMap = new Dictionary<int,int>();
58 var stateMap = new Dictionary<int,int>(); 58 var stateMap = new Dictionary<int,int>();
59 59