This is from the documentation and it obviously works:

(define parser1
  (syntax-parser
    [((~alt (~once (~seq #:a x) #:name "#:a keyword")
            (~optional (~seq #:b y) #:name "#:b keyword")
            (~seq #:c z)) ...)
     'ok]))
(parser1 #'(#:a 1))

When run it yields 'ok.

If I change it to this, it fails and I don't understand why:

(define (parser2 stx)
  (syntax-parse stx
    [(parser2 ((~alt (~once (~seq #:a x) #:name "#:a keyword")
                     (~optional (~seq #:b y) #:name "#:b keyword")
                     (~seq #:c z)) ...))
     #''ok]))
(parser2 (#:a 1))

This yields:
[...source location...] #%datum: keyword misused as an expression
;   at: #:a


I can see that (#:a 1) is not valid under the default parser since #:a is
not valid for initial position but shouldn't the entire parenthesized
expression be given to the macro processor and then replaced with something
valid before being rejected?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKofDYFY8AYb2Lyh7CQXx1i01w8jm4DVcMrJL%3DQYHX9SsRQ%40mail.gmail.com.

Reply via email to