I have an ANTLR listener for C++ where I want to get the name of a member declarator. Currently, I'm using this approach:
def enterMemberDeclarator(self, ctx: CPP14Parser.MemberDeclaratorContext):
id = ctx.declarator().pointerDeclarator().noPointerDeclarator().noPointerDeclarator().declaratorid().idExpression().unqualifiedId()
which is just a horrible expression. I feel like there should be some way of getting the id immediately without having to go down that rabbit hole. Additionally, some of these expressions might be None
so I fear that I would have to make even more effort to get to the result...
The grammar is from here