1 | ; Source: http://www.fit.vutbr.cz/study/courses/APR/public/ebnf.html#string-character
|
---|
2 |
|
---|
3 | ; Programs and Blocks
|
---|
4 |
|
---|
5 | program
|
---|
6 | program-heading block "."
|
---|
7 | program-heading
|
---|
8 | program identifier "(" identifier-list ")" ";"
|
---|
9 | block
|
---|
10 | declaration-part statement-part
|
---|
11 | declaration-part
|
---|
12 | [ label-declaration-part ]
|
---|
13 | [ constant-definition-part ]
|
---|
14 | [ type-definition-part ]
|
---|
15 | [ variable-declaration-part ]
|
---|
16 | procedure-and-function-declaration-part
|
---|
17 | label-declaration-part
|
---|
18 | label label { "," label } ";"
|
---|
19 | constant-definition-part
|
---|
20 | const constant-definition ";" { constant-definition ";" }
|
---|
21 | constant-definition
|
---|
22 | identifier "=" constant
|
---|
23 | type-definition-part
|
---|
24 | type type-definition ";" { type-definition ";" }
|
---|
25 | type-definition
|
---|
26 | identifier "=" type
|
---|
27 | variable-declaration-part
|
---|
28 | var variable-declaration ";" { variable-declaration ";" }
|
---|
29 | variable-declaration
|
---|
30 | identifier-list ":" type
|
---|
31 | procedure-and-function-declaration-part
|
---|
32 | { (procedure-declaration | function-declaration) ";" }
|
---|
33 | procedure-declaration
|
---|
34 | procedure-heading ";" procedure-body |
|
---|
35 | procedure-heading ";" directive |
|
---|
36 | procedure-identification ";" procedure-body
|
---|
37 | procedure-body
|
---|
38 | block
|
---|
39 | function-declaration
|
---|
40 | function-heading ";" function-body |
|
---|
41 | function-heading ";" directive |
|
---|
42 | function-identification ";" function-body
|
---|
43 | function-body
|
---|
44 | block
|
---|
45 | directive
|
---|
46 | forward | compiler-defined-directives
|
---|
47 | statement-part
|
---|
48 | begin statement-sequence end
|
---|
49 |
|
---|
50 | ; Procedure and Function Definitions
|
---|
51 |
|
---|
52 | procedure-heading
|
---|
53 | procedure identifier [ formal-parameter-list ]
|
---|
54 | function-heading
|
---|
55 | function identifier [ formal-parameter-list ] ":" result-type
|
---|
56 | result-type
|
---|
57 | type-identifier
|
---|
58 | procedure-identification
|
---|
59 | procedure procedure-identifier
|
---|
60 | function-identification
|
---|
61 | function function-identifier
|
---|
62 | formal-parameter-list
|
---|
63 | "(" formal-parameter-section { ";" formal-parameter-section } ")"
|
---|
64 | formal-parameter-section
|
---|
65 | value-parameter-section |
|
---|
66 | variable-parameter-section |
|
---|
67 | procedure-parameter-section |
|
---|
68 | function-parameter-section
|
---|
69 | value-parameter-section
|
---|
70 | identifier-list ":" parameter-type
|
---|
71 | variable-parameter-section
|
---|
72 | var identifier-list ":" parameter-type
|
---|
73 | procedure-parameter-section
|
---|
74 | procedure-heading
|
---|
75 | function-parameter-section
|
---|
76 | function-heading
|
---|
77 | parameter-type
|
---|
78 | type-identifier | conformant-array-schema
|
---|
79 | conformant-array-schema
|
---|
80 | packed-conformant-array-schema |
|
---|
81 | unpacked-conformant-array-schema
|
---|
82 | packed-conformant-array-schema
|
---|
83 | packed array "[ " bound-specification " ]" of type-idnetifier
|
---|
84 | unpacked-conformant-array-schema
|
---|
85 | array "[ " bound-specification { ";" bound-specification } " ]"
|
---|
86 | of (type-identifier | conformant-array-schema)
|
---|
87 | bound-specification
|
---|
88 | identifier ".." identifier ":" ordinal-type-identifier
|
---|
89 | ordinal-type-identifier
|
---|
90 | type-identifier
|
---|
91 |
|
---|
92 | ; Statements
|
---|
93 |
|
---|
94 | statement-sequence
|
---|
95 | statement { ";" statement }
|
---|
96 | statement
|
---|
97 | [ label ":" ] (simple-statement | structured-statement)
|
---|
98 | simple-statement
|
---|
99 | [ assignment-statement | procedure-statement | goto-statement ]
|
---|
100 | assignment-statement
|
---|
101 | (variable | function-identifier) ":=" expression
|
---|
102 | procedure-statement
|
---|
103 | procedure-identifier [ actual-parameter-list ]
|
---|
104 | goto-statement
|
---|
105 | goto label
|
---|
106 | structured-statement
|
---|
107 | compound-statement | repetitive-statement | conditional-statement | with-statement
|
---|
108 | compound-statement
|
---|
109 | begin statement-sequence end
|
---|
110 | repetitive-statement
|
---|
111 | while-statement | repeat-statement | for-statement
|
---|
112 | while-statement
|
---|
113 | while expression do statement
|
---|
114 | repeat-statement
|
---|
115 | repeat statement-sequence until expression
|
---|
116 | for-statement
|
---|
117 | for variable-identifier ":=" initial-expression (to | downto) final-expression do statement
|
---|
118 | initial-expression
|
---|
119 | expression
|
---|
120 | final-expression
|
---|
121 | expression
|
---|
122 | conditional-statement
|
---|
123 | if-statement | case-statement
|
---|
124 | if-statement
|
---|
125 | if expression then statement [ else statement ]
|
---|
126 | case-statement
|
---|
127 | case expression of
|
---|
128 | case-limb { ";" case-limb } [ ";" ]
|
---|
129 | end
|
---|
130 | case-limb
|
---|
131 | case-label-list ":" statement
|
---|
132 | case-label-list
|
---|
133 | constant { "," constant }
|
---|
134 | with-statement
|
---|
135 | with record-variable { "," record-variable } do statement
|
---|
136 | actual-parameter-list
|
---|
137 | "(" actual-parameter { "," actual-parameter } ")"
|
---|
138 | actual-parameter
|
---|
139 | actual-value | actual-variable | actual-procedure | actual-function
|
---|
140 | actual-value
|
---|
141 | expression
|
---|
142 | actual-procedure
|
---|
143 | procedure-identifier
|
---|
144 | actual-function
|
---|
145 | function-identifier
|
---|
146 |
|
---|
147 | ; Expressions
|
---|
148 |
|
---|
149 | expression
|
---|
150 | simple-expression [ relational-operator simple-expression ]
|
---|
151 | simple-expression
|
---|
152 | [ sign ] term { addition-operator term }
|
---|
153 | term
|
---|
154 | factor { multiplication-operator factor }
|
---|
155 | factor
|
---|
156 | variable | number | string | set | nil | constant-identifier | bound-identifier | function-designator | "(" expression ")" | not factor
|
---|
157 | relational-operator
|
---|
158 | "=" | "<>" | "<" | "<=" | ">" | ">=" | "in"
|
---|
159 | addition-operator
|
---|
160 | "+" | "-" | or
|
---|
161 | multiplication-operator
|
---|
162 | "*" | "/" | div | mod | and
|
---|
163 | variable
|
---|
164 | entire-variable | component-variable | referenced-variable
|
---|
165 | entire-variable
|
---|
166 | variable-identifier | field-identifier
|
---|
167 | component-variable
|
---|
168 | indexed-variable | field-designator | file-buffer
|
---|
169 | indexed-variable
|
---|
170 | array-variable "[ " expression-list " ]"
|
---|
171 | field-designator
|
---|
172 | record-variable "." field-identifier
|
---|
173 | set
|
---|
174 | "[ " element-list " ]"
|
---|
175 | element-list
|
---|
176 | [ expression { "," expression } ]
|
---|
177 | function-designator
|
---|
178 | function-identifier [ actual-parameter-list ]
|
---|
179 | file-buffer
|
---|
180 | file-variable "^"
|
---|
181 |
|
---|
182 | ; Types
|
---|
183 |
|
---|
184 | type
|
---|
185 | simple-type | structured-type | pointer-type | type-identifier
|
---|
186 | simple-type
|
---|
187 | subrange-type | enumerated-type
|
---|
188 | enumerated-type
|
---|
189 | "(" identifier-list ")"
|
---|
190 | subrange-type
|
---|
191 | lower-bound ".." upper-bound
|
---|
192 | lower-bound
|
---|
193 | constant
|
---|
194 | upper-bound
|
---|
195 | constant
|
---|
196 | structured-type
|
---|
197 | [ packed ] unpacked-structured-type
|
---|
198 | unpacked-structured-type
|
---|
199 | array-type | record-type | set-type | file-type
|
---|
200 | array-type
|
---|
201 | array "[ " index-type { "," index-type } " ]" of element-type
|
---|
202 | index-type
|
---|
203 | simple-type
|
---|
204 | element-type
|
---|
205 | type
|
---|
206 | record-type
|
---|
207 | record field-list end
|
---|
208 | set-type
|
---|
209 | set of base-type
|
---|
210 | base-type
|
---|
211 | type
|
---|
212 | file-type
|
---|
213 | file of file-component-type
|
---|
214 | file-component-type
|
---|
215 | type
|
---|
216 | pointer-type
|
---|
217 | "^" type-identifier
|
---|
218 |
|
---|
219 | ; Record Fields
|
---|
220 |
|
---|
221 | field-list
|
---|
222 | [ (fixed-part [ ";" variant-part ] | variant-part) [ ";" ] ]
|
---|
223 | fixed-part
|
---|
224 | record-section { ";" record-section }
|
---|
225 | record-section
|
---|
226 | identifier-list ":" type
|
---|
227 | variant-part
|
---|
228 | case tag-field type-identifier of variant { ";" variant }
|
---|
229 | tag-field
|
---|
230 | [ identifier ":" ]
|
---|
231 | variant
|
---|
232 | case-label-list ":" "(" field-list ")"
|
---|
233 |
|
---|
234 | ; Input/Output
|
---|
235 |
|
---|
236 | output-list
|
---|
237 | output-value { "," output-value }
|
---|
238 | output-value
|
---|
239 | expression [ ";" field-width [ ":" fraction-length ] ]
|
---|
240 | field-width
|
---|
241 | expression
|
---|
242 | fraction-length
|
---|
243 | expression
|
---|
244 |
|
---|
245 | ; Variable and Identifier Categories
|
---|
246 |
|
---|
247 | identifier
|
---|
248 | letter { letter | digit }
|
---|
249 | file-variable
|
---|
250 | variable
|
---|
251 | referenced-variable
|
---|
252 | pointer-variable "^"
|
---|
253 | record-variable
|
---|
254 | variable
|
---|
255 | pointer-variable
|
---|
256 | variable
|
---|
257 | actual-variable
|
---|
258 | variable
|
---|
259 | array-variable
|
---|
260 | variable
|
---|
261 | field-identifier
|
---|
262 | identifier
|
---|
263 | constant-identifier
|
---|
264 | identifier
|
---|
265 | variable-identifier
|
---|
266 | identifier
|
---|
267 | type-identifier
|
---|
268 | identifier
|
---|
269 | procedure-identifier
|
---|
270 | identifier
|
---|
271 | function-identifier
|
---|
272 | identifier
|
---|
273 | bound-identifier
|
---|
274 | identifier
|
---|
275 |
|
---|
276 | ; Low Level Definitions
|
---|
277 |
|
---|
278 | variable-list
|
---|
279 | variable { "," variable }
|
---|
280 | identifier-list
|
---|
281 | identifier { "," identifier }
|
---|
282 | expression-list
|
---|
283 | expression { "," expression }
|
---|
284 | number
|
---|
285 | integer-number | real-number
|
---|
286 | integer-number
|
---|
287 | digit-sequence
|
---|
288 | real-number
|
---|
289 | digit-sequence "." [ digit-sequence ] [ scale-factor ] |
|
---|
290 | digit-sequence scale-factor
|
---|
291 | scale-factor
|
---|
292 | ("E" | "e") [ sign ] digit-sequence
|
---|
293 | unsigned-digit-sequence
|
---|
294 | digit { digit }
|
---|
295 | digit-sequence
|
---|
296 | [ sign ] unsigned-digit-sequence
|
---|
297 | sign
|
---|
298 | "+" | "-"
|
---|
299 | letter
|
---|
300 | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
|
---|
301 | digit
|
---|
302 | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
|
---|
303 | string
|
---|
304 | "'" string-character { string-character } "'"
|
---|
305 | string-character
|
---|
306 | any-character-except-quote | "''"
|
---|
307 | label
|
---|
308 | integer-number
|
---|
309 | constant
|
---|
310 | [ sign ] (constant-identifier | number) | string
|
---|