<div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Apr 27, 2012 at 14:18, Sam Tobin-Hochstadt <span dir="ltr"><<a href="mailto:samth@ccs.neu.edu" target="_blank">samth@ccs.neu.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Fri, Apr 27, 2012 at 8:03 AM, Laurent <<a href="mailto:laurent.orseau@gmail.com">laurent.orseau@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> I'm trying to match form declarations that can contain optional<br>
> keyword-followed-by-something (more precisely matching "defforms"<br>
> declarations).<br>
> It looks like (id [#:kw1 val1] x [#:kw2 val2] ....) where the [] means<br>
> optional.<br>
> For example the list to match may be '(a b) or '(a #:kw1 1 b) or '(a b<br>
> #:kw2 2) or '(a #:kw1 3 b #:kw2 4), etc.<br>
><br>
> But I couldn't figure out how to say "match 2 things one after the other, 0<br>
> or 1 time".<br>
> Something like that could do it:<br>
> (match L<br>
> [`(,id ,@(list '#:kw1 v1) ... ,x ,@(list '#:kw2 v2) ... ....)<br>
> ....])<br>
><br>
> but nothing I tried got close to it (the ... are quoted and don't like being<br>
> unquoted).<br>
> Google gave me that result:<br>
> <a href="http://stackoverflow.com/questions/7061533/match-form-in-racket-scheme-question-about-matching-sequences" target="_blank">http://stackoverflow.com/questions/7061533/match-form-in-racket-scheme-question-about-matching-sequences</a><br>
> but that's not really what I'm after.<br>
><br>
> Is there any way to do that with match patterns without doing some<br>
> recurrence over `match' myself (and not writing all the possible composition<br>
> of with/without each keyword)?<br>
<br>
</div></div>`match' doesn't support the repetition constraints and other<br>
extensions to ... patterns that `syntax-parse' does. `list-no-order'<br>
patterns might be helpful here, though.<br></blockquote><div><br>ok, never mind, tanks.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
If you're processing the contents of a `defform' call, probably the<br>
right thing to do is just just use `syntax-parse' -- it's great for<br>
this sort of thing.<br></blockquote><div><br>Actually, the defforms are read directly from a scribble file, so it's not a call.<br>Is it possible to have syntax-parse deal directly with values instead of syntax objects?<br>
</div></div>(I suppose I could turn the read list into a syntax object, but that's probably not the best way to do it, is it?)<br></div>