all repos — hex @ d341720b97b23d4db45054767f8002ee1cd94e86

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

Fixes.
h3rald h3rald@h3rald.com
Thu, 28 Nov 2024 09:45:45 +0100
commit

d341720b97b23d4db45054767f8002ee1cd94e86

parent

b6ecf29e68f7abfcd6c046a93b3acd8bdc12fe22

2 files changed, 65 insertions(+), 46 deletions(-)

jump to
M hex.chex.c

@@ -697,12 +697,16 @@ if (token->type == HEX_TOKEN_INTEGER)

{ element->type = HEX_TYPE_INTEGER; element->data.intValue = hex_parse_integer(token->value); + quotation[size] = element; + size++; } else if (token->type == HEX_TOKEN_STRING) { char *processedStr = hex_process_string(ctx, token->value); element->type = HEX_TYPE_STRING; element->data.strValue = strdup(processedStr); + quotation[size] = element; + size++; } else if (token->type == HEX_TOKEN_SYMBOL) {

@@ -730,6 +734,8 @@ element->type = HEX_TYPE_USER_SYMBOL;

} token->position.filename = strdup(position->filename); element->token = token; + quotation[size] = element; + size++; } else if (token->type == HEX_TOKEN_QUOTATION_START) {

@@ -740,6 +746,8 @@ hex_free_token(token);

hex_free_list(ctx, quotation, size); return 1; } + quotation[size] = element; + size++; } else if (token->type == HEX_TOKEN_COMMENT) {

@@ -752,9 +760,6 @@ hex_free_token(token);

hex_free_list(ctx, quotation, size); return 1; } - - quotation[size] = element; - size++; } if (balanced != 0)
M tests.hextests.hex

@@ -28,56 +28,70 @@ try

) "test" store -; --- Tests +; --- Define tests +( + (0x1 "a" store a 0x1 ==) + ("a" free 0x1) + ("aaa" type "string" == 0x1 type "integer" == () type "quotation" == and and) + ((0x1 0x2 +) i 0x3 ==) + ;4 -(0x1 "a" store a 0x1 ==) test i -("a" free 0x1) test i -("aaa" type "string" == 0x1 type "integer" == () type "quotation" == and and) test i -((0x1 0x2 +) i 0x3 ==) test i -("0x2 0x2 -" eval 0x0 ==) test i -;5 + ("0x2 0x2 -" eval 0x0 ==) + (0x4 0x5 + 0x9 ==) + (0x5 0x3 - 0x2 ==) + (0x5 0x2 * 0xa ==) + ;8 -(0x4 0x5 + 0x9 ==) test i -(0x5 0x3 - 0x2 ==) test i -(0x5 0x2 * 0xa ==) test i -(0x5 0x2 / 0x2 ==) test i -(0x4 0x2 % 0x0 ==) test i -;10 + (0x5 0x2 / 0x2 ==) + (0x4 0x2 % 0x0 ==) + (0x10101 0x01010 & 0x0 ==) + (0x10111 0x01000 | 0x11111 ==) + ;12 -(0x10101 0x01010 & 0x0 ==) test i -(0x10111 0x01000 | 0x11111 ==) test i -(0x1 0x1 ^ 0x0 ==) test i -(0x1 ~ 0xfffffffe ==) test i -(0x1 0x4 << 0x10 ==) test i -;15 -(0x10 0x4 >> 0x1 ==) test i -("10" int 0x10 ==) test i -(0x10 str "10" ==) test i -(0xa dec "10" ==) test i -("10" hex 0xa ==) test i -;20 + (0x1 0x1 ^ 0x0 ==) + (0x1 ~ 0xfffffffe ==) + (0x1 0x4 << 0x10 ==) + (0x10 0x4 >> 0x1 ==) + ;16 -("aaa" "aaa" ==) test i -(0x20 0x20 ==) test i -(0x21 0x22 !=) test i -("abba" "aaa" !=) test i -(0x2 0x1 >) test i -;25 + ("10" int 0x10 ==) + (0x10 str "10" ==) + (0xa dec "10" ==) + ("10" hex 0xa ==) + ;20 -(0x2 0x2 >=) test i -(0x2 0x3 <) test i -(0x3 0x3 <=) test i -(0x2 0x3 and) test i -(0x1 0x0 or) test i -;30 + ("aaa" "aaa" ==) + (0x20 0x20 ==) + (0x21 0x22 !=) + ("abba" "aaa" !=) + ;24 -(0x1 0x0 xor) test i -(0x1 0x1 xor not) test i -("hello" " world" cat "hello world" ==) test i -((0x1 "a") ("b") cat (0x1 "a" "b") ==) test i -((0x1 0x2 0x3) 0x1 0x2 slice (0x2 0x3) ==) test i -("hello" 0x0 0x3 slice "hell" ==) test i + (0x2 0x1 >) + (0x2 0x2 >=) + (0x2 0x3 <) + (0x3 0x3 <=) + ;28 + + (0x2 0x3 and) + (0x1 0x0 or) + (0x1 0x0 xor) + (0x1 0x1 xor not) + ;32 + + ("hello" " world" cat "hello world" ==) + ((0x1 "a") ("b") cat (0x1 "a" "b") ==) + ((0x1 0x2 0x3) 0x1 0x2 slice (0x2 0x3) ==) + ("hello" 0x0 0x3 slice "hell" ==) + ;36 + + ("aaaaa" len 0x5 ==) +) "tests" store + + +; --- Run tests +tests (test i) each + ; --- Report "\nSuccessful Tests: " print successes dec print "/" print successes failures + dec puts