unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Q on (language <lang> spec)
@ 2015-10-17 19:02 Matt Wette
  2015-10-18 20:00 ` Matt Wette
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Wette @ 2015-10-17 19:02 UTC (permalink / raw)
  To: guile-user

[-- Attachment #1: Type: text/plain, Size: 2272 bytes --]

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



[-- Attachment #2: Type: text/html, Size: 4360 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-23 13:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-17 19:02 Q on (language <lang> spec) Matt Wette
2015-10-18 20:00 ` Matt Wette
2015-10-19  3:53   ` Nala Ginrut
2015-10-23  0:20     ` Matt Wette
2015-10-23 13:10       ` Matt Wette

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).