예제 #1
0
        public List <string> GetAsRegularGrammar()
        {
            var    list = new List <String>();
            string temp = string.Empty;

            for (int i = 0; i < States.Count; i++)
            {
                var transitions = Transitions.FindAll(a => a.CurrentState == States[i]);
                if (transitions.Count != 0)
                {
                    temp += string.Format("{0} -> {1} {2}", transitions[0].CurrentState, transitions[0].Symbol,
                                          transitions[0].NextState);
                    for (int j = 1; j < transitions.Count; j++)
                    {
                        temp += " | ";
                        temp += string.Format("{0} {1}", transitions[j].Symbol, transitions[j].NextState);
                    }
                    list.Add(temp);
                }
                temp = string.Empty;
            }
            return(list);
        }