[pypy-svn] r17281 - in pypy/dist/pypy/interpreter: pyparser/test testcompiler
pedronis at codespeak.net
pedronis at codespeak.net
Tue Sep 6 14:17:06 CEST 2005
Author: pedronis
Date: Tue Sep 6 14:17:04 2005
New Revision: 17281
Added:
pypy/dist/pypy/interpreter/testcompiler/
- copied from r17267, pypy/dist/pypy/interpreter/stablecompiler/
Modified:
pypy/dist/pypy/interpreter/pyparser/test/test_astcompiler.py
pypy/dist/pypy/interpreter/testcompiler/future.py
pypy/dist/pypy/interpreter/testcompiler/pyassem.py
pypy/dist/pypy/interpreter/testcompiler/pycodegen.py
pypy/dist/pypy/interpreter/testcompiler/symbols.py
pypy/dist/pypy/interpreter/testcompiler/syntax.py
pypy/dist/pypy/interpreter/testcompiler/transformer.py
pypy/dist/pypy/interpreter/testcompiler/visitor.py
Log:
yet another compiler :(, this one cannot be used with PyPy itself, is meant to be used by test_astcompiler and should
be short lived (that's the hope).
PS: pedronis in this very moments hates globals, non-overridable imports and wished module and packages could be a bit more
like ML functors.
Modified: pypy/dist/pypy/interpreter/pyparser/test/test_astcompiler.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyparser/test/test_astcompiler.py (original)
+++ pypy/dist/pypy/interpreter/pyparser/test/test_astcompiler.py Tue Sep 6 14:17:04 2005
@@ -3,6 +3,11 @@
from pypy.interpreter.pycode import PyCode
import py.test
+def setup_module(mod):
+ import sys
+ if sys.version[:3] != "2.4":
+ py.test.skip("expected to work only on 2.4")
+
from pypy.interpreter.astcompiler import ast, misc, pycodegen
from test_astbuilder import expressions, comparisons, funccalls, backtrackings,\
@@ -16,27 +21,27 @@
TESTS = [
expressions,
-## augassigns,
-## comparisons,
-## funccalls,
-## backtrackings,
-## listmakers,
-## dictmakers,
-## multiexpr,
-## attraccess,
-## slices,
-## imports,
-## execs,
-## prints,
-## globs,
-## raises_,
-## # EXEC INPUTS
-## # one_stmt_classdefs,
-## one_stmt_funcdefs,
-## if_stmts,
-## tryexcepts,
-## # docstrings,
-## # returns,
+ augassigns,
+ comparisons,
+ funccalls,
+ backtrackings,
+ listmakers,
+ dictmakers,
+ multiexpr,
+ attraccess,
+ slices,
+ imports,
+ execs,
+ prints,
+ globs,
+ raises_,
+# EXEC_INPUTS
+ one_stmt_classdefs,
+ one_stmt_funcdefs,
+ if_stmts,
+ tryexcepts,
+ docstrings,
+ returns,
]
import sys
@@ -59,19 +64,15 @@
return builder.rule_stack[-1]
-### Note: builtin compile and compiler.compile behave differently
-def compile_with_builtin_comiple( expr, target="exec" ):
- return compile( expr, "<?>", target )
-
def compile_with_astcompiler(expr, target='exec', space=FakeSpace()):
- ast = ast_parse_expr(epxr, target='exec', space=space)
+ ast = ast_parse_expr(expr, target='exec', space=space)
misc.set_filename('<?>', ast)
codegen = pycodegen.ModuleCodeGenerator(space, ast)
- rcode = codegenerator.getCode()
+ rcode = codegen.getCode()
return to_code(rcode)
def compile_with_stablecompiler(expr, target='exec'):
- from pypy.interpreter.stablecompiler import compile
+ from pypy.interpreter.testcompiler import compile
# from compiler import compile
return compile(expr, '<?>', target)
@@ -119,7 +120,7 @@
def check_compile(expr):
print "Compiling:", expr
sc_code = compile_with_stablecompiler(expr, target='exec')
- as_code = compile_with_astcompiler(expr, target='exec')
+ ac_code = compile_with_astcompiler(expr, target='exec')
compare_code(ac_code, sc_code)
## def check_compile( expr ):
@@ -135,14 +136,14 @@
## compare_code(code1,code2)
def test_compile_argtuple_1():
- py.test.skip('will be tested when more basic stuff will work')
+ #py.test.skip('will be tested when more basic stuff will work')
code = """def f( x, (y,z) ):
print x,y,z
"""
check_compile( code )
def test_compile_argtuple_2():
- py.test.skip('will be tested when more basic stuff will work')
+ #py.test.skip('will be tested when more basic stuff will work')
code = """def f( x, (y,(z,t)) ):
print x,y,z,t
"""
@@ -150,7 +151,7 @@
def test_compile_argtuple_3():
- py.test.skip('will be tested when more basic stuff will work')
+ #py.test.skip('will be tested when more basic stuff will work')
code = """def f( x, (y,(z,(t,u))) ):
print x,y,z,t,u
"""
Modified: pypy/dist/pypy/interpreter/testcompiler/future.py
==============================================================================
--- pypy/dist/pypy/interpreter/stablecompiler/future.py (original)
+++ pypy/dist/pypy/interpreter/testcompiler/future.py Tue Sep 6 14:17:04 2005
@@ -2,7 +2,7 @@
"""
-from pypy.interpreter.stablecompiler import ast, walk
+from pypy.interpreter.testcompiler import ast, walk
def is_future(stmt):
"""Return true if statement is a well-formed future statement"""
@@ -69,7 +69,7 @@
if __name__ == "__main__":
import sys
- from pypy.interpreter.stablecompiler import parseFile, walk
+ from pypy.interpreter.testcompiler import parseFile, walk
for file in sys.argv[1:]:
print file
Modified: pypy/dist/pypy/interpreter/testcompiler/pyassem.py
==============================================================================
--- pypy/dist/pypy/interpreter/stablecompiler/pyassem.py (original)
+++ pypy/dist/pypy/interpreter/testcompiler/pyassem.py Tue Sep 6 14:17:04 2005
@@ -5,8 +5,8 @@
import sys
import types
-from pypy.interpreter.stablecompiler import misc
-from pypy.interpreter.stablecompiler.consts \
+from pypy.interpreter.testcompiler import misc
+from pypy.interpreter.testcompiler.consts \
import CO_OPTIMIZED, CO_NEWLOCALS, CO_VARARGS, CO_VARKEYWORDS
class FlowGraph:
Modified: pypy/dist/pypy/interpreter/testcompiler/pycodegen.py
==============================================================================
--- pypy/dist/pypy/interpreter/stablecompiler/pycodegen.py (original)
+++ pypy/dist/pypy/interpreter/testcompiler/pycodegen.py Tue Sep 6 14:17:04 2005
@@ -6,13 +6,13 @@
import types
from cStringIO import StringIO
-from pypy.interpreter.stablecompiler import ast, parse, walk, syntax
-from pypy.interpreter.stablecompiler import pyassem, misc, future, symbols
-from pypy.interpreter.stablecompiler.consts import SC_LOCAL, SC_GLOBAL, \
+from pypy.interpreter.testcompiler import ast, parse, walk, syntax
+from pypy.interpreter.testcompiler import pyassem, misc, future, symbols
+from pypy.interpreter.testcompiler.consts import SC_LOCAL, SC_GLOBAL, \
SC_FREE, SC_CELL, SC_DEFAULT
-from pypy.interpreter.stablecompiler.consts import CO_VARARGS, CO_VARKEYWORDS, \
+from pypy.interpreter.testcompiler.consts import CO_VARARGS, CO_VARKEYWORDS, \
CO_NEWLOCALS, CO_NESTED, CO_GENERATOR, CO_GENERATOR_ALLOWED, CO_FUTURE_DIVISION
-from pypy.interpreter.stablecompiler.pyassem import TupleArg
+from pypy.interpreter.testcompiler.pyassem import TupleArg
# XXX The version-specific code can go, since this code only works with 2.x.
# Do we have Python 1.x or Python 2.x?
Modified: pypy/dist/pypy/interpreter/testcompiler/symbols.py
==============================================================================
--- pypy/dist/pypy/interpreter/stablecompiler/symbols.py (original)
+++ pypy/dist/pypy/interpreter/testcompiler/symbols.py Tue Sep 6 14:17:04 2005
@@ -1,9 +1,9 @@
"""Module symbol-table generator"""
-from pypy.interpreter.stablecompiler import ast
-from pypy.interpreter.stablecompiler.consts import SC_LOCAL, SC_GLOBAL, \
+from pypy.interpreter.testcompiler import ast
+from pypy.interpreter.testcompiler.consts import SC_LOCAL, SC_GLOBAL, \
SC_FREE, SC_CELL, SC_UNKNOWN, SC_DEFAULT
-from pypy.interpreter.stablecompiler.misc import mangle
+from pypy.interpreter.testcompiler.misc import mangle
import types
@@ -431,7 +431,7 @@
if __name__ == "__main__":
import sys
- from pypy.interpreter.stablecompiler import parseFile, walk
+ from pypy.interpreter.testcompiler import parseFile, walk
import symtable
def get_names(syms):
Modified: pypy/dist/pypy/interpreter/testcompiler/syntax.py
==============================================================================
--- pypy/dist/pypy/interpreter/stablecompiler/syntax.py (original)
+++ pypy/dist/pypy/interpreter/testcompiler/syntax.py Tue Sep 6 14:17:04 2005
@@ -9,7 +9,7 @@
errors.
"""
-from pypy.interpreter.stablecompiler import ast, walk
+from pypy.interpreter.testcompiler import ast, walk
def check(tree, multi=None):
v = SyntaxErrorChecker(multi)
Modified: pypy/dist/pypy/interpreter/testcompiler/transformer.py
==============================================================================
--- pypy/dist/pypy/interpreter/stablecompiler/transformer.py (original)
+++ pypy/dist/pypy/interpreter/testcompiler/transformer.py Tue Sep 6 14:17:04 2005
@@ -27,10 +27,10 @@
# make sure we import the parser with the correct grammar
import pypy.interpreter.pyparser.pythonparse
-from pypy.interpreter.stablecompiler.ast import *
+from pypy.interpreter.testcompiler.ast import *
import parser
-import pypy.interpreter.pyparser.pysymbol as symbol
-import pypy.interpreter.pyparser.pytoken as token
+import symbol as symbol
+import token as token
import sys
# transforming is requiring a lot of recursion depth so make sure we have enough
Modified: pypy/dist/pypy/interpreter/testcompiler/visitor.py
==============================================================================
--- pypy/dist/pypy/interpreter/stablecompiler/visitor.py (original)
+++ pypy/dist/pypy/interpreter/testcompiler/visitor.py Tue Sep 6 14:17:04 2005
@@ -1,4 +1,4 @@
-from pypy.interpreter.stablecompiler import ast
+from pypy.interpreter.testcompiler import ast
# XXX should probably rename ASTVisitor to ASTWalker
# XXX can it be made even more generic?
More information about the Pypy-commit
mailing list