I don't know what would be recommended, but I also need to have an ErrorNode that derives from my custom node.
What I did is I overloaded the errorNode method in my NodeAdaptor to tkae as an input a CustomErrorNode error node. My CustomErrorNode class derives from my CustomNode and is actually only a wrapper of CommonErrorNode. That way, there are no class cast exceptions AND I get the full functionnality or error nodes. Hope that helped, Bruno M-A. Selon Matthieu Riou <[email protected]>: > Hi, > > I've just migrated from 3.0.1 to 3.1.1 and the new use of CommonErrorNode to > handle errors is giving some pain. I use my own AST tree type, so in my > grammar I have: > > options { > output=AST; > language=Java; > ASTLabelType=LinkedListTree; > } > > But it seems that ANTLR casts a little too generously in the generated > parser as I end up with code like this in all catch blocks: > > retval.tree = (LinkedListTree)adaptor.errorNode(input, retval.start, > input.LT(-1), re); > > The method call returns a CommonErrorNode which can't be cast to my tree > implementation, resulting in a ClassCastException. I'm wondering wheter my > tree should extend CommonErrorNode instead of BaseTree but the > CommonErrorNode implementation (especially the constructors) look fairly > specific to error handling. > > What would be the recommended solution here? > > Thanks! > Matthieu > List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
