#| -*-Scheme-*-
-$Id: list-parser.scm,v 1.1 2008/09/03 02:49:06 cph Exp $
+$Id: list-parser.scm,v 1.2 2008/09/03 05:53:44 cph Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
`(IF ,(make-test items)
,(make-body items lose)
(,lose)))))
+
+(define (wrap-list-parser parser)
+ (lambda (items)
+ (parser items
+ (lambda (items vals lose)
+ (if (null? items)
+ (list-parser-vals->list vals)
+ (lose)))
+ (lambda ()
+ #f))))
\f
(define-pattern-compiler '(MATCH-NULL)
(lambda (pattern env items win lose)
',datum))))
(lambda (items lose)
`(,win (CDR ,items) ,(null-vals) ,lose)))))
+\f
+(define-pattern-compiler '(VALUES * EXPRESSION)
+ (lambda (pattern env items win lose)
+ `(,win ,items
+ ,(let ((vals
+ (map (lambda (expr)
+ (single-val (close-syntax expr env)))
+ (cdr pattern))))
+ (if (pair? vals)
+ (let loop ((vals vals))
+ (if (pair? (cdr vals))
+ (join-vals (car vals) (loop (cdr vals)))
+ (car vals)))
+ (null-vals)))
+ ,lose)))
(define-pattern-compiler '(LIST * FORM)
(lambda (pattern env items win lose)
(,win (CDR ,items) ,vals ,lose)
(,lose))))))
lose)))))
-\f
+
(define-pattern-compiler '(SEXP EXPRESSION)
(lambda (pattern env items win lose)
`(,(close-syntax (cadr pattern) env) ,items ,win ,lose)))
vals
`(,win ,items ,(null-vals) ,lose)))
lose)))
-
+\f
(define-pattern-compiler '(? * FORM)
(lambda (pattern env items win lose)
(compile-pattern `(SEQ ,@(cdr pattern))
#| -*-Scheme-*-
-$Id: runtime.pkg,v 14.670 2008/09/03 02:49:09 cph Exp $
+$Id: runtime.pkg,v 14.671 2008/09/03 05:53:47 cph Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
(parent (runtime))
(export ()
list-parser
- list-parser-vals->list))
+ list-parser-vals->list
+ wrap-list-parser))
(define-package (runtime postgresql)
(file-case options