[pypy-commit] lang-scheme default: Fix parser helper functions
boemmels
noreply at buildbot.pypy.org
Mon Aug 29 17:01:52 CEST 2011
Author: Juergen Boemmels <boemmels at web.de>
Branch:
Changeset: r2:95db321dfa25
Date: 2011-08-29 10:29 +0200
http://bitbucket.org/pypy/lang-scheme/changeset/95db321dfa25/
Log: Fix parser helper functions
New symbols should only be created with 'symbol', this guarantees
that they are unique. Also includes a testcase which failed in old
situation.
diff --git a/scheme/object.py b/scheme/object.py
--- a/scheme/object.py
+++ b/scheme/object.py
@@ -82,8 +82,6 @@
w_obj = ctx.get(self.name)
return (w_obj, None)
-w_ellipsis = W_Symbol("...")
-
def symbol(name):
#use this to create new symbols, it stores all symbols
#in W_Symbol.obarray dict
@@ -97,6 +95,8 @@
assert isinstance(w_symb, W_Symbol)
return w_symb
+w_ellipsis = symbol("...")
+
class W_Boolean(W_Root):
def __init__(self, val):
self.boolval = bool(val)
@@ -479,16 +479,16 @@
# Parser helpers
##
def quote(sexpr):
- return W_Pair(W_Symbol('quote'), W_Pair(sexpr, w_nil))
+ return W_Pair(symbol('quote'), W_Pair(sexpr, w_nil))
def qq(sexpr):
- return W_Pair(W_Symbol('quasiquote'), W_Pair(sexpr, w_nil))
+ return W_Pair(symbol('quasiquote'), W_Pair(sexpr, w_nil))
def unquote(sexpr):
- return W_Pair(W_Symbol('unquote'), W_Pair(sexpr, w_nil))
+ return W_Pair(symbol('unquote'), W_Pair(sexpr, w_nil))
def unquote_splicing(sexpr):
- return W_Pair(W_Symbol('unquote-splicing'), W_Pair(sexpr, w_nil))
+ return W_Pair(symbol('unquote-splicing'), W_Pair(sexpr, w_nil))
##
diff --git a/scheme/test/test_eval.py b/scheme/test/test_eval.py
--- a/scheme/test/test_eval.py
+++ b/scheme/test/test_eval.py
@@ -376,6 +376,10 @@
assert isinstance(w_pair.cdr.car, W_Symbol)
assert w_pair.cdr.car.to_string() == "y"
+ w_bool = eval_noctx("(eq? 'quote (car ''foo))")
+ assert isinstance(w_bool, W_Boolean)
+ assert w_bool.to_boolean() is True
+
def test_list():
ctx = ExecutionContext()
ctx.put("var", W_Integer(42))
More information about the pypy-commit
mailing list