diff options
author | Camil Staps | 2016-10-14 22:17:01 +0200 |
---|---|---|
committer | Camil Staps | 2016-10-14 22:17:01 +0200 |
commit | 6ca377762516888b0488d60c971e0660ae6035f4 (patch) | |
tree | 74c6b013aa80f61cd0bd511a097e54a686b33680 /interpreter/print.c | |
parent | Make debug graphs a command line option (-g) (diff) |
token_list using an array for memory efficiency
Diffstat (limited to 'interpreter/print.c')
-rw-r--r-- | interpreter/print.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/interpreter/print.c b/interpreter/print.c index 5433fcb..e1ed9ed 100644 --- a/interpreter/print.c +++ b/interpreter/print.c @@ -20,8 +20,8 @@ void print_token(struct token *tk) { case TOKEN_CLOSE_SQ: c = ']'; break; case TOKEN_EQUALS: c = '='; break; case TOKEN_COMMA: c = ','; break; - case TOKEN_CODE: printf("code "); return; - case TOKEN_IMPORT: printf("import "); return; + case TOKEN_CODE: printf("code"); return; + case TOKEN_IMPORT: printf("import"); return; case TOKEN_NAME: printf("%s", (char*) tk->var); return; @@ -34,10 +34,10 @@ void print_token(struct token *tk) { } void print_token_list(struct token_list *list) { - print_token(&list->elem); - if (list->rest) { - printf(list->elem.kind == TOKEN_SEMICOLON ? "\n" : " "); - print_token_list(list->rest); + unsigned int i; + for (i = 0; i < list->index; i++) { + print_token(&list->elems[i]); + printf(list->elems[i].kind == TOKEN_SEMICOLON ? "\n" : " "); } } |