當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。