當前位置: 首頁>>代碼示例>>C#>>正文


C# Antlr3.Tool.Grammar.BuildNFA方法代碼示例

本文整理匯總了C#中Antlr3.Tool.Grammar.BuildNFA方法的典型用法代碼示例。如果您正苦於以下問題:C# Antlr3.Tool.Grammar.BuildNFA方法的具體用法?C# Antlr3.Tool.Grammar.BuildNFA怎麽用?C# Antlr3.Tool.Grammar.BuildNFA使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Antlr3.Tool.Grammar的用法示例。


在下文中一共展示了Antlr3.Tool.Grammar.BuildNFA方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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 );
 }
開發者ID:bszafko,項目名稱:antlrcs,代碼行數:13,代碼來源:TestDFAMatching.cs

示例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 );
 }
開發者ID:bszafko,項目名稱:antlrcs,代碼行數:14,代碼來源:TestDFAMatching.cs

示例3: checkRule

        private void checkRule( Grammar g, string rule, string expecting )
        {
            g.BuildNFA();
            State startState = g.GetRuleStartState( rule );
            FASerializer serializer = new FASerializer( g );
            string result = serializer.Serialize( startState );

            //System.out.print(result);
            Assert.AreEqual( expecting, result );
        }
開發者ID:JSchofield,項目名稱:antlrcs,代碼行數:10,代碼來源:TestNFAConstruction.cs

示例4: PerformGrammarAnalysis

        protected internal virtual void PerformGrammarAnalysis( CodeGenerator generator,
                                              Grammar grammar )
        {
            // Build NFAs from the grammar AST
            grammar.BuildNFA();

            // Create the DFA predictors for each decision
            grammar.CreateLookaheadDFAs();
        }
開發者ID:bszafko,項目名稱:antlrcs,代碼行數:9,代碼來源:Target.cs

示例5: 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 );
 }
開發者ID:bszafko,項目名稱:antlrcs,代碼行數:13,代碼來源:TestDFAMatching.cs

示例6: 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 );
 }
開發者ID:bszafko,項目名稱:antlrcs,代碼行數:13,代碼來源:TestDFAMatching.cs


注:本文中的Antlr3.Tool.Grammar.BuildNFA方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。