From d520ab848960a899fb93de36911713d175a2135f Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sat, 27 Apr 2024 12:30:40 -0700 Subject: [PATCH] Added tests, ignoring empty rules --- examples/tests.modal | 3 +++ src/modal.c | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/tests.modal b/examples/tests.modal index 7351dbe..9f6bd51 100644 --- a/examples/tests.modal +++ b/examples/tests.modal @@ -88,12 +88,15 @@ reverse (modal) = ladom (reverse 1) test ?(?-) (Incomplete definitions) +<> <> +<> () () <> (incomplete-basic) <> (incomplete-reg ?x) <> (waste-rule) * (incomplete-basic) = () (incomplete 1) test (incomplete-reg abcdef) = () (incomplete 2) test +(?(?x) incomplete-lambda) = () (incomplete 3) test ?(?-) (Inline rules) diff --git a/src/modal.c b/src/modal.c index 221ade7..837f271 100644 --- a/src/modal.c +++ b/src/modal.c @@ -228,11 +228,14 @@ rewrite(void) Rule *r = NULL; /* phase: define */ if(c == '<' && s[1] == '>') { - r = rules_++; + r = rules_; s = compile_rule(r, rules_ - rules - 1, s + 2); - if(!quiet && r->a) - printf("<> "), echo_rule(r, r->a), echo_rule(r, r->b), putc('\n', stdout); - while(*s == ' ') s++; + if(*r->a) { + if(!quiet && r->a) + printf("<> "), echo_rule(r, r->a), echo_rule(r, r->b), putc('\n', stdout); + while(*s == ' ') s++; + rules_++; + } return write_tail(s); } /* phase: undefine */