From ce17a386f6c9047f8e7251de3a9e9cf3c10996e0 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sat, 27 Aug 2016 08:53:56 +0200 Subject: fuspelc -> fuspel --- interpreter/.gitignore | 2 +- interpreter/Makefile | 4 ++-- interpreter/fuspel.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ interpreter/fuspelc.c | 59 -------------------------------------------------- 4 files changed, 62 insertions(+), 62 deletions(-) create mode 100644 interpreter/fuspel.c delete mode 100644 interpreter/fuspelc.c diff --git a/interpreter/.gitignore b/interpreter/.gitignore index 9148247..ea6faae 100644 --- a/interpreter/.gitignore +++ b/interpreter/.gitignore @@ -1,2 +1,2 @@ *.o -fuspelc +fuspel diff --git a/interpreter/Makefile b/interpreter/Makefile index 25c28ee..dd22bf8 100644 --- a/interpreter/Makefile +++ b/interpreter/Makefile @@ -1,8 +1,8 @@ CFLAGS=-Wall -Wextra -Werror -s DEPS=lex.h syntax.h print.h parse.h log.h eval.h mem.h code.h -OBJ=fuspelc.o lex.o syntax.o print.o parse.o log.o eval.o mem.o code.o -EXE=fuspelc +OBJ=fuspel.o lex.o syntax.o print.o parse.o log.o eval.o mem.o code.o +EXE=fuspel .PHONY: all clean diff --git a/interpreter/fuspel.c b/interpreter/fuspel.c new file mode 100644 index 0000000..0e1d82b --- /dev/null +++ b/interpreter/fuspel.c @@ -0,0 +1,59 @@ +#include +#include + +#include "eval.h" +#include "lex.h" +#include "mem.h" +#include "parse.h" +#include "print.h" + +int main(void) { + token_list* tokens; + fuspel* pgm; + expression* result; + + tokens = NULL; + + while (!feof(stdin)) { + char program[79]; + if (!fgets(program, 79, stdin)) { + if (feof(stdin)) + break; + fprintf(stderr, "Couldn't read input.\n"); + exit(EXIT_FAILURE); + } + + tokens = lex(tokens, program); + if (!tokens) { + fprintf(stderr, "Couldn't lex program.\n"); + exit(EXIT_FAILURE); + } + } + + pgm = parse(tokens); + free_token_list(tokens); + my_free(tokens); + + if (!pgm) { + fprintf(stderr, "Couldn't parse program.\n"); + exit(EXIT_FAILURE); + } + + printf("\n"); + print_fuspel(pgm); + printf("\n\n"); + + result = eval_main(pgm); + if (result) { + print_expression(result); + printf("\n"); + + free_expression(result); + my_free(result); + } + + free_fuspel(pgm); + my_free(pgm); + + return 0; +} diff --git a/interpreter/fuspelc.c b/interpreter/fuspelc.c deleted file mode 100644 index 0e1d82b..0000000 --- a/interpreter/fuspelc.c +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include - -#include "eval.h" -#include "lex.h" -#include "mem.h" -#include "parse.h" -#include "print.h" - -int main(void) { - token_list* tokens; - fuspel* pgm; - expression* result; - - tokens = NULL; - - while (!feof(stdin)) { - char program[79]; - if (!fgets(program, 79, stdin)) { - if (feof(stdin)) - break; - fprintf(stderr, "Couldn't read input.\n"); - exit(EXIT_FAILURE); - } - - tokens = lex(tokens, program); - if (!tokens) { - fprintf(stderr, "Couldn't lex program.\n"); - exit(EXIT_FAILURE); - } - } - - pgm = parse(tokens); - free_token_list(tokens); - my_free(tokens); - - if (!pgm) { - fprintf(stderr, "Couldn't parse program.\n"); - exit(EXIT_FAILURE); - } - - printf("\n"); - print_fuspel(pgm); - printf("\n\n"); - - result = eval_main(pgm); - if (result) { - print_expression(result); - printf("\n"); - - free_expression(result); - my_free(result); - } - - free_fuspel(pgm); - my_free(pgm); - - return 0; -} -- cgit v1.2.3