-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathASTDef.h
More file actions
79 lines (72 loc) · 1.95 KB
/
ASTDef.h
File metadata and controls
79 lines (72 loc) · 1.95 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
78
79
// Batch Number - 38
// 2014A7PS102P - RISHABH JOSHI
// 2014A7PS248P - DEEP VYAS
#ifndef _ASTDEF_
#define _ASTDEF_
#include <stdbool.h>
#include "parserDef.h"
#include "lexerDef.h"
#include "hashTable.h"
//#include "HashTreeDef.h"
typedef union{
int num;
float r_num;
int tval;
}valueAST;
struct ASTNode{
//Arithmetic or Boolean Nodes non-terminals==
GNodeType gnode;
tag t;
valueAST value;
//==
//ID or Module name==
int dtype; // 0 integer, 1 real, 2 bool, 3 array
int lrange;
int rrange;
int arrtype; // 0 integer arr, 1 real arr, 2 bool arr
//SymbolTable Ptr
int startscope;
int endscope;
tokenInfo *tokenptr;
int scope;
//==
//For operators
// STMT TYPE
int stmttype;
//if IOSTMT
//VAR
int vartype;
int sign;
// ITERTIVESMT
int looptype;
//IDLIST OR STATEMENT LIST
int listcount;
/*FOR CODE GEN*/
int decode;
struct ASTNode *lop,*rop;
// Pointer to the hashTable made void* and typecasted later
void *htPointer;
// FOR CODE GENERATION
int memoryLocation;
//Family
struct ASTNode *parent,*child,*sibling;
};
typedef struct ASTNode ASTNode;
/*Function prototypes*/
ASTNode* genAST(ParseTreeNode *proot,ASTNode *parent);
ASTNode* compressList(ParseTreeNode *proot,ASTNode *parent);
ASTNode* create_ast_node();
int extract_type(ParseTreeNode *node);
ASTNode* make_id_node(ParseTreeNode *idnode,ParseTreeNode *dnode);
ASTNode* compressList(ParseTreeNode *proot,ASTNode *parent);
ASTNode* resolve_var(ParseTreeNode *node,ASTNode *parent);
ASTNode* resolve_assgn_stmt(ParseTreeNode *node,ASTNode *parent);
ASTNode* resolve_module_stmt(ParseTreeNode *node,ASTNode *parent);
ASTNode* resolve_exp_recursive(ParseTreeNode *node,ASTNode *parent);
ASTNode* genAST(ParseTreeNode *proot,ASTNode *parent);
void _printAST(ASTNode *ast_root);
ASTNode* makeAST(char *filename);
void printAllocatedMemory(ASTNode *ast_root, int *number);
void _printAllocatedMemory2(ParseTreeNode *proot, int *number);
void printAllocatedMemory2(int *number);
#endif