diff --git a/asm/lex.c b/asm/lex.c index a5c0645..47f63a1 100644 --- a/asm/lex.c +++ b/asm/lex.c @@ -1,15 +1,17 @@ +#include "lex.h" + #include #include -#include #include #include +#include #include #include #include #include #include #include -#include "lex.h" +#include #define LINEBUF_DEFAULT_CAPACITY 1024 @@ -21,11 +23,11 @@ static struct lex_token_def keywords[] = { LEX_TOKEN_DEF(IVY_ASM_KW_USE, "@use"), 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_LAMBDA, "@lambda"), 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_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)); if (!id) { @@ -364,7 +367,7 @@ static int advance(struct ivy_asm_lexer *lex) 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; } @@ -393,7 +396,8 @@ static struct ivy_asm_token *create_token(enum ivy_asm_token_type type) 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; @@ -495,7 +499,8 @@ static enum ivy_status push_double(struct ivy_asm_lexer *lex, double v) 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); if (!tok) { @@ -835,7 +840,7 @@ static enum ivy_status read_keyword(struct ivy_asm_lexer *lex) 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) { 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); - + struct ivy_asm_token *tok = create_token(label ? IVY_ASM_TOK_LABEL : IVY_ASM_TOK_IDENT); tok->t_str = b_string_steal(str); diff --git a/asm/lex.h b/asm/lex.h index aa8fafb..198dad1 100644 --- a/asm/lex.h +++ b/asm/lex.h @@ -2,8 +2,9 @@ #define _LEX_H_ #include -#include #include +#include +#include #include enum lexer_state_type { @@ -19,7 +20,7 @@ struct lexer_state { struct ivy_asm_lexer_symbol_node { char s_char; - enum ivy_symbol s_id; + enum ivy_asm_symbol s_id; b_queue_entry s_entry; b_queue s_children; @@ -50,4 +51,4 @@ struct ivy_asm_lexer { size_t lex_linebuf_ptr; }; -#endif \ No newline at end of file +#endif