Do not match on substrings

This commit is contained in:
Devine Lu Linvega 2024-04-25 22:35:15 -07:00
parent 7e9eab04fc
commit 2f9f9d7f15
4 changed files with 7 additions and 4 deletions

View File

@ -1,8 +1,8 @@
?(?-) (This is a fully functional Modal REPL.) ?(?-) (This is a fully functional Modal REPL.)
<> quit EOF <> quit EOF
<> wait?~ (?~ wait!)
<> (?: print) ?: <> (?: print) ?:
<> (wait ?~) (?~ wait stdin) <> (EOF wait!) (Bye.\n print)
<> (EOF wait stdin) (Bye.\n print)
(Say something, or type "quit":\n) print wait stdin (Say something, or type "quit":\n) print wait!

View File

@ -52,6 +52,7 @@
connect foo bar baz = foo-barbaz (substring 1) test connect foo bar baz = foo-barbaz (substring 1) test
prefix-anything = anything-suffix (substring 2) test prefix-anything = anything-suffix (substring 2) test
?(foo QQQ) foobar = foobar (substring 3) test
?(?-) (Lambdas) ?(?-) (Lambdas)

View File

@ -8,7 +8,7 @@ all: dest
dest: dest:
@ mkdir -p bin @ mkdir -p bin
run: all bin/modal run: all bin/modal
@ bin/modal -q examples/hello.modal @ bin/modal examples/hello.modal
debug: all bin/modal-debug debug: all bin/modal-debug
@ bin/modal-debug examples/hello.modal @ bin/modal-debug examples/hello.modal
test: all bin/modal-debug bin/modal test: all bin/modal-debug bin/modal

View File

@ -131,6 +131,8 @@ apply_rule(Rule *r, char *s)
} }
if(c != *s++) return 0; if(c != *s++) return 0;
} }
c = *s;
if(!spacer(c)) return 0;
/* phase: write rule */ /* phase: write rule */
while((c = *b++)) { while((c = *b++)) {
if(c == '?') { if(c == '?') {