[antlr-interest] (error)Reference to TreeAdaptor and Common Tree are ambiguous.(newbie)

Randall R Schulz rschulz at sonic.net
Sun Jul 15 15:15:39 PDT 2007


On Sunday 15 July 2007 13:11, ali azimi wrote:
> Hi,
>
>   I have produced a Lexer and a Parser. When I try to implemnt them
> Using java netBeans, I face some error message as following:
>
>   C:\MyProjects\Final
> Project\src\finalprojectsim2\FinalProjectSim2Parser.java:74:
> reference to TreeAdaptor is ambiguous, both class
> org.antlr.runtime.tree.TreeAdaptor in org.antlr.runtime.tree and
> class org.antlr.runtime.TreeAdaptor in org.antlr.runtime match
> protected TreeAdaptor adaptor = new CommonTreeAdaptor();
>
>   and
>
>   C:\MyProjects\Final
> Project\src\finalprojectsim2\FinalProjectSim2Parser.java:139:
> reference to CommonTree is ambiguous, both class
> org.antlr.runtime.tree.CommonTree in org.antlr.runtime.tree and class
> org.antlr.runtime.CommonTree in org.antlr.runtime match CommonTree
> tree;
>
>
>   According to the error messages I have two classes of “TreeAdaptor”
> and two classes of “CommonTree” one in "org.antlr.runtime.tree" and
> one in "org.antlr.runtime". But I have just one class which is called
> TreeAdaptor and one class which is called “CommonTree” and both are
> located in "org.antlr.runtime.tree". So why do I get these errors?

I'd look at both your import statements and your IDE's source-path and 
class-path setup. It's possible you've established a kind of alias: 
more than one way of interpreting the contents of a given unqualified 
name or more than one way of accessing a given set of classes in your 
library JAR files or class file directories.

Perhaps you have both the antlr-3.0.jar and the antlr-runtime-3.0.jar 
files in your classpath? The former is for the ANTLR processor, used 
only when transforming your grammar specification to Java code. Running 
that code requires only the antlr-runtime-3.0.jar file. Likewise for 
the antlr.2.7.7.jar (for the moment, ANTLR 3.0 parses its 
specifications using a bootstrapping parser written using antlr 2.7) 
and for stringtemplate-3.0.jar (used for modular source code 
synthesis). Conversely, all the classes in the antlr-runtime-3.0.jar 
are also present in antlr-3.0.jar.

The upshot is that to compile or run an ANTLR-generated parser you need 
only antlr-runtime-3.0.jar.


>   Thank you so much in advance.
>
>   Best wishes,
>
>   Al


Randall Schulz


More information about the antlr-interest mailing list