[gambit-list] compiling javascript syntax to scheme

Marc Feeley feeley at iro.umontreal.ca
Thu Mar 25 13:55:34 EDT 2010


On 2010-03-22, at 11:41 PM, Ben Weaver wrote:

> On Tue, Mar 23, 2010 at 12:07 AM, James Long <longster at gmail.com> wrote:
> 
> Yep, that's exactly what I was thinking.  It might require a little more than a lightweight macro layer, though.  I would like to translate "return" statements into calls to continuations, and make sure the code flow is as expressive as javascript's.  
> 
> You're right, we'd definitely need continuations to make return work (among the other things that Per pointed out ;-)
>  
> Great!  We should talk more about it soon.  What do you think about lexers like SILex? 
> 
> Sounds good.  I'd be up for trying SILex.  The ecmascript-for-guile project seems worth looking into as well.
> 

I've started playing around with the Guile ecmascript parser.  When using LALR-SCM I unfortunately get many parser generator errors (shift/reduce and reduce/reduce conflicts).  I'm not sure how hard it is to fix.

Another approach would be to use OMeta (http://tinlizzie.org/ometa/), for which there is a Scheme version (http://www.lshift.net/blog/2008/07/01/ometa-for-scheme).  The OMeta project includes a parser for JavaScript (http://www.tinlizzie.org/ometa-js/#JavaScript_Compiler) which basically produces S-expression based ASTs.

Here is an overview of OMeta: http://tinlizzie.org/ometa/dls07-slides.pdf .

Marc




More information about the Gambit-list mailing list