本文整理汇总了C#中Antlr.Runtime.Tree.CommonTree.ToStringTree方法的典型用法代码示例。如果您正苦于以下问题:C# CommonTree.ToStringTree方法的具体用法?C# CommonTree.ToStringTree怎么用?C# CommonTree.ToStringTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Antlr.Runtime.Tree.CommonTree
的用法示例。
在下文中一共展示了CommonTree.ToStringTree方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例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();
}
示例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();
}
示例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: 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();
}
示例6: 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();
}
示例7: 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();
}