mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-29 22:40:34 +02:00
peg: lower datum->syntax in cg-peg-any case
* module/ice-9/peg.scm (cg-peg-any): Datum->syntax here... (peg-sexp-compile): ...instead of here.
This commit is contained in:
parent
b987677437
commit
6a297af101
1 changed files with 8 additions and 7 deletions
|
@ -173,11 +173,13 @@
|
||||||
;; Generates code for matching any character.
|
;; Generates code for matching any character.
|
||||||
;; E.g.: (cg-peg-any syntax 'body)
|
;; E.g.: (cg-peg-any syntax 'body)
|
||||||
(define (cg-peg-any for-syntax accum)
|
(define (cg-peg-any for-syntax accum)
|
||||||
(safe-bind
|
(let ((str (syntax str))
|
||||||
(str strlen at)
|
(strlen (syntax strlen))
|
||||||
(cggl for-syntax str strlen at
|
(at (syntax at)))
|
||||||
(cggr for-syntax accum
|
(datum->syntax for-syntax
|
||||||
'cg-peg-any `(substring ,str ,at (+ ,at 1)) `(+ ,at 1)))))
|
(cggl for-syntax str strlen at
|
||||||
|
(cggr for-syntax accum
|
||||||
|
'cg-peg-any `(substring ,str ,at (+ ,at 1)) `(+ ,at 1))))))
|
||||||
|
|
||||||
;; Generates code for matching a range of characters between start and end.
|
;; Generates code for matching a range of characters between start and end.
|
||||||
;; E.g.: (cg-range syntax #\a #\z 'body)
|
;; E.g.: (cg-range syntax #\a #\z 'body)
|
||||||
|
@ -217,8 +219,7 @@
|
||||||
((string? match) (cg-string for-syntax match (baf accum)))
|
((string? match) (cg-string for-syntax match (baf accum)))
|
||||||
((symbol? match) ;; either peg-any or a nonterminal
|
((symbol? match) ;; either peg-any or a nonterminal
|
||||||
(cond
|
(cond
|
||||||
((eq? match 'peg-any) (datum->syntax for-syntax
|
((eq? match 'peg-any) (cg-peg-any for-syntax (baf accum)))
|
||||||
(cg-peg-any for-syntax (baf accum))))
|
|
||||||
;; if match is any other symbol it's a nonterminal, so just return it
|
;; if match is any other symbol it's a nonterminal, so just return it
|
||||||
(#t (datum->syntax for-syntax match))))
|
(#t (datum->syntax for-syntax match))))
|
||||||
((or (not (list? match)) (null? match))
|
((or (not (list? match)) (null? match))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue