Hi all,<br><br>I came across this nested macro expression, found at <a href="http://fabiokung.com/2007/10/24/ruby-dsl-to-describe-automata/">http://fabiokung.com/2007/10/24/ruby-dsl-to-describe-automata/</a> :<br><br><span style="font-family: courier new,monospace;">(define-syntax automaton (syntax-rules (:)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> [(_ init-state</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> [state : response ...]</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ...)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (let-syntax ([process-state (syntax-rules (-> accept)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> [(_ accept)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (lambda (stream)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (cond [(null? stream) #t]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> [else #f]))]</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> [(_ (label -> target) (... ...))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (lambda (stream)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (cond [(null? stream) #f]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> [else (case (car stream)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> [(label) (target (cdr stream))]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (... ...)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> [else #f])]))])])</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (letrec ([state (process-state response ...)]</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ...)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> init-state))]))</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(define cdar-sequence?</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (automaton init</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> [init : (c -> more)]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> [more : (a -> more)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (d -> more)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (r -> end)]</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> [end : accept]))</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;" clear="all"><span style="font-family: courier new,monospace;">(cdar-sequence? '(c a d a d r)) ; => #t</span><br style="font-family: courier new,monospace;" clear="all">
<span style="font-family: courier new,monospace;">(cdar-sequence? '(a c a d r c)) ; => #f</span><br><br>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?<br>
<br><br>-- <br>James Coglan<br><a href="http://github.com/jcoglan/heist">http://github.com/jcoglan/heist</a><br>