Re: [racket-users] syntax-parse: using expr/c with ~optional

2017-03-22 Thread Dupéron Georges
> (prefix 6 5 4) raises the same error as before, and the definition of > prefix/parse complains "syntax-parse: duplicate attribute in: tail". This is because ~or behaves differently under ellipses, and nested ~or are just inlined. Your code for prefix/parse is therefore equivalent to (~or alt1

Re: [racket-users] syntax-parse: using expr/c with ~optional

2017-03-21 Thread Philip McGrath
Thanks! Is there an equivalent approach that works to replace ~optional as a repetition constraint? Given: (define-syntax (prefix stx) > (syntax-parse stx > [(_ (~or (~seq nat:exact-nonnegative-integer) > (~optional (~seq #:tail tail) > #:defaults ([tail

Re: [racket-users] syntax-parse: using expr/c with ~optional

2017-03-20 Thread Alex Knauth
> On Mar 20, 2017, at 11:04 AM, Philip McGrath wrote: > > Using expr/c to attach a contract to a macro sub-pattern doesn't seem to work > with ~optional, even when the attribute is bound with #:defaults. > > For example, this program: > #lang racket > (require

[racket-users] syntax-parse: using expr/c with ~optional

2017-03-20 Thread Philip McGrath
Using expr/c to attach a contract to a macro sub-pattern doesn't seem to work with ~optional, even when the attribute is bound with #:defaults. For example, this program: > #lang racket (require (for-syntax syntax/parse)) > (define-syntax (example stx) > (syntax-parse stx > [(_ (~optional