diff --git a/examples/python2.g b/examples/python2.g index b9f93dc..986350d 100644 --- a/examples/python2.g +++ b/examples/python2.g @@ -100,13 +100,14 @@ comp_op: "<"|">"|"=="|">="|"<="|"<>"|"!="|"in"|"not" "in"|"is"|"is" "not" | molecule "[" [subscriptlist] "]" -> getitem | molecule "." NAME -> getattr | atom -?atom: "(" [yield_expr|testlist_comp] ")" +?atom: "(" [yield_expr|testlist_comp] ")" -> tuple | "[" [listmaker] "]" | "{" [dictorsetmaker] "}" | "`" testlist1 "`" + | "(" test ")" | NAME | number | string+ listmaker: test ( list_for | ("," test)* [","] ) -?testlist_comp: test ( comp_for | ("," test)* [","] ) +?testlist_comp: test ( comp_for | ("," test)+ [","] | ",") lambdef: "lambda" [paramlist] ":" test ?subscriptlist: subscript ("," subscript)* [","] subscript: "." "." "." | test | [test] ":" [test] [sliceop] diff --git a/examples/python3.g b/examples/python3.g index a8dd688..1c01e75 100644 --- a/examples/python3.g +++ b/examples/python3.g @@ -121,12 +121,13 @@ AWAIT: "await" | "{" [dictorsetmaker] "}" -> dict | NAME -> var | number | string+ + | "(" test ")" | "..." -> ellipsis | "None" -> const_none | "True" -> const_true | "False" -> const_false -testlist_comp: (test|star_expr) ( comp_for | ("," (test|star_expr))* [","] ) +?testlist_comp: (test|star_expr) ( comp_for | ("," (test|star_expr))+ [","] | ",") subscriptlist: subscript ("," subscript)* [","] subscript: test | [test] ":" [test] [sliceop] sliceop: ":" [test]