public GrammarValidationReport PrecomputeGrammar()
        {
            ErrorHandler eh = new ErrorHandler();

            if (StartSymbol == null)
            {
                eh.AddNewError(ErrorCode.NO_START_SYMBOL_DETECTED, this);
            }

            for (int i = 0; i < RuleList.Count; i++)
            {
                Symbol lhs = RuleList[i].GetLeftHandSideOfRule();
                if (CheckIsSymbolANullStringSymbol(lhs))
                {
                    eh.AddNewError(ErrorCode.NULL_STRING_SYMBOL_ON_LHS, RuleList[i]);
                }
                if (!NonTerminalsList.Contains(lhs))
                {
                    NonTerminalsList.Add(lhs);
                }
            }
            ;

            if (!NonTerminalsList.Contains(StartSymbol))
            {
                eh.AddNewError(ErrorCode.NO_START_SYMBOL_IN_LHS_OF_RULES, this);
            }

            for (int i = 0; i < RuleList.Count; i++)
            {
                List <Symbol> rhs = RuleList[i].GetRightHandSideOfRule();
                if (rhs.Count < 1)
                {
                    eh.AddNewError(ErrorCode.RHS_HAS_NO_SYMBOLS, RuleList[i]);
                }

                for (int j = 0; j < rhs.Count; j++)
                {
                    Symbol symbol = rhs[j];
                    if (CheckIsSymbolANullStringSymbol(symbol) && rhs.Count > 1)
                    {
                        eh.AddNewError(ErrorCode.NULL_STRING_SYMBOL_NOT_ALONE_ON_RHS, RuleList[i]);
                    }
                    if (!NonTerminalsList.Contains(symbol) && !TerminalsList.Contains(symbol))
                    {
                        TerminalsList.Add(symbol);
                    }
                }
            }
            ;

            GrammarValidationReport report = new GrammarValidationReport(eh.GetErrorDescriptionList());

            _IsGrammarValid = report.isSuccessfull;
            return(report);
        }
 private void CheckGrammar(Grammar grammar)
 {
     if (grammar == null)
     {
         _errorHandler.AddNewError(ErrorCode.NO_GRAMMAR, grammar);
         return;
     }
     else if (!grammar.IsGrammarValid())
     {
         GrammarValidationReport er = grammar.PrecomputeGrammar();
         if (!er.isSuccessfull)
         {
             _errorHandler.AddNewError(ErrorCode.INCORRECT_GRAMMAR, grammar);
             return;
         }
     }
 }