antlr4 – get left and right sibling of rule context

Tags: , ,



An easy question, on which I cannot find something useful in the API docs: is there a way to get the left and right sibling of a ParserRuleContext?

Say I have in my .g4:

identifiers : identifier (',' identifier)*;

When handling a IdentifierContext, I would like to get a reference to the left and the right IdentifierContext.

Answer

[…] is there a way to get the left and right sibling of a ParserRuleContext?

No, alas, there is not.



Source: stackoverflow