diff --git a/src/exec.c b/src/exec.c index 57928ca..a28a8e3 100644 --- a/src/exec.c +++ b/src/exec.c @@ -8,14 +8,12 @@ extern AST* root; ASTNumData exec_expr(AST* ast) { - ast_print(ast); + // ast_print(ast); log_dbg("Started execution."); switch (ast->type) { case AST_TYPE_CALL: return exec_call(ast); - case AST_TYPE_NUM: - exec_print(*(ASTNumData*)ast->data); - return *(ASTNumData*)ast->data; - default: printf("what\n"); + case AST_TYPE_NUM: return *(ASTNumData*)ast->data; + default: printf("what\n"); } } diff --git a/src/grammar.y b/src/grammar.y index d47910e..32dd406 100644 --- a/src/grammar.y +++ b/src/grammar.y @@ -37,10 +37,9 @@ input: exp: NUM { $$ = ast_init(AST_TYPE_NUM, ast_num_data_init($1)); } | NUM PLUS NUM { - AST* argv[2] = { - ast_init(AST_TYPE_NUM, ast_num_data_init($1)), - ast_init(AST_TYPE_NUM, ast_num_data_init($3)) - }; + AST** argv = calloc(2, sizeof(AST*)); + argv[0] = ast_init(AST_TYPE_NUM, ast_num_data_init($1)); + argv[1] = ast_init(AST_TYPE_NUM, ast_num_data_init($3)); $$ = ast_init(AST_TYPE_CALL, ast_call_data_init("+", 2, argv)); } diff --git a/src/main.c b/src/main.c index 9e9fa97..8ad0a28 100644 --- a/src/main.c +++ b/src/main.c @@ -40,12 +40,11 @@ int main(int argc, char** argv) { log_dbgf("cline: %s", ln->buf); if (ln->ln > 0) { - // I hope to god it's null-terminated. inp = ln->buf; if (yyparse() == 0) printf("Parsed successfully!\n"); else printf("Parse error.\n"); - // exec_expr(root); + exec_print(exec_expr(root)); ast_print(root); }