From 7b746f409017b208382021e8b5900076d6a35108 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Fri, 18 Feb 2011 10:48:22 +0100 Subject: peg: cg-string without cggl * module/ice-9/peg.scm (cg-string): Refactor to not use cggl. --- module/ice-9/peg.scm | 12 ++++++------ 1 file 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) -- cgit v1.2.1