bpo-34822: Simplify AST for subscription. (GH-9605)
* Remove the slice type.
* Make Slice a kind of the expr type instead of the slice type.
* Replace ExtSlice(slices) with Tuple(slices, Load()).
* Replace Index(value) with a value itself.
All non-terminal nodes in AST for expressions are now of the expr type.
diff --git a/Parser/Python.asdl b/Parser/Python.asdl
index bec30a7..a1ddebd 100644
--- a/Parser/Python.asdl
+++ b/Parser/Python.asdl
@@ -78,21 +78,20 @@
-- the following expression can appear in assignment context
| Attribute(expr value, identifier attr, expr_context ctx)
- | Subscript(expr value, slice slice, expr_context ctx)
+ | Subscript(expr value, expr slice, expr_context ctx)
| Starred(expr value, expr_context ctx)
| Name(identifier id, expr_context ctx)
| List(expr* elts, expr_context ctx)
| Tuple(expr* elts, expr_context ctx)
+ -- can appear only in Subscript
+ | Slice(expr? lower, expr? upper, expr? step)
+
-- col_offset is the byte offset in the utf8 string the parser uses
attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset)
expr_context = Load | Store | Del | AugLoad | AugStore | Param
- slice = Slice(expr? lower, expr? upper, expr? step)
- | ExtSlice(slice* dims)
- | Index(expr value)
-
boolop = And | Or
operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift