Browse Source

Small fix in Python grammars (misread tuples, issue #68)

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.5.3
Erez Shinan 6 years ago
parent
commit
23875c5590
2 changed files with 5 additions and 3 deletions
  1. +3
    -2
      examples/python2.g
  2. +2
    -1
      examples/python3.g

+ 3
- 2
examples/python2.g View File

@@ -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]


+ 2
- 1
examples/python3.g View File

@@ -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]


Loading…
Cancel
Save