Merge ast-branch to head

This change implements a new bytecode compiler, based on a
transformation of the parse tree to an abstract syntax defined in
Parser/Python.asdl.

The compiler implementation is not complete, but it is in stable
enough shape to run the entire test suite excepting two disabled
tests.
This commit is contained in:
Jeremy Hylton 2005-10-20 19:59:25 +00:00
parent 2cb94aba12
commit 3e0055f8c6
54 changed files with 13675 additions and 6810 deletions

View file

@ -8,7 +8,7 @@
# regression test, the filterwarnings() call has been added to
# regrtest.py.
from test.test_support import TestFailed, verify, check_syntax
from test.test_support import TestFailed, verify, vereq, check_syntax
import sys
print '1. Parser'
@ -157,28 +157,31 @@ def f2(one_argument): pass
def f3(two, arguments): pass
def f4(two, (compound, (argument, list))): pass
def f5((compound, first), two): pass
verify(f2.func_code.co_varnames == ('one_argument',))
verify(f3.func_code.co_varnames == ('two', 'arguments'))
vereq(f2.func_code.co_varnames, ('one_argument',))
vereq(f3.func_code.co_varnames, ('two', 'arguments'))
if sys.platform.startswith('java'):
verify(f4.func_code.co_varnames ==
vereq(f4.func_code.co_varnames,
('two', '(compound, (argument, list))', 'compound', 'argument',
'list',))
verify(f5.func_code.co_varnames ==
vereq(f5.func_code.co_varnames,
('(compound, first)', 'two', 'compound', 'first'))
else:
verify(f4.func_code.co_varnames == ('two', '.2', 'compound',
'argument', 'list'))
verify(f5.func_code.co_varnames == ('.0', 'two', 'compound', 'first'))
vereq(f4.func_code.co_varnames,
('two', '.1', 'compound', 'argument', 'list'))
vereq(f5.func_code.co_varnames,
('.0', 'two', 'compound', 'first'))
def a1(one_arg,): pass
def a2(two, args,): pass
def v0(*rest): pass
def v1(a, *rest): pass
def v2(a, b, *rest): pass
def v3(a, (b, c), *rest): return a, b, c, rest
# ceval unpacks the formal arguments into the first argcount names;
# thus, the names nested inside tuples must appear after these names.
if sys.platform.startswith('java'):
verify(v3.func_code.co_varnames == ('a', '(b, c)', 'rest', 'b', 'c'))
else:
verify(v3.func_code.co_varnames == ('a', '.2', 'rest', 'b', 'c'))
vereq(v3.func_code.co_varnames, ('a', '.1', 'rest', 'b', 'c'))
verify(v3(1, (2, 3), 4) == (1, 2, 3, (4,)))
def d01(a=1): pass
d01()
@ -410,6 +413,10 @@ def g1(): return
def g2(): return 1
g1()
x = g2()
check_syntax("class foo:return 1")
print 'yield_stmt'
check_syntax("class foo:yield 1")
print 'raise_stmt' # 'raise' test [',' test]
try: raise RuntimeError, 'just testing'