lang: fix a bunch of compiler warnings

This commit is contained in:
2024-11-27 22:45:34 +00:00
parent 9df8474515
commit 7f9894d8f9
5 changed files with 39 additions and 21 deletions

View File

@@ -2,8 +2,8 @@
#include "node.h"
#include <blue/object/string.h>
#include <ivy/lang/operator.h>
#include <ivy/lang/lex.h>
#include <ivy/lang/operator.h>
#include <stdio.h>
enum expr_end {
@@ -94,7 +94,8 @@ static enum ivy_status finalise_expr(struct expr_parser_state *state)
int i = 0;
b_queue_foreach (&it, &state->s_operand_queue) {
struct ivy_token *operand = b_unbox(struct ivy_token, it.entry, t_entry);
struct ivy_token *operand
= b_unbox(struct ivy_token, it.entry, t_entry);
if (i > 0) {
printf(" ");
@@ -105,7 +106,8 @@ static enum ivy_status finalise_expr(struct expr_parser_state *state)
}
b_queue_foreach (&it, &state->s_operator_stack) {
struct ivy_token *operator = b_unbox(struct ivy_token, it.entry, t_entry);
struct ivy_token *operator= b_unbox(
struct ivy_token, it.entry, t_entry);
if (i > 0) {
printf(" ");
@@ -212,11 +214,11 @@ static struct token_parse_result parse_double(
b_queue_push_back(&state->s_operand_queue, &tok->t_entry);
set_previous(state, tok);
return PARSE_RESULT(IVY_OK, 0);
}
static struct ivy_operator *get_operator(struct ivy_token *tok)
static const struct ivy_operator *get_operator(struct ivy_token *tok)
{
switch (tok->t_type) {
case IVY_TOK_KEYWORD:
@@ -238,7 +240,7 @@ static struct token_parse_result parse_symbol(
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
}
struct ivy_operator *op = ivy_operator_get(tok->t_symbol);
const struct ivy_operator *op = ivy_operator_get(tok->t_symbol);
if (!op) {
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
}
@@ -250,17 +252,19 @@ static struct token_parse_result parse_symbol(
break;
}
struct ivy_token *top = b_unbox(struct ivy_token, top_entry, t_entry);
struct ivy_token *top
= b_unbox(struct ivy_token, top_entry, t_entry);
if (ivy_token_is_symbol(top, IVY_SYM_LEFT_PAREN)) {
break;
}
struct ivy_operator *top_op = get_operator(top);
const struct ivy_operator *top_op = get_operator(top);
if (top_op->op_precedence < op->op_precedence) {
break;
}
if (top_op->op_precedence == op->op_precedence && op->op_associativity != IVY_ASSOCIATIVITY_LEFT) {
if (top_op->op_precedence == op->op_precedence
&& op->op_associativity != IVY_ASSOCIATIVITY_LEFT) {
break;
}
@@ -286,7 +290,7 @@ static struct token_parse_result parse_left_paren(
b_queue_push_back(&state->s_operator_stack, &tok->t_entry);
set_previous(state, tok);
return PARSE_RESULT(IVY_OK, 0);
}