localize 2 and 3 argument BUILD_SLICE...

Nontermninal name matches AST anme now. Add test.
This commit is contained in:
rocky
2017-11-25 21:07:43 -05:00
parent 3d7b160e30
commit b7003914c9
10 changed files with 53 additions and 17 deletions

View File

@@ -313,6 +313,21 @@ class Python2Parser(PythonParser):
"mapexpr ::= %s %s" % (opname, kvlist_n)
], customize)
continue
elif opname_base == 'BUILD_SLICE':
slice_num = token.attr
if slice_num == 2:
self.add_unique_rules([
'expr ::= slice2',
'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',
], customize)
continue
elif opname_base in ('CALL_FUNCTION', 'CALL_FUNCTION_VAR',
'CALL_FUNCTION_VAR_KW', 'CALL_FUNCTION_KW'):
args_pos = (v & 0xff) # positional parameters