meta: replace bluelib with fx

This commit is contained in:
2026-03-16 14:07:33 +00:00
parent d2abb6faa3
commit e5546f97c2
105 changed files with 1668 additions and 1668 deletions

View File

@@ -1,10 +1,10 @@
#include "lex.h"
#include <blue/core/hash.h>
#include <blue/core/queue.h>
#include <blue/ds/dict.h>
#include <blue/ds/number.h>
#include <blue/ds/string.h>
#include <fx/core/hash.h>
#include <fx/core/queue.h>
#include <fx/ds/dict.h>
#include <fx/ds/number.h>
#include <fx/ds/string.h>
#include <ctype.h>
#include <ivy/diag.h>
#include <ivy/lang/diag.h>
@@ -163,40 +163,40 @@ static struct lexer_state *push_lexer_state(
state->s_type = state_type;
state->s_brace_depth = lex->lex_brace_depth;
b_queue_push_back(&lex->lex_state, &state->s_entry);
fx_queue_push_back(&lex->lex_state, &state->s_entry);
return state;
}
static void pop_lexer_state(struct ivy_lexer *lex)
{
b_queue_entry *entry = b_queue_pop_back(&lex->lex_state);
fx_queue_entry *entry = fx_queue_pop_back(&lex->lex_state);
if (!entry) {
return;
}
struct lexer_state *state = b_unbox(struct lexer_state, entry, s_entry);
struct lexer_state *state = fx_unbox(struct lexer_state, entry, s_entry);
free(state);
}
static struct lexer_state *get_lexer_state(struct ivy_lexer *lex)
{
b_queue_entry *entry = b_queue_last(&lex->lex_state);
fx_queue_entry *entry = fx_queue_last(&lex->lex_state);
if (!entry) {
return NULL;
}
return b_unbox(struct lexer_state, entry, s_entry);
return fx_unbox(struct lexer_state, entry, s_entry);
}
static void destroy_state_stack(b_queue *state)
static void destroy_state_stack(fx_queue *state)
{
b_queue_entry *entry = b_queue_first(state);
fx_queue_entry *entry = fx_queue_first(state);
while (entry) {
struct lexer_state *node
= b_unbox(struct lexer_state, entry, s_entry);
b_queue_entry *next = b_queue_next(entry);
b_queue_delete(state, entry);
= fx_unbox(struct lexer_state, entry, s_entry);
fx_queue_entry *next = fx_queue_next(entry);
fx_queue_delete(state, entry);
free(node);
@@ -207,27 +207,27 @@ static void destroy_state_stack(b_queue *state)
static struct ivy_lexer_symbol_node *get_symbol_node(
struct ivy_lexer_symbol_node *node, char c)
{
b_queue_entry *entry = b_queue_first(&node->s_children);
fx_queue_entry *entry = fx_queue_first(&node->s_children);
while (entry) {
struct ivy_lexer_symbol_node *child
= b_unbox(struct ivy_lexer_symbol_node, entry, s_entry);
= fx_unbox(struct ivy_lexer_symbol_node, entry, s_entry);
if (child->s_char == c) {
return child;
}
entry = b_queue_next(entry);
entry = fx_queue_next(entry);
}
return NULL;
}
static b_string *get_temp_string(struct ivy_lexer *lex)
static fx_string *get_temp_string(struct ivy_lexer *lex)
{
if (!lex->lex_temp) {
lex->lex_temp = b_string_create();
lex->lex_temp = fx_string_create();
}
b_string_clear(lex->lex_temp);
fx_string_clear(lex->lex_temp);
return lex->lex_temp;
}
@@ -252,7 +252,7 @@ static enum ivy_status put_symbol(
child->s_def = NULL;
child->s_char = c;
b_queue_push_back(&tree->s_children, &child->s_entry);
fx_queue_push_back(&tree->s_children, &child->s_entry);
tree = child;
}
@@ -262,12 +262,12 @@ static enum ivy_status put_symbol(
static void destroy_symbol_tree(struct ivy_lexer_symbol_node *tree)
{
b_queue_entry *entry = b_queue_first(&tree->s_children);
fx_queue_entry *entry = fx_queue_first(&tree->s_children);
while (entry) {
struct ivy_lexer_symbol_node *node
= b_unbox(struct ivy_lexer_symbol_node, entry, s_entry);
b_queue_entry *next = b_queue_next(entry);
b_queue_delete(&tree->s_children, entry);
= fx_unbox(struct ivy_lexer_symbol_node, entry, s_entry);
fx_queue_entry *next = fx_queue_next(entry);
fx_queue_delete(&tree->s_children, entry);
destroy_symbol_tree(node);
@@ -300,22 +300,22 @@ static struct ivy_lexer_symbol_node *build_symbol_tree(void)
return root;
}
static void init_keywords(b_dict *keyword_dict)
static void init_keywords(fx_dict *keyword_dict)
{
for (size_t i = 0; i < nr_keywords; i++) {
struct lex_token_def *keyword = &keywords[i];
b_dict_put(keyword_dict, keyword->name, B_RV_INT(keyword->id));
fx_dict_put(keyword_dict, keyword->name, FX_RV_INT(keyword->id));
}
}
static enum ivy_keyword find_keyword_by_name(struct ivy_lexer *lex, const char *s)
{
b_number *id = b_dict_at(lex->lex_keywords, s);
fx_number *id = fx_dict_at(lex->lex_keywords, s);
if (!id) {
return IVY_KW_NONE;
}
return b_number_get_int(id);
return fx_number_get_int(id);
}
enum ivy_status ivy_lexer_create(struct ivy_lexer **lexp)
@@ -346,7 +346,7 @@ enum ivy_status ivy_lexer_create(struct ivy_lexer **lexp)
return IVY_ERR_NO_MEMORY;
}
lex->lex_keywords = b_dict_create();
lex->lex_keywords = fx_dict_create();
init_keywords(lex->lex_keywords);
*lexp = lex;
@@ -355,12 +355,12 @@ enum ivy_status ivy_lexer_create(struct ivy_lexer **lexp)
void ivy_lexer_destroy(struct ivy_lexer *lex)
{
b_queue_entry *entry = b_queue_first(&lex->lex_queue);
fx_queue_entry *entry = fx_queue_first(&lex->lex_queue);
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);
struct ivy_token *tok = fx_unbox(struct ivy_token, entry, t_entry);
fx_queue_entry *next = fx_queue_next(entry);
fx_queue_delete(&lex->lex_queue, entry);
ivy_token_destroy(tok);
@@ -376,11 +376,11 @@ void ivy_lexer_destroy(struct ivy_lexer *lex)
}
if (lex->lex_temp) {
b_string_unref(lex->lex_temp);
fx_string_unref(lex->lex_temp);
}
if (lex->lex_keywords) {
b_dict_unref(lex->lex_keywords);
fx_dict_unref(lex->lex_keywords);
}
destroy_state_stack(&lex->lex_state);
@@ -546,7 +546,7 @@ static enum ivy_status push_token(struct ivy_lexer *lex, struct ivy_token *tok)
tok->t_end.c_row = lex->lex_token_end_row;
tok->t_end.c_col = lex->lex_token_end_col;
b_queue_push_back(&lex->lex_queue, &tok->t_entry);
fx_queue_push_back(&lex->lex_queue, &tok->t_entry);
lex->lex_prev_token = tok->t_type;
return IVY_OK;
}
@@ -772,7 +772,7 @@ static enum ivy_status read_dquote_marker(struct ivy_lexer *lex)
static enum ivy_status read_atom(struct ivy_lexer *lex)
{
b_string *str = get_temp_string(lex);
fx_string *str = get_temp_string(lex);
while (true) {
int c = peek(lex);
@@ -790,24 +790,24 @@ static enum ivy_status read_atom(struct ivy_lexer *lex)
}
char s[] = {c, 0};
b_string_append_cstr(str, s);
fx_string_append_cstr(str, s);
set_token_end(lex);
advance(lex);
}
if (b_string_get_size(str, B_STRLEN_NORMAL) == 0) {
if (fx_string_get_size(str, FX_STRLEN_NORMAL) == 0) {
/* TODO report empty atom error */
return IVY_ERR_BAD_SYNTAX;
}
char *s = b_string_steal(str);
char *s = fx_string_steal(str);
return push_atom(lex, s);
}
static enum ivy_status read_string_content(struct ivy_lexer *lex)
{
int c;
b_string *str = get_temp_string(lex);
fx_string *str = get_temp_string(lex);
struct lexer_state *state = get_lexer_state(lex);
if (!str) {
@@ -830,16 +830,16 @@ static enum ivy_status read_string_content(struct ivy_lexer *lex)
}
char s[2] = {c, 0};
b_string_append_cstr(str, s);
fx_string_append_cstr(str, s);
set_token_end(lex);
advance(lex);
}
if (b_string_get_size(str, B_STRLEN_NORMAL) == 0) {
if (fx_string_get_size(str, FX_STRLEN_NORMAL) == 0) {
return IVY_OK;
}
char *s = b_string_steal(str);
char *s = fx_string_steal(str);
enum ivy_status status = push_string_content(lex, s);
if (status != IVY_OK) {
@@ -854,7 +854,7 @@ static enum ivy_status read_number(struct ivy_lexer *lex, bool negate)
int token_len = 0;
int base = 10;
int dots = 0;
b_string *str = get_temp_string(lex);
fx_string *str = get_temp_string(lex);
if (!negate) {
set_token_start(lex);
@@ -889,7 +889,7 @@ static enum ivy_status read_number(struct ivy_lexer *lex, bool negate)
token_len++;
dots++;
char s[] = {c, 0};
b_string_append_cstr(str, s);
fx_string_append_cstr(str, s);
set_token_end(lex);
advance(lex);
continue;
@@ -936,7 +936,7 @@ static enum ivy_status read_number(struct ivy_lexer *lex, bool negate)
}
char s[] = {c, 0};
b_string_append_cstr(str, s);
fx_string_append_cstr(str, s);
set_token_end(lex);
advance(lex);
token_len++;
@@ -946,7 +946,7 @@ static enum ivy_status read_number(struct ivy_lexer *lex, bool negate)
return push_int(lex, 0);
}
const char *s = b_string_ptr(str);
const char *s = fx_string_ptr(str);
char *ep = NULL;
/* negative numbers will be lexed as a hyphen followed by a positive
@@ -1057,7 +1057,7 @@ static enum ivy_status read_symbol(struct ivy_lexer *lex)
static enum ivy_status read_ident(struct ivy_lexer *lex)
{
b_string *str = get_temp_string(lex);
fx_string *str = get_temp_string(lex);
bool label = false;
set_token_start(lex);
char prev = 0;
@@ -1085,13 +1085,13 @@ static enum ivy_status read_ident(struct ivy_lexer *lex)
}
char s[2] = {c, 0};
b_string_append_cstr(str, s);
fx_string_append_cstr(str, s);
set_token_end(lex);
advance(lex);
prev = c;
}
const char *s = b_string_ptr(str);
const char *s = fx_string_ptr(str);
if (!label && !strcmp(s, "_")) {
return push_symbol(lex, IVY_SYM_UNDERSCORE);
}
@@ -1103,7 +1103,7 @@ static enum ivy_status read_ident(struct ivy_lexer *lex)
struct ivy_token *tok
= create_token(label ? IVY_TOK_LABEL : IVY_TOK_IDENT);
tok->t_str = b_string_steal(str);
tok->t_str = fx_string_steal(str);
return push_token(lex, tok);
}
@@ -1177,7 +1177,7 @@ struct ivy_token *ivy_lexer_peek(struct ivy_lexer *lex)
{
enum ivy_status status = IVY_OK;
while (b_queue_empty(&lex->lex_queue)) {
while (fx_queue_empty(&lex->lex_queue)) {
status = pump_tokens(lex);
if (status != IVY_OK) {
@@ -1188,8 +1188,8 @@ struct ivy_token *ivy_lexer_peek(struct ivy_lexer *lex)
lex->lex_status = status;
b_queue_entry *entry = b_queue_first(&lex->lex_queue);
struct ivy_token *tok = b_unbox(struct ivy_token, entry, t_entry);
fx_queue_entry *entry = fx_queue_first(&lex->lex_queue);
struct ivy_token *tok = fx_unbox(struct ivy_token, entry, t_entry);
return tok;
}
@@ -1197,7 +1197,7 @@ struct ivy_token *ivy_lexer_read(struct ivy_lexer *lex)
{
enum ivy_status status = IVY_OK;
while (b_queue_empty(&lex->lex_queue)) {
while (fx_queue_empty(&lex->lex_queue)) {
status = pump_tokens(lex);
if (status != IVY_OK) {
@@ -1206,14 +1206,14 @@ struct ivy_token *ivy_lexer_read(struct ivy_lexer *lex)
}
}
b_queue_entry *entry = b_queue_pop_front(&lex->lex_queue);
struct ivy_token *tok = b_unbox(struct ivy_token, entry, t_entry);
fx_queue_entry *entry = fx_queue_pop_front(&lex->lex_queue);
struct ivy_token *tok = fx_unbox(struct ivy_token, entry, t_entry);
return tok;
}
bool ivy_lexer_tokens_available(struct ivy_lexer *lex)
{
if (!b_queue_empty(&lex->lex_queue)) {
if (!fx_queue_empty(&lex->lex_queue)) {
return true;
}
@@ -1235,7 +1235,7 @@ struct ivy_token *ivy_token_create_ident(const char *s)
memset(tok, 0x0, sizeof *tok);
tok->t_type = IVY_TOK_IDENT;
tok->t_str = b_strdup(s);
tok->t_str = fx_strdup(s);
if (!tok->t_str) {
free(tok);