asm: add missing includes

This commit is contained in:
2024-11-22 22:30:15 +00:00
parent ceb9f10b66
commit f1be82c495
2 changed files with 19 additions and 13 deletions

View File

@@ -1,15 +1,17 @@
#include "lex.h"
#include <blue/core/hash.h> #include <blue/core/hash.h>
#include <blue/core/queue.h> #include <blue/core/queue.h>
#include <blue/object/string.h>
#include <blue/object/dict.h> #include <blue/object/dict.h>
#include <blue/object/number.h> #include <blue/object/number.h>
#include <blue/object/string.h>
#include <ctype.h> #include <ctype.h>
#include <ivy/asm/lex.h> #include <ivy/asm/lex.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "lex.h" #include <wctype.h>
#define LINEBUF_DEFAULT_CAPACITY 1024 #define LINEBUF_DEFAULT_CAPACITY 1024
@@ -21,11 +23,11 @@
static struct lex_token_def keywords[] = { static struct lex_token_def keywords[] = {
LEX_TOKEN_DEF(IVY_ASM_KW_USE, "@use"), LEX_TOKEN_DEF(IVY_ASM_KW_USE, "@use"),
LEX_TOKEN_DEF(IVY_ASM_KW_IDENT, "@ident"), LEX_TOKEN_DEF(IVY_ASM_KW_IDENT, "@ident"),
LEX_TOKEN_DEF(IVY_ASM_KW_SELECTOR, "@selector"), LEX_TOKEN_DEF(IVY_ASM_KW_SELECTOR, "@selector"),
LEX_TOKEN_DEF(IVY_ASM_KW_ATOM, "@atom"), LEX_TOKEN_DEF(IVY_ASM_KW_ATOM, "@atom"),
LEX_TOKEN_DEF(IVY_ASM_KW_LAMBDA, "@lambda"), LEX_TOKEN_DEF(IVY_ASM_KW_LAMBDA, "@lambda"),
LEX_TOKEN_DEF(IVY_ASM_KW_CONSTPOOL, "@constpool"), LEX_TOKEN_DEF(IVY_ASM_KW_CONSTPOOL, "@constpool"),
LEX_TOKEN_DEF(IVY_ASM_KW_CLASS, "@class"), LEX_TOKEN_DEF(IVY_ASM_KW_CLASS, "@class"),
LEX_TOKEN_DEF(IVY_ASM_KW_MSGH, "@msgh"), LEX_TOKEN_DEF(IVY_ASM_KW_MSGH, "@msgh"),
LEX_TOKEN_DEF(IVY_ASM_KW_END, "@end"), LEX_TOKEN_DEF(IVY_ASM_KW_END, "@end"),
}; };
@@ -201,7 +203,8 @@ static void init_keywords(b_dict *keyword_dict)
} }
} }
static enum ivy_keyword find_keyword_by_name(struct ivy_asm_lexer *lex, const char *s) static enum ivy_asm_keyword find_keyword_by_name(
struct ivy_asm_lexer *lex, const char *s)
{ {
b_number *id = B_NUMBER(b_dict_at(lex->lex_keywords, s)); b_number *id = B_NUMBER(b_dict_at(lex->lex_keywords, s));
if (!id) { if (!id) {
@@ -364,7 +367,7 @@ static int advance(struct ivy_asm_lexer *lex)
return c; return c;
} }
static bool input_available(struct ivy_asm_lexer* lex) static bool input_available(struct ivy_asm_lexer *lex)
{ {
return lex->lex_linebuf_ptr < lex->lex_linebuf_len; return lex->lex_linebuf_ptr < lex->lex_linebuf_len;
} }
@@ -393,7 +396,8 @@ static struct ivy_asm_token *create_token(enum ivy_asm_token_type type)
return tok; return tok;
} }
static enum ivy_status push_token(struct ivy_asm_lexer *lex, struct ivy_asm_token *tok) static enum ivy_status push_token(
struct ivy_asm_lexer *lex, struct ivy_asm_token *tok)
{ {
struct ivy_asm_token **slot = &lex->lex_queue; struct ivy_asm_token **slot = &lex->lex_queue;
@@ -495,7 +499,8 @@ static enum ivy_status push_double(struct ivy_asm_lexer *lex, double v)
return push_token(lex, tok); return push_token(lex, tok);
} }
static enum ivy_status push_keyword(struct ivy_asm_lexer *lex, enum ivy_keyword keyword) static enum ivy_status push_keyword(
struct ivy_asm_lexer *lex, enum ivy_asm_keyword keyword)
{ {
struct ivy_asm_token *tok = malloc(sizeof *tok); struct ivy_asm_token *tok = malloc(sizeof *tok);
if (!tok) { if (!tok) {
@@ -835,7 +840,7 @@ static enum ivy_status read_keyword(struct ivy_asm_lexer *lex)
const char *s = b_string_ptr(str); const char *s = b_string_ptr(str);
enum ivy_keyword keyword = find_keyword_by_name(lex, s); enum ivy_asm_keyword keyword = find_keyword_by_name(lex, s);
if (keyword == IVY_ASM_KW_NONE) { if (keyword == IVY_ASM_KW_NONE) {
return IVY_ERR_BAD_SYNTAX; return IVY_ERR_BAD_SYNTAX;
@@ -872,7 +877,7 @@ static enum ivy_status read_ident(struct ivy_asm_lexer *lex)
} }
const char *s = b_string_ptr(str); const char *s = b_string_ptr(str);
struct ivy_asm_token *tok struct ivy_asm_token *tok
= create_token(label ? IVY_ASM_TOK_LABEL : IVY_ASM_TOK_IDENT); = create_token(label ? IVY_ASM_TOK_LABEL : IVY_ASM_TOK_IDENT);
tok->t_str = b_string_steal(str); tok->t_str = b_string_steal(str);

View File

@@ -2,8 +2,9 @@
#define _LEX_H_ #define _LEX_H_
#include <blue/core/queue.h> #include <blue/core/queue.h>
#include <blue/object/string.h>
#include <blue/object/dict.h> #include <blue/object/dict.h>
#include <blue/object/string.h>
#include <ivy/asm/lex.h>
#include <stdint.h> #include <stdint.h>
enum lexer_state_type { enum lexer_state_type {
@@ -19,7 +20,7 @@ struct lexer_state {
struct ivy_asm_lexer_symbol_node { struct ivy_asm_lexer_symbol_node {
char s_char; char s_char;
enum ivy_symbol s_id; enum ivy_asm_symbol s_id;
b_queue_entry s_entry; b_queue_entry s_entry;
b_queue s_children; b_queue s_children;
@@ -50,4 +51,4 @@ struct ivy_asm_lexer {
size_t lex_linebuf_ptr; size_t lex_linebuf_ptr;
}; };
#endif #endif