@@ -5,7 +5,7 @@ use nom::IResult;
5
5
use ast:: * ;
6
6
use expressions:: ExpressionParser ;
7
7
use helpers:: * ;
8
- use statements:: { block, ImportParser } ;
8
+ use statements:: { block, func_body_suite , ImportParser } ;
9
9
10
10
/*********************************************************************
11
11
* Decorators
@@ -46,7 +46,7 @@ named_args!(pub decorated(indent: usize) <StrSpan, CompoundStatement>,
46
46
*********************************************************************/
47
47
48
48
// async_funcdef: 'async' funcdef
49
- // funcdef: 'def' NAME parameters ['->' test] ':' suite
49
+ // funcdef: 'def' NAME parameters ['->' test] ':' [TYPE_COMMENT] func_body_suite
50
50
named_args ! ( funcdef( indent: usize , decorators: Vec <Decorator >) <StrSpan , CompoundStatement >,
51
51
do_parse!(
52
52
indent!( indent) >>
@@ -57,7 +57,7 @@ named_args!(funcdef(indent: usize, decorators: Vec<Decorator>) <StrSpan, Compoun
57
57
parameters: ws_nonl!( parameters) >>
58
58
return_type: opt!( ws_nonl!( preceded!( tag!( "->" ) , call!( ExpressionParser :: <NewlinesAreNotSpaces >:: test) ) ) ) >>
59
59
ws_nonl!( char !( ':' ) ) >>
60
- code: call!( block , indent) >> (
60
+ code: call!( func_body_suite , indent) >> (
61
61
CompoundStatement :: Funcdef ( Funcdef {
62
62
async : async . is_some( ) , decorators, name, parameters, return_type: return_type. map( |t| * t) , code
63
63
} )
@@ -195,11 +195,11 @@ named!(parameters<StrSpan, TypedArgsList>,
195
195
map!( delimited!( char !( '(' ) , opt!( ws_comm!( typedargslist) ) , char !( ')' ) ) , |o| o. unwrap_or_default( ) )
196
196
) ;
197
197
198
- // typedargslist: (tfpdef ['=' test] (',' tfpdef ['=' test])* [',' [
199
- // '*' [tfpdef] (',' tfpdef ['=' test])* [',' ['**' tfpdef [',']]]
200
- // | '**' tfpdef [',']]]
201
- // | '*' [tfpdef] (',' tfpdef ['=' test])* [',' ['**' tfpdef [',']]]
202
- // | '**' tfpdef [','])
198
+ // typedargslist: (tfpdef ['=' test] (',' [TYPE_COMMENT] tfpdef ['=' test])* (TYPE_COMMENT | [',' [TYPE_COMMENT] [
199
+ // '*' [tfpdef] (',' [TYPE_COMMENT] tfpdef ['=' test])* (TYPE_COMMENT | [',' [TYPE_COMMENT] [ '**' tfpdef [','] [TYPE_COMMENT]]])
200
+ // | '**' tfpdef [','] [TYPE_COMMENT]]])
201
+ // | '*' [tfpdef] (',' [TYPE_COMMENT] tfpdef ['=' test])* (TYPE_COMMENT | [',' [TYPE_COMMENT] [ '**' tfpdef [','] [TYPE_COMMENT]]])
202
+ // | '**' tfpdef [','] [TYPE_COMMENT ])
203
203
//
204
204
// tfpdef: NAME [':' test]
205
205
//
0 commit comments