I have a JFlex language which describes a simple grammar which is slightly different from most in that it does not have an 'identifier' token. There are some keywords, string literals, and brace pairs, but no identifiers.
Using this grammar as a highlighting lexer in an IDEA custom language, when the user starts typing a keyword, the characters are lexed as bad characters since they don't match anything in the grammar yet. However, once the user has finished typing the keyword, it remains highlighted as bad characters. If I then go back to the beginning of the keyword and insert a space, the word then becomes recognized a keyword and is highlighted correctly.
I assume this is because the highlighter is doing incremental lexing of each character typed but when the space is inserted earlier in the line, it re-lexes the whole line or to the end of the file?
What can I do to fix this?