stage1 完成ast 定义sema

This commit is contained in:
zzy
2026-08-03 12:39:28 +08:00
parent a4ec5656d2
commit 74d7376039
19 changed files with 3857 additions and 137 deletions

View File

@@ -4,10 +4,9 @@
#include "../stage0/include/utils.h"
#include "spl_lexer.h"
#include "spl_tok.h"
#include <math.h>
typedef enum {
SPL_AST_CONTAINER_MEMBER,
SPL_AST_CONTAINER_ITEM,
SPL_AST_FN_DECL,
SPL_AST_FN_DEFINE,
SPL_AST_TYPE_DECL,
@@ -37,7 +36,11 @@ struct spl_ast_node {
spl_ast_node_kind_t kind;
spl_ast_loc_t loc;
union {
spl_ast_node_ref_vec_t container_member;
struct {
spl_ast_node_ref_vec_t attr_list; /* attr_item */
spl_ast_node_ref_t self; /* self */
spl_ast_node_ref_vec_t members; /* container_decl 列表 */
} container_item;
struct {
const char *ident;
@@ -58,18 +61,8 @@ struct spl_ast_node {
} param_decl;
struct {
spl_ast_node_ref_vec_t attr_list; /* attr_item */
const char *name;
enum {
SPL_AST_TYPE_STRUCT,
SPL_AST_TYPE_UNION,
SPL_AST_TYPE_ENUM,
SPL_AST_TYPE_TYPE_EXPR,
} kind;
union {
spl_ast_node_ref_t type_expr;
spl_ast_node_ref_t aggregate_list;
};
spl_ast_node_ref_t type_expr;
} type_decl;
struct {
spl_ast_node_ref_vec_t attr_list; /* attr_item */
@@ -103,6 +96,7 @@ struct spl_ast_node {
SPL_AST_CONTINUE_STATEMENT,
SPL_AST_DEFER_STATEMENT,
SPL_AST_VARDECL,
SPL_AST_CONSTDECL,
SPL_AST_TYPEDECL,
SPL_AST_EXPR_STATEMENT,
} kind;
@@ -131,8 +125,8 @@ struct spl_ast_node {
} for_statement;
struct {
spl_ast_node_ref_t expr;
spl_ast_node_ref_vec_t paced_exprs;
spl_ast_node_ref_vec_t statements;
spl_ast_node_ref_vec_t paced_exprs; /* packed_expr */
spl_ast_node_ref_vec_t match_block; /* block_item */
} match_statement;
struct {
spl_ast_node_ref_t expr;
@@ -145,6 +139,7 @@ struct spl_ast_node {
spl_ast_node_ref_vec_t block_or_statement; /* block_item/statement */
} defer_statement;
spl_ast_node_ref_t var_decl;
spl_ast_node_ref_t const_decl;
spl_ast_node_ref_t type_decl;
spl_ast_node_ref_t expr_statement;
};
@@ -280,10 +275,13 @@ struct spl_ast_node {
struct {
spl_ast_node_ref_vec_t type_prefixs; /* prefix_type */
spl_ast_node_ref_vec_t attr_list; /* attr_item */
enum {
SPL_AST_BASE_TYPE_FN,
SPL_AST_BASE_TYPE_PATH,
SPL_AST_TYPE_STRUCT,
SPL_AST_TYPE_UNION,
SPL_AST_TYPE_ENUM,
} kind;
const char *spl_base_type;
@@ -293,6 +291,7 @@ struct spl_ast_node {
spl_ast_node_ref_vec_t param_list; /* param_decl */
spl_ast_node_ref_t type_expr;
} fn_type;
spl_ast_node_ref_vec_t aggregate_list; /* container_decl */
};
} type_expr;
struct {