[racket] How to communicate from macro to DrRacket tool ?

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Thu Apr 4 05:39:26 EDT 2013

On Wed, Apr 3, 2013 at 10:31 PM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
>
> You can put syntax properties on the result of your expander for the
> state-machine macro and then search for those properties in the expanded
> text. Maybe that will help?

There's information about how Typed Racket does this (using roughly
the technique Robby outlined, plus others) in our papers about the
implementation, from PLDI 2011 and the Scheme Workshop 2007 [1,2].

The other significant technique is basically the following:

Expand a form like:

   (my-special-dsl some arguments here)

to

   (begin (define-values () (begin (quote-syntax (my-special-dsl some
arguments here)) (values)) ;; just the original input syntax
               the-actual-expansion)

Then your tool can look at the results of expansion (via the hook
Robby describes) and find occurrences of this pattern, and discover
your DSL. Note that this only really works if either (a) your DSL
doesn't have any general expansion positions as subforms or (b) you
don't need to analyze those subforms.  Otherwise syntax properties are
the best route.

Sam

[1] http://www.ccs.neu.edu/racket/pubs/scheme2007-ctf.pdf
[2] http://www.ccs.neu.edu/racket/pubs/pldi11-thacff.pdf

Posted on the users mailing list.