diff options
author | Georg Brandl <georg@python.org> | 2006-09-06 07:06:08 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-09-06 07:06:08 (GMT) |
commit | 52318d6215f9f9626d38a9b81b52d411dbbdb36a (patch) | |
tree | 72563f6321f9265fb9d77702ee729e68048bdd07 /Lib | |
parent | 7cae87ca7b0a3a7ce497cbd335c8ec82fe680476 (diff) | |
download | cpython-52318d6215f9f9626d38a9b81b52d411dbbdb36a.zip cpython-52318d6215f9f9626d38a9b81b52d411dbbdb36a.tar.gz cpython-52318d6215f9f9626d38a9b81b52d411dbbdb36a.tar.bz2 |
Patch #1550786: ellipsis literal.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/compiler/ast.py | 13 | ||||
-rw-r--r-- | Lib/compiler/pycodegen.py | 3 | ||||
-rw-r--r-- | Lib/compiler/transformer.py | 8 | ||||
-rw-r--r-- | Lib/test/output/test_grammar | 1 | ||||
-rw-r--r-- | Lib/test/test_grammar.py | 6 |
5 files changed, 12 insertions, 19 deletions
diff --git a/Lib/compiler/ast.py b/Lib/compiler/ast.py index b06531f..0be36a4 100644 --- a/Lib/compiler/ast.py +++ b/Lib/compiler/ast.py @@ -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 diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py index e0c3a10..83d0481 100644 --- a/Lib/compiler/pycodegen.py +++ b/Lib/compiler/pycodegen.py @@ -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: diff --git a/Lib/compiler/transformer.py b/Lib/compiler/transformer.py index 4f2107f..0ffb597 100644 --- a/Lib/compiler/transformer.py +++ b/Lib/compiler/transformer.py @@ -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) diff --git a/Lib/test/output/test_grammar b/Lib/test/output/test_grammar index 8be2a1f..5033276 100644 --- a/Lib/test/output/test_grammar +++ b/Lib/test/output/test_grammar @@ -7,6 +7,7 @@ test_grammar 1.1.2.2 Long integers 1.1.2.3 Floating point 1.1.3 String literals +1.1.4 Ellipsis literal 1.2 Grammar single_input file_input diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index 6e9b204..eb93283 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -125,6 +125,12 @@ the \'lazy\' dog.\n\ '; verify(x == y) +print '1.1.4 Ellipsis literal' + +x = ... +verify(x == Ellipsis) + + print '1.2 Grammar' print 'single_input' # NEWLINE | simple_stmt | compound_stmt NEWLINE |