From c7c5a20977e02dfed5afc774ed3ebaa44123f96c Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Thu, 4 Apr 2024 20:13:14 -0700 Subject: [PATCH] Unwrap rules storage --- examples/hello.modal | 2 +- examples/test.modal | 2 +- src/modal.c | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) 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; }