From 64feef1b9ea72adf7ba32998e9dca7d507607498 Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Mon, 2 Jan 2023 22:31:49 -0800 Subject: a lot of stuff. --- src/include/ast.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/include/ast.h (limited to 'src/include/ast.h') diff --git a/src/include/ast.h b/src/include/ast.h new file mode 100644 index 0000000..f7be3d5 --- /dev/null +++ b/src/include/ast.h @@ -0,0 +1,42 @@ +#ifndef AST_H +#define AST_H +#include + +typedef struct AST_STRUCT { + enum { + /* complex types */ + AST_PAIR, + AST_SYMBOL, + /* self evaluating types */ + AST_STRING, + AST_BOOL, + AST_INT, + AST_FLOAT, + AST_FUNCTION, + } type; + + /* For functions, the car will be a list of variables, and the cdr will be the + * expression */ + struct AST_STRUCT *car; + struct AST_STRUCT *cdr; + + char *string_value; + int int_value; + double float_value; + bool bool_value; +} ast_t; + +ast_t *init_ast_string(char *value); + +ast_t *init_ast_int(int value); + +ast_t *init_ast_float(double value); + +ast_t *init_ast_pair(ast_t *car, ast_t *cdr); + +ast_t *init_ast_bool(bool value); + +ast_t *init_ast_symbol(char *value); + +ast_t *init_ast_function(ast_t *car, ast_t *cdr); +#endif -- cgit