本文整理汇总了C#中Tree.Node.setFormToQuote方法的典型用法代码示例。如果您正苦于以下问题:C# Node.setFormToQuote方法的具体用法?C# Node.setFormToQuote怎么用?C# Node.setFormToQuote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree.Node
的用法示例。
在下文中一共展示了Node.setFormToQuote方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: print
public override void print(Node t, int n, bool p)
{
// Indent if necessary
for (int i = 0; i < n; i++)
Console.Write(" ");
// Since this form can be created from either the quote character,
// '\'', or the quote string, "quote" we need two mutually
// exclusive cases to handle each
if (charQuote) {
// If what is trying to be printed is the root node,
// set all subsequent Cons nodes' forms to Quote
// print "'("
// if the cdr is not nil, recur down the tree
//else it is nil, so print the RPARN
if (isRoot) {
t.setFormToQuote(charQuote, depth);
t.getCar().print(0, false);
Console.Write("(");
if (!t.getCdr().isNil()) {
t = t.getCdr();
t.print(0, true);
}
else {
t.getCdr().print(0, true);
}
}
// This is not the root, so do these set of instructions:
// If the car is a Cons node, print a LPAREN because it is the
// start of an inner list.
// Print the car, which will implicitly recur on its subtree
// Print single whitespaces when necessary and
// print the cdr which also implicity recurs on its subtree
else {
if (t.getCar().isPair()) {
Console.Write("(");
}
t.getCar().print(0, false);
if (!t.getCdr().isNil() && !isRoot) {
Console.Write(" ");
}
t.getCdr().print(0, true);
}
// Write a carriage return only if the cdr is Nil and the
// Cons node depth is 0, which means it is on far right side of
// the tree
if (t.getCdr().isNil() && depth == 0) {
Console.WriteLine();
}
}
// Quote strings are handled very similary with the exception that
// the first and last parentheses are not printed and "quote" will
// pretty print out to "\'"
else {
if (isRoot) {
t.setFormToQuote(charQuote, depth);
Console.Write("\'");
t = t.getCdr();
t.print(0, true);
}
else {
if (t.getCar().isPair()) {
Console.Write("(");
}
t.getCar().print(0, false);
if (!t.getCdr().isNil()) {
Console.Write(" ");
t.getCdr().print(0, true);
}
else {
if (depth != 0) {
t.getCdr().print(0, true);
}
else {
Console.WriteLine();
}
}
}
}
}