Given the following grammar (in ANTLR v3):
test : value0 COMMA_KEYWORD value1 (COMMA_KEYWORD value2)*;
How can we exclude (skip) COMMA_KEYWORD from the AST tree built by ANTLR (and without using a write rule)?
The alternative to using rewrite rules is to use tree construction operators:
https://theantlrguy.atlassian.net/wiki/spaces/ANTLR3/pages/2687090/Tree+construction
You can use ! operator to omit a token or subtree from AST:
test : value0 COMMA_KEYWORD! value1 (COMMA_KEYWORD! value2)*;