本文整理汇总了C#中Antlr.Runtime.Tree.CommonTree.SanityCheckParentAndChildIndexes方法的典型用法代码示例。如果您正苦于以下问题:C# CommonTree.SanityCheckParentAndChildIndexes方法的具体用法?C# CommonTree.SanityCheckParentAndChildIndexes怎么用?C# CommonTree.SanityCheckParentAndChildIndexes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Antlr.Runtime.Tree.CommonTree
的用法示例。
在下文中一共展示了CommonTree.SanityCheckParentAndChildIndexes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: 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();
}
示例4: 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();
}
示例5: TestBecomeRoot5
public void TestBecomeRoot5()
{
// ^(nil 5) becomes new root of ^(101 102 103)
CommonTree newRoot = new CommonTree( (IToken)null );
newRoot.AddChild( new CommonTree( new CommonToken( 5 ) ) );
CommonTree oldRoot = new CommonTree( new CommonToken( 101 ) );
oldRoot.AddChild( new CommonTree( new CommonToken( 102 ) ) );
oldRoot.AddChild( new CommonTree( new CommonToken( 103 ) ) );
ITreeAdaptor adaptor = new CommonTreeAdaptor();
adaptor.BecomeRoot( newRoot, oldRoot );
newRoot.SanityCheckParentAndChildIndexes();
}
示例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();
}
示例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();
}
示例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();
}