I'm new to antlr3, and I'm trying to write a lexer that accept '+' and '-' as a special symbol but when see '++' operator it should treat it as a error but I don't know how to implement it, now with below specification it tokenize '++' as two token '+' and '+'.
SPECIALSYMBOL: ('+'|'-');
Keep your
SPECIALSYMBOL
as it is and handle the case in the parser rules : if you do not allow repeatedSPECIALSYMBOL
in your rules, a++
should produce an error.