-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathparserDef.h
75 lines (63 loc) · 1.5 KB
/
parserDef.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
64
65
66
67
68
69
70
71
72
73
74
75
/*
Group Number : 2
1 Dhruv Rawat 2019B3A70537P thedhruvrawat
2 Chirag Gupta 2019B3A70555P Chirag5128
3 Swastik Mantry 2019B1A71019P Swastik-Mantry
4 Shreyas Sheeranali 2019B3A70387P ShreyasSR
5 Vaibhav Prabhu 2019B3A70593P prabhuvaibhav
*/
#ifndef PARSER_DEF
#define PARSER_DEF
#include "Set.h"
#include "lexerDef.h"
typedef struct Tuple {
int enumID;
char* token;
} Tuple;
typedef struct listElement {
int productionID;
struct listElement* next;
} listElement;
typedef struct grammarElement {
bool isTerminal;
int tokenID;
char lexeme[100];
struct grammarElement *next, *prev;
} grammarElement;
typedef struct ProductionRule {
int productionID;
int RHScount;
grammarElement* LHS; // pointer to LHS of a rule
grammarElement *RHSHead, *RHSTail; // pointer to first element in RHS
Set *firstSet, *followSet;
} ProductionRule;
typedef struct ProductionTable {
int maxRules, ruleCount;
ProductionRule** grammarrules;
} ProductionTable;
typedef struct Leaf {
TOKEN* tok;
} Leaf;
typedef struct NonLeaf {
int productionID;
} NonLeaf;
typedef struct ParseTreeNode {
bool isLeaf;
union {
Leaf leaf;
NonLeaf nonLeaf;
};
int depth;
int tokenID;
int productionID;
int tokenDerivedFrom;
struct ParseTreeNode* next;
struct ParseTreeNode* child;
} ParseTreeNode;
typedef struct ParseTree {
ParseTreeNode* root;
int sz;
int treeDepth;
} ParseTree;
extern bool PARSER_ERROR;
#endif