Converging lambdas and match
This commit is contained in:
parent
3c5e3de38f
commit
19b3c03a8a
19
src/modal.c
19
src/modal.c
|
@ -146,7 +146,7 @@ parse_frag(char *s)
|
|||
static int
|
||||
rewrite(void)
|
||||
{
|
||||
char c, last = 0, *p = direction ? bank_b : bank_a;
|
||||
char c, last = 0, *p = direction ? bank_b : bank_a, *res;
|
||||
while((c = *p) && c <= ' ') p++;
|
||||
while((c = *p)) {
|
||||
if(spacer(last)) {
|
||||
|
@ -154,21 +154,15 @@ rewrite(void)
|
|||
if(p[0] == '<' && p[1] == '>') {
|
||||
r = rules_++;
|
||||
r->id = rules_ - rules - 1;
|
||||
p += 2;
|
||||
r->a = dict_, p = parse_frag(p);
|
||||
r->b = dict_, p = parse_frag(p);
|
||||
p += 2, r->a = dict_, p = parse_frag(p), r->b = dict_, p = parse_frag(p);
|
||||
return commit_rule(r, p, 1);
|
||||
}
|
||||
if(p[0] == '?' && p[1] == '(') {
|
||||
char *res;
|
||||
p += 2;
|
||||
lambda.a = dict_, p = parse_frag(p);
|
||||
lambda.b = dict_, p = parse_frag(p);
|
||||
r = λ
|
||||
p += 2, r->a = dict_, p = parse_frag(p), r->b = dict_, p = parse_frag(p);
|
||||
p++;
|
||||
while((c = *p) && c <= ' ') p++;
|
||||
r = λ
|
||||
res = match_rule(p, r);
|
||||
if(res != NULL) {
|
||||
if((res = match_rule(p, r)) != NULL) {
|
||||
char cc, *b = r->b;
|
||||
printf("LAMBDA [%s][%s] > %s\n", r->a, r->b, p);
|
||||
if(!*b && last == ' ') outp_--;
|
||||
|
@ -182,8 +176,7 @@ rewrite(void)
|
|||
}
|
||||
}
|
||||
for(r = rules; r < rules_; r++) {
|
||||
char *res = match_rule(p, r);
|
||||
if(res != NULL) {
|
||||
if((res = match_rule(p, r)) != NULL) {
|
||||
char cc, *b = r->b;
|
||||
if(!*b && last == ' ') outp_--;
|
||||
while((cc = *b++)) {
|
||||
|
|
Loading…
Reference in New Issue