From 6ca377762516888b0488d60c971e0660ae6035f4 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Fri, 14 Oct 2016 22:17:01 +0200 Subject: token_list using an array for memory efficiency --- interpreter/print.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'interpreter/print.c') 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" : " "); } } -- cgit v1.2.3