From: Elijah Cohen Date: Fri, 27 Sep 2024 19:03:15 +0000 (-0500) Subject: made warning/error/printing macros to clean things up a bit X-Git-Tag: v-12.13.14~26 X-Git-Url: https://git.eli173.com/?a=commitdiff_plain;h=ba77198905d9db1e8895ee0a97c2f0ae6328178b;p=klapaucius made warning/error/printing macros to clean things up a bit --- diff --git a/src/builtins/arithmetic.c b/src/builtins/arithmetic.c index a64e5c5..6b21be0 100644 --- a/src/builtins/arithmetic.c +++ b/src/builtins/arithmetic.c @@ -1,4 +1,5 @@ +#include "../config.h" #include "../types.h" #include "../builtins.h" #include "../sexpr.h" diff --git a/src/eval.c b/src/eval.c index 986be0b..70325b2 100644 --- a/src/eval.c +++ b/src/eval.c @@ -25,7 +25,8 @@ Sexpr* eval(Sexpr* s, Sexpr* dict) { if(s->type == SYM) { Sexpr* lookedup = lookup(dict, s); if(lookedup->type == NIL) { - printf("%s not defined\n", s->value.s); + //printf("%s not defined\n", s->value.s); + ERR("not defined: ", s->value.s); sexpr_free(s); return lookedup; } diff --git a/src/parser.c b/src/parser.c index d70ea59..202e289 100644 --- a/src/parser.c +++ b/src/parser.c @@ -150,7 +150,7 @@ Sexpr* parse(char* s) { Sexpr* vals = vals_parse(tokens); sexpr_free(tokens); if(!balance_checker(vals)) { - printf("unbalanced parenthesis\n"); + WARN("unbalanced parenthesis", ""); sexpr_free(vals); return NULL; } diff --git a/src/repl.c b/src/repl.c index b076f16..db3e492 100644 --- a/src/repl.c +++ b/src/repl.c @@ -26,13 +26,14 @@ int main(int argc, char** argv) { add_history(input); Sexpr* in = parse(input); if(in == NULL) { - printf("bad input\n"); + ERR("bad input\n", ""); } else { //printf("- -%s\n", sprint_sexpr(in)); Sexpr* out = eval(clone(in), env); char* outstr = sprint_sexpr(out); - printf(" - %s\n", outstr); + PRINTMV(" - ", outstr); + //printf(" - %s\n", outstr); sexpr_free(in); sexpr_free(out); free(outstr); diff --git a/src/sexpr.c b/src/sexpr.c index c77bfdb..7d37562 100644 --- a/src/sexpr.c +++ b/src/sexpr.c @@ -186,7 +186,7 @@ Sexpr* reverse(Sexpr* s) { char* sprint_sexpr(Sexpr* s) { if(s == NULL) { - printf("UH OH IT'S NULL\n"); + WARN("UH OH IT'S NULL", ""); return NULL; } // assumes not null