Re: [racket-users] help with splicing syntax class error report

2017-03-14 Thread Stephen Chang
You get the dreaded "bad syntax" because syntax-parse doesnt know
which pattern failed. There a couple of things you can do:

1) Use a commit pattern, which tells syntax-parse not to backtrack
past the commit point. You have to change the order of patterns for
this to work.

  (define-splicing-syntax-class maybe
#:datum-literals (:thing)
(pattern (~seq) #:attr n #'0)
(pattern (~seq ~! :thing n:id)))

2) Use the ~post pattern, which essentially tells syntax-parse to give
priority to a particular pattern.

  (define-splicing-syntax-class maybe
#:datum-literals (:thing)
(pattern (~post (~seq :thing n:id)))
(pattern (~seq) #:attr n #'0))

On Tue, Mar 14, 2017 at 1:13 PM, Dan Liebgold
 wrote:
> Hi -
>
> I have some legacy code syntax I'm retrofitting with syntax-parse. Is there a 
> simple way to have this type of syntax error report a better error message:
>
> http://pasterack.org/pastes/59739
>
> I'd like it to point directly to ":thung" and say it expected ":thing" or 
> nothing there if possible.
>
> Thanks,
> Dan
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] help with splicing syntax class error report

2017-03-14 Thread Dan Liebgold
Hi -

I have some legacy code syntax I'm retrofitting with syntax-parse. Is there a 
simple way to have this type of syntax error report a better error message:

http://pasterack.org/pastes/59739

I'd like it to point directly to ":thung" and say it expected ":thing" or 
nothing there if possible.

Thanks,
Dan

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.