当前位置: 首页>>代码示例>>C#>>正文


C# CommonTree.ReplaceChildren方法代码示例

本文整理汇总了C#中Antlr.Runtime.Tree.CommonTree.ReplaceChildren方法的典型用法代码示例。如果您正苦于以下问题:C# CommonTree.ReplaceChildren方法的具体用法?C# CommonTree.ReplaceChildren怎么用?C# CommonTree.ReplaceChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Antlr.Runtime.Tree.CommonTree的用法示例。


在下文中一共展示了CommonTree.ReplaceChildren方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestReplaceWithNoChildren

 public void TestReplaceWithNoChildren()
 {
     CommonTree t = new CommonTree( new CommonToken( 101 ) );
     CommonTree newChild = new CommonTree( new CommonToken( 5 ) );
     bool error = false;
     try
     {
         t.ReplaceChildren( 0, 0, newChild );
     }
     catch ( ArgumentException /*iae*/ )
     {
         error = true;
     }
     assertTrue( error );
 }
开发者ID:bszafko,项目名称:antlrcs,代码行数:15,代码来源:TestTrees.cs

示例2: TestReplaceWithOneChildren

        public void TestReplaceWithOneChildren()
        {
            // assume token type 99 and use text
            CommonTree t = new CommonTree( new CommonToken( 99, "a" ) );
            CommonTree c0 = new CommonTree( new CommonToken( 99, "b" ) );
            t.AddChild( c0 );

            CommonTree newChild = new CommonTree( new CommonToken( 99, "c" ) );
            t.ReplaceChildren( 0, 0, newChild );
            string expecting = "(a c)";
            assertEquals( expecting, t.ToStringTree() );
            t.SanityCheckParentAndChildIndexes();
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:13,代码来源:TestTrees.cs

示例3: TestReplaceOneWithTwoInMiddle

        public void TestReplaceOneWithTwoInMiddle()
        {
            CommonTree t = new CommonTree( new CommonToken( 99, "a" ) );
            t.AddChild( new CommonTree( new CommonToken( 99, "b" ) ) );
            t.AddChild( new CommonTree( new CommonToken( 99, "c" ) ) );
            t.AddChild( new CommonTree( new CommonToken( 99, "d" ) ) );

            CommonTree newChildren = (CommonTree)adaptor.Nil();
            newChildren.AddChild( new CommonTree( new CommonToken( 99, "x" ) ) );
            newChildren.AddChild( new CommonTree( new CommonToken( 99, "y" ) ) );

            t.ReplaceChildren( 1, 1, newChildren );
            string expecting = "(a b x y d)";
            assertEquals( expecting, t.ToStringTree() );
            t.SanityCheckParentAndChildIndexes();
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:16,代码来源:TestTrees.cs

示例4: TestReplaceTwoWithOneAtRight

        public void TestReplaceTwoWithOneAtRight()
        {
            CommonTree t = new CommonTree( new CommonToken( 99, "a" ) );
            t.AddChild( new CommonTree( new CommonToken( 99, "b" ) ) );
            t.AddChild( new CommonTree( new CommonToken( 99, "c" ) ) );
            t.AddChild( new CommonTree( new CommonToken( 99, "d" ) ) );

            CommonTree newChild = new CommonTree( new CommonToken( 99, "x" ) );

            t.ReplaceChildren( 1, 2, newChild );
            string expecting = "(a b x)";
            assertEquals( expecting, t.ToStringTree() );
            t.SanityCheckParentAndChildIndexes();
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:14,代码来源:TestTrees.cs

示例5: TestReplaceInMiddle

        public void TestReplaceInMiddle()
        {
            CommonTree t = new CommonTree( new CommonToken( 99, "a" ) );
            t.AddChild( new CommonTree( new CommonToken( 99, "b" ) ) );
            t.AddChild( new CommonTree( new CommonToken( 99, "c" ) ) ); // index 1
            t.AddChild( new CommonTree( new CommonToken( 99, "d" ) ) );

            CommonTree newChild = new CommonTree( new CommonToken( 99, "x" ) );
            t.ReplaceChildren( 1, 1, newChild );
            string expecting = "(a b x d)";
            assertEquals( expecting, t.ToStringTree() );
            t.SanityCheckParentAndChildIndexes();
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:13,代码来源:TestTrees.cs

示例6: TestReplaceTwoWithOneAtLeft

        public void TestReplaceTwoWithOneAtLeft()
        {
            CommonTree t = new CommonTree( new CommonToken( 99, "a" ) );
            t.AddChild( new CommonTree( new CommonToken( 99, "b" ) ) );
            t.AddChild( new CommonTree( new CommonToken( 99, "c" ) ) );
            t.AddChild( new CommonTree( new CommonToken( 99, "d" ) ) );

            CommonTree newChild = new CommonTree( new CommonToken( 99, "x" ) );

            t.ReplaceChildren( 0, 1, newChild );
            string expecting = "(a x d)";
            Assert.AreEqual( expecting, t.ToStringTree() );
            t.SanityCheckParentAndChildIndexes();
        }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:14,代码来源:TestTrees.cs

示例7: TestReplaceOneWithTwoAtRight

        public void TestReplaceOneWithTwoAtRight()
        {
            CommonTree t = new CommonTree( new CommonToken( 99, "a" ) );
            t.AddChild( new CommonTree( new CommonToken( 99, "b" ) ) );
            t.AddChild( new CommonTree( new CommonToken( 99, "c" ) ) );
            t.AddChild( new CommonTree( new CommonToken( 99, "d" ) ) );

            CommonTree newChildren = (CommonTree)adaptor.Nil();
            newChildren.AddChild( new CommonTree( new CommonToken( 99, "x" ) ) );
            newChildren.AddChild( new CommonTree( new CommonToken( 99, "y" ) ) );

            t.ReplaceChildren( 2, 2, newChildren );
            string expecting = "(a b c x y)";
            Assert.AreEqual( expecting, t.ToStringTree() );
            t.SanityCheckParentAndChildIndexes();
        }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:16,代码来源:TestTrees.cs

示例8: TestReplaceAtRight

        public void TestReplaceAtRight()
        {
            CommonTree t = new CommonTree( new CommonToken( 99, "a" ) );
            t.AddChild( new CommonTree( new CommonToken( 99, "b" ) ) );
            t.AddChild( new CommonTree( new CommonToken( 99, "c" ) ) );
            t.AddChild( new CommonTree( new CommonToken( 99, "d" ) ) ); // index 2

            CommonTree newChild = new CommonTree( new CommonToken( 99, "x" ) );
            t.ReplaceChildren( 2, 2, newChild );
            string expecting = "(a b c x)";
            Assert.AreEqual( expecting, t.ToStringTree() );
            t.SanityCheckParentAndChildIndexes();
        }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:13,代码来源:TestTrees.cs

示例9: TestReplaceWithNoChildren

 public void TestReplaceWithNoChildren()
 {
     CommonTree t = new CommonTree( new CommonToken( 101 ) );
     CommonTree newChild = new CommonTree( new CommonToken( 5 ) );
     t.ReplaceChildren( 0, 0, newChild );
 }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:6,代码来源:TestTrees.cs


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