summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2011-02-18 10:48:22 +0100
committerAndy Wingo <wingo@pobox.com>2013-01-16 10:11:38 +0100
commit7b746f409017b208382021e8b5900076d6a35108 (patch)
treecb95939e67ba7218065f564aa3ec11b221d75546
parent990b24b2541e375357b49a22c414776f75e5aeca (diff)
downloadguile-7b746f409017b208382021e8b5900076d6a35108.tar.gz
peg: cg-string without cggl
* module/ice-9/peg.scm (cg-string): Refactor to not use cggl.
-rw-r--r--module/ice-9/peg.scm12
1 files changed, 6 insertions, 6 deletions
diff --git a/module/ice-9/peg.scm b/module/ice-9/peg.scm
index 9735d6628..041636d0c 100644
--- a/module/ice-9/peg.scm
+++ b/module/ice-9/peg.scm
@@ -142,12 +142,12 @@ return EXP."
;; Generates code that matches a particular string.
;; E.g.: (cg-string syntax "abc" 'body)
(define (cg-string for-syntax match accum)
- (let ((len (string-length match)))
- (cggl for-syntax #'str #'strlen #'at
- #`(if (string= str #,match at (min (+ at #,len) strlen))
- #,(cggr for-syntax accum 'cg-string match
- #`(+ at #,len))
- #f))))
+ (let ((mlen (string-length match)))
+ #`(lambda (str len pos)
+ (and (<= (+ pos #,mlen) len)
+ (string= str #,match pos (+ pos #,mlen))
+ #,(cggr for-syntax accum 'cg-string match
+ #`(+ pos #,mlen))))))
;; Generates code for matching any character.
;; E.g.: (cg-peg-any syntax 'body)