Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | |
2 | name ::= lc_letter (lc_letter | "_")* | |
3 | ||
4 | lc_letter ::= "a"..."z" | |
5 | ||
6 | identifier ::= | |
7 | (letter|"_") (letter | digit | "_")* | |
8 | ||
9 | letter ::= | |
10 | lowercase | uppercase | |
11 | ||
12 | lowercase ::= | |
13 | "a"..."z" | |
14 | ||
15 | uppercase ::= | |
16 | "A"..."Z" | |
17 | ||
18 | digit ::= | |
19 | "0"..."9" | |
20 | ||
21 | stringliteral ::= | |
22 | [stringprefix](shortstring | longstring) | |
23 | ||
24 | stringprefix ::= | |
25 | "r" | "u" | "ur" | "R" | "U" | "UR" | "Ur" | "uR" | |
26 | ||
27 | shortstring ::= | |
28 | "'" shortstringitem* "'" | |
29 | | '"' shortstringitem* '"' | |
30 | ||
31 | longstring ::= | |
32 | "'''" longstringitem* "'''" | |
33 | | '"""' longstringitem* '"""' | |
34 | ||
35 | shortstringitem ::= | |
36 | shortstringchar | escapeseq | |
37 | ||
38 | longstringitem ::= | |
39 | longstringchar | escapeseq | |
40 | ||
41 | shortstringchar ::= | |
42 | <any source character except "\" or newline or the quote> | |
43 | ||
44 | longstringchar ::= | |
45 | <any source character except "\"> | |
46 | ||
47 | escapeseq ::= | |
48 | "\" <any ASCII character> | |
49 | ||
50 | longinteger ::= | |
51 | integer ("l" | "L") | |
52 | ||
53 | integer ::= | |
54 | decimalinteger | octinteger | hexinteger | |
55 | ||
56 | decimalinteger ::= | |
57 | nonzerodigit digit* | "0" | |
58 | ||
59 | octinteger ::= | |
60 | "0" octdigit+ | |
61 | ||
62 | hexinteger ::= | |
63 | "0" ("x" | "X") hexdigit+ | |
64 | ||
65 | nonzerodigit ::= | |
66 | "1"..."9" | |
67 | ||
68 | octdigit ::= | |
69 | "0"..."7" | |
70 | ||
71 | hexdigit ::= | |
72 | digit | "a"..."f" | "A"..."F" | |
73 | ||
74 | floatnumber ::= | |
75 | pointfloat | exponentfloat | |
76 | ||
77 | pointfloat ::= | |
78 | [intpart] fraction | intpart "." | |
79 | ||
80 | exponentfloat ::= | |
81 | (intpart | pointfloat) | |
82 | exponent | |
83 | ||
84 | intpart ::= | |
85 | digit+ | |
86 | ||
87 | fraction ::= | |
88 | "." digit+ | |
89 | ||
90 | exponent ::= | |
91 | ("e" | "E") ["+" | "-"] digit+ | |
92 | ||
93 | imagnumber ::= (floatnumber | intpart) ("j" | "J") | |
94 | ||
95 | atom ::= | |
96 | identifier | literal | enclosure | |
97 | ||
98 | enclosure ::= | |
99 | parenth_form | list_display | |
100 | | generator_expression | dict_display | |
101 | | string_conversion | |
102 | ||
103 | literal ::= | |
104 | stringliteral | integer | longinteger | |
105 | | floatnumber | imagnumber | |
106 | ||
107 | parenth_form ::= | |
108 | "(" [expression_list] ")" | |
109 | ||
110 | test ::= | |
111 | and_test ( "or" and_test )* | |
112 | | lambda_form | |
113 | ||
114 | testlist ::= | |
115 | test ( "," test )* [ "," ] | |
116 | ||
117 | list_display ::= | |
118 | "[" [listmaker] "]" | |
119 | ||
120 | listmaker ::= | |
121 | expression ( list_for | |
122 | | ( "," expression )* [","] ) | |
123 | ||
124 | list_iter ::= | |
125 | list_for | list_if | |
126 | ||
127 | list_for ::= | |
128 | "for" expression_list "in" testlist | |
129 | [list_iter] | |
130 | ||
131 | list_if ::= | |
132 | "if" test [list_iter] | |
133 | ||
134 | generator_expression ::= | |
135 | "(" test genexpr_for ")" | |
136 | ||
137 | genexpr_for ::= | |
138 | "for" expression_list "in" test | |
139 | [genexpr_iter] | |
140 | ||
141 | genexpr_iter ::= | |
142 | genexpr_for | genexpr_if | |
143 | ||
144 | genexpr_if ::= | |
145 | "if" test [genexpr_iter] | |
146 | ||
147 | dict_display ::= | |
148 | "\{" [key_datum_list] "\}" | |
149 | ||
150 | key_datum_list ::= | |
151 | key_datum ("," key_datum)* [","] | |
152 | ||
153 | key_datum ::= | |
154 | expression ":" expression | |
155 | ||
156 | string_conversion ::= | |
157 | "`" expression_list "`" | |
158 | ||
159 | primary ::= | |
160 | atom | attributeref | |
161 | | subscription | slicing | call | |
162 | ||
163 | attributeref ::= | |
164 | primary "." identifier | |
165 | ||
166 | subscription ::= | |
167 | primary "[" expression_list "]" | |
168 | ||
169 | slicing ::= | |
170 | simple_slicing | extended_slicing | |
171 | ||
172 | simple_slicing ::= | |
173 | primary "[" short_slice "]" | |
174 | ||
175 | extended_slicing ::= | |
176 | primary "[" slice_list "]" | |
177 | ||
178 | slice_list ::= | |
179 | slice_item ("," slice_item)* [","] | |
180 | ||
181 | slice_item ::= | |
182 | expression | proper_slice | ellipsis | |
183 | ||
184 | proper_slice ::= | |
185 | short_slice | long_slice | |
186 | ||
187 | short_slice ::= | |
188 | [lower_bound] ":" [upper_bound] | |
189 | ||
190 | long_slice ::= | |
191 | short_slice ":" [stride] | |
192 | ||
193 | lower_bound ::= | |
194 | expression | |
195 | ||
196 | upper_bound ::= | |
197 | expression | |
198 | ||
199 | stride ::= | |
200 | expression | |
201 | ||
202 | ellipsis ::= | |
203 | "..." | |
204 | ||
205 | call ::= | |
206 | primary "(" [argument_list [","]] ")" | |
207 | primary "(" [argument_list [","] | | |
208 | test genexpr_for ] ")" | |
209 | ||
210 | argument_list ::= | |
211 | positional_arguments ["," keyword_arguments] | |
212 | ["," "*" expression] | |
213 | ["," "**" expression] | |
214 | | keyword_arguments ["," "*" expression] | |
215 | ["," "**" expression] | |
216 | | "*" expression ["," "**" expression] | |
217 | | "**" expression | |
218 | ||
219 | positional_arguments ::= | |
220 | expression ("," expression)* | |
221 | ||
222 | keyword_arguments ::= | |
223 | keyword_item ("," keyword_item)* | |
224 | ||
225 | keyword_item ::= | |
226 | identifier "=" expression | |
227 | ||
228 | power ::= | |
229 | primary ["**" u_expr] | |
230 | ||
231 | u_expr ::= | |
232 | power | "-" u_expr | |
233 | | "+" u_expr | "\~" u_expr | |
234 | ||
235 | m_expr ::= | |
236 | u_expr | m_expr "*" u_expr | |
237 | | m_expr "//" u_expr | |
238 | | m_expr "/" u_expr | |
239 | | m_expr "\%" u_expr | |
240 | ||
241 | a_expr ::= | |
242 | m_expr | a_expr "+" m_expr | |
243 | | a_expr "-" m_expr | |
244 | <tex2html_comment_mark>39 | |
245 | ||
246 | shift_expr ::= | |
247 | a_expr | |
248 | | shift_expr ( "<<" | ">>" ) a_expr | |
249 | ||
250 | and_expr ::= | |
251 | shift_expr | and_expr "\;SPMamp;" shift_expr | |
252 | ||
253 | xor_expr ::= | |
254 | and_expr | xor_expr "\textasciicircum" and_expr | |
255 | ||
256 | or_expr ::= | |
257 | xor_expr | or_expr "|" xor_expr | |
258 | ||
259 | comparison ::= | |
260 | or_expr ( comp_operator or_expr )* | |
261 | ||
262 | comp_operator ::= | |
263 | "<" | ">" | "==" | ">=" | "<=" | "<>" | "!=" | |
264 | | "is" ["not"] | ["not"] "in" | |
265 | ||
266 | expression ::= | |
267 | or_test | lambda_form | |
268 | ||
269 | or_test ::= | |
270 | and_test | or_test "or" and_test | |
271 | ||
272 | and_test ::= | |
273 | not_test | and_test "and" not_test | |
274 | ||
275 | not_test ::= | |
276 | comparison | "not" not_test | |
277 | ||
278 | lambda_form ::= | |
279 | "lambda" [parameter_list]: expression | |
280 | ||
281 | expression_list ::= | |
282 | expression ( "," expression )* [","] | |
283 | ||
284 | simple_stmt ::= expression_stmt | |
285 | | assert_stmt | |
286 | | assignment_stmt | |
287 | | augmented_assignment_stmt | |
288 | | pass_stmt | |
289 | | del_stmt | |
290 | | print_stmt | |
291 | | return_stmt | |
292 | | yield_stmt | |
293 | | raise_stmt | |
294 | | break_stmt | |
295 | | continue_stmt | |
296 | | import_stmt | |
297 | | global_stmt | |
298 | | exec_stmt | |
299 | ||
300 | expression_stmt ::= | |
301 | expression_list | |
302 | ||
303 | assert_stmt ::= | |
304 | "assert" expression ["," expression] | |
305 | ||
306 | assignment_stmt ::= | |
307 | (target_list "=")+ expression_list | |
308 | ||
309 | target_list ::= | |
310 | target ("," target)* [","] | |
311 | ||
312 | target ::= | |
313 | identifier | |
314 | | "(" target_list ")" | |
315 | | "[" target_list "]" | |
316 | | attributeref | |
317 | | subscription | |
318 | | slicing | |
319 | ||
320 | augmented_assignment_stmt ::= | |
321 | target augop expression_list | |
322 | ||
323 | augop ::= | |
324 | "+=" | "-=" | "*=" | "/=" | "\%=" | "**=" | |
325 | <tex2html_comment_mark>45 | |
326 | | ">>=" | "<<=" | "\&=" | "\textasciicircum=" | "|=" | |
327 | ||
328 | pass_stmt ::= | |
329 | "pass" | |
330 | ||
331 | del_stmt ::= | |
332 | "del" target_list | |
333 | ||
334 | print_stmt ::= | |
335 | "print" ( \optionalexpression ("," expression)* \optional"," | |
336 | | ">\code>" expression | |
337 | \optional("," expression)+ \optional"," ) | |
338 | ||
339 | return_stmt ::= | |
340 | "return" [expression_list] | |
341 | ||
342 | yield_stmt ::= | |
343 | "yield" expression_list | |
344 | ||
345 | raise_stmt ::= | |
346 | "raise" [expression ["," expression | |
347 | ["," expression]]] | |
348 | ||
349 | break_stmt ::= | |
350 | "break" | |
351 | ||
352 | continue_stmt ::= | |
353 | "continue" | |
354 | ||
355 | import_stmt ::= | |
356 | "import" module ["as" name] | |
357 | ( "," module ["as" name] )* | |
358 | | "from" module "import" identifier | |
359 | ["as" name] | |
360 | ( "," identifier ["as" name] )* | |
361 | | "from" module "import" "(" identifier | |
362 | ["as" name] | |
363 | ( "," identifier ["as" name] )* [","] ")" | |
364 | | "from" module "import" "*" | |
365 | ||
366 | module ::= | |
367 | (identifier ".")* identifier | |
368 | ||
369 | global_stmt ::= | |
370 | "global" identifier ("," identifier)* | |
371 | ||
372 | exec_stmt ::= | |
373 | "exec" expression | |
374 | ["in" expression ["," expression]] | |
375 | ||
376 | compound_stmt ::= | |
377 | if_stmt | |
378 | | while_stmt | |
379 | | for_stmt | |
380 | | try_stmt | |
381 | | funcdef | |
382 | | classdef | |
383 | ||
384 | suite ::= | |
385 | stmt_list NEWLINE | |
386 | | NEWLINE INDENT statement+ DEDENT | |
387 | ||
388 | statement ::= | |
389 | stmt_list NEWLINE | compound_stmt | |
390 | ||
391 | stmt_list ::= | |
392 | simple_stmt (";" simple_stmt)* [";"] | |
393 | ||
394 | if_stmt ::= | |
395 | "if" expression ":" suite | |
396 | ( "elif" expression ":" suite )* | |
397 | ["else" ":" suite] | |
398 | ||
399 | while_stmt ::= | |
400 | "while" expression ":" suite | |
401 | ["else" ":" suite] | |
402 | ||
403 | for_stmt ::= | |
404 | "for" target_list "in" expression_list | |
405 | ":" suite | |
406 | ["else" ":" suite] | |
407 | ||
408 | try_stmt ::= | |
409 | try_exc_stmt | try_fin_stmt | |
410 | ||
411 | try_exc_stmt ::= | |
412 | "try" ":" suite | |
413 | ("except" [expression | |
414 | ["," target]] ":" suite)+ | |
415 | ["else" ":" suite] | |
416 | ||
417 | try_fin_stmt ::= | |
418 | "try" ":" suite | |
419 | "finally" ":" suite | |
420 | ||
421 | funcdef ::= | |
422 | [decorators] "def" funcname "(" [parameter_list] ")" | |
423 | ":" suite | |
424 | ||
425 | decorators ::= | |
426 | decorator+ | |
427 | ||
428 | decorator ::= | |
429 | "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE | |
430 | ||
431 | dotted_name ::= | |
432 | identifier ("." identifier)* | |
433 | ||
434 | parameter_list ::= | |
435 | (defparameter ",")* | |
436 | (~~"*" identifier [, "**" identifier] | |
437 | | "**" identifier | |
438 | | defparameter [","] ) | |
439 | ||
440 | defparameter ::= | |
441 | parameter ["=" expression] | |
442 | ||
443 | sublist ::= | |
444 | parameter ("," parameter)* [","] | |
445 | ||
446 | parameter ::= | |
447 | identifier | "(" sublist ")" | |
448 | ||
449 | funcname ::= | |
450 | identifier | |
451 | ||
452 | classdef ::= | |
453 | "class" classname [inheritance] ":" | |
454 | suite | |
455 | ||
456 | inheritance ::= | |
457 | "(" expression_list ")" | |
458 | ||
459 | classname ::= | |
460 | identifier | |
461 | ||
462 | file_input ::= | |
463 | (NEWLINE | statement)* | |
464 | ||
465 | interactive_input ::= | |
466 | [stmt_list] NEWLINE | compound_stmt NEWLINE | |
467 | ||
468 | eval_input ::= | |
469 | expression_list NEWLINE* | |
470 | ||
471 | input_input ::= | |
472 | expression_list NEWLINE |