source: branches/generator/Grammers/Pascal1.ebnf

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