Only try-match during spacers
This commit is contained in:
parent
cced3c8d26
commit
bb72d27e2d
|
@ -3,20 +3,20 @@
|
|||
<> (add (0) (s ?y)) (s ?y)
|
||||
<> (add (0) (0)) (0)
|
||||
|
||||
<> (subtract (s ?x) (s ?y)) (subtract ?x ?y)
|
||||
<> (subtract (s ?x) (0)) (s ?x)
|
||||
<> (subtract (0) (s ?y)) (s ?y)
|
||||
<> (subtract (0) (0)) (0)
|
||||
<> (sub (s ?x) (s ?y)) (sub ?x ?y)
|
||||
<> (sub (s ?x) (0)) (s ?x)
|
||||
<> (sub (0) (s ?y)) (s ?y)
|
||||
<> (sub (0) (0)) (0)
|
||||
|
||||
<> (multiply (s ?x) (s ?y)) (add (s ?x) (multiply (s ?x) (subtract (s ?y) (s (0)))))
|
||||
<> (multiply (s ?x) (s (0)) (s ?x)
|
||||
<> (multiply (s (0)) (s ?y) (s ?y)
|
||||
<> (multiply (s ?x) (0)) (0)
|
||||
<> (multiply (0) (s ?x)) (0)
|
||||
<> (mul (s ?x) (s ?y)) (add (s ?x) (mul (s ?x) (sub (s ?y) (s (0)))))
|
||||
<> (mul (s ?x) (s (0)) (s ?x)
|
||||
<> (mul (s (0)) (s ?y) (s ?y)
|
||||
<> (mul (s ?x) (0)) (0)
|
||||
<> (mul (0) (s ?x)) (0)
|
||||
|
||||
<> (?x + ?y) (add ?x ?y)
|
||||
<> (?x - ?y) (subtract ?x ?y)
|
||||
<> (?x * ?y) (multiply ?x ?y)
|
||||
<> (?x - ?y) (sub ?x ?y)
|
||||
<> (?x * ?y) (mul ?x ?y)
|
||||
|
||||
<> (factorial (s (0))) ((s (0)))
|
||||
<> (factorial (s ?x)) (((s ?x) * factorial ((s ?x) - (s (0)))))
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<> (?x dup) (?x ?x)
|
||||
<> (?x ?y swap) (?y ?x)
|
||||
<> ( ?x pop) ()
|
||||
<> ([b]) ()
|
||||
<> (b) ([b])
|
||||
|
||||
(1 2 3) (4 5 6) swap pop dup
|
||||
(abc)
|
|
@ -59,7 +59,7 @@ match(char *p, Rule *r)
|
|||
regs[id] = b;
|
||||
a++, b = walk(b), c = *b;
|
||||
}
|
||||
if(!a[0]) return b;
|
||||
if(!a[0] && spacer(*(b + 1))) return b;
|
||||
if(c != *b) return NULL;
|
||||
a++, b++;
|
||||
}
|
||||
|
@ -143,6 +143,7 @@ rewrite(void)
|
|||
int i;
|
||||
if(p[0] == '<' && p[1] == '>')
|
||||
p = addrule(p) + 1, c = *p;
|
||||
if(p == bank_a || p == bank_b || spacer(*(p - 1))) {
|
||||
for(i = 0; i < rules_len; i++) {
|
||||
Rule *r = &rules[i];
|
||||
char *res = match(p, r);
|
||||
|
@ -161,6 +162,7 @@ rewrite(void)
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
*outp_++ = c;
|
||||
p++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue