The similar question and the author’s website give me solutions like this:
Identifier "identifier"
= !ReservedWord [A-Za-z_]+
ReservedWord
= "test"
/ "abc"
This solution can’t parse an identifier like this "test_var".
In this example, the grammar !ReservedWord will exclusive all variables starting with "test" or "abc".
Thanks in advance.
ReservedWordsucceeds, when a reserved word is complete, regardless of what follows. So the solution is to make it fail when there is a longer match that includes more identifier characters: