#ifndef __GUT_PARSE_TREE_HPP #define __GUT_PARSE_TREE_HPP #include #include #include #include "util.hpp" #include "variable.hpp" #include "environ.hpp" namespace gut { typedef enum { NODE_TYPE_NULL = 0, NODE_TYPE_SYMBOL, NODE_TYPE_VALUE, NODE_TYPE_NODE } node_type_e; typedef struct { std::jmp_buf context; variable *result; environment *env; } stackframe_t; typedef struct _ptnode { node_type_e type; int token_id; unsigned long line; union { void *data; variable *value; struct _ptnode *node; std::string *symbol; } element; struct _ptnode *next; static struct _ptnode *newnode(void); static struct _ptnode *newnode(variable *value); static struct _ptnode *newnode(struct _ptnode *node); static struct _ptnode *newnode(std::string *symbol); struct _ptnode *add(variable *value); struct _ptnode *add(struct _ptnode *node); struct _ptnode *add(std::string *symbol); struct _ptnode *append(struct _ptnode *node); void print(void); void destroy(void); variable eval(stackframe_t *frame); variable run(stackframe_t *frame); //private struct _ptnode *tail(void); } ptnode; typedef ptnode * pptnode; typedef struct token { int id; std::string value; } token_t; typedef std::map sub_table_t; extern sub_table_t g_sub; } // namespace gut #endif // __GUT_PTNODE_HPP