-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgram1
90 lines (90 loc) · 3.03 KB
/
gram1
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
program = otherFunctions mainFunctions
mainFunctions = TK_MAIN stmts TK_END
otherFunctions = function otherFunctions
otherFunctions = epsilon
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 = epsilon
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 = epsilon
stmts = typeDefinitions declarations otherStmts returnStmt
typeDefinitions = typeDefinition typeDefinitions
typeDefinitions = epsilon
typeDefinition = TK_RECORD TK_RECORDID fieldDefinitions TK_ENDRECORD TK_SEM
fieldDefinitions = fieldDefinition fieldDefinitions moreFields
fieldDefinition = TK_TYPE primitiveDatatype TK_COLON TK_FIELDID TK_SEM
moreFields = fieldDefinition moreFields
moreFields = epsilon
declarations = declaration declarations
declarations = epsilon
declaration = TK_TYPE dataType TK_COLON TK_ID global_or_not TK_SEM
global_or_not = TK_COLON TK_GLOBAL
global_or_not = epsilon
otherStmts = stmt otherStmts
otherStmts = epsilon
stmt = assignmentStmt
stmt = iterativeStmt
stmt = conditionalStmt
stmt = ioStmt
stmt = funCallStmt
assignmentStmt = SingleOrRecId TK_ASSIGNOP arithmeticExpression TK_SEM
SingleOrRecId = TK_ID SingleOrRecId_
SingleOrRecId_ = TK_DOT TK_FIELDID
SingleOrRecId_ = epsilon
funCallStmt = outputParameters TK_CALL TK_FUNID TK_WITH TK_PARAMETERS inputParameters TK_SEM
outputParameters = TK_SQL idList TK_SQR TK_ASSIGNOP
outputParameters = epsilon
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 elseStmt
elseStmt = TK_ELSE stmt otherStmts TK_ENDIF
elseStmt = 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 innerTerm
innerTerm = plusMinus term innerTerm
innerTerm = epsilon
term = factor termPrime
termPrime = mulDiv factor termPrime
termPrime = epsilon
factor = TK_OP arithmeticExpression TK_CL
factor = all
mulDiv = TK_MUL
mulDiv = TK_DIV
plusMinus = TK_PLUS
plusMinus = TK_MINUS
all = TK_ID
all = TK_NUM
all = TK_RNUM
all = TK_RECORDID recAdjust
recAdjust = epsilon
recAdjust = 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 = epsilon
idList = TK_ID more_ids
more_ids = TK_COMMA idList
more_ids = epsilon