all repos — hex @ 620381a08d8df3b1522741dc696052cb16630940

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

Improvements
h3rald h3rald@h3rald.com
Sat, 23 Nov 2024 15:02:47 +0100
commit

620381a08d8df3b1522741dc696052cb16630940

parent

9f678893582e9a3e3f07bac087536ae8ac23b46b

2 files changed, 32 insertions(+), 9 deletions(-)

jump to
M hex.chex.c

@@ -28,6 +28,8 @@ char HEX_ERROR[256] = "";

char **HEX_ARGV; int HEX_ARGC = 0; int HEX_ERRORS = 1; +int HEX_REPL = 0; +int HEX_STDIN = 0; char *HEX_NATIVE_SYMBOLS[] = { "store",

@@ -853,6 +855,10 @@

// Print the stack trace void print_stack_trace() { + if (HEX_STDIN || HEX_REPL) + { + return; + } fprintf(stderr, "[stack trace] (most recent symbol first):\n"); for (size_t i = 0; i < stackTrace.size; i++)

@@ -3730,11 +3736,13 @@ }

} if (!isatty(fileno(stdin))) { + HEX_STDIN = 1; // Process piped input from stdin hex_process_stdin(); } else { + HEX_REPL = 1; // Start REPL hex_repl(); }
M tests.hextests.hex

@@ -1,27 +1,42 @@

+0x0 "test-count" store 0x0 "successes" store 0x0 "failures" store +() "errors" store ( "current-test" store - (current-test i) + test-count 0x1 + "test-counnt" store + ( + (current-test i) + ( + "." print + successes 0x1 + "successes" store + ) + ( + "x" print + failures 0x1 + "failures" store + ) + if + ) ( - "." print - successes 0x1 + "successes" store - ) - ( + ; Store error + (test-count str " - " error) join errors append "errors" store "x" print failures 0x1 + "failures" store ) - if + try ) "test" store - - ; --- Tests (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 length 0 >) + errors (warn) each +when + ; --- Cleanup -"a" free +;"a" free