You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Sync NT joined_str and formmated_value with AST
This commit is contained in:
@@ -39,7 +39,10 @@ class PythonParser(GenericASTBuilder):
|
|||||||
'print_items',
|
'print_items',
|
||||||
# PyPy:
|
# PyPy:
|
||||||
'imports_cont',
|
'imports_cont',
|
||||||
'kvlist_n']
|
'kvlist_n',
|
||||||
|
# Python 3.6+
|
||||||
|
'joined_str',
|
||||||
|
]
|
||||||
self.collect = frozenset(nt_list)
|
self.collect = frozenset(nt_list)
|
||||||
|
|
||||||
def ast_first_offset(self, ast):
|
def ast_first_offset(self, ast):
|
||||||
|
@@ -88,20 +88,20 @@ class Python36Parser(Python35Parser):
|
|||||||
self.add_unique_doc_rules(rules_str, customize)
|
self.add_unique_doc_rules(rules_str, customize)
|
||||||
elif opname == 'BUILD_STRING':
|
elif opname == 'BUILD_STRING':
|
||||||
v = token.attr
|
v = token.attr
|
||||||
fstring_expr_or_str_n = "fstring_expr_or_str_%s" % v
|
joined_str_n = "formatted_value_%s" % v
|
||||||
rules_str = """
|
rules_str = """
|
||||||
expr ::= fstring_expr
|
expr ::= fstring_expr
|
||||||
fstring_expr ::= expr FORMAT_VALUE
|
fstring_expr ::= expr FORMAT_VALUE
|
||||||
str ::= LOAD_CONST
|
str ::= LOAD_CONST
|
||||||
fstring_expr_or_str ::= fstring_expr
|
formatted_value ::= fstring_expr
|
||||||
fstring_expr_or_str ::= str
|
formatted_value ::= str
|
||||||
|
|
||||||
expr ::= fstring_multi
|
expr ::= fstring_multi
|
||||||
fstring_multi ::= fstring_expr_or_strs BUILD_STRING
|
fstring_multi ::= joined_str BUILD_STRING
|
||||||
fstring_expr_or_strs ::= fstring_expr_or_str+
|
joined_str ::= formatted_value+
|
||||||
fstring_multi ::= %s BUILD_STRING
|
fstring_multi ::= %s BUILD_STRING
|
||||||
%s ::= %sBUILD_STRING
|
%s ::= %sBUILD_STRING
|
||||||
""" % (fstring_expr_or_str_n, fstring_expr_or_str_n, "fstring_expr_or_str " * v)
|
""" % (joined_str_n, joined_str_n, "formatted_value " * v)
|
||||||
self.add_unique_doc_rules(rules_str, customize)
|
self.add_unique_doc_rules(rules_str, customize)
|
||||||
|
|
||||||
def custom_classfunc_rule(self, opname, token, customize,
|
def custom_classfunc_rule(self, opname, token, customize,
|
||||||
|
Reference in New Issue
Block a user