Fixed issue with empty r->b rules
This commit is contained in:
parent
93d7d791f3
commit
7ea50f18b7
|
@ -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))))))
|
|
@ -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)
|
||||
(implode reverse (explode hello)) (read) (explode hello) empty-register (eq abc abc) (eq abc def) (1 2 3) (4 5 6) swap pop dup
|
|
@ -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++);
|
||||
|
|
Loading…
Reference in New Issue