diff options
author | Noah Lavine <nlavine@haverford.edu> | 2011-01-30 16:10:07 -0500 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2011-03-24 21:10:02 +0100 |
commit | f85c87dd8dd6b78357bba33aba2ffc47c4bfcb33 (patch) | |
tree | 0ebe7bbeebaaab64f21b8a1c3b5c21e39aa25cdc | |
parent | 28ff0654096b93c1e281ab3e89279b8caf7b80ef (diff) | |
download | guile-f85c87dd8dd6b78357bba33aba2ffc47c4bfcb33.tar.gz |
peg: lower datum->syntax in cg-range case
* module/ice-9/peg.scm (cg-range): Datum->syntax here...
(peg-sexp-compile): ...instead of here.
-rw-r--r-- | module/ice-9/peg.scm | 24 |
1 files 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 |