change printing master
authorMart Lubbers <mart@martlubbers.net>
Wed, 23 May 2018 11:34:44 +0000 (13:34 +0200)
committerMart Lubbers <mart@martlubbers.net>
Wed, 23 May 2018 11:34:44 +0000 (13:34 +0200)
print.c

diff --git a/print.c b/print.c
index 9e6280c..02fcc16 100644 (file)
--- a/print.c
+++ b/print.c
@@ -27,12 +27,19 @@ void term_print(struct lambda *t, struct lambda *mark)
                term_print(t, mark);
                break;
        case lambda_app:
                term_print(t, mark);
                break;
        case lambda_app:
-               putchar('(');
+               if(t->data.application.expr1->which == lambda_abs)
+                       putchar('(');
                term_print(t->data.application.expr1, mark);
                if(t->data.application.expr1->which == lambda_abs)
                term_print(t->data.application.expr1, mark);
                if(t->data.application.expr1->which == lambda_abs)
-               printf(") (");
+                       putchar(')');
+
+               putchar(' ');
+
+               if(t->data.application.expr2->which == lambda_abs)
+                       putchar('(');
                term_print(t->data.application.expr2, mark);
                term_print(t->data.application.expr2, mark);
-               putchar(')');
+               if(t->data.application.expr2->which == lambda_abs)
+                       putchar(')');
                break;
        }
        if(t == mark)
                break;
        }
        if(t == mark)
@@ -42,5 +49,5 @@ void term_print(struct lambda *t, struct lambda *mark)
 void lambda_print(struct lambda *t, struct lambda *mark)
 {
        term_print(t, mark);
 void lambda_print(struct lambda *t, struct lambda *mark)
 {
        term_print(t, mark);
-       printf("\n;");
+       putchar('\n');
 }
 }