-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathptree.h
64 lines (53 loc) · 1.06 KB
/
ptree.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef __PTREE_H_
#define __PTREE_H_
#include "stream.h"
#include "operators.h"
typedef enum
{
NONE,
IDENTIFIER,
OPERATOR,
NUMERIC_CONSTANT,
CHAR_CONSTANT,
STRING_CONSTANT,
STRUCT_CONSTANT,
NULL_CONSTANT,
TRUE_CONSTANT,
FALSE_CONSTANT,
OPERATION,
STRUCT_DECLARATION,
VARIABLE_DECLARATION,
FUNCTION_DECLARATION,
POINTER_TYPE,
ARRAY_TYPE,
STRUCT_TYPE,
FUNCTION_TYPE,
ELLIPSIS,
IF_STATEMENT,
WHILE_STATEMENT,
FOR_STATEMENT,
RETURN_STATEMENT,
ASSERT_STATEMENT,
BREAK_STATEMENT,
CONTINUE_STATEMENT,
BLOCK,
}NodeType;
extern const char* nodeTypeNames[];
typedef struct Node Node;
struct Node
{
int type;
String source;
char* value;
OperatorId operator;
Node* child;
Node* next;
};
__attribute__((noreturn)) void panicNode(const Node* n, const char* format, ...);
void assertNode(const Node* n, bool assertion, const char* format, ...);
void freeNode(Node* n);
void addChild(Node* parent, const Node children);
Node* getChild(const Node* parent, const int index);
int getChildrenCount(const Node* parent);
void dumpNode(const Node* n);
#endif