According to the docs for syntax-parse/#:literals [1], "syntax-parse requires 
all literals to have a binding", and "the syntax-patterns are interpreted as if 
each occurrence of pattern-id were replaced with the following pattern: 
(~literal literal-id #:phase phase-expr)"

So, this error makes sense, because foo has no binding:

    > (require syntax/parse)
    > (syntax-parse #'(a foo b) #:literals (foo) [(x foo y) 'ok])
    ; readline-input:31:38: syntax-parse: literal is unbound in phase 0 (phase 
0 relative to the enclosing module) at: foo

but when I use the expanded version, there is no error:

    > (syntax-parse #'(a foo b) [(x (~literal foo) y) 'ok])
    'ok
    > (syntax-parse #'(a foo b) [(x (~literal foo #:phase 0) y) 'ok])
    'ok
    > (syntax-parse #'(a foo b) [(x (~literal foo #:phase 1) y) 'ok])
    'ok

What am I missing here?

[1] 
https://docs.racket-lang.org/syntax/Parsing_Syntax.html#(form._((lib._syntax%2Fparse..rkt)._syntax-parse))

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/sigid.2705c4f2af.20210312172948.GA5134%40papaya.papaya.

Reply via email to