Resolve warnings

This commit is contained in:
Night Kaly 2025-01-14 12:09:20 +00:00
parent dc566b4345
commit 1d297cf0f0
Signed by: night0721
SSH key fingerprint: SHA256:B/hgVwUoBpx5vdNsXl9w8XwZljA9766uk6T4ubZp5HM
3 changed files with 3 additions and 10 deletions

View file

@ -133,10 +133,9 @@ value_t visit_binary(expr_t *expr)
}
// String/number comparisons
if (left.type == VAL_STRING && right.type == VAL_NUMBER ||
left.type == VAL_NUMBER && right.type == VAL_STRING ) {
if ((left.type == VAL_STRING && right.type == VAL_NUMBER) ||
(left.type == VAL_NUMBER && right.type == VAL_STRING)) {
runtime_error("Operands must be numbers.", expr->line);
}
runtime_error("Operands must be two numbers or two strings.", expr->line);

View file

@ -263,13 +263,7 @@ array_t *tokenize(char *filename)
int found = 0;
for (int i = 0; i < sizeof(reserved_keywords) / sizeof(reserved_keywords[0]); i++) {
if (strcmp(id, reserved_keywords[i].keyword) == 0) {
char upper_id[len + 1];
for (int i = 0; i < len; i++) {
upper_id[i] = toupper(id[i]);
}
upper_id[len] = 0;
token_add(tokens, token_gen(reserved_keywords[i].token_type, id, line));
found = 1;
}
}

View file

@ -217,7 +217,7 @@ stmt_t var_declaration(void)
{
token_t *name = consume(TOKEN_IDENTIFIER, "Expect variable name.");
expr_t *initializer;
expr_t *initializer = NULL;
if (check(TOKEN_EQUAL)) {
initializer = expression();
}