File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,7 +55,8 @@ yield_stmt: yield_expr
5555raise_stmt: 'raise' [test [',' test [',' test]]]
5656import_stmt: import_name | import_from
5757import_name: 'import' dotted_as_names
58- import_from: ('from' ('.'* dotted_name | '.'+)
58+ # note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS
59+ import_from: ('from' (('.' | '...')* dotted_name | ('.' | '...')+)
5960 'import' ('*' | '(' import_as_names ')' | import_as_names))
6061import_as_name: NAME ['as' NAME]
6162dotted_as_name: dotted_name ['as' NAME]
Original file line number Diff line number Diff line change @@ -2406,8 +2406,8 @@ ast_for_import_stmt(struct compiling *c, const node *n)
24062406 /*
24072407 import_stmt: import_name | import_from
24082408 import_name: 'import' dotted_as_names
2409- import_from: 'from' ('.'* dotted_name | '.') 'import'
2410- ('*' | '(' import_as_names ')' | import_as_names)
2409+ import_from: 'from' (( '.' | '...') * dotted_name | ( '.' | '...')+)
2410+ 'import' ('*' | '(' import_as_names ')' | import_as_names)
24112411 */
24122412 int lineno ;
24132413 int col_offset ;
@@ -2445,6 +2445,10 @@ ast_for_import_stmt(struct compiling *c, const node *n)
24452445 mod = alias_for_import_name (c , CHILD (n , idx ));
24462446 idx ++ ;
24472447 break ;
2448+ } else if (TYPE (CHILD (n , idx )) == ELLIPSIS ) {
2449+ /* three consecutive dots are tokenized as one ELLIPSIS */
2450+ ndots += 3 ;
2451+ continue ;
24482452 } else if (TYPE (CHILD (n , idx )) != DOT ) {
24492453 break ;
24502454 }
You can’t perform that action at this time.
0 commit comments