[antlr-interest] Re: Can Resolvers etc be written as ANTLR tree parsers?

John D. Mitchell johnm-antlr at non.net
Tue Jan 14 10:45:11 PST 2003


>>>>> "micheal" == micheal jor <open zone at virgin net> <open.zone at virgin.net> writes:

[...]

>> The trick is to build the initial AST with sufficient information. :-) A
>> canonical example seems to be mapping back to the source with position
>> information.

> Isn't this a Lexer issue?. Ensuring the info is captured by the lexer in
> the first place?

There's two primary facets to the problem:

	* Gathering the information in the first place

	* Propagating the information through the intervening stages
	to where you need it.

[...]

>> * create auxiliary structues that you thread through the tree

> An example would be?

Use-def/def-use chains.  [I.e., chaining together all of the uses of e.g.,
a variable with the definition of that variable.]


>>> If there are examples of resolvers etc written as ANTLR tree parsers,
>>> I'd appreciate a link/sample.

>> In this context, what do you mean by "resolvers"?

> A processing entity that traverses an AST and links ID nodes to their
> defining occurences, resolving overloads and expression types. [Might
> make mutiple traversals.]

Use an auxiliarly stack to track scoping.  Of course, that can become more
complicated depending on your source language.

For use before definition, you can create a lookaside list per scope where
you save the references to those uses and resolve them either when you come
to the definition or when you leave the scope or when you've completed the
traversal -- again, it depends a lot on the semantics of your language.

Take care,
	John


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list