diff options
| author | Oskari Timperi <oskari.timperi@iki.fi> | 2014-05-15 22:48:34 +0300 |
|---|---|---|
| committer | Oskari Timperi <oskari.timperi@iki.fi> | 2014-05-15 22:48:34 +0300 |
| commit | e23d0ee6eec1433849e4af1f3906a0946a19aef4 (patch) | |
| tree | b7eaef2719ebc43a976cd5f63dea30d03fecca9a /atom.h | |
| parent | 3666d3b9334286a2242c8da20cac446dd9ee17e9 (diff) | |
| download | lispish-e23d0ee6eec1433849e4af1f3906a0946a19aef4.tar.gz lispish-e23d0ee6eec1433849e4af1f3906a0946a19aef4.zip | |
add atom types for true, false, nil
Diffstat (limited to 'atom.h')
| -rw-r--r-- | atom.h | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -4,13 +4,16 @@ #define LIST_GET_ATOM(LIST) ((struct atom *) (LIST)->data) #define ATOM_TYPE(LIST) ((LIST_GET_ATOM(LIST))->type) + #define IS_INT(LIST) ((ATOM_TYPE(LIST)) == ATOM_INT) #define IS_STR(LIST) ((ATOM_TYPE(LIST)) == ATOM_STR) #define IS_SYM(LIST) ((ATOM_TYPE(LIST)) == ATOM_SYMBOL) #define IS_LIST(LIST) ((ATOM_TYPE(LIST)) == ATOM_LIST) +#define IS_ATOM(LIST) (!(IS_LIST(LIST))) #define IS_TRUE(LIST) (LIST_GET_ATOM(LIST) == &true_atom) #define IS_FALSE(LIST) (LIST_GET_ATOM(LIST) == &false_atom) + #define IS_NIL(LIST) (LIST_GET_ATOM(LIST) == &nil_atom) #define CAR(LIST) LIST @@ -24,11 +27,16 @@ enum ATOM_INT, ATOM_STR, ATOM_SYMBOL, - ATOM_LIST + ATOM_LIST, + ATOM_TRUE, + ATOM_FALSE }; +struct list; + struct atom { + char type; union { long l; @@ -39,11 +47,8 @@ struct atom } str; struct list *list; }; - char type; }; -struct list; - struct atom *atom_new(char type); struct atom *atom_new_int(long l); struct atom *atom_new_str(const char *str, int len); |
