lang: ast: fix incorrect return types; add function to determine expression tokens
This commit is contained in:
28
lang/ast/expr.c
Normal file
28
lang/ast/expr.c
Normal 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),
|
||||
};
|
||||
Reference in New Issue
Block a user