From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Matt Wette Newsgroups: gmane.lisp.guile.user Subject: Q on (language spec) Date: Sat, 17 Oct 2015 12:02:53 -0700 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_A7D8FCFE-9341-4DFC-BC35-661DB537662B" X-Trace: ger.gmane.org 1445108623 28355 80.91.229.3 (17 Oct 2015 19:03:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 17 Oct 2015 19:03:43 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Oct 17 21:03:34 2015 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZnWlP-0001n1-CZ for guile-user@m.gmane.org; Sat, 17 Oct 2015 21:03:31 +0200 Original-Received: from localhost ([::1]:59506 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnWlO-00046p-L0 for guile-user@m.gmane.org; Sat, 17 Oct 2015 15:03:30 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnWl7-00046b-9i for guile-user@gnu.org; Sat, 17 Oct 2015 15:03:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZnWl4-0002rL-2s for guile-user@gnu.org; Sat, 17 Oct 2015 15:03:13 -0400 Original-Received: from vms173025pub.verizon.net ([206.46.173.25]:61300) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnWl3-0002rH-SN for guile-user@gnu.org; Sat, 17 Oct 2015 15:03:09 -0400 Original-Received: from [192.168.2.127] ([72.87.204.128]) by vms173025.mailsrvcs.net (Oracle Communications Messaging Server 7.0.5.32.0 64bit (built Jul 16 2014)) with ESMTPA id <0NWD00H67OWT6I40@vms173025.mailsrvcs.net> for guile-user@gnu.org; Sat, 17 Oct 2015 14:02:54 -0500 (CDT) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=J+9Xl1TS c=1 sm=1 tr=0 a=Jf1g6iwM2K3MHzQE8uPn/Q==:117 a=o1OHuDzbAAAA:8 a=oR5dmqMzAAAA:8 a=5lJygRwiOn0A:10 a=dCMiC6t8ouR5_KgP5ykA:9 a=QEXdDO2ut3YA:10 a=ntsNaiwMgxtxXsUNFrsA:9 a=zdyLGP70gU0kVk6-:21 a=_W_S_7VecoQA:10 X-Mailer: Apple Mail (2.2104) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.46.173.25 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:12095 Archived-At: --Apple-Mail=_A7D8FCFE-9341-4DFC-BC35-661DB537662B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 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=20 [#:name] [#:title] [#:reader] [#:printer] [#:parser=3D#f] [#:compilers=3D'()] [#:decompilers=3D'()] [#:evaluator=3D#f] [#:joiner=3D#f] [#:for-humans?=3D#t] = [#:make-default-environment=3Dmake-fresh-user-module] Here are my assumptions. I=E2=80=99d 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=E2=80=99ve 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 =3D 123 javascript@(guile-user)> ,L scheme Happy hacking with Scheme! To switch back, type `,L javascript'. scheme@(guile-user)> abc $1 =3D 123 Matt --Apple-Mail=_A7D8FCFE-9341-4DFC-BC35-661DB537662B Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 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=3D#f] [#:compilers=3D'()]

                 =       [#:decompilers=3D'()] [#:evaluator=3D#f]

                 =       [#:joiner=3D#f] [#:for-humans?=3D#t]

                 =       = [#:make-default-environment=3Dmake-fresh-user-module]


Here are my = assumptions.   I=E2=80=99d 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=E2=80=99ve= 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 =3D 123

javascript@(guile-user)> ,L scheme

Happy hacking with Scheme!  To switch back, type `,L = javascript'.

scheme@(guile-user)> abc

$1 =3D 123


Matt


= --Apple-Mail=_A7D8FCFE-9341-4DFC-BC35-661DB537662B--