[antlr-interest] AST construction: partial null trees
oliver.zeigermann at gmail.com
Sat Dec 13 04:03:51 PST 2008
I have not investigated why, but including partial null trees often
makes the whole generated ASTs null which makes debugging really hard.
Am I doing anything wrong, or could that indeed be handled more
gracefully by ANTLR?
As an example have a look at such a parser grammar rule creating an AST
: quantor parameters -> ^( QUANTORCALL quantor parameters)
which indeed would mess up my complete parsetree for reasons that are
not obvious at first glance.
However, even though parameters are not syntactically optional, they
can still return a null tree when the list of parameters is empty. If
so, the whole tree is messed up.
Of course, adding a '?' to the tree generation part of parameters fixes this:
: quantor parameters -> ^( QUANTORCALL quantor parameters?)
But should that really be necessary?
Or is it even considered bad style to return a null tree from a subrule?
Any input welcome!
More information about the antlr-interest