lang: ast: fix incorrect return types; add function to determine expression tokens

This commit is contained in:
2024-11-27 12:56:10 +00:00
parent cd89c20beb
commit ad25b89af0
6 changed files with 127 additions and 21 deletions

28
lang/ast/expr.c Normal file
View File

@@ -0,0 +1,28 @@
#include "ctx.h"
#include "node.h"
#include <blue/object/string.h>
#include <ivy/lang/lex.h>
struct expr_parser_state {
struct parser_state s_base;
};
static enum ivy_status add_child(
struct ivy_ast_node *parent, struct ivy_ast_node *child)
{
struct ivy_ast_expr_node *c = (struct ivy_ast_expr_node *)parent;
if (!c->n_child) {
c->n_child = child;
return IVY_OK;
}
return IVY_ERR_NOT_SUPPORTED;
}
struct ast_node_type expr_node_ops = {
.n_add_child = add_child,
.n_state_size = sizeof(struct expr_parser_state),
.n_node_size = sizeof(struct ivy_ast_expr_node),
};