[racket] syntax-parse and literals

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Fri Sep 2 21:36:01 EDT 2011

syntax-parse requires literals to be bound, it will never match just
based on the identifier symbol

A standard thing is to do:

(define-syntax (: stx) (raise-syntax-error stx ': "Cannot be used outside ..."))

and then export :

Jay

On Fri, Sep 2, 2011 at 7:31 PM, Shriram Krishnamurthi <sk at cs.brown.edu> wrote:
> I am having some trouble figuring out how to use syntax-parse in
> combination with wanting literals (aka, internal keywords) in a macro
> definition.  I have
>
>  (syntax-case stx (:)
>
> and am trying to achieve a similar effect.  I tried
>
>  (syntax-parse stx #:literals(:)
>
> but that resulted in
>
>  syntax-parse: literal is unbound in phase 0 (phase 0 relative to the
> enclosing module) in: :
>
> I don't see an example of this in the docs.  Since I have only one
> literal, I was hoping to avoid the complexity of literal-sets --
> basically, attain the equivalent of the (:) in syntax-case.
>
> Thanks!
>
> Shriram
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93



Posted on the users mailing list.