@@ -372,7 +372,7 @@ IpyHelpEndEscapeCommandStatement: ast::Stmt = {
372
372
// We are permissive than the original implementation because we would allow whitespace
373
373
// between the expression and the suffix while the IPython implementation doesn't allow it.
374
374
// For example, `foo ?` would be valid in our case but invalid from IPython.
375
- <location:@L> <e:Expression<"All ">> <suffix:("?")+> <end_location:@R> =>? {
375
+ <location:@L> <e:Expression<"all ">> <suffix:("?")+> <end_location:@R> =>? {
376
376
fn unparse_expr(expr: &ast::Expr, buffer: &mut String) -> Result<(), LexicalError> {
377
377
match expr {
378
378
ast::Expr::Name(ast::ExprName { id, .. }) => {
@@ -1054,7 +1054,7 @@ WithStatement: ast::Stmt = {
1054
1054
1055
1055
WithItems: Vec<ast::WithItem> = {
1056
1056
"(" <WithItemsNoAs> ","? ")",
1057
- "(" <left:(<WithItemsNoAs> ",")?> <mid:WithItem<"as"> > <right:("," <WithItem<"all">>)*> ","? ")" => {
1057
+ "(" <left:(<WithItemsNoAs> ",")?> <mid:WithItemAs > <right:("," <WithItem<"all">>)*> ","? ")" => {
1058
1058
left.into_iter().flatten().chain([mid]).chain(right).collect()
1059
1059
},
1060
1060
<WithItem<"no-withitems">> => vec![<>],
@@ -1071,12 +1071,16 @@ WithItemsNoAs: Vec<ast::WithItem> = {
1071
1071
}
1072
1072
1073
1073
WithItem<Goal>: ast::WithItem = {
1074
- <location:@L> <context_expr: Test<Goal>> <end_location:@R> if Goal != "as" => ast::WithItem { context_expr, optional_vars: None, range: (location..end_location).into() },
1074
+ <location:@L> <context_expr: Test<Goal>> <end_location:@R> => ast::WithItem { context_expr, optional_vars: None, range: (location..end_location).into() },
1075
+ <WithItemAs>,
1076
+ };
1077
+
1078
+ WithItemAs: ast::WithItem = {
1075
1079
<location:@L> <context_expr:Test<"all">> "as" <vars:Expression<"all">> <end_location:@R> => {
1076
1080
let optional_vars = Some(Box::new(set_context(vars, ast::ExprContext::Store)));
1077
1081
ast::WithItem { context_expr, optional_vars, range: (location..end_location).into() }
1078
1082
},
1079
- };
1083
+ }
1080
1084
1081
1085
FuncDef: ast::Stmt = {
1082
1086
<location:@L> <decorator_list:Decorator*> <is_async:"async"?> "def" <name:Identifier> <type_params:TypeParams?> <args:Parameters> <r:("->" <Test<"all">>)?> ":" <body:Suite> => {
0 commit comments