forked from SarthakShah001/Compiler2K23
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparserDef.h
More file actions
116 lines (110 loc) · 1.74 KB
/
parserDef.h
File metadata and controls
116 lines (110 loc) · 1.74 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
***** Group No. - 9 *****
Name : Sarthak Shah ID : 2020A7PS0092P
Name : Siddharth Khandelwal ID : 2020A7PS0098P
Name : Archaj Jain ID : 2020A7PS0072P
Name : BhanuPratap Singh Rathore ID : 2020A7PS1675P
Name : Rishi Rakesh Shrivastava ID : 2020A7PS0108P
*/
#ifndef _parserdef_
#define _parserdef_
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
typedef struct SYMBOL* symbol;
#include "hashTable.h"
#include "lexer.h"
#include "doublyLinkedList.h"
#define terminal tkType
#define num_rules 138
#define max_rule_length 200
extern int error_count;
typedef enum NONTERMINAL{
program,
moduleDeclarations,
moduleDeclaration,
otherModules,
driverModule,
module,
ret,
input_plist,
N1,
output_plist,
N2,
dataType,
range_arrays,
type,
moduleDef,
statements,
ioStmt,
boolConstt,
var_print,
P1,
simpleStmt,
assignmentStmt,
whichStmt,
lvalueIDStmt,
lvalueARRStmt,
index_arr,
new_index,
sign,
moduleReuseStmt,
actual_para_list,
N20,
optional,
idList,
N3,
expression,
U,
new_NT,
var_id_num,
unary_op,
arithmeticOrBooleanExpr,
N7,
AnyTerm,
N8,
arithmeticExpr,
N4,
term,
N5,
factor,
N11,
element_index_with_expressions,
arrExpr,
arr_N4,
arrTerm,
arr_N5,
arrFactor,
N10,
op1,
op2,
logicalOp,
relationalOp,
declareStmt,
condionalStmt,
caseStmts,
N9,
value,
DEFAULT,//default not working
iterativeStmt,
range_for_loop,
index_for_loop,
new_index_for_loop,
sign_for_loop
} nonterminal;
extern char *nonterminal_str[];
extern hashtable terminals,nonterminals;
struct SYMBOL{
union
{
terminal t;
nonterminal nt;
};
bool is_terminal;
};
typedef struct RULES{
nonterminal LHS;
dlinkedlist RHS;
}rule;
extern rule grep[num_rules];
#endif