Implement atom evaluation

This commit is contained in:
2025-08-10 13:55:20 +01:00
parent 03bd0ff597
commit 3f871d2b43
5 changed files with 95 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
add_library(imp
am.c
env.c
eval.c
expr.c
memory_stream.c
parse.c

19
lib/eval.c Normal file
View File

@@ -0,0 +1,19 @@
#include "eval.h"
#include "env.h"
#include <assert.h>
void eval(am_t *am)
{
assert(am->expr->is_atom);
switch (am->expr->atom.type) {
case ATOM_TYPE_EMPTY_LIST:
case ATOM_TYPE_INTEGER:
am->val = am->expr;
break;
case ATOM_TYPE_SYMBOL:
env_fetch(am);
break;
}
}

8
lib/include/eval.h Normal file
View File

@@ -0,0 +1,8 @@
#ifndef EVAL_H
#define EVAL_H
#include "am.h"
void eval(am_t *am);
#endif