[antlr-interest] CommonErrorNode and using ASTLabelType (3.0.1 -> 3.1.1)
Matthieu Riou
matthieu at offthelip.org
Fri Feb 13 17:27:21 PST 2009
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090213/b31110ee/attachment.html
More information about the antlr-interest
mailing list