I’m adding a rule to my ANTLR4 lexer that looks like [/a-zA-Z0-9_?+-.*\u005B-\u005E\u007B-\u007D]+ and it lexes just fine. However, when I add \u002C to it, regardless of where I add that character, or when I add a literal , to it, I get the same error:
chars ',' used multiple times in set [/a-zA-Z0-9_?+-.*\u005B-\u005E\u007B-\u007D\u002C]
There is only one , in the set regardless, so I’m unsure what might be causing the error.
>Solution :
The - in +-. sequence is interpreted in the same way as in A-Z, i.e. as a meta-character that designates a range, not literally as a dash character. The range between + and . includes ,:
2B: +
2C: ,
2D: -
2E: .
If you would like to interpret the dash literally, include it as the last character, right before the closing square bracket.