lang: ast: re-write expression parser to support keyword messages

also adjust some parser state callbackss to better support sub-parsers returning
 results to their parents.
This commit is contained in:
2024-12-02 07:56:27 +00:00
parent 1c73e1d37b
commit 1c5b23d968
11 changed files with 605 additions and 613 deletions

View File

@@ -1,11 +1,11 @@
#include "ctx.h"
#include "node.h"
#include "block.h"
#include "ctx.h"
#include "iterate.h"
#include "node.h"
#include <blue/object/string.h>
#include <ivy/lang/lex.h>
#include <stdio.h>
static struct token_parse_result parse_end(
struct ivy_parser *ctx, struct ivy_token *tok)
@@ -21,7 +21,7 @@ static struct token_parse_result parse_end(
}
static struct token_parse_result parse_bang(
struct ivy_parser* ctx, struct ivy_token* tok)
struct ivy_parser *ctx, struct ivy_token *tok)
{
struct block_parser_state *state
= parser_get_state(ctx, struct block_parser_state);
@@ -51,9 +51,10 @@ static struct token_parse_result parse_expr_begin(
}
static enum ivy_status add_child(
struct ivy_ast_node *parent, struct ivy_ast_node *child)
struct parser_state *parent, struct ivy_ast_node *child)
{
struct ivy_ast_block_node *block = (struct ivy_ast_block_node *)parent;
struct ivy_ast_block_node *block
= (struct ivy_ast_block_node *)parent->s_node;
b_queue_push_back(&block->n_expr, &child->n_entry);
@@ -70,7 +71,7 @@ static void collect_children(
{
struct ivy_ast_block_node *block = (struct ivy_ast_block_node *)node;
b_queue_iterator it = {0};
b_queue_foreach(&it, &block->n_expr) {
b_queue_foreach (&it, &block->n_expr) {
struct ivy_ast_node *expr
= b_unbox(struct ivy_ast_node, it.entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, expr);