On Mon, Jan 21, 2013 at 1:04 PM, Lorenz Köhl <rainbowtw...@gmail.com> wrote:
> How can I match datums more concisely with syntax-parse?
>
> I get syntax objects like this from ragg:
>
> #'(old-timestamp (old-date 2 23) (time-of-day 2 ":" 23 ":" 42))
>
> The parts I care about are the numbers. I write patterns like
>
> ((~datum old-timestamp)
>       ((~datum old-date) month day)
>       ((~datum time-of-day) hour ":" minute ":" second))
>
> to extract them. But with longer syntax the patterns gets messy. I tried 
> #:literals (foo ..) but I don't know what binding I should give to the ids 
> and how (and why).


Hi Lorenz!


Does the following help?

    https://gist.github.com/4589601

The idea is that replace-context from the syntax/strip-context library
can update the lexical context of the syntax objects.  We can then
later use #:literal-set without trouble.

I need some feedback from syntax/parse users to figure out what Ragg
should do here to integrate better with syntax-parse.  I really did
want ragg output to return syntax objects with no initial
interpretation assigned to them, to fit in with the A-ness of the AST.


> Is there an equivalent to #:datums (old-timestamp time-of-day …) in 
> syntax-parse?

I've wondered about this as well.


Best of wishes!

____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to