mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Patch #1550786: ellipsis literal.
This commit is contained in:
parent
7cae87ca7b
commit
52318d6215
19 changed files with 140 additions and 141 deletions
|
@ -427,19 +427,6 @@ class Div(Node):
|
|||
def __repr__(self):
|
||||
return "Div((%s, %s))" % (repr(self.left), repr(self.right))
|
||||
|
||||
class Ellipsis(Node):
|
||||
def __init__(self, lineno=None):
|
||||
self.lineno = lineno
|
||||
|
||||
def getChildren(self):
|
||||
return ()
|
||||
|
||||
def getChildNodes(self):
|
||||
return ()
|
||||
|
||||
def __repr__(self):
|
||||
return "Ellipsis()"
|
||||
|
||||
class FloorDiv(Node):
|
||||
def __init__(self, (left, right), lineno=None):
|
||||
self.left = left
|
||||
|
|
|
@ -1214,9 +1214,6 @@ class CodeGenerator:
|
|||
|
||||
# object constructors
|
||||
|
||||
def visitEllipsis(self, node):
|
||||
self.emit('LOAD_CONST', Ellipsis)
|
||||
|
||||
def visitTuple(self, node):
|
||||
self.set_lineno(node)
|
||||
for elt in node.nodes:
|
||||
|
|
|
@ -113,6 +113,7 @@ class Transformer:
|
|||
token.LBRACE: self.atom_lbrace,
|
||||
token.NUMBER: self.atom_number,
|
||||
token.STRING: self.atom_string,
|
||||
token.DOT: self.atom_ellipsis,
|
||||
token.NAME: self.atom_name,
|
||||
}
|
||||
self.encoding = None
|
||||
|
@ -747,6 +748,9 @@ class Transformer:
|
|||
k += self.decode_literal(node[1])
|
||||
return Const(k, lineno=nodelist[0][2])
|
||||
|
||||
def atom_ellipsis(self, nodelist):
|
||||
return Const(Ellipsis, lineno=nodelist[0][2])
|
||||
|
||||
def atom_name(self, nodelist):
|
||||
return Name(nodelist[0][1], lineno=nodelist[0][2])
|
||||
|
||||
|
@ -1276,11 +1280,9 @@ class Transformer:
|
|||
lineno=extractLineNo(nodelist))
|
||||
|
||||
def com_subscript(self, node):
|
||||
# slice_item: expression | proper_slice | ellipsis
|
||||
# slice_item: expression | proper_slice
|
||||
ch = node[1]
|
||||
t = ch[0]
|
||||
if t == token.DOT and node[2][0] == token.DOT:
|
||||
return Ellipsis()
|
||||
if t == token.COLON or len(node) > 2:
|
||||
return self.com_sliceobj(node)
|
||||
return self.com_node(ch)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue