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


C# Node.setFormToQuote方法代码示例

本文整理汇总了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();
                        }
                    }
                }
            }
        }
开发者ID:HurricaneFist,项目名称:cs4101proj1,代码行数:85,代码来源:Quote.cs


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