@@ -31,9 +31,9 @@ named!(pub test<StrSpan, Box<Expression>>,
31
31
| do_parse!(
32
32
left: call!( Self :: or_test) >>
33
33
right: opt!( do_parse!(
34
- ws3 !( keyword!( "if" ) ) >>
34
+ ws_auto !( keyword!( "if" ) ) >>
35
35
cond: call!( Self :: or_test) >>
36
- ws3 !( keyword!( "else" ) ) >>
36
+ ws_auto !( keyword!( "else" ) ) >>
37
37
right: call!( Self :: test) >> (
38
38
( cond, right)
39
39
)
@@ -57,7 +57,7 @@ named!(test_nocond<StrSpan, Box<Expression>>,
57
57
58
58
// lambdef: 'lambda' [varargslist] ':' test
59
59
named ! ( lambdef<StrSpan , Box <Expression >>,
60
- ws3 !( do_parse!(
60
+ ws_auto !( do_parse!(
61
61
keyword!( "lambda" ) >>
62
62
args: opt!( varargslist) >>
63
63
spaces!( ) >>
@@ -221,10 +221,10 @@ named!(atom_expr<StrSpan, Box<Expression>>,
221
221
do_parse!(
222
222
lhs: call!( Self :: atom) >>
223
223
trailers: fold_many0!(
224
- ws3 !( alt!(
225
- delimited!( char !( '(' ) , ws4 !( call!( ExpressionParser :: <NewlinesAreSpaces >:: arglist) ) , char !( ')' ) ) => { |args| Trailer :: Call ( args) }
226
- | delimited!( char !( '[' ) , ws4 !( separated_list!( char !( ',' ) , call!( ExpressionParser :: <NewlinesAreSpaces >:: subscript) ) ) , char !( ']' ) ) => { |i| Trailer :: Subscript ( i) }
227
- | preceded!( ws3 !( char !( '.' ) ) , name) => { |name| Trailer :: Attribute ( name) }
224
+ ws_auto !( alt!(
225
+ delimited!( char !( '(' ) , ws_comm !( call!( ExpressionParser :: <NewlinesAreSpaces >:: arglist) ) , char !( ')' ) ) => { |args| Trailer :: Call ( args) }
226
+ | delimited!( char !( '[' ) , ws_comm !( separated_list!( char !( ',' ) , call!( ExpressionParser :: <NewlinesAreSpaces >:: subscript) ) ) , char !( ']' ) ) => { |i| Trailer :: Subscript ( i) }
227
+ | preceded!( ws_auto !( char !( '.' ) ) , name) => { |name| Trailer :: Attribute ( name) }
228
228
) ) ,
229
229
lhs,
230
230
|acc, item| Box :: new( match item {
@@ -256,13 +256,13 @@ named!(atom<StrSpan, Box<Expression>>,
256
256
} }
257
257
| number
258
258
| name => { |n| Expression :: Name ( n) }
259
- | tuple!( char !( '[' ) , ws4 !( opt!( char !( ' ' ) ) ) , char !( ']' ) ) => { |_| Expression :: ListLiteral ( vec![ ] ) }
260
- | tuple!( char !( '{' ) , ws4 !( opt!( char !( ' ' ) ) ) , char !( '}' ) ) => { |_| Expression :: DictLiteral ( vec![ ] ) }
261
- | tuple!( char !( '(' ) , ws4 !( opt!( char !( ' ' ) ) ) , char !( ')' ) ) => { |_| Expression :: TupleLiteral ( vec![ ] ) }
262
- | delimited!( char !( '{' ) , ws4 !( map!(
259
+ | tuple!( char !( '[' ) , ws_comm !( opt!( char !( ' ' ) ) ) , char !( ']' ) ) => { |_| Expression :: ListLiteral ( vec![ ] ) }
260
+ | tuple!( char !( '{' ) , ws_comm !( opt!( char !( ' ' ) ) ) , char !( '}' ) ) => { |_| Expression :: DictLiteral ( vec![ ] ) }
261
+ | tuple!( char !( '(' ) , ws_comm !( opt!( char !( ' ' ) ) ) , char !( ')' ) ) => { |_| Expression :: TupleLiteral ( vec![ ] ) }
262
+ | delimited!( char !( '{' ) , ws_comm !( map!(
263
263
call!( ExpressionParser :: <NewlinesAreSpaces >:: dictorsetmaker) , |e: Box <_>| * e
264
264
) ) , char !( '}' ) )
265
- | map_opt!( ws3 !( delimited!( char !( '(' ) , ws4 !(
265
+ | map_opt!( ws_auto !( delimited!( char !( '(' ) , ws_comm !(
266
266
call!( ExpressionParser :: <NewlinesAreSpaces >:: testlist_comp)
267
267
) , char !( ')' ) ) ) , |ret| {
268
268
match ret {
@@ -276,10 +276,10 @@ named!(atom<StrSpan, Box<Expression>>,
276
276
TestlistCompReturn :: Single ( SetItem :: Star ( _) ) => None ,
277
277
}
278
278
} )
279
- | delimited!( char !( '(' ) , ws4 !(
279
+ | delimited!( char !( '(' ) , ws_comm !(
280
280
call!( ExpressionParser :: <NewlinesAreSpaces >:: yield_expr)
281
281
) , char !( ')' ) )
282
- | delimited!( char !( '[' ) , ws4 !(
282
+ | delimited!( char !( '[' ) , ws_comm !(
283
283
call!( ExpressionParser :: <NewlinesAreSpaces >:: testlist_comp)
284
284
) , char !( ']' ) ) => { |ret| {
285
285
match ret {
@@ -294,21 +294,21 @@ named!(atom<StrSpan, Box<Expression>>,
294
294
// testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] )
295
295
named ! ( testlist_comp<StrSpan , TestlistCompReturn >,
296
296
do_parse!(
297
- first: ws3 !( alt!(
297
+ first: ws_auto !( alt!(
298
298
call!( Self :: test) => { |e: Box <_>| SetItem :: Unique ( * e) }
299
299
| preceded!( char !( '*' ) , call!( Self :: expr) ) => { |e: Box <_>| SetItem :: Star ( * e) }
300
300
) ) >>
301
301
r: alt!(
302
302
call!( Self :: comp_for) => { |comp| TestlistCompReturn :: Comp ( Box :: new( first) , comp) }
303
303
| opt!( delimited!(
304
- ws3 !( char !( ',' ) ) ,
305
- separated_list!( ws3 !( char !( ',' ) ) ,
304
+ ws_auto !( char !( ',' ) ) ,
305
+ separated_list!( ws_auto !( char !( ',' ) ) ,
306
306
alt!(
307
307
call!( Self :: test) => { |e: Box <_>| SetItem :: Unique ( * e) }
308
308
| preceded!( char !( '*' ) , call!( Self :: expr) ) => { |e: Box <_>| SetItem :: Star ( * e) }
309
309
)
310
310
) ,
311
- ws3 !( opt!( char !( ',' ) ) )
311
+ ws_auto !( opt!( char !( ',' ) ) )
312
312
) ) => { |v: Option <Vec <SetItem >>| {
313
313
match v {
314
314
Some ( v) => {
@@ -327,11 +327,11 @@ named!(testlist_comp<StrSpan, TestlistCompReturn>,
327
327
328
328
// subscript: test | [test] ':' [test] [sliceop]
329
329
named ! ( subscript<StrSpan , Subscript >,
330
- ws4 !( alt!(
330
+ ws_comm !( alt!(
331
331
preceded!( char !( ':' ) , call!( Self :: subscript_trail, None ) )
332
332
| do_parse!(
333
333
first: call!( Self :: test) >>
334
- r: opt!( ws4 !( preceded!( char !( ':' ) , call!( Self :: subscript_trail, Some ( * first. clone( ) ) ) ) ) ) >> ( // FIXME: remove this clone
334
+ r: opt!( ws_comm !( preceded!( char !( ':' ) , call!( Self :: subscript_trail, Some ( * first. clone( ) ) ) ) ) ) >> ( // FIXME: remove this clone
335
335
r. unwrap_or( Subscript :: Simple ( * first) )
336
336
)
337
337
)
@@ -353,18 +353,18 @@ named_args!(subscript_trail(first: Option<Expression>) <StrSpan, Subscript>,
353
353
354
354
// exprlist: (expr|star_expr) (',' (expr|star_expr))* [',']
355
355
named ! ( pub exprlist<StrSpan , Vec <Expression >>,
356
- separated_nonempty_list!( ws3 !( char !( ',' ) ) , map!( alt!( call!( Self :: expr) |call!( Self :: star_expr) ) , |e| * e) )
356
+ separated_nonempty_list!( ws_auto !( char !( ',' ) ) , map!( alt!( call!( Self :: expr) |call!( Self :: star_expr) ) , |e| * e) )
357
357
) ;
358
358
359
359
// testlist: test (',' test)* [',']
360
360
named ! ( pub testlist<StrSpan , Vec <Expression >>,
361
- separated_nonempty_list!( ws3 !( char !( ',' ) ) , map!( call!( Self :: test) , |e| * e) )
361
+ separated_nonempty_list!( ws_auto !( char !( ',' ) ) , map!( call!( Self :: test) , |e| * e) )
362
362
) ;
363
363
364
364
// FIXME: the code of this function is unreadable
365
365
named ! ( pub possibly_empty_testlist<StrSpan , Vec <Expression >>,
366
366
alt!(
367
- tuple!( separated_nonempty_list!( ws3 !( char !( ',' ) ) , map!( call!( Self :: test) , |e: Box <_>| * e) ) , opt!( ws3 !( char !( ',' ) ) ) ) => { |( mut e, comma) : ( Vec <_>, _) |
367
+ tuple!( separated_nonempty_list!( ws_auto !( char !( ',' ) ) , map!( call!( Self :: test) , |e: Box <_>| * e) ) , opt!( ws_auto !( char !( ',' ) ) ) ) => { |( mut e, comma) : ( Vec <_>, _) |
368
368
match ( e. len( ) , comma) {
369
369
( 0 , _) => unreachable!( ) ,
370
370
( 1 , Some ( _) ) => vec![ Expression :: TupleLiteral ( vec![ SetItem :: Unique ( e. remove( 0 ) ) ] ) ] , // The remove can't panic, because len == 1
@@ -389,7 +389,7 @@ impl ExpressionParser<NewlinesAreSpaces> {
389
389
// ((test | star_expr)
390
390
// (comp_for | (',' (test | star_expr))* [','])) )
391
391
named ! ( dictorsetmaker<StrSpan , Box <Expression >>,
392
- ws4 !( alt!(
392
+ ws_comm !( alt!(
393
393
do_parse!(
394
394
tag!( "**" ) >>
395
395
e: map!( call!( Self :: expr) , |e: Box <_>| DictItem :: Star ( * e) ) >>
@@ -421,7 +421,7 @@ named!(dictorsetmaker<StrSpan, Box<Expression>>,
421
421
named_args ! ( dictmaker( item1: DictItem ) <StrSpan , Box <Expression >>,
422
422
map!(
423
423
opt!( alt!(
424
- ws4 !( delimited!( char !( ',' ) , separated_list!( char !( ',' ) , call!( Self :: dictitem) ) , opt!( ws4 !( char !( ',' ) ) ) ) ) => { |v: Vec <_>| {
424
+ ws_comm !( delimited!( char !( ',' ) , separated_list!( char !( ',' ) , call!( Self :: dictitem) ) , opt!( ws_comm !( char !( ',' ) ) ) ) ) => { |v: Vec <_>| {
425
425
let mut v = v;
426
426
v. insert( 0 , item1. clone( ) ) ; // FIXME: do not clone
427
427
Box :: new( Expression :: DictLiteral ( v) )
@@ -442,7 +442,7 @@ named_args!(dictmaker(item1: DictItem) <StrSpan, Box<Expression>>,
442
442
named_args ! ( setmaker( item1: SetItem ) <StrSpan , Box <Expression >>,
443
443
do_parse!(
444
444
rest: opt!( alt!(
445
- ws4 !( delimited!( char !( ',' ) , separated_list!( char !( ',' ) , call!( Self :: setitem) ) , opt!( ws4 !( char !( ',' ) ) ) ) ) => { |v: Vec <_>| {
445
+ ws_comm !( delimited!( char !( ',' ) , separated_list!( char !( ',' ) , call!( Self :: setitem) ) , opt!( ws_comm !( char !( ',' ) ) ) ) ) => { |v: Vec <_>| {
446
446
let mut v = v;
447
447
v. insert( 0 , item1. clone( ) ) ; // FIXME: do not clone
448
448
Box :: new( Expression :: SetLiteral ( v) )
@@ -460,14 +460,14 @@ named_args!(setmaker(item1: SetItem) <StrSpan, Box<Expression>>,
460
460
) ;
461
461
462
462
named ! ( dictitem<StrSpan , DictItem >,
463
- ws4 !( alt!(
463
+ ws_comm !( alt!(
464
464
preceded!( tag!( "**" ) , call!( Self :: expr) ) => { |e: Box <_>| DictItem :: Star ( * e) }
465
465
| tuple!( call!( Self :: test) , char !( ':' ) , call!( Self :: test) ) => { |( e1, _, e2) : ( Box <_>, _, Box <_>) | DictItem :: Unique ( * e1, * e2) }
466
466
) )
467
467
) ;
468
468
469
469
named ! ( setitem<StrSpan , SetItem >,
470
- ws4 !( alt!(
470
+ ws_comm !( alt!(
471
471
preceded!( tag!( "*" ) , call!( Self :: expr) ) => { |e: Box <_>| SetItem :: Star ( * e) }
472
472
|call!( Self :: test) => { |e: Box <_>| SetItem :: Unique ( * e) }
473
473
) )
@@ -489,8 +489,8 @@ impl<ANS: AreNewlinesSpaces> ExpressionParser<ANS> {
489
489
// '**' test |
490
490
// '*' test )
491
491
named ! ( pub arglist<StrSpan , Vec <Argument >>,
492
- ws4 !( do_parse!(
493
- args: separated_list!( ws4 !( char !( ',' ) ) ,
492
+ ws_comm !( do_parse!(
493
+ args: separated_list!( ws_comm !( char !( ',' ) ) ,
494
494
alt!(
495
495
preceded!( tag!( "**" ) , call!( Self :: test) ) => { |kwargs: Box <_>| Argument :: Kwargs ( * kwargs) }
496
496
| preceded!( char !( '*' ) , call!( Self :: test) ) => { |args: Box <_>| Argument :: Starargs ( * args) }
@@ -502,7 +502,7 @@ named!(pub arglist<StrSpan, Vec<Argument>>,
502
502
)
503
503
| do_parse!(
504
504
test1: call!( Self :: test) >>
505
- next: opt!( ws4 !( alt!( call!( Self :: comp_for) ) ) ) >> (
505
+ next: opt!( ws_comm !( alt!( call!( Self :: comp_for) ) ) ) >> (
506
506
match next {
507
507
Some ( e) => Argument :: Positional ( Expression :: Generator ( Box :: new( SetItem :: Unique ( * test1) ) , e) ) ,
508
508
None => Argument :: Positional ( * test1)
@@ -511,7 +511,7 @@ named!(pub arglist<StrSpan, Vec<Argument>>,
511
511
)
512
512
)
513
513
) >>
514
- opt!( ws4 !( char !( ',' ) ) ) >>
514
+ opt!( ws_comm !( char !( ',' ) ) ) >>
515
515
( args)
516
516
) )
517
517
) ;
@@ -570,10 +570,10 @@ named_args!(comp_if(acc: Vec<ComprehensionChunk>) <StrSpan, Vec<ComprehensionChu
570
570
// yield_expr: 'yield' [yield_arg]
571
571
// yield_arg: 'from' test | testlist
572
572
named ! ( pub yield_expr<StrSpan , Expression >,
573
- ws3 !( preceded!(
573
+ ws_auto !( preceded!(
574
574
keyword!( "yield" ) ,
575
- ws3 !( alt!(
576
- preceded!( ws3 !( keyword!( "from" ) ) , call!( Self :: test) ) => { |e| Expression :: YieldFrom ( e) }
575
+ ws_auto !( alt!(
576
+ preceded!( ws_auto !( keyword!( "from" ) ) , call!( Self :: test) ) => { |e| Expression :: YieldFrom ( e) }
577
577
| call!( Self :: testlist) => { |e| Expression :: Yield ( e) }
578
578
| tag!( "" ) => { |_| Expression :: Yield ( Vec :: new( ) ) }
579
579
) )
0 commit comments