@@ -304,10 +304,10 @@ named!(atom<StrSpan, Box<Expression>>,
304
304
// testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] )
305
305
named ! ( testlist_comp<StrSpan , TestlistCompReturn >,
306
306
do_parse!(
307
- first: alt!(
307
+ first: ws3! ( alt!(
308
308
call!( Self :: test) => { |e: Box <_>| SetItem :: Unique ( * e) }
309
309
| call!( Self :: star_expr) => { |e: Box <_>| SetItem :: Star ( * e) }
310
- ) >>
310
+ ) ) >>
311
311
r: alt!(
312
312
call!( Self :: comp_for) => { |comp| TestlistCompReturn :: Comp ( Box :: new( first) , comp) }
313
313
| opt!( delimited!(
@@ -418,16 +418,16 @@ named!(dictorsetmaker<StrSpan, Box<Expression>>,
418
418
419
419
named_args ! ( dictmaker( item1: DictItem ) <StrSpan , Box <Expression >>,
420
420
map!(
421
- opt!( ws4! ( alt!(
422
- delimited!( char !( ',' ) , separated_list!( char !( ',' ) , call!( Self :: dictitem) ) , opt!( ws4!( char !( ',' ) ) ) ) => { |v: Vec <_>| {
421
+ opt!( alt!(
422
+ ws4! ( delimited!( char !( ',' ) , separated_list!( char !( ',' ) , call!( Self :: dictitem) ) , opt!( ws4!( char !( ',' ) ) ) ) ) => { |v: Vec <_>| {
423
423
let mut v = v;
424
424
v. insert( 0 , item1. clone( ) ) ; // FIXME: do not clone
425
425
Box :: new( Expression :: DictLiteral ( v) )
426
426
} }
427
427
| preceded!( peek!( tuple!( tag!( "for" ) , call!( helpers:: space_sep) ) ) , call!( Self :: comp_for) ) => { |comp| {
428
428
Box :: new( Expression :: DictComp ( Box :: new( item1. clone( ) ) , comp) ) // FIXME: do not clone
429
429
} }
430
- ) ) ) ,
430
+ ) ) ,
431
431
|rest| {
432
432
match rest {
433
433
Some ( r) => r,
@@ -439,16 +439,16 @@ named_args!(dictmaker(item1: DictItem) <StrSpan, Box<Expression>>,
439
439
440
440
named_args ! ( setmaker( item1: SetItem ) <StrSpan , Box <Expression >>,
441
441
do_parse!(
442
- rest: opt!( ws4! ( alt!(
443
- delimited!( char !( ',' ) , separated_list!( char !( ',' ) , call!( Self :: setitem) ) , opt!( ws4!( char !( ',' ) ) ) ) => { |v: Vec <_>| {
442
+ rest: opt!( alt!(
443
+ ws4! ( delimited!( char !( ',' ) , separated_list!( char !( ',' ) , call!( Self :: setitem) ) , opt!( ws4!( char !( ',' ) ) ) ) ) => { |v: Vec <_>| {
444
444
let mut v = v;
445
445
v. insert( 0 , item1. clone( ) ) ; // FIXME: do not clone
446
446
Box :: new( Expression :: SetLiteral ( v) )
447
447
} }
448
448
| call!( Self :: comp_for) => { |comp| {
449
449
Box :: new( Expression :: SetComp ( Box :: new( item1. clone( ) ) , comp) ) // FIXME: do not clone
450
450
} }
451
- ) ) ) >> (
451
+ ) ) >> (
452
452
match rest {
453
453
Some ( r) => r,
454
454
None => Box :: new( Expression :: SetLiteral ( vec![ item1] ) ) ,
@@ -565,7 +565,6 @@ named!(comp_for<StrSpan, Vec<ComprehensionChunk>>,
565
565
) ;
566
566
named_args ! ( comp_for2( acc: Vec <ComprehensionChunk >) <StrSpan , Vec <ComprehensionChunk >>,
567
567
do_parse!(
568
- space_sep!( ) >>
569
568
async : map!( opt!( terminated!( tag!( "async" ) , space_sep!( ) ) ) , |o| o. is_some( ) ) >>
570
569
tag!( "for" ) >>
571
570
space_sep!( ) >>
@@ -574,6 +573,7 @@ named_args!(comp_for2(acc: Vec<ComprehensionChunk>) <StrSpan, Vec<ComprehensionC
574
573
tag!( "in" ) >>
575
574
space_sep!( ) >>
576
575
iterator: map!( call!( Self :: or_test) , |e| * e) >>
576
+ spaces!( ) >>
577
577
r: call!( Self :: opt_comp_iter, { let mut acc = acc; acc. push( ComprehensionChunk :: For { async , item, iterator } ) ; acc } ) >> (
578
578
r
579
579
)
@@ -583,7 +583,6 @@ named_args!(comp_for2(acc: Vec<ComprehensionChunk>) <StrSpan, Vec<ComprehensionC
583
583
// comp_if: 'if' test_nocond [comp_iter]
584
584
named_args ! ( comp_if( acc: Vec <ComprehensionChunk >) <StrSpan , Vec <ComprehensionChunk >>,
585
585
do_parse!(
586
- space_sep!( ) >>
587
586
tag!( "if" ) >>
588
587
space_sep!( ) >>
589
588
cond: map!( call!( Self :: test_nocond) , |e| * e) >>
@@ -1513,7 +1512,7 @@ mod tests {
1513
1512
fn test_comp_for ( ) {
1514
1513
let comp_for = ExpressionParser :: < NewlinesAreNotSpaces > :: comp_for;
1515
1514
1516
- assert_parse_eq ( comp_for ( make_strspan ( " for bar in baz" ) ) , Ok ( ( make_strspan ( "" ) , vec ! [
1515
+ assert_parse_eq ( comp_for ( make_strspan ( "for bar in baz" ) ) , Ok ( ( make_strspan ( "" ) , vec ! [
1517
1516
ComprehensionChunk :: For {
1518
1517
async : false ,
1519
1518
item: vec![
0 commit comments