lang: ast: add stub functions for retrieving, printing, interating, and destroying ast nodes
This commit is contained in:
@@ -112,3 +112,35 @@ void parser_pop_state(struct ivy_parser *parser, enum pop_state_flags flags)
|
||||
|
||||
free(state);
|
||||
}
|
||||
|
||||
bool ivy_parser_is_node_complete(struct ivy_parser *parser)
|
||||
{
|
||||
return (parser->p_state.q_first == parser->p_state.q_last);
|
||||
}
|
||||
|
||||
struct ivy_ast_node *ivy_parser_root_node(struct ivy_parser *parser)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_first(&parser->p_state);
|
||||
struct parser_state *state = b_unbox(struct parser_state, entry, s_entry);
|
||||
return state->s_node;
|
||||
}
|
||||
|
||||
struct ivy_ast_node *ivy_parser_dequeue_node(struct ivy_parser *parser)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_first(&parser->p_state);
|
||||
struct parser_state *state = b_unbox(struct parser_state, entry, s_entry);
|
||||
|
||||
if (state->s_node->n_type != IVY_AST_UNIT) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct ivy_ast_unit_node *unit = (struct ivy_ast_unit_node *)state->s_node;
|
||||
|
||||
entry = b_queue_pop_front(&unit->n_children);
|
||||
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b_unbox(struct ivy_ast_node, entry, n_entry);
|
||||
}
|
||||
@@ -78,3 +78,11 @@ enum ivy_status ast_node_add_child(
|
||||
|
||||
return add_child(parent, child);
|
||||
}
|
||||
|
||||
void ivy_ast_node_print(struct ivy_ast_node *node)
|
||||
{
|
||||
}
|
||||
|
||||
void ivy_ast_node_destroy(struct ivy_ast_node *node)
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user