diff --git a/examples/test.modal b/examples/test.modal index 312e9f4..c9e0aa4 100644 --- a/examples/test.modal +++ b/examples/test.modal @@ -1,4 +1,4 @@ <> (swap ?x ?y) (?y ?x) -(swap 123 456) +(swap (123) (456)) diff --git a/src/modal.c b/src/modal.c index 9f6600a..c10fe55 100644 --- a/src/modal.c +++ b/src/modal.c @@ -18,15 +18,15 @@ walk(char *s) { int depth = 0; char c; - while((c = *s++)) { - if(c == '(') depth++; - if(c == ')') { - --depth; - if(!depth) break; + if(s[0] == '(') { + while((c = *s++)) { + if(c == '(') depth++; + if(c == ')') --depth; + if(!depth) return s; } - if(depth == 0 && c == ' ') return s - 1; - if(depth < 1 && c == ' ') { return s - 1; } } + while((c = *s++)) + if(spacer(c)) return s - 1; return s; }