Grammar cleanup: import_as_cont -> import_as

This commit is contained in:
rocky
2017-11-18 10:26:57 -05:00
parent 0c0a534a48
commit f7ff4c2d41
4 changed files with 12 additions and 7 deletions

View File

@@ -38,6 +38,15 @@ def test_grammar():
assert expect_lhs == set(lhs)
assert unused_rhs == set(rhs)
assert expect_right_recursive == right_recursive
expect_dup_rhs = frozenset([('COME_FROM',), ('CONTINUE',), ('JUMP_ABSOLUTE',),
('LOAD_CONST',),
('JUMP_BACK',), ('JUMP_FORWARD',)])
reduced_dup_rhs = {k: dup_rhs[k] for k in dup_rhs if k not in expect_dup_rhs}
for k in reduced_dup_rhs:
print(k, reduced_dup_rhs[k])
# assert not reduced_dup_rhs, reduced_dup_rhs
s = get_scanner(PYTHON_VERSION, IS_PYPY)
ignore_set = set(
"""

View File

@@ -409,10 +409,8 @@ class PythonParser(GenericASTBuilder):
importfrom ::= LOAD_CONST LOAD_CONST IMPORT_NAME importlist POP_TOP
importmultiple ::= LOAD_CONST LOAD_CONST import_as imports_cont
imports_cont ::= imports_cont import_cont
imports_cont ::= import_cont
import_cont ::= LOAD_CONST LOAD_CONST import_as_cont
import_as_cont ::= IMPORT_FROM designator
imports_cont ::= import_cont+
import_cont ::= LOAD_CONST LOAD_CONST import_as
load_attrs ::= LOAD_ATTR+
"""

View File

@@ -31,7 +31,7 @@ class Python24Parser(Python25Parser):
importstar ::= filler LOAD_CONST IMPORT_NAME IMPORT_STAR
importmultiple ::= filler LOAD_CONST import_as imports_cont
import_cont ::= filler LOAD_CONST import_as_cont
import_cont ::= filler LOAD_CONST import_as
# Python 2.5+ omits POP_TOP POP_BLOCK
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_TOP POP_BLOCK COME_FROM

View File

@@ -983,8 +983,6 @@ class SourceWalker(GenericASTTraversal, object):
self.write(iname, ' as ', sname)
self.prune() # stop recursing
n_import_as_cont = n_import_as
def n_importfrom(self, node):
relative_path_index = 0
if self.version >= 2.5 and node[relative_path_index].pattr > 0: