public SyntaxScanner(List <LexemDataCell> table)
        {
            lexemTable    = new List <LexemDataCell>(table);
            stack         = new SymbolsStack(SpecialSymbs.START_SYMB);
            movingMatrix  = new MovingMatrix();
            rules         = new RulesMatrix();
            usedRulesList = new List <int>();

            //Logger.Debug("SyntaxScanner created!");
        }
        static void SymbolsStackTest()
        {
            SymbolsStack s = new SymbolsStack();

            string[] strs = { "1", "2", "3", "4", "5" };

            s.Push(strs[0]);
            s.Push(strs[1]);
            Debug.Assert(s.Lenght == 2);

            string poped = s.Pop();

            Debug.Assert(poped.Equals(strs[1]));
            Debug.Assert(s.Lenght == 1);

            s.Push(strs[1]);
            s.Push(strs[2]);
            Debug.Assert(s.Lenght == 3);
            string getted = s.GetFirstTerminalSymb();

            Debug.Assert(s.Lenght == 3);
            Debug.Assert(getted.Equals(strs[2]));

            s.Push(SpecialSymbs.NOT_TERMINAL_SYMB);
            Debug.Assert(s.Lenght == 4);
            getted = s.GetFirstTerminalSymb();
            Debug.Assert(s.Lenght == 4);
            Debug.Assert(getted.Equals(strs[2]));

            s = new SymbolsStack();
            for (int i = 0; i < 100; i++)
            {
                s.Push(Convert.ToString(i));
            }
            Debug.Assert(s.Lenght == 100);
            for (int i = 99; i >= 0; i--)
            {
                Debug.Assert(Convert.ToString(i).Equals(s.Pop()));
            }
            Debug.Assert(s.Lenght == 0);
        }
Exemple #3
0
 public string ToString(Grammar grammar)
 {
     return(String.Join(" ", SymbolsStack.Reverse().Select(s => grammar.Userify(s.Symbol))));
 }