-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathast.h
More file actions
77 lines (62 loc) · 1.39 KB
/
ast.h
File metadata and controls
77 lines (62 loc) · 1.39 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef _AST_H
#define _AST_H
// Header file for the abstract syntax tree nodes used by the parser
#include <stdio.h>
#include <errno.h>
#include "symtable.h"
enum AST_TYPE {
AST_VAR = 0,
AST_FN,
AST_PARAMETERS,
AST_STORAGE,
AST_TYPE = 4,
AST_QUALIFIER,
AST_STRUCT,
AST_UNION,
AST_ASSIGN,
AST_RETURN,
AST_NUM = 10,
AST_CHAR,
AST_STRING,
AST_BINOP,
AST_UNOP,
AST_TERNOP = 15,
AST_IF,
AST_IFELSE,
AST_FOR,
AST_WHILE,
AST_DO = 20,
AST_SWITCH,
AST_LABEL
};
enum KW_TYPE {
KW_INT = 0,
KW_CHAR,
KW_DOUBLE,
KW_LONG,
KW_SHORT,
KW_VOID,
KW_FLOAT,
KW_SIGNED,
KW_UNSIGNED
};
enum AST_INSERT_TYPE {
AST_INSERT_LEFT = 0,
AST_INSERT_NEXT = 1
};
struct astNode {
enum AST_TYPE type;
int scope;
char filename[128];
struct astNode *left, *right, *initCondition, *condition, *loopCondition, *next, *prev, *if_true, *else_true;
struct attr {
int size, val, op, storage, type, linenum, returnType, varNum;
char *identname, stringval[4096];
} attributes;
};
struct astNode *new_astNode(int type);
struct astNode *insert_astNode(struct astNode *parent, struct astNode *node, int insertType);
struct astNode *reverse_AST(struct astNode *parent, int insertType);
void print_astNode(struct astNode *node);
void print_AST(struct astNode *start);
#endif