I've got a rule to match a string that looks like so:
STRING
: '"' ( ~( '"' | '\\' ) | '\\' . )* '"'
;
I dont want the quotes to be part of the tokens text. In Antlr2 I would just put '!'
after the quotes to tell Antlr not to add them to the text.
Notice the '!' below.
STRING
: '"'! ( ~( '"' | '\\' ) | '\\' . )* '"'!
;
However in Antlr3 I can no longer do this as I get the error:
warning(149): Crv__.g:0:0: rewrite syntax or operator with no output option; setting output=AST
I don't know if I can use a rewrite rule here as I don't know how to write the match everything token '.'
My only other thought is to grab the matched text and return it without the quotes, but I'm not sure how to do that as the token hasn't been created yet.
I'm using the C Antlr runtime. How can I accomplish this?