From b5ebb8abad1e8877ead643aa4d5abae765d45787 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Thu, 17 Feb 2011 13:49:28 +0100 Subject: peg; syntax helper cleanups * module/ice-9/peg.scm (until, single?, push!): Move outside the eval-when. Use syntax-rules, and single? is faster now. --- module/ice-9/peg.scm | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'module/ice-9') diff --git a/module/ice-9/peg.scm b/module/ice-9/peg.scm index 9419dd5c8..7ae6bd5f9 100644 --- a/module/ice-9/peg.scm +++ b/module/ice-9/peg.scm @@ -35,10 +35,9 @@ peg:substring peg-record? keyword-flatten) + #:use-module (system base pmatch) #:use-module (ice-9 pretty-print)) -(eval-when (compile load eval) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;; LOOPING CONSTRUCTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -50,7 +49,7 @@ ((_ test stmt stmt* ...) (let lp () (or action - (begin stmt stmt* (lp))))))) + (begin stmt stmt* ... (lp))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;; GENERIC LIST-PROCESSING MACROS @@ -59,17 +58,19 @@ ;; Return #t if the list has only one element (calling length all the time on ;; potentially long lists was really slow). (define-syntax single? - (lambda (x) - (syntax-case x () - ((_ lst) - #'(and (list? lst) (not (null? lst)) (null? (cdr lst))))))) + (syntax-rules () + ((_ x) + (pmatch x + ((_) #t) + (else #f))))) ;; Push an object onto a list. (define-syntax push! - (lambda (x) - (syntax-case x () - ((_ lst obj) - #'(set! lst (cons obj lst)))))) + (syntax-rules () + ((_ lst obj) + (set! lst (cons obj lst))))) + +(eval-when (compile load eval) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;; CODE GENERATORS -- cgit v1.2.1