JavaScript source code generation library for scala

I am looking for a library in scala that generates JavaScript from an abstract syntax tree. I want to use it in a compiler that generates JavaScript at the end, and I don’t want to implement the beautiful part of printing myself. A.

+4
source share
4 answers

I did half of yesterday's research on this. There seems to be no standard standalone solution. Each project that I looked at turned itself off:

How independent and reusable can these various classes be? It just seems to me that the AST class in JScala and s2js is autonomous and can be easily borrowed by another project. The Scala -JS AST classes seem somewhat more confused with their surroundings; Get up, all the more. (I welcome changes that improve my informal experience.)

How mature and battle tested are these various projects? My informal impression is that they are ranked in descending order as follows: Lift, Scala -JS, JScala, s2js.

For my own project, I think I'm going to copy and paste two source files from JScala and see how this happens.

PS I also mentioned, for completeness:

+7
source

A genuine web framework generates JavaScript from AST. However, I never looked at its end. AST is described here freely. Http://exploring.liftweb.net/master/index-10.html

+2
source

StringTemplate (from ANTLR) is pretty good for generating code, I would say, and it keeps track of the indentation and keeps the indentation of nested statements at the right level. Not a very beautiful print, but better than nothing. (At the same time, I wonder why you want pretty-typed JavaScript if in the end it will be reduced anyway.)

There is a Scala shell for StringTemplate (at least I seem to remember I saw more): http://software.clapper.org/scalasti/

The virtualized scala does not seem to be the one you need, I would say, since it starts with Scala a Scala AST, and it is not what you have.

However, if you are interested in such things, you can check out http://nescala.org/2013/talks#26 (Alvaro Carrasco) as well.

+2
source

There is a Virtualized-Scala project, one of its instances generates Javascript from Scala code, js-scala . There you will find links to projects and talk about it.

+1
source

All Articles