cppClassBodyBlock
: NEWLINE+ accessLevel ':' INDENT
( NEWLINE+ cppMember[$accessLevel.tree])+
DEDENT
-> cppMember+
;
cppMember[antlr3::ItemPtr accessLevel]
: declaration -> ^(MEMBER {$accessLevel} declaration)
;
When there are multiple members in the block, setTokenBoundaries call in the cppClassBodyBlock is applied to nil node, that is discarded later, and I'm perfectly ok with this behavior. But if there is only one member, rulePostProcessing unwraps member tree from nil node and setTokenBoundaries is applied to member node itself. This results into corrupted location information.
How can I skip call to setTokenBoundaries or removal of the nil node?