diff options
author | Andy Wingo <wingo@pobox.com> | 2011-02-18 10:48:22 +0100 |
---|---|---|
committer | Noah Lavine <nlavine@haverford.edu> | 2011-09-05 21:50:58 -0400 |
commit | 42e66235ad6119d5b374933c0c451d66d5873982 (patch) | |
tree | 3c10ad9e56776ce55c87c2418d971c3d4ad335d6 | |
parent | d924bc8573cc02a4160aa620b104571667f44de3 (diff) | |
download | guile-42e66235ad6119d5b374933c0c451d66d5873982.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) |