[antlr-interest] java.g parsing order for "extends"?
Terence Parr
parrt at jguru.com
Fri Feb 22 09:13:26 PST 2002
On Friday, February 22, 2002, at 08:11 AM, Seth Delackner wrote:
> Suppose we have the following relationship:
>
> A.java:
> public class A {
> public interface I {}
> }
>
> B.java:
> public class B extends A {}
>
> C.java:
>
> public class C extends B {
> class inner implements I {}
> }
>
> Now, if I try to parse C.java, first I get a typeDefinition for 'C',
> then it starts analyzing the object block for 'C', which contains the
> declaration for 'inner'. Shouldn't it parse B, then A, then finally get
> to A's inner block? Or does java.g already do this, and the grammar I'm
> looking at, which is based loosely on java.g, is broken?
java.g only parses and builds a tree. It is up to you to do symbol
resolution if you want a compiler or whatever. :) Typically you would
collect a list of dependencies as you parse and then go after them or as
you say recursively track down all dependencies on demand.
For translation, it is usually sufficient to collect a tree for each
file separately.
Ter
--
Chief Scientist & Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list