Remove Python2 buitin "print" from Python3's grammr. Start class tests

This commit is contained in:
rocky
2015-12-22 05:50:00 -05:00
parent 217b1b6f54
commit 41cceb5931
5 changed files with 75 additions and 27 deletions

View File

@@ -0,0 +1,2 @@
class A:
pass

View File

@@ -0,0 +1,33 @@
class A:
class A1:
def __init__(self):
self.a1 = True
def foo(self):
self.b = True
def __init__(self):
self.a = True
def foo(self):
self.fooed = True
class B:
def __init__(self):
self.bed = True
def bar(self):
self.barred = True
class C(A,B):
def foobar(self):
self.foobared = True
c = C()
c.foo()
c.bar()
c.foobar()

View File

@@ -92,6 +92,12 @@ def_op('STORE_LOCALS', 69)
def_op('PRINT_EXPR', 70) def_op('PRINT_EXPR', 70)
def_op('LOAD_BUILD_CLASS', 71) def_op('LOAD_BUILD_CLASS', 71)
# Python3 drops/changes:
# def_op('PRINT_ITEM', 71)
# def_op('PRINT_NEWLINE', 72)
# def_op('PRINT_ITEM_TO', 73)
# def_op('PRINT_NEWLINE_TO', 74)
def_op('INPLACE_LSHIFT', 75) def_op('INPLACE_LSHIFT', 75)
def_op('INPLACE_RSHIFT', 76) def_op('INPLACE_RSHIFT', 76)
def_op('INPLACE_AND', 77) def_op('INPLACE_AND', 77)

View File

@@ -100,13 +100,19 @@ def_op('BINARY_OR', 66)
def_op('INPLACE_POWER', 67) def_op('INPLACE_POWER', 67)
def_op('GET_ITER', 68) def_op('GET_ITER', 68)
## FIXME: no code generates this # FIXME: no code generates this
def_op('STORE_LOCALS', 69) def_op('STORE_LOCALS', 69)
def_op('PRINT_EXPR', 70) def_op('PRINT_EXPR', 70)
def_op('LOAD_BUILD_CLASS', 71) def_op('LOAD_BUILD_CLASS', 71)
def_op('YIELD_FROM', 72) def_op('YIELD_FROM', 72)
# Python3 drops/changes:
# def_op('PRINT_ITEM', 71)
# def_op('PRINT_NEWLINE', 72)
# def_op('PRINT_ITEM_TO', 73)
# def_op('PRINT_NEWLINE_TO', 74)
def_op('INPLACE_LSHIFT', 75) def_op('INPLACE_LSHIFT', 75)
def_op('INPLACE_RSHIFT', 76) def_op('INPLACE_RSHIFT', 76)
def_op('INPLACE_AND', 77) def_op('INPLACE_AND', 77)

View File

@@ -164,34 +164,35 @@ class Python3Parser(PythonParser):
assign3 ::= expr expr expr ROT_THREE ROT_TWO designator designator designator assign3 ::= expr expr expr ROT_THREE ROT_TWO designator designator designator
''' '''
def p_print(self, args): # Python3 doesn't have a built-in print.
''' # def p_print(self, args):
stmt ::= print_items_stmt # '''
stmt ::= print_nl # stmt ::= print_items_stmt
stmt ::= print_items_nl_stmt # stmt ::= print_nl
# stmt ::= print_items_nl_stmt
print_items_stmt ::= expr PRINT_ITEM print_items_opt # print_items_stmt ::= expr PRINT_ITEM print_items_opt
print_items_nl_stmt ::= expr PRINT_ITEM print_items_opt PRINT_NEWLINE_CONT # print_items_nl_stmt ::= expr PRINT_ITEM print_items_opt PRINT_NEWLINE_CONT
print_items_opt ::= print_items # print_items_opt ::= print_items
print_items_opt ::= # print_items_opt ::=
print_items ::= print_items print_item # print_items ::= print_items print_item
print_items ::= print_item # print_items ::= print_item
print_item ::= expr PRINT_ITEM_CONT # print_item ::= expr PRINT_ITEM_CONT
print_nl ::= PRINT_NEWLINE # print_nl ::= PRINT_NEWLINE
''' # '''
def p_print_to(self, args): # def p_print_to(self, args):
''' # '''
stmt ::= print_to # stmt ::= print_to
stmt ::= print_to_nl # stmt ::= print_to_nl
stmt ::= print_nl_to # stmt ::= print_nl_to
print_to ::= expr print_to_items POP_TOP # print_to ::= expr print_to_items POP_TOP
print_to_nl ::= expr print_to_items PRINT_NEWLINE_TO # print_to_nl ::= expr print_to_items PRINT_NEWLINE_TO
print_nl_to ::= expr PRINT_NEWLINE_TO # print_nl_to ::= expr PRINT_NEWLINE_TO
print_to_items ::= print_to_items print_to_item # print_to_items ::= print_to_items print_to_item
print_to_items ::= print_to_item # print_to_items ::= print_to_item
print_to_item ::= DUP_TOP expr ROT_TWO PRINT_ITEM_TO # print_to_item ::= DUP_TOP expr ROT_TWO PRINT_ITEM_TO
''' # '''
def p_import20(self, args): def p_import20(self, args):
''' '''