You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
Try removing more singleton rules
This commit is contained in:
@@ -39,7 +39,7 @@ entry_points = {
|
||||
'pydisassemble=uncompyle6.bin.pydisassemble:main',
|
||||
]}
|
||||
ftp_url = None
|
||||
install_requires = ['spark-parser >= 1.8.4, < 1.9.0',
|
||||
install_requires = ['spark-parser >= 1.8.5, < 1.9.0',
|
||||
'xdis >= 3.6.2, < 3.7.0', 'six']
|
||||
license = 'MIT'
|
||||
mailing_list = 'python-debugger@googlegroups.com'
|
||||
|
@@ -46,6 +46,15 @@ class PythonParser(GenericASTBuilder):
|
||||
]
|
||||
self.collect = frozenset(nt_list)
|
||||
|
||||
# ??? Do we need a debug option to skip eliding singleton reductions?
|
||||
# Time will tell if it if useful in debugging
|
||||
|
||||
# FIXME: optional_nt is a misnomer. It's really about there being a
|
||||
# singleton reduction that we can simplify. It also happens to be optional
|
||||
# in its other derivation
|
||||
self.optional_nt |= frozenset(['come_froms', 'suite_stmts', 'l_stmts_opt',
|
||||
'c_stmts_opt'])
|
||||
|
||||
# Reduce singleton reductions in these nonterminals:
|
||||
# FIXME: would love to do expr, sstmts, stmts and
|
||||
# so on but that would require major changes to the
|
||||
@@ -180,11 +189,19 @@ class PythonParser(GenericASTBuilder):
|
||||
# stmts -> stmts stmt -> stmts stmt -> ...
|
||||
# stmms -> stmt stmt ...
|
||||
#
|
||||
rv = args[0]
|
||||
if not hasattr(args[0], 'append'):
|
||||
# Was in self.optional_nt as a single item, but we find we have
|
||||
# more than one now...
|
||||
rv = GenericASTBuilder.nonterminal(self, nt, [args[0]])
|
||||
else:
|
||||
rv = args[0]
|
||||
pass
|
||||
rv.append(args[1])
|
||||
elif n == 1 and args[0] in self.singleton:
|
||||
rv = GenericASTBuilder.nonterminal(self, nt, args[0])
|
||||
del args[0] # save memory
|
||||
elif n == 1 and nt in self.optional_nt:
|
||||
rv = args[0]
|
||||
else:
|
||||
rv = GenericASTBuilder.nonterminal(self, nt, args)
|
||||
return rv
|
||||
|
Reference in New Issue
Block a user