Antlr3.Analysis.DecisionProbe.IssueWarnings C# (CSharp) Method

IssueWarnings() public method

public IssueWarnings ( ) : void
return void
        public virtual void IssueWarnings()
        {
            // NONREGULAR DUE TO RECURSION > 1 ALTS
            // Issue this before aborted analysis, which might also occur
            // if we take too long to terminate
            if ( _nonLLStarDecision && !_dfa.AutoBacktrackMode )
            {
                ErrorManager.NonLLStarDecision( this );
            }

            IssueRecursionWarnings();

            // generate a separate message for each problem state in DFA
            ICollection<DFAState> resolvedStates = NondeterministicStatesResolvedWithSemanticPredicate;
            ICollection<DFAState> problemStates = DFAStatesWithSyntacticallyAmbiguousAlts;
            foreach (DFAState d in problemStates)
            {
                if (_dfa.Nfa.Grammar.NFAToDFAConversionExternallyAborted())
                    break;

                IDictionary<int, ICollection<IToken>> insufficientAltToLocations = GetIncompletelyCoveredAlts(d);
                if (insufficientAltToLocations != null && insufficientAltToLocations.Count > 0)
                {
                    ErrorManager.InsufficientPredicates(this, d, insufficientAltToLocations);
                }
                // don't report problem if resolved
                if (resolvedStates == null || !resolvedStates.Contains(d))
                {
                    // first strip last alt from disableAlts if it's wildcard
                    // then don't print error if no more disable alts
                    List<int> disabledAlts = GetDisabledAlternatives(d).ToList();
                    StripWildCardAlts(disabledAlts);
                    if (disabledAlts.Count > 0)
                    {
                        // nondeterminism; same input predicts multiple alts.
                        // but don't emit error if greedy=true explicitly set
                        bool explicitlyGreedy = false;
                        GrammarAST blockAST = d.Dfa.Nfa.Grammar.GetDecisionBlockAST(d.Dfa.DecisionNumber);
                        if (blockAST != null)
                        {
                            string greedyS = (string)blockAST.GetBlockOption("greedy");
                            if (greedyS != null && greedyS.Equals("true"))
                                explicitlyGreedy = true;
                        }

                        if (!explicitlyGreedy)
                            ErrorManager.Nondeterminism(this, d);
                    }
                }
            }

            ICollection<DFAState> danglingStates = DanglingStates;
            if ( danglingStates.Count > 0 )
            {
                //Console.Error.WriteLine( "no emanating edges for states: " + danglingStates );
                foreach ( DFAState d in danglingStates )
                {
                    ErrorManager.DanglingState( this, d );
                }
            }

            if ( !_nonLLStarDecision )
            {
                var unreachableAlts = _dfa.UnreachableAlts;
                if ( unreachableAlts != null && unreachableAlts.Count > 0 )
                {
                    // give different msg if it's an empty Tokens rule from delegate
                    bool isInheritedTokensRule = false;
                    if ( _dfa.IsTokensRuleDecision )
                    {
                        foreach ( int altI in unreachableAlts )
                        {
                            GrammarAST decAST = _dfa.DecisionASTNode;
                            GrammarAST altAST = (GrammarAST)decAST.GetChild( altI - 1 );
                            GrammarAST delegatedTokensAlt =
                                (GrammarAST)altAST.GetFirstChildWithType( ANTLRParser.DOT );
                            if ( delegatedTokensAlt != null )
                            {
                                isInheritedTokensRule = true;
                                ErrorManager.GrammarWarning( ErrorManager.MSG_IMPORTED_TOKENS_RULE_EMPTY,
                                                            _dfa.Nfa.Grammar,
                                                            null,
                                                            _dfa.Nfa.Grammar.name,
                                                            delegatedTokensAlt.GetChild( 0 ).Text );
                            }
                        }
                    }
                    if ( isInheritedTokensRule )
                    {
                    }
                    else
                    {
                        ErrorManager.UnreachableAlts( this, unreachableAlts );
                    }
                }
            }
        }