[plt-scheme] Nested macros and (... ...)
Hi all,
I came across this nested macro expression, found at
http://fabiokung.com/2007/10/24/ruby-dsl-to-describe-automata/ :
(define-syntax automaton (syntax-rules (:)
[(_ init-state
[state : response ...]
...)
(let-syntax ([process-state (syntax-rules (-> accept)
[(_ accept)
(lambda (stream)
(cond [(null? stream) #t]
[else #f]))]
[(_ (label -> target) (... ...))
(lambda (stream)
(cond [(null? stream) #f]
[else (case (car stream)
[(label) (target (cdr stream))]
(... ...)
[else #f])]))])])
(letrec ([state (process-state response ...)]
...)
init-state))]))
(define cdar-sequence?
(automaton init
[init : (c -> more)]
[more : (a -> more)
(d -> more)
(r -> end)]
[end : accept]))
(cdar-sequence? '(c a d a d r)) ; => #t
(cdar-sequence? '(a c a d r c)) ; => #f
Am I right in thinking that (... ...) is a way of placing a literal ... in
the expansion without it being treated as a repetition pattern by the first
expansion?
--
James Coglan
http://github.com/jcoglan/heist
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090305/a00d21bc/attachment.html>