This is my image structure ANTLR 4 parsing tree gui:
This my listener rule enterDeclaration :
public void enterDeclaration(ADTCParser.DeclarationContext ctx) {
TokenStream tokens = parser.getTokenStream();
String initDeclarationList = tokens.getText(ctx.initDeclarationList());
}
to get tokens from initDeclarationList such as :
String initDeclarationList = tokens.getText(ctx.initDeclarationList());
String parameterDeclaration = ???
And my questions is "How to get tokens from sub-rule "parameterDeclaration" from " structure based on the image above ?
BTW, im using grammar C in ANTLR 4 this is link for grammar : https://github.com/antlr/grammars-v4/blob/master/c/C.g4