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

GetDecision() protected method

protected GetDecision ( int decision ) : Decision
decision int
return Decision
        protected internal virtual Decision GetDecision( int decision )
        {
            int index = decision - 1;
            if ( index >= indexToDecision.Count )
            {
                return null;
            }
            Decision d = indexToDecision[index];
            return d;
        }

Usage Example

Beispiel #1
0
        internal virtual void Stats(Grammar g, StringBuilder buf)
        {
            int numDec = g.NumberOfDecisions;
            for (int decision = 1; decision <= numDec; decision++)
            {
                Grammar.Decision d = g.GetDecision(decision);
                if (d.dfa == null)
                { // unusued decisions in auto synpreds
                    //System.err.println("no decision "+decision+" dfa for "+d.blockAST.toStringTree());
                    continue;
                }
                int k = d.dfa.MaxLookaheadDepth;
                Rule enclosingRule = d.dfa.NFADecisionStartState.enclosingRule;
                if (enclosingRule.IsSynPred)
                    continue; // don't count synpred rules
                buf.Append(g.name + "." + enclosingRule.Name + ":" +
                           "");
                GrammarAST decisionAST =
                    d.dfa.NFADecisionStartState.associatedASTNode;
                buf.Append(decisionAST.Line);
                buf.Append(":");
                buf.Append(decisionAST.CharPositionInLine);
                buf.Append(" decision " + decision + ":");

                if (d.dfa.IsCyclic)
                    buf.Append(" cyclic");
                if (k != int.MaxValue)
                    buf.Append(" k=" + k); // fixed, no sempreds
                if (d.dfa.HasSynPred)
                    buf.Append(" backtracks"); // isolated synpred not gated
                if (d.dfa.HasSemPred)
                    buf.Append(" sempred"); // user-defined sempred
                //			else {
                //				buf.append("undefined");
                //				FASerializer serializer = new FASerializer(g);
                //				String result = serializer.serialize(d.dfa.startState);
                //				System.err.println(result);
                //			}
                buf.AppendLine();
            }
        }
All Usage Examples Of Antlr3.Tool.Grammar::GetDecision
Grammar