all repos — hex @ e99de0f4ecc0e09bc1eaaa034bc5d75021c74216

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

Merge branch 'master' of github.com:h3rald/hex
h3rald h3rald@h3rald.com
Sun, 24 Nov 2024 21:36:56 +0100
commit

e99de0f4ecc0e09bc1eaaa034bc5d75021c74216

parent

8306c40e9a745a8b8441baa9b3ba770d1efe3357

2 files changed, 15 insertions(+), 11 deletions(-)

jump to
M hex.chex.c

@@ -66,7 +66,7 @@ "and",

"or", "not", "xor", - "concat", + "cat", "slice", "len", "get",

@@ -216,7 +216,6 @@ hex_error("Cannot overwrite native symbol %s", key);

return 1; } free(HEX_REGISTRY[i].key); - hex_free_element(HEX_REGISTRY[i].value); HEX_REGISTRY[i].key = strdup(key); HEX_REGISTRY[i].value = value; return 0;

@@ -269,7 +268,9 @@ ////////////////////////////////////////

void hex_debug(const char *format, ...); void hex_debug_element(const char *message, HEX_StackElement element); +void hex_print_element(FILE *stream, HEX_StackElement element); void add_to_stack_trace(HEX_Token *token); +char *hex_type(HEX_ElementType type); HEX_StackElement HEX_STACK[HEX_STACK_SIZE]; int HEX_TOP = -1;

@@ -477,8 +478,6 @@ fprintf(stdout, "\n");

va_end(args); } } - -void hex_print_element(FILE *stream, HEX_StackElement element); char *hex_type(HEX_ElementType type) {

@@ -1985,9 +1984,9 @@ }

//////////////////////////////////////// // Quotation/String symbols // -//////////////////////////////////////// +/////////////////////////////////////// -int hex_symbol_concat() +int hex_symbol_cat() { HEX_StackElement value = hex_pop(); if (value.type == HEX_TYPE_INVALID)

@@ -2049,7 +2048,7 @@ }

} else { - hex_error("Symbol 'concat' requires two quotations or two strings"); + hex_error("Symbol 'cat' requires two quotations or two strings"); result = 1; }

@@ -3545,7 +3544,7 @@ hex_set_native_symbol("and", hex_symbol_and);

hex_set_native_symbol("or", hex_symbol_or); hex_set_native_symbol("not", hex_symbol_not); hex_set_native_symbol("xor", hex_symbol_xor); - hex_set_native_symbol("concat", hex_symbol_concat); + hex_set_native_symbol("cat", hex_symbol_cat); hex_set_native_symbol("slice", hex_symbol_slice); hex_set_native_symbol("len", hex_symbol_len); hex_set_native_symbol("get", hex_symbol_get);
M tests.hextests.hex

@@ -20,22 +20,27 @@ if

) ( ; Store error - ;errors test-count str " - " concat error concat q concat "errors" store + errors " - Test #" test-count str cat ": " cat error cat q cat "errors" store "x" print failures 0x1 + "failures" store ) try ) "test" store + ; --- Tests -;(0x1 "a" store a 0x1 == dup) test i +(0x1 "a" store a 0x1 ==) test i (a free 0x1) test i ; --- Report "\nSuccessful Tests: " print successes dec print "/" print successes failures + dec puts + (errors len 0x0 >) - (errors (warn) each) + ( + "Errors:" warn + errors (warn) each + ) when ; --- Cleanup