guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, master, updated. release_1-9-12-99-g1f


From: Ludovic Courtès
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-12-99-g1ffed5a
Date: Mon, 27 Sep 2010 20:50:52 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=1ffed5aa95d66123a552fa3513373e78a1679287

The branch, master has been updated
       via  1ffed5aa95d66123a552fa3513373e78a1679287 (commit)
      from  56ec46a7c3f8761b3e1f4fb2f957882636fbaaee (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1ffed5aa95d66123a552fa3513373e78a1679287
Author: Ludovic Courtès <address@hidden>
Date:   Mon Sep 27 22:50:36 2010 +0200

    Add support for `..1' to `match'.
    
    Patch accepted upstream:
    <http://lists.gnu.org/archive/html/guile-devel/2010-09/threads.html#00114>.
    
    * module/ice-9/match.upstream.scm (match-two): Add support for `..1'.
    
    * test-suite/tests/match.test ("matches")["list ..1", "list ..1, with
      predicate"]: New tests.
      ("doesn't match")["list ..1", "list ..1, with predicate"]: New tests.

-----------------------------------------------------------------------

Summary of changes:
 module/ice-9/match.upstream.scm |    6 +++++-
 test-suite/tests/match.test     |   23 ++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/module/ice-9/match.upstream.scm b/module/ice-9/match.upstream.scm
index 963b89f..bf3335b 100644
--- a/module/ice-9/match.upstream.scm
+++ b/module/ice-9/match.upstream.scm
@@ -125,7 +125,7 @@
 ;; pattern so far.
 
 (define-syntax match-two
-  (syntax-rules (_ ___ *** quote quasiquote ? $ = and or not set! get!)
+  (syntax-rules (_ ___ ..1 *** quote quasiquote ? $ = and or not set! get!)
     ((match-two v () g+s (sk ...) fk i)
      (if (null? v) (sk ... i) fk))
     ((match-two v (quote p) g+s (sk ...) fk i)
@@ -161,6 +161,10 @@
      (match-extract-vars p (match-gen-search v p q g+s sk fk i) i ()))
     ((match-two v (p *** . q) g+s sk fk i)
      (match-syntax-error "invalid use of ***" (p *** . q)))
+    ((match-two v (p ..1) g+s sk fk i)
+     (if (pair? v)
+         (match-one v (p ___) g+s sk fk i)
+         fk))
     ((match-two v (p . q) g+s sk fk i)
      (if (pair? v)
          (let ((w (car v)) (x (cdr v)))
diff --git a/test-suite/tests/match.test b/test-suite/tests/match.test
index 70a15ec..d1432d8 100644
--- a/test-suite/tests/match.test
+++ b/test-suite/tests/match.test
@@ -67,6 +67,16 @@
         ((x . rest)
          (and (eq? x 'a) (equal? rest '(b c)))))))
 
+  (pass-if "list ..1"
+    (match '(a b c)
+      ((x ..1)
+       (equal? x '(a b c)))))
+
+  (pass-if "list ..1, with predicate"
+    (match '(a b c)
+      (((and x (? symbol?)) ..1)
+       (equal? x '(a b c)))))
+
   (pass-if "tree"
     (let ((tree '(one (two 2) (three 3 (and 4 (and 5))))))
       (match tree
@@ -79,4 +89,15 @@
   (pass-if-exception "tree"
     exception:match-error
     (match '(a (b c))
-      ((foo (bar)) #t))))
+      ((foo (bar)) #t)))
+
+  (pass-if-exception "list ..1"
+    exception:match-error
+    (match '()
+      ((x ..1) #f)))
+
+  (pass-if-exception "list ..1, with predicate"
+    exception:match-error
+    (match '(a 0)
+      (((and x (? symbol?)) ..1)
+       (equal? x '(a b c))))))


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]