[antlr-interest] Questions: Scopes, Identifiers and more.

ANTLR Mailing List jstpierre-antlr at mecheye.net
Tue Jun 10 16:25:08 PDT 2008


The Grammar I am referring to is attached BELOW (The attachment
scrubbed; attachment1.obj)

The reference compiler I am writing the grammar from is written in
ECMAScript and can be found here:
http://hg.mozilla.org/index.cgi/tamarin-central/file/6582fd7afc59/esc/src/
, most specifically,
http://hg.mozilla.org/index.cgi/tamarin-central/file/6582fd7afc59/esc/src/parse.es

Hello everyone, I am getting while compiling very confusing and the
source lines appear to be incorrect (1.):

[19:02:13] warning(200): Ecma.g:270:18: Decision can match input such
as "{UnsignedIntLiteral, IntLiteral, DecimalLiteral, StringLiteral,
True..LeftBrace, Var..Const, Function, Super..New, Let}" using
multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input

As I remember in previous ANTLRWorks versions, the rule at the source
line would be given additional DFAs to show the two paths that lead to
the token consumption. This is not happening here for some reason.

2. The reference compiler uses singly-linked-lists for its AST
abstraction. I would like to see why ANTLR chose to do the AST
abstraction it did

3. Both compilers need to keep track of block notion for doing code
generation (global, class instance, class static, function). The
reference compiler calls these Ribs and keeps track of them by another
singly-linked-list, which acts like a stack. Is there a way to do
something similar in ANTLR?

4. I need keep track of identifiers vs. keywords, as "else" and "if"
need to be seperated by whitespace, "else" can also be followed by a
right curly brace, "{", and "else5" is a keyword. Is there a way to do
this in ANTLR?

Thanks,
 JP St. Pierre
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Ecma.g
Type: application/octet-stream
Size: 30347 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080610/1f1ec37f/attachment-0001.obj 


More information about the antlr-interest mailing list