-
Notifications
You must be signed in to change notification settings - Fork 2
/
newGrammar.txt
50 lines (50 loc) · 2.56 KB
/
newGrammar.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
<program> --> <moduleDeclarations> <otherModules> <driverModule> <otherModules> $
<moduleDeclarations> --> <moduleDeclaration> <moduleDeclarations> | eps $
<moduleDeclaration> --> DECLARE MODULE ID SEMICOL $
<otherModules> --> <module> <otherModules> | eps $
<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 | eps $
<input_plist> --> ID COLON <dataType> <N1> $
<N1> --> COMMA ID COLON <dataType> <N1> | eps $
<output_plist> --> ID COLON <type> <N2> $
<N2> --> COMMA ID COLON <type> <N2> | eps $
<dataType> --> INTEGER | REAL | BOOLEAN | ARRAY SQBO <range> SQBC OF <type> $
<type> --> INTEGER | REAL | BOOLEAN $
<moduleDef> --> START <statements> END $
<statements> --> <statement> <statements> | eps $
<statement> --> <ioStmt> | <simpleStmt> | <declareStmt> | <condionalStmt> | <iterativeStmt> $
<ioStmt> --> GET_VALUE BO ID BC SEMICOL | PRINT BO <var> BC SEMICOL $
<var> --> ID <whichId> | NUM | RNUM $
<whichId> --> SQBO ID SQBC | eps $
<simpleStmt> --> <assignmentStmt> | <moduleReuseStmt> $
<assignmentStmt> --> ID <whichStmt> $
<whichStmt> --> <lvalueIDStmt> | <lvalueARRStmt> $
<lvalueIDStmt> --> ASSIGNOP <expression> SEMICOL $
<lvalueARRStmt> --> SQBO <index> SQBC ASSIGNOP <expression> SEMICOL $
<index> --> NUM | ID $
<moduleReuseStmt> --> <optional> USE MODULE ID WITH PARAMETERS <idList> SEMICOL $
<optional> --> SQBO <idList> SQBC ASSIGNOP | eps $
<idList> --> ID <N3> $
<N3> --> COMMA ID <N3> | eps $
<expression> --> <level1> <temp1> $
<temp1> --> <logicalOp> <level1> <temp1> | eps $
<level1> --> <level2> <temp2> $
<temp2> --> <relationalOp> <level2> <temp2> | eps $
<level2> --> <level3> <temp3> $
<temp3> --> <op1> <level3> <temp3> | eps $
<level3> --> <level4> <temp4> $
<temp4> --> <op2> <level4> <temp4> | eps $
<level4> --> BO <expression> BC | MINUS BO <expression> BC | <var> | TRUE | FALSE $
<op1> --> PLUS | MINUS $
<op2> --> MUL | DIV $
<logicalOp> --> AND | OR $
<relationalOp> --> LT | LE | GT | GE | EQ | NE $
<declareStmt> --> DECLARE <idList> COLON <dataType> SEMICOL $
<condionalStmt> --> SWITCH BO ID BC START <caseStmts> <default> END $
<caseStmts> --> CASE <value> COLON <statements> BREAK SEMICOL <N9> $
<N9> --> CASE <value> COLON <statements> BREAK SEMICOL <N9> | eps $
<value> --> NUM | TRUE | FALSE $
<default> --> DEFAULT COLON <statements> BREAK SEMICOL | eps $
<iterativeStmt> --> FOR BO ID IN <range> BC START <statements> END | WHILE BO <expression> BC START <statements> END $
<range> --> NUM RANGEOP NUM $