From 66bd58b89bffb6876ded047e647f1b3d342d305a Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sun, 7 Apr 2024 16:26:53 -0700 Subject: [PATCH] Write empty register name when null --- examples/test.modal | 4 +++- src/modal.c | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/test.modal b/examples/test.modal index 22c8abc..b6a2297 100644 --- a/examples/test.modal +++ b/examples/test.modal @@ -5,5 +5,7 @@ <> (reverse/l (?h) ?l) (str (?h ?l)) <> (implode str ?*) (?*) <> ((read)) (?:) +<> (empty-register) (?x) +<> (explode ?*) (str (?*)) -(implode reverse (explode hello)) (read) \ No newline at end of file +(implode reverse (explode hello)) (read) (explode hello) empty-register \ No newline at end of file diff --git a/src/modal.c b/src/modal.c index e935f2e..900d4c4 100644 --- a/src/modal.c +++ b/src/modal.c @@ -105,7 +105,6 @@ commit(char r) { int depth = 0; char c, *s = regs[(int)r]; - if(!s) return !fprintf(stderr, "?%c Empty\n", r); if(r == '*') s = plode(s); else if(s[0] == '(') { @@ -184,7 +183,7 @@ rewrite(void) if(res != NULL) { char cc, *b = r->b; while((cc = *b++)) { - if(cc == '?') + if(cc == '?' && regs[(int)b[0]]) commit(*b++); else *outp_++ = cc;