示例#1
0
 override public void Pretty(PrettyBuilder builder)
 {
     builder.NewLine();
     builder.Append("return ");
     returnValue.Pretty(builder);
     builder.Append(";");
 }
示例#2
0
 override public void Pretty(PrettyBuilder builder)
 {
     builder.Append(id.id);
     builder.Append("(");
     builder.Intersperse(exprList, ", ");
     builder.Append(")");
 }
示例#3
0
 override public void Pretty(PrettyBuilder builder)
 {
     builder.NewLine();
     builder.Append("{");
     builder.Indent();
     builder.PrettyStm(stmList);
     builder.Unindent();
     builder.NewLine();
     builder.Append("}");
 }
示例#4
0
 override public void Pretty(PrettyBuilder builder)
 {
     builder.NewLine();
     builder.Append("if(");
     exp.Pretty(builder);
     builder.Append(")");
     //builder.Indent();
     stm.Pretty(builder);
     //builder.Unindent();
     //builder.NewLine();
 }
示例#5
0
        override public void Pretty(PrettyBuilder builder)
        {
            builder.NewLine();
            builder.Append(types[type] + " ");
            builder.Append(id.id);
            builder.Append("(");
            builder.Intersperse(arg, ", ");
            builder.Append(")");

            stm.Pretty(builder);

            //builder.NewLine();
        }
示例#6
0
        // public string Name ;
        // public Expression Argument;

        override public void Pretty(PrettyBuilder builder, int outerPrecedence, bool opposite)
        {
            if (outerPrecedence >= 4)
            {
                builder.Append("(");
            }

            builder.Append($"{Name} ");
            Argument.Pretty(builder, 4, false);

            if (outerPrecedence >= 4)
            {
                builder.Append(")");
            }
        }
示例#7
0
        override public void Pretty(PrettyBuilder builder, int outerPrecedence, bool opposite)
        {
            bool eval = outerPrecedence > precedences[op] || opposite && outerPrecedence == precedences[op];

            if (eval)
            {
                builder.Append("(");
            }
            left.Pretty(builder, precedences[op], false);
            builder.Append(" " + operators[op] + " ");
            right.Pretty(builder, precedences[op], true);
            if (eval)
            {
                builder.Append(")");
            }
        }
示例#8
0
        override public void Pretty(PrettyBuilder builder, int outerPrecedence, bool opposite)
        {
            bool eval = outerPrecedence > 1 || opposite && outerPrecedence == 1;

            if (eval)
            {
                builder.Append("(");
            }
            lo.Pretty(builder);
            builder.Append(" = ");
            ro.Pretty(builder);
            if (eval)
            {
                builder.Append(")");
            }
        }
示例#9
0
        override public void Pretty(PrettyBuilder builder, int outerPrecedence, bool opposite)
        {
            BinaryOperatorExpression tempB;
            UnaryOperatorExpression  tempU;
            AssignmentExpression     tempA;
            bool eval = false;

            System.Type type = exp.GetType();
            if (type.Name == "UnaryOperatorExpression")
            {
                tempU = (UnaryOperatorExpression)exp;
                eval  = outerPrecedence > 8;
            }
            if (type.Name == "BinaryOperatorExpression")
            {
                tempB = (BinaryOperatorExpression)exp;
                eval  = outerPrecedence > BinaryOperatorExpression.precedences[tempB.op];
            }
            if (type.Name == "AssignmentExpression")
            {
                tempA = (AssignmentExpression)exp;
                eval  = outerPrecedence >= 1;
            }
            builder.Append(operators[op]);

            exp.Pretty(builder, 8, false);
        }
示例#10
0
        // public string Name;
        // public string ArgumentName;
        // public Expression Body;
        // public Expression Recipient;
        override public void Pretty(PrettyBuilder builder, int outerPrecedence, bool opposite)
        {
            if (outerPrecedence > 1)
            {
                builder.Append("(");
            }

            builder.Append($"let {Name} {ArgumentName} = ");
            Body.Pretty(builder, 1, false);
            builder.Append(" in ");
            Recipient.Pretty(builder, 1, false);

            if (outerPrecedence > 1)
            {
                builder.Append(")");
            }
        }
示例#11
0
        override public void Pretty(PrettyBuilder builder, int outerPrecedence, bool opposite)
        {
            var precedence    = Precedences[Operator];
            var associativity = Associativities[Operator];

            if (outerPrecedence > precedence || opposite && outerPrecedence == precedence)
            {
                builder.Append("(");
            }

            Expression1.Pretty(builder, precedence, associativity == Associativity.Right);
            builder.Append(Strings[Operator]);
            Expression2.Pretty(builder, precedence, associativity == Associativity.Left);

            if (outerPrecedence > precedence || opposite && outerPrecedence == precedence)
            {
                builder.Append(")");
            }
        }
示例#12
0
        // public Expression Expression1;
        // public Expression Expression2;

        override public void Pretty(PrettyBuilder builder, int outerPrecedence, bool opposite)
        {
            if (outerPrecedence > 0)
            {
                builder.Append("(");
                builder.Indent();
                builder.NewLine();
            }
            Expression1.Pretty(builder, 0, false);
            builder.Append(", ");
            builder.NewLine();
            Expression2.Pretty(builder, 0, false);
            if (outerPrecedence > 0)
            {
                builder.Unindent();
                builder.NewLine();
                builder.Append(")");
                builder.NewLine();
            }
        }
示例#13
0
 override public void Pretty(PrettyBuilder builder)
 {
     builder.Append(types[type] + " ");
     builder.Append(id.id);
 }
示例#14
0
 override public void Pretty(PrettyBuilder builder)
 {
     builder.NewLine();
     builder.Append("return;");
 }
示例#15
0
 override public void Pretty(PrettyBuilder builder)
 {
     builder.Append(binvalue.ToString().ToLower());
 }
示例#16
0
 override public void Pretty(PrettyBuilder builder)
 {
     lo.Pretty(builder);
     builder.Append(" = ");
     ro.Pretty(builder);
 }
示例#17
0
 // public string Value;
 override public void Pretty(PrettyBuilder builder, int outerPrecedence, bool opposite)
 {
     builder.Append(Value);
 }
示例#18
0
 override public void Pretty(PrettyBuilder builder)
 {
     builder.Append(num.ToString());
 }
示例#19
0
 override public void Pretty(PrettyBuilder builder)
 {
     builder.Append(id);
 }
示例#20
0
 override public void Pretty(PrettyBuilder builder)
 {
     builder.NewLine();
     decl.Pretty(builder);
     builder.Append(";");
 }