view Implab/Automaton/IDFATable.cs @ 187:dd4a3590f9c6 ref20160224

Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler Any unhandled OperationCanceledException will cause the promise cancelation
author cin
date Tue, 19 Apr 2016 17:35:20 +0300
parents 0f70905b4652
children
line wrap: on
line source

using System.Collections.Generic;


namespace Implab.Automaton {
    /// <summary>
    /// Полностью описывает DFA автомат, его поведение, состояние и входные символы.
    /// </summary>
    /// <example>
    /// class MyAutomaton {
    ///     int m_current;
    ///     readonly DFAStateDescriptor<string>[] m_automaton;
    ///     readonly IAlphabet<MyCommands> m_commands;
    /// 
    ///     public MyAutomaton(IDFADefinition&lt;MyCommands,MyStates,string&gt; definition) {
    ///         m_current = definition.StateAlphabet.Translate(MyStates.Initial);
    ///         m_automaton = definition.GetTransitionTable();
    ///         m_commands = definition.InputAlphabet;
    ///     }
    /// 
    ///     // defined a method which will move the automaton to the next state
    ///     public void Move(MyCommands cmd) {
    ///         // use transition map to determine the next state
    ///         var next = m_automaton[m_current].transitions[m_commands.Translate(cmd)];
    /// 
    ///         // validate that we aren't in the unreachable state
    ///         if (next == DFAConst.UNREACHABLE_STATE)
    ///             throw new InvalidOperationException("The specified command is invalid");
    /// 
    ///         // if everything is ok
    ///         m_current = next;
    ///     }
    /// }
    /// </example>
    public interface IDFATable : IEnumerable<AutomatonTransition> {
        int StateCount {
            get;
        }

        int AlphabetSize {
            get;
        }

        int InitialState {
            get;
        }

        bool IsFinalState(int s);

        IEnumerable<int> FinalStates {
            get;
        }
    }
}