diff options
author | Andy Wingo <wingo@pobox.com> | 2011-02-17 13:49:28 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-01-16 10:11:35 +0100 |
commit | b5ebb8abad1e8877ead643aa4d5abae765d45787 (patch) | |
tree | 1454efc56e2b71ca915b490c15fff7d121954d6f /module/ice-9 | |
parent | 3c8963de27babbb85d6ff243645658cb0b8f0756 (diff) | |
download | guile-b5ebb8abad1e8877ead643aa4d5abae765d45787.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.
Diffstat (limited to 'module/ice-9')
-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 |