implemented function parsing
This commit is contained in:
parent
7d6436bb97
commit
b504739d59
6 changed files with 80 additions and 9 deletions
10
lc.c
10
lc.c
|
|
@ -168,7 +168,13 @@ void print_ast(ast_node *node, int depth) {
|
|||
print_ast(node->expr.var_decl.value, depth + 1);
|
||||
break;
|
||||
case NODE_FUNCTION:
|
||||
printf("FunctionDef (Fields missing in struct)\n");
|
||||
printf("Function: %.*s\n", (int)node->expr.function.name_len, node->expr.function.name);
|
||||
m = node->expr.function.parameters;
|
||||
while (m) {
|
||||
print_ast(m->type, depth + 1);
|
||||
m = m->next;
|
||||
}
|
||||
print_ast(node->expr.function.body, depth + 1);
|
||||
break;
|
||||
case NODE_RETURN:
|
||||
printf("Return:\n");
|
||||
|
|
@ -203,7 +209,7 @@ void print_ast(ast_node *node, int depth) {
|
|||
|
||||
int main(void)
|
||||
{
|
||||
FILE *fp = fopen("test.c", "r");
|
||||
FILE *fp = fopen("test.l", "r");
|
||||
usize size = 0;
|
||||
fseek(fp, 0, SEEK_END);
|
||||
size = ftell(fp);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue