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


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

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


在下文中一共展示了Antlr3.Tool.Grammar.GetRule方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestA

 public void TestA()
 {
     Grammar g = new Grammar(
             "parser grammar P;\n" +
             "a : A;" );
     string expecting =
         "(rule a ARG RET scope (BLOCK (ALT A <end-of-alt>) <end-of-block>) <end-of-rule>)";
     string found = g.GetRule( "a" ).tree.ToStringTree();
     assertEquals( expecting, found );
 }
開發者ID:bszafko,項目名稱:antlrcs,代碼行數:10,代碼來源:TestASTConstruction.cs

示例2: TestActionInStarLoop

 public void TestActionInStarLoop()
 {
     Grammar g = new Grammar(
             "grammar Expr;\n" +
             "options { backtrack=true; }\n" +
             "a : ({blort} 'x')* ;\n" );  // bug: the synpred had nothing in it
     string expecting =
         "(rule synpred1_Expr ARG RET scope (BLOCK (ALT blort 'x' <end-of-alt>) <end-of-block>) <end-of-rule>)";
     string found = g.GetRule( "synpred1_Expr" ).tree.ToStringTree();
     assertEquals( expecting, found );
 }
開發者ID:bszafko,項目名稱:antlrcs,代碼行數:11,代碼來源:TestASTConstruction.cs

示例3: TestStringStar

 public void TestStringStar()
 {
     Grammar g = new Grammar(
             "grammar P;\n" +
             "a : 'while'*;" );
     string expecting =
         "(rule a ARG RET scope (BLOCK (ALT (* (BLOCK (ALT 'while' <end-of-alt>) <end-of-block>)) <end-of-alt>) <end-of-block>) <end-of-rule>)";
     string found = g.GetRule( "a" ).tree.ToStringTree();
     assertEquals( expecting, found );
 }
開發者ID:bszafko,項目名稱:antlrcs,代碼行數:10,代碼來源:TestASTConstruction.cs

示例4: TestSetLabel

 public void TestSetLabel()
 {
     Grammar g = new Grammar(
             "grammar P;\n" +
             "a : x=(A|B);\n" );
     string expecting =
         "(rule a ARG RET scope (BLOCK (ALT (= x (BLOCK (ALT A <end-of-alt>) (ALT B <end-of-alt>) <end-of-block>)) <end-of-alt>) <end-of-block>) <end-of-rule>)";
     string found = g.GetRule( "a" ).tree.ToStringTree();
     assertEquals( expecting, found );
 }
開發者ID:bszafko,項目名稱:antlrcs,代碼行數:10,代碼來源:TestASTConstruction.cs

示例5: TestRuleListLabelOfPositiveClosure

 public void TestRuleListLabelOfPositiveClosure()
 {
     Grammar g = new Grammar(
             "grammar P;\n" +
             "options {output=AST;}\n" +
             "a : x+=b+;\n" +
             "b : ID;\n" );
     string expecting =
         "(rule a ARG RET scope (BLOCK (ALT (+ (BLOCK (ALT (+= x b) <end-of-alt>) <end-of-block>)) <end-of-alt>) <end-of-block>) <end-of-rule>)";
     string found = g.GetRule( "a" ).tree.ToStringTree();
     assertEquals( expecting, found );
 }
開發者ID:bszafko,項目名稱:antlrcs,代碼行數:12,代碼來源:TestASTConstruction.cs

示例6: TestNakeRulePlusInLexer

 public void TestNakeRulePlusInLexer()
 {
     Grammar g = new Grammar(
             "lexer grammar P;\n" +
             "A : B+;\n" +
             "B : 'a';" );
     string expecting =
         "(rule A ARG RET scope (BLOCK (ALT (+ (BLOCK (ALT B <end-of-alt>) <end-of-block>)) <end-of-alt>) <end-of-block>) <end-of-rule>)";
     string found = g.GetRule( "A" ).tree.ToStringTree();
     assertEquals( expecting, found );
 }
開發者ID:bszafko,項目名稱:antlrcs,代碼行數:11,代碼來源:TestASTConstruction.cs

示例7: TestNakedRuleOptional

 public void TestNakedRuleOptional()
 {
     Grammar g = new Grammar(
             "parser grammar P;\n" +
             "a : b?;\n" +
             "b : B;" );
     string expecting =
         "(rule a ARG RET scope (BLOCK (ALT (? (BLOCK (ALT b <end-of-alt>) <end-of-block>)) <end-of-alt>) <end-of-block>) <end-of-rule>)";
     string found = g.GetRule( "a" ).tree.ToStringTree();
     assertEquals( expecting, found );
 }
開發者ID:bszafko,項目名稱:antlrcs,代碼行數:11,代碼來源:TestASTConstruction.cs

示例8: TestEmptyAlt

 public void TestEmptyAlt()
 {
     Grammar g = new Grammar(
             "parser grammar P;\n" +
             "a : ;");
     string expecting =
         "(rule a ARG RET scope (BLOCK (ALT epsilon <end-of-alt>) <end-of-block>) <end-of-rule>)";
     string found = g.GetRule("a").Tree.ToStringTree();
     Assert.AreEqual(expecting, found);
 }
開發者ID:mahanteshck,項目名稱:antlrcs,代碼行數:10,代碼來源:TestASTConstruction.cs

示例9: TestCharOptional

 public void TestCharOptional()
 {
     Grammar g = new Grammar(
             "grammar P;\n" +
             "a : 'a'?;" );
     string expecting =
         "(rule a ARG RET scope (BLOCK (ALT (? (BLOCK (ALT 'a' <end-of-alt>) <end-of-block>)) <end-of-alt>) <end-of-block>) <end-of-rule>)";
     string found = g.GetRule( "a" ).tree.ToStringTree();
     assertEquals( expecting, found );
 }
開發者ID:bszafko,項目名稱:antlrcs,代碼行數:10,代碼來源:TestASTConstruction.cs

示例10: ActionTranslator

 public ActionTranslator( CodeGenerator generator,
                              string ruleName,
                              IToken actionToken,
                              int outerAltNum )
     : this(new ANTLRStringStream( actionToken.Text ))
 {
     this.generator = generator;
     grammar = generator.grammar;
     this.enclosingRule = grammar.GetRule( ruleName );
     this.actionToken = actionToken;
     this.outerAltNum = outerAltNum;
 }
開發者ID:bszafko,項目名稱:antlrcs,代碼行數:12,代碼來源:ActionTranslatorHelper.cs

示例11: TestStringStarInLexer

 public void TestStringStarInLexer()
 {
     Grammar g = new Grammar(
             "lexer grammar P;\n" +
             "B : 'while'*;" );
     string expecting =
         "(rule B ARG RET scope (BLOCK (ALT (* (BLOCK (ALT 'while' <end-of-alt>) <end-of-block>)) <end-of-alt>) <end-of-block>) <end-of-rule>)";
     string found = g.GetRule( "B" ).Tree.ToStringTree();
     Assert.AreEqual( expecting, found );
 }
開發者ID:mahanteshck,項目名稱:antlrcs,代碼行數:10,代碼來源:TestASTConstruction.cs

示例12: TestRuleStar

 public void TestRuleStar()
 {
     Grammar g = new Grammar(
             "parser grammar P;\n" +
             "a : (b)*;\n" +
             "b : B;" );
     string expecting =
         "(rule a ARG RET scope (BLOCK (ALT (* (BLOCK (ALT b <end-of-alt>) <end-of-block>)) <end-of-alt>) <end-of-block>) <end-of-rule>)";
     string found = g.GetRule( "a" ).Tree.ToStringTree();
     Assert.AreEqual( expecting, found );
 }
開發者ID:mahanteshck,項目名稱:antlrcs,代碼行數:11,代碼來源:TestASTConstruction.cs

示例13: TestRuleLabelOfPositiveClosure

 public void TestRuleLabelOfPositiveClosure()
 {
     Grammar g = new Grammar(
             "grammar P;\n" +
             "a : x=b+;\n" +
             "b : ID;\n" );
     string expecting =
         "(rule a ARG RET scope (BLOCK (ALT (+ (BLOCK (ALT (= x b) <end-of-alt>) <end-of-block>)) <end-of-alt>) <end-of-block>) <end-of-rule>)";
     string found = g.GetRule( "a" ).Tree.ToStringTree();
     Assert.AreEqual( expecting, found );
 }
開發者ID:mahanteshck,項目名稱:antlrcs,代碼行數:11,代碼來源:TestASTConstruction.cs

示例14: TestRootTokenInStarLoop

 public void TestRootTokenInStarLoop()
 {
     Grammar g = new Grammar(
             "grammar Expr;\n" +
             "options { backtrack=true; }\n" +
             "a : ('*'^)* ;\n" );  // bug: the synpred had nothing in it
     string expecting =
         "(rule synpred1_Expr ARG RET scope (BLOCK (ALT '*' <end-of-alt>) <end-of-block>) <end-of-rule>)";
     string found = g.GetRule( "synpred1_Expr" ).Tree.ToStringTree();
     Assert.AreEqual( expecting, found );
 }
開發者ID:mahanteshck,項目名稱:antlrcs,代碼行數:11,代碼來源:TestASTConstruction.cs

示例15: TestNotSetListLabelInLoop

 public void TestNotSetListLabelInLoop()
 {
     Grammar g = new Grammar(
             "grammar P;\n" +
             "a : x+=~(A|B)+;\n" );
     string expecting =
         "(rule a ARG RET scope (BLOCK (ALT (+ (BLOCK (ALT (+= x (~ (BLOCK (ALT A <end-of-alt>) (ALT B <end-of-alt>) <end-of-block>))) <end-of-alt>) <end-of-block>)) <end-of-alt>) <end-of-block>) <end-of-rule>)";
     string found = g.GetRule( "a" ).Tree.ToStringTree();
     Assert.AreEqual( expecting, found );
 }
開發者ID:mahanteshck,項目名稱:antlrcs,代碼行數:10,代碼來源:TestASTConstruction.cs


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