I am playing with the compiler tower and have been digging through the (system 
base language) module to try to get my hands around writing to the compiler 
tower.  Here is the define-language signature:

define-language 
                       [#:name] [#:title] [#:reader] [#:printer]
                       [#:parser=#f] [#:compilers='()]
                       [#:decompilers='()] [#:evaluator=#f]
                       [#:joiner=#f] [#:for-humans?=#t]
                       [#:make-default-environment=make-fresh-user-module]

Here are my assumptions.   I’d appreciate corrections if I have missed 
something.

reader is a procedure that must be provided.  The procedure takes input port 
and environment and returns a form of the implementers choice.  The text read 
from the input port is (nominally) in the supported language.

parser is an optional procedure.  If provided, it takes the output form 
generated by the reader and returns another form in the implementors choice.

compilers is an a-list of (symbol . procedure).  For each symbol the associated 
procedure takes as input the form produced by the parser or reader (for the 
case where parser is not provided) and generates the code associated with the 
symbol.  For example, if no parser is defined, an entry  of `(tree-il . 
,compile-tree-il) means the implementer provides a procedure compile-tree-il 
that takes a form (returned by the reader), an environment form, and an options 
(a-list?) and generates tree-il.

decompilers is an a-list of (symbol . procedure).   The procedure takes an 
expression in the symbol-designated form, along with environment and option 
a-list, and returns something in the implementers intermediate form (output of 
parser, or of reader in case no parser is specified).

What did I miss or get wrong?   I have not been digging to figure out joiner or 
evaluator yet.

I have been able to do the following, but not sure I’ve got things laid out 
correctly yet:
scheme@(guile-user)> ,L javascript
Happy hacking with javascript!  To switch back, type `,L scheme'.
javascript@(guile-user)> var abc = 123
javascript@(guile-user)> ,L scheme
Happy hacking with Scheme!  To switch back, type `,L javascript'.
scheme@(guile-user)> abc
$1 = 123

Matt


Reply via email to