lang: update bluelib api usage

This commit is contained in:
2025-11-06 10:38:32 +00:00
parent b26c37c349
commit 4386965cd9
40 changed files with 351 additions and 271 deletions

View File

@@ -11,5 +11,5 @@ else ()
endif () endif ()
target_include_directories(ivy-lang PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/) target_include_directories(ivy-lang PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/)
target_link_libraries(ivy-lang mie ivy-diag ivy-common Bluelib::Core Bluelib::Object Bluelib::Term) target_link_libraries(ivy-lang mie ivy-diag ivy-common Bluelib::Core Bluelib::Ds Bluelib::Term)
target_compile_definitions(ivy-lang PRIVATE IVY_EXPORT=1 IVY_STATIC=${IVY_STATIC}) target_compile_definitions(ivy-lang PRIVATE IVY_EXPORT=1 IVY_STATIC=${IVY_STATIC})

View File

@@ -1,13 +1,14 @@
#include "ctx.h" #include "ctx.h"
#include "node.h" #include "node.h"
#include <blue/object/string.h> #include <blue/ds/string.h>
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, b_string *str)
{ {
struct ivy_ast_atom_node *v = (struct ivy_ast_atom_node *)node; struct ivy_ast_atom_node *v = (struct ivy_ast_atom_node *)node;
b_string_append_cstrf(str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type), b_string_append_cstrf(
str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type),
v->n_content->t_str); v->n_content->t_str);
} }

View File

@@ -5,7 +5,7 @@
#include "iterate.h" #include "iterate.h"
#include "node.h" #include "node.h"
#include <blue/object/string.h> #include <blue/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
void block_add_terminator(struct block_parser_state *state, unsigned short tok) void block_add_terminator(struct block_parser_state *state, unsigned short tok)
@@ -143,11 +143,12 @@ static void collect_children(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator) struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
{ {
struct ivy_ast_block_node *block = (struct ivy_ast_block_node *)node; struct ivy_ast_block_node *block = (struct ivy_ast_block_node *)node;
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(&block->n_expr);
b_queue_foreach (&it, &block->n_expr) { while (entry) {
struct ivy_ast_node *expr struct ivy_ast_node *expr
= b_unbox(struct ivy_ast_node, it.entry, n_entry); = b_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, expr); ast_node_iterator_enqueue_node(iterator, node, expr);
entry = b_queue_next(entry);
} }
} }

View File

@@ -11,11 +11,12 @@ static void collect_children(
ast_node_iterator_enqueue_node(iterator, node, cascade->n_recipient); ast_node_iterator_enqueue_node(iterator, node, cascade->n_recipient);
} }
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(&cascade->n_msg);
b_queue_foreach (&it, &cascade->n_msg) { while (entry) {
struct ivy_ast_node *arg struct ivy_ast_node *arg
= b_unbox(struct ivy_ast_node, it.entry, n_entry); = b_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, arg); ast_node_iterator_enqueue_node(iterator, node, arg);
entry = b_queue_next(entry);
} }
} }

View File

@@ -2,7 +2,7 @@
#include "iterate.h" #include "iterate.h"
#include "node.h" #include "node.h"
#include <blue/object/string.h> #include <blue/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <stdio.h> #include <stdio.h>
@@ -162,17 +162,20 @@ static void collect_children(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator) struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
{ {
struct ivy_ast_class_node *c = (struct ivy_ast_class_node *)node; struct ivy_ast_class_node *c = (struct ivy_ast_class_node *)node;
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(&c->n_properties);
b_queue_foreach (&it, &c->n_properties) { while (entry) {
struct ivy_ast_node *child struct ivy_ast_node *child
= b_unbox(struct ivy_ast_node, it.entry, n_entry); = b_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, child); ast_node_iterator_enqueue_node(iterator, node, child);
entry = b_queue_next(entry);
} }
b_queue_foreach (&it, &c->n_msg_handlers) { entry = b_queue_first(&c->n_msg_handlers);
while (entry) {
struct ivy_ast_node *child struct ivy_ast_node *child
= b_unbox(struct ivy_ast_node, it.entry, n_entry); = b_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, child); ast_node_iterator_enqueue_node(iterator, node, child);
entry = b_queue_next(entry);
} }
} }

View File

@@ -339,11 +339,12 @@ static void cond_group_collect_children(
struct ivy_ast_cond_group_node *group struct ivy_ast_cond_group_node *group
= (struct ivy_ast_cond_group_node *)node; = (struct ivy_ast_cond_group_node *)node;
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(&group->n_branches);
b_queue_foreach (&it, &group->n_branches) { while (entry) {
struct ivy_ast_node *branch struct ivy_ast_node *branch
= b_unbox(struct ivy_ast_node, it.entry, n_entry); = b_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, branch); ast_node_iterator_enqueue_node(iterator, node, branch);
entry = b_queue_next(entry);
} }
} }

View File

@@ -1,8 +1,6 @@
#include "ctx.h" #include "ctx.h"
#include "node.h" #include "node.h"
#include <blue/object/string.h>
struct ast_node_type c_true_node_ops = { struct ast_node_type c_true_node_ops = {
.n_state_size = sizeof(struct parser_state), .n_state_size = sizeof(struct parser_state),
.n_node_size = sizeof(struct ivy_ast_node), .n_node_size = sizeof(struct ivy_ast_node),

View File

@@ -44,12 +44,13 @@ void ivy_parser_destroy(struct ivy_parser *parser, struct ivy_ast_node **result)
{ {
struct ivy_ast_node *root = NULL; struct ivy_ast_node *root = NULL;
b_queue_iterator it; b_queue_entry *entry = b_queue_first(&parser->p_state);
b_queue_iterator_begin(&parser->p_state, &it); ;
while (b_queue_iterator_is_valid(&it)) { while (entry) {
struct parser_state *state struct parser_state *state
= b_unbox(struct parser_state, it.entry, s_entry); = b_unbox(struct parser_state, entry, s_entry);
b_queue_iterator_erase(&it); b_queue_entry *next = b_queue_next(entry);
b_queue_delete(&parser->p_state, entry);
if (root) { if (root) {
ivy_ast_node_destroy(root); ivy_ast_node_destroy(root);
@@ -57,6 +58,7 @@ void ivy_parser_destroy(struct ivy_parser *parser, struct ivy_ast_node **result)
root = state->s_node; root = state->s_node;
free(state); free(state);
entry = next;
} }
if (result) { if (result) {

View File

@@ -1,7 +1,7 @@
#include "ctx.h" #include "ctx.h"
#include "node.h" #include "node.h"
#include <blue/object/string.h> #include <blue/ds/string.h>
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, b_string *str)
{ {

View File

@@ -3,7 +3,7 @@
#include "../node.h" #include "../node.h"
#include "expr.h" #include "expr.h"
#include <blue/object/string.h> #include <blue/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <ivy/lang/operator.h> #include <ivy/lang/operator.h>
#include <stdio.h> #include <stdio.h>
@@ -296,7 +296,7 @@ enum ivy_status expr_finalise_arith(
struct expr_parser_state *state, struct ivy_ast_node **expr_tree, struct expr_parser_state *state, struct ivy_ast_node **expr_tree,
enum ivy_operator_precedence minimum_precedence) enum ivy_operator_precedence minimum_precedence)
{ {
b_queue_iterator it = {0}; b_queue_entry *entry = NULL;
/* first, take all the operators still left on the operator stack and /* first, take all the operators still left on the operator stack and
* add them to the output queue. * add them to the output queue.
@@ -304,7 +304,7 @@ enum ivy_status expr_finalise_arith(
* since each set of parentheses has its own expression context, * since each set of parentheses has its own expression context,
* we don't have to handle parentheses here */ * we don't have to handle parentheses here */
while (true) { while (true) {
b_queue_entry *entry = b_queue_pop_back(&state->s_operator_stack); entry = b_queue_pop_back(&state->s_operator_stack);
if (!entry) { if (!entry) {
break; break;
} }
@@ -355,20 +355,21 @@ enum ivy_status expr_finalise_arith(
b_queue q = B_QUEUE_INIT; b_queue q = B_QUEUE_INIT;
b_queue_entry *tmp = NULL; b_queue_entry *tmp = NULL;
b_queue_iterator_begin(&state->s_output_queue, &it); entry = b_queue_first(&state->s_output_queue);
int i = 0; int i = 0;
while (b_queue_iterator_is_valid(&it)) { while (entry) {
struct ivy_ast_node *item struct ivy_ast_node *item
= b_unbox(struct ivy_ast_node, it.entry, n_entry); = b_unbox(struct ivy_ast_node, entry, n_entry);
b_queue_iterator_erase(&it); b_queue_entry *next = b_queue_next(entry);
b_queue_delete(&state->s_output_queue, entry);
/* if the node is an operand, just push it to a temporary queue /* if the node is an operand, just push it to a temporary queue
* and come back to it later. */ * and come back to it later. */
if (item->n_type != IVY_AST_OP && item->n_type != IVY_AST_MSG) { if (item->n_type != IVY_AST_OP && item->n_type != IVY_AST_MSG) {
/* operand */ /* operand */
b_queue_push_back(&q, &item->n_entry); b_queue_push_back(&q, &item->n_entry);
continue; goto next;
} }
const struct ivy_operator *op = NULL; const struct ivy_operator *op = NULL;
@@ -388,7 +389,7 @@ enum ivy_status expr_finalise_arith(
struct ivy_ast_node, tmp, n_entry); struct ivy_ast_node, tmp, n_entry);
} }
b_queue_push_back(&q, &msg->n_base.n_entry); b_queue_push_back(&q, &msg->n_base.n_entry);
continue; goto next;
} }
struct ivy_ast_op_node *op_node = (struct ivy_ast_op_node *)item; struct ivy_ast_op_node *op_node = (struct ivy_ast_op_node *)item;
@@ -397,7 +398,7 @@ enum ivy_status expr_finalise_arith(
* queue as-is */ * queue as-is */
if (op_node_is_complete(op_node)) { if (op_node_is_complete(op_node)) {
b_queue_push_back(&q, &item->n_entry); b_queue_push_back(&q, &item->n_entry);
continue; goto next;
} }
/* otherwise, pop the relevant operands from the operand /* otherwise, pop the relevant operands from the operand
@@ -432,6 +433,8 @@ enum ivy_status expr_finalise_arith(
/* ...and push the newly-completed operator node to the operand /* ...and push the newly-completed operator node to the operand
* queue */ * queue */
b_queue_push_back(&q, &op_node->n_base.n_entry); b_queue_push_back(&q, &op_node->n_base.n_entry);
next:
entry = next;
} }
#if 0 #if 0
@@ -445,13 +448,15 @@ enum ivy_status expr_finalise_arith(
* their operands have just been moved to the temporary operand stack * their operands have just been moved to the temporary operand stack
* used above. move them back to the parser state's output queue here * used above. move them back to the parser state's output queue here
* so they can be used later. */ * so they can be used later. */
b_queue_foreach (&it, &state->s_operator_stack) { entry = b_queue_first(&state->s_operator_stack);
b_queue_entry *entry = b_queue_pop_front(&q); while (entry) {
if (!entry) { b_queue_entry *entry2 = b_queue_pop_front(&q);
if (!entry2) {
return IVY_ERR_INTERNAL_FAILURE; return IVY_ERR_INTERNAL_FAILURE;
} }
b_queue_push_back(&state->s_output_queue, entry); b_queue_push_back(&state->s_output_queue, entry2);
entry = b_queue_next(entry);
} }
#if 0 #if 0
@@ -908,14 +913,17 @@ static struct ivy_ast_selector_node *keyword_selector_from_label_list(b_queue *l
struct ivy_ast_selector_node *sel struct ivy_ast_selector_node *sel
= (struct ivy_ast_selector_node *)ast_node_create(IVY_AST_SELECTOR); = (struct ivy_ast_selector_node *)ast_node_create(IVY_AST_SELECTOR);
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(labels);
b_queue_entry *next = NULL;
b_queue_iterator_begin(labels, &it); while (entry) {
while (b_queue_iterator_is_valid(&it)) {
struct ivy_token *label struct ivy_token *label
= b_unbox(struct ivy_token, it.entry, t_entry); = b_unbox(struct ivy_token, entry, t_entry);
b_queue_iterator_erase(&it); next = b_queue_next(entry);
b_queue_delete(labels, entry);
b_queue_push_back(&sel->n_arg_labels, &label->t_entry); b_queue_push_back(&sel->n_arg_labels, &label->t_entry);
entry = next;
} }
return sel; return sel;
@@ -929,13 +937,17 @@ static struct ivy_ast_cascade_node *expr_finalise_cascade(
cascade->n_recipient = state->s_recipient; cascade->n_recipient = state->s_recipient;
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(&state->s_cascade_msg);
b_queue_iterator_begin(&state->s_cascade_msg, &it); b_queue_entry *next = NULL;
while (b_queue_iterator_is_valid(&it)) {
while (entry) {
struct ivy_ast_node *msg struct ivy_ast_node *msg
= b_unbox(struct ivy_ast_node, it.entry, n_entry); = b_unbox(struct ivy_ast_node, entry, n_entry);
b_queue_iterator_erase(&it); next = b_queue_next(entry);
b_queue_delete(&state->s_cascade_msg, entry);
b_queue_push_back(&cascade->n_msg, &msg->n_entry); b_queue_push_back(&cascade->n_msg, &msg->n_entry);
entry = next;
} }
return cascade; return cascade;
@@ -950,15 +962,17 @@ static struct ivy_ast_msg_node *expr_finalise_keyword_msg(
msg->n_recipient = state->s_recipient; msg->n_recipient = state->s_recipient;
msg->n_sel = keyword_selector_from_label_list(&state->s_labels); msg->n_sel = keyword_selector_from_label_list(&state->s_labels);
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(&state->s_args);
b_queue_entry *next = NULL;
b_queue_iterator_begin(&state->s_args, &it); while (entry) {
while (b_queue_iterator_is_valid(&it)) {
struct ivy_ast_node *arg struct ivy_ast_node *arg
= b_unbox(struct ivy_ast_node, it.entry, n_entry); = b_unbox(struct ivy_ast_node, entry, n_entry);
b_queue_iterator_erase(&it); next = b_queue_next(entry);
b_queue_delete(&state->s_args, entry);
b_queue_push_back(&msg->n_arg, &arg->n_entry); b_queue_push_back(&msg->n_arg, &arg->n_entry);
entry = next;
} }
return msg; return msg;
@@ -974,22 +988,28 @@ static struct ivy_ast_msg_node *expr_finalise_complex_msg(
state->s_msg = NULL; state->s_msg = NULL;
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(&state->s_labels);
b_queue_iterator_begin(&state->s_labels, &it); b_queue_entry *next = NULL;
while (b_queue_iterator_is_valid(&it)) { while (entry) {
struct ivy_token *label struct ivy_token *label
= b_unbox(struct ivy_token, it.entry, t_entry); = b_unbox(struct ivy_token, entry, t_entry);
b_queue_iterator_erase(&it); next = b_queue_next(entry);
b_queue_delete(&state->s_labels, entry);
b_queue_push_back(&msg->n_sel->n_arg_labels, &label->t_entry); b_queue_push_back(&msg->n_sel->n_arg_labels, &label->t_entry);
entry = next;
} }
b_queue_iterator_begin(&state->s_args, &it); entry = b_queue_first(&state->s_args);
while (b_queue_iterator_is_valid(&it)) { while (entry) {
struct ivy_ast_node *arg struct ivy_ast_node *arg
= b_unbox(struct ivy_ast_node, it.entry, n_entry); = b_unbox(struct ivy_ast_node, entry, n_entry);
b_queue_iterator_erase(&it); next = b_queue_next(entry);
b_queue_delete(&state->s_args, entry);
b_queue_push_back(&msg->n_arg, &arg->n_entry); b_queue_push_back(&msg->n_arg, &arg->n_entry);
entry = next;
} }
return msg; return msg;

View File

@@ -1,7 +1,7 @@
#include "../node.h" #include "../node.h"
#include "expr.h" #include "expr.h"
#include <blue/object/string.h> #include <blue/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <ivy/lang/operator.h> #include <ivy/lang/operator.h>
#include <stdio.h> #include <stdio.h>

View File

@@ -1,13 +1,14 @@
#include "ctx.h" #include "ctx.h"
#include "node.h" #include "node.h"
#include <blue/object/string.h> #include <blue/ds/string.h>
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, b_string *str)
{ {
struct ivy_ast_ident_node *ident = (struct ivy_ast_ident_node *)node; struct ivy_ast_ident_node *ident = (struct ivy_ast_ident_node *)node;
b_string_append_cstrf(str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type), b_string_append_cstrf(
str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type),
ident->n_content->t_str); ident->n_content->t_str);
} }

View File

@@ -1,13 +1,14 @@
#include "ctx.h" #include "ctx.h"
#include "node.h" #include "node.h"
#include <blue/object/string.h> #include <blue/ds/string.h>
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, b_string *str)
{ {
struct ivy_ast_int_node *v = (struct ivy_ast_int_node *)node; struct ivy_ast_int_node *v = (struct ivy_ast_int_node *)node;
b_string_append_cstrf(str, "%s (%llu)", ivy_ast_node_type_to_string(node->n_type), b_string_append_cstrf(
str, "%s (%llu)", ivy_ast_node_type_to_string(node->n_type),
v->n_value->t_int); v->n_value->t_int);
} }

View File

@@ -63,12 +63,11 @@ enum ivy_status iterate_postorder(
b_queue_push_back(&it->it_queue, &node->n_it.it_entry); b_queue_push_back(&it->it_queue, &node->n_it.it_entry);
node->n_it.it_depth = 0; node->n_it.it_depth = 0;
b_queue_iterator q_it; b_queue_entry *entry = b_queue_first(&it->it_queue);
b_queue_iterator_begin(&it->it_queue, &q_it);
while (b_queue_iterator_is_valid(&q_it)) { while (entry) {
struct ivy_ast_node_iterator_entry *it_entry = b_unbox( struct ivy_ast_node_iterator_entry *it_entry = b_unbox(
struct ivy_ast_node_iterator_entry, q_it.entry, it_entry); struct ivy_ast_node_iterator_entry, entry, it_entry);
node = b_unbox(struct ivy_ast_node, it_entry, n_it); node = b_unbox(struct ivy_ast_node, it_entry, n_it);
if (!node) { if (!node) {
@@ -78,11 +77,11 @@ enum ivy_status iterate_postorder(
const struct ast_node_type *type = get_ast_node_type(node->n_type); const struct ast_node_type *type = get_ast_node_type(node->n_type);
if (type->n_collect_children) { if (type->n_collect_children) {
it->it_insert_after = q_it.entry; it->it_insert_after = entry;
type->n_collect_children(node, it); type->n_collect_children(node, it);
} }
b_queue_iterator_next(&q_it); entry = b_queue_next(entry);
} }
while (!b_queue_empty(&it->it_queue)) { while (!b_queue_empty(&it->it_queue)) {
@@ -111,12 +110,11 @@ enum ivy_status ivy_ast_node_iterate(
b_queue_push_back(&it->it_queue, &node->n_it.it_entry); b_queue_push_back(&it->it_queue, &node->n_it.it_entry);
node->n_it.it_depth = 0; node->n_it.it_depth = 0;
b_queue_iterator q_it; b_queue_entry *entry = b_queue_first(&it->it_queue);
b_queue_iterator_begin(&it->it_queue, &q_it);
while (b_queue_iterator_is_valid(&q_it)) { while (entry) {
struct ivy_ast_node_iterator_entry *it_entry = b_unbox( struct ivy_ast_node_iterator_entry *it_entry = b_unbox(
struct ivy_ast_node_iterator_entry, q_it.entry, it_entry); struct ivy_ast_node_iterator_entry, entry, it_entry);
node = b_unbox(struct ivy_ast_node, it_entry, n_it); node = b_unbox(struct ivy_ast_node, it_entry, n_it);
if (!node) { if (!node) {
@@ -132,11 +130,11 @@ enum ivy_status ivy_ast_node_iterate(
const struct ast_node_type *type = get_ast_node_type(node->n_type); const struct ast_node_type *type = get_ast_node_type(node->n_type);
if (type->n_collect_children) { if (type->n_collect_children) {
it->it_insert_after = q_it.entry; it->it_insert_after = entry;
type->n_collect_children(node, it); type->n_collect_children(node, it);
} }
b_queue_iterator_next(&q_it); entry = b_queue_next(entry);
} }
while (!b_queue_empty(&it->it_queue)) { while (!b_queue_empty(&it->it_queue)) {

View File

@@ -147,11 +147,12 @@ static void collect_children(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator) struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
{ {
struct ivy_ast_lambda_node *lambda = (struct ivy_ast_lambda_node *)node; struct ivy_ast_lambda_node *lambda = (struct ivy_ast_lambda_node *)node;
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(&lambda->n_arg);
b_queue_foreach (&it, &lambda->n_arg) { while (entry) {
struct ivy_ast_node *expr struct ivy_ast_node *expr
= b_unbox(struct ivy_ast_node, it.entry, n_entry); = b_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, expr); ast_node_iterator_enqueue_node(iterator, node, expr);
entry = b_queue_next(entry);
} }
if (lambda->n_body) { if (lambda->n_body) {

View File

@@ -1,7 +1,7 @@
#include "ctx.h" #include "ctx.h"
#include "node.h" #include "node.h"
#include <blue/object/string.h> #include <blue/ds/string.h>
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, b_string *str)
{ {

View File

@@ -262,10 +262,10 @@ static void match_collect_children(
ast_node_iterator_enqueue_node(iterator, node, match->n_cond); ast_node_iterator_enqueue_node(iterator, node, match->n_cond);
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(&match->n_branches);
b_queue_foreach (&it, &match->n_branches) { while (entry) {
struct ivy_ast_node *branch struct ivy_ast_node *branch
= b_unbox(struct ivy_ast_node, it.entry, n_entry); = b_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, branch); ast_node_iterator_enqueue_node(iterator, node, branch);
} }
} }

View File

@@ -16,11 +16,12 @@ static void collect_children(
iterator, node, (struct ivy_ast_node *)msg->n_sel); iterator, node, (struct ivy_ast_node *)msg->n_sel);
} }
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(&msg->n_arg);
b_queue_foreach (&it, &msg->n_arg) { while (entry) {
struct ivy_ast_node *arg struct ivy_ast_node *arg
= b_unbox(struct ivy_ast_node, it.entry, n_entry); = b_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, arg); ast_node_iterator_enqueue_node(iterator, node, arg);
entry = b_queue_next(entry);
} }
} }

View File

@@ -4,7 +4,7 @@
#include "ivy/status.h" #include "ivy/status.h"
#include "node.h" #include "node.h"
#include <blue/object/string.h> #include <blue/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
struct msgh_parser_state { struct msgh_parser_state {

View File

@@ -1,6 +1,6 @@
#include "node.h" #include "node.h"
#include <blue/object/string.h> #include <blue/ds/string.h>
#include <ivy/lang/ast.h> #include <ivy/lang/ast.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -250,7 +250,7 @@ struct ivy_ast_node *ast_node_create(enum ivy_ast_node_type type)
return node; return node;
} }
void ivy_ast_node_to_string(struct ivy_ast_node *node, struct b_string *out) void ivy_ast_node_to_string(struct ivy_ast_node *node, b_string *out)
{ {
const struct ast_node_type *type_info = get_ast_node_type(node->n_type); const struct ast_node_type *type_info = get_ast_node_type(node->n_type);
if (!type_info) { if (!type_info) {
@@ -304,12 +304,11 @@ void ivy_ast_node_destroy(struct ivy_ast_node *node)
b_queue_push_back(&it.it_queue, &node->n_it.it_entry); b_queue_push_back(&it.it_queue, &node->n_it.it_entry);
node->n_it.it_depth = 0; node->n_it.it_depth = 0;
b_queue_iterator q_it; b_queue_entry *entry = b_queue_first(&it.it_queue);
b_queue_iterator_begin(&it.it_queue, &q_it);
while (b_queue_iterator_is_valid(&q_it)) { while (entry) {
struct ivy_ast_node_iterator_entry *it_entry = b_unbox( struct ivy_ast_node_iterator_entry *it_entry = b_unbox(
struct ivy_ast_node_iterator_entry, q_it.entry, it_entry); struct ivy_ast_node_iterator_entry, entry, it_entry);
node = b_unbox(struct ivy_ast_node, it_entry, n_it); node = b_unbox(struct ivy_ast_node, it_entry, n_it);
if (!node) { if (!node) {
@@ -319,11 +318,11 @@ void ivy_ast_node_destroy(struct ivy_ast_node *node)
const struct ast_node_type *type = get_ast_node_type(node->n_type); const struct ast_node_type *type = get_ast_node_type(node->n_type);
if (type->n_collect_children) { if (type->n_collect_children) {
it.it_insert_after = q_it.entry; it.it_insert_after = entry;
type->n_collect_children(node, &it); type->n_collect_children(node, &it);
} }
b_queue_iterator_next(&q_it); entry = b_queue_next(entry);
} }
while (!b_queue_empty(&it.it_queue)) { while (!b_queue_empty(&it.it_queue)) {

View File

@@ -1,6 +1,7 @@
#ifndef _AST_NODE_H_ #ifndef _AST_NODE_H_
#define _AST_NODE_H_ #define _AST_NODE_H_
#include <blue/ds/string.h>
#include <ivy/lang/ast.h> #include <ivy/lang/ast.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
@@ -46,7 +47,7 @@ typedef struct token_parse_result (*token_parse_function)(
struct ast_node_type { struct ast_node_type {
enum ivy_status (*n_add_child)( enum ivy_status (*n_add_child)(
struct parser_state *, struct ivy_ast_node *); struct parser_state *, struct ivy_ast_node *);
void (*n_to_string)(struct ivy_ast_node *, struct b_string *); void (*n_to_string)(struct ivy_ast_node *, b_string *);
void (*n_init_state)(struct ivy_parser *, struct parser_state *, uintptr_t); void (*n_init_state)(struct ivy_parser *, struct parser_state *, uintptr_t);
void (*n_collect_children)( void (*n_collect_children)(
struct ivy_ast_node *, struct ivy_ast_node_iterator *); struct ivy_ast_node *, struct ivy_ast_node_iterator *);

View File

@@ -1,13 +1,16 @@
#include "ctx.h" #include "ctx.h"
#include "node.h"
#include "iterate.h" #include "iterate.h"
#include <blue/object/string.h> #include "node.h"
#include <blue/ds/string.h>
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, b_string *str)
{ {
struct ivy_ast_op_node *op = (struct ivy_ast_op_node *)node; struct ivy_ast_op_node *op = (struct ivy_ast_op_node *)node;
b_string_append_cstrf(str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type), ivy_operator_id_to_string(op->n_op->op_id)); b_string_append_cstrf(
str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type),
ivy_operator_id_to_string(op->n_op->op_id));
} }
static void collect_children( static void collect_children(

View File

@@ -4,8 +4,8 @@
#include "iterate.h" #include "iterate.h"
#include "node.h" #include "node.h"
#include <blue/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <blue/object/string.h>
enum package_type { enum package_type {
PACKAGE_NONE = 0, PACKAGE_NONE = 0,
@@ -34,9 +34,13 @@ struct package_parser_state {
struct ivy_ast_node *s_cond; struct ivy_ast_node *s_cond;
}; };
static enum ivy_status add_package_item(struct package_parser_state *state, struct ivy_ast_node *index, struct ivy_ast_node *value) static enum ivy_status add_package_item(
struct package_parser_state *state, struct ivy_ast_node *index,
struct ivy_ast_node *value)
{ {
struct ivy_ast_pkg_static_item_node *item = (struct ivy_ast_pkg_static_item_node *)ast_node_create(IVY_AST_PKG_ITEM); struct ivy_ast_pkg_static_item_node *item
= (struct ivy_ast_pkg_static_item_node *)ast_node_create(
IVY_AST_PKG_ITEM);
if (!item) { if (!item) {
return IVY_ERR_NO_MEMORY; return IVY_ERR_NO_MEMORY;
} }
@@ -64,7 +68,8 @@ static struct ivy_ast_node *finalise_package(struct package_parser_state *state)
switch (state->s_type) { switch (state->s_type) {
case PACKAGE_STATIC: case PACKAGE_STATIC:
s = (struct ivy_ast_pkg_static_node *)ast_node_create(IVY_AST_PKG_STATIC); s = (struct ivy_ast_pkg_static_node *)ast_node_create(
IVY_AST_PKG_STATIC);
if (!s) { if (!s) {
return NULL; return NULL;
@@ -74,7 +79,8 @@ static struct ivy_ast_node *finalise_package(struct package_parser_state *state)
state->s_items = B_QUEUE_INIT; state->s_items = B_QUEUE_INIT;
return (struct ivy_ast_node *)s; return (struct ivy_ast_node *)s;
case PACKAGE_DYNAMIC: case PACKAGE_DYNAMIC:
d = (struct ivy_ast_pkg_dynamic_node *)ast_node_create(IVY_AST_PKG_DYNAMIC); d = (struct ivy_ast_pkg_dynamic_node *)ast_node_create(
IVY_AST_PKG_DYNAMIC);
if (!d) { if (!d) {
return NULL; return NULL;
} }
@@ -98,7 +104,8 @@ static struct ivy_ast_node *finalise_package(struct package_parser_state *state)
static struct token_parse_result parse_equal_right_angle( static struct token_parse_result parse_equal_right_angle(
struct ivy_parser *ctx, struct ivy_token *tok) struct ivy_parser *ctx, struct ivy_token *tok)
{ {
struct package_parser_state *state = parser_get_state(ctx, struct package_parser_state); struct package_parser_state *state
= parser_get_state(ctx, struct package_parser_state);
if (state->s_type == PACKAGE_NONE) { if (state->s_type == PACKAGE_NONE) {
state->s_type = PACKAGE_STATIC; state->s_type = PACKAGE_STATIC;
@@ -123,7 +130,9 @@ static struct token_parse_result parse_equal_right_angle(
state->s_next_index = state->s_prev_node; state->s_next_index = state->s_prev_node;
state->s_prev_node = NULL; state->s_prev_node = NULL;
struct expr_parser_state *expr = (struct expr_parser_state *)parser_push_state(ctx, IVY_AST_EXPR, 0); struct expr_parser_state *expr
= (struct expr_parser_state *)parser_push_state(
ctx, IVY_AST_EXPR, 0);
expr_add_terminator(expr, IVY_SYM_COMMA); expr_add_terminator(expr, IVY_SYM_COMMA);
expr->s_subexpr_depth = 1; expr->s_subexpr_depth = 1;
@@ -133,7 +142,8 @@ static struct token_parse_result parse_equal_right_angle(
static struct token_parse_result parse_comma( static struct token_parse_result parse_comma(
struct ivy_parser *ctx, struct ivy_token *tok) struct ivy_parser *ctx, struct ivy_token *tok)
{ {
struct package_parser_state *state = parser_get_state(ctx, struct package_parser_state); struct package_parser_state *state
= parser_get_state(ctx, struct package_parser_state);
if (state->s_type == PACKAGE_NONE) { if (state->s_type == PACKAGE_NONE) {
state->s_type = PACKAGE_STATIC; state->s_type = PACKAGE_STATIC;
@@ -144,7 +154,8 @@ static struct token_parse_result parse_comma(
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
} }
if (state->s_prev != IVY_SYM_LEFT_BRACE && state->s_prev != IVY_SYM_COMMA && state->s_prev != IVY_SYM_EQUAL_RIGHT_ANGLE) { if (state->s_prev != IVY_SYM_LEFT_BRACE && state->s_prev != IVY_SYM_COMMA
&& state->s_prev != IVY_SYM_EQUAL_RIGHT_ANGLE) {
/* token unexpected at this time. */ /* token unexpected at this time. */
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
} }
@@ -154,14 +165,17 @@ static struct token_parse_result parse_comma(
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
} }
enum ivy_status status = add_package_item(state, state->s_next_index, state->s_prev_node); enum ivy_status status = add_package_item(
state, state->s_next_index, state->s_prev_node);
if (status != IVY_OK) { if (status != IVY_OK) {
return PARSE_RESULT(status, 0); return PARSE_RESULT(status, 0);
} }
state->s_prev = IVY_SYM_COMMA; state->s_prev = IVY_SYM_COMMA;
struct expr_parser_state *expr = (struct expr_parser_state *)parser_push_state(ctx, IVY_AST_EXPR, 0); struct expr_parser_state *expr
= (struct expr_parser_state *)parser_push_state(
ctx, IVY_AST_EXPR, 0);
expr_add_terminator(expr, IVY_SYM_EQUAL_RIGHT_ANGLE); expr_add_terminator(expr, IVY_SYM_EQUAL_RIGHT_ANGLE);
expr->s_subexpr_depth = 1; expr->s_subexpr_depth = 1;
@@ -171,7 +185,8 @@ static struct token_parse_result parse_comma(
static struct token_parse_result parse_right_brace( static struct token_parse_result parse_right_brace(
struct ivy_parser *ctx, struct ivy_token *tok) struct ivy_parser *ctx, struct ivy_token *tok)
{ {
struct package_parser_state *state = parser_get_state(ctx, struct package_parser_state); struct package_parser_state *state
= parser_get_state(ctx, struct package_parser_state);
if (state->s_type == PACKAGE_NONE) { if (state->s_type == PACKAGE_NONE) {
state->s_type = PACKAGE_STATIC; state->s_type = PACKAGE_STATIC;
@@ -181,13 +196,15 @@ static struct token_parse_result parse_right_brace(
switch (state->s_type) { switch (state->s_type) {
case PACKAGE_STATIC: case PACKAGE_STATIC:
if (state->s_prev != IVY_SYM_LEFT_BRACE && state->s_prev != IVY_SYM_COMMA && state->s_prev != IVY_SYM_EQUAL_RIGHT_ANGLE) { if (state->s_prev != IVY_SYM_LEFT_BRACE && state->s_prev != IVY_SYM_COMMA
&& state->s_prev != IVY_SYM_EQUAL_RIGHT_ANGLE) {
/* token unexpected at this time. */ /* token unexpected at this time. */
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
} }
if (state->s_prev_node) { if (state->s_prev_node) {
status = add_package_item(state, state->s_next_index, state->s_prev_node); status = add_package_item(
state, state->s_next_index, state->s_prev_node);
} }
break; break;
@@ -235,7 +252,8 @@ static struct token_parse_result parse_right_brace(
static struct token_parse_result parse_for( static struct token_parse_result parse_for(
struct ivy_parser *ctx, struct ivy_token *tok) struct ivy_parser *ctx, struct ivy_token *tok)
{ {
struct package_parser_state *state = parser_get_state(ctx, struct package_parser_state); struct package_parser_state *state
= parser_get_state(ctx, struct package_parser_state);
if (state->s_type == PACKAGE_NONE) { if (state->s_type == PACKAGE_NONE) {
state->s_type = PACKAGE_DYNAMIC; state->s_type = PACKAGE_DYNAMIC;
@@ -260,7 +278,9 @@ static struct token_parse_result parse_for(
state->s_transform = state->s_prev_node; state->s_transform = state->s_prev_node;
state->s_prev_node = NULL; state->s_prev_node = NULL;
struct expr_parser_state *expr = (struct expr_parser_state *)parser_push_state(ctx, IVY_AST_EXPR, 0); struct expr_parser_state *expr
= (struct expr_parser_state *)parser_push_state(
ctx, IVY_AST_EXPR, 0);
expr_add_terminator(expr, IVY_KW_IN); expr_add_terminator(expr, IVY_KW_IN);
expr->s_subexpr_depth = 1; expr->s_subexpr_depth = 1;
@@ -270,7 +290,8 @@ static struct token_parse_result parse_for(
static struct token_parse_result parse_in( static struct token_parse_result parse_in(
struct ivy_parser *ctx, struct ivy_token *tok) struct ivy_parser *ctx, struct ivy_token *tok)
{ {
struct package_parser_state *state = parser_get_state(ctx, struct package_parser_state); struct package_parser_state *state
= parser_get_state(ctx, struct package_parser_state);
if (state->s_type != PACKAGE_DYNAMIC) { if (state->s_type != PACKAGE_DYNAMIC) {
/* this token cannot be used in this context. */ /* this token cannot be used in this context. */
@@ -291,7 +312,9 @@ static struct token_parse_result parse_in(
state->s_item = state->s_prev_node; state->s_item = state->s_prev_node;
state->s_prev_node = NULL; state->s_prev_node = NULL;
struct expr_parser_state *expr = (struct expr_parser_state *)parser_push_state(ctx, IVY_AST_EXPR, 0); struct expr_parser_state *expr
= (struct expr_parser_state *)parser_push_state(
ctx, IVY_AST_EXPR, 0);
expr_add_terminator(expr, IVY_KW_IF); expr_add_terminator(expr, IVY_KW_IF);
expr->s_subexpr_depth = 1; expr->s_subexpr_depth = 1;
@@ -301,7 +324,8 @@ static struct token_parse_result parse_in(
static struct token_parse_result parse_if( static struct token_parse_result parse_if(
struct ivy_parser *ctx, struct ivy_token *tok) struct ivy_parser *ctx, struct ivy_token *tok)
{ {
struct package_parser_state *state = parser_get_state(ctx, struct package_parser_state); struct package_parser_state *state
= parser_get_state(ctx, struct package_parser_state);
if (state->s_type != PACKAGE_DYNAMIC) { if (state->s_type != PACKAGE_DYNAMIC) {
/* this token cannot be used in this context. */ /* this token cannot be used in this context. */
@@ -322,7 +346,9 @@ static struct token_parse_result parse_if(
state->s_source = state->s_prev_node; state->s_source = state->s_prev_node;
state->s_prev_node = NULL; state->s_prev_node = NULL;
struct expr_parser_state *expr = (struct expr_parser_state *)parser_push_state(ctx, IVY_AST_EXPR, 0); struct expr_parser_state *expr
= (struct expr_parser_state *)parser_push_state(
ctx, IVY_AST_EXPR, 0);
expr_add_terminator(expr, IVY_SYM_RIGHT_BRACE); expr_add_terminator(expr, IVY_SYM_RIGHT_BRACE);
expr->s_subexpr_depth = 1; expr->s_subexpr_depth = 1;
@@ -332,8 +358,7 @@ static struct token_parse_result parse_if(
static enum ivy_status add_child( static enum ivy_status add_child(
struct parser_state *parent, struct ivy_ast_node *child) struct parser_state *parent, struct ivy_ast_node *child)
{ {
struct package_parser_state *state struct package_parser_state *state = (struct package_parser_state *)parent;
= (struct package_parser_state *)parent;
if (state->s_prev_node) { if (state->s_prev_node) {
return IVY_ERR_BAD_SYNTAX; return IVY_ERR_BAD_SYNTAX;
@@ -346,19 +371,22 @@ static enum ivy_status add_child(
static void pkg_static_collect_children( static void pkg_static_collect_children(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator) struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
{ {
struct ivy_ast_pkg_static_node *pkg = (struct ivy_ast_pkg_static_node *)node; struct ivy_ast_pkg_static_node *pkg
= (struct ivy_ast_pkg_static_node *)node;
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(&pkg->n_items);
b_queue_foreach (&it, &pkg->n_items) { while (entry) {
struct ivy_ast_node *item = b_unbox(struct ivy_ast_node, it.entry, n_entry); struct ivy_ast_node *item
= b_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, item); ast_node_iterator_enqueue_node(iterator, node, item);
entry = b_queue_next(entry);
} }
} }
static void pkg_static_item_to_string(struct ivy_ast_node *node, b_string *str) static void pkg_static_item_to_string(struct ivy_ast_node *node, b_string *str)
{ {
struct ivy_ast_pkg_static_item_node *item = (struct ivy_ast_pkg_static_item_node *)node; struct ivy_ast_pkg_static_item_node *item
= (struct ivy_ast_pkg_static_item_node *)node;
b_string_append_cstr(str, ivy_ast_node_type_to_string(node->n_type)); b_string_append_cstr(str, ivy_ast_node_type_to_string(node->n_type));
@@ -370,7 +398,8 @@ static void pkg_static_item_to_string(struct ivy_ast_node *node, b_string *str)
static void pkg_static_item_collect_children( static void pkg_static_item_collect_children(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator) struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
{ {
struct ivy_ast_pkg_static_item_node *item = (struct ivy_ast_pkg_static_item_node *)node; struct ivy_ast_pkg_static_item_node *item
= (struct ivy_ast_pkg_static_item_node *)node;
if (item->n_index) { if (item->n_index) {
ast_node_iterator_enqueue_node(iterator, node, item->n_index); ast_node_iterator_enqueue_node(iterator, node, item->n_index);
@@ -384,7 +413,8 @@ static void pkg_static_item_collect_children(
static void pkg_dynamic_collect_children( static void pkg_dynamic_collect_children(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator) struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
{ {
struct ivy_ast_pkg_dynamic_node *pkg = (struct ivy_ast_pkg_dynamic_node *)node; struct ivy_ast_pkg_dynamic_node *pkg
= (struct ivy_ast_pkg_dynamic_node *)node;
if (pkg->n_transform) { if (pkg->n_transform) {
ast_node_iterator_enqueue_node(iterator, node, pkg->n_transform); ast_node_iterator_enqueue_node(iterator, node, pkg->n_transform);
@@ -410,7 +440,9 @@ static void init_state(struct ivy_parser *ctx, struct parser_state *sp, uintptr_
state->s_prev = IVY_SYM_LEFT_BRACE; state->s_prev = IVY_SYM_LEFT_BRACE;
state->s_next_implicit_index = 0; state->s_next_implicit_index = 0;
struct expr_parser_state *expr = (struct expr_parser_state *)parser_push_state(ctx, IVY_AST_EXPR, 0); struct expr_parser_state *expr
= (struct expr_parser_state *)parser_push_state(
ctx, IVY_AST_EXPR, 0);
expr_add_terminator(expr, IVY_KW_FOR); expr_add_terminator(expr, IVY_KW_FOR);
expr->s_subexpr_depth = 1; expr->s_subexpr_depth = 1;
} }

View File

@@ -5,7 +5,7 @@
#include "ivy/status.h" #include "ivy/status.h"
#include "node.h" #include "node.h"
#include <blue/object/string.h> #include <blue/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <stdio.h> #include <stdio.h>

View File

@@ -2,7 +2,7 @@
#include "ivy/status.h" #include "ivy/status.h"
#include "node.h" #include "node.h"
#include <blue/object/string.h> #include <blue/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <stdio.h> #include <stdio.h>
@@ -252,22 +252,19 @@ static void to_string(struct ivy_ast_node *node, b_string *str)
b_string_append_cstr(str, "("); b_string_append_cstr(str, "(");
} }
b_queue_iterator label_it = {0}; b_queue_entry *label_entry = b_queue_first(&sel->n_arg_labels);
b_queue_iterator name_it = {0}; b_queue_entry *name_entry = b_queue_first(&sel->n_arg_names);
b_queue_iterator_begin(&sel->n_arg_labels, &label_it);
b_queue_iterator_begin(&sel->n_arg_names, &name_it);
int i = 0; int i = 0;
while (b_queue_iterator_is_valid(&label_it)) { while (label_entry) {
if (i > 0) { if (i > 0) {
b_string_append_cstr(str, " "); b_string_append_cstr(str, " ");
} }
struct ivy_token *label, *name; struct ivy_token *label, *name;
label = b_unbox(struct ivy_token, label_it.entry, t_entry); label = b_unbox(struct ivy_token, label_entry, t_entry);
name = b_unbox(struct ivy_token, name_it.entry, t_entry); name = b_unbox(struct ivy_token, name_entry, t_entry);
if (label && label->t_type == IVY_TOK_LABEL && label->t_str) { if (label && label->t_type == IVY_TOK_LABEL && label->t_str) {
b_string_append_cstrf(str, "%s:", label->t_str); b_string_append_cstrf(str, "%s:", label->t_str);
@@ -283,8 +280,8 @@ static void to_string(struct ivy_ast_node *node, b_string *str)
i++; i++;
} }
b_queue_iterator_next(&label_it); label_entry = b_queue_next(label_entry);
b_queue_iterator_next(&name_it); name_entry = b_queue_next(name_entry);
} }
if (sel->n_msg_name && !b_queue_empty(&sel->n_arg_labels)) { if (sel->n_msg_name && !b_queue_empty(&sel->n_arg_labels)) {

View File

@@ -3,7 +3,7 @@
#include "iterate.h" #include "iterate.h"
#include "node.h" #include "node.h"
#include <blue/object/string.h> #include <blue/ds/string.h>
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, b_string *str)
{ {
@@ -68,11 +68,12 @@ static void collect_children(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator) struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
{ {
struct ivy_ast_fstring_node *str = (struct ivy_ast_fstring_node *)node; struct ivy_ast_fstring_node *str = (struct ivy_ast_fstring_node *)node;
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(&str->n_value);
b_queue_foreach (&it, &str->n_value) { while (entry) {
struct ivy_ast_node *child struct ivy_ast_node *child
= b_unbox(struct ivy_ast_node, it.entry, n_entry); = b_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, child); ast_node_iterator_enqueue_node(iterator, node, child);
entry = b_queue_next(entry);
} }
} }

View File

@@ -236,11 +236,12 @@ static void try_collect_children(
ast_node_iterator_enqueue_node(iterator, node, try->n_try); ast_node_iterator_enqueue_node(iterator, node, try->n_try);
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(&try->n_catch);
b_queue_foreach (&it, &try->n_catch) { while (entry) {
struct ivy_ast_node *catch struct ivy_ast_node *catch
= b_unbox(struct ivy_ast_node, it.entry, n_entry); = b_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, catch); ast_node_iterator_enqueue_node(iterator, node, catch);
entry = b_queue_next(entry);
} }
if (try->n_finally) { if (try->n_finally) {

View File

@@ -4,7 +4,7 @@
#include "ivy/status.h" #include "ivy/status.h"
#include "node.h" #include "node.h"
#include <blue/object/string.h> #include <blue/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <stdio.h> #include <stdio.h>
@@ -117,11 +117,12 @@ static void collect_children(
{ {
struct ivy_ast_tuple_node *tuple = (struct ivy_ast_tuple_node *)node; struct ivy_ast_tuple_node *tuple = (struct ivy_ast_tuple_node *)node;
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(&tuple->n_members);
b_queue_foreach (&it, &tuple->n_members) { while (entry) {
struct ivy_ast_node *item struct ivy_ast_node *item
= b_unbox(struct ivy_ast_node, it.entry, n_entry); = b_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, item); ast_node_iterator_enqueue_node(iterator, node, item);
entry = b_queue_next(entry);
} }
} }

View File

@@ -1,7 +1,7 @@
#include "ctx.h" #include "ctx.h"
#include "node.h" #include "node.h"
#include <blue/object/string.h> #include <blue/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <stdio.h> #include <stdio.h>
@@ -68,10 +68,9 @@ static void to_string(struct ivy_ast_node *node, b_string *str)
int i = 0; int i = 0;
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(&unit_import->n_ident);
b_queue_foreach (&it, &unit_import->n_ident) { while (entry) {
struct ivy_token *tok struct ivy_token *tok = b_unbox(struct ivy_token, entry, t_entry);
= b_unbox(struct ivy_token, it.entry, t_entry);
if (i > 0) { if (i > 0) {
b_string_append_cstr(str, "."); b_string_append_cstr(str, ".");
@@ -79,6 +78,7 @@ static void to_string(struct ivy_ast_node *node, b_string *str)
b_string_append_cstr(str, tok->t_str); b_string_append_cstr(str, tok->t_str);
i++; i++;
entry = b_queue_next(entry);
} }
b_string_append_cstr(str, ")"); b_string_append_cstr(str, ")");

View File

@@ -1,7 +1,7 @@
#include "ctx.h" #include "ctx.h"
#include "node.h" #include "node.h"
#include <blue/object/string.h> #include <blue/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <stdio.h> #include <stdio.h>
@@ -66,10 +66,9 @@ static void to_string(struct ivy_ast_node *node, b_string *str)
b_string_append_cstr(str, " ("); b_string_append_cstr(str, " (");
int i = 0; int i = 0;
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(&unit_package->n_ident);
b_queue_foreach (&it, &unit_package->n_ident) { while (entry) {
struct ivy_token *tok struct ivy_token *tok = b_unbox(struct ivy_token, entry, t_entry);
= b_unbox(struct ivy_token, it.entry, t_entry);
if (i > 0) { if (i > 0) {
b_string_append_cstr(str, "."); b_string_append_cstr(str, ".");

View File

@@ -58,11 +58,12 @@ static void collect_children(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator) struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
{ {
struct ivy_ast_unit_node *unit = (struct ivy_ast_unit_node *)node; struct ivy_ast_unit_node *unit = (struct ivy_ast_unit_node *)node;
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(&unit->n_children);
b_queue_foreach (&it, &unit->n_children) { while (entry) {
struct ivy_ast_node *child struct ivy_ast_node *child
= b_unbox(struct ivy_ast_node, it.entry, n_entry); = b_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, child); ast_node_iterator_enqueue_node(iterator, node, child);
entry = b_queue_next(entry);
} }
} }

View File

@@ -55,12 +55,12 @@ static enum ivy_status get_eval_type(
{ {
struct mie_type *type = NULL; struct mie_type *type = NULL;
b_queue_iterator it; b_queue_entry *entry = b_queue_first(&state->s_edges);
b_queue_foreach (&it, &state->s_edges) { while (entry) {
struct mie_phi_edge *edge struct mie_phi_edge *edge
= b_unbox(struct mie_phi_edge, it.entry, e_entry); = b_unbox(struct mie_phi_edge, entry, e_entry);
if (!edge->e_value) { if (!edge->e_value) {
continue; goto next;
} }
struct mie_type *edge_type struct mie_type *edge_type
@@ -68,8 +68,10 @@ static enum ivy_status get_eval_type(
if (!type) { if (!type) {
type = edge_type; type = edge_type;
continue;
} }
next:
entry = b_queue_next(entry);
} }
*out = type; *out = type;
@@ -92,13 +94,14 @@ static enum ivy_status emit_phi_instr(
size_t i = 0; size_t i = 0;
b_queue_iterator it; b_queue_entry *entry = b_queue_first(&state->s_edges);
b_queue_foreach (&it, &state->s_edges) { while (entry) {
struct mie_phi_edge *edge struct mie_phi_edge *edge
= b_unbox(struct mie_phi_edge, it.entry, e_entry); = b_unbox(struct mie_phi_edge, entry, e_entry);
memcpy(&edges[i], edge, sizeof *edge); memcpy(&edges[i], edge, sizeof *edge);
i++; i++;
entry = b_queue_next(entry);
} }
struct mie_value *phi = mie_builder_phi( struct mie_value *phi = mie_builder_phi(

View File

@@ -128,35 +128,36 @@ static enum ivy_status state_init(
static void serialise_selector( static void serialise_selector(
struct ivy_ast_selector_node *sel, b_stringstream *out) struct ivy_ast_selector_node *sel, b_stringstream *out)
{ {
b_stringstream_add(out, "_M"); b_stream_write_string(out, "_M", NULL);
if (sel->n_msg_name) { if (sel->n_msg_name) {
const char *msg_name = sel->n_msg_name->t_str; const char *msg_name = sel->n_msg_name->t_str;
b_stringstream_addf(out, "%zu%s", strlen(msg_name), msg_name); b_stream_write_fmt(out, NULL, "%zu%s", strlen(msg_name), msg_name);
} else { } else {
b_stringstream_add(out, "0"); b_stream_write_char(out, '0');
} }
b_queue_iterator it; b_queue_entry *entry = b_queue_first(&sel->n_arg_labels);
b_queue_foreach (&it, &sel->n_arg_labels) { while (entry) {
struct ivy_token *arg struct ivy_token *arg = b_unbox(struct ivy_token, entry, t_entry);
= b_unbox(struct ivy_token, it.entry, t_entry);
if (arg->t_type != IVY_TOK_IDENT && arg->t_type != IVY_TOK_LABEL) { if (arg->t_type != IVY_TOK_IDENT && arg->t_type != IVY_TOK_LABEL) {
b_stringstream_addf(out, "0"); b_stream_write_char(out, '0');
continue; goto next;
} }
const char *label = arg->t_str; const char *label = arg->t_str;
if (label) { if (label) {
b_stringstream_addf(out, "%zu%s", strlen(label), label); b_stream_write_fmt(out, NULL, "%zu%s", strlen(label), label);
} else { } else {
b_stringstream_addf(out, "0"); b_stream_write_char(out, '0');
} }
next:
entry = b_queue_next(entry);
} }
b_stringstream_add(out, "E"); b_stream_write_char(out, 'E');
} }
static enum ivy_status state_fini( static enum ivy_status state_fini(
@@ -167,10 +168,11 @@ static enum ivy_status state_fini(
struct msg_codegen_state *msg = (struct msg_codegen_state *)state; struct msg_codegen_state *msg = (struct msg_codegen_state *)state;
b_stringstream str; b_stringstream *str = b_stringstream_create();
b_stringstream_begin_dynamic(&str); serialise_selector(msg->s_selector, str);
serialise_selector(msg->s_selector, &str); char *sel = b_stringstream_steal(str);
char *sel = b_stringstream_end(&str); b_stringstream_unref(str);
struct mie_value *sel_value = mie_ctx_get_selector(gen->c_ctx, sel); struct mie_value *sel_value = mie_ctx_get_selector(gen->c_ctx, sel);
free(sel); free(sel);

View File

@@ -2,7 +2,7 @@
#include "var-map.h" #include "var-map.h"
#include <blue/core/stringstream.h> #include <blue/core/stringstream.h>
#include <blue/object/list.h> #include <blue/ds/list.h>
#include <mie/ir/block.h> #include <mie/ir/block.h>
#include <mie/ir/func.h> #include <mie/ir/func.h>
#include <mie/ir/module.h> #include <mie/ir/module.h>
@@ -144,17 +144,17 @@ static struct code_generator_result gen_while_loop(
static void serialise_package_name(b_queue *parts, b_stringstream *out) static void serialise_package_name(b_queue *parts, b_stringstream *out)
{ {
b_stringstream_add(out, "_ZN"); b_stream_write_string(out, "_ZN", NULL);
b_queue_iterator it; b_queue_entry *entry = b_queue_first(parts);
b_queue_foreach (&it, parts) { while (entry) {
struct ivy_token *tok struct ivy_token *tok = b_unbox(struct ivy_token, entry, t_entry);
= b_unbox(struct ivy_token, it.entry, t_entry);
size_t len = strlen(tok->t_str); size_t len = strlen(tok->t_str);
b_stringstream_addf(out, "%zu%s", len, tok->t_str); b_stream_write_fmt(out, NULL, "%zu%s", len, tok->t_str);
entry = b_queue_next(entry);
} }
b_stringstream_add(out, "E"); b_stream_write_char(out, 'E');
} }
static struct code_generator_result gen_unit_package( static struct code_generator_result gen_unit_package(
@@ -165,10 +165,10 @@ static struct code_generator_result gen_unit_package(
struct ivy_ast_unit_package_node *pkg struct ivy_ast_unit_package_node *pkg
= (struct ivy_ast_unit_package_node *)node; = (struct ivy_ast_unit_package_node *)node;
b_stringstream str; b_stringstream *str = b_stringstream_create();
b_stringstream_begin_dynamic(&str); serialise_package_name(&pkg->n_ident, str);
serialise_package_name(&pkg->n_ident, &str); char *ident = b_stringstream_steal(str);
char *ident = b_stringstream_end(&str); b_stringstream_unref(str);
struct mie_value *ident_val = mie_ctx_get_string(gen->c_ctx, ident); struct mie_value *ident_val = mie_ctx_get_string(gen->c_ctx, ident);
free(ident); free(ident);
@@ -198,10 +198,10 @@ static struct code_generator_result gen_unit_import(
import_list = MIE_ARRAY(rec->r_value); import_list = MIE_ARRAY(rec->r_value);
} }
b_stringstream str; b_stringstream *str = b_stringstream_create();
b_stringstream_begin_dynamic(&str); serialise_package_name(&pkg->n_ident, str);
serialise_package_name(&pkg->n_ident, &str); char *ident = b_stringstream_steal(str);
char *ident = b_stringstream_end(&str); b_stringstream_unref(str);
struct mie_value *ident_val = mie_ctx_get_string(gen->c_ctx, ident); struct mie_value *ident_val = mie_ctx_get_string(gen->c_ctx, ident);
free(ident); free(ident);

View File

@@ -1,7 +1,7 @@
#include "var-map.h" #include "var-map.h"
#include <blue/object/hashmap.h> #include <blue/ds/hashmap.h>
#include <blue/object/string.h> #include <blue/ds/string.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -15,7 +15,7 @@ enum ivy_status codegen_var_map_init(struct codegen_var_map *map)
enum ivy_status codegen_var_map_fini(struct codegen_var_map *map) enum ivy_status codegen_var_map_fini(struct codegen_var_map *map)
{ {
b_hashmap_release(map->m_map); b_hashmap_unref(map->m_map);
return IVY_OK; return IVY_OK;
} }

View File

@@ -1,9 +1,9 @@
#ifndef CODEGEN_VAR_MAP_H_ #ifndef CODEGEN_VAR_MAP_H_
#define CODEGEN_VAR_MAP_H_ #define CODEGEN_VAR_MAP_H_
#include <blue/ds/hashmap.h>
#include <ivy/status.h> #include <ivy/status.h>
struct b_hashmap;
struct mie_value; struct mie_value;
struct ivy_ast_node; struct ivy_ast_node;
@@ -20,7 +20,7 @@ struct codegen_var {
}; };
struct codegen_var_map { struct codegen_var_map {
struct b_hashmap *m_map; b_hashmap *m_map;
}; };
extern enum ivy_status codegen_var_map_init(struct codegen_var_map *map); extern enum ivy_status codegen_var_map_init(struct codegen_var_map *map);

View File

@@ -2,6 +2,7 @@
#define IVY_LANG_AST_H_ #define IVY_LANG_AST_H_
#include <blue/core/queue.h> #include <blue/core/queue.h>
#include <blue/ds/string.h>
#include <ivy/lang/operator.h> #include <ivy/lang/operator.h>
#include <ivy/lang/selector.h> #include <ivy/lang/selector.h>
#include <ivy/misc.h> #include <ivy/misc.h>
@@ -364,7 +365,7 @@ IVY_API struct ivy_ast_node *ivy_ast_node_create(enum ivy_ast_node_type type);
IVY_API enum ivy_status ivy_ast_node_iterate( IVY_API enum ivy_status ivy_ast_node_iterate(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *it, struct ivy_ast_node *node, struct ivy_ast_node_iterator *it,
ivy_ast_node_iteration_callback callback, void *arg); ivy_ast_node_iteration_callback callback, void *arg);
IVY_API void ivy_ast_node_to_string(struct ivy_ast_node *node, struct b_string *out); IVY_API void ivy_ast_node_to_string(struct ivy_ast_node *node, b_string *out);
IVY_API void ivy_ast_node_set_bounds_from_token( IVY_API void ivy_ast_node_set_bounds_from_token(
struct ivy_ast_node *parent, const struct ivy_token *tok); struct ivy_ast_node *parent, const struct ivy_token *tok);
IVY_API void ivy_ast_node_extend_bounds( IVY_API void ivy_ast_node_extend_bounds(

View File

@@ -1,9 +1,10 @@
#include <stdio.h>
#include "lex.h" #include "lex.h"
#include <ivy/lang/lex.h>
#include <ivy/lang/internal.h> #include <blue/ds/number.h>
#include <blue/object/number.h>
#include <blue/term/print.h> #include <blue/term/print.h>
#include <ivy/lang/internal.h>
#include <ivy/lang/lex.h>
#include <stdio.h>
static void print_symbol_node(struct ivy_lexer_symbol_node *node, int depth) static void print_symbol_node(struct ivy_lexer_symbol_node *node, int depth)
{ {
@@ -19,27 +20,31 @@ static void print_symbol_node(struct ivy_lexer_symbol_node *node, int depth)
b_printf("\n"); b_printf("\n");
b_queue_iterator it; b_queue_entry *entry = b_queue_first(&node->s_children);
b_queue_foreach (&it, &node->s_children) { while (entry) {
struct ivy_lexer_symbol_node *child = b_unbox( struct ivy_lexer_symbol_node *child
struct ivy_lexer_symbol_node, it.entry, s_entry); = b_unbox(struct ivy_lexer_symbol_node, entry, s_entry);
print_symbol_node(child, depth + 1); print_symbol_node(child, depth + 1);
entry = b_queue_next(entry);
} }
} }
void internal_lexer_print_symbol_tree(struct ivy_lexer* lex) void internal_lexer_print_symbol_tree(struct ivy_lexer *lex)
{ {
print_symbol_node(lex->lex_sym_tree, -1); print_symbol_node(lex->lex_sym_tree, -1);
} }
void internal_lexer_print_keyword_dict(struct ivy_lexer* lex) void internal_lexer_print_keyword_dict(struct ivy_lexer *lex)
{ {
b_dict_iterator it = {0}; b_iterator *it = b_iterator_begin(lex->lex_keywords);
b_dict_foreach(&it, lex->lex_keywords) { b_foreach_ptr(b_dict_item, item, it)
const char *kw_name = it.key; {
enum ivy_keyword kw_id = b_number_get_int(B_NUMBER(it.value)); const b_string *kw_name = item->key;
enum ivy_keyword kw_id = b_number_get_int(item->value);
b_printf("([magenta]%s[reset]) = [green]%s[reset]\n", ivy_keyword_to_string(kw_id), kw_name); b_printf(
"([magenta]%s[reset]) = [green]%s[reset]\n",
ivy_keyword_to_string(kw_id), b_string_ptr(kw_name));
} }
} }

View File

@@ -2,9 +2,9 @@
#include <blue/core/hash.h> #include <blue/core/hash.h>
#include <blue/core/queue.h> #include <blue/core/queue.h>
#include <blue/object/dict.h> #include <blue/ds/dict.h>
#include <blue/object/number.h> #include <blue/ds/number.h>
#include <blue/object/string.h> #include <blue/ds/string.h>
#include <ctype.h> #include <ctype.h>
#include <ivy/diag.h> #include <ivy/diag.h>
#include <ivy/lang/diag.h> #include <ivy/lang/diag.h>
@@ -17,10 +17,7 @@
#define LINEBUF_DEFAULT_CAPACITY 1024 #define LINEBUF_DEFAULT_CAPACITY 1024
#define LEX_TOKEN_DEF(i, n) \ #define LEX_TOKEN_DEF(i, n) {.id = (i), .name = (n)}
{ \
.id = (i), .name = (n) \
}
static struct lex_token_def keywords[] = { static struct lex_token_def keywords[] = {
LEX_TOKEN_DEF(IVY_KW_PACKAGE, "package"), LEX_TOKEN_DEF(IVY_KW_PACKAGE, "package"),
@@ -154,27 +151,31 @@ static struct lexer_state *get_lexer_state(struct ivy_lexer *lex)
static void destroy_state_stack(b_queue *state) static void destroy_state_stack(b_queue *state)
{ {
b_queue_iterator it; b_queue_entry *entry = b_queue_first(state);
b_queue_iterator_begin(state, &it); while (entry) {
while (b_queue_iterator_is_valid(&it)) {
struct lexer_state *node struct lexer_state *node
= b_unbox(struct lexer_state, it.entry, s_entry); = b_unbox(struct lexer_state, entry, s_entry);
b_queue_iterator_erase(&it); b_queue_entry *next = b_queue_next(entry);
b_queue_delete(state, entry);
free(node); free(node);
entry = next;
} }
} }
static struct ivy_lexer_symbol_node *get_symbol_node( static struct ivy_lexer_symbol_node *get_symbol_node(
struct ivy_lexer_symbol_node *node, char c) struct ivy_lexer_symbol_node *node, char c)
{ {
b_queue_iterator it; b_queue_entry *entry = b_queue_first(&node->s_children);
b_queue_foreach (&it, &node->s_children) { while (entry) {
struct ivy_lexer_symbol_node *child = b_unbox( struct ivy_lexer_symbol_node *child
struct ivy_lexer_symbol_node, it.entry, s_entry); = b_unbox(struct ivy_lexer_symbol_node, entry, s_entry);
if (child->s_char == c) { if (child->s_char == c) {
return child; return child;
} }
entry = b_queue_next(entry);
} }
return NULL; return NULL;
@@ -221,14 +222,16 @@ static enum ivy_status put_symbol(
static void destroy_symbol_tree(struct ivy_lexer_symbol_node *tree) static void destroy_symbol_tree(struct ivy_lexer_symbol_node *tree)
{ {
b_queue_iterator it; b_queue_entry *entry = b_queue_first(&tree->s_children);
b_queue_iterator_begin(&tree->s_children, &it); while (entry) {
while (b_queue_iterator_is_valid(&it)) { struct ivy_lexer_symbol_node *node
struct ivy_lexer_symbol_node *node = b_unbox( = b_unbox(struct ivy_lexer_symbol_node, entry, s_entry);
struct ivy_lexer_symbol_node, it.entry, s_entry); b_queue_entry *next = b_queue_next(entry);
b_queue_iterator_erase(&it); b_queue_delete(&tree->s_children, entry);
destroy_symbol_tree(node); destroy_symbol_tree(node);
entry = next;
} }
free(tree); free(tree);
@@ -267,7 +270,7 @@ static void init_keywords(b_dict *keyword_dict)
static enum ivy_keyword find_keyword_by_name(struct ivy_lexer *lex, const char *s) static enum ivy_keyword find_keyword_by_name(struct ivy_lexer *lex, const char *s)
{ {
b_number *id = B_NUMBER(b_dict_at(lex->lex_keywords, s)); b_number *id = b_dict_at(lex->lex_keywords, s);
if (!id) { if (!id) {
return IVY_KW_NONE; return IVY_KW_NONE;
} }
@@ -312,14 +315,16 @@ enum ivy_status ivy_lexer_create(struct ivy_lexer **lexp)
void ivy_lexer_destroy(struct ivy_lexer *lex) void ivy_lexer_destroy(struct ivy_lexer *lex)
{ {
b_queue_iterator it = {0}; b_queue_entry *entry = b_queue_first(&lex->lex_queue);
b_queue_iterator_begin(&lex->lex_queue, &it);
while (entry) {
struct ivy_token *tok = b_unbox(struct ivy_token, entry, t_entry);
b_queue_entry *next = b_queue_next(entry);
b_queue_delete(&lex->lex_queue, entry);
while (b_queue_iterator_is_valid(&it)) {
struct ivy_token *tok
= b_unbox(struct ivy_token, it.entry, t_entry);
b_queue_iterator_erase(&it);
ivy_token_destroy(tok); ivy_token_destroy(tok);
entry = next;
} }
if (lex->lex_linebuf) { if (lex->lex_linebuf) {
@@ -331,11 +336,11 @@ void ivy_lexer_destroy(struct ivy_lexer *lex)
} }
if (lex->lex_temp) { if (lex->lex_temp) {
b_string_release(lex->lex_temp); b_string_unref(lex->lex_temp);
} }
if (lex->lex_keywords) { if (lex->lex_keywords) {
b_dict_release(lex->lex_keywords); b_dict_unref(lex->lex_keywords);
} }
destroy_state_stack(&lex->lex_state); destroy_state_stack(&lex->lex_state);

View File

@@ -2,8 +2,8 @@
#define _LEX_H_ #define _LEX_H_
#include <blue/core/queue.h> #include <blue/core/queue.h>
#include <blue/object/dict.h> #include <blue/ds/dict.h>
#include <blue/object/string.h> #include <blue/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <ivy/status.h> #include <ivy/status.h>
#include <stdint.h> #include <stdint.h>