• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# AntlrUnitTests.ErrorQueue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中AntlrUnitTests.ErrorQueue的典型用法代码示例。如果您正苦于以下问题:C# ErrorQueue类的具体用法?C# ErrorQueue怎么用?C# ErrorQueue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ErrorQueue类属于AntlrUnitTests命名空间,在下文中一共展示了ErrorQueue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Test0IndexedGlobalScope

        public void Test0IndexedGlobalScope()
        {
            string action = "$Symbols[0]::names.add($id.text);";
            string expecting =
                "((Symbols_scope)Symbols_stack.elementAt(0)).names.add((id!=null?id.getText():null));";

            ErrorQueue equeue = new ErrorQueue();
            ErrorManager.SetErrorListener( equeue );
            Grammar g = new Grammar(
                "grammar t;\n" +
                "scope Symbols {\n" +
                "  int n;\n" +
                "  List names;\n" +
                "}\n" +
                "a scope Symbols; : (id=ID ';' {" + action + "} )+\n" +
                "  ;\n" +
                "ID : 'a';\n" );
            AntlrTool antlr = newTool();
            CodeGenerator generator = new CodeGenerator( antlr, g, "Java" );
            g.CodeGenerator = generator;
            generator.GenRecognizer(); // forces load of templates
            ActionTranslator translator = new ActionTranslator( generator, "a",
                                                                         new CommonToken( ANTLRParser.ACTION, action ), 1 );
            string found = translator.Translate();
            Assert.AreEqual(expecting, found);

            Assert.AreEqual(0, equeue.errors.Count, "unexpected errors: " + equeue);
        }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:28,代码来源:TestAttributes.cs


示例2: TestCannotHaveSpaceAfterDot

        public void TestCannotHaveSpaceAfterDot()
        {
            string action = "%x. y = z;";
            //String expecting = null;

            ErrorQueue equeue = new ErrorQueue();
            ErrorManager.SetErrorListener( equeue );
            Grammar g = new Grammar(
                "grammar t;\n" +
                "options {\n" +
                "    output=template;\n" +
                "}\n" +
                "\n" +
                "a : ID {" + action + "}\n" +
                "  ;\n" +
                "\n" +
                "ID : 'a';\n" );
            AntlrTool antlr = newTool();
            CodeGenerator generator = new CodeGenerator( antlr, g, "Java" );
            g.CodeGenerator = generator;
            generator.GenRecognizer(); // forces load of templates

            int expectedMsgID = ErrorManager.MSG_INVALID_TEMPLATE_ACTION;
            object expectedArg = "%x.";
            GrammarSemanticsMessage expectedMessage =
                new GrammarSemanticsMessage( expectedMsgID, g, null, expectedArg );
            checkError( equeue, expectedMessage );
        }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:28,代码来源:TestTemplates.cs


示例3: TestMessageStringificationIsConsistent

        public void TestMessageStringificationIsConsistent()
        {
            string action = "$other.tree = null;";
            ErrorQueue equeue = new ErrorQueue();
            ErrorManager.SetErrorListener( equeue );
            Grammar g = new Grammar(
                "grammar a;\n" +
                "options { output = AST;}" +
                "otherrule\n" +
                "    : 'y' ;" +
                "rule\n" +
                "    : other=otherrule {" + action + "}\n" +
                "    ;" );
            AntlrTool antlr = newTool();
            CodeGenerator generator = new CodeGenerator( antlr, g, "Java" );
            g.CodeGenerator = generator;
            generator.GenRecognizer(); // forces load of templates
            ActionTranslator translator = new ActionTranslator( generator,
                                                                        "rule",
                                                                        new CommonToken( ANTLRParser.ACTION, action ), 1 );
            string rawTranslation =
                translator.Translate();

            int expectedMsgID = ErrorManager.MSG_WRITE_TO_READONLY_ATTR;
            object expectedArg = "other";
            object expectedArg2 = "tree";
            GrammarSemanticsMessage expectedMessage =
                new GrammarSemanticsMessage( expectedMsgID, g, null, expectedArg, expectedArg2 );
            string expectedMessageString = expectedMessage.ToString();
            Assert.AreEqual( expectedMessageString, expectedMessage.ToString() );
        }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:31,代码来源:TestMessages.cs


示例4: TestBadGrammarOption

        public void TestBadGrammarOption()
        {
            ErrorQueue equeue = new ErrorQueue();
            ErrorManager.SetErrorListener( equeue ); // unique listener per thread
            AntlrTool antlr = newTool();
            Grammar g = new Grammar( antlr,
                                    "grammar t;\n" +
                                    "options {foo=3; language=Java;}\n" +
                                    "a : 'a';\n" );

            object expectedArg = "foo";
            int expectedMsgID = ErrorManager.MSG_ILLEGAL_OPTION;
            GrammarSemanticsMessage expectedMessage =
                new GrammarSemanticsMessage( expectedMsgID, g, null, expectedArg );
            checkGrammarSemanticsError( equeue, expectedMessage );
        }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:16,代码来源:TestSymbolDefinitions.cs


示例5: Test3LevelImport

        public void Test3LevelImport()
        {
            ErrorQueue equeue = new ErrorQueue();
            ErrorManager.SetErrorListener( equeue );
            string slave =
                "parser grammar T;\n" +
                "a : T ;\n";
            mkdir( tmpdir );
            writeFile( tmpdir, "T.g", slave );
            string slave2 =
                "parser grammar S;\n" + // A, B, C token type order
                "import T;\n" +
                "a : S ;\n";
            mkdir( tmpdir );
            writeFile( tmpdir, "S.g", slave2 );

            string master =
                "grammar M;\n" +
                "import S;\n" +
                "a : M ;\n";
            writeFile( tmpdir, "M.g", master );
            AntlrTool antlr = newTool( new string[] { "-lib", tmpdir } );
            CompositeGrammar composite = new CompositeGrammar();
            Grammar g = new Grammar( antlr, tmpdir + "/M.g", composite );
            composite.SetDelegationRoot( g );
            g.ParseAndBuildAST();
            g.composite.AssignTokenTypes();
            g.composite.DefineGrammarSymbols();

            string expectedTokenIDToTypeMap = "[M=6, S=5, T=4]";
            string expectedStringLiteralToTypeMap = "{}";
            string expectedTypeToTokenList = "[T, S, M]";

            assertEquals( expectedTokenIDToTypeMap,
                         realElements( g.composite.tokenIDToTypeMap ).ToElementString() );
            assertEquals( expectedStringLiteralToTypeMap, g.composite.stringLiteralToTypeMap.ToElementString() );
            assertEquals( expectedTypeToTokenList,
                         realElements( g.composite.typeToTokenList ).ToElementString() );

            assertEquals( "unexpected errors: " + equeue, 0, equeue.errors.Count );

            bool ok =
                rawGenerateAndBuildRecognizer( "M.g", master, "MParser", null, false );
            bool expecting = true; // should be ok
            assertEquals( expecting, ok );
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:46,代码来源:TestCompositeGrammars.cs


示例6: TestRewriteRuleAndRewriteModeIgnoreActionsPredicates

        public void TestRewriteRuleAndRewriteModeIgnoreActionsPredicates()
        {
            ErrorQueue equeue = new ErrorQueue();
            ErrorManager.SetErrorListener( equeue );
            Grammar g = new Grammar(
                "tree grammar TP;\n" +
                "options {ASTLabelType=CommonTree; output=template; rewrite=true;}\n" +
                "a: {action} {action2} x=A -> {ick}\n" +
                " | {pred1}? y+=B -> {ick}\n" +
                " | C {action} -> {ick}\n" +
                " | {pred2}?=> z+=D -> {ick}\n" +
                " | (E)=> ^(F G) -> {ick}\n" +
                " ;\n"
            );
            AntlrTool antlr = newTool();
            antlr.SetOutputDirectory( null ); // write to /dev/null
            CodeGenerator generator = new CodeGenerator( antlr, g, "Java" );
            g.CodeGenerator = generator;
            generator.GenRecognizer();

            Assert.AreEqual(0, equeue.warnings.Count, "unexpected errors: " + equeue);
        }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:22,代码来源:TestRewriteTemplates.cs


示例7: TestNoWildcardAsRootError

        public void TestNoWildcardAsRootError()
        {
            ErrorQueue equeue = new ErrorQueue();
            ErrorManager.SetErrorListener( equeue );

            string treeGrammar =
                "tree grammar TP;\n" +
                "options {output=AST;}\n" +
                "a : ^(. INT) \n" +
                "  ;\n";

            Grammar g = new Grammar( treeGrammar );
            AntlrTool antlr = newTool();
            antlr.SetOutputDirectory( null ); // write to /dev/null
            CodeGenerator generator = new CodeGenerator( antlr, g, "Java" );
            g.CodeGenerator = generator;
            generator.GenRecognizer();

            assertEquals( "unexpected errors: " + equeue, 1, equeue.errors.Count );

            int expectedMsgID = ErrorManager.MSG_WILDCARD_AS_ROOT;
            object expectedArg = null;
            RecognitionException expectedExc = null;
            GrammarSyntaxMessage expectedMessage =
                new GrammarSyntaxMessage( expectedMsgID, g, null, expectedArg, expectedExc );

            checkError( equeue, expectedMessage );
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:28,代码来源:TestTreeGrammarRewriteAST.cs


示例8: TestCStyleReturnInitValue

        public void TestCStyleReturnInitValue()
        {
            ErrorQueue equeue = new ErrorQueue();
            ErrorManager.SetErrorListener( equeue );
            Grammar g = new Grammar(
                "grammar t;\n" +
                "a : r ;\n" +
                "r returns [int (*x)()=NULL] : 'a' ;\n" );
            Assert.AreEqual(0, equeue.errors.Count, "unexpected errors: " + equeue);

            Rule r = g.GetRule( "r" );
            AttributeScope retScope = r.ReturnScope;
            var parameters = retScope.Attributes;
            Assert.IsNotNull(parameters, "missing return action");
            Assert.AreEqual( 1, parameters.Count );
            string found = parameters.ElementAt( 0 ).ToString();
            string expecting = "int (*)() x=NULL";
            Assert.AreEqual( expecting, found );
        }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:19,代码来源:TestAttributes.cs


示例9: TestNonGreedyLoopThatNeverLoops

        public void TestNonGreedyLoopThatNeverLoops()
        {
            Grammar g = new Grammar(
                "lexer grammar t;\n" +
                "DUH : (options {greedy=false;}:'x')+ ;" ); // loop never matched
            string expecting =
                ":s0=>2" + NewLine;

            ErrorQueue equeue = new ErrorQueue();
            ErrorManager.SetErrorListener( equeue );

            checkDecision( g, 1, expecting, new int[] { 1 } );

            Assert.AreEqual(1, equeue.size(), "unexpected number of expected problems");
            Message msg = (Message)equeue.errors[0];
            Assert.IsTrue(msg is GrammarUnreachableAltsMessage, "warning must be an unreachable alt");
            GrammarUnreachableAltsMessage u = (GrammarUnreachableAltsMessage)msg;
            Assert.AreEqual( "[1]", u.alts.ToElementString() );
        }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:19,代码来源:TestCharDFAConversion.cs


示例10: TestCharListLabelInLexer

        public void TestCharListLabelInLexer()
        {
            ErrorQueue equeue = new ErrorQueue();
            ErrorManager.SetErrorListener( equeue );
            Grammar g = new Grammar(
                "lexer grammar t;\n" +
                "R : x+='z' ;\n" );

            AntlrTool antlr = newTool();
            CodeGenerator generator = new CodeGenerator( antlr, g, "Java" );
            g.CodeGenerator = generator;
            generator.GenRecognizer(); // forces load of templates
            Assert.AreEqual(0, equeue.errors.Count, "unexpected errors: " + equeue);
        }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:14,代码来源:TestAttributes.cs


示例11: checkError

 //throws Exception
 protected void checkError( ErrorQueue equeue,
                           GrammarSemanticsMessage expectedMessage )
 {
     /*
     System.out.println(equeue.infos);
     System.out.println(equeue.warnings);
     System.out.println(equeue.errors);
     */
     Message foundMsg = null;
     for ( int i = 0; i < equeue.errors.Count; i++ )
     {
         Message m = (Message)equeue.errors[i];
         if ( m.msgID == expectedMessage.msgID )
         {
             foundMsg = m;
         }
     }
     Assert.IsTrue(equeue.errors.Count > 0, "no error; " + expectedMessage.msgID + " expected");
     Assert.IsTrue(equeue.errors.Count <= 1, "too many errors; " + equeue.errors);
     Assert.IsTrue(foundMsg != null, "couldn't find expected error: " + expectedMessage.msgID);
     Assert.IsTrue(foundMsg is GrammarSemanticsMessage, "error is not a GrammarSemanticsMessage");
     Assert.AreEqual( expectedMessage.arg, foundMsg.arg );
     Assert.AreEqual( expectedMessage.arg2, foundMsg.arg2 );
 }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:25,代码来源:TestTemplates.cs


示例12: TestSetAttrOfExprInMembers

        public void TestSetAttrOfExprInMembers()
        {
            ErrorQueue equeue = new ErrorQueue();
            ErrorManager.SetErrorListener( equeue );
            Grammar g = new Grammar(
                "grammar t;\n" +
                "options {\n" +
                "    output=template;\n" +
                "}\n" +
                "@members {\n" +
                "%code.instr = o;" + // must not get null ptr!
                "}\n" +
                "a : ID\n" +
                "  ;\n" +
                "\n" +
                "ID : 'a';\n" );
            AntlrTool antlr = newTool();
            CodeGenerator generator = new CodeGenerator( antlr, g, "Java" );
            g.CodeGenerator = generator;
            generator.GenRecognizer(); // forces load of templates

            assertNoErrors( equeue );
        }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:23,代码来源:TestTemplates.cs


示例13: TestFullyQualifiedRefToCurrentRuleParameter

        public void TestFullyQualifiedRefToCurrentRuleParameter()
        {
            string action = "$a.i;";
            string expecting = "i;";

            ErrorQueue equeue = new ErrorQueue();
            ErrorManager.SetErrorListener( equeue );
            Grammar g = new Grammar(
                "grammar t;\n" +
                "a[int i]: {" + action + "}\n" +
                "  ;\n" );
            AntlrTool antlr = newTool();
            CodeGenerator generator = new CodeGenerator( antlr, g, "Java" );
            g.CodeGenerator = generator;
            generator.GenRecognizer(); // forces load of templates
            ActionTranslator translator = new ActionTranslator( generator, "a",
                                                                         new CommonToken( ANTLRParser.ACTION, action ), 1 );
            string found = translator.Translate();
            Assert.AreEqual(expecting, found);

            Assert.AreEqual(0, equeue.errors.Count, "unexpected errors: " + equeue);
        }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:22,代码来源:TestAttributes.cs


示例14: TestForwardRefRuleLabels

        public void TestForwardRefRuleLabels()
        {
            string action = "$r.x; $r.start; $r.stop; $r.tree; $a.x; $a.tree;";
            string expecting = "(r!=null?r.x:0); (r!=null?((Token)r.start):null); (r!=null?((Token)r.stop):null); (r!=null?((Object)r.tree):null); (r!=null?r.x:0); (r!=null?((Object)r.tree):null);";

            ErrorQueue equeue = new ErrorQueue();
            ErrorManager.SetErrorListener( equeue );
            Grammar g = new Grammar(
                "parser grammar t;\n" +
                "b : r=a {###" + action + "!!!}\n" +
                "  ;\n" +
                "a returns [int x]\n" +
                "  : ;\n" );
            AntlrTool antlr = newTool();
            antlr.SetOutputDirectory( null ); // write to /dev/null
            CodeGenerator generator = new CodeGenerator( antlr, g, "Java" );
            g.CodeGenerator = generator;
            generator.GenRecognizer(); // codegen phase sets some vars we need

            StringTemplate codeST = generator.RecognizerST;
            string code = codeST.Render();
            int startIndex = code.IndexOf("###") + 3;
            int endIndex = code.IndexOf("!!!");
            string found = code.Substring(startIndex, endIndex - startIndex);
            Assert.AreEqual( expecting, found );

            Assert.AreEqual(0, equeue.errors.Count, "unexpected errors: " + equeue);
        }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:28,代码来源:TestAttributes.cs


示例15: TestDynamicScopeRefOkEvenThoughRuleRefExists

        public void TestDynamicScopeRefOkEvenThoughRuleRefExists()
        {
            string action = "$b::n;";
            string expecting = "((b_scope)b_stack.peek()).n;";

            ErrorQueue equeue = new ErrorQueue();
            ErrorManager.SetErrorListener( equeue );
            Grammar g = new Grammar(
                "grammar t;\n" +
                "s : b ;\n" +
                "b\n" +
                "scope {\n" +
                "  int n;\n" +
                "} : '(' b ')' {" + action + "}\n" + // refers to current invocation's n
                "  ;\n" );
            AntlrTool antlr = newTool();
            CodeGenerator generator = new CodeGenerator( antlr, g, "Java" );
            g.CodeGenerator = generator;
            generator.GenRecognizer(); // forces load of templates
            ActionTranslator translator = new ActionTranslator( generator, "b",
                                                                         new CommonToken( ANTLRParser.ACTION, action ), 1 );
            string found = translator.Translate();
            Assert.AreEqual(expecting, found);

            Assert.AreEqual(0, equeue.errors.Count, "unexpected errors: " + equeue);
        }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:26,代码来源:TestAttributes.cs


示例16: TestDynamicRuleScopeRefInSubrule

        public void TestDynamicRuleScopeRefInSubrule()
        {
            string action = "$a::n;";
            string expecting = "((a_scope)a_stack.peek()).n;";

            ErrorQueue equeue = new ErrorQueue();
            ErrorManager.SetErrorListener( equeue );
            Grammar g = new Grammar(
                "grammar t;\n" +
                "a\n" +
                "scope {\n" +
                "  float n;\n" +
                "} : b ;\n" +
                "b : {" + action + "}\n" +
                "  ;\n" );
            AntlrTool antlr = newTool();
            CodeGenerator generator = new CodeGenerator( antlr, g, "Java" );
            g.CodeGenerator = generator;
            generator.GenRecognizer(); // forces load of templates
            ActionTranslator translator = new ActionTranslator( generator, "b",
                                                                         new CommonToken( ANTLRParser.ACTION, action ), 1 );
            string found = translator.Translate();
            Assert.AreEqual(expecting, found);

            Assert.AreEqual(0, equeue.errors.Count, "unexpected errors: " + equeue);
        }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:26,代码来源:TestAttributes.cs


示例17: TestDoNotTranslateScopeAttributeCompare

 public void TestDoNotTranslateScopeAttributeCompare()
 {
     string action = "if ($rule::foo == \"foo\" || 1) { System.out.println(\"ouch\"); }";
     string expecting = "if (((rule_scope)rule_stack.peek()).foo == \"foo\" || 1) { System.out.println(\"ouch\"); }";
     ErrorQueue equeue = new ErrorQueue();
     ErrorManager.SetErrorListener( equeue );
     Grammar g = new Grammar(
             "grammar a;\n" +
             "rule\n" +
             "scope {\n" +
             "   String foo;" +
             "} :\n" +
             "     twoIDs" +
             "    ;\n" +
             "twoIDs:\n" +
             "    ID ID {" + action + "}\n" +
             "    ;\n" +
             "ID : 'id';"
     );
     AntlrTool antlr = newTool();
     CodeGenerator generator = new CodeGenerator( antlr, g, "Java" );
     g.CodeGenerator = generator;
     generator.GenRecognizer();
     ActionTranslator translator = new ActionTranslator( generator,
                                                                  "twoIDs",
                                                                  new CommonToken( ANTLRParser.ACTION, action ), 1 );
     string rawTranslation =
         translator.Translate();
     // check that we didn't use scopeSetAttributeRef int translation!
     bool foundScopeSetAttributeRef = false;
     for ( int i = 0; i < translator.chunks.Count; i++ )
     {
         object chunk = translator.chunks[i];
         if ( chunk is StringTemplate )
         {
             if ( ( (StringTemplate)chunk ).Name.Equals( "/scopeSetAttributeRef" ) )
             {
                 foundScopeSetAttributeRef = true;
             }
         }
     }
     Assert.IsFalse(foundScopeSetAttributeRef, "action translator used scopeSetAttributeRef template in comparison!");
     StringTemplateGroup templates =
         new StringTemplateGroup();
     StringTemplate actionST = new StringTemplate( templates, rawTranslation );
     string found = actionST.Render();
     Assert.AreEqual(0, equeue.errors.Count, "unexpected errors: " + equeue);
     Assert.AreEqual( expecting, found );
 }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:49,代码来源:TestAttributes.cs


示例18: TestComplicatedArgParsingWithTranslation

        public void TestComplicatedArgParsingWithTranslation()
        {
            string action = "x, $A.text+\"3242\", (*$A).foo(21,33), 3.2+1, '\\n', " +
                            "\"a,oo\\nick\", {bl, \"fdkj\"eck}";
            string expecting = "x, (A1!=null?A1.getText():null)+\"3242\", (*A1).foo(21,33), 3.2+1, '\\n', \"a,oo\\nick\", {bl, \"fdkj\"eck}";

            ErrorQueue equeue = new ErrorQueue();
            ErrorManager.SetErrorListener( equeue );

            // now check in actual grammar.
            Grammar g = new Grammar(
                "parser grammar t;\n" +
                "a[User u, int i]\n" +
                "        : A a[" + action + "] B\n" +
                "        ;" );
            AntlrTool antlr = newTool();
            CodeGenerator generator = new CodeGenerator( antlr, g, "Java" );
            g.CodeGenerator = generator;
            generator.GenRecognizer(); // forces load of templates
            ActionTranslator translator = new ActionTranslator( generator, "a",
                                                                         new CommonToken( ANTLRParser.ACTION, action ), 1 );
            string found = translator.Translate();
            Assert.AreEqual(expecting, found);

            Assert.AreEqual(0, equeue.errors.Count, "unexpected errors: " + equeue);
        }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:26,代码来源:TestAttributes.cs


示例19: TestDoNotTranslateAttributeCompare

 public void TestDoNotTranslateAttributeCompare()
 {
     string action = "$a.line == $b.line";
     string expecting = "(a!=null?a.getLine():0) == (b!=null?b.getLine():0)";
     ErrorQueue equeue = new ErrorQueue();
     ErrorManager.SetErrorListener( equeue );
     Grammar g = new Grammar(
             "lexer grammar a;\n" +
             "RULE:\n" +
             "     a=ID b=ID {" + action + "}" +
             "    ;\n" +
             "ID : 'id';"
     );
     AntlrTool antlr = newTool();
     CodeGenerator generator = new CodeGenerator( antlr, g, "Java" );
     g.CodeGenerator = generator;
     generator.GenRecognizer();
     ActionTranslator translator = new ActionTranslator( generator,
                                                                  "RULE",
                                                                  new CommonToken( ANTLRParser.ACTION, action ), 1 );
     string found = translator.Translate();
     Assert.AreEqual(0, equeue.errors.Count, "unexpected errors: " + equeue);
     Assert.AreEqual( expecting, found );
 }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:24,代码来源:TestAttributes.cs


示例20: TestRewriteRuleAndRewriteModeRefRule

        public void TestRewriteRuleAndRewriteModeRefRule()
        {
            ErrorQueue equeue = new ErrorQueue();
            ErrorManager.SetErrorListener( equeue );
            Grammar g = new Grammar(
                "tree grammar TP;\n" +
                "options {ASTLabelType=CommonTree; output=template; rewrite=true;}\n" +
                "a  : b+ -> {ick}\n" +
                "   | b b A -> {ick}\n" +
                "   ;\n" +
                "b  : B ;\n"
            );
            AntlrTool antlr = newTool();
            antlr.SetOutputDirectory( null ); // write to /dev/null
            CodeGenerator generator = new CodeGenerator( antlr, g, "Java" );
            g.CodeGenerator = generator;
            generator.GenRecognizer();

            Assert.AreEqual(0, equeue.warnings.Count, "unexpected errors: " + equeue);
        }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:20,代码来源:TestRewriteTemplates.cs



注:本文中的AntlrUnitTests.ErrorQueue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Ants.Location类代码示例发布时间:2022-05-24
下一篇:
C# Ast.GrammarAST类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap