diff --git a/examples/hello.modal b/examples/hello.modal index dd63d61..1e92471 100644 --- a/examples/hello.modal +++ b/examples/hello.modal @@ -1,4 +1,4 @@ <> (?x dup) (?x ?x) <> (?x ?y swap) (?y ?x) -foo ((A B swap) dup) \ No newline at end of file +(A B swap) dup \ No newline at end of file diff --git a/examples/test.modal b/examples/test.modal index dd63d61..1e92471 100644 --- a/examples/test.modal +++ b/examples/test.modal @@ -1,4 +1,4 @@ <> (?x dup) (?x ?x) <> (?x ?y swap) (?y ?x) -foo ((A B swap) dup) \ No newline at end of file +(A B swap) dup \ No newline at end of file diff --git a/src/modal.c b/src/modal.c index 108efbf..f399099 100644 --- a/src/modal.c +++ b/src/modal.c @@ -119,8 +119,14 @@ parse_rulefrag(FILE *f) int depth = 0; char c, *origin = dict_; while(f && fread(&c, 1, 1, f) && c && c != 0xa) { - if(c == '(') depth++; - if(c == ')') --depth; + if(c == '(') { + depth++; + if(depth == 1) continue; + } + if(c == ')') { + --depth; + if(depth == 0) continue; + } if(c == ' ' && !depth) break; *dict_++ = c; }