From: Mart Lubbers Date: Wed, 23 May 2018 10:10:37 +0000 (+0200) Subject: change eval order X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=b797d6e5f2825df597832d6109c486ebdc1e0e11;p=lambda.git change eval order --- diff --git a/lambda.y b/lambda.y index 9cde7e1..cb14118 100644 --- a/lambda.y +++ b/lambda.y @@ -117,7 +117,6 @@ struct lambda *decls_lookup(char *ident) int main() { - setbuf(stdout, NULL); int r = yyparse(); yylex_destroy(); return r; @@ -146,7 +145,7 @@ lambda struct lambda *t = $1; printf(" "); for(unsigned int i = 0; i<999; i++) - if(!lambda_reduce(&t, &t, true)) + if(!lambda_reduce(&t, &t, false)) break; lambda_print(t, NULL); putchar('\n'); diff --git a/print.c b/print.c index c7503b8..f093ff5 100644 --- a/print.c +++ b/print.c @@ -14,7 +14,6 @@ void term_print(struct lambda *t, struct lambda *mark) putchar('|'); switch(t->which){ case lambda_ident: -// printf("%s(%p)", t->data.identifier.ident, (void *)t->data.identifier.binding); printf("%s", t->data.identifier.ident); break; case lambda_abs: @@ -28,19 +27,12 @@ void term_print(struct lambda *t, struct lambda *mark) term_print(t, mark); break; case lambda_app: - if(t->data.application.expr1->which == lambda_abs) - putchar('('); + putchar('('); term_print(t->data.application.expr1, mark); if(t->data.application.expr1->which == lambda_abs) - putchar(')'); - - putchar(' '); - - if(t->data.application.expr2->which == lambda_app) - putchar('('); + printf(") ("); term_print(t->data.application.expr2, mark); - if(t->data.application.expr2->which == lambda_app) - putchar(')'); + putchar(')'); break; } if(t == mark)