62 lines
1.4 KiB
C
62 lines
1.4 KiB
C
#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);
|
|
|
|
ASTNode *ast_node_num(Token num);
|
|
|
|
ASTNode *ast_node_str(Token str);
|
|
|
|
ASTNode *ast_node_star(Token star);
|
|
|
|
ASTNode *ast_node_andref(Token andref);
|
|
|
|
ASTNode *ast_node_expr(Token caller);
|
|
|
|
ASTNode *ast_node_param_list(Token tok_lparen);
|
|
|
|
ASTNode *ast_node_param(Token id, ASTNode *type);
|
|
|
|
ASTNode *ast_node_compound(Token tok_lcurly);
|
|
|
|
ASTNode *ast_node_lambda(ASTNode *param_list, ASTNode *body);
|
|
|
|
ASTNode *ast_node_stmt_return(Token tok_return, ASTNode *expr);
|
|
|
|
ASTNode *ast_node_stmt_expr(ASTNode *expr);
|
|
|
|
ASTNode *ast_node_stmt_if(Token tok_if, ASTNode *condition, ASTNode *then_branch, ASTNode *else_branch);
|
|
|
|
ASTNode *ast_node_stmt_set(Token tok_dollar, ASTNode *id, ASTNode *expr);
|