Implement atom evaluation
This commit is contained in:
@@ -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
19
lib/eval.c
Normal 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
8
lib/include/eval.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef EVAL_H
|
||||
#define EVAL_H
|
||||
|
||||
#include "am.h"
|
||||
|
||||
void eval(am_t *am);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user