]> git.eli173.com Git - klapaucius/commitdiff
made warning/error/printing macros to clean things up a bit
authorElijah Cohen <eli@eli173.com>
Fri, 27 Sep 2024 19:03:15 +0000 (14:03 -0500)
committerElijah Cohen <eli@eli173.com>
Fri, 27 Sep 2024 19:03:15 +0000 (14:03 -0500)
src/builtins/arithmetic.c
src/eval.c
src/parser.c
src/repl.c
src/sexpr.c

index a64e5c5b1f59b173c641663450b04900cc49f0d4..6b21be048b7f6a85f77d849436aae6c5681ce80a 100644 (file)
@@ -1,4 +1,5 @@
 
+#include "../config.h"
 #include "../types.h"
 #include "../builtins.h"
 #include "../sexpr.h"
index 986be0bc34c437eece2135f060ba16a4e49255f6..70325b20175ae9d7f59a76c11237a461803370e3 100644 (file)
@@ -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;
                }
index d70ea5905249b0760dda6082f987097cf5e1c78a..202e2893a6be9395e8bc27fbbee9d198c0341f4b 100644 (file)
@@ -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;
        }
index b076f16eed040500eeac942fabf3119054b9cb13..db3e4921f4036cd554b31956a7a92e73cf93b61a 100644 (file)
@@ -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);
index c77bfdb77e42d2690803c26446ec9c07b6acb645..7d375624981d2c8995c475360949c85bb46dc5f9 100644 (file)
@@ -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