[plt-scheme] Storing syntax

From: Chongkai Zhu (czhu at cs.utah.edu)
Date: Tue Dec 15 12:37:40 EST 2009

Use syntax-property and 'certify-mode.

Chongkai

Marco Monteiro wrote:
> I'm trying to store a representation of the expanded code in some module.
> I'm currently using one method that translates the syntax to an AST when
> expanding the #%module-begin in my language. I am experimenting with
> storing the syntax instead, like so:
>
> (define-syntax (_#%module-begin stx)
>  (syntax-case stx ()
>    [(_ . forms)
>     (let ([a (local-expand (syntax/loc stx (#%plain-module-begin . forms))
>                            'module-begin '())])
>       (with-syntax ([code a]
>                     [(_ body ...) a])
>         (syntax/loc stx (#%module-begin
>                          (mute body) ...
>                          (add-code #'code)))))]))
>
> . In this code, the add-code procedure stores the syntax object.
>
> This almost works. The problem is that the expanded code can contain
> identifiers from other modules that are not exported, so I get errors like
> "compile: access from an uncertified context to unexported variable
> from module".
>
> In some cases, I don't have access to the macros. For example, I'm using
> quasiquote from scheme that expands to use qq-expand that is not exported.
>
> Is it possible to make this, or something similar, work?
>
> Marco
> ------------------------------------------------------------------------
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>   



Posted on the users mailing list.