Antlr3.Tool.Grammar.CreateLookaheadDFA C# (CSharp) Method

CreateLookaheadDFA() public method

public CreateLookaheadDFA ( int decision, bool wackTempStructures ) : Antlr3.Analysis.DFA
decision int
wackTempStructures bool
return Antlr3.Analysis.DFA
        public virtual DFA CreateLookaheadDFA( int decision, bool wackTempStructures )
        {
            Decision d = GetDecision( decision );
            string enclosingRule = d.startState.enclosingRule.Name;
            Rule r = d.startState.enclosingRule;

            //[email protected]("createLookaheadDFA(): "+enclosingRule+" dec "+decision+"; synprednames prev used "+synPredNamesUsedInDFA);
            NFAState decisionStartState = GetDecisionNFAStartState( decision );
            DateTime startDFA = DateTime.MinValue;
            DateTime stopDFA = DateTime.MinValue;
            if ( composite.WatchNFAConversion )
            {
                Console.Out.WriteLine( "--------------------\nbuilding lookahead DFA (d="
                                   + decisionStartState.DecisionNumber + ") for " +
                                   decisionStartState.Description );
                startDFA = DateTime.Now;
            }

            DFA lookaheadDFA = DFA.CreateFromNfa( decision, decisionStartState );
            // Retry to create a simpler DFA if analysis failed (non-LL(*),
            // recursion overflow, or time out).
            bool failed =
                lookaheadDFA.Probe.IsNonLLStarDecision ||
                lookaheadDFA.Probe.AnalysisOverflowed;
            if ( failed && lookaheadDFA.OkToRetryWithK1 )
            {
                // set k=1 option and try again.
                // First, clean up tracking stuff
                decisionsWhoseDFAsUsesSynPreds.Remove( lookaheadDFA );
                // TODO: clean up synPredNamesUsedInDFA also (harder)
                d.blockAST.SetBlockOption( this, "k", 1 );
                if ( composite.WatchNFAConversion )
                {
                    Console.Out.Write( "trying decision " + decision +
                                     " again with k=1; reason: " +
                                     lookaheadDFA.ReasonForFailure );
                }
                lookaheadDFA = null; // make sure other memory is "free" before redoing
                lookaheadDFA = DFA.CreateFromNfa( decision, decisionStartState );
            }

            SetLookaheadDFA( decision, lookaheadDFA );

            if ( wackTempStructures )
            {
                foreach ( DFAState s in lookaheadDFA.UniqueStates.Values )
                {
                    s.Reset();
                }
            }

            // create map from line:col to decision DFA (for ANTLRWorks)
            UpdateLineColumnToLookaheadDFAMap( lookaheadDFA );

            if ( composite.WatchNFAConversion )
            {
                stopDFA = DateTime.Now;
                Console.Out.WriteLine( "cost: " + lookaheadDFA.NumberOfStates +
                                   " states, " + (int)( stopDFA - startDFA ).TotalMilliseconds + " ms" );
            }
            //[email protected]("after create DFA; synPredNamesUsedInDFA="+synPredNamesUsedInDFA);
            return lookaheadDFA;
        }
Grammar