Archived
1
0
Fork 0
This repository has been archived on 2023-11-10. You can view files and clone it, but cannot push or open issues or pull requests.
lispy/lval/base.h

39 lines
669 B
C
Raw Permalink Normal View History

2018-06-07 19:10:53 -04:00
#ifndef LVAL_BASE
#define LVAL_BASE
struct lval;
struct lenv;
typedef struct lval lval;
typedef struct lenv lenv;
typedef lval* (*lbuiltin) (lenv*, lval*);
2018-06-07 19:10:53 -04:00
typedef union typeval {
long num;
double dec;
// Error and symbols contain string data
char* err;
char* sym;
2018-06-07 19:10:53 -04:00
} TypeVal;
// A lispy value can either be a number, error, symbol, or an expression
struct lval {
2018-06-07 19:10:53 -04:00
int type;
TypeVal data;
// Function
lbuiltin builtin;
lenv* env;
lval* formals;
lval* body;
2018-06-07 19:10:53 -04:00
// Count and pointer to a list of lval*
int count;
lval** cell;
};
2018-06-07 19:10:53 -04:00
// Possible lispy value types
enum { LVAL_ERR, LVAL_LONG, LVAL_DOUBLE, LVAL_SYM, LVAL_SEXPR, LVAL_QEXPR, LVAL_FUN };
2018-06-07 19:10:53 -04:00
#endif