return r;
}
+struct lambda *make_numeral(unsigned int i)
+{
+ struct lambda *body = make_ident("x");
+ while(i-- > 0)
+ body = make_application(make_ident("f"), body);
+ return make_abstraction("f", make_abstraction("x", body));
+}
+
+struct lambda *make_bool(bool b)
+{
+ return b
+ ? make_abstraction("a", make_abstraction("b", make_ident("a")))
+ : make_abstraction("a", make_abstraction("b", make_ident("b")));
+}
+
void decls_prepend(char *ident, struct lambda *value)
{
struct decllist *head = malloc(sizeof (struct decllist));
%}
-%token LAMBDA DOT OBRACE CBRACE IDENT FUNC SEMICOLON ASSIGN
+%token LAMBDA DOT OBRACE CBRACE IDENT FUNC SEMICOLON ASSIGN LITERAL
%%
| appterm
{ $$ = $1; }
appterm
- : FUNC
+ : LITERAL
+ { $$ = $1; }
+ | FUNC
{
$$ = decls_lookup($1->data.identifier.ident);
lambda_free($1);