-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrammar.txt
executable file
·84 lines (62 loc) · 2.89 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
Program := Single-Command
Command := Single-Command
| Command ; Single-Command
Single-Command := empty
| V-Name := Expression
| Identifier ( Actual-Param-Sequence )
| IF Expression THEN Single-Command ELSE Single-Command
| WHILE Expression DO Single-Command
| LET Declaration IN Single-Command
| BEGIN Command END
Expression := Secondary-Expression
| LET Declaration IN Expression
| IF Expression THEN Expression ELSE Expression
Secondary-Expression := Primary-Expression
| Secondary-Expression Operator Primary-Expression
Primary-Expression := Integer-Literal
| Character-Literal
| V-Name
| Identifier ( Actual-Param-Sequence )
| Operator Primary-Expression
| ( Expression )
| { Record-Aggregate }
| [ Array-Aggregate ]
Record-Aggregate := Identifier ~ Expression
| Identifier ~ Expression , Record-Aggregate
Array-Aggregate := Expression
| Expression , Array-Aggregate
V-Name := Identifier
| V-Name . Identifier
| V-Name [ Expression ]
Declaration := Single-Declaration
| Declaration ; Single-Declaration
Single-Declaration := CONST Identifier ~ Expression
| VAR Identifier : Type-Denoter
| PROC Identifier ( Formal-Param-Sequence ) ~ Single-Command
| FUNC Identifier ( Formal-Param-Sequence ) : Type-Denoter ~ Expression
| TYPE Identifier ~ Type-Denoter
Formal-Param-Sequence := empty
| Proper-Formal-Param-Sequence
Proper-Formal-Param-Sequence := Formal-Param
| Formal-Param , Proper-Formal-Param-Sequence
Formal-Param := Identifier : Type-Denoter
| VAR Identifier : Type-Denoter
| PROC Identifier ( Formal-Param-Sequence )
| FUNC Identifier ( Formal-Param-Sequence ) : Type-Denoter
Actual-Param-Sequence := empty
| Proper-Actual-Param-Sequence
Proper-Actual-Param-Sequence := Actual-Param
| Actual-Param , Proper-Actual-Param-Sequence
Actual-Param := Expression
| VAR V-Name
| PROC Identifier
| FUNC Identifier
Type-Denoter := Identifier
| ARRAY Integer-Literal OF Type-Denoter
| RECORD Record-Type-Denoter END
Record-Type-Denoter := Identifier : Type-Denoter
| Identifier : Type-Denoter , Record-Type-Denoter
Operator := + | - | * | / | < | > | = | \
Identifier := Letter | Identifier Letter | Identifier Digit
Integer-Literal := Digit | Integer-Literal Digit
Comment := ! Graphic* EOL