Skip to content

Commit 56466d1

Browse files
committed
actually parse augassign.
1 parent b2c05b7 commit 56466d1

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/expressions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,15 @@ named!(testlist_comp<StrSpan, TestlistCompReturn>,
337337

338338
// subscript: test | [test] ':' [test] [sliceop]
339339
named!(subscript<StrSpan, Subscript>,
340-
alt!(
340+
ws4!(alt!(
341341
preceded!(char!(':'), call!(Self::subscript_trail, None))
342342
| do_parse!(
343343
first: call!(Self::test) >>
344-
r: opt!(preceded!(char!(':'), call!(Self::subscript_trail, Some(*first.clone())))) >> ( // FIXME: remove this clone
344+
r: opt!(ws4!(preceded!(char!(':'), call!(Self::subscript_trail, Some(*first.clone()))))) >> ( // FIXME: remove this clone
345345
r.unwrap_or(Subscript::Simple(*first))
346346
)
347347
)
348-
)
348+
))
349349
);
350350
named_args!(subscript_trail(first: Option<Expression>) <StrSpan, Subscript>,
351351
do_parse!(

src/statements.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,24 +68,24 @@ named!(expr_stmt<StrSpan, Statement>,
6868
)
6969
)
7070

71-
| // Case 2: "foo", "foo = bar", "foo = bar = baz", ...
71+
| // Case 2: "Foo += bar" (and other operators)
7272
do_parse!(
73-
rhs: many0!(ws2!(preceded!(char!('='), alt!(
73+
op: augassign >>
74+
rhs: alt!(
7475
call!(ExpressionParser::<NewlinesAreNotSpaces>::yield_expr) => { |e| vec![e] }
75-
| testlist_star_expr
76-
)))) >> (
77-
Statement::Assignment(lhs.clone(), rhs)
76+
| call!(ExpressionParser::<NewlinesAreNotSpaces>::testlist)
77+
) >> (
78+
Statement::AugmentedAssignment(lhs.clone(), op, rhs)
7879
)
7980
)
8081

81-
| // Case 3: "Foo += bar" (and other operators)
82+
| // Case 3: "foo", "foo = bar", "foo = bar = baz", ...
8283
do_parse!(
83-
op: augassign >>
84-
rhs: alt!(
84+
rhs: many0!(ws2!(preceded!(char!('='), alt!(
8585
call!(ExpressionParser::<NewlinesAreNotSpaces>::yield_expr) => { |e| vec![e] }
86-
| call!(ExpressionParser::<NewlinesAreNotSpaces>::testlist)
87-
) >> (
88-
Statement::AugmentedAssignment(lhs, op, rhs)
86+
| testlist_star_expr
87+
)))) >> (
88+
Statement::Assignment(lhs, rhs)
8989
)
9090
)
9191
)) >>

0 commit comments

Comments
 (0)