[pypy-svn] r44741 - in pypy/dist/pypy/lang/scheme: . test

jlg at codespeak.net jlg at codespeak.net
Thu Jul 5 16:26:08 CEST 2007


Author: jlg
Date: Thu Jul  5 16:26:07 2007
New Revision: 44741

Modified:
   pypy/dist/pypy/lang/scheme/ssparser.py
   pypy/dist/pypy/lang/scheme/test/test_parser.py
Log:
dotted list parsing

Modified: pypy/dist/pypy/lang/scheme/ssparser.py
==============================================================================
--- pypy/dist/pypy/lang/scheme/ssparser.py	(original)
+++ pypy/dist/pypy/lang/scheme/ssparser.py	Thu Jul  5 16:26:07 2007
@@ -47,7 +47,8 @@
         return {s};
     
     sexpr:
-        list
+        dotted
+      | list
       | FLOAT
       | FIXNUM
       | BOOLEAN
@@ -62,6 +63,17 @@
         IGNORE*
         return {p};
 
+    dotted:
+        '('
+        IGNORE*
+        car = sexpr
+        '.'
+        IGNORE*
+        cdr = sexpr
+        ')'
+        IGNORE*
+        return {W_Pair(car, cdr)};
+        
     pair:
         car = sexpr
         cdr = pair

Modified: pypy/dist/pypy/lang/scheme/test/test_parser.py
==============================================================================
--- pypy/dist/pypy/lang/scheme/test/test_parser.py	(original)
+++ pypy/dist/pypy/lang/scheme/test/test_parser.py	Thu Jul  5 16:26:07 2007
@@ -100,3 +100,9 @@
     t = parse("#t")
     assert unwrap(t) == True
 
+def test_dotted():
+    t = parse("(1 . 2)")
+    assert isinstance(t, W_Pair)
+    assert unwrap(t.car) == 1
+    assert unwrap(t.cdr) == 2
+



More information about the Pypy-commit mailing list