peg: lower datum->syntax in cg-string case
authorNoah Lavine <nlavine@haverford.edu>
Sun, 30 Jan 2011 21:04:36 +0000 (16:04 -0500)
committerAndy Wingo <wingo@pobox.com>
Wed, 16 Jan 2013 09:11:30 +0000 (10:11 +0100)
* module/ice-9/peg.scm (cg-string): Return syntax instead of
  s-expressions.
  (peg-sexp-compile): No need for datum->string in cg-string case.

module/ice-9/peg.scm

index c373d5c..261a53e 100644 (file)
 ;; Generates code that matches a particular string.
 ;; E.g.: (cg-string syntax "abc" 'body)
 (define (cg-string for-syntax match accum)
-  (safe-bind
-   (str strlen at)
-   (let ((len (string-length match)))
+  (let ((str (syntax str))
+        (strlen (syntax strlen))
+        (at (syntax at))
+        (len (string-length match)))
+    (datum->syntax for-syntax
      (cggl for-syntax str strlen at
            `(if (string=? (substring ,str ,at (min (+ ,at ,len) ,strlen))
                           ,match)
 ;; E.g.: (peg-sexp-compile syntax '(and "abc" (or "-" (range #\a #\z))) 'all)
 (define (peg-sexp-compile for-syntax match accum)
   (cond
-   ((string? match) (datum->syntax for-syntax
-                                   (cg-string for-syntax match (baf accum))))
+   ((string? match) (cg-string for-syntax match (baf accum)))
    ((symbol? match) ;; either peg-any or a nonterminal
     (cond
      ((eq? match 'peg-any) (datum->syntax for-syntax