本文整理汇总了C#中Antlr3.Tool.Grammar.GetNumberOfCyclicDecisions方法的典型用法代码示例。如果您正苦于以下问题:C# Grammar.GetNumberOfCyclicDecisions方法的具体用法?C# Grammar.GetNumberOfCyclicDecisions怎么用?C# Grammar.GetNumberOfCyclicDecisions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Antlr3.Tool.Grammar
的用法示例。
在下文中一共展示了Grammar.GetNumberOfCyclicDecisions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetReportData
public static ReportData GetReportData(Grammar g)
{
ReportData data = new ReportData();
data.version = Version;
data.gname = g.name;
data.gtype = g.GrammarTypeString;
data.language = (string)g.GetOption("language");
data.output = (string)g.GetOption("output");
if (data.output == null)
{
data.output = "none";
}
string k = (string)g.GetOption("k");
if (k == null)
{
k = "none";
}
data.grammarLevelk = k;
string backtrack = (string)g.GetOption("backtrack");
if (backtrack == null)
{
backtrack = "false";
}
data.grammarLevelBacktrack = backtrack;
int totalNonSynPredProductions = 0;
int totalNonSynPredRules = 0;
ICollection<Rule> rules = g.Rules;
foreach (Rule r in rules)
{
if (!r.Name.StartsWith(Grammar.SynpredRulePrefix, StringComparison.OrdinalIgnoreCase))
{
totalNonSynPredProductions += r.NumberOfAlts;
totalNonSynPredRules++;
}
}
data.numRules = totalNonSynPredRules;
data.numOuterProductions = totalNonSynPredProductions;
int numACyclicDecisions =
g.NumberOfDecisions - g.GetNumberOfCyclicDecisions();
List<int> depths = new List<int>();
int[] acyclicDFAStates = new int[numACyclicDecisions];
int[] cyclicDFAStates = new int[g.GetNumberOfCyclicDecisions()];
int acyclicIndex = 0;
int cyclicIndex = 0;
int numLL1 = 0;
int blocksWithSynPreds = 0;
int dfaWithSynPred = 0;
int numDecisions = 0;
int numCyclicDecisions = 0;
for (int i = 1; i <= g.NumberOfDecisions; i++)
{
Grammar.Decision d = g.GetDecision(i);
if (d.dfa == null)
{
//System.out.println("dec "+d.decision+" has no AST");
continue;
}
Rule r = d.dfa.NFADecisionStartState.enclosingRule;
if (r.Name.StartsWith(Grammar.SynpredRulePrefix, StringComparison.OrdinalIgnoreCase))
{
//System.out.println("dec "+d.decision+" is a synpred");
continue;
}
numDecisions++;
if (BlockHasSynPred(d.blockAST))
blocksWithSynPreds++;
//if (g.decisionsWhoseDFAsUsesSynPreds.contains(d.dfa))
// dfaWithSynPred++;
if (d.dfa.HasSynPred)
dfaWithSynPred++;
// NFAState decisionStartState = g.getDecisionNFAStartState(d.decision);
// int nalts = g.getNumberOfAltsForDecisionNFA(decisionStartState);
// for (int alt = 1; alt <= nalts; alt++) {
// int walkAlt =
// decisionStartState.translateDisplayAltToWalkAlt(alt);
// NFAState altLeftEdge = g.getNFAStateForAltOfDecision(decisionStartState, walkAlt);
// }
// int nalts = g.getNumberOfAltsForDecisionNFA(d.dfa.decisionNFAStartState);
// for (int a=1; a<nalts; a++) {
// NFAState altStart =
// g.getNFAStateForAltOfDecision(d.dfa.decisionNFAStartState, a);
// }
if (!d.dfa.IsCyclic)
{
if (d.dfa.IsClassicDFA)
{
int maxk = d.dfa.MaxLookaheadDepth;
//System.out.println("decision "+d.dfa.decisionNumber+" k="+maxk);
if (maxk == 1)
numLL1++;
depths.Add(maxk);
}
//.........这里部分代码省略.........