[antlr-interest] Pruning malformed ASTs
Richard Thrippleton
richard.thrippleton at progress.com
Fri Jun 4 09:29:57 PDT 2010
I am in the slightly painful situation of wanting to apply a tree grammar
(type and other constraints checking) after a parser grammar even in the
case that there were parse errors.
At the moment I just have the tree grammar exit at the moment that it
encounters a malformed part of the tree; as I've seen stated on here before,
there's no other sensible thing to do.
Sometimes I'm fortunate to have simple parse errors that still result in a
correct tree (e.g. standalone unexpected tokens just get removed in
recovery). For the larger parse errors I'll get an AST containing
CommonErrorNodes which obviously trip up the tree grammar.
What I'm looking for is some common pattern or part of the ANTLR API that
will allow the parser to snip subtrees at a specific granularity that
contain error nodes as I create them. For example:
procedure:
command* -> ^(PROC command*)
needs to ignore any tree coming out of the 'command' rule that contains
error nodes.
Thanks,
Richard
--
\o/
More information about the antlr-interest
mailing list