A couple questions about literals in syntax-parse:
1. I'd like to make a syntax-class that is just a set of literals (with a clear error for something not matching any literal). Is there a better way than this:
http://pasterack.org/pastes/86722
I need to ignore the bindings for those identifiers, and I need to preserve the syntax context.
2. Is there any plan or easy way to implement #:datum-literal-sets for syntax-classes? It'd be nice to share a list of literals (with ignored bindings) among multiple classes.
Thanks,
Dan
Ah, oops I missed that keyword parameter.
> For question 1, that's probably the best way. If you want to suppress
> the printing of all of the datum literals in error messages, you can
> mark the syntax class as `#:opaque`.
>
I was more wanting to avoid keeping two lists of the literals in the source... I *do* want the error to enumerate possibilities.
> In principle, you could also use `literal-set->predicate`, but I just
> discovered it ignores the datum literals. I'll push a fix.
>
I saw that... assuming it worked, I'm not sure how/where I would put that..
Hmm... I can't quite figure that one out. Maybe with some examples? How does the ":spec" in the pattern work? It's just a class specified....
The examples in TR seem to declare classes one literal at a time?
> Its companion `define-merged-syntax-class` is quite nice too.
>
> https://github.com/racket/typed-racket/blob/master/typed-racket-lib/typed-racket/optimizer/utils.rkt#L110
>
I was just looking for exactly that... very useful.