diff Implab/Automaton/RegularExpressions/Grammar.cs @ 164:ec35731ae299 ref20160224

Almost complete DFA refactoring
author cin
date Thu, 25 Feb 2016 02:11:13 +0300
parents 419aa51b04fd
children e227e78d72e4
line wrap: on
line diff
--- a/Implab/Automaton/RegularExpressions/Grammar.cs	Wed Feb 24 20:12:52 2016 +0300
+++ b/Implab/Automaton/RegularExpressions/Grammar.cs	Thu Feb 25 02:11:13 2016 +0300
@@ -71,14 +71,16 @@
         protected CDFADefinition BuildDFA(Token<TTag> lang) {
             Safe.ArgumentNotNull(lang, "lang");
 
-            var dfa = new CDFADefinition(Alphabet);
-            
+            var dfa = new RegularDFADefinition<TSymbol, TTag>(Alphabet, 0);
+
+            var table = new DFATransitionTable<TTag>();
+
             var builder = new RegularDFABuilder<TTag>();
 
             lang.Accept( builder );
 
-            builder.BuildDFA(dfa);
-            if (dfa.InitialStateIsFinal)
+            var initialState = builder.BuildDFA(table);
+            if (table.IsFinalState(initialState))
                 throw new ApplicationException("The specified language contains empty token");
 
             return dfa.Optimize();