minor implementation for parser

(simple type and defn)
This commit is contained in:
2025-11-23 22:07:04 +09:00
parent 3682559a56
commit d8c0b2a762
9 changed files with 476 additions and 13 deletions

36
include/ast_util.h Normal file
View File

@@ -0,0 +1,36 @@
#pragma once
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include "globals.h"
void ast_node_add_child(ASTNode *parent, ASTNode *child);
void ast_node_free(ASTNode *node);
void ast_node_print(ASTNode *node, int depth);
/*
NODE SPECIFIC FUNCTIONS
*/
ASTNode *ast_node_program();
ASTNode *ast_node_defn(Token tok_val, ASTNode *type, ASTNode *id, ASTNode *expr);
ASTNode *ast_node_type_simple(Token tok_id);
ASTNode *ast_node_type_complex(Token tok_bracket, ASTNode *type_param, ASTNode *type_out);
ASTNode *ast_node_type_param();
ASTNode *ast_node_type_out();
ASTNode *ast_node_type_star(Token tok_star);
ASTNode *ast_node_type_void();
ASTNode *ast_node_id(Token id);