struct lambda *make_bool(bool b)
{
- return b
- ? make_abstraction("a", false, make_abstraction("b", false, make_ident("a")))
- : make_abstraction("a", false, make_abstraction("b", false, make_ident("b")));
+ return make_abstraction("a", false,
+ make_abstraction("b", false, make_ident(b ? "a" : "b")));
}
void decls_prepend(char *ident, struct lambda *value)
struct lambda *decls_lookup(char *ident)
{
- struct decllist *c = decls;
- while(c != NULL){
+ for(struct decllist *c = decls; c != NULL; c = c->next)
if(strcmp(c->ident, ident) == 0)
return copy(c->value);
- c = c->next;
- }
return make_ident(ident);
}
decls_prepend($1->data.identifier.ident, $2);
printf("%s = ", $1->data.identifier.ident);
lambda_print($2, NULL);
- putchar('\n');
lambda_free($1);
}
| term
if(!lambda_reduce(&t, &t, false))
break;
lambda_print(t, NULL);
- putchar('\n');
lambda_free(t);
}
func