Open Thirumalai-Shaktivel opened 2 years ago
Yes, we'll have to fix this in both the old and new parser.
For this, we need to do something like:
--- a/grammar/Python.asdl
+++ b/grammar/Python.asdl
@@ -72,7 +72,7 @@ module LPython
| YieldFrom(expr value)
-- need sequences for compare to distinguish between
-- x < 4 < 3 and (x < 4) < 3
- | Compare(expr left, cmpop ops, expr* comparators)
+ | Compare(expr left, cmpop2* ops, expr* comparators)
| Call(expr func, expr* args, keyword* keywords)
| FormattedValue(expr value, int conversion, expr? format_spec)
| JoinedStr(expr* values)
@@ -112,6 +112,8 @@ module LPython
cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn
+ cmpop2 = (cmpop op)
+
comprehension = (expr target, expr iter, expr* ifs, int is_async)
excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)
Example:
causes Old parser Error:
Originally posted by @akshanshbhatt in https://github.com/lcompilers/lpython/issues/786#issuecomment-1188659782