[antlr-interest] heteroAST example

Michael Laszlo mjl at nova.edu
Thu Sep 8 07:39:06 PDT 2005


 
The heteroAST example runs perfectly for me under some java systems (sdk1.4.1_01). But on other systems (jdk1.5.0_04,sdk1.4.2_06) I get this error:

C:\j2sdk1.4.2_06\antlr-2.7.5\heteroAST>java Main
4;
exception: java.lang.IllegalArgumentException: Invalid class or can't make instance, INTNode
java.lang.IllegalArgumentException: Invalid class or can't make instance, INTNode
        at antlr.ASTFactory.createUsingCtor(ASTFactory.java:251)
        at antlr.ASTFactory.create(ASTFactory.java:210)
        at CalcParser.atom(CalcParser.java:138)
        at CalcParser.mexpr(CalcParser.java:102)
        at CalcParser.expr(CalcParser.java:66)
        at Main.main(Main.java:12)

It seems to be due an InvocationTargetException thrown by ASTFactory.createUsingCTor() when it attempts to create an instance of INTNode using reflection: the specific call is 

t = (AST)ctor.newInstance(new Object[]{token}); 

In turn, it appears that token.getText returns "<no text>"; that is, it never picked up the value from the lexer. So the INTNode constructor fails when it attempts to parse the token's text as an int.

I would guess that my problem is due to an error in my Java system configuration, but I haven't been able to find it. Maybe someone can point me in the right direction.

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050908/4113ad94/attachment.html


More information about the antlr-interest mailing list