cython-devel
changeset 1372:3ba99a87b30d
support parentheses around import-from names
| author | Stefan Behnel <scoder@users.berlios.de> |
|---|---|
| date | Mon Nov 24 12:47:22 2008 +0100 (3 years ago) |
| parents | 3a0a894dda7a |
| children | 7d773a2b60d2 |
| files | Cython/Compiler/Parsing.py |
line diff
1.1 --- a/Cython/Compiler/Parsing.py Sun Nov 23 20:11:42 2008 +0100
1.2 +++ b/Cython/Compiler/Parsing.py Mon Nov 24 12:47:22 2008 +0100
1.3 @@ -42,6 +42,10 @@
1.4 d.update(kwds)
1.5 return ctx
1.6
1.7 +def eat_newlines(s):
1.8 + while s.sy == 'NEWLINE':
1.9 + s.next()
1.10 +
1.11 def p_ident(s, message = "Expected an identifier"):
1.12 if s.sy == 'IDENT':
1.13 name = s.systring
1.14 @@ -1022,14 +1026,27 @@
1.15 else:
1.16 s.error("Expected 'import' or 'cimport'")
1.17 is_cimport = kind == 'cimport'
1.18 + is_parenthesized = False
1.19 if s.sy == '*':
1.20 imported_names = [(s.position(), "*", None, None)]
1.21 s.next()
1.22 else:
1.23 + if s.sy == '(':
1.24 + is_parenthesized = True
1.25 + s.next()
1.26 + eat_newlines(s)
1.27 imported_names = [p_imported_name(s, is_cimport)]
1.28 + if is_parenthesized:
1.29 + eat_newlines(s)
1.30 while s.sy == ',':
1.31 s.next()
1.32 + if is_parenthesized:
1.33 + eat_newlines(s)
1.34 imported_names.append(p_imported_name(s, is_cimport))
1.35 + if is_parenthesized:
1.36 + eat_newlines(s)
1.37 + if is_parenthesized:
1.38 + s.expect(')')
1.39 dotted_name = EncodedString(dotted_name)
1.40 if dotted_name == '__future__':
1.41 if not first_statement:
