[Python-3000-checkins] r54440 - in python/branches/p3yk: Grammar/Grammar Python/ast.c
georg.brandl
python-3000-checkins at python.org
Mon Mar 19 19:56:53 CET 2007
Author: georg.brandl
Date: Mon Mar 19 19:56:50 2007
New Revision: 54440
Modified:
python/branches/p3yk/Grammar/Grammar
python/branches/p3yk/Python/ast.c
Log:
"from ... import x" should not be a syntax error... make
import_stmt accept ELLIPSes and DOTs.
Modified: python/branches/p3yk/Grammar/Grammar
==============================================================================
--- python/branches/p3yk/Grammar/Grammar (original)
+++ python/branches/p3yk/Grammar/Grammar Mon Mar 19 19:56:50 2007
@@ -55,7 +55,8 @@
raise_stmt: 'raise' [test [',' test [',' test]]]
import_stmt: import_name | import_from
import_name: 'import' dotted_as_names
-import_from: ('from' ('.'* dotted_name | '.'+)
+# note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS
+import_from: ('from' (('.' | '...')* dotted_name | ('.' | '...')+)
'import' ('*' | '(' import_as_names ')' | import_as_names))
import_as_name: NAME ['as' NAME]
dotted_as_name: dotted_name ['as' NAME]
Modified: python/branches/p3yk/Python/ast.c
==============================================================================
--- python/branches/p3yk/Python/ast.c (original)
+++ python/branches/p3yk/Python/ast.c Mon Mar 19 19:56:50 2007
@@ -2406,8 +2406,8 @@
/*
import_stmt: import_name | import_from
import_name: 'import' dotted_as_names
- import_from: 'from' ('.'* dotted_name | '.') 'import'
- ('*' | '(' import_as_names ')' | import_as_names)
+ import_from: 'from' (('.' | '...')* dotted_name | ('.' | '...')+)
+ 'import' ('*' | '(' import_as_names ')' | import_as_names)
*/
int lineno;
int col_offset;
@@ -2445,6 +2445,10 @@
mod = alias_for_import_name(c, CHILD(n, idx));
idx++;
break;
+ } else if (TYPE(CHILD(n, idx)) == ELLIPSIS) {
+ /* three consecutive dots are tokenized as one ELLIPSIS */
+ ndots += 3;
+ continue;
} else if (TYPE(CHILD(n, idx)) != DOT) {
break;
}
More information about the Python-3000-checkins
mailing list