guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Q on (language <lang> spec)


From: Matt Wette
Subject: Q on (language <lang> spec)
Date: Sat, 17 Oct 2015 12:02:53 -0700

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

[Prev in Thread] Current Thread [Next in Thread]