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


C# Node.print方法代码示例

本文整理汇总了C#中Tree.Node.print方法的典型用法代码示例。如果您正苦于以下问题:C# Node.print方法的具体用法?C# Node.print怎么用?C# Node.print使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tree.Node的用法示例。


在下文中一共展示了Node.print方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: print

        public override void print(Node t, int n, bool p)
        {
            if (!p)
            {
                var spaces = "";
                if (n >= 0) spaces = new string(' ', n);
                Console.Write(spaces + "(if ");
                if (t.getCdr().getCar().isPair())
                {
                    if((t.getCdr().getCar() as Cons).form is If ||
                        (t.getCdr().getCar() as Cons).form is Lambda ||
                        (t.getCdr().getCar() as Cons).form is Define)
                    t.getCdr().getCar().print(n+4, true);
                    else
                    {
                        t.getCdr().getCar().print(0, false);
                    }

                }
                else
                    t.getCdr().getCar().print(0, false);
                t = t.getCdr().getCdr();
                do
                {
                    Console.WriteLine("");
                    t.getCar().print(n + 4, false);
                    t = t.getCdr();
                } while (t.getCdr() != null);
                Console.WriteLine("");
                t.print(n, true);
            }
            else
            {
                var spaces = "";
                if (n >= 0) spaces = new string(' ', n);
                Console.Write("(if ");
                if (t.getCdr().getCar().isPair())
                {
                    if ((t.getCdr().getCar() as Cons).form is If ||
                        (t.getCdr().getCar() as Cons).form is Lambda ||
                        (t.getCdr().getCar() as Cons).form is Define)
                        t.getCdr().getCar().print(n+4, true);
                    else
                    {
                        t.getCdr().getCar().print(0, false);
                    }

                }
                t.getCdr().getCar().print(0, false);
                t = t.getCdr().getCdr();
                do
                {
                    Console.WriteLine("");
                    t.getCar().print(n + 4, false);
                    t = t.getCdr();
                } while (t.getCdr() != null);
                Console.WriteLine("");
                t.print(n, true);
            }
        }
开发者ID:tlecom3,项目名称:4101_prog1,代码行数:60,代码来源:If.cs

示例2: print

 public override void print(Node t, int n, bool p)
 {
     var spaces = "";
     if(n >= 0) spaces = new string(' ', n);
     if(!p) { Console.Write(spaces+"("); p = true; }
     n = 0;
     do
     {
         t.getCar().print(n, false);
         t = t.getCdr();
         if(!t.isNull())
             Console.Write(' ');
     } while (t.getCdr() != null);
     if (t.isPair() || t.isNull())
         t.print(n, p);
     else
     {
         Console.Write(". ");
         t.print(n, p);
         Console.Write(")");
     }
 }
开发者ID:tlecom3,项目名称:4101_prog1,代码行数:22,代码来源:Regular.cs

示例3: printVar

 private static void printVar(Node t, int n, bool p)
 {
     string spaces = new string(' ', n);
     if (!p) { Console.Write(spaces + "("); p = true; }
     n = 0;
     do
     {
         t.getCar().print(n, false);
         t = t.getCdr();
         if (!t.isNull())
             Console.Write(' ');
     } while (t.getCdr() != null);
     t.print(n, p);
 }
开发者ID:Lumenze,项目名称:4101_prog1,代码行数:14,代码来源:Define.cs

示例4: print

 public override void print(Node t, int n, bool p)
 {
     var spaces = "";
     if (n >= 0) spaces = new string(' ', n);
     Console.Write(spaces + "(let ");
     t = t.getCdr();
     do
     {
         Console.WriteLine("");
         t.getCar().print(n + 4, false);
         t = t.getCdr();
     } while (t.getCdr() != null);
     Console.WriteLine("");
     t.print(n, true);
 }
开发者ID:tlecom3,项目名称:4101_prog1,代码行数:15,代码来源:Let.cs

示例5: printFunc

 private static void printFunc(Node t, int n, bool p)
 {
     string spaces = "";
     if (n >= 0) spaces = new string(' ', n);
     Console.Write(spaces + "(define ");
     t.getCdr().getCar().print(0, false);
     t = t.getCdr().getCdr();
     do
     {
         Console.WriteLine("");
         t.getCar().print(n + 4, false);
         t = t.getCdr();
     } while (t.getCdr() != null);
     Console.WriteLine("");
     t.print(n, true);
 }
开发者ID:Lumenze,项目名称:4101_prog1,代码行数:16,代码来源:Define.cs

示例6: apply1

 //if arg's length = 1
 private Node apply1(Node arg1)
 {
     string name = this.symbol.getName();
     bool flag = name.Equals("car");
     Node result;
     if (flag)
     {
         result = arg1.getCar();
     }//end if
     else
     {
         bool flag2 = name.Equals("cdr");
         if (flag2)
         {
             result = arg1.getCdr();
         }//end if
         else
         {
             bool flag3 = name.Equals("number?");
             if (flag3)
             {
                 result = BoolLit.getInstance(arg1.isNumber());
             }//end if
             else
             {
                 bool flag4 = name.Equals("symbol?");
                 if (flag4)
                 {
                     result = BoolLit.getInstance(arg1.isSymbol());
                 }//end if
                 else
                 {
                     bool flag5 = name.Equals("null?");
                     if (flag5)
                     {
                         result = BoolLit.getInstance(arg1.isNull());
                     }//end if
                     else
                     {
                         bool flag6 = name.Equals("pair?");
                         if (flag6)
                         {
                             result = BoolLit.getInstance(arg1.isPair());
                         }//end if
                         else
                         {
                             bool flag7 = name.Equals("procedure?");
                             if (flag7)
                             {
                                 result = BoolLit.getInstance(arg1.isProcedure());
                             }//end if
                             else
                             {
                                 bool flag8 = name.Equals("write");// i am not sure if im handling this correctly
                                 if (flag8)
                                 {
                                     arg1.print(-1);
                                     result = Unspecific.getInstance();
                                 }//end if
                                 else
                                 {
                                     bool flag9 = name.Equals("display"); // i am not sure if im handling this correctly
                                     if (flag9)
                                     {
                                         StringLit.printDoubleQuotes = false;
                                         arg1.print(-1);
                                         StringLit.printDoubleQuotes = true;
                                         result = Unspecific.getInstance();
                                     }//end if
                                     else
                                     {
                                         bool flag10 = name.Equals("load");
                                         if (flag10)
                                         {
                                             bool flag11 = !arg1.isString();
                                             if (flag11)
                                             {
                                                 Console.Error.WriteLine("Error: wrong type of argument");
                                                 result = Nil.getInstance();
                                             }
                                             else
                                             {
                                                 string stringVal = arg1.getStringVal();
                                                 try
                                                 {
                                                     //not sure why it has to be Parse.Scanner to call this
                                                     Parse.Scanner s = new Parse.Scanner(File.OpenText(stringVal));
                                                     TreeBuilder b = new TreeBuilder();
                                                     Parse.Parser parser = new Parse.Parser(s, b);
                                                     for (Node node = (Node)parser.parseExp(); node != null; node = (Node)parser.parseExp())
                                                     {
                                                         node.eval(Scheme4101.env);
                                                     }
                                                 }
                                                 catch (SystemException)
                                                 {
                                                     Console.Error.WriteLine("Could not find file " + stringVal);
                                                 }
                                                 result = Unspecific.getInstance();
//.........这里部分代码省略.........
开发者ID:Profitlol,项目名称:prog2-baum,代码行数:101,代码来源:BuiltIn.cs

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