[antlr-interest] (no subject)

Bryan Ewbank ewbank at gmail.com
Thu Jun 16 03:34:16 PDT 2005


To be precise, you could make a symbol table using ANTLR's data
structures, but I don't think you want to.

ANTLR provides the tools to build and process trees based (almost)
exclusively on the syntax of the language; what you need is to build
an extra data structure - a symbol table - to contain the additional
information so you can detect and reject references to undefined
symbols (and, conversely, detect and reject redefinitions).

I say "almost" because you can use semantic predicates to drive
recognition, meaning that you can use your symbol table to have ANTLR
reject illegal symbols.  You still require a symbol table as an extra
data structure, managed by your action code, to track defined symbols.

On 6/14/05, Ilinca Denisa FRECUS <lilincutzy at yahoo.com> wrote:
> Hello,
> 
> I am trying to parse the following text with antlr:
> 
> ComponentA a;
> a.methodA();
> 
> and I don't know how to check that the declared
> variable is the one on which I call the operation (for
> example something like:
> 
> ComponentA a;
> b.methodA();
> 
> is not acceptable. )
> 
> How can I make a symbol table with antlr? Do I have to
> traverse the CommonAST? How do I do this? (I don't
> have acces to its children)
> 
> Thank you very much!
> 
> Ilinca Frecus
> 
> 
> 
> __________________________________
> Discover Yahoo!
> Have fun online with music videos, cool games, IM and more. Check it out!
> http://discover.yahoo.com/online.html
>


More information about the antlr-interest mailing list