Handle PyPy JUMP_IF_NOT_DEBUG

Update README.rst to note PyPY and reorganize a little
This commit is contained in:
rocky
2016-07-25 09:06:13 -04:00
parent 285444e19a
commit 476eb50868
9 changed files with 50 additions and 20 deletions

View File

@@ -250,6 +250,10 @@ class Python3Parser(PythonParser):
def p_misc3(self, args):
"""
try_middle ::= JUMP_FORWARD COME_FROM except_stmts END_FINALLY NOP COME_FROM
for_block ::= l_stmts
iflaststmtl ::= testexpr c_stmts_opt
iflaststmt ::= testexpr c_stmts_opt34
c_stmts_opt34 ::= JUMP_BACK JUMP_ABSOLUTE c_stmts_opt
"""
def p_jump3(self, args):
@@ -298,14 +302,6 @@ class Python3Parser(PythonParser):
binary_subscr2 ::= expr expr DUP_TOP_TWO BINARY_SUBSCR
'''
def p_misc3(self, args):
'''
for_block ::= l_stmts
iflaststmtl ::= testexpr c_stmts_opt
iflaststmt ::= testexpr c_stmts_opt34
c_stmts_opt34 ::= JUMP_BACK JUMP_ABSOLUTE c_stmts_opt
'''
@staticmethod
def call_fn_name(token):
"""Customize CALL_FUNCTION to add the number of positional arguments"""
@@ -475,6 +471,14 @@ class Python3Parser(PythonParser):
self.add_unique_rule("call_function ::= expr CALL_METHOD",
opname, token.attr, customize)
continue
elif opname == 'JUMP_IF_NOT_DEBUG':
self.add_unique_rule(
"stmt ::= assert_pypy", opname, v, customize)
self.add_unique_rule(
"assert_pypy ::= JUMP_IF_NOT_DEBUG assert_expr jmp_true "
"LOAD_ASSERT RAISE_VARARGS_1 COME_FROM",
opname, token.attr, customize)
continue
elif opname_base == 'BUILD_MAP':
kvlist_n = "kvlist_%s" % token.attr
if self.version >= 3.5: