diff Implab/Parsing/DFADefinition.cs @ 160:5802131432e4 v2

fixed regression: race condition in Promise DFA refactoring
author cin
date Thu, 18 Feb 2016 19:38:54 +0300
parents 5558e43c79bb
children 2a8466f0cb8a
line wrap: on
line diff
--- a/Implab/Parsing/DFADefinition.cs	Thu Feb 18 16:06:14 2016 +0300
+++ b/Implab/Parsing/DFADefinition.cs	Thu Feb 18 19:38:54 2016 +0300
@@ -66,8 +66,8 @@
             m_states[s1].transitions[symbol] = s2;
         }
 
-        public void Optimize<TA>(IDFADefinition minimalDFA,IAlphabet<TA> sourceAlphabet, IAlphabet<TA> minimalAlphabet) {
-            Safe.ArgumentNotNull(minimalDFA, "minimalDFA");
+        protected IDFADefinition Optimize<TA>(Func<IAlphabet<TA>, IDFADefinition> dfaFactory,IAlphabet<TA> sourceAlphabet, IAlphabet<TA> minimalAlphabet) {
+            Safe.ArgumentNotNull(dfaFactory, "dfaFactory");
             Safe.ArgumentNotNull(minimalAlphabet, "minimalAlphabet");
 
             var setComparer = new CustomEqualityComparer<HashSet<int>>(
@@ -211,6 +211,8 @@
             
             // построение автомата
 
+            var minimalDFA = dfaFactory(minimalAlphabet);
+
             var states = new int[ optimalMap.Length ];
             states[0] = UNREACHEBLE_STATE;
             
@@ -237,6 +239,7 @@
                 }
             }
 
+            return minimalDFA;
         }
 
         public void PrintDFA<TA>(IAlphabet<TA> alphabet) {