-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseDef.h
More file actions
88 lines (80 loc) · 1.86 KB
/
parseDef.h
File metadata and controls
88 lines (80 loc) · 1.86 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
/*
BATCH NUMBER: 23
PRABODH AGARWAL 2012B1A7801P
DEEPANSHU SINGH 2012B3A7593P
parseDef.h: defines the variables and data structures used in parser.c
*/
#ifndef PARSEDEF
#define PARSEDEF
#include "lexer.h"
#define NON_TERMINAL_OFFSET 1000 // Offset for Non-Terminal's enum. Terminal Enum starts from 0.
#define gg (*g)
#define MAX_RULES 88 // Number of rules in Grammar
#define MAX_RULE_SIZE 100 // Maximum size of a rule
#define MAX_TERMINALS 57 // Number of Terminals in a grammar
#define MAX_NON_TERMINALS 52 // Number of Non-Terminals in a grammar
typedef enum{
all = NON_TERMINAL_OFFSET,
allVar,
arithmeticExpression,
assignmentStmt,
booleanExpression,
conditionalStmt,
constructedDatatype,
dataType,
declaration,
declarations,
innerTerm,
elseStmt,
factor,
fieldDefinition,
fieldDefinitions,
funCallStmt,
function,
global_or_not,
mulDiv,
idList,
input_par,
inputParameters,
ioStmt,
iterativeStmt,
logicalOp,
plusMinus,
mainFunctions,
more_ids,
moreFields,
operator,
optionalReturn,
otherFunctions,
otherStmts,
output_par,
outputParameters,
parameter_list,
primitiveDatatype,
program,
relationalOp,
remaining_list,
returnStmt,
singleOrRecId_,
singleOrRecId,
stmt,
stmts,
recAdjust,
term,
termPrime,
typeDefinition,
typeDefinitions,
var
}nontermid;
//Data Structure to store Parse Tree
struct parseTree{
union { //union used because a node can either be a non terminal or a terminal not both
nontermid nonterm;
tokenInfo term;
};
short isTerminal; // whether the node is a terminal or not
struct parseTree *children; // to store pointers to the children of the node
int nochildren; // number of children of a node
};
typedef struct parseTree parseTree;
#endif