当前位置: 首页>>代码示例>>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;未经允许,请勿转载。