本文整理匯總了C#中Antlr3.Tool.Grammar.GetLookaheadDFA方法的典型用法代碼示例。如果您正苦於以下問題:C# Antlr3.Tool.Grammar.GetLookaheadDFA方法的具體用法?C# Antlr3.Tool.Grammar.GetLookaheadDFA怎麽用?C# Antlr3.Tool.Grammar.GetLookaheadDFA使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Antlr3.Tool.Grammar
的用法示例。
在下文中一共展示了Antlr3.Tool.Grammar.GetLookaheadDFA方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TestFiniteCommonLeftPrefixes
public void TestFiniteCommonLeftPrefixes()
{
Grammar g = new Grammar(
"lexer grammar t;\n" +
"A : 'a' 'b' | 'a' 'c' | 'd' 'e' ;" );
g.BuildNFA();
g.CreateLookaheadDFAs( false );
DFA dfa = g.GetLookaheadDFA( 1 );
checkPrediction( dfa, "ab", 1 );
checkPrediction( dfa, "ac", 2 );
checkPrediction( dfa, "de", 3 );
checkPrediction( dfa, "q", NFA.INVALID_ALT_NUMBER );
}
示例2: TestSets
public void TestSets()
{
Grammar g = new Grammar(
"lexer grammar t;\n" +
"A : {;}'a'..'z' | ';' | '0'..'9' ;" );
g.BuildNFA();
g.CreateLookaheadDFAs( false );
DFA dfa = g.GetLookaheadDFA( 1 );
checkPrediction( dfa, "a", 1 );
checkPrediction( dfa, "q", 1 );
checkPrediction( dfa, "z", 1 );
checkPrediction( dfa, ";", 2 );
checkPrediction( dfa, "9", 3 );
}
示例3: TestSimpleAltCharTest
public void TestSimpleAltCharTest()
{
Grammar g = new Grammar(
"lexer grammar t;\n" +
"A : {;}'a' | 'b' | 'c';" );
g.BuildNFA();
g.CreateLookaheadDFAs( false );
DFA dfa = g.GetLookaheadDFA( 1 );
checkPrediction( dfa, "a", 1 );
checkPrediction( dfa, "b", 2 );
checkPrediction( dfa, "c", 3 );
checkPrediction( dfa, "d", NFA.INVALID_ALT_NUMBER );
}
示例4: TestSimpleLoops
public void TestSimpleLoops()
{
Grammar g = new Grammar(
"lexer grammar t;\n" +
"A : (DIGIT)+ '.' DIGIT | (DIGIT)+ ;\n" +
"fragment DIGIT : '0'..'9' ;\n" );
g.BuildNFA();
g.CreateLookaheadDFAs( false );
DFA dfa = g.GetLookaheadDFA( 3 );
checkPrediction( dfa, "32", 2 );
checkPrediction( dfa, "999.2", 1 );
checkPrediction( dfa, ".2", NFA.INVALID_ALT_NUMBER );
}