diff --git a/examples/arithmetic.modal b/examples/arithmetic.modal index 193bd39..7dc5405 100644 --- a/examples/arithmetic.modal +++ b/examples/arithmetic.modal @@ -17,4 +17,4 @@ <> (factorial (s (0))) ((s (0))) <> (factorial (s ?x)) (((s ?x) * factorial ((s ?x) - (s (0))))) -factorial (s (s (s (s (s (0)))))) +factorial (s (s (s (s (s (0)))))) \ No newline at end of file diff --git a/examples/test.modal b/examples/test.modal index af01726..c28e6d2 100644 --- a/examples/test.modal +++ b/examples/test.modal @@ -9,5 +9,8 @@ <> (explode ?*) (str (?*)) <> (eq ?x ?x) (#t) <> (eq ?x ?y) (#f) +<> (?x dup) (?x ?x) +<> (?x ?y swap) (?y ?x) +<> (?x pop) () -(implode reverse (explode hello)) (read) (explode hello) empty-register (eq abc abc) (eq abc def) \ No newline at end of file +(implode reverse (explode hello)) (read) (explode hello) empty-register (eq abc abc) (eq abc def) (1 2 3) (4 5 6) swap pop dup \ No newline at end of file diff --git a/src/modal.c b/src/modal.c index 900d4c4..bd15fe2 100644 --- a/src/modal.c +++ b/src/modal.c @@ -105,6 +105,8 @@ commit(char r) { int depth = 0; char c, *s = regs[(int)r]; + printf(">[%s]\n", s); + if(r == '*') s = plode(s); else if(s[0] == '(') { @@ -182,6 +184,7 @@ rewrite(void) char *res = match(p, r); if(res != NULL) { char cc, *b = r->b; + if(!*b) outp_--; while((cc = *b++)) { if(cc == '?' && regs[(int)b[0]]) commit(*b++);