@@ -32,9 +32,9 @@ named!(pub test<StrSpan, Box<Expression>>,
3232 left: call!( Self :: or_test) >>
3333 right: opt!( do_parse!(
3434 ws_auto!( keyword!( "if" ) ) >>
35- cond: call!( Self :: or_test) >>
35+ cond: return_error! ( call!( Self :: or_test) ) >>
3636 ws_auto!( keyword!( "else" ) ) >>
37- right: call!( Self :: test) >> (
37+ right: return_error! ( call!( Self :: test) ) >> (
3838 ( cond, right)
3939 )
4040 ) ) >> (
@@ -57,28 +57,26 @@ named!(test_nocond<StrSpan, Box<Expression>>,
5757
5858// lambdef: 'lambda' [varargslist] ':' test
5959named ! ( lambdef<StrSpan , Box <Expression >>,
60- ws_auto!( do_parse!(
61- keyword!( "lambda" ) >>
60+ ws_auto!( preceded!( keyword!( "lambda" ) , return_error!( do_parse!(
6261 args: opt!( varargslist) >>
6362 spaces!( ) >>
6463 char !( ':' ) >>
6564 spaces!( ) >>
6665 code: call!( Self :: test) >> (
6766 Box :: new( Expression :: Lambdef ( args. unwrap_or_default( ) , code) )
6867 )
69- ) )
68+ ) ) ) )
7069) ;
7170
7271// lambdef_nocond: 'lambda' [varargslist] ':' test_nocond
7372named ! ( lambdef_nocond<StrSpan , Box <Expression >>,
74- do_parse!(
75- keyword!( "lambda" ) >>
73+ ws_auto!( preceded!( keyword!( "lambda" ) , return_error!( do_parse!(
7674 args: opt!( varargslist) >>
7775 char !( ':' ) >>
7876 code: call!( Self :: test_nocond) >> (
7977 Box :: new( Expression :: Lambdef ( args. unwrap_or_default( ) , code) )
8078 )
81- )
79+ ) ) ) )
8280) ;
8381
8482} // End ExpressionParser
@@ -426,7 +424,7 @@ named_args!(dictmaker(item1: DictItem) <StrSpan, Box<Expression>>,
426424 v. insert( 0 , item1. clone( ) ) ; // FIXME: do not clone
427425 Box :: new( Expression :: DictLiteral ( v) )
428426 } }
429- | preceded!( peek!( keyword!( "for" ) ) , call!( Self :: comp_for) ) => { |comp| {
427+ | preceded!( peek!( keyword!( "for" ) ) , return_error! ( call!( Self :: comp_for) ) ) => { |comp| {
430428 Box :: new( Expression :: DictComp ( Box :: new( item1. clone( ) ) , comp) ) // FIXME: do not clone
431429 } }
432430 ) ) ,
@@ -529,7 +527,7 @@ named_args!(comp_iter(acc: Vec<ComprehensionChunk>) <StrSpan, Vec<ComprehensionC
529527) ;
530528
531529named_args ! ( opt_comp_iter( acc: Vec <ComprehensionChunk >) <StrSpan , Vec <ComprehensionChunk >>,
532- map!( opt!( call!( Self :: comp_iter, acc. clone( ) ) ) , |r| r. unwrap_or( acc) ) // FIXME: do not clone
530+ return_error! ( map!( opt!( call!( Self :: comp_iter, acc. clone( ) ) ) , |r| r. unwrap_or( acc) ) ) // FIXME: do not clone
533531) ;
534532
535533// comp_for: [ASYNC] 'for' exprlist 'in' or_test [comp_iter]
@@ -541,11 +539,11 @@ named_args!(comp_for2(acc: Vec<ComprehensionChunk>) <StrSpan, Vec<ComprehensionC
541539 async : map!( opt!( terminated!( tag!( "async" ) , space_sep!( ) ) ) , |o| o. is_some( ) ) >>
542540 keyword!( "for" ) >>
543541 spaces!( ) >>
544- item: call!( Self :: exprlist) >>
542+ item: return_error! ( call!( Self :: exprlist) ) >>
545543 spaces!( ) >>
546544 keyword!( "in" ) >>
547545 spaces!( ) >>
548- iterator: map!( call!( Self :: or_test) , |e| * e) >>
546+ iterator: return_error! ( map!( call!( Self :: or_test) , |e| * e) ) >>
549547 spaces!( ) >>
550548 r: call!( Self :: opt_comp_iter, { let mut acc = acc; acc. push( ComprehensionChunk :: For { async , item, iterator } ) ; acc } ) >> (
551549 r
@@ -558,7 +556,7 @@ named_args!(comp_if(acc: Vec<ComprehensionChunk>) <StrSpan, Vec<ComprehensionChu
558556 do_parse!(
559557 keyword!( "if" ) >>
560558 spaces!( ) >>
561- cond: map!( call!( Self :: test_nocond) , |e| * e) >>
559+ cond: return_error! ( map!( call!( Self :: test_nocond) , |e| * e) ) >>
562560 spaces!( ) >>
563561 r: call!( Self :: opt_comp_iter, { let mut acc = acc; acc. push( ComprehensionChunk :: If { cond } ) ; acc } ) >> (
564562 r
0 commit comments