forked from mayankgupta022/compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.txt
89 lines (89 loc) · 3 KB
/
grammar.txt
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
program otherfunctions mainfunction .
mainfunction TK_MAIN stmts TK_END .
otherfunctions function otherfunctions .
otherfunctions eps .
function TK_FUNID input_par output_par TK_SEM stmts TK_END .
input_par TK_INPUT TK_PARAMETER TK_LIST TK_SQL parameter_list TK_SQR .
output_par TK_OUTPUT TK_PARAMETER TK_LIST TK_SQL parameter_list TK_SQR .
output_par eps .
parameter_list datatype TK_ID remaining_list .
datatype primitivedatatype .
datatype constructeddatatype .
primitivedatatype TK_INT .
primitivedatatype TK_REAL .
constructeddatatype TK_RECORD TK_RECORDID .
remaining_list TK_COMMA parameter_list .
remaining_list eps .
stmts typedefinitions declarations otherstmts returnstmt .
typedefinitions typedefinition typedefinitions .
typedefinitions eps .
typedefinition TK_RECORD TK_RECORDID fielddefinitions TK_ENDRECORD TK_SEM .
fielddefinitions fielddefinition fielddefinition morefields .
fielddefinition TK_TYPE primitivedatatype TK_COLON TK_FIELDID TK_SEM .
morefields fielddefinition morefields .
morefields eps .
declarations declaration declarations .
declarations eps .
declaration TK_TYPE datatype TK_COLON TK_ID global_or_not TK_SEM .
global_or_not TK_COLON TK_GLOBAL .
global_or_not eps .
otherstmts stmt otherstmts .
otherstmts eps .
stmt assignmentstmt .
stmt iterativestmt .
stmt conditionalstmt .
stmt iostmt .
stmt funcallstmt .
assignmentstmt singleorrecid TK_ASSIGNOP arithmeticexpression TK_SEM .
singleorrecid TK_ID newstate .
newstate TK_DOT TK_FIELDID .
newstate eps .
funcallstmt outputparameters TK_CALL TK_FUNID TK_WITH TK_PARAMETERS inputparameters TK_SEM.
outputparameters TK_SQL idlist TK_SQR TK_ASSIGNOP .
outputparameters eps .
inputparameters TK_SQL idlist TK_SQR .
iterativestmt TK_WHILE TK_OP booleanexpression TK_CL stmt otherstmts TK_ENDWHILE .
conditionalstmt TK_IF TK_OP booleanexpression TK_CL TK_THEN stmt otherstmts elsepart .
elsepart TK_ELSE stmt otherstmts TK_ENDIF .
elsepart TK_ENDIF .
iostmt TK_READ TK_OP singleorrecid TK_CL TK_SEM .
iostmt TK_WRITE TK_OP allvar TK_CL TK_SEM .
allvar var .
allvar TK_RECORDID .
arithmeticexpression term expprime .
expprime lowprecedenceoperators term expprime .
expprime eps .
term factor termprime .
termprime highprecedenceoperators factor termprime .
termprime eps .
factor TK_OP arithmeticexpression TK_CL .
factor all .
highprecedenceoperators TK_MUL .
highprecedenceoperators TK_DIV .
lowprecedenceoperators TK_PLUS .
lowprecedenceoperators TK_MINUS .
all TK_NUM .
all TK_RNUM .
all TK_ID temp .
temp eps .
temp TK_DOT TK_FIELDID .
booleanexpression TK_OP booleanexpression TK_CL logicalop TK_OP booleanexpression TK_CL .
booleanexpression var relationalop var .
booleanexpression TK_NOT booleanexpression .
var TK_ID .
var TK_NUM .
var TK_RNUM .
logicalop TK_AND .
logicalop TK_OR .
relationalop TK_LT .
relationalop TK_LE .
relationalop TK_EQ .
relationalop TK_GT .
relationalop TK_GE .
relationalop TK_NE .
returnstmt TK_RETURN optionalreturn TK_SEM .
optionalreturn TK_SQL idlist TK_SQR .
optionalreturn eps .
idlist TK_ID more_ids .
more_ids TK_COMMA idlist .
more_ids eps .