-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrammar_rules.txt
executable file
·86 lines (86 loc) · 3.77 KB
/
grammar_rules.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
[ stmtsAndFunctionDefs ] ===) [ stmtOrFunctionDef ] [ stmtsAndFunctionDefs_type1 ]
[ mainFunction ] ===) MAIN SQO SQC [ stmtsAndFunctionDefs ] END SEMICOLON
[ stmtOrFunctionDef ] ===) [ stmt ]
[ stmtOrFunctionDef ] ===) [ functionDef ]
[ stmtsAndFunctionDefs_type1 ] ===) [ stmtsAndFunctionDefs ]
[ stmtsAndFunctionDefs_type1 ] ===) ?
[ stmt ] ===) [ declarationStmt ]
[ stmt ] ===) [ assignmentStmt_type1 ]
[ stmt ] ===) [ assignmentStmt_type2 ]
[ stmt ] ===) [ ifStmt ]
[ stmt ] ===) [ ioStmt ]
[ stmt ] ===) [ funCallStmt ] SEMICOLON
[ functionDef ] ===) FUNCTION SQO [ parameter_list ] SQC ASSIGNOP FUNID SQO [ parameter_list ] SQC [ stmtsAndFunctionDefs ] END SEMICOLON
[ parameter_list ] ===) [ type ] ID [ remainingList ]
[ type ] ===) INT
[ type ] ===) REAL
[ type ] ===) STRING
[ type ] ===) MATRIX
[ remainingList ] ===) COMMA [ parameter_list ]
[ remainingList ] ===) ?
[ declarationStmt ] ===) [ type ] [ var_list ] SEMICOLON
[ assignmentStmt_type1 ] ===) [ leftHandSide_singleVar ] ASSIGNOP [ rightHandSide_type1 ] SEMICOLON
[ assignmentStmt_type2 ] ===) [ leftHandSide_listVar ] ASSIGNOP [ rightHandSide_type2 ] SEMICOLON
[ leftHandSide_singleVar ] ===) ID
[ leftHandSide_listVar ] ===) SQO [ var_list ] SQC
[ rightHandSide_type1 ] ===) [ arithmeticExpression ]
[ rightHandSide_type1 ] ===) [ sizeExpression ]
[ rightHandSide_type1 ] ===) [ funCallStmt ]
[ rightHandSide_type2 ] ===) [ sizeExpression ]
[ rightHandSide_type2 ] ===) [ funCallStmt ]
[ var_list ] ===) ID [ more_ids ]
[ more_ids ] ===) COMMA [ var_list ]
[ more_ids ] ===) ?
[ sizeExpression ] ===) SIZE ID
[ ifStmt ] ===) IF OP [ booleanExpression ] CL [ stmt ] [ otherStmts ] [ elsePart ]
[ elsePart ] ===) ELSE [ stmt ] [ otherStmts ] ENDIF SEMICOLON
[ elsePart ] ===) ENDIF SEMICOLON
[ otherStmts ] ===) [ stmt ] [ otherStmts ]
[ otherStmts ] ===) ?
[ ioStmt ] ===) READ OP ID CL SEMICOLON
[ ioStmt ] ===) PRINT OP ID CL SEMICOLON
[ funCallStmt ] ===) FUNID OP [ inputParameterList ] CL
[ inputParameterList ] ===) [ var ] [ listVar ]
[ inputParameterList ] ===) ?
[ listVar ] ===) COMMA [ inputParameterList ]
[ listVar ] ===) ?
[ factor ] ===) OP [ arithmeticExpression ] CL
[ factor ] ===) [ var ]
[ arithmeticExpression ] ===) [ arithmeticTerm ] [ arithmeticExpression_type2 ]
[ arithmeticExpression_type2 ] ===) [ operator_lowPrecedence ] [ arithmeticExpression ]
[ arithmeticExpression_type2 ] ===) ?
[ arithmeticTerm ] ===) [ factor ] [ arithmeticTerm_type2 ]
[ arithmeticTerm_type2 ] ===) [ operator_highPrecedence ] [ arithmeticTerm ]
[ arithmeticTerm_type2 ] ===) ?
[ operator_lowPrecedence ] ===) PLUS
[ operator_lowPrecedence ] ===) MINUS
[ operator_highPrecedence ] ===) MUL
[ operator_highPrecedence ] ===) DIV
[ booleanExpression ] ===) OP [ booleanExpression ] CL [ logicalOp ] OP [ booleanExpression ] CL
[ booleanExpression ] ===) NOT OP [ booleanExpression ] CL
[ booleanExpression ] ===) [ constrainedVars ] [ relationalOp ] [ constrainedVars ]
[ constrainedVars ] ===) ID
[ constrainedVars ] ===) NUM
[ constrainedVars ] ===) RNUM
[ var ] ===) ID [ matrixElement ]
[ var ] ===) NUM
[ var ] ===) RNUM
[ var ] ===) STR
[ var ] ===) [ matrix ]
[ matrix ] ===) SQO [ rows ] SQC
[ rows ] ===) [ row ] [ rowsRemaining ]
[ rowsRemaining ] ===) SEMICOLON [ rows ]
[ rowsRemaining ] ===) ?
[ row ] ===) NUM [ remainingColElements ]
[ remainingColElements ] ===) COMMA NUM [ remainingColElements ]
[ remainingColElements ] ===) ?
[ matrixElement ] ===) SQO NUM COMMA NUM SQC
[ matrixElement ] ===) ?
[ logicalOp ] ===) AND
[ logicalOp ] ===) OR
[ relationalOp ] ===) LT
[ relationalOp ] ===) LE
[ relationalOp ] ===) EQ
[ relationalOp ] ===) GT
[ relationalOp ] ===) GE
[ relationalOp ] ===) NE