-
Notifications
You must be signed in to change notification settings - Fork 4
/
grammar.txt
93 lines (91 loc) · 3.38 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
90
91
92
93
<program> : <moduleDeclarations> <otherModules> <driverModule> <otherModules>
<moduleDeclarations> : <moduleDeclaration> <moduleDeclarations>
<moduleDeclarations> : EMPTY
<moduleDeclaration> : DECLARE MODULE ID SEMICOL
<otherModules> : <module> <otherModules>
<otherModules> : EMPTY
<driverModule> : DRIVERDEF DRIVER PROGRAM DRIVERENDDEF <moduleDef>
<module> : DEF MODULE ID ENDDEF TAKES INPUT SQBO <input_plist> SQBC SEMICOL <ret> <moduleDef>
<ret> : RETURNS SQBO <output_plist> SQBC SEMICOL
<ret> : EMPTY
<input_plist> : ID COLON <dataType> <input_plistRec>
<input_plistRec> : COMMA ID COLON <dataType> <input_plistRec>
<input_plistRec> : EMPTY
<output_plist> : ID COLON <type> <output_plistRec>
<output_plistRec> : COMMA ID COLON <type> <output_plistRec>
<output_plistRec> : EMPTY
<type> : INTEGER
<type> : REAL
<type> : BOOLEAN
<dataType> : <type>
<dataType> : ARRAY SQBO <range> SQBC OF <type>
<moduleDef> : START <statements> END
<statements> : <statement> <statements>
<statements> : EMPTY
<statement> : <ioStmt>
<statement> : <simpleStmt>
<statement> : <declareStmt>
<statement> : <condionalStmt>
<statement> : <iterativeStmt>
<statement> : SEMICOL
<ioStmt> : GET_VALUE BO ID <whichId> BC SEMICOL
<ioStmt> : PRINT BO <var> BC SEMICOL
<whichId> : SQBO <index> SQBC
<whichId> : EMPTY
<index> : NUM
<index> : ID
<simpleStmt> : <assignmentStmt>
<simpleStmt> : <moduleReuseStmt>
<assignmentStmt> : ID <whichId> ASSIGNOP <expression> SEMICOL
<moduleReuseStmt> : <optional> USE MODULE ID WITH PARAMETERS <idList> SEMICOL
<optional> : SQBO <idList> SQBC ASSIGNOP
<optional> : EMPTY
<idList> : ID <idListRec>
<idListRec> : COMMA ID <idListRec>
<idListRec> : EMPTY
<expression> : <arithOrBoolExpr>
<expression> : MINUS BO <arithmeticExpr> BC
<arithOrBoolExpr> : <anyTerm> <arithOrBoolExprRec>
<arithOrBoolExprRec> : <logicalOp> <anyTerm> <arithOrBoolExprRec>
<arithOrBoolExprRec> : EMPTY
<anyTerm> : <arithmeticExpr> <anyTermRec>
<anyTermRec> : <relationalOp> <arithmeticExpr> <anyTermRec>
<anyTermRec> : EMPTY
<arithmeticExpr> : <term> <arithmeticExprRec>
<arithmeticExprRec> : <pm> <term> <arithmeticExprRec>
<arithmeticExprRec> : EMPTY
<term> : <factor> <termRec>
<termRec> : <md> <factor> <termRec>
<termRec> : EMPTY
<factor> : BO <arithOrBoolExpr> BC
<factor> : <var>
<var> : ID <whichId>
<var> : NUM
<var> : RNUM
<var> : TRUE
<var> : FALSE
<pm> : PLUS
<pm> : MINUS
<md> : MUL
<md> : DIV
<logicalOp> : AND
<logicalOp> : OR
<relationalOp> : LT
<relationalOp> : LE
<relationalOp> : GT
<relationalOp> : GE
<relationalOp> : EQ
<relationalOp> : NE
<declareStmt> : DECLARE <idList> COLON <dataType> SEMICOL
<condionalStmt> : SWITCH BO ID BC START <caseStmts> <default> END
<caseStmts> : CASE <value> COLON <statements> BREAK SEMICOL <caseStmtsRec>
<caseStmtsRec> : CASE <value> COLON <statements> BREAK SEMICOL <caseStmtsRec>
<caseStmtsRec> : EMPTY
<value> : NUM
<value> : TRUE
<value> : FALSE
<default> : DEFAULT COLON <statements> BREAK SEMICOL
<default> : EMPTY
<iterativeStmt> : FOR BO ID IN <range> BC START <statements> END
<iterativeStmt> : WHILE BO <arithOrBoolExpr> BC START <statements> END
<range> : NUM RANGEOP NUM