Reputation: 4075
I am specifying a token in my antlr grammar as:
ID : [a-zA-Z0-9\*\?]; // Allow tokens such as Asdf*fdsa
But I get an invalid escape sequence \*
error. How can I specify special characters in the character set that Antlr allows for tokens?
Upvotes: 2
Views: 607
Reputation: 370455
*
and ?
don't have a special meaning inside character classes and don't need to be escaped. So just remove the backslashes and you're good.
You'll also want to add a +
after the character class if you want to be able to match more than one character (as in the example).
Upvotes: 2