10. 完整的语法规范

这是完整的 Python 语法规范,直接提取自用于生成 CPython 解析器的语法 (参见 Grammar/python.gram)。 这里显示的版本省略了有关代码生成和错误恢复的细节。

The notation is a mixture of EBNF and PEG. In particular, & followed by a symbol, token or parenthesized group indicates a positive lookahead (i.e., is required to match but not consumed), while ! indicates a negative lookahead (i.e., is required not to match). We use the | separator to mean PEG’s “ordered choice” (written as / in traditional PEG grammars). See PEP 617 for more details on the grammar’s syntax.

  1. # PEG grammar for Python
  2. # ========================= START OF THE GRAMMAR =========================
  3. # General grammatical elements and rules:
  4. #
  5. # * Strings with double quotes (") denote SOFT KEYWORDS
  6. # * Strings with single quotes (') denote KEYWORDS
  7. # * Upper case names (NAME) denote tokens in the Grammar/Tokens file
  8. # * Rule names starting with "invalid_" are used for specialized syntax errors
  9. # - These rules are NOT used in the first pass of the parser.
  10. # - Only if the first pass fails to parse, a second pass including the invalid
  11. # rules will be executed.
  12. # - If the parser fails in the second phase with a generic syntax error, the
  13. # location of the generic failure of the first pass will be used (this avoids
  14. # reporting incorrect locations due to the invalid rules).
  15. # - The order of the alternatives involving invalid rules matter
  16. # (like any rule in PEG).
  17. #
  18. # Grammar Syntax (see PEP 617 for more information):
  19. #
  20. # rule_name: expression
  21. # Optionally, a type can be included right after the rule name, which
  22. # specifies the return type of the C or Python function corresponding to the
  23. # rule:
  24. # rule_name[return_type]: expression
  25. # If the return type is omitted, then a void * is returned in C and an Any in
  26. # Python.
  27. # e1 e2
  28. # Match e1, then match e2.
  29. # e1 | e2
  30. # Match e1 or e2.
  31. # The first alternative can also appear on the line after the rule name for
  32. # formatting purposes. In that case, a | must be used before the first
  33. # alternative, like so:
  34. # rule_name[return_type]:
  35. # | first_alt
  36. # | second_alt
  37. # ( e )
  38. # Match e (allows also to use other operators in the group like '(e)*')
  39. # [ e ] or e?
  40. # Optionally match e.
  41. # e*
  42. # Match zero or more occurrences of e.
  43. # e+
  44. # Match one or more occurrences of e.
  45. # s.e+
  46. # Match one or more occurrences of e, separated by s. The generated parse tree
  47. # does not include the separator. This is otherwise identical to (e (s e)*).
  48. # &e
  49. # Succeed if e can be parsed, without consuming any input.
  50. # !e
  51. # Fail if e can be parsed, without consuming any input.
  52. # ~
  53. # Commit to the current alternative, even if it fails to parse.
  54. #
  55. # STARTING RULES
  56. # ==============
  57. file: [statements] ENDMARKER
  58. interactive: statement_newline
  59. eval: expressions NEWLINE* ENDMARKER
  60. func_type: '(' [type_expressions] ')' '->' expression NEWLINE* ENDMARKER
  61. fstring: star_expressions
  62. # GENERAL STATEMENTS
  63. # ==================
  64. statements: statement+
  65. statement: compound_stmt | simple_stmts
  66. statement_newline:
  67. | compound_stmt NEWLINE
  68. | simple_stmts
  69. | NEWLINE
  70. | ENDMARKER
  71. simple_stmts:
  72. | simple_stmt !';' NEWLINE # Not needed, there for speedup
  73. | ';'.simple_stmt+ [';'] NEWLINE
  74. # NOTE: assignment MUST precede expression, else parsing a simple assignment
  75. # will throw a SyntaxError.
  76. simple_stmt:
  77. | assignment
  78. | star_expressions
  79. | return_stmt
  80. | import_stmt
  81. | raise_stmt
  82. | 'pass'
  83. | del_stmt
  84. | yield_stmt
  85. | assert_stmt
  86. | 'break'
  87. | 'continue'
  88. | global_stmt
  89. | nonlocal_stmt
  90. compound_stmt:
  91. | function_def
  92. | if_stmt
  93. | class_def
  94. | with_stmt
  95. | for_stmt
  96. | try_stmt
  97. | while_stmt
  98. | match_stmt
  99. # SIMPLE STATEMENTS
  100. # =================
  101. # NOTE: annotated_rhs may start with 'yield'; yield_expr must start with 'yield'
  102. assignment:
  103. | NAME ':' expression ['=' annotated_rhs ]
  104. | ('(' single_target ')'
  105. | single_subscript_attribute_target) ':' expression ['=' annotated_rhs ]
  106. | (star_targets '=' )+ (yield_expr | star_expressions) !'=' [TYPE_COMMENT]
  107. | single_target augassign ~ (yield_expr | star_expressions)
  108. annotated_rhs: yield_expr | star_expressions
  109. augassign:
  110. | '+='
  111. | '-='
  112. | '*='
  113. | '@='
  114. | '/='
  115. | '%='
  116. | '&='
  117. | '|='
  118. | '^='
  119. | '<<='
  120. | '>>='
  121. | '**='
  122. | '//='
  123. return_stmt:
  124. | 'return' [star_expressions]
  125. raise_stmt:
  126. | 'raise' expression ['from' expression ]
  127. | 'raise'
  128. global_stmt: 'global' ','.NAME+
  129. nonlocal_stmt: 'nonlocal' ','.NAME+
  130. del_stmt:
  131. | 'del' del_targets &(';' | NEWLINE)
  132. yield_stmt: yield_expr
  133. assert_stmt: 'assert' expression [',' expression ]
  134. import_stmt: import_name | import_from
  135. # Import statements
  136. # -----------------
  137. import_name: 'import' dotted_as_names
  138. # note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS
  139. import_from:
  140. | 'from' ('.' | '...')* dotted_name 'import' import_from_targets
  141. | 'from' ('.' | '...')+ 'import' import_from_targets
  142. import_from_targets:
  143. | '(' import_from_as_names [','] ')'
  144. | import_from_as_names !','
  145. | '*'
  146. import_from_as_names:
  147. | ','.import_from_as_name+
  148. import_from_as_name:
  149. | NAME ['as' NAME ]
  150. dotted_as_names:
  151. | ','.dotted_as_name+
  152. dotted_as_name:
  153. | dotted_name ['as' NAME ]
  154. dotted_name:
  155. | dotted_name '.' NAME
  156. | NAME
  157. # COMPOUND STATEMENTS
  158. # ===================
  159. # Common elements
  160. # ---------------
  161. block:
  162. | NEWLINE INDENT statements DEDENT
  163. | simple_stmts
  164. decorators: ('@' named_expression NEWLINE )+
  165. # Class definitions
  166. # -----------------
  167. class_def:
  168. | decorators class_def_raw
  169. | class_def_raw
  170. class_def_raw:
  171. | 'class' NAME ['(' [arguments] ')' ] ':' block
  172. # Function definitions
  173. # --------------------
  174. function_def:
  175. | decorators function_def_raw
  176. | function_def_raw
  177. function_def_raw:
  178. | 'def' NAME '(' [params] ')' ['->' expression ] ':' [func_type_comment] block
  179. | ASYNC 'def' NAME '(' [params] ')' ['->' expression ] ':' [func_type_comment] block
  180. # Function parameters
  181. # -------------------
  182. params:
  183. | parameters
  184. parameters:
  185. | slash_no_default param_no_default* param_with_default* [star_etc]
  186. | slash_with_default param_with_default* [star_etc]
  187. | param_no_default+ param_with_default* [star_etc]
  188. | param_with_default+ [star_etc]
  189. | star_etc
  190. # Some duplication here because we can't write (',' | &')'),
  191. # which is because we don't support empty alternatives (yet).
  192. slash_no_default:
  193. | param_no_default+ '/' ','
  194. | param_no_default+ '/' &')'
  195. slash_with_default:
  196. | param_no_default* param_with_default+ '/' ','
  197. | param_no_default* param_with_default+ '/' &')'
  198. star_etc:
  199. | '*' param_no_default param_maybe_default* [kwds]
  200. | '*' param_no_default_star_annotation param_maybe_default* [kwds]
  201. | '*' ',' param_maybe_default+ [kwds]
  202. | kwds
  203. kwds:
  204. | '**' param_no_default
  205. # One parameter. This *includes* a following comma and type comment.
  206. #
  207. # There are three styles:
  208. # - No default
  209. # - With default
  210. # - Maybe with default
  211. #
  212. # There are two alternative forms of each, to deal with type comments:
  213. # - Ends in a comma followed by an optional type comment
  214. # - No comma, optional type comment, must be followed by close paren
  215. # The latter form is for a final parameter without trailing comma.
  216. #
  217. param_no_default:
  218. | param ',' TYPE_COMMENT?
  219. | param TYPE_COMMENT? &')'
  220. param_no_default_star_annotation:
  221. | param_star_annotation ',' TYPE_COMMENT?
  222. | param_star_annotation TYPE_COMMENT? &')'
  223. param_with_default:
  224. | param default ',' TYPE_COMMENT?
  225. | param default TYPE_COMMENT? &')'
  226. param_maybe_default:
  227. | param default? ',' TYPE_COMMENT?
  228. | param default? TYPE_COMMENT? &')'
  229. param: NAME annotation?
  230. param_star_annotation: NAME star_annotation
  231. annotation: ':' expression
  232. star_annotation: ':' star_expression
  233. default: '=' expression | invalid_default
  234. # If statement
  235. # ------------
  236. if_stmt:
  237. | 'if' named_expression ':' block elif_stmt
  238. | 'if' named_expression ':' block [else_block]
  239. elif_stmt:
  240. | 'elif' named_expression ':' block elif_stmt
  241. | 'elif' named_expression ':' block [else_block]
  242. else_block:
  243. | 'else' ':' block
  244. # While statement
  245. # ---------------
  246. while_stmt:
  247. | 'while' named_expression ':' block [else_block]
  248. # For statement
  249. # -------------
  250. for_stmt:
  251. | 'for' star_targets 'in' ~ star_expressions ':' [TYPE_COMMENT] block [else_block]
  252. | ASYNC 'for' star_targets 'in' ~ star_expressions ':' [TYPE_COMMENT] block [else_block]
  253. # With statement
  254. # --------------
  255. with_stmt:
  256. | 'with' '(' ','.with_item+ ','? ')' ':' block
  257. | 'with' ','.with_item+ ':' [TYPE_COMMENT] block
  258. | ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block
  259. | ASYNC 'with' ','.with_item+ ':' [TYPE_COMMENT] block
  260. with_item:
  261. | expression 'as' star_target &(',' | ')' | ':')
  262. | expression
  263. # Try statement
  264. # -------------
  265. try_stmt:
  266. | 'try' ':' block finally_block
  267. | 'try' ':' block except_block+ [else_block] [finally_block]
  268. | 'try' ':' block except_star_block+ [else_block] [finally_block]
  269. # Except statement
  270. # ----------------
  271. except_block:
  272. | 'except' expression ['as' NAME ] ':' block
  273. | 'except' ':' block
  274. except_star_block:
  275. | 'except' '*' expression ['as' NAME ] ':' block
  276. finally_block:
  277. | 'finally' ':' block
  278. # Match statement
  279. # ---------------
  280. match_stmt:
  281. | "match" subject_expr ':' NEWLINE INDENT case_block+ DEDENT
  282. subject_expr:
  283. | star_named_expression ',' star_named_expressions?
  284. | named_expression
  285. case_block:
  286. | "case" patterns guard? ':' block
  287. guard: 'if' named_expression
  288. patterns:
  289. | open_sequence_pattern
  290. | pattern
  291. pattern:
  292. | as_pattern
  293. | or_pattern
  294. as_pattern:
  295. | or_pattern 'as' pattern_capture_target
  296. or_pattern:
  297. | '|'.closed_pattern+
  298. closed_pattern:
  299. | literal_pattern
  300. | capture_pattern
  301. | wildcard_pattern
  302. | value_pattern
  303. | group_pattern
  304. | sequence_pattern
  305. | mapping_pattern
  306. | class_pattern
  307. # Literal patterns are used for equality and identity constraints
  308. literal_pattern:
  309. | signed_number !('+' | '-')
  310. | complex_number
  311. | strings
  312. | 'None'
  313. | 'True'
  314. | 'False'
  315. # Literal expressions are used to restrict permitted mapping pattern keys
  316. literal_expr:
  317. | signed_number !('+' | '-')
  318. | complex_number
  319. | strings
  320. | 'None'
  321. | 'True'
  322. | 'False'
  323. complex_number:
  324. | signed_real_number '+' imaginary_number
  325. | signed_real_number '-' imaginary_number
  326. signed_number:
  327. | NUMBER
  328. | '-' NUMBER
  329. signed_real_number:
  330. | real_number
  331. | '-' real_number
  332. real_number:
  333. | NUMBER
  334. imaginary_number:
  335. | NUMBER
  336. capture_pattern:
  337. | pattern_capture_target
  338. pattern_capture_target:
  339. | !"_" NAME !('.' | '(' | '=')
  340. wildcard_pattern:
  341. | "_"
  342. value_pattern:
  343. | attr !('.' | '(' | '=')
  344. attr:
  345. | name_or_attr '.' NAME
  346. name_or_attr:
  347. | attr
  348. | NAME
  349. group_pattern:
  350. | '(' pattern ')'
  351. sequence_pattern:
  352. | '[' maybe_sequence_pattern? ']'
  353. | '(' open_sequence_pattern? ')'
  354. open_sequence_pattern:
  355. | maybe_star_pattern ',' maybe_sequence_pattern?
  356. maybe_sequence_pattern:
  357. | ','.maybe_star_pattern+ ','?
  358. maybe_star_pattern:
  359. | star_pattern
  360. | pattern
  361. star_pattern:
  362. | '*' pattern_capture_target
  363. | '*' wildcard_pattern
  364. mapping_pattern:
  365. | '{' '}'
  366. | '{' double_star_pattern ','? '}'
  367. | '{' items_pattern ',' double_star_pattern ','? '}'
  368. | '{' items_pattern ','? '}'
  369. items_pattern:
  370. | ','.key_value_pattern+
  371. key_value_pattern:
  372. | (literal_expr | attr) ':' pattern
  373. double_star_pattern:
  374. | '**' pattern_capture_target
  375. class_pattern:
  376. | name_or_attr '(' ')'
  377. | name_or_attr '(' positional_patterns ','? ')'
  378. | name_or_attr '(' keyword_patterns ','? ')'
  379. | name_or_attr '(' positional_patterns ',' keyword_patterns ','? ')'
  380. positional_patterns:
  381. | ','.pattern+
  382. keyword_patterns:
  383. | ','.keyword_pattern+
  384. keyword_pattern:
  385. | NAME '=' pattern
  386. # EXPRESSIONS
  387. # -----------
  388. expressions:
  389. | expression (',' expression )+ [',']
  390. | expression ','
  391. | expression
  392. expression:
  393. | disjunction 'if' disjunction 'else' expression
  394. | disjunction
  395. | lambdef
  396. yield_expr:
  397. | 'yield' 'from' expression
  398. | 'yield' [star_expressions]
  399. star_expressions:
  400. | star_expression (',' star_expression )+ [',']
  401. | star_expression ','
  402. | star_expression
  403. star_expression:
  404. | '*' bitwise_or
  405. | expression
  406. star_named_expressions: ','.star_named_expression+ [',']
  407. star_named_expression:
  408. | '*' bitwise_or
  409. | named_expression
  410. assignment_expression:
  411. | NAME ':=' ~ expression
  412. named_expression:
  413. | assignment_expression
  414. | expression !':='
  415. disjunction:
  416. | conjunction ('or' conjunction )+
  417. | conjunction
  418. conjunction:
  419. | inversion ('and' inversion )+
  420. | inversion
  421. inversion:
  422. | 'not' inversion
  423. | comparison
  424. # Comparison operators
  425. # --------------------
  426. comparison:
  427. | bitwise_or compare_op_bitwise_or_pair+
  428. | bitwise_or
  429. compare_op_bitwise_or_pair:
  430. | eq_bitwise_or
  431. | noteq_bitwise_or
  432. | lte_bitwise_or
  433. | lt_bitwise_or
  434. | gte_bitwise_or
  435. | gt_bitwise_or
  436. | notin_bitwise_or
  437. | in_bitwise_or
  438. | isnot_bitwise_or
  439. | is_bitwise_or
  440. eq_bitwise_or: '==' bitwise_or
  441. noteq_bitwise_or:
  442. | ('!=' ) bitwise_or
  443. lte_bitwise_or: '<=' bitwise_or
  444. lt_bitwise_or: '<' bitwise_or
  445. gte_bitwise_or: '>=' bitwise_or
  446. gt_bitwise_or: '>' bitwise_or
  447. notin_bitwise_or: 'not' 'in' bitwise_or
  448. in_bitwise_or: 'in' bitwise_or
  449. isnot_bitwise_or: 'is' 'not' bitwise_or
  450. is_bitwise_or: 'is' bitwise_or
  451. # Bitwise operators
  452. # -----------------
  453. bitwise_or:
  454. | bitwise_or '|' bitwise_xor
  455. | bitwise_xor
  456. bitwise_xor:
  457. | bitwise_xor '^' bitwise_and
  458. | bitwise_and
  459. bitwise_and:
  460. | bitwise_and '&' shift_expr
  461. | shift_expr
  462. shift_expr:
  463. | shift_expr '<<' sum
  464. | shift_expr '>>' sum
  465. | sum
  466. # Arithmetic operators
  467. # --------------------
  468. sum:
  469. | sum '+' term
  470. | sum '-' term
  471. | term
  472. term:
  473. | term '*' factor
  474. | term '/' factor
  475. | term '//' factor
  476. | term '%' factor
  477. | term '@' factor
  478. | factor
  479. factor:
  480. | '+' factor
  481. | '-' factor
  482. | '~' factor
  483. | power
  484. power:
  485. | await_primary '**' factor
  486. | await_primary
  487. # Primary elements
  488. # ----------------
  489. # Primary elements are things like "obj.something.something", "obj[something]", "obj(something)", "obj" ...
  490. await_primary:
  491. | AWAIT primary
  492. | primary
  493. primary:
  494. | primary '.' NAME
  495. | primary genexp
  496. | primary '(' [arguments] ')'
  497. | primary '[' slices ']'
  498. | atom
  499. slices:
  500. | slice !','
  501. | ','.(slice | starred_expression)+ [',']
  502. slice:
  503. | [expression] ':' [expression] [':' [expression] ]
  504. | named_expression
  505. atom:
  506. | NAME
  507. | 'True'
  508. | 'False'
  509. | 'None'
  510. | strings
  511. | NUMBER
  512. | (tuple | group | genexp)
  513. | (list | listcomp)
  514. | (dict | set | dictcomp | setcomp)
  515. | '...'
  516. group:
  517. | '(' (yield_expr | named_expression) ')'
  518. # Lambda functions
  519. # ----------------
  520. lambdef:
  521. | 'lambda' [lambda_params] ':' expression
  522. lambda_params:
  523. | lambda_parameters
  524. # lambda_parameters etc. duplicates parameters but without annotations
  525. # or type comments, and if there's no comma after a parameter, we expect
  526. # a colon, not a close parenthesis. (For more, see parameters above.)
  527. #
  528. lambda_parameters:
  529. | lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* [lambda_star_etc]
  530. | lambda_slash_with_default lambda_param_with_default* [lambda_star_etc]
  531. | lambda_param_no_default+ lambda_param_with_default* [lambda_star_etc]
  532. | lambda_param_with_default+ [lambda_star_etc]
  533. | lambda_star_etc
  534. lambda_slash_no_default:
  535. | lambda_param_no_default+ '/' ','
  536. | lambda_param_no_default+ '/' &':'
  537. lambda_slash_with_default:
  538. | lambda_param_no_default* lambda_param_with_default+ '/' ','
  539. | lambda_param_no_default* lambda_param_with_default+ '/' &':'
  540. lambda_star_etc:
  541. | '*' lambda_param_no_default lambda_param_maybe_default* [lambda_kwds]
  542. | '*' ',' lambda_param_maybe_default+ [lambda_kwds]
  543. | lambda_kwds
  544. lambda_kwds:
  545. | '**' lambda_param_no_default
  546. lambda_param_no_default:
  547. | lambda_param ','
  548. | lambda_param &':'
  549. lambda_param_with_default:
  550. | lambda_param default ','
  551. | lambda_param default &':'
  552. lambda_param_maybe_default:
  553. | lambda_param default? ','
  554. | lambda_param default? &':'
  555. lambda_param: NAME
  556. # LITERALS
  557. # ========
  558. strings: STRING+
  559. list:
  560. | '[' [star_named_expressions] ']'
  561. tuple:
  562. | '(' [star_named_expression ',' [star_named_expressions] ] ')'
  563. set: '{' star_named_expressions '}'
  564. # Dicts
  565. # -----
  566. dict:
  567. | '{' [double_starred_kvpairs] '}'
  568. double_starred_kvpairs: ','.double_starred_kvpair+ [',']
  569. double_starred_kvpair:
  570. | '**' bitwise_or
  571. | kvpair
  572. kvpair: expression ':' expression
  573. # Comprehensions & Generators
  574. # ---------------------------
  575. for_if_clauses:
  576. | for_if_clause+
  577. for_if_clause:
  578. | ASYNC 'for' star_targets 'in' ~ disjunction ('if' disjunction )*
  579. | 'for' star_targets 'in' ~ disjunction ('if' disjunction )*
  580. listcomp:
  581. | '[' named_expression for_if_clauses ']'
  582. setcomp:
  583. | '{' named_expression for_if_clauses '}'
  584. genexp:
  585. | '(' ( assignment_expression | expression !':=') for_if_clauses ')'
  586. dictcomp:
  587. | '{' kvpair for_if_clauses '}'
  588. # FUNCTION CALL ARGUMENTS
  589. # =======================
  590. arguments:
  591. | args [','] &')'
  592. args:
  593. | ','.(starred_expression | ( assignment_expression | expression !':=') !'=')+ [',' kwargs ]
  594. | kwargs
  595. kwargs:
  596. | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+
  597. | ','.kwarg_or_starred+
  598. | ','.kwarg_or_double_starred+
  599. starred_expression:
  600. | '*' expression
  601. kwarg_or_starred:
  602. | NAME '=' expression
  603. | starred_expression
  604. kwarg_or_double_starred:
  605. | NAME '=' expression
  606. | '**' expression
  607. # ASSIGNMENT TARGETS
  608. # ==================
  609. # Generic targets
  610. # ---------------
  611. # NOTE: star_targets may contain *bitwise_or, targets may not.
  612. star_targets:
  613. | star_target !','
  614. | star_target (',' star_target )* [',']
  615. star_targets_list_seq: ','.star_target+ [',']
  616. star_targets_tuple_seq:
  617. | star_target (',' star_target )+ [',']
  618. | star_target ','
  619. star_target:
  620. | '*' (!'*' star_target)
  621. | target_with_star_atom
  622. target_with_star_atom:
  623. | t_primary '.' NAME !t_lookahead
  624. | t_primary '[' slices ']' !t_lookahead
  625. | star_atom
  626. star_atom:
  627. | NAME
  628. | '(' target_with_star_atom ')'
  629. | '(' [star_targets_tuple_seq] ')'
  630. | '[' [star_targets_list_seq] ']'
  631. single_target:
  632. | single_subscript_attribute_target
  633. | NAME
  634. | '(' single_target ')'
  635. single_subscript_attribute_target:
  636. | t_primary '.' NAME !t_lookahead
  637. | t_primary '[' slices ']' !t_lookahead
  638. t_primary:
  639. | t_primary '.' NAME &t_lookahead
  640. | t_primary '[' slices ']' &t_lookahead
  641. | t_primary genexp &t_lookahead
  642. | t_primary '(' [arguments] ')' &t_lookahead
  643. | atom &t_lookahead
  644. t_lookahead: '(' | '[' | '.'
  645. # Targets for del statements
  646. # --------------------------
  647. del_targets: ','.del_target+ [',']
  648. del_target:
  649. | t_primary '.' NAME !t_lookahead
  650. | t_primary '[' slices ']' !t_lookahead
  651. | del_t_atom
  652. del_t_atom:
  653. | NAME
  654. | '(' del_target ')'
  655. | '(' [del_targets] ')'
  656. | '[' [del_targets] ']'
  657. # TYPING ELEMENTS
  658. # ---------------
  659. # type_expressions allow */** but ignore them
  660. type_expressions:
  661. | ','.expression+ ',' '*' expression ',' '**' expression
  662. | ','.expression+ ',' '*' expression
  663. | ','.expression+ ',' '**' expression
  664. | '*' expression ',' '**' expression
  665. | '*' expression
  666. | '**' expression
  667. | ','.expression+
  668. func_type_comment:
  669. | NEWLINE TYPE_COMMENT &(NEWLINE INDENT) # Must be followed by indented block
  670. | TYPE_COMMENT
  671. # ========================= END OF THE GRAMMAR ===========================
  672. # ========================= START OF INVALID RULES =======================