From a5b8d28dd7a97455f4bc1289cb12d3e9388fe2c6 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sun, 31 Aug 2008 07:53:07 +0000 Subject: [PATCH] Implement new *parser forms ENCAPSULATE* and TRANSFORM* that call their procedure with the values spread out as arguments. TRANSFORM* additionally expects the procedure to return multiple values. --- v7/src/star-parser/parser.scm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/v7/src/star-parser/parser.scm b/v7/src/star-parser/parser.scm index 13bf9d910..0a48cd5bf 100644 --- a/v7/src/star-parser/parser.scm +++ b/v7/src/star-parser/parser.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: parser.scm,v 1.39 2008/01/30 20:02:40 cph Exp $ +$Id: parser.scm,v 1.40 2008/08/31 07:53:07 cph Exp $ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, @@ -134,6 +134,20 @@ USA. ,@(if ptr (list v) '()) (PARSER-BUFFER-ERROR ,(or ptr v) ,msg ,@irritants)))))) +(define-*parser-expander 'ENCAPSULATE* + (lambda (procedure expression) + `(ENCAPSULATE (LAMBDA (V) (APPLY ,procedure (VECTOR->LIST V))) + ,expression))) + +(define-*parser-expander 'TRANSFORM* + (lambda (procedure expression) + `(TRANSFORM (LAMBDA (V) + (CALL-WITH-VALUES + (LAMBDA () + (APPLY ,procedure (VECTOR->LIST V))) + VECTOR)) + ,expression))) + (define-parser-preprocessor '(ALT SEQ) (lambda (expression external-bindings internal-bindings) `(,(car expression) -- 2.25.1