-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgr_hr.txt
57 lines (57 loc) · 2.68 KB
/
gr_hr.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
<program> -> <moduleDeclarations> <otherModules> <driverModule> <otherModules>
<moduleDeclarations> -> <moduleDeclaration> <moduleDeclarations> | ε
<moduleDeclaration> -> DECLARE MODULE ID SEMICOL
<otherModules> -> <module> <otherModules> | ε
<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 | ε
<input_plist> -> ID COLON <dataType> <N1>
<N1> -> COMMA ID COLON <dataType> <N1> | ε
<output_plist> -> ID COLON <type> <N2>
<N2> -> COMMA ID COLON <type> <N2> | ε
<dataType> -> INTEGER | REAL | BOOLEAN | ARRAY SQBO <range_arrays> SQBC OF <type>
<range_arrays> -> <index> RANGEOP <index>
<type> -> INTEGER | REAL | BOOLEAN
<moduleDef> -> START <statements> END
<statements> -> <statement> <statements> | ε
<statement> -> <ioStmt> | <simpleStmt> | <declareStmt> | <conditionalStmt> | <iterativeStmt>
<ioStmt> -> GET_VALUE BO ID BC SEMICOL | PRINT BO <var> BC SEMICOL
<boolConstt> -> TRUE | FALSE
<var_id_num> -> ID <whichId> | NUM | RNUM
<var> -> <var_id_num> | <boolConstt>
<whichId> -> SQBO <index> SQBC | ε
<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 | ε
<idList> -> ID <N3>
<N3> -> COMMA ID <N3> | ε
<expression> -> <arithmeticOrBooleanExpr> | <U>
<U> -> <unary_op> <new_NT>
<new_NT> -> BO <arithmeticExpr> BC | <var_id_num>
<unary_op> -> PLUS | MINUS
<arithmeticOrBooleanExpr> -> <AnyTerm> <N7>
<N7> -> <logicalOp> <AnyTerm> <N7> | ε
<AnyTerm> -> <arithmeticExpr> <N8> | <boolConstt>
<N8> -> <relationalOp> <arithmeticExpr> | ε
<arithmeticExpr> -> <term> <N4>
<N4> -> <op1> <term> <N4> | ε
<term> -> <factor> <N5>
<N5> -> <op2> <factor> <N5> | ε
<factor> -> BO <arithmeticOrBooleanExpr> BC | <var_id_num>
<op1> -> PLUS | MINUS
<op2> -> MUL | DIV
<logicalOp> -> AND | OR
<relationalOp> -> LT | LE | GT | GE | EQ | NE
<declareStmt> -> DECLARE <idList> COLON <dataType> SEMICOL
<conditionalStmt> -> SWITCH BO ID BC START <caseStmts> <default> END
<caseStmts> -> CASE <value> COLON <statements> BREAK SEMICOL <N9>
<N9> -> CASE <value> COLON <statements> BREAK SEMICOL <N9> | ε
<value> -> NUM | TRUE | FALSE
<default> -> DEFAULT COLON <statements> BREAK SEMICOL | ε
<iterativeStmt> -> FOR BO ID IN <range> BC START <statements> END | WHILE BO <arithmeticOrBooleanExpr> BC START <statements> END
<range> -> NUM RANGEOP NUM