[erlang-questions] JavaScript compiler for Erlang

Joe Armstrong erlang@REDACTED
Tue Jul 17 09:40:30 CEST 2007


All little more digging revealed this to be a "Pratt parser" - I also found a
simplified js parser at http://javascript.crockford.com/tdop/index.html.

Things are looking up.

Now I need to find a decent description of Pratt's parser.

/Joe


On 7/17/07, Joe Armstrong <erlang@REDACTED> wrote:
> Thanks - I found the narcissus code.
>
> Then I built the stand-alone version of spidermonkey - and tried to load the
> narcissus code into the stand-alone spidermoney and ... nothing
> happened. It just
> sat staring at me like an underfed cat and refused to purr.
>
> I read (well skimmed) the code for the javascript-in-javascript parser.
>
> This is neat code and not the kind of stuff you write after having read the
> first few chapters of the Dragon book. It's  a mix of a lexer, a
> recursive descent parser
> and a operator precedence parser - all rolled together into a single file.
>
> Since it's a meta-interpreter I've no idea if the code is even correct
> and if it computes
> the same values as the embedded js interpreters.
>
> So the problem of a parser still remains - I suspect the easiest way
> is to make a library from spidermonkey and use the C parser, and hack
> this to dump the parse tree in
> a suitable form. Embedding spidermonkey in Erlang would have the added
> advantage of
> making any new js interpreter/compiler easy to test - just by running
> the same function in
> the real interpreter and in the Erlang version.
>
> /Joe
>
>
>
>
> On 7/16/07, Bob Ippolito <bob@REDACTED> wrote:
> > On 7/16/07, Joe Armstrong <erlang@REDACTED> wrote:
> > > I have on occasion thought that it would be fun to implement Javascript.
> > >
> > > The idea of having lot's of little javascripts running in process and
> > > message parsing
> > > would be fun.
> > >
> > > The first step would be a simple interpretor - from that the compiler
> > > is easy :-)
> > >
> > > The difficulty of wring an interpretor seems mainly to do with getting
> > > an accurate
> > > parse tree of the js source into Erlang - the interpretor should be pretty easy.
> > >
> > > So now I wonder "how can I get a parse tree of some javascript" - Ideally
> > > there would be a javascript-parser-in-javascript that produced a JSON
> > > parse tree.
> > >
> > > If such a parser exists please tell me where to find it !!
> >
> > Take a look at Narcissus:
> > http://en.wikipedia.org/wiki/Narcissus_(JavaScript_engine)
> >
> > -bob
> >
>



More information about the erlang-questions mailing list