From 6a2b633d6fdc10ffb496f90912f57ec72daf25f6 Mon Sep 17 00:00:00 2001 From: A404M Date: Fri, 24 Jan 2025 04:22:47 +0330 Subject: some clean up --- src/compiler/ast-tree.c | 22 ++++++++++++++++++---- src/compiler/code-generator.c | 4 ++++ 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/compiler/ast-tree.c b/src/compiler/ast-tree.c index 76ee706..0a8811c 100644 --- a/src/compiler/ast-tree.c +++ b/src/compiler/ast-tree.c @@ -23,8 +23,20 @@ void astTreePrint(const AstTree *tree, int indent) { printf(" "); printf("arguments=[\n"); for (size_t i = 0; i < metadata->arguments_size; ++i) { - // astTreePrint(metadata->arguments[i], indent + 1); // TODO: do it - printf(",\n"); + for (int i = 0; i < indent + 1; ++i) + printf(" "); + printf("{name=%.*s,\n", + (int)(metadata->arguments[i].name_end - + metadata->arguments[i].name_begin), + metadata->arguments[i].name_begin); + for (int i = 0; i < indent + 1; ++i) + printf(" "); + printf("type=\n"); + astTreePrint(metadata->arguments[i].type, indent + 2); + printf("\n"); + for (int i = 0; i < indent + 1; ++i) + printf(" "); + printf("},\n"); } for (int i = 0; i < indent; ++i) printf(" "); @@ -281,8 +293,10 @@ AstTree *astTreeParseFunction(ParserNode *parserNode, function->arguments[function->arguments_size].value = NULL; function->arguments[function->arguments_size].type = type; - function->arguments[function->arguments_size].name_begin = arg_metadata->name->str_begin; - function->arguments[function->arguments_size].name_end = arg_metadata->name->str_end; + function->arguments[function->arguments_size].name_begin = + arg_metadata->name->str_begin; + function->arguments[function->arguments_size].name_end = + arg_metadata->name->str_end; function->arguments_size += 1; } diff --git a/src/compiler/code-generator.c b/src/compiler/code-generator.c index 932202a..035a471 100644 --- a/src/compiler/code-generator.c +++ b/src/compiler/code-generator.c @@ -63,6 +63,8 @@ CodeGeneratorCodes *codeGenerator(AstTreeRoot *astTreeRoot) { codes, createGenerateCode(NULL, NULL, CODE_GENERATOR_INSTRUCTION_PRINT)); continue; + case AST_TREE_TOKEN_TYPE_FUNCTION: + case AST_TREE_TOKEN_TYPE_VOID: case AST_TREE_TOKEN_NONE: } printLog("Bad token %d", variable->value->token); @@ -85,6 +87,8 @@ bool codeGeneratorAstTreeFunction(char *label_begin, char *label_end, CODE_GENERATOR_INSTRUCTION_PRINT)); goto OK; case AST_TREE_TOKEN_FUNCTION: + case AST_TREE_TOKEN_TYPE_FUNCTION: + case AST_TREE_TOKEN_TYPE_VOID: case AST_TREE_TOKEN_NONE: } printLog("Bad token %d", tree.token); -- cgit v1.2.3