[antlr-interest] Bug in buildTokenTypeASTClassMap generation(antlr 2.7.2)

Ric Klaren klaren at cs.utwente.nl
Thu Jul 17 03:19:27 PDT 2003


Hi,

On Wed, Jul 16, 2003 at 04:43:15PM -0000, ilandrieu wrote:
> I'm not a user of antlr, but I am using it to compile the Java Data Objects  
> reference implementation. Their grammar file contains rules like:     
>      
>     IMPORT = "import"         <AST=com.sun.jdori.common.query.tree.Node>;      
>      
> (the quotes around import are important, I could not throw them out). This
> leads to the generation of the following code in antlr 2.7.2 for the method
> buildTokenTypeASTClassMap in the parser class : 
>      
> 	protected void buildTokenTypeASTClassMap() {     
> 		tokenTypeToASTClassMap = new Hashtable();     
> 		tokenTypeToASTClassMap.put(new Integer("import"),    
> com.sun.jdori.common.query.tree.Node.class);     
>         ....

Could reproduce it. Could you try changing in JavaCodegenerator.java in the
method getTokenASTNodeMap the line:

					println("tokenTypeToASTClassMap.put(new Integer("+s+"), "+
							ts.getASTNodeType()+".class);");

To:


					println("tokenTypeToASTClassMap.put(new Integer("+ts.getTokenType()+"), "+
							ts.getASTNodeType()+".class);");

I think that will fix the problem. I'll put up a snapshot with the fix
shortly at http://wwwhome.cs.utwente.nl/~klaren/antlr/

> I solved my problem, but I wanted to know whether this is a known issue
> with antlr 2.7.2 (or should I file it somewhere?), or is it a problem in
> the JDO grammar file?  

Now it's a known issue ;)

Thanks for the report!

Cheers,

Ric
-- 
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
  Chaos is found in greatest abundance wherever order is being sought.
  --- Terry Pratchet


 

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




More information about the antlr-interest mailing list