back off of build_slice{2,3} ->slice{2,3}

There is another slice rule that interferes with this.
This commit is contained in:
rocky
2017-11-25 21:49:03 -05:00
parent b7003914c9
commit 566ef37ecc
3 changed files with 11 additions and 11 deletions

View File

@@ -317,15 +317,15 @@ class Python2Parser(PythonParser):
slice_num = token.attr
if slice_num == 2:
self.add_unique_rules([
'expr ::= slice2',
'slice2 ::= expr expr BUILD_SLICE_2'
'expr ::= build_slice2',
'build_slice2 ::= expr expr BUILD_SLICE_2'
], customize)
else:
assert slice_num == 3, ("BUILD_SLICE value must be 2 or 3; is %s" %
slice_num)
self.add_unique_rules([
'expr ::= slice3',
'slice3 ::= expr expr expr BUILD_SLICE_3',
'expr ::= build_slice3',
'build_slice3 ::= expr expr expr BUILD_SLICE_3',
], customize)
continue
elif opname_base in ('CALL_FUNCTION', 'CALL_FUNCTION_VAR',

View File

@@ -741,14 +741,14 @@ class Python3Parser(PythonParser):
elif opname_base == 'BUILD_SLICE':
if token.attr == 2:
self.add_unique_rules([
'expr ::= slice2',
'slice2 ::= expr expr BUILD_SLICE_2'
'expr ::= build_slice2',
'build_slice2 ::= expr expr BUILD_SLICE_2'
], customize)
else:
assert token.attr == 3, "BUILD_SLICE value must be 2 or 3; is %s" % v
self.add_unique_rules([
'expr ::= slice3',
'slice3 ::= expr expr expr BUILD_SLICE_3',
'expr ::= build_slice3',
'build_slice3 ::= expr expr expr BUILD_SLICE_3',
], customize)
elif opname_base == 'CALL_METHOD':
# PyPy only - DRY with parse2

View File

@@ -714,7 +714,7 @@ class SourceWalker(GenericASTTraversal, object):
assert False, "dunno about this python version"
self.prune() # stop recursing
def n_slice3(self, node):
def n_build_slice3(self, node):
p = self.prec
self.prec = 100
if not node[0].isNone():
@@ -728,7 +728,7 @@ class SourceWalker(GenericASTTraversal, object):
self.prec = p
self.prune() # stop recursing
def n_slice2(self, node):
def n_build_slice2(self, node):
p = self.prec
self.prec = 100
if not node[0].isNone():
@@ -1744,7 +1744,7 @@ class SourceWalker(GenericASTTraversal, object):
# if a tuple item is some sort of slice.
no_parens = False
for n in node:
if n == 'expr' and n[0].kind.startswith('slice'):
if n == 'expr' and n[0].kind.startswith('build_slice'):
no_parens = True
break
pass