fix eval
This commit is contained in:
parent
417b109fda
commit
c8b083d826
15
main.c
15
main.c
|
@ -278,7 +278,7 @@ void expect(const enum TokenType token_type)
|
|||
|
||||
struct Object *parse()
|
||||
{
|
||||
return parens();
|
||||
return expr();
|
||||
}
|
||||
|
||||
struct Object *expr()
|
||||
|
@ -337,8 +337,17 @@ struct Object *parens_part()
|
|||
|
||||
struct Object *eval(struct Object *const program)
|
||||
{
|
||||
if (program->type != TYPE_PAIR) {
|
||||
error("eval expects pair");
|
||||
if (!program) {
|
||||
error("can't eval null");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (program->type != TYPE_PAIR && program->type != TYPE_ATOM) {
|
||||
return program;
|
||||
}
|
||||
|
||||
if (program->type == TYPE_ATOM) {
|
||||
error("can't eval atoms");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue