all repos — hex @ 9f678893582e9a3e3f07bac087536ae8ac23b46b

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

Improved string handling.
h3rald h3rald@h3rald.com
Sat, 23 Nov 2024 14:51:41 +0100
commit

9f678893582e9a3e3f07bac087536ae8ac23b46b

parent

ca765f7c2550b7594b8819b0f9f823c8b452e49d

3 files changed, 24 insertions(+), 1 deletions(-)

jump to
M build.shbuild.sh

@@ -1,1 +1,1 @@

-gcc hex.c -o hex +CC hex.c -o hex
M hex.chex.c

@@ -570,6 +570,15 @@ else if (*ptr == '"')

{ break; } + else if (*ptr == '\n') + { + hex_error("Unescaped new line in string"); + token->value = "<newline>"; + token->type = HEX_TOKEN_INVALID; + token->line = *line; + token->column = *column; + return token; + } else { ptr++;

@@ -582,6 +591,9 @@ if (*ptr != '"')

{ hex_error("Unterminated string"); token->type = HEX_TOKEN_INVALID; + token->value = strdup(ptr); + token->line = *line; + token->column = *column; return token; }

@@ -656,6 +668,8 @@ }

else { token->type = HEX_TOKEN_INVALID; + token->line = *line; + token->column = *column; } }

@@ -3540,6 +3554,13 @@ return result;

} token = hex_next_token(&input, &line, &column); + } + if (token->type == HEX_TOKEN_INVALID) + { + token->filename = strdup(filename); + add_to_stack_trace(token); + print_stack_trace(); + return 1; } hex_free_token(token); return 0;
M tests.hextests.hex

@@ -15,6 +15,8 @@ )

if ) "test" store + + ; --- Tests (0x1 "a" store a 0x1 ==) test i