From 0b61da75fed6cf871a0a90d34baf77ece7238605 Mon Sep 17 00:00:00 2001 From: Noah Lavine Date: Sun, 30 Jan 2011 16:10:07 -0500 Subject: [PATCH] peg: lower datum->syntax in cg-range case * module/ice-9/peg.scm (cg-range): Datum->syntax here... (peg-sexp-compile): ...instead of here. --- module/ice-9/peg.scm | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/module/ice-9/peg.scm b/module/ice-9/peg.scm index a2f4ca999..e33645419 100644 --- a/module/ice-9/peg.scm +++ b/module/ice-9/peg.scm @@ -184,15 +184,18 @@ ;; Generates code for matching a range of characters between start and end. ;; E.g.: (cg-range syntax #\a #\z 'body) (define (cg-range for-syntax start end accum) - (safe-bind - (str strlen at c) - (cggl for-syntax str strlen at - `(let ((,c (string-ref ,str ,at))) - (if (and - (char>=? ,c ,start) - (char<=? ,c ,end)) - ,(cggr for-syntax accum 'cg-range `(string ,c) `(+ ,at 1)) - #f))))) + (let ((str (syntax str)) + (strlen (syntax strlen)) + (at (syntax at)) + (c (syntax c))) + (datum->syntax for-syntax + (cggl for-syntax str strlen at + `(let ((,c (string-ref ,str ,at))) + (if (and + (char>=? ,c ,start) + (char<=? ,c ,end)) + ,(cggr for-syntax accum 'cg-range `(string ,c) `(+ ,at 1)) + #f)))))) ;; Filters the accum argument to peg-sexp-compile for buildings like string ;; literals (since we don't want to tag them with their name if we're doing an @@ -228,8 +231,7 @@ (error-val `(peg-sexp-compile-error-1 ,match ,accum)))) ((eq? (car match) 'range) ;; range of characters (e.g. [a-z]) - (datum->syntax for-syntax - (cg-range for-syntax (cadr match) (caddr match) (baf accum)))) + (cg-range for-syntax (cadr match) (caddr match) (baf accum))) ((eq? (car match) 'ignore) ;; match but don't parse (peg-sexp-compile for-syntax (cadr match) 'none)) ((eq? (car match) 'capture) ;; parse