Unwrap rules on reading
This commit is contained in:
parent
0557b06faf
commit
373137a054
|
@ -1,5 +1,4 @@
|
|||
<> (?x dup) (?x ?x)
|
||||
<> (?x ?y swap) (?y ?x)
|
||||
|
||||
((A B swap) dup)
|
||||
|
||||
A B dup
|
||||
|
|
13
src/modal.c
13
src/modal.c
|
@ -107,7 +107,7 @@ print_rules(void)
|
|||
{
|
||||
int i;
|
||||
for(i = 0; i < rules_len; i++)
|
||||
printf("Rule #%d: %s -> %s\n", i, rules[i].a, rules[i].b);
|
||||
printf("Rule #%d: <%s> -> <%s>\n", i, rules[i].a, rules[i].b);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
@ -118,14 +118,19 @@ parse_rulefrag(char *line)
|
|||
char c, *s = line, *res = dict_;
|
||||
if(s[0] == '(') {
|
||||
while((c = *s++)) {
|
||||
if(c == '(') depth++;
|
||||
*dict_++ = c;
|
||||
if(c == ')') --depth;
|
||||
if(c == '(') {
|
||||
depth++;
|
||||
if(depth == 1) continue;
|
||||
}
|
||||
if(c == ')') {
|
||||
--depth;
|
||||
if(!depth) {
|
||||
*dict_++ = 0;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
*dict_++ = c;
|
||||
}
|
||||
}
|
||||
while(!spacer(s[0]) && (*dict_++ = *s++))
|
||||
;
|
||||
|
|
Loading…
Reference in New Issue