[racket] metacircular interpreter: macro parser ==> Re: metacircular interpreter, lexical scope, environment

From: Jon Rafkind (rafkind at cs.utah.edu)
Date: Sun Dec 5 13:47:07 EST 2010

On 12/05/2010 11:35 AM, YC wrote:
> Hi all - 
> continuing on the metacircular interpreter topic - I am now moving
> into creating a macro parser, but quickly realize the disproportionate
> effort required (compared to the effort so far) to come up with a
> macro parser for something like syntax-rules.   Specifically, it seems
> that matching for nested ellipses is quite hard to get right, and I
> have not gotten to the hygiene portion yet, which appears to mean that
> I need my own syntax objects that have the same symbol but are
> different (and yet will resolve down lexically for ids that are in the
> head position). 
> Are there anyone who can share experiences on how to go about this
> "easily"?  Thanks,

Attached is a simple macro expander (but not hygienic) that follows the
algorithm laid out in the paper "Macro by Example" by Wand and others.
Its written in python but the code follows the paper reasonably close so
maybe you can understand it. The paper is on the acm digital library if
you can load it (but for some reason its not loading for me right now,
so here is a google search link to it).


It looks like you can follow a paper by Dybvig on how to implement
hygiene correctly.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20101205/e56c0b08/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: desugar.py
Type: text/x-python
Size: 19099 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20101205/e56c0b08/attachment.py>

Posted on the users mailing list.