예제 #1
0
            internal static ProductDfaState <TSymbol> MakeDeadState()
            {
                var result = new ProductDfaState <TSymbol> {
                    _accepting = 0
                };

                result._transitions = new[]
                { new KeyValuePair <TSymbol, ProductDfaState <TSymbol> >(default(TSymbol), result) };
                return(result);
            }
예제 #2
0
        internal static MinimizedDfa <TSymbol> MakeEmptyLanguageDfa <TSymbol>()
            where TSymbol : IComparable <TSymbol>, IEquatable <TSymbol>
        {
            var result = new ProductDfa <TSymbol> {
                _start = ProductDfaState <TSymbol> .MakeDeadState()
            }
            .Minimized <ProductDfa <TSymbol>, ProductDfaState <TSymbol>, TSymbol>();

            DfaStatesConcpetCheck <TSymbol> .CheckDfaStates(result);

            return(result);
        }
예제 #3
0
            private ProductDfaState <TSymbol> GetProductState(TLastDfaState lastDfaState, TNewDfaState newDfaState)
            {
                var statePack = new Tuple <TLastDfaState, TNewDfaState>(lastDfaState, newDfaState);

                if (_productionMapping.ContainsKey(statePack))
                {
                    return(_productionMapping[statePack]);
                }
                // Tworzę stub stanu, tak aby można było się do niego odnosić
                var productState = new ProductDfaState <TSymbol>
                {
                    _accepting = _getProductAccepting(lastDfaState.Accepting, newDfaState.Accepting)
                };

                _productionMapping[statePack] = productState;
                // Przygotowuję przejścia
                var productTransitions = MakeProductTransitions(lastDfaState.Transitions, newDfaState.Transitions);

                // Zapisuję wygenerowane przejścia w stanie
                productState._transitions = productTransitions.ToArray();
                // Stan jest gotowy
                return(productState);
            }