skopy/lib/include/node.h

39 lines
1010 B
C

#ifndef SK_NODE_H
#define SK_NODE_H
#include "commons.h"
#define NODE_KIND(G) \
G(NODE_ROOT), \
G(NODE_INT), \
G(NODE_ADD), G(NODE_SUB), G(NODE_MUL),\
G(NODE_DIV), G(NODE_POW), G(NODE_MOD),\
G(NODE_USUB), G(NODE_ASSERT_EQ), \
G(NODE_BOOL), G(NODE_AND), G(NODE_OR), \
G(NODE_NOT), G(NODE_FLOAT), G(NODE_STRING), \
G(NODE_LT), G(NODE_LE), G(NODE_GT), G(NODE_GE), \
G(NODE_EQUAL), G(NODE_NOT_EQUAL), G(NODE_VAR_DECL), \
G(NODE_CONST_DECL), G(NODE_IDENT), G(NODE_ASSIGN), \
G(NODE_BLOCK), G(NODE_IF), G(NODE_FUN), G(NODE_PARAMS), \
G(NODE_RETURN), G(NODE_CALL), G(NODE_ARGS), G(NODE_MODULE), \
G(NODE_MOD_ACCESS), G(NODE_IMPORT)
SK_ENUM_H(NodeKind, NODE_KIND);
struct node
{
NodeKind kind;
struct vec children;
struct token* token;
};
void node_init(struct node* self,
NodeKind kind,
struct token* token);
void node_free(struct node* self);
void node_push_new_child(struct node* self, struct node* child);
void node_str(struct node* self, struct str* dest);
#endif