1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-29 14:30:34 +02:00

peg: cg-string without cggl

* module/ice-9/peg.scm (cg-string): Refactor to not use cggl.
This commit is contained in:
Andy Wingo 2011-02-18 10:48:22 +01:00
parent 990b24b254
commit 7b746f4090

View file

@ -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)