Added basic string support.
Added comments beginning with a semi-colon. Added load function to load lisp from a file. Arguments passed to klisp will be read and evaluated as lisp files.
This commit is contained in:
9
lval.h
9
lval.h
@@ -25,7 +25,7 @@ typedef struct lval_func lval_func;
|
||||
#define LVAL_IS_TRUE(val) (val->type == LVAL_NUM && fabs(val->data.num) > DBL_EPSILON)
|
||||
#define LVAL_IS_FALSE(val) (val->type == LVAL_NUM && fabs(val->data.num) <= DBL_EPSILON)
|
||||
|
||||
enum VAL_TYPE { LVAL_ERR, LVAL_NUM, LVAL_SYM, LVAL_FUNC, LVAL_S_EXPR, LVAL_Q_EXPR, LVAL_EXIT };
|
||||
enum VAL_TYPE { LVAL_ERR, LVAL_NUM, LVAL_SYM, LVAL_FUNC, LVAL_S_EXPR, LVAL_Q_EXPR, LVAL_EXIT, LVAL_STR };
|
||||
enum VAL_ERROR { LERR_DIV_ZERO, LERR_BAD_OP, LERR_BAD_NUM, LERR_BAD_SYM, LERR_OTHER, LERR_SYNTAX };
|
||||
typedef enum VAL_TYPE VAL_TYPE;
|
||||
typedef enum VAL_ERROR VAL_ERROR;
|
||||
@@ -46,11 +46,13 @@ struct lval {
|
||||
union {
|
||||
double_t num;
|
||||
char* sym;
|
||||
char* str;
|
||||
short exitcode;
|
||||
struct lval_func* func;
|
||||
struct {
|
||||
enum VAL_ERROR num;
|
||||
char* detail;
|
||||
} err;
|
||||
struct lval_func* func;
|
||||
} data;
|
||||
|
||||
int cell_count;
|
||||
@@ -65,7 +67,8 @@ lval* lval_s_expr();
|
||||
lval* lval_q_expr();
|
||||
lval* lval_builtin(lbuiltin func, char* name);
|
||||
lval* lval_lambda(lval* formals, lval* body);
|
||||
lval* lval_exit();
|
||||
lval* lval_exit(short exitcode);
|
||||
lval* lval_str(char* str);
|
||||
|
||||
lval* lval_add(lval* val, lval* x);
|
||||
lval* lval_pop(lval* val, int i);
|
||||
|
||||
Reference in New Issue
Block a user