[pypy-svn] r14879 - in pypy/dist/pypy/interpreter/pyparser: . test
adim at codespeak.net
adim at codespeak.net
Thu Jul 21 18:27:25 CEST 2005
Author: adim
Date: Thu Jul 21 18:27:23 2005
New Revision: 14879
Modified:
pypy/dist/pypy/interpreter/pyparser/astbuilder.py
pypy/dist/pypy/interpreter/pyparser/test/test_astbuilder.py
Log:
still make more tests pass
TODO: we should directly put methods like 'to_lvalue()'
in the ast nodes classes (ast.Tuple, ast.Name, etc.) in order
to avoid code like :
if isinstance(ast_node, ast.Tuple):
...
elif:
...
TODO2: replace calls to eval() with appropriate RPYTHON implementations
Modified: pypy/dist/pypy/interpreter/pyparser/astbuilder.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyparser/astbuilder.py (original)
+++ pypy/dist/pypy/interpreter/pyparser/astbuilder.py Thu Jul 21 18:27:23 2005
@@ -13,6 +13,11 @@
def to_lvalue( ast_node, OP ):
if isinstance( ast_node, ast.Name ):
return ast.AssName( ast_node.name, OP )
+ elif isinstance(ast_node, ast.Tuple):
+ nodes = []
+ for node in ast_node.getChildren():
+ nodes.append(ast.AssName(node.name, consts.OP_ASSIGN))
+ return ast.AssTuple(nodes)
else:
assert False, "TODO"
@@ -63,6 +68,14 @@
def build_single_input( builder, nb ):
pass
+def eval_number(value):
+ """temporary implementation"""
+ return eval(value)
+
+def eval_string(value):
+ """temporary implementation"""
+ return eval(value)
+
def build_atom( builder, nb ):
L = get_atoms( builder, nb )
top = L[0]
@@ -77,12 +90,12 @@
elif top.name == tok.NAME:
builder.push( ast.Name(top.value) )
elif top.name == tok.NUMBER:
- builder.push( ast.Const(eval(top.value)) )
+ builder.push( ast.Const(eval_number(top.value)) )
elif top.name == tok.STRING:
# need to concatenate strings in L
s = ''
for token in L:
- s += eval(token.value)
+ s += eval_string(token.value)
builder.push( ast.Const(s) )
# assert False, "TODO (String)"
else:
Modified: pypy/dist/pypy/interpreter/pyparser/test/test_astbuilder.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyparser/test/test_astbuilder.py (original)
+++ pypy/dist/pypy/interpreter/pyparser/test/test_astbuilder.py Thu Jul 21 18:27:23 2005
@@ -25,8 +25,10 @@
"x, y, z = 1, 2, 3",
"x = 'a' 'b' 'c'",
]
-expression_tests = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 15] # = range(len(expressions))
-failed_expression_tests = [ 13, 14]
+expression_tests = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15] # = range(len(expressions))
+# expression_tests = [14]
+
+failed_expression_tests = [ 13]
comparisons = [
"a < b",
More information about the Pypy-commit
mailing list