From 2f9f9d7f15242f043aebe800adc9ea696b73d2dd Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Thu, 25 Apr 2024 22:35:15 -0700 Subject: [PATCH] Do not match on substrings --- examples/repl.modal | 6 +++--- examples/tests.modal | 1 + makefile | 2 +- src/modal.c | 2 ++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/repl.modal b/examples/repl.modal index e6354c9..15cbd7f 100644 --- a/examples/repl.modal +++ b/examples/repl.modal @@ -1,8 +1,8 @@ ?(?-) (This is a fully functional Modal REPL.) <> quit EOF +<> wait?~ (?~ wait!) <> (?: print) ?: -<> (wait ?~) (?~ wait stdin) -<> (EOF wait stdin) (Bye.\n print) +<> (EOF wait!) (Bye.\n print) -(Say something, or type "quit":\n) print wait stdin +(Say something, or type "quit":\n) print wait! \ No newline at end of file diff --git a/examples/tests.modal b/examples/tests.modal index 8a47786..01a175e 100644 --- a/examples/tests.modal +++ b/examples/tests.modal @@ -52,6 +52,7 @@ connect foo bar baz = foo-barbaz (substring 1) test prefix-anything = anything-suffix (substring 2) test +?(foo QQQ) foobar = foobar (substring 3) test ?(?-) (Lambdas) diff --git a/makefile b/makefile index 24e2457..315db9c 100644 --- a/makefile +++ b/makefile @@ -8,7 +8,7 @@ all: dest dest: @ mkdir -p bin run: all bin/modal - @ bin/modal -q examples/hello.modal + @ bin/modal examples/hello.modal debug: all bin/modal-debug @ bin/modal-debug examples/hello.modal test: all bin/modal-debug bin/modal diff --git a/src/modal.c b/src/modal.c index 0e4f055..7190316 100644 --- a/src/modal.c +++ b/src/modal.c @@ -131,6 +131,8 @@ apply_rule(Rule *r, char *s) } if(c != *s++) return 0; } + c = *s; + if(!spacer(c)) return 0; /* phase: write rule */ while((c = *b++)) { if(c == '?') {