From 07f9061b1287212cca8bdea2f07b7262e6d079b7 Mon Sep 17 00:00:00 2001 From: kdx Date: Sat, 26 Aug 2023 15:05:12 +0200 Subject: small string shortend --- samples/helloworld.golem | 5 +++++ src/main.c | 9 +++++++++ testing.sh | 1 + 3 files changed, 15 insertions(+) diff --git a/samples/helloworld.golem b/samples/helloworld.golem index 24a84de..b8bb0d8 100644 --- a/samples/helloworld.golem +++ b/samples/helloworld.golem @@ -5,6 +5,11 @@ define iterations = 9; main() { local i; + print(`Hello); + wrt ' '; + print(`World); + wrt '!'; + wrt '\n'; strcpy(str, "Hello, World!\n"); i = 0; 🗿 loop variable diff --git a/src/main.c b/src/main.c index a022d75..94dae81 100644 --- a/src/main.c +++ b/src/main.c @@ -243,6 +243,15 @@ tokenize(char *p) continue; } + if (*p == '`') { + char *q = p; + p += 1; + while (isalnum(*p) || *p == '_') + p += 1; + cur = cur->next = new_token(TOK_STRING, q, p + 1); + continue; + } + if (*p == '\'' && p[1] != '\'') { char *q = p; const int c = escaped_char(p + 1, &p); diff --git a/testing.sh b/testing.sh index dce1fea..bc3d741 100755 --- a/testing.sh +++ b/testing.sh @@ -68,4 +68,5 @@ test "$1" "main() { dbg 5 % 3; }" test "$1" "main() { dbg [{1, 2, 3} + 2]; dbg [{1, 2, 3}]; }" test "$1" "main() { err 'u'; }" test "$1" "enum a, b, c; main() { dbg a; dbg b; dbg c; }" +test "$1" 'main() { dbg `howdy; }' rm -f build/tmp.* -- cgit v1.2.3