diff options
author | Preston Pan <preston@nullring.xyz> | 2023-01-05 19:42:29 -0800 |
---|---|---|
committer | Preston Pan <preston@nullring.xyz> | 2023-01-05 19:42:29 -0800 |
commit | 7b544da27cf99dd1de9c25f59c76d924e1878e31 (patch) | |
tree | 9ab3c2b4274fd2ed11701c2cd7309b7e1150f1f0 /src/print.c | |
parent | 75bffac83e8e8a30ae7643a5d830e580d1ffee65 (diff) |
silence warnings
Diffstat (limited to 'src/print.c')
-rw-r--r-- | src/print.c | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/src/print.c b/src/print.c index 9339549..b2d4f32 100644 --- a/src/print.c +++ b/src/print.c @@ -2,24 +2,59 @@ #include "./include/ast.h" #include <stdio.h> -void print_string(ast_t *str) { printf("=> \"%s\"\n", str->string_value); } +void print_string(ast_t *str) { printf("%s\n", str->string_value); } -void print_int(ast_t *i) { printf("=> %d\n", i->int_value); } +void print_int(ast_t *i) { printf("%d\n", i->int_value); } void print_bool(ast_t *b) { if (b->bool_value) - printf("=> T\n"); + printf("T\n"); else - printf("=> F\n"); + printf("F\n"); } -void print_float(ast_t *f) { printf("=> %f\n", f->float_value); } +void print_float(ast_t *f) { printf("%f\n", f->float_value); } -void print_symbol(ast_t *s) { printf("=> %s\n", s->string_value); } +void print_symbol(ast_t *s) { printf("S: %s\n", s->string_value); } void print_func(ast_t *f) { print_pair(f->cdr); } -void print_pair(ast_t *p) {} +void print_pair(ast_t *p) { + printf("("); + ast_t *cur = p; + bool is_last = false; + + while (cur != NULL && (cur->cdr != NULL && cur->cdr->car != NULL)) { + if (cur->cdr == NULL) { + is_last = true; + } + switch (cur->car->type) { + case AST_STRING: + printf("%s", cur->car->string_value); + break; + case AST_INT: + printf("%d", cur->car->int_value); + break; + case AST_FLOAT: + printf("%d", cur->car->int_value); + break; + case AST_BOOL: + printf("%d", cur->car->int_value); + break; + case AST_FUNCTION: + break; + case AST_SYMBOL: + printf("%d", cur->car->int_value); + break; + case AST_PAIR: + printf("%d", cur->car->int_value); + break; + case AST_ROOT: + break; + } + cur = cur->cdr; + } +} void print(ast_t *res) { switch (res->type) { |