question about parse s-expression to language

26 views
Skip to first unread message

Louis de Guenchy

unread,
Aug 5, 2019, 7:48:56 PM8/5/19
to nanopass-framework
Hi everyone!


Recently, I was exploring the use of nanopass to write a scheme to javascript compiler.

I have read "A Nanopass Framework for Commercial Compiler Development", "A Nanopass Framework for Compiler Education", "Nanopass Framework Users Guide".

But I still have some difficulties:

1 . In the pass parse-and-rename : * (e) -> Lsrc (), (line 1465  of  https://github.com/akeep/scheme-to-c/blob/master/c.ss) witch part is necessary if I wan't to rename the name of function, means just parse s-expression to Language (of Nanopass).



1.a (with-output-language (Lsrc Expr) ;; what's this for? line 1532
1.b (Expr : * (e env) -> Expr () ;; I think this is the necessary part in the pass? line 1640
1.c  (Expr e initial-env) ;; what's this for? line 1665


thanks

Amirouche Boubekki

unread,
Aug 6, 2019, 8:51:04 AM8/6/19
to Louis de Guenchy, nanopass-framework
Hello Louis!

Le mar. 6 août 2019 à 01:48, Louis de Guenchy
<louis.d...@gmail.com> a écrit :
>
> Hi everyone!
>

> I have read "A Nanopass Framework for Commercial Compiler Development", "A Nanopass Framework for Compiler Education", "Nanopass Framework Users Guide".
>
> But I still have some difficulties:
>
> 1 . In the pass parse-and-rename : * (e) -> Lsrc (), (line 1465 of https://github.com/akeep/scheme-to-c/blob/master/c.ss) witch part is necessary if I wan't to rename the name of function, means just parse s-expression to Language (of Nanopass).
>
>
>
> 1.a (with-output-language (Lsrc Expr) ;; what's this for? line 1532

That will bind quasiquote to generate Lsrc records instead of plain symbols

> 1.b (Expr : * (e env) -> Expr () ;; I think this is the necessary part in the pass? line 1640

This one specify that Expr takes something as argument e and another
parameters env (that is initial-env below)

> 1.c (Expr e initial-env) ;; what's this for? line 1665

This will start the pass. When the pass only takes an expression as
argument it is not required.

Here is another example:
https://github.com/akeep/scheme-to-c/blob/master/c.ss#L2589

>
> Recently, I was exploring the use of nanopass to write a scheme to javascript compiler.
>

I have been working on Scheme-to-Javascript compiler called Ruse
Scheme [0] there is demo integration with react [1], it support
calling JavaScript and be called by Javascript, it far from complete
but it is useable. In particular it doesn't support rest arguments and
many other things but I think it is a good start.

[0] repo: https://github.com/ruse-lang/ruse
[1] demo using react: https://scheme-live.github.io/ruse-scheme/demo/counter/

I changed plan to target wasm instead, mainly because to support
call/cc and tail-call optimisation it requires a trampoline which
makes it very slow... Using wasm I still need a trampoline to interop
with JavaScript but it will be faster because wasm.

FWIW, readable JavaScript is not required because there is sourcemap
that integrates with the browser debugger. sourcemaps are coming to
wasm too.

I will be very glad if we could join forces together to work on that!
What do you think?


--
Amirouche ~ amz3 ~ https://hyper.dev

Louis de Guenchy

unread,
Aug 6, 2019, 10:15:17 AM8/6/19
to nanopass-framework
Hello, it seems that the project you mentioned is not based on nanopasse.

Unfortunately, I don't know how to write rust, but it looks very good.

This is the goal of my experimental project: https://github.com/guenchi/NodeScheme

Based on Dan Friedman's (match) I implemented a prototype now I want to rewrite it with nanopass to avoid the complexity explosion.

I decided to develop on chezscheme because I found a “hack” way to port syntax-rules and syntax-case to javascript.

I think this is more important than call/cc or tail call.

If bucklescript represents  typed means of javascript, then I hope this project can represent macro means of javascript.

在 2019年8月6日星期二 UTC+2下午2:51:04,Amirouche Boubekki写道:

Amirouche Boubekki

unread,
Aug 6, 2019, 10:45:43 AM8/6/19
to Louis de Guenchy, nanopass-framework
Le mar. 6 août 2019 à 16:15, Louis de Guenchy
<louis.d...@gmail.com> a écrit :
>
> Hello, it seems that the project you mentioned is not based on nanopasse.

The project is at https://github.com/scheme-live/ruse-scheme

Checkout rusec.scm

Yes there is an *archived* scheme named ruse also.

>
> This is the goal of my experimental project: https://github.com/guenchi/NodeScheme
>
> Based on Dan Friedman's (match) I implemented a prototype now I want to rewrite it with nanopass to avoid the complexity explosion.
>

Yes, nanopass is really good at keeping complexity down.

> I decided to develop on chezscheme because I found a “hack” way to port syntax-rules and syntax-case to javascript.
>
> I think this is more important than call/cc or tail call.

As you wish...
> --
> You received this message because you are subscribed to the Google Groups "nanopass-framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to nanopass-framew...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/nanopass-framework/da27774d-0972-4208-b529-30c7315ca9ea%40googlegroups.com.

Amirouche Boubekki

unread,
Aug 6, 2019, 10:50:55 AM8/6/19
to Louis de Guenchy, nanopass-framework
> I decided to develop on chezscheme because I found a “hack” way to port syntax-rules and syntax-case to javascript.

My implementation rely on Chez Scheme `expand` to support all syntax
forms and the R6RS library system.

Louis de Guenchy

unread,
Aug 6, 2019, 11:12:35 AM8/6/19
to nanopass-framework
This is very interesting. It seems that you have the same thoughts as me and walked in front of me.

I am very interested in working with you.

Maybe I will keep my project, but I am sure I will RP to ruse-scheme.



在 2019年8月6日星期二 UTC+2下午4:45:43,Amirouche Boubekki写道:
> To unsubscribe from this group and stop receiving emails from it, send an email to nanopass-framework+unsub...@googlegroups.com.

Louis de Guenchy

unread,
Aug 6, 2019, 11:22:02 AM8/6/19
to nanopass-framework

> I think this is more important than call/cc or tail call.

As you wish...


I think  tail call is less important because I seem to hear that the latest javascript standard will support tail calls, 
so we can translate the code directly without using a trampoline. 
Reply all
Reply to author
Forward
0 new messages