-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.txt
60 lines (60 loc) · 2.32 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
<program> := program ( ) { <statement-list> }
<statement-list> := <statement> <statement-list>
<statement-list> := <statement>
<statement> := <declaration> ;
<statement> := <assignment> ;
<statement> := <row>
<declaration> := declare list of variables <identifier-list> : <type>
<declaration> := declare <identifier> : <type>
<identifier-list> := <identifier>
<identifier-list> := <identifier> <identifier-list>
<type> := <primitive_type>
<type> := <array>
<primitive_type> := integer
<primitive_type> := real
<primitive_type> := boolean
<array> := <rectangular_array>
<array> := <jagged_array>
<rectangular_array> := array <enumeration-list> of integer
<enumeration-list> := <enumeration>
<enumeration-list> := <enumeration> <enumeration-list>
<enumeration> := <static_enumeration>
<enumeration> := <dynamic_enumeration>
<static_enumeration> := [ <constant> .. <constant> ]
<dynamic_enumeration> := [ <identifier> .. <identifier> ]
<dynamic_enumeration> := [ <constant> .. <identifier> ]
<dynamic_enumeration> := [ <identifier> .. <constant> ]
<jagged_array> := jagged array <static_enumeration> <brackets> of integer
<brackets> := [ ]
<brackets> := [ ] [ ]
<row> := R1 [ <constant> ] : size <constant> : values { <constant-list> }
<constants> := <constant>
<constant-list> := <constants>
<constant-list> := <constants> ; <constant-list>
<constants> := <constant> <constants>
<assignment> := <assignee> = <expression>
<assignee> := <identifier>
<assignee> := <identifier> [ <dimensions> ]
<expression> := <boolean_expression>
<expression> := <arithmetic_expression>
<term> := <boolean_term>
<term> := <arithmetic_term>
<boolean_term> := <identifier>
<boolean_expression> := <boolean_term>
<boolean_expression> := <boolean_term> ||| <boolean_expression>
<boolean_term> := <identifier> &&& <boolean_term>
<arithmetic_expression> := <arithmetic_term>
<arithmetic_expression> := <arithmetic_term> <addsub> <arithmetic_expression>
<addsub> := +
<addsub> := -
<arithmetic_term> := <constant>
<arithmetic_term> := <identifier>
<arithmetic_term> := <array_term>
<array_term> := <identifier> [ <dimensions> ]
<dimensions> := <constant>
<dimensions> := <constant> <dimensions>
<arithmetic_term> := <constant> <muldiv> <arithmetic_term>
<arithmetic_term> := <identifier> <muldiv> <arithmetic_term>
<arithmetic_term> := <array_term> <muldiv> <arithmetic_term>
<muldiv> := *
<muldiv> := /