From 23875c55905d89228b5c80b0f8e80483c09f5c95 Mon Sep 17 00:00:00 2001 From: Erez Shinan Date: Sun, 21 Jan 2018 16:10:11 +0200 Subject: [PATCH] Small fix in Python grammars (misread tuples, issue #68) --- examples/python2.g | 5 +++-- examples/python3.g | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) 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]