Merge branch 'master' into python-2.4

This commit is contained in:
rocky
2017-11-27 21:41:01 -05:00
6 changed files with 32 additions and 6 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,2 @@
# Python 2's deprecated unary convert (akin to "repr()"
`abc`

View File

@@ -36,6 +36,7 @@ class PythonParser(GenericASTBuilder):
# Python < 3
'print_items',
# PyPy:
'imports_cont',
'kvlist_n']
self.collect = frozenset(nt_list)

View File

@@ -33,7 +33,6 @@ class Python33Parser(Python32Parser):
self.remove_rules("""
# 3.3+ adds POP_BLOCKS
whileTruestmt ::= SETUP_LOOP l_stmts JUMP_ABSOLUTE JUMP_BACK COME_FROM_LOOP
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK 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
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK

View File

@@ -304,7 +304,17 @@ class SourceWalker(GenericASTTraversal, object):
TABLE_DIRECT.update({
'tryfinallystmt': ( '%|try:\n%+%c%-%|finally:\n%+%c%-\n\n', 1, 4 )
})
if version <= 2.1:
TABLE_DIRECT.update({
'importmultiple': ( '%c', 2 ),
'imports_cont': ( '%c', 2 ),
# FIXME: not quite right. We have indiividual imports
# when there is in fact one: "import a, b, ..."
'imports_cont': ( '%C%,', (1, 100, '\n') ),
})
pass
pass
pass
elif version >= 2.5:
########################
# Import style for 2.5+
@@ -978,6 +988,20 @@ class SourceWalker(GenericASTTraversal, object):
self.prune()
def n_import_as(self, node):
if self.version <= 2.1:
if len(node) == 2:
designator = node[1]
assert designator == 'designator'
if designator[0].pattr == node[0].pattr:
self.write("import %s\n" % node[0].pattr)
else:
self.write("import %s as %s\n" %
(node[0].pattr, designator[0].pattr))
pass
pass
self.prune() # stop recursing
store_node = node[-1][-1]
assert store_node.kind.startswith('STORE_')
iname = node[0].pattr # import name