You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 09:22:40 +08:00
further work on supporting single and multiple fstring decompilation
This commit is contained in:
@@ -516,19 +516,21 @@ class Python3Parser(PythonParser):
|
||||
elif opname == 'FORMAT_VALUE':
|
||||
# Python 3.6+
|
||||
self.addRule("""
|
||||
expr ::= fstring_expr
|
||||
fstring_expr ::= expr FORMAT_VALUE
|
||||
str ::= LOAD_CONST
|
||||
fstring_expr_or_str ::= fstring_expr
|
||||
fstring_expr_or_str ::= str
|
||||
expr ::= fstring_single
|
||||
fstring_single ::= expr FORMAT_VALUE
|
||||
""", nop_func)
|
||||
elif opname == 'BUILD_STRING':
|
||||
# Python 3.6+
|
||||
v = token.attr
|
||||
fstring_expr_or_str_n = "fstring_expr_or_str_%s" % v
|
||||
rule = """
|
||||
expr ::= fstring
|
||||
fstring ::= %s BUILD_STRING
|
||||
expr ::= fstring_expr
|
||||
fstring_expr ::= expr FORMAT_VALUE
|
||||
str ::= LOAD_CONST
|
||||
fstring_expr_or_str ::= fstring_expr
|
||||
fstring_expr_or_str ::= str
|
||||
expr ::= fstring_multi
|
||||
fstring_multi ::= %s BUILD_STRING
|
||||
%s ::= %sBUILD_STRING
|
||||
""" % (fstring_expr_or_str_n, fstring_expr_or_str_n, "fstring_expr_or_str " * v)
|
||||
self.addRule(rule, nop_func)
|
||||
|
Reference in New Issue
Block a user