all repos — hex @ b48dc7bc1ba2f9de9c0618db81213969c56bed23

A tiny, minimalist, slightly-esoteric concatenative programming lannguage.

Improved parsing error messages.
h3rald h3rald@h3rald.com
Sun, 01 Dec 2024 14:44:10 +0100
commit

b48dc7bc1ba2f9de9c0618db81213969c56bed23

parent

25166d7919b755250db59a520e98303d736be715

1 files changed, 8 insertions(+), 8 deletions(-)

jump to
M hex.chex.c

@@ -706,7 +706,7 @@ capacity *= 2;

quotation = (hex_item_t **)realloc(quotation, capacity * sizeof(hex_item_t *)); if (!quotation) { - hex_error(ctx, "Memory allocation failed"); + hex_error(ctx, "(%d,%d), Memory allocation failed", position->line, position->column); return 1; } }

@@ -739,7 +739,7 @@ item->data.fnValue = value.data.fnValue;

} else { - hex_error(ctx, "Unable to reference native symbol: %s", token->value); + hex_error(ctx, "(%d,%d) Unable to reference native symbol: %s", position->line, position->column, token->value); hex_free_token(token); hex_free_list(ctx, quotation, size); return 1;

@@ -772,7 +772,7 @@ // Ignore comments

} else { - hex_error(ctx, "Unexpected token in quotation: %d", token->value); + hex_error(ctx, "(%d,%d) Unexpected token in quotation: %d", position->line, position->column, token->value); hex_free_token(token); hex_free_list(ctx, quotation, size); return 1;

@@ -781,7 +781,7 @@ }

if (balanced != 0) { - hex_error(ctx, "Unterminated quotation"); + hex_error(ctx, "(%d,%d) Unterminated quotation", position->line, position->column); hex_free_token(token); hex_free_list(ctx, quotation, size); return 1;

@@ -3480,8 +3480,8 @@ FREE(ctx, list);

for (int i = 0; i < count; i++) { FREE(ctx, *quotation[i]); - } - return 1 ; + } + return 1; } } return 0;

@@ -3707,7 +3707,7 @@ result = hex_push_symbol(ctx, token);

} else if (token->type == HEX_TOKEN_QUOTATION_END) { - hex_error(ctx, "Unexpected end of quotation"); + hex_error(ctx, "(%d,%d) Unexpected end of quotation", position.line, position.column); result = 1; } else if (token->type == HEX_TOKEN_QUOTATION_START)

@@ -3715,7 +3715,7 @@ {

hex_item_t *quotationItem = (hex_item_t *)malloc(sizeof(hex_item_t)); if (hex_parse_quotation(ctx, &input, quotationItem, &position) != 0) { - hex_error(ctx, "Failed to parse quotation"); + hex_error(ctx, "(%d,%d) Failed to parse quotation", position.line, position.column); result = 1; } else