You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
import_as -> alias; and reinstate rule
This commit is contained in:
@@ -383,19 +383,19 @@ class PythonParser(GenericASTBuilder):
|
|||||||
stmt ::= importstar
|
stmt ::= importstar
|
||||||
stmt ::= importmultiple
|
stmt ::= importmultiple
|
||||||
|
|
||||||
importlist ::= importlist import_as
|
importlist ::= importlist alias
|
||||||
importlist ::= import_as
|
importlist ::= alias
|
||||||
import_as ::= IMPORT_NAME store
|
alias ::= IMPORT_NAME store
|
||||||
import_as ::= IMPORT_FROM store
|
alias ::= IMPORT_FROM store
|
||||||
import_as ::= IMPORT_NAME load_attrs store
|
alias ::= IMPORT_NAME load_attrs store
|
||||||
|
|
||||||
importstmt ::= LOAD_CONST LOAD_CONST import_as
|
importstmt ::= LOAD_CONST LOAD_CONST alias
|
||||||
importstar ::= LOAD_CONST LOAD_CONST IMPORT_NAME IMPORT_STAR
|
importstar ::= LOAD_CONST LOAD_CONST IMPORT_NAME IMPORT_STAR
|
||||||
importfrom ::= LOAD_CONST LOAD_CONST IMPORT_NAME importlist POP_TOP
|
importfrom ::= LOAD_CONST LOAD_CONST IMPORT_NAME importlist POP_TOP
|
||||||
importmultiple ::= LOAD_CONST LOAD_CONST import_as imports_cont
|
importmultiple ::= LOAD_CONST LOAD_CONST alias imports_cont
|
||||||
|
|
||||||
imports_cont ::= import_cont+
|
imports_cont ::= import_cont+
|
||||||
import_cont ::= LOAD_CONST LOAD_CONST import_as
|
import_cont ::= LOAD_CONST LOAD_CONST alias
|
||||||
|
|
||||||
load_attrs ::= LOAD_ATTR+
|
load_attrs ::= LOAD_ATTR+
|
||||||
"""
|
"""
|
||||||
|
@@ -27,7 +27,7 @@ class Python21Parser(Python22Parser):
|
|||||||
|
|
||||||
def p_import21(self, args):
|
def p_import21(self, args):
|
||||||
'''
|
'''
|
||||||
import_as ::= IMPORT_NAME_CONT store
|
alias ::= IMPORT_NAME_CONT store
|
||||||
'''
|
'''
|
||||||
|
|
||||||
class Python21ParserSingle(Python22Parser, PythonParserSingle):
|
class Python21ParserSingle(Python22Parser, PythonParserSingle):
|
||||||
|
@@ -48,7 +48,7 @@ class Python23Parser(Python24Parser):
|
|||||||
expr ::= and2
|
expr ::= and2
|
||||||
and2 ::= _jump jmp_false COME_FROM expr COME_FROM
|
and2 ::= _jump jmp_false COME_FROM expr COME_FROM
|
||||||
|
|
||||||
import_as ::= IMPORT_NAME load_attrs store
|
alias ::= IMPORT_NAME load_attrs store
|
||||||
load_attrs ::= LOAD_ATTR+
|
load_attrs ::= LOAD_ATTR+
|
||||||
|
|
||||||
conditional ::= expr jmp_false expr JUMP_FORWARD expr COME_FROM
|
conditional ::= expr jmp_false expr JUMP_FORWARD expr COME_FROM
|
||||||
|
@@ -26,12 +26,12 @@ class Python24Parser(Python25Parser):
|
|||||||
# 2.5+ has two LOAD_CONSTs, one for the number '.'s in a relative import
|
# 2.5+ has two LOAD_CONSTs, one for the number '.'s in a relative import
|
||||||
# keep positions similar to simplify semantic actions
|
# keep positions similar to simplify semantic actions
|
||||||
|
|
||||||
importstmt ::= filler LOAD_CONST import_as
|
importstmt ::= filler LOAD_CONST alias
|
||||||
importfrom ::= filler LOAD_CONST IMPORT_NAME importlist POP_TOP
|
importfrom ::= filler LOAD_CONST IMPORT_NAME importlist POP_TOP
|
||||||
importstar ::= filler LOAD_CONST IMPORT_NAME IMPORT_STAR
|
importstar ::= filler LOAD_CONST IMPORT_NAME IMPORT_STAR
|
||||||
|
|
||||||
importmultiple ::= filler LOAD_CONST import_as imports_cont
|
importmultiple ::= filler LOAD_CONST alias imports_cont
|
||||||
import_cont ::= filler LOAD_CONST import_as
|
import_cont ::= filler LOAD_CONST alias
|
||||||
|
|
||||||
# Python 2.5+ omits POP_TOP POP_BLOCK
|
# Python 2.5+ omits POP_TOP POP_BLOCK
|
||||||
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_TOP POP_BLOCK COME_FROM
|
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_TOP POP_BLOCK COME_FROM
|
||||||
|
@@ -73,7 +73,6 @@ class Python32Parser(Python3Parser):
|
|||||||
try_middle ::= JUMP_FORWARD COME_FROM_EXCEPT except_stmts END_FINALLY COME_FROM_EXCEPT_CLAUSE
|
try_middle ::= JUMP_FORWARD COME_FROM_EXCEPT except_stmts END_FINALLY COME_FROM_EXCEPT_CLAUSE
|
||||||
try_middle ::= jmp_abs COME_FROM except_stmts END_FINALLY
|
try_middle ::= jmp_abs COME_FROM except_stmts END_FINALLY
|
||||||
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK try_middle else_suite come_from_except_clauses
|
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK try_middle else_suite come_from_except_clauses
|
||||||
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM_LOOP
|
|
||||||
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK NOP COME_FROM_LOOP
|
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK NOP COME_FROM_LOOP
|
||||||
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK NOP COME_FROM_LOOP
|
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK NOP COME_FROM_LOOP
|
||||||
""")
|
""")
|
||||||
|
@@ -487,7 +487,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
|||||||
self.set_pos_info(node, start, len(self.f.getvalue()))
|
self.set_pos_info(node, start, len(self.f.getvalue()))
|
||||||
self.prune()
|
self.prune()
|
||||||
|
|
||||||
def n_import_as(self, node):
|
def n_alias(self, node):
|
||||||
start = len(self.f.getvalue())
|
start = len(self.f.getvalue())
|
||||||
iname = node[0].pattr
|
iname = node[0].pattr
|
||||||
|
|
||||||
|
@@ -989,7 +989,7 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
self.indent_less()
|
self.indent_less()
|
||||||
self.prune()
|
self.prune()
|
||||||
|
|
||||||
def n_import_as(self, node):
|
def n_alias(self, node):
|
||||||
if self.version <= 2.1:
|
if self.version <= 2.1:
|
||||||
if len(node) == 2:
|
if len(node) == 2:
|
||||||
store = node[1]
|
store = node[1]
|
||||||
|
Reference in New Issue
Block a user