consider the following lexer rules in ANTLR4:
ID: [a-z]+;
INT: [0-9]+;
ARRAY: ID '[' INT ']';
Is it possible in a tree navigation scenario where I have access to ctx.ARRAY()(where ctxis the subclass ParserRuleContextthat was created from the parser rule) to get a textual representation of the lexer IDand rules INT? Currently, I am getting the whole textual representation with ctx.ARRAY().getText()and parse the contents IDand INTwith the help of regular expressions and just wondered if there is a “cleaner” from the proposed ANTLR solution.
Note. Due to the external dependencies creating ARRAY, the parser rule is not an option.
Thanks for the important answers.
source
share