APEX allows some keywords to also be identifiers. From official docs:
The following are special types of keywords that aren't reserved words and can be used as identifiers:
The problem is that we can not enable them directly as KEYWORD, or it would make the AST Validation fail. On top of that:
- for the parser Unit Tests we make it fail hard (to make sure that our ASTs are correct).
- for the ruling ITs, we only log the parsing issues (but we want to have as little issues as possible)
We can not resolve the ambiguity between identifiers and keywords by using only Apex Lexer, we also need the AST from Apex parser.