feat: allow identifiers to contain utf-8 characters #216
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
(check the value of STATE_COUNT in src/parser.c)
See #142 (comment) for more context: essentially the true definition of a legal identifier is consistent with what is currently listed on the docs:
^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$
However, from my (limited) understanding there is a bug of sorts when PHP is parsing multibyte characters and instead compares the individual bytes which in practice allows characters outside the given regex to be parsed as identifiers.
This PR updates the grammar and scanner to allow the full utf-8 range as valid identifiers (
\u0080
-\uffff
). PHP may even parse characters higher than this range (I haven't tested it), but given that utf-8 is already technically illegal I don't see the need to try and support anything higher. Although it would be real easy to update the scanner to use the full uint32 returned by the lexer.Closes #142, closes #171