lang: ast: implement caret (return) parsing

This commit is contained in:
2024-12-06 10:01:56 +00:00
parent d1855afc05
commit f3cd89c72a
6 changed files with 72 additions and 1 deletions

19
lang/ast/return.c Normal file
View File

@@ -0,0 +1,19 @@
#include "ctx.h"
#include "iterate.h"
#include "node.h"
static void collect_children(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
{
struct ivy_ast_return_node *ret = (struct ivy_ast_return_node *)node;
if (ret->n_val) {
ast_node_iterator_enqueue_node(iterator, node, ret->n_val);
}
}
struct ast_node_type return_node_ops = {
.n_collect_children = collect_children,
.n_state_size = sizeof(struct parser_state),
.n_node_size = sizeof(struct ivy_ast_return_node),
};