diff options
author | Andy Wingo <wingo@pobox.com> | 2011-02-17 13:49:28 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2011-03-24 21:10:03 +0100 |
commit | 33d6e99e98094b9de9cde15139c2b3d1eee9606a (patch) | |
tree | a7c06cf929325d29d7a36533e17a76d220afa121 | |
parent | 82d621927d46c94009ad7b2700011e259e06eaf0 (diff) | |
download | guile-33d6e99e98094b9de9cde15139c2b3d1eee9606a.tar.gz |
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.
-rw-r--r-- | module/ice-9/peg.scm | 23 |
1 files changed, 12 insertions, 11 deletions
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 |