Advertisement
alternyxx

mmpy

Feb 23rd, 2025 (edited)
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.49 KB | None | 0 0
  1. # there's a tl note for every translation i did, comments which do not
  2. # involve translations are ones im making to simplify python's grammar to be usable to
  3. # parsing to my own ast
  4. # i highly doubt you're interested in the semantics of python's grammar and is advised to
  5. # mainly go over the burmese translations
  6. <file> ::= <statement>*
  7. # GENERAL STATEMENTS
  8. # ==================
  9. <statement> ::= <compound_stmt> | <simple_stmts>
  10. <simple_stmts> ::= # icl ts pmo ngl, lk plz btr cmts
  11. | <simple_stmt> !';' NEWLINE # Not needed, there for speedup
  12. | <simple_stmt> (';' <simple_stmt>)* ';'? NEWLINE
  13. # | ';'.<simple_stmt>+ (';')? NEWLINE
  14. <simple_stmt> ::=
  15. | <assignment>
  16. | <type_alias>
  17. | <star_expressions>
  18. | <return_stmt>
  19. | <import_stmt>
  20. | <raise_stmt>
  21. # | 'pass' i genuinely dont know how to translate this, you can always do ... in python
  22. # | <del_stmt> honestly i think i used this once and it was because i didnt know pop exist
  23. # | <yield_stmt> dk how to translate
  24. # | <assert_stmt> dk how to translate
  25. | 'ရပ်ဆဲ'
  26. | 'ဆက်လက်'
  27. # | <global_stmt> not willing to translate these as i doubt modern python uses it
  28. # | <nonlocal_stmt>
  29. <compound_stmt> ::=
  30. | <function_def>
  31. | <if_stmt>
  32. | <class_def>
  33. # | <with_stmt> dont know how to translate
  34. | <for_stmt>
  35. | <try_stmt>
  36. | <while_stmt>
  37. # | <match_stmt> just cant be bothered with python's overly verbose switches
  38. <assignment> ::=
  39. | NAME ':' <expression> ('=' <annotated_rhs> )?
  40. | ('(' <single_target> ')'
  41. | <single_subscript_attribute_target>) ':' <expression> ('=' <annotated_rhs> )?
  42. | (<star_targets> '=' )+ (<yield_expr> | <star_expressions>) !'=' TYPE_COMMENT?
  43. | <single_target> <augassign> ~ (<yield_expr> | <star_expressions>)
  44. <annotated_rhs> ::= <yield_expr> | <star_expressions>
  45. <augassign> ::=
  46. | '+='
  47. | '-='
  48. | '*='
  49. | '@='
  50. | '/='
  51. | '%='
  52. | '&='
  53. | '|='
  54. | '^='
  55. | '<<='
  56. | '>>='
  57. | '**='
  58. | '//='
  59. # PLEASE USE
  60. <return_stmt> ::=
  61. | (<star_expressions>)? 'ရသည်'
  62. <raise_stmt> ::=
  63. | 'ပစ်'
  64. | (<expression> 'မှ')? <expression> 'ပစ်ပေး'
  65. # <global_stmt> ::= 'global' NAME (',' NAME)*
  66. # <nonlocal_stmt> ::= 'nonlocal' NAME (',' NAME)*
  67. # <del_stmt> ::=
  68. # | 'del' <del_targets> &(';' | NEWLINE)
  69. # <yield_stmt> ::= <yield_expr>
  70. # <assert_stmt> ::= 'assert' <expression> (',' <expression> )?
  71. <import_stmt> ::=
  72. | <import_name>
  73. # | <import_from>
  74. # Import statements
  75. # -----------------
  76. <import_name> ::= 'import' <dotted_as_names>
  77. <import_from> ::=
  78. # xD 'from ..' ends up working anyways
  79. | 'from' ('.' | '...')* <dotted_name> 'import' <import_from_targets>
  80. | 'from' ('.' | '...')+ 'import' <import_from_targets>
  81. <import_from_targets> ::=
  82. | '(' <import_from_as_names> (',')? ')'
  83. | <import_from_as_names> !','
  84. | '*'
  85. <import_from_as_names> ::=
  86. | <import_from_as_name> (',' <import_from_as_name>)*
  87. <import_from_as_name> ::=
  88. | NAME ('as' NAME )?
  89. <dotted_as_names> ::=
  90. | <dotted_as_name> (',' <dotted_as_name>)*
  91. <dotted_as_name> ::=
  92. | <dotted_name> ('as' NAME )?
  93. <dotted_name> ::=
  94. | <dotted_name> '.' NAME
  95. | NAME
  96. # COMPOUND STATEMENTS
  97. # ===================
  98. # Common elements
  99. # ---------------
  100. <block> ::=
  101. | NEWLINE INDENT <statements> DEDENT
  102. | <simple_stmts>
  103. <decorators> ::= ('@' <named_expression> NEWLINE )+
  104. # Class definitions
  105. # -----------------
  106. <class_def> ::=
  107. | <decorators> <class_def_raw>
  108. | <class_def_raw>
  109. # this will probably be the weirdest one, i felt 'အရာဝတ္ထု' was 1. too verbose and 2. အရာဝတ္ထု Human feels weird...
  110. # maybe i shouldve opted for some other stuff especially since 'ဝတ္ထု' and 'အရာဝတ္ထု' are two completely different things
  111. # or so some people have said
  112. # or so i said but im js gonna use အရာဝတ္ထု :/
  113. <class_def_raw> ::=
  114. | 'အရာဝတ္ထု' NAME <type_params>? ('(' <arguments>? ')' )? ':' <block>
  115. # Function definitions
  116. # --------------------
  117. <function_def> ::=
  118. | <decorators> <function_def_raw>
  119. | <function_def_raw>
  120. <function_def_raw> ::=
  121. | 'သတ်မှတ်ချက်' NAME <type_params>? '(' <params>? ')' ('->' <expression> )? ':' <func_type_comment>? <block>
  122. # | 'async' 'def' NAME <type_params>? '(' <params>? ')' ('->' <expression> )? ':' <func_type_comment>? <block>
  123. # dk of a way to translate async
  124. # Function parameters
  125. # -------------------
  126. <params> ::=
  127. | <parameters>
  128. <parameters> ::=
  129. | <slash_no_default> <param_no_default>* <param_with_default>* <star_etc>?
  130. | <slash_with_default> <param_with_default>* <star_etc>?
  131. | <param_no_default>+ <param_with_default>* <star_etc>?
  132. | <param_with_default>+ <star_etc>?
  133. | <star_etc>
  134. # Some duplication here because we can't write (',' | &')'),
  135. # which is because we don't support empty alternatives (yet).
  136. # yea and dont ever support that, i dont wanna deal w/ it
  137. <slash_no_default> ::=
  138. | <param_no_default>+ '/' ','
  139. | <param_no_default>+ '/' &')'
  140. <slash_with_default> ::=
  141. | <param_no_default>* <param_with_default>+ '/' ','
  142. | <param_no_default>* <param_with_default>+ '/' &')'
  143. <star_etc> ::=
  144. | '*' <param_no_default> <param_maybe_default>* <kwds>?
  145. | '*' <param_no_default_star_annotation> <param_maybe_default>* <kwds>?
  146. | '*' ',' <param_maybe_default>+ <kwds>?
  147. | <kwds>
  148. <kwds> ::=
  149. | '**' <param_no_default>
  150. <param_no_default> ::=
  151. | <param> ',' TYPE_COMMENT?
  152. | <param> TYPE_COMMENT? &')'
  153. <param_no_default_star_annotation> ::=
  154. | <param_star_annotation> ',' TYPE_COMMENT?
  155. | <param_star_annotation> TYPE_COMMENT? &')'
  156. <param_with_default> ::=
  157. | <param> <default> ',' TYPE_COMMENT?
  158. | <param> <default> TYPE_COMMENT? &')'
  159. <param_maybe_default> ::=
  160. | <param> <default>? ',' TYPE_COMMENT?
  161. | <param> <default>? TYPE_COMMENT? &')'
  162. <param> ::= NAME <annotation>?
  163. <param_star_annotation> ::= NAME <star_annotation>
  164. <annotation> ::= ':' <expression>
  165. <star_annotation> ::= ':' <star_expression>
  166. <default> ::= '=' <expression>
  167. # If statement
  168. # ------------
  169. <if_stmt> ::=
  170. | <named_expression> 'ဖြစ်ရင်' ':' <block> <elif_stmt>
  171. | <named_expression> 'ဖြစ်ရင်' ':' <block> <else_block>?
  172. <elif_stmt> ::=
  173. | 'သိုမဟုတ်' <named_expression> 'ဖြစ်ရင်' ':' <block> <elif_stmt>
  174. | 'သိုမဟုတ်' <named_expression> 'ဖြစ်ရင်' ':' <block> <else_block>?
  175. <else_block> ::=
  176. | 'သိုမဟုတ်' ':' <block>
  177. # While statement
  178. # ---------------
  179. <while_stmt> ::=
  180. | <named_expression> 'ဖြစ်နေစဉ်' ':' <block> <else_block>?
  181. # For statement
  182. # -------------
  183. <for_stmt> ::=
  184. | <star_expressions> 'ရှိ' <star_targets> 'အတွက်' ':' TYPE_COMMENT? <block> <else_block>?
  185. # | 'async' 'for' <star_targets> 'in' ~ <star_expressions> ':' TYPE_COMMENT? <block> <else_block>?
  186. # yet again the async
  187. # With statement
  188. # --------------
  189. # again dk how i would translate this
  190. # <with_stmt> ::=
  191. # | 'with' '(' <with_item> (',' <with_item>)* ','? ')' ':' TYPE_COMMENT? <block>
  192. # | 'with' <with_item> (',' <with_item>)* ':' TYPE_COMMENT? <block>
  193. # | 'async' 'with' '(' <with_item> (',' <with_item>)* ','? ')' ':' <block>
  194. # | 'async' 'with' <with_item> (',' <with_item>)* ':' TYPE_COMMENT? <block>
  195. # <with_item> ::=
  196. # | <expression> 'as' <star_target> &(',' | ')' | ':')
  197. # | <expression>
  198. # Try statement
  199. # -------------
  200. <try_stmt> ::=
  201. | 'စမ်းကြည့်' ':' <block> <finally_block>
  202. | 'စမ်းကြည့်' ':' <block> <except_block>+ <else_block>? <finally_block>?
  203. # | 'စမ်းကြည့်' ':' <block> <except_star_block>+ <else_block>? <finally_block>?
  204. # refer to <except_star_block>
  205. # Except statement
  206. # ----------------
  207. <except_block> ::=
  208. | <expression> ('ကို' NAME 'အနေဖြင့်' )? 'ဖမ်း၍' ':' <block>
  209. | 'ဖမ်း' ':' <block>
  210. <except_star_block> ::=
  211. # the last thing i can find about this is
  212. # https://groups.google.com/g/dev-python/c/G3p9_jovyus?pli=1
  213. | 'except' '*' <expression> ('as' NAME )? ':' <block>
  214. <finally_block> ::=
  215. | 'နောက်ဆုံး' ':' <block>
  216. # Match statement
  217. # ---------------
  218. <match_stmt> ::=
  219. | "match" <subject_expr> ':' NEWLINE INDENT <case_block>+ DEDENT
  220. <subject_expr> ::=
  221. | <star_named_expression> ',' <star_named_expressions>?
  222. | <named_expression>
  223. <case_block> ::=
  224. | "case" <patterns> <guard>? ':' <block>
  225. <guard> ::= 'if' <named_expression>
  226. <patterns> ::=
  227. | <open_sequence_pattern>
  228. | <pattern>
  229. <pattern> ::=
  230. | <as_pattern>
  231. | <or_pattern>
  232. <as_pattern> ::=
  233. | <or_pattern> 'as' <pattern_capture_target>
  234. <or_pattern> ::=
  235. | <closed_pattern> ('|' <closed_pattern>)*
  236. <closed_pattern> ::=
  237. | <literal_pattern>
  238. | <capture_pattern>
  239. | <wildcard_pattern>
  240. | <value_pattern>
  241. | <group_pattern>
  242. | <sequence_pattern>
  243. | <mapping_pattern>
  244. | <class_pattern>
  245. # Literal patterns are used for equality and identity constraints
  246. <literal_pattern> ::=
  247. | <signed_number> !('+' | '-')
  248. | <complex_number>
  249. | <strings>
  250. | 'ဗလာ'
  251. | 'မှန်'
  252. | 'မှား'
  253. # Literal expressions are used to restrict permitted mapping <pattern> keys
  254. <literal_expr> ::=
  255. | <signed_number> !('+' | '-')
  256. | <complex_number>
  257. | <strings>
  258. | 'ဗလာ'
  259. | 'မှန်'
  260. | 'မှား'
  261. <complex_number> ::=
  262. | <signed_real_number> '+' <imaginary_number>
  263. | <signed_real_number> '-' <imaginary_number>
  264. <signed_number> ::=
  265. | NUMBER
  266. | '-' NUMBER
  267. <signed_real_number> ::=
  268. | <real_number>
  269. | '-' <real_number>
  270. <real_number> ::=
  271. | NUMBER
  272. <imaginary_number> ::=
  273. | NUMBER
  274. <capture_pattern> ::=
  275. | <pattern_capture_target>
  276. <pattern_capture_target> ::=
  277. | !"_" NAME !('.' | '(' | '=')
  278. <wildcard_pattern> ::=
  279. | "_"
  280. <value_pattern> ::=
  281. | <attr> !('.' | '(' | '=')
  282. <attr> ::=
  283. | <name_or_attr> '.' NAME
  284. <name_or_attr> ::=
  285. | <attr>
  286. | NAME
  287. <group_pattern> ::=
  288. | '(' <pattern> ')'
  289. <sequence_pattern> ::=
  290. | '[' <maybe_sequence_pattern>? ']'
  291. | '(' <open_sequence_pattern>? ')'
  292. <open_sequence_pattern> ::=
  293. | <maybe_star_pattern> ',' <maybe_sequence_pattern> ?
  294. <maybe_sequence_pattern> ::=
  295. | <maybe_star_pattern> (',' <maybe_star_pattern>)* ','?
  296. <maybe_star_pattern> ::=
  297. | <star_pattern>
  298. | <pattern>
  299. <star_pattern> ::=
  300. | '*' <pattern_capture_target>
  301. | '*' <wildcard_pattern>
  302. <mapping_pattern> ::=
  303. | '{' '}'
  304. | '{' <double_star_pattern> ','? '}'
  305. | '{' <items_pattern> ',' <double_star_pattern> ','? '}'
  306. | '{' <items_pattern> ','? '}'
  307. <items_pattern> ::=
  308. | <key_value_pattern> (',' <key_value_pattern>)*
  309. <key_value_pattern> ::=
  310. | (<literal_expr> | <attr>) ':' <pattern>
  311. <double_star_pattern> ::=
  312. | '**' <pattern_capture_target>
  313. <class_pattern> ::=
  314. | <name_or_attr> '(' ')'
  315. | <name_or_attr> '(' <positional_patterns> ','? ')'
  316. | <name_or_attr> '(' <keyword_patterns> ','? ')'
  317. | <name_or_attr> '(' <positional_patterns> ',' <keyword_patterns> ','? ')'
  318. <positional_patterns> ::=
  319. | <pattern> (',' <pattern>)*
  320. <keyword_patterns> ::=
  321. | <key_value_pattern> (',' <keyword_pattern>)*
  322. <keyword_pattern> ::=
  323. | NAME '=' <pattern>
  324. # Type <statement>
  325. # ---------------
  326. <type_alias> ::=
  327. | "type" NAME <type_params>? '=' <expression>
  328. # Type <param>eter declaration
  329. # --------------------------
  330. <type_params> ::=
  331. | '[' <type_param_seq> ']'
  332. <type_param_seq> ::= <type_param> (',' <type_param>)* ','?
  333. <type_param> ::=
  334. | NAME <type_param_bound>? <type_param_default>?
  335. | '*' NAME <type_param_starred_default>?
  336. | '**' NAME <type_param_default>?
  337. <type_param_bound> ::= ':' <expression>
  338. <type_param_default> ::= '=' <expression>
  339. <type_param_starred_default> ::= '=' <star_expression>
  340. # EXPRESSIONS
  341. # -----------
  342. <expressions> ::=
  343. | <expression> (',' <expression> )+ ','?
  344. | <expression> ','
  345. | <expression>
  346. <expression> ::=
  347. | <disjunction> 'if' <disjunction> 'else' <expression>
  348. | <disjunction>
  349. | <lambdef>
  350. <yield_expr> ::=
  351. | 'yield' 'from' <expression>
  352. | 'yield' <star_expressions>?
  353. <star_expressions> ::=
  354. | <star_expression> (',' <star_expression> )+ ','?
  355. | <star_expression> ','
  356. | <star_expression>
  357. <star_expression> ::=
  358. | '*' <bitwise_or>
  359. | <expression>
  360. <star_named_expressions> ::= <star_named_expression> (',' <star_named_expression>)* ','?
  361. <star_named_expression> ::=
  362. | '*' <bitwise_or>
  363. | <named_expression>
  364. <assignment_expression> ::=
  365. | NAME ':=' ~ <expression>
  366. <named_expression> ::=
  367. | <assignment_expression>
  368. | <expression> !':='
  369. <disjunction> ::=
  370. | <conjunction> ('သို့မဟုတ်' <conjunction> )+
  371. | <conjunction>
  372. # 'ဖြစ်၍' is the only one that works with the other stuff
  373. <conjunction> ::=
  374. | <inversion> ('ဖြစ်၍' <inversion> )+
  375. | <inversion>
  376. # python allowing (not not not not not foo)
  377. # to be parsable is so strange
  378. # dont think we can do that
  379. <inversion> ::=
  380. | <inversion> 'မ' # this will prob be troublesome for most parser generators and could lead
  381. | <comparison> # lead to recursion errors, im hoping that itll
  382. # what im hoping with this is that the parser will fail to parse 'မ' and parse comparison
  383. # i just woke up and found out thats only an issue with LL parsing which is how my
  384. # parser generator works so alas, im the one dealing w/ that, yikes
  385. # Comparison operators
  386. # --------------------
  387. <comparison> ::=
  388. | <bitwise_or> <compare_op_bitwise_or_pair>+
  389. | <bitwise_or>
  390. <compare_op_bitwise_or_pair> ::=
  391. | <eq_bitwise_or>
  392. | <noteq_bitwise_or>
  393. | <lte_bitwise_or>
  394. | <lt_bitwise_or>
  395. | <gte_bitwise_or>
  396. | <gt_bitwise_or>
  397. | <notin_bitwise_or>
  398. | <in_bitwise_or>
  399. | <isnot_bitwise_or>
  400. | <is_bitwise_or>
  401. <eq_bitwise_or> ::= '==' <bitwise_or>
  402. <noteq_bitwise_or> ::=
  403. | ('!=' ) <bitwise_or>
  404. <lte_bitwise_or> ::= '<=' <bitwise_or>
  405. <lt_bitwise_or> ::= '<' <bitwise_or>
  406. <gte_bitwise_or> ::= '>=' <bitwise_or>
  407. <gt_bitwise_or> ::= '>' <bitwise_or>
  408. <notin_bitwise_or> ::= 'not' 'in' <bitwise_or>
  409. <in_bitwise_or> ::= 'in' <bitwise_or>
  410. <isnot_bitwise_or> ::= 'သည်' 'not' <bitwise_or>
  411. <is_bitwise_or> ::= 'သည်' <bitwise_or>
  412. # Bitwise operators
  413. # -----------------
  414. <bitwise_or> ::=
  415. | <bitwise_or> '|' <bitwise_xor>
  416. | <bitwise_xor>
  417. <bitwise_xor> ::=
  418. | <bitwise_xor> '^' <bitwise_and>
  419. | <bitwise_and>
  420. <bitwise_and> ::=
  421. | <bitwise_and> '&' <shift_expr>
  422. | <shift_expr>
  423. <shift_expr> ::=
  424. | <shift_expr> '<<' <sum>
  425. | <shift_expr> '>>' <sum>
  426. | <sum>
  427. # Arithmetic operators
  428. # --------------------
  429. <sum> ::=
  430. | <sum> '+' <term>
  431. | <sum> '-' <term>
  432. | <term>
  433. <term> ::=
  434. | <term> '*' <factor>
  435. | <term> '/' <factor>
  436. | <term> '//' <factor>
  437. | <term> '%' <factor>
  438. | <term> '@' <factor>
  439. | <factor>
  440. <factor> ::=
  441. | '+' <factor>
  442. | '-' <factor>
  443. | '~' <factor>
  444. | <power>
  445. <power> ::=
  446. | <await_primary> '**' <factor>
  447. | <await_primary>
  448. # Primary elements
  449. # ----------------
  450. # Primary elements are things like "obj.something.something", "obj[something]", "obj(something)", "obj" ...
  451. <await_primary> ::=
  452. | 'စောင့်ဆိုင်း' <primary>
  453. | <primary>
  454. <primary> ::=
  455. | <primary> '.' NAME
  456. | <primary> <genexp>
  457. | <primary> '(' (<arguments>)? ')'
  458. | <primary> '[' <slices> ']'
  459. | <atom>
  460. <slices> ::=
  461. | <slice> !','
  462. | (<slice> | <starred_expression>) (',' (<slice> | <starred_expression>))* (',')?
  463. <slice> ::=
  464. | <expression>? ':' <expression>? (':' <expression>? )?
  465. | <named_expression>
  466. <atom> ::=
  467. | NAME
  468. | 'မှန်'
  469. | 'မှား'
  470. | 'ဗလာ'
  471. | <strings>
  472. | NUMBER
  473. | (<tuple> | <group> | <genexp>)
  474. | (<list> | <listcomp>)
  475. | (<dict> | <set> | <dictcomp> | <setcomp>)
  476. | '...'
  477. <group> ::=
  478. | '(' (<yield_expr> | <named_expression>) ')'
  479. # Lambda functions
  480. # ----------------
  481. <lambdef> ::=
  482. | 'lambda' <lambda_params>? ':' <expression>
  483. <lambda_params> ::=
  484. | <lambda_parameters>
  485. <lambda_parameters> ::=
  486. | <lambda_slash_no_default> <lambda_param_no_default>* <lambda_param_with_default>* <lambda_star_etc>?
  487. | <lambda_slash_with_default> <lambda_param_with_default>* <lambda_star_etc>?
  488. | <lambda_param_no_default>+ <lambda_param_with_default>* <lambda_star_etc>?
  489. | <lambda_param_with_default>+ <lambda_star_etc>?
  490. | <lambda_star_etc>
  491. <lambda_slash_no_default> ::=
  492. | <lambda_param_no_default>+ '/' ','
  493. | <lambda_param_no_default>+ '/' &':'
  494. <lambda_slash_with_default> ::=
  495. | <lambda_param_no_default>* <lambda_param_with_default>+ '/' ','
  496. | <lambda_param_no_default>* <lambda_param_with_default>+ '/' &':'
  497. <lambda_star_etc> ::=
  498. | '*' <lambda_param_no_default> <lambda_param_maybe_default>* <lambda_kwds>?
  499. | '*' ',' <lambda_param_maybe_default>+ <lambda_kwds>?
  500. | <lambda_kwds>
  501. <lambda_kwds> ::=
  502. | '**' <lambda_param_no_default>
  503. <lambda_param_no_default> ::=
  504. | <lambda_param> ','
  505. | <lambda_param> &':'
  506. <lambda_param_with_default> ::=
  507. | <lambda_param> <default> ','
  508. | <lambda_param> <default> &':'
  509. <lambda_param_maybe_default> ::=
  510. | <lambda_param> <default>? ','
  511. | <lambda_param> <default>? &':'
  512. <lambda_param> ::= NAME
  513. # LITERALS
  514. # ========
  515. <fstring_middle> ::=
  516. | <fstring_replacement_field>
  517. | FSTRING_MIDDLE
  518. <fstring_replacement_field> ::=
  519. | '{' <annotated_rhs> '='? <fstring_conversion>? <fstring_full_format_spec>? '}'
  520. <fstring_conversion> ::=
  521. | "!" NAME
  522. <fstring_full_format_spec> ::=
  523. | ':' <fstring_format_spec>*
  524. <fstring_format_spec> ::=
  525. | FSTRING_MIDDLE
  526. | <fstring_replacement_field>
  527. <fstring> ::=
  528. | FSTRING_START <fstring_middle>* FSTRING_END
  529. <string> ::= STRING
  530. <strings> ::= (<fstring>|<string>)+
  531. <list> ::=
  532. | '[' <star_named_expressions>? ']'
  533. <tuple> ::=
  534. | '(' (<star_named_expression> ',' <star_named_expressions>? )? ')'
  535. <set> ::= '{' <star_named_expressions> '}'
  536. # Dicts
  537. # -----
  538. <dict> ::=
  539. | '{' <double_starred_kvpairs>? '}'
  540. <double_starred_kvpairs> ::= <double_starred_kvpair> (',' <double_starred_kvpair>)* ','?
  541. <double_starred_kvpair> ::=
  542. | '**' <bitwise_or>
  543. | <kvpair>
  544. <kvpair> ::= <expression> ':' <expression>
  545. # Comprehensions & Generators
  546. # ---------------------------
  547. <for_if_clauses> ::=
  548. | <for_if_clause>+
  549. <for_if_clause> ::=
  550. | 'async' 'for' <star_targets> 'in' ~ <disjunction> ('if' <disjunction> )*
  551. | 'for' <star_targets> 'in' ~ <disjunction> ('if' <disjunction> )*
  552. <listcomp> ::=
  553. | '[' <named_expression> <for_if_clauses> ']'
  554. <setcomp> ::=
  555. | '{' <named_expression> <for_if_clauses> '}'
  556. <genexp> ::=
  557. | '(' ( <assignment_expression> | <expression> !':=') <for_if_clauses> ')'
  558. <dictcomp> ::=
  559. | '{' <kvpair> <for_if_clauses> '}'
  560. # FUNCTION CALL ARGUMENTS
  561. # =======================
  562. <arguments> ::=
  563. | <args> ','? &')'
  564. <args> ::= # girl wtf
  565. | (<starred_expression> | ( <assignment_expression> | <expression> !':=') !'=') (',' (<starred_expression> | ( <assignment_expression> | <expression> !':=') !'='))* (',' <kwargs>)?
  566. | <kwargs>
  567. <kwargs> ::=
  568. | <kwarg_or_starred> (',' <kwarg_or_starred>)* ',' <kwarg_or_double_starred> (',' <kwarg_or_double_starred>)*
  569. | <kwarg_or_starred> (',' <kwarg_or_starred>)*
  570. | <kwarg_or_double_starred> (',' <kwarg_or_double_starred>)*
  571. <starred_expression> ::=
  572. | '*' <expression>
  573. <kwarg_or_starred> ::=
  574. | NAME '=' <expression>
  575. | <starred_expression>
  576. <kwarg_or_double_starred> ::=
  577. | NAME '=' <expression>
  578. | '**' <expression>
  579. <star_targets> ::=
  580. | <star_target> !','
  581. | <star_target> (',' <star_target> )* ','?
  582. <star_targets_list_seq> ::= <star_target> (',' <star_target>)* ','?
  583. <star_targets_tuple_seq> ::=
  584. | <star_target> (',' <star_target> )+ ','?
  585. | <star_target> ','
  586. <star_target> ::=
  587. | '*' (!'*' <star_target>)
  588. | <target_with_star_atom>
  589. <target_with
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement