asm: fix compiler warnings

This commit is contained in:
2024-12-14 21:03:44 +00:00
parent 462f67c6aa
commit a167dd2af5
8 changed files with 150 additions and 117 deletions

View File

@@ -1,29 +1,30 @@
#include "parse.h"
#include <ivy/ident.h>
#include <ivy/asm/bin.h>
#include <ivy/asm/assembler.h>
#include <ivy/asm/bin.h>
#include <ivy/asm/lex.h>
#include <ivy/ident.h>
struct ident_parser_state {
struct parser_state s_base;
unsigned int s_prev_token;
b_queue s_parts;
};
static enum ivy_status init_state(
struct ivy_asm_parser *ctx, struct parser_state *s)
static void init_state(struct ivy_asm_parser *ctx, struct parser_state *s)
{
struct ident_parser_state *state = (struct ident_parser_state *)s;
state->s_prev_token = IVY_ASM_SYM_LEFT_PAREN;
return IVY_OK;
}
static enum ivy_status parse_ident(
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
{
struct ident_parser_state *state = (struct ident_parser_state *)asm_parser_get_state(ctx);
if (state->s_prev_token != IVY_ASM_SYM_LEFT_PAREN && state->s_prev_token != IVY_ASM_SYM_DOT) {
struct ident_parser_state *state
= (struct ident_parser_state *)asm_parser_get_state(ctx);
if (state->s_prev_token != IVY_ASM_SYM_LEFT_PAREN
&& state->s_prev_token != IVY_ASM_SYM_DOT) {
return IVY_ERR_BAD_SYNTAX;
}
@@ -36,21 +37,23 @@ static enum ivy_status parse_ident(
static enum ivy_status parse_dot(
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
{
struct ident_parser_state *state = (struct ident_parser_state *)asm_parser_get_state(ctx);
struct ident_parser_state *state
= (struct ident_parser_state *)asm_parser_get_state(ctx);
if (state->s_prev_token != IVY_ASM_TOK_IDENT) {
return IVY_ERR_BAD_SYNTAX;
}
state->s_prev_token = IVY_ASM_SYM_DOT;
return IVY_OK;
}
static enum ivy_status parse_right_paren(
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
{
struct ident_parser_state *state = (struct ident_parser_state *)asm_parser_get_state(ctx);
struct ident_parser_state *state
= (struct ident_parser_state *)asm_parser_get_state(ctx);
if (state->s_prev_token != IVY_ASM_TOK_IDENT) {
return IVY_ERR_BAD_SYNTAX;
@@ -61,7 +64,8 @@ static enum ivy_status parse_right_paren(
b_queue_iterator it = {0};
b_queue_iterator_begin(&state->s_parts, &it);
while (b_queue_iterator_is_valid(&it)) {
struct ivy_asm_token *tok = b_unbox(struct ivy_asm_token, it.entry, t_entry);
struct ivy_asm_token *tok
= b_unbox(struct ivy_asm_token, it.entry, t_entry);
b_queue_iterator_erase(&it);
ivy_ident_add_part(ident, tok->t_str);
@@ -83,4 +87,4 @@ struct parser_state_type ident_parser_state_type = {
SYM_PARSER(DOT, parse_dot),
SYM_PARSER(RIGHT_PAREN, parse_right_paren),
},
};
};