diff options
author | Andy Wingo <wingo@pobox.com> | 2011-02-18 10:48:22 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-01-16 10:11:38 +0100 |
commit | 7b746f409017b208382021e8b5900076d6a35108 (patch) | |
tree | cb95939e67ba7218065f564aa3ec11b221d75546 | |
parent | 990b24b2541e375357b49a22c414776f75e5aeca (diff) | |
download | guile-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.scm | 12 |
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) |