On 1/2/07, Phlip <phlip2005 / gmail.com> wrote:
> spooq wrote:
>
> > Parsing with regexps makes baby Jesus cry.  Javascript itself can be
> > quite flexible, so it may be possible to do enough with a standard
> > interpreter's run-time. Alternatively, have a look at the Mozilla
> > projects repository for a real interpreter you could hack on.
>
> This question is for an academic paper, so it has even more ridiculous
> constraints on the amount of fun I can have. (And why hasn't the
> industry invented a Lex in a Bottle, using Regexp-like strings and a
> BNF notation?)

Not sure exactly how you want to improve on lex?

> Can I add a parser to the Syntax library? It only does Ruby, XML, and
> YAML so far...

I don't see how that's better than grabbing the Javascript grammar off
the web in BNF :
http://www.mozilla.org/js/language/es4/formal/lexer-grammar.html
http://www.antlr.org/grammar/1153976512034/ecmascriptA3.g
etc.

> And, yes, JavaScript was designed to be parsed, unlike some other
> languages...

No names need be mentioned... ;)

http://corion.net/perl-dev/Javascript-PurePerl.html does javascript to
xml, which seems the best/quickest solution that I've seen in my 2
minutes of googling. Just write enough perl to put that into a file
somewhere, and get into a nicer language ASAP ;)