@@ -405,6 +405,47 @@ fn format_typed_param(param: &(Name, Option<Expression>, Option<Expression>)) ->
405
405
s
406
406
}
407
407
408
+ fn format_untyped_params ( param : & UntypedArgsList ) -> String {
409
+ let UntypedArgsList { ref positional_args, ref star_args, ref keyword_args, ref star_kwargs } = * param;
410
+ let mut s = String :: new ( ) ;
411
+
412
+ s. push_str ( & comma_join ( positional_args. iter ( ) . map ( format_untyped_param) ) ) ;
413
+ if positional_args. len ( ) > 0 {
414
+ s. push_str ( ", " ) ;
415
+ }
416
+
417
+ match star_args {
418
+ StarParams :: No => ( ) ,
419
+ StarParams :: Anonymous => s. push_str ( "*, " ) ,
420
+ StarParams :: Named ( ref name) => {
421
+ s. push_str ( name) ;
422
+ } ,
423
+ }
424
+
425
+ s. push_str ( & comma_join ( keyword_args. iter ( ) . map ( format_untyped_param) ) ) ;
426
+ if keyword_args. len ( ) > 0 {
427
+ s. push_str ( ", " ) ;
428
+ }
429
+
430
+ if let Some ( name) = star_kwargs {
431
+ s. push_str ( "**" ) ;
432
+ s. push_str ( name) ;
433
+ s. push_str ( ", " ) ;
434
+ }
435
+
436
+ s
437
+ }
438
+
439
+ fn format_untyped_param ( param : & ( Name , Option < Expression > ) ) -> String {
440
+ let ( name, value) = param;
441
+ let mut s = name. to_string ( ) ;
442
+ if let Some ( ref value) = value {
443
+ s. push_str ( "=" ) ;
444
+ s. push_str ( & format_expr ( value) ) ;
445
+ }
446
+ s
447
+ }
448
+
408
449
fn format_subscript ( sub : & Subscript ) -> String {
409
450
match * sub {
410
451
Subscript :: Simple ( ref e) => format_expr ( e) ,
@@ -496,9 +537,11 @@ fn format_expr(e: &Expression) -> String {
496
537
format ! ( "({}) if ({}) else ({})" , format_expr( e1) , format_expr( e2) , format_expr( e3) ) ,
497
538
Expression :: Star ( ref e) =>
498
539
format ! ( "*{}" , format_expr( e) ) ,
499
- Expression :: Yield ( _) => unimplemented ! ( ) ,
500
- Expression :: YieldFrom ( _) => unimplemented ! ( ) ,
501
- Expression :: Lambdef ( _, _) => unimplemented ! ( ) ,
540
+ Expression :: Yield ( ref items) =>
541
+ format ! ( "yield {}" , comma_join( items. iter( ) . map( format_expr) ) ) ,
542
+ Expression :: YieldFrom ( ref iterable) => format ! ( "yield from {}" , format_expr( iterable) ) ,
543
+ Expression :: Lambdef ( ref params, ref body) =>
544
+ format ! ( "lambda {}: {}" , format_untyped_params( params) , format_expr( body) )
502
545
}
503
546
}
504
547
0 commit comments