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