Esempio n. 1
0
 public abstract void DoThings(int action, DFA <Token, Function> dfa);
Esempio n. 2
0
        /// <summary>
        /// Get next state
        /// </summary>
        /// <param name="action">action (letter eg.), if ation less then 0, means get else state</param>
        /// <param name="dfa">DFA that call this state</param>
        /// <returns>next state id</returns>
        public virtual int NextState(int action, DFA <Token, Function> dfa, out bool isElseAction)
        {
            Debug.Assert(NextStateIds != null);

            isElseAction = false;

            if (action < 0)
            {
                isElseAction = true;
                return(ElseStateId);
            }


            if (NextStateIdDict != null)
            {
                int nextState;
                if (NextStateIdDict.TryGetValue(action, out nextState))
                {
                    if (nextState < 0)
                    {
                        isElseAction = true;
                        return(ElseStateId);
                    }
                    else
                    {
                        return(nextState);
                    }
                }
                else
                {
                    isElseAction = true;
                    return(ElseStateId);
                }
            }
            else
            {
                if (NextStateIds == null)
                {
                    isElseAction = true;
                    return(ElseStateId);
                }

                if (action >= NextStateIds.Length)
                {
                    isElseAction = true;
                    return(ElseStateId);
                }
                else
                {
                    int nextState = NextStateIds[action];

                    if (nextState < 0)
                    {
                        isElseAction = true;
                        return(ElseStateId);
                    }
                    else
                    {
                        return(nextState);
                    }
                }
            }
        }