[antlr-interest] Writing a compiler for ECMAScript 4

ANTLR Mailing List jstpierre-antlr at mecheye.net
Mon May 26 07:59:55 PDT 2008


I am currently writing a compiler for ECMAScript 4 in ActionScript 3,
using Tamarin ESC:
http://hg.mozilla.org/index.cgi/tamarin-central/file/548a350c9c29/esc/src/
(parse.es, lex-*.es and ast.es are the biggies) as a source. I am also
somewhat contributing to the ANTLR ActionScript target, but George
Scott is mainly the guru behind it.

The reference compiler uses a lot of tricks and half-assed
implementations (context, ribs, desugaring patterns, etc.), and I was
wondering if these same things can be done either straightforwardly in
ANTLR or in a better ANTLR-istic way. I have the latest 3.1b1 build,
and already have a somewhat complete grammar for an old revision which
I will attach.

Main points of interest:
 * How much does ANTLR help in compilation, e.g. can I traverse the
AST to build symbol tables, resolve qualified name and type names?
 * Would there be a more ANTLR-istic approach to the parser than what
is shown in ESC, or would it be better to write a hand parser?
 * In ECMAScript the parser's/lexer's main goal is to seperate '/'
usage from Regular Expressions and Division. ESC does this by a
non-buffered lexer that retrieves tokens based on context. Can ANTLR
grammars have context?
 * Does ANTLR have support for heterogeneous AST nodes?

Thanks in advance,
  JP St. Pierre
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Ecma.g
Type: application/octet-stream
Size: 30639 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080526/595e3dfb/attachment-0001.obj 


More information about the antlr-interest mailing list