From 7775bdabd55ea33a09d6cdc69959249f2940432d Mon Sep 17 00:00:00 2001 From: rocky Date: Wed, 29 Nov 2017 10:38:18 -0500 Subject: [PATCH] import_as -> alias; and reinstate rule --- uncompyle6/parser.py | 16 ++++++++-------- uncompyle6/parsers/parse21.py | 2 +- uncompyle6/parsers/parse23.py | 2 +- uncompyle6/parsers/parse24.py | 6 +++--- uncompyle6/parsers/parse32.py | 1 - uncompyle6/semantics/fragments.py | 2 +- uncompyle6/semantics/pysource.py | 2 +- 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index 122e37c0..784f6379 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -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+ """ diff --git a/uncompyle6/parsers/parse21.py b/uncompyle6/parsers/parse21.py index 31a13e68..c2cb8675 100644 --- a/uncompyle6/parsers/parse21.py +++ b/uncompyle6/parsers/parse21.py @@ -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): diff --git a/uncompyle6/parsers/parse23.py b/uncompyle6/parsers/parse23.py index d5a1d013..5d7a30ab 100644 --- a/uncompyle6/parsers/parse23.py +++ b/uncompyle6/parsers/parse23.py @@ -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 diff --git a/uncompyle6/parsers/parse24.py b/uncompyle6/parsers/parse24.py index 2d4140bb..2c295bfd 100644 --- a/uncompyle6/parsers/parse24.py +++ b/uncompyle6/parsers/parse24.py @@ -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 diff --git a/uncompyle6/parsers/parse32.py b/uncompyle6/parsers/parse32.py index 1822cdc6..7732e0fc 100644 --- a/uncompyle6/parsers/parse32.py +++ b/uncompyle6/parsers/parse32.py @@ -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 """) diff --git a/uncompyle6/semantics/fragments.py b/uncompyle6/semantics/fragments.py index ad858e74..a23409aa 100644 --- a/uncompyle6/semantics/fragments.py +++ b/uncompyle6/semantics/fragments.py @@ -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 diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index b0a2abfe..20cdbf10 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -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]