Skip to content

Commit

Permalink
Merge pull request #1232 from evtn/patch-1
Browse files Browse the repository at this point in the history
Updated Python grammar list literal to support `[*x]`
  • Loading branch information
erezsh committed Dec 19, 2022
2 parents ed2bd92 + 88fe0fd commit f3d7904
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lark/grammars/python.lark
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ AWAIT: "await"
?atom: "(" yield_expr ")"
| "(" _tuple_inner? ")" -> tuple
| "(" comprehension{test_or_star_expr} ")" -> tuple_comprehension
| "[" _testlist_comp? "]" -> list
| "[" _exprlist? "]" -> list
| "[" comprehension{test_or_star_expr} "]" -> list_comprehension
| "{" _dict_exprlist? "}" -> dict
| "{" comprehension{key_value} "}" -> dict_comprehension
| "{" _set_exprlist "}" -> set
| "{" _exprlist "}" -> set
| "{" comprehension{test} "}" -> set_comprehension
| name -> var
| number
Expand All @@ -215,10 +215,8 @@ AWAIT: "await"

?string_concat: string+

_testlist_comp: test | _tuple_inner
_tuple_inner: test_or_star_expr (("," test_or_star_expr)+ [","] | ",")


?test_or_star_expr: test
| star_expr

Expand All @@ -234,7 +232,7 @@ _dict_exprlist: (key_value | "**" expr) ("," (key_value | "**" expr))* [","]

key_value: test ":" test

_set_exprlist: test_or_star_expr ("," test_or_star_expr)* [","]
_exprlist: test_or_star_expr ("," test_or_star_expr)* [","]

classdef: "class" name ["(" [arguments] ")"] ":" suite

Expand Down

0 comments on commit f3d7904

Please sign in to comment.