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);
}

View File

@@ -33,7 +33,7 @@ const struct ast_node_type *get_ast_node_type(enum ivy_ast_node_type type)
return node_ops[type];
}
enum tok_expr_type get_tok_expr_type(struct ivy_token *tok)
enum token_expr_type get_token_expr_type(struct ivy_token *tok)
{
switch (tok->t_type) {
case IVY_TOK_IDENT:
@@ -136,7 +136,7 @@ token_parse_function get_token_parser(
return better_parser;
}
enum token_expr_type expr_type = get_tok_expr_type(tok);
enum token_expr_type expr_type = get_token_expr_type(tok);
switch (expr_type) {
case TOK_EXPR_BEGIN:
better_parser = type->n_expr_parser.expr_begin

View File

@@ -16,7 +16,7 @@ enum token_parse_flags {
PARSE_REPEAT_TOKEN = 0x01u,
};
enum tok_expr_type {
enum token_expr_type {
TOK_EXPR_NONE = 0,
TOK_EXPR_BEGIN,
TOK_EXPR_ANY,
@@ -54,7 +54,7 @@ struct ast_node_type {
extern const struct ast_node_type *get_ast_node_type(enum ivy_ast_node_type type);
extern token_parse_function get_token_parser(
struct ivy_ast_node *context, struct ivy_token *tok);
extern enum tok_expr_type get_tok_expr_type(struct ivy_token *tok);
extern enum token_expr_type get_token_expr_type(struct ivy_token *tok);
extern struct ivy_ast_node *ast_node_create_with_size(
enum ivy_ast_node_type type, size_t size);
extern enum ivy_status ast_node_add_child(