From 4a57c3c56436c483523cc7247d9c207a90c3b8e4 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Fri, 10 May 2024 14:25:54 -0700 Subject: [PATCH] Catch empty rules --- examples/tests.modal | 3 ++- src/modal.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/tests.modal b/examples/tests.modal index e2c7881..4f58865 100644 --- a/examples/tests.modal +++ b/examples/tests.modal @@ -81,7 +81,8 @@ abc ?(?x) def = abc (lambda 2/2) test <> (incomplete-basic) <> (incomplete-reg ?x) -<> (waste-rule) * +<> <> +<> () () (incomplete-basic) = () (incomplete 1/4) test (incomplete-reg abcdef) = () (incomplete 2/4) test diff --git a/src/modal.c b/src/modal.c index 35f7992..55ef37f 100644 --- a/src/modal.c +++ b/src/modal.c @@ -226,7 +226,7 @@ parse_frag(char **side, char *s) { char c, *cap; while((c = *s) && c == ' ') s++; - if(c == ')' || (c == '<' || c == '>')) + if(c == ')' || c == '<' || c == '>' || (c == '(' && s[1] == ')')) *side = NULL; else { cap = walk(s), *side = dict_; @@ -315,7 +315,7 @@ main(int argc, char **argv) return !printf("usage: modal [-vqn] source.modal\n"); for(i = 1; i < argc && *argv[i] == '-'; i++) { switch(argv[i][1]) { - case 'v': /* version */ return !printf("Modal Interpreter, 9 May 2024.\n"); + case 'v': /* version */ return !printf("Modal Interpreter, 10 May 2024.\n"); case 'q': /* quiet */ quiet = 1; break; case 'p': /* debug */ debug = 1; break; case 'a': /* access */ access = 1; break;