Fix import and 3.x class bugs...

import x.y as z was failing across all Python versions
class decorators for Python 3.0..3.3 was failing
reduce 3.x while grammar rules
This commit is contained in:
rocky
2017-11-29 06:59:05 -05:00
parent 42fd38e2c0
commit f2eaa09e96
19 changed files with 6 additions and 12 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,6 +1,6 @@
# Tests:
import sys
from os import path
from os import *
import time as time1, os as os1
import http.client as httpclient

View File

@@ -387,6 +387,7 @@ class PythonParser(GenericASTBuilder):
importlist ::= import_as
import_as ::= IMPORT_NAME store
import_as ::= IMPORT_FROM store
import_as ::= IMPORT_NAME load_attrs store
importstmt ::= LOAD_CONST LOAD_CONST import_as
importstar ::= LOAD_CONST LOAD_CONST IMPORT_NAME IMPORT_STAR
@@ -395,6 +396,8 @@ class PythonParser(GenericASTBuilder):
imports_cont ::= import_cont+
import_cont ::= LOAD_CONST LOAD_CONST import_as
load_attrs ::= LOAD_ATTR+
"""
def p_list_comprehension(self, args):

View File

@@ -373,11 +373,6 @@ class Python3Parser(PythonParser):
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
COME_FROM_LOOP
# The JUMP_ABSOLUTE below comes from escaping an "if" block which surrounds
# the while. This is messy
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
JUMP_ABSOLUTE COME_FROM_LOOP
whilestmt ::= SETUP_LOOP testexpr return_stmts POP_BLOCK
COME_FROM_LOOP

View File

@@ -18,9 +18,6 @@ class Python33Parser(Python32Parser):
# We do the grammar hackery below for semantics
# actions that want c_stmts_opt at index 1
whileTruestmt ::= SETUP_LOOP l_stmts JUMP_ABSOLUTE
JUMP_BACK COME_FROM_LOOP
# Python 3.5+ has jump optimization to remove the redundant
# jump_excepts. But in 3.3 we need them added
@@ -33,11 +30,8 @@ class Python33Parser(Python32Parser):
def add_custom_rules(self, tokens, customize):
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 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
POP_BLOCK JUMP_ABSOLUTE COME_FROM_LOOP
""")
super(Python33Parser, self).add_custom_rules(tokens, customize)
return

View File

@@ -1434,6 +1434,8 @@ class SourceWalker(GenericASTTraversal, object):
if node == 'classdefdeco2':
if self.version >= 3.6:
class_name = node[1][1].pattr
elif self.version <= 3.3:
class_name = node[2][0].pattr
else:
class_name = node[1][2].pattr
buildclass = node