lang: ast: implement simple identifier and operator expression parsing

This commit is contained in:
2024-11-27 22:29:29 +00:00
parent 31de937a21
commit 101d87e09d
4 changed files with 503 additions and 50 deletions

View File

@@ -16,6 +16,12 @@ enum token_parse_flags {
PARSE_REPEAT_TOKEN = 0x01u,
};
enum tok_expr_type {
TOK_EXPR_NONE = 0,
TOK_EXPR_BEGIN,
TOK_EXPR_ANY,
};
struct token_parse_result {
enum ivy_status r_status;
enum token_parse_flags r_flags;
@@ -38,13 +44,17 @@ struct ast_node_type {
token_parse_function n_token_parsers[IVY_TOK_TYPE_COUNT];
token_parse_function n_keyword_parsers[IVY_KW_TYPE_COUNT];
token_parse_function n_symbol_parsers[IVY_SYM_TYPE_COUNT];
token_parse_function n_expr_parser;
struct {
token_parse_function expr_begin;
token_parse_function expr_other;
token_parse_function expr_all;
} n_expr_parser;
};
extern const struct ast_node_type *get_ast_node_type(enum ivy_ast_node_type type);
extern token_parse_function get_token_parser(
struct ivy_ast_node *context, struct ivy_token *tok);
extern enum tok_expr_type get_tok_expr_type(struct ivy_token *tok);
extern struct ivy_ast_node *ast_node_create_with_size(
enum ivy_ast_node_type type, size_t size);
extern enum ivy_status ast_node_add_child(