[racket] syntax-case and multiple ellipsis

From: Spencer Florence (spencer at florence.io)
Date: Tue Jun 17 14:45:57 EDT 2014

Silly me, I was trying (require syntax/parse). Thanks!


On Tue, Jun 17, 2014 at 1:26 PM, Stephen Chang <stchang at ccs.neu.edu> wrote:

> Hmm, you might need to provide some more details about what you are
> trying to define then? (This particular example seems to work with
> syntax-parse in TR)
>
> #lang typed/racket
> (require (for-syntax syntax/parse))
>
> (define-syntax (test stx)
>   (syntax-parse stx #:datum-literals (in def)
>     [(_ name
>         (def a ...) ...
>         (in clause do ...) ...)
>      #'(list a ... ... do ... ...)]))
>
> (test A (def 1 2 3) (in 4 5 6))
>
> On Tue, Jun 17, 2014 at 2:08 PM, Spencer Florence <spencer at florence.io>
> wrote:
> > Unfortunately I'm working in typed racket, which (as far as I can tell)
> > doesn't play nice with syntax-parse. Any other ideas?
> >
> >
> > On Tue, Jun 17, 2014 at 1:04 PM, Jens Axel Søgaard <
> jensaxel at soegaard.net>
> > wrote:
> >>
> >> Hi Spencer,
> >>
> >> The problem is that syntax-case pattern doesn't allow allow
> >> pattern of the form (x ... y ...) that is with two ellipsis on the
> >> same level.
> >>
> >> Luckily syntax-parse allow these:
> >>
> >> (require syntax/parse)
> >>
> >> (syntax-parse #'(a a a a 41 42 43)
> >>   [(c ... d ...)
> >>    #''((c ...) (d ...))])
> >>
> >> (syntax-parse #'(a a a a 41 42 43)
> >>   [(c:id ... d ...)
> >>    #''((c ...) (d ...))])
> >>
> >>
> >> /Jens Axel
> >>
> >>
> >>
> >>
> >> 2014-06-17 19:46 GMT+02:00 Spencer Florence <florence at northwestern.edu
> >:
> >> > Hey all,
> >> >
> >> > I'm trying to write a macro with syntax-case that looks something like
> >> > this:
> >> >
> >> >  (syntax-case stx (in def)
> >> >     [(_ name
> >> >         (def a ...) ...
> >> >         (in clause do ...) ...)
> >> >      stuff])
> >> >
> >> > But, this gives me the error "syntax-case: misplaced ellipsis in
> pattern
> >> > (follows other ellipsis)" on the last ellipsis. Does anyone know a way
> >> > around this?
> >> >
> >> > --spencer
> >> >
> >> > ____________________
> >> >   Racket Users list:
> >> >   http://lists.racket-lang.org/users
> >> >
> >>
> >>
> >>
> >> --
> >> --
> >> Jens Axel Søgaard
> >>
> >> ____________________
> >>   Racket Users list:
> >>   http://lists.racket-lang.org/users
> >
> >
> >
> > ____________________
> >   Racket Users list:
> >   http://lists.racket-lang.org/users
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140617/94598cd0/attachment-0001.html>

Posted on the users mailing list.