Fixed issue in write reg
This commit is contained in:
parent
70a158d3da
commit
920be34b20
|
@ -1,4 +1,4 @@
|
|||
<> (swap ?x ?y) (?y ?x)
|
||||
|
||||
(swap (123) (456))
|
||||
<> (?x dup) (?x ?x)
|
||||
<> (?x ?y swap) (?y ?x)
|
||||
|
||||
foo ((A B swap) dup)
|
20
src/modal.c
20
src/modal.c
|
@ -35,31 +35,29 @@ match(char *p, Rule *r)
|
|||
{
|
||||
char c, *a = r->a, *b = p;
|
||||
while((c = *a)) {
|
||||
if(c == '?') {
|
||||
regs[(int)*(++a)] = b, a++, b = walk(b), c = *b;
|
||||
}
|
||||
if(c == '?') regs[(int)*(++a)] = b, a++, b = walk(b), c = *b;
|
||||
if(c != *b) return NULL;
|
||||
a++, b++;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
static int
|
||||
static void
|
||||
writereg(char r)
|
||||
{
|
||||
int depth = 0;
|
||||
char c, *s = regs[(int)r];
|
||||
if(s[0] == '(') {
|
||||
while((c = *s++)) {
|
||||
if(c == '(') depth++;
|
||||
if(c == ')') {
|
||||
--depth;
|
||||
if(!depth) break;
|
||||
}
|
||||
if(depth < 0) break;
|
||||
if(depth == 0 && c == ' ') break;
|
||||
*outp_++ = c;
|
||||
if(c == ')') --depth;
|
||||
if(!depth) return;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
while(!spacer(s[0]) && (*outp_++ = *s++))
|
||||
;
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue