public AscendentDealer(GrammarDeterministicAutomata afd)
        {
            _afd = afd;
            //Para a geração dos firsts e follows
            _nonRecursiveDealer = new NonRecursiveDealer();
            _finalStatesList    = new List <GrammarState>();
            _table       = new SyntaxTable();
            _productions = new List <String>();

            //Numera todas as produções
            NumerateProductions();

            //Método que gera a tabela
            GenerateTable();
        }
        private bool NonRecursiveAnalizer(ref string feedback)
        {
            NonRecursiveDealer   dealer        = new NonRecursiveDealer();
            SimpleStack <Symbol> analizerStack = new SimpleStack <Symbol>();

            analizerStack.Push(Terminal.Initial);
            analizerStack.Push(NonTerminal.InitialSymbol);
            //Empilha código

            Token token      = null;
            bool  nextToken  = true;
            bool  errorFound = false;

            if (Lexic.ListToken != null && Lexic.ListToken.Count > 0)
            {
                //Quando um token é removido da pilha, o seu valor fica null
                while (analizerStack.Size > 0 && !errorFound)
                {
                    if (nextToken)
                    {
                        token = Lexic.NextToken();
                        if (token != null)
                        {
                            while (token.Type == TokenType.LINE_BREAK)
                            {
                                line++;
                                token = Lexic.NextToken();
                            }
                        }
                        nextToken = false;
                    }

                    Symbol symbol = analizerStack.Pop();

                    if (symbol is NonTerminal)
                    {
                        NonTerminal   nonTerminal = (NonTerminal)symbol;
                        List <Symbol> list        = nonTerminal.GetRuleForToken(token);

                        if (list != null && list.Count != 0)
                        {
                            //Coloca os elementos da lista na ordem
                            for (int i = list.Count - 1; i >= 0; i--)
                            {
                                analizerStack.Push(list[i]);
                            }
                        }
                        else
                        {
                            if (!nonTerminal.ContainsEmpty())
                            {
                                feedback  += INCOMPLETE_TENSE_MISS + nonTerminal.Value + ", linha " + line + "\r\n";
                                errorFound = true;
                            }
                            else if ((nonTerminal.Equals(NonTerminal.InitialSymbol)) && (token != null))
                            {
                                feedback  += INSTRUCTION_INVALID + token.Value + ", linha " + line + "\r\n";
                                errorFound = true;
                            }
                        }
                    }
                    else
                    {
                        if (symbol.Value != "$")
                        {
                            Terminal terminal = (Terminal)symbol;

                            if (terminal != null)
                            {
                                if (token == null)
                                {
                                    feedback  += INCOMPLETE_TENSE_MISS + terminal.Value + ", linha " + line + "\r\n";
                                    errorFound = true;
                                }
                                else
                                {
                                    if (terminal.EquivalentToToken(token))
                                    {
                                        //Seta a variável para buscar o próximo token
                                        nextToken = true;
                                    }
                                    else
                                    {
                                        feedback  += INCOMPLETE_TENSE_MISS + terminal.Value + ", linha " + line + "\r\n";
                                        errorFound = true;
                                    }
                                }
                            }
                        }
                    }
                }

                token = Lexic.NextToken();

                if ((token != null) && (token.Type != TokenType.LINE_BREAK) && (!errorFound))
                {
                    feedback  += INSTRUCTION_INVALID + token.Value + ", linha " + line + "\r\n";
                    errorFound = true;
                }
            }
            return(!errorFound);
        }