From: Mart Lubbers Date: Fri, 18 May 2018 10:17:56 +0000 (+0200) Subject: Supposedly streameing X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=285e907e48be4a67a5c3f5c8c641ec3c0f5529a8;p=lambda.git Supposedly streameing --- diff --git a/Makefile b/Makefile index 84b6636..79e13c7 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ CFLAGS:=-g -Wall -Wextra -pedantic -lambda: lambda.tab.o lambda.yy.o main.o print.o mem.o reduce.o +lambda: lambda.tab.o lambda.yy.o print.o mem.o reduce.o $(LINK.c) $(LDLIBS) $^ $(OUTPUT_OPTION) %.tab.c: %.y diff --git a/lambda.h b/lambda.h index 457e5cf..8256f04 100644 --- a/lambda.h +++ b/lambda.h @@ -37,7 +37,5 @@ struct lambda *make_abstraction(char *, struct lambda *); struct lambda *make_application(struct lambda *, struct lambda *); struct lambda *make_numeral(unsigned int i); struct lambda *make_bool(bool b); -void decls_free(); -void decls_print(); #define YYSTYPE struct lambda * #endif diff --git a/lambda.y b/lambda.y index a9b0f14..813b77d 100644 --- a/lambda.y +++ b/lambda.y @@ -2,10 +2,11 @@ %{ #include "lambda.h" #include "lambda.tab.h" +#include "lambda.yy.h" #include "mem.h" #include "print.h" +#include "reduce.h" -struct lambda *result; struct decllist *decls = NULL; extern int yylex(); @@ -17,6 +18,14 @@ void yyerror(const char *str) int yywrap() { + struct decllist *t; + while(decls != NULL){ + free(decls->ident); + lambda_free(decls->value); + t = decls->next; + free(decls); + decls = t; + } return 1; } @@ -88,38 +97,11 @@ struct lambda *decls_lookup(char *ident) return make_ident(ident); } -void decls_print() +int main() { - struct decllist *c = decls; - unsigned int maxlen = 0, len; - while(c != NULL){ - len = strlen(c->ident); - maxlen = maxlen < len ? len : maxlen; - c = c->next; - } - - c = decls; - while(c != NULL){ - printf("%s ", c->ident); - len = strlen(c->ident); - for(unsigned int i = 1; idata.identifier.ident, $3); + printf("%s = ", $1->data.identifier.ident); + lambda_print($3, NULL); lambda_free($1); } term diff --git a/main.c b/main.c index 4269ff4..dce43c3 100644 --- a/main.c +++ b/main.c @@ -7,20 +7,9 @@ #include "print.h" #include "mem.h" -extern struct lambda *result; - int main() { int r = yyparse(); - int maxdepth = 10000; - if(r == 0){ - decls_print(); - printf(" "); - lambda_reduce(result, result, &maxdepth); - lambda_print(result, NULL); - } - yylex_destroy(); - lambda_free(result); decls_free(); return r; }