dcsimg
ClassCastException with GnuCParser
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Andreas_Morf
Posted On:   Wednesday, February 13, 2002 02:03 PM

Hello everyone If I run the GnuCParser provided on the antlr.org page get the following output: CMD>java Main test.c Parsing... doFile: E:Developmentantlr-2.7.1cgrammar est.c parseFile: test.c parser exception: java.lang.ClassCastException: antlr.CommonToken java.lang.ClassCastException: antlr.CommonToken at StdCLexer.makeToken(StdCLexer.java:78) at StdCLexer.mID(StdCLexer.java:2147) ..... I am using JDK1.3.1 and ANTLR-2.7.2a2. The build process works ok, except with a few warnings when translating the grammar files. Dow anyone have an advice/solution? Thanks    More>>

Hello everyone


If I run the GnuCParser provided on the antlr.org page get the following output:


CMD>java Main test.c


Parsing...
doFile:
E:Developmentantlr-2.7.1cgrammar est.c
parseFile: test.c
parser exception: java.lang.ClassCastException: antlr.CommonToken
java.lang.ClassCastException: antlr.CommonToken
at StdCLexer.makeToken(StdCLexer.java:78)
at StdCLexer.mID(StdCLexer.java:2147)


.....


I am using JDK1.3.1 and ANTLR-2.7.2a2. The build process works ok, except with a few warnings when translating the grammar files.


Dow anyone have an advice/solution?


Thanks


Andreas Morf (andreas_morf@bluewin.ch)

   <<Less

Re: ClassCastException with GnuCParser

Posted By:   Monty_Zukowski  
Posted On:   Thursday, February 14, 2002 06:29 AM

You probably need to do this in the program you are calling the parser from:

// set AST node type to TNode or get nasty cast class errors
parser.setASTNodeType(TNode.class.getName());
TNode.setTokenVocabulary("GNUCTokenTypes");

See the TestThrough.java class for an example of how to set up and invoke the lexer, parser and tree parsers.


Also, if you embark on an interesting project, please let the authors know. We like to find out what's going on with our software ;)

About | Sitemap | Contact