You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Update copyright
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2016-2020, 2023 Rocky Bernstein
|
# Copyright (c) 2016-2020, 2023-2024 Rocky Bernstein
|
||||||
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
|
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
|
||||||
# Copyright (c) 2000-2002 by hartmut Goebel <hartmut@goebel.noris.de>
|
# Copyright (c) 2000-2002 by hartmut Goebel <hartmut@goebel.noris.de>
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2016-2017, 2022 Rocky Bernstein
|
# Copyright (c) 2016-2017, 2022, 2024 Rocky Bernstein
|
||||||
"""
|
"""
|
||||||
spark grammar differences over Python 3.2 for Python 3.1.
|
spark grammar differences over Python 3.2 for Python 3.1.
|
||||||
"""
|
"""
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2016-2017, 2022 Rocky Bernstein
|
# Copyright (c) 2016-2017, 2022-2024 Rocky Bernstein
|
||||||
"""
|
"""
|
||||||
spark grammar differences over Python 3 for Python 3.2.
|
spark grammar differences over Python 3 for Python 3.2.
|
||||||
"""
|
"""
|
||||||
@@ -84,7 +84,7 @@ class Python32Parser(Python3Parser):
|
|||||||
for i, token in enumerate(tokens):
|
for i, token in enumerate(tokens):
|
||||||
opname = token.kind
|
opname = token.kind
|
||||||
if opname.startswith("MAKE_FUNCTION_A"):
|
if opname.startswith("MAKE_FUNCTION_A"):
|
||||||
args_pos, args_kw, annotate_args = token.attr
|
args_pos, _, annotate_args = token.attr
|
||||||
# Check that there are 2 annotated params?
|
# Check that there are 2 annotated params?
|
||||||
rule = (
|
rule = (
|
||||||
"mkfunc_annotate ::= %s%sannotate_tuple "
|
"mkfunc_annotate ::= %s%sannotate_tuple "
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2017-2018 Rocky Bernstein
|
# Copyright (c) 2017-2018, 2022-2024 Rocky Bernstein
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -21,7 +21,6 @@ from uncompyle6.parsers.parse33 import Python33Parser
|
|||||||
|
|
||||||
|
|
||||||
class Python34Parser(Python33Parser):
|
class Python34Parser(Python33Parser):
|
||||||
|
|
||||||
def p_misc34(self, args):
|
def p_misc34(self, args):
|
||||||
"""
|
"""
|
||||||
expr ::= LOAD_ASSERT
|
expr ::= LOAD_ASSERT
|
||||||
@@ -57,36 +56,45 @@ class Python34Parser(Python33Parser):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def customize_grammar_rules(self, tokens, customize):
|
def customize_grammar_rules(self, tokens, customize):
|
||||||
self.remove_rules("""
|
self.remove_rules(
|
||||||
|
"""
|
||||||
yield_from ::= expr expr YIELD_FROM
|
yield_from ::= expr expr YIELD_FROM
|
||||||
# 3.4.2 has this. 3.4.4 may now
|
# 3.4.2 has this. 3.4.4 may now
|
||||||
# while1stmt ::= SETUP_LOOP l_stmts COME_FROM JUMP_BACK COME_FROM_LOOP
|
# while1stmt ::= SETUP_LOOP l_stmts COME_FROM JUMP_BACK COME_FROM_LOOP
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
super(Python34Parser, self).customize_grammar_rules(tokens, customize)
|
super(Python34Parser, self).customize_grammar_rules(tokens, customize)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
class Python34ParserSingle(Python34Parser, PythonParserSingle):
|
class Python34ParserSingle(Python34Parser, PythonParserSingle):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
# Check grammar
|
# Check grammar
|
||||||
p = Python34Parser()
|
p = Python34Parser()
|
||||||
p.check_grammar()
|
p.check_grammar()
|
||||||
from xdis.version_info import IS_PYPY, PYTHON_VERSION_TRIPLE
|
from xdis.version_info import IS_PYPY, PYTHON_VERSION_TRIPLE
|
||||||
|
|
||||||
if PYTHON_VERSION_TRIPLE[:2] == (3, 4):
|
if PYTHON_VERSION_TRIPLE[:2] == (3, 4):
|
||||||
lhs, rhs, tokens, right_recursive, dup_rhs = p.check_sets()
|
lhs, rhs, tokens, right_recursive, dup_rhs = p.check_sets()
|
||||||
from uncompyle6.scanner import get_scanner
|
from uncompyle6.scanner import get_scanner
|
||||||
|
|
||||||
s = get_scanner(PYTHON_VERSION_TRIPLE, IS_PYPY)
|
s = get_scanner(PYTHON_VERSION_TRIPLE, IS_PYPY)
|
||||||
opcode_set = set(s.opc.opname).union(set(
|
opcode_set = set(s.opc.opname).union(
|
||||||
"""JUMP_BACK CONTINUE RETURN_END_IF COME_FROM
|
set(
|
||||||
|
"""JUMP_BACK CONTINUE RETURN_END_IF COME_FROM
|
||||||
LOAD_GENEXPR LOAD_ASSERT LOAD_SETCOMP LOAD_DICTCOMP LOAD_CLASSNAME
|
LOAD_GENEXPR LOAD_ASSERT LOAD_SETCOMP LOAD_DICTCOMP LOAD_CLASSNAME
|
||||||
LAMBDA_MARKER RETURN_LAST
|
LAMBDA_MARKER RETURN_LAST
|
||||||
""".split()))
|
""".split()
|
||||||
|
)
|
||||||
|
)
|
||||||
remain_tokens = set(tokens) - opcode_set
|
remain_tokens = set(tokens) - opcode_set
|
||||||
import re
|
import re
|
||||||
remain_tokens = set([re.sub(r'_\d+$', '', t) for t in remain_tokens])
|
|
||||||
remain_tokens = set([re.sub('_CONT$', '', t) for t in remain_tokens])
|
remain_tokens = set([re.sub(r"_\d+$", "", t) for t in remain_tokens])
|
||||||
|
remain_tokens = set([re.sub("_CONT$", "", t) for t in remain_tokens])
|
||||||
remain_tokens = set(remain_tokens) - opcode_set
|
remain_tokens = set(remain_tokens) - opcode_set
|
||||||
print(remain_tokens)
|
print(remain_tokens)
|
||||||
# print(sorted(p.rule2name.items()))
|
# print(sorted(p.rule2name.items()))
|
||||||
|
Reference in New Issue
Block a user