Commit 305e7ba8 authored by Stefan Behnel's avatar Stefan Behnel

Index: Cython/Compiler/Parsing.py

parent 0f9ba0d2
...@@ -497,20 +497,16 @@ def p_subscript(s): ...@@ -497,20 +497,16 @@ def p_subscript(s):
# 1, 2 or 3 ExprNodes, depending on how # 1, 2 or 3 ExprNodes, depending on how
# many slice elements were encountered. # many slice elements were encountered.
pos = s.position() pos = s.position()
if s.sy == '.': start = p_slice_element(s, (':',))
expect_ellipsis(s) if s.sy != ':':
return [ExprNodes.EllipsisNode(pos)] return [start]
else: s.next()
start = p_slice_element(s, (':',)) stop = p_slice_element(s, (':', ',', ']'))
if s.sy != ':': if s.sy != ':':
return [start] return [start, stop]
s.next() s.next()
stop = p_slice_element(s, (':', ',', ']')) step = p_slice_element(s, (':', ',', ']'))
if s.sy != ':': return [start, stop, step]
return [start, stop]
s.next()
step = p_slice_element(s, (':', ',', ']'))
return [start, stop, step]
def p_slice_element(s, follow_set): def p_slice_element(s, follow_set):
# Simple expression which may be missing iff # Simple expression which may be missing iff
...@@ -569,6 +565,9 @@ def p_atom(s): ...@@ -569,6 +565,9 @@ def p_atom(s):
return p_dict_or_set_maker(s) return p_dict_or_set_maker(s)
elif sy == '`': elif sy == '`':
return p_backquote_expr(s) return p_backquote_expr(s)
elif sy == '.':
expect_ellipsis(s)
return ExprNodes.EllipsisNode(pos)
elif sy == 'INT': elif sy == 'INT':
value = s.systring value = s.systring
s.next() s.next()
......
#from ... import foo
print ...
def test():
x = ...
assert x is Ellipsis
"""
>>> test()
"""
def test():
x = ...
assert x is Ellipsis
d = {}
d[...] = 1
assert d[...] == 1
del d[...]
assert ... not in d
d[..., ...] = 1
assert d[..., ...] == 1
assert d[..., Ellipsis] == 1
assert (Ellipsis, Ellipsis) in d
del d[..., ...]
assert (Ellipsis, Ellipsis) not in d
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment