diff --git a/examples/test.modal b/examples/test.modal index 6e8c05f..572cb9b 100644 --- a/examples/test.modal +++ b/examples/test.modal @@ -1,5 +1,4 @@ <> (?x dup) (?x ?x) <> (?x ?y swap) (?y ?x) -((A B swap) dup) - +A B dup diff --git a/src/modal.c b/src/modal.c index 812759c..b7bede3 100644 --- a/src/modal.c +++ b/src/modal.c @@ -107,7 +107,7 @@ print_rules(void) { int i; for(i = 0; i < rules_len; i++) - printf("Rule #%d: %s -> %s\n", i, rules[i].a, rules[i].b); + printf("Rule #%d: <%s> -> <%s>\n", i, rules[i].a, rules[i].b); printf("\n"); } @@ -118,13 +118,18 @@ parse_rulefrag(char *line) char c, *s = line, *res = dict_; if(s[0] == '(') { while((c = *s++)) { - if(c == '(') depth++; - *dict_++ = c; - if(c == ')') --depth; - if(!depth) { - *dict_++ = 0; - return res; + if(c == '(') { + depth++; + if(depth == 1) continue; } + if(c == ')') { + --depth; + if(!depth) { + *dict_++ = 0; + return res; + } + } + *dict_++ = c; } } while(!spacer(s[0]) && (*dict_++ = *s++))