mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-11-23 21:20:06 +00:00
import_as -> alias; and reinstate rule
This commit is contained in:
parent
ff43403a05
commit
7775bdabd5
@ -383,19 +383,19 @@ class PythonParser(GenericASTBuilder):
|
||||
stmt ::= importstar
|
||||
stmt ::= importmultiple
|
||||
|
||||
importlist ::= importlist import_as
|
||||
importlist ::= import_as
|
||||
import_as ::= IMPORT_NAME store
|
||||
import_as ::= IMPORT_FROM store
|
||||
import_as ::= IMPORT_NAME load_attrs store
|
||||
importlist ::= importlist alias
|
||||
importlist ::= alias
|
||||
alias ::= IMPORT_NAME store
|
||||
alias ::= IMPORT_FROM 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
|
||||
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+
|
||||
import_cont ::= LOAD_CONST LOAD_CONST import_as
|
||||
import_cont ::= LOAD_CONST LOAD_CONST alias
|
||||
|
||||
load_attrs ::= LOAD_ATTR+
|
||||
"""
|
||||
|
@ -27,7 +27,7 @@ class Python21Parser(Python22Parser):
|
||||
|
||||
def p_import21(self, args):
|
||||
'''
|
||||
import_as ::= IMPORT_NAME_CONT store
|
||||
alias ::= IMPORT_NAME_CONT store
|
||||
'''
|
||||
|
||||
class Python21ParserSingle(Python22Parser, PythonParserSingle):
|
||||
|
@ -48,7 +48,7 @@ class Python23Parser(Python24Parser):
|
||||
expr ::= and2
|
||||
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+
|
||||
|
||||
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
|
||||
# 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
|
||||
importstar ::= filler LOAD_CONST IMPORT_NAME IMPORT_STAR
|
||||
|
||||
importmultiple ::= filler LOAD_CONST import_as imports_cont
|
||||
import_cont ::= filler LOAD_CONST import_as
|
||||
importmultiple ::= filler LOAD_CONST alias imports_cont
|
||||
import_cont ::= filler LOAD_CONST alias
|
||||
|
||||
# Python 2.5+ omits POP_TOP POP_BLOCK
|
||||
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 ::= jmp_abs COME_FROM except_stmts END_FINALLY
|
||||
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 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.prune()
|
||||
|
||||
def n_import_as(self, node):
|
||||
def n_alias(self, node):
|
||||
start = len(self.f.getvalue())
|
||||
iname = node[0].pattr
|
||||
|
||||
|
@ -989,7 +989,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
self.indent_less()
|
||||
self.prune()
|
||||
|
||||
def n_import_as(self, node):
|
||||
def n_alias(self, node):
|
||||
if self.version <= 2.1:
|
||||
if len(node) == 2:
|
||||
store = node[1]
|
||||
|
Loading…
Reference in New Issue
Block a user