-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparserDef.h
More file actions
94 lines (78 loc) · 1.62 KB
/
parserDef.h
File metadata and controls
94 lines (78 loc) · 1.62 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
/*
* COMPILER PROJECT- ERPLAG COMPILER
* CSE - D 2019
* Sahil Garg, Jenit Jain, Amrit Goyal
*/
#ifndef parserDef
#define parserDef
#include "lexer.h"
#include "lexerDef.h"
#define RULECNT 96
#define NTSIZE 52
#define TSIZE 60
//List of Definitions for Parser
int parse_status;
int no_of_parse_tree_nodes;
typedef enum
{
program, moduleDeclarations, moduleDeclaration, otherModules, driverModule, module, ret,
input_plist, N1, output_plist, N2, dataType, type, moduleDef, statements, statement,
ioStmt, var, whichID, simpleStmt, assignmentStmt, whichStmt, lvalueIDStmt, lvalueARRStmt,
index_nt, moduleReuseStmt, optional, idList, N3, expression, arithmeticOrBooleanExpr, N7,
AnyTerm, N8, arithmeticExpr, N4, term_1, N5, factor, op1, op2, logicalOp, relationalOp,
declareStmt, conditionalStmt, caseStmts, N9, value, default_1, iterativeStmt, range
}non_term;
typedef union
{
term t;
non_term nt;
}gElement;
typedef enum {terminal, non_terminal} tag;
term first[TSIZE][20];
term follow[TSIZE][20];
struct gNode
{
tag t;
gElement ge;
struct gNode* next;
};
struct gHead
{
non_term t;
struct gNode* top;
};
struct PTStack
{
struct gNode* top;
int size;
};
typedef struct pNode *pNode;
typedef struct Queue Queue;
struct Queue
{
pNode front;
pNode back;
int size;
};
struct pNode
{
tag t;
gElement e;
int level, no_of_child;
tokenInfo* token_link;
pNode next;
pNode parent;
Queue child;
};
struct parseTree
{
pNode root;
pNode c_node;
int height;
};
typedef struct gHead gHead;
typedef struct gNode *gNode;
typedef struct gHead *Grammar;
typedef struct parseTree parseTree;
typedef struct PTStack PTStack;
#endif