Cannot match Unicode characters outside the BMP #1
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.
This is a bit of a mess...
PEG.js does not allow specifying characters outside the BMP (more than two bytes) in its grammars. JavaScript handles these as multi-byte sequences, for example
\ud83d\udca9
. Presumably this works fine with vanilla PEG.js.In phpegjs, we use PCRE to split all characters in the input. This handles emoji characters as, for example, a single
\u{1f4a9}
.It would be very difficult to bridge this gap. We'd have to write logic (in JavaScript) to accept string literals containing multibyte sequences like
\ud83d\udca9
, calculate what their length would be in PHP, then adjust the generated code to account for the difference between the string length in PHP and in JavaScript.That still wouldn't handle matching character classes, because JavaScript and PEG.js would have to use two separate character classes like
[\ud83d][\udca9]
, but PHP would have to use[\x{1f4a9}]
instead.Fortunately this is only going to be a problem if your grammar itself needs to match these characters. Hopefully you don't need to do this.