[plt-scheme] Defining syntax inside the transformer environment

From: Daniel Franke (daniel at franke.name)
Date: Mon Dec 12 04:34:13 EST 2005

Hash: SHA1

I'm working on a macro for expanding infix math expressions (written as strings)
into Scheme S-expressions. I defined a macro (using defmacro.ss) called
lex-state which returns lambda expressions. Basically, the lambda expression
reperesents a single state of the DFA that drives the lexical analyzer. Then,
with define-values-for-syntax, I've bound several symbols, L0 through L7 (each
representing one state), to the procedures that result from evaluating the
lambda expressions to which lex-state expands.  Later, the main macro (the one
exported outside my module) will call these procedures in order to lex the
string passed to it.

The problem is, lex-state doesn't seem to exist in the transformer environment.
When I go to bind L0 through L7 to its expansion, the compiler errors out and
tells me that lex-state isn't bound. I've worked around the problem by putting
lex-state in a separate module and then importing it via require-for-syntax.
However, this seems like a kludge at best.  Is there a better way of going about
this? Something along the lines of define-macro-for-syntax?
Version: GnuPG v1.4.2 (Darwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org


Posted on the users mailing list.