You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Increase test coverage. Remove some epsilon reductionsa
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -46,14 +46,18 @@ class PythonParser(GenericASTBuilder):
|
||||
]
|
||||
self.collect = frozenset(nt_list)
|
||||
|
||||
# For these items we need to keep the 1st epslion reduction since
|
||||
# the nonterminal name is used in a semantic action.
|
||||
self.keep_epsilon = frozenset(('kvlist_n', 'kvlist'))
|
||||
|
||||
# ??? 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'])
|
||||
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
|
||||
@@ -196,7 +200,12 @@ class PythonParser(GenericASTBuilder):
|
||||
else:
|
||||
rv = args[0]
|
||||
pass
|
||||
rv.append(args[1])
|
||||
# In a list-like entity where the first item goes to epsilon,
|
||||
# drop that and save the 2nd item as the first one
|
||||
if len(rv) == 0 and nt not in self.keep_epsilon:
|
||||
rv = args[1]
|
||||
else:
|
||||
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
|
||||
|
@@ -141,7 +141,7 @@ class Python36Parser(Python35Parser):
|
||||
self.addRule("""expr ::= call_ex_kw
|
||||
expr ::= call_ex_kw2
|
||||
call_ex_kw ::= expr expr build_map_unpack_with_call
|
||||
CALL_FUNCTION_EX_KW
|
||||
CALL_FUNCTION_EX_KW
|
||||
call_ex_kw2 ::= expr
|
||||
build_tuple_unpack_with_call
|
||||
build_map_unpack_with_call
|
||||
|
Reference in New Issue
Block a user