In java grammar I have a parser rule,
name : Identifier ('.' Identifier)* ';' ;
How to get all the identifiers under a single AST tree node?
In java grammar I have a parser rule,
name : Identifier ('.' Identifier)* ';' ;
How to get all the identifiers under a single AST tree node?
It seems impossible to me only with your lexer-parser.
For this, you will need the called: tree-walker.This third part of the parsing process will make you able to go through the generated AST and, with a counter, print the number of occurrences.
I let you a reference here in case you decide to implement it.
https://theantlrguy.atlassian.net/wiki/display/ANTLR3/Tree+construction
I hope this would help you!