From 7ad541eb029e3d14038da88da5cc7dab58f67220 Mon Sep 17 00:00:00 2001 From: = <=> Date: Wed, 20 May 2020 01:37:15 +0100 Subject: [PATCH] Variableize Makefile and adjust pebble tokens Also made repl() a void function --- src/Makefile | 11 ++++++----- src/calc.h | 6 +++--- src/pebblisp.c | 5 +++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Makefile b/src/Makefile index 4c0e1de..d5fe2f9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,16 +1,17 @@ files = pebblisp.c tokens.c object.c env.c +exe = pebblisp all: - gcc -g -O0 -o pebblisp -D STANDALONE $(files) && ./tests.sh + gcc -g -O0 -o $(exe) -D STANDALONE $(files) && ./tests.sh notest: - gcc -g -O0 -o pebblisp -D STANDALONE $(files) + gcc -g -O0 -o $(exe) -D STANDALONE $(files) val: - gcc -g -O0 -o pebblisp -D STANDALONE $(files) && ./tests.sh -val + gcc -g -O0 -o $(exe) -D STANDALONE $(files) && ./tests.sh -val debug: - gcc -g -O0 -o pebblisp -D STANDALONE -D DEBUG $(files) && ./tests.sh + gcc -g -O0 -o $(exe) -D STANDALONE -D DEBUG $(files) && ./tests.sh run: - ./pebblisp + ./$(exe) diff --git a/src/calc.h b/src/calc.h index ae6bc66..4df83ab 100644 --- a/src/calc.h +++ b/src/calc.h @@ -41,16 +41,16 @@ char temptext[SMAX_LENGTH] = ""; char resulttext[RESULT_LENGTH] = ""; char *tokens[] = { - " ", "(", ")", + " ", "(", ")", "+ ", "- ", "* ", "/ ", "1","2","3", "4","5","6", "7","8","9", "0", "a", "b", "c", "d", "e", "= ", "< ", "> ", - "spent", "window", + "spent ", "window", "\"", - "map", "fn", "def", "if", "\n", + "cat", "map", "fn", "def", "if", "\n", END_PHRASE }; diff --git a/src/pebblisp.c b/src/pebblisp.c index 2f7d7b7..b9a6870 100644 --- a/src/pebblisp.c +++ b/src/pebblisp.c @@ -84,7 +84,8 @@ void eval_forms(Object *destList, const Object *src, struct Environment *env) { int length = listLength(src) - 1; // Not counting first_form for(int i = 0; i < length; i++) { // Evaluates all in list - destList[i] = eval(itemAt(src, i + 1), env); // Skip the first + Object *ptr = itemAt(src, i + 1); // Skip the first + destList[i] = eval(ptr, env); } } @@ -411,7 +412,7 @@ Object parseEval(const char *input, struct Environment *env) } #ifdef STANDALONE -int repl(struct Environment *env) +void repl(struct Environment *env) { char input[200] = ""; while(input[0] != 'q') {