I have the following code (or similar, anyway):
fragment COMMA : ',' ;
fragment OP : '(' ;
fragment CP : ')' ;
expression
: ID
| call
;
call
: ID OP expression (COMMA expression)* CP
;
But when I try an example expression, like: foo(bar, baz)
, I get an error, more specifically, token recognition error at: '('
. And when I make them normal rules, and not fragments, commas and parenthesis are added to the parse tree. I want to use COMMAs and parenthesis to match rules, but I don't want them in the parse tree. Anyway, why aren't the fragments working?