-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chunk unicode similar to spread syntax and less like regex #462
Comments
I think the actionable part here is allowing non-BMP characters in a character class to work as expected. The current behavior is useless, so backward-compatibility with older Peggy/peg.js versions is not needed. The rule given above gets generated with: var peg$r0 = /^[#x\u266F\uD834\uDD2A]/;
var peg$e0 = peg$classExpectation(["#", "x", "\u266F", "\uD834", "\uDD2A"], false, false); Both of which are wrong. This should generate: var peg$r0 = /^[#x\u266F\uD834\uDD2A]/u; // JS backward-compat issue!
var peg$e0 = peg$classExpectation(["#", "x", "\u266F", "\uD834\uDD2A"], false, false); or: var peg$r0 = /^[#x\u266F\u{1d12a}]/u; // JS backward-compat issue!
var peg$e0 = peg$classExpectation(["#", "x", "\u266F", "\u{1d12a}"], false, false); (see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode) Alternately, this could be automatically turned into the following rule: SharpAccidental = [#x♯] / "𝄪" If we are dropping IE11 support in 4.0, the first solution is probably better, but we should only put a |
I'm unsure if conditional |
Let's talk about browser support in #463. |
The way unicode codepoints are chunked in Peggy patterns doesn't follow visual chunking.
Example grammar:
sharp.peggy
Unexpected result:
Reasonable behavior in node using spread syntax:
The text was updated successfully, but these errors were encountered: