forked from f20180301/PPL_Assignment_2020
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgrammar.txt
64 lines (64 loc) · 2.61 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
<s> => PROGRAM BROP BRCL CURLYOP <start> CURLYCL
<start> => <declaration> <assignment>
<declaration> => <declaration_stmt> <declaration>
<declaration> => <declaration_stmt>
<declaration_stmt> => <primitive>
<declaration_stmt> => <array>
<declaration_stmt> => <jagged_array>
<assignment> => <assignment_stmt> <assignment>
<assignment> => <assignment_stmt>
<assignment_stmt> => <arr_pid> EQUALS <expression> SEMICOLON
<primitive> => <single_primitive>
<primitive> => <multi_primitive>
<single_primitive> => DECLARE ID COLON <type> SEMICOLON
<multi_primitive> => DECLARE LIST OF VARIABLES <var_list> COLON <type> SEMICOLON
<array> => <single_array>
<array> => <multi_array>
<single_array> => DECLARE ID COLON ARRAY <array_dim> OF INTEGER SEMICOLON
<multi_array> => DECLARE LIST OF VARIABLES <var_list> COLON ARRAY <array_dim> OF INTEGER SEMICOLON
<array_dim> => SQOP <num_id> DD <num_id> SQCL <array_dim>
<array_dim> => SQOP <num_id> DD <num_id> SQCL
<jagged_array> => <jagged_2d_array>
<jagged_array> => <jagged_3d_array>
<jagged_2d_array> => <single_jagged_2d_array>
<jagged_2d_array> => <multi_jagged_2d_array>
<single_jagged_2d_array> => DECLARE ID COLON JAGGED ARRAY <jagged_2d_dim> OF INTEGER SEMICOLON <jag_lines>
<multi_jagged_2d_array> => DECLARE LIST OF VARIABLES <var_list> COLON JAGGED ARRAY <jagged_2d_dim> OF INTEGER SEMICOLON <jag_lines>
<jagged_3d_array> => <single_jagged_3d_array>
<jagged_3d_array> => <multi_jagged_3d_array>
<single_jagged_3d_array> => DECLARE ID COLON JAGGED ARRAY <jagged_3d_dim> OF INTEGER SEMICOLON <jag_lines>
<multi_jagged_3d_array> => DECLARE LIST OF VARIABLES <var_list> COLON JAGGED ARRAY <jagged_3d_dim> OF INTEGER SEMICOLON <jag_lines>
<jagged_2d_dim> => SQOP NUM DD NUM SQCL SQOP SQCL
<jagged_3d_dim> => SQOP NUM DD NUM SQCL SQOP SQCL SQOP SQCL
<jag_lines> => <jag_line> <jag_lines>
<jag_lines> => <jag_line>
<jag_line> => R1 SQOP NUM SQCL COLON SIZE NUM COLON VALUES CURLYOP <jag_list> CURLYCL
<jag_list> => <num_list> SEMICOLON <jag_list>
<jag_list> => <num_list>
<num_list> => NUM <num_list>
<num_list> => EPSILON
<num_id> => NUM
<num_id> => ID
<var_list> => ID <var_list>
<var_list> => ID
<arr_pid> => ID SQOP <idx> SQCL
<arr_pid> => ID
<idx> => <num_id> <idx>
<idx> => EPSILON
<type> => INTEGER
<type> => REAL
<type> => BOOLEAN
<expression> => <arithmetic_expression>
<arithmetic_expression> => <term> <op1> <arithmetic_expression>
<arithmetic_expression> => <term>
<term> => <factor> <op2> <term>
<term> => <factor>
<factor> => BROP <expression> BRCL
<factor> => NUM
<factor> => <arr_pid>
<op1> => PLUS
<op1> => MINUS
<op1> => AND
<op1> => OR
<op2> => DIVIDE
<op2> => MUL