Bang on version 1.0-1.4 Python

This commit is contained in:
rocky
2022-05-02 22:03:52 -04:00
parent 5df57489b4
commit e94e9379c0
2 changed files with 27 additions and 18 deletions

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2018, 2022 Rocky Bernstein
from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
from uncompyle6.parser import PythonParserSingle
from uncompyle6.parser import PythonParserSingle, nop_func
from uncompyle6.parsers.parse15 import Python15Parser
class Python14Parser(Python15Parser):
@@ -11,6 +11,8 @@ class Python14Parser(Python15Parser):
# Not much here yet, but will probably need to add UNARY_CALL,
# LOAD_LOCAL, SET_FUNC_ARGS
args ::= RESERVE_FAST UNPACK_ARG args_store
args_store ::= STORE_FAST*
call ::= expr tuple BINARY_CALL
expr ::= call
kv ::= DUP_TOP expr ROT_TWO LOAD_CONST STORE_SUBSCR
@@ -18,11 +20,11 @@ class Python14Parser(Python15Parser):
print_expr_stmt ::= expr PRINT_EXPR
raise_stmt2 ::= expr expr RAISE_EXCEPTION
star_args ::= RESERVE_FAST UNPACK_VARARG_1 args_store
args ::= RESERVE_FAST UNPACK_ARG args_store
stmt ::= print_expr_stmt
args_store ::= STORE_FAST+
stmt ::= args
stmt ::= print_expr_stmt
stmt ::= star_args
stmt ::= varargs
varargs ::= RESERVE_FAST UNPACK_VARARG_0 args_store
# Not strictly needed, but tidies up output
@@ -55,7 +57,14 @@ class Python14Parser(Python15Parser):
jb_pop
POP_BLOCK else_suitel COME_FROM
""")
self.check_reduce['doc_junk'] = 'tokens'
self.check_reduce["doc_junk"] = "tokens"
for i, token in enumerate(tokens):
opname = token.kind
opname_base = opname[:opname.rfind("_")]
if opname_base == "UNPACK_VARARG":
if token.attr > 1:
self.addRule(f"star_args ::= RESERVE_FAST {opname} args_store", nop_func)
def reduce_is_invalid(self, rule, ast, tokens, first, last):