Open bergus opened 9 years ago
Alternative library Regex.make takes a more exhaustive approach to this, and might be instructive.
ClassAtom as Range delimiters:
RegExp.make`[${"a"}-${"z"}]`
- is anything but a single-codepoint string valid here?
Regex.make says no. Any single code point matching token is okay on a range boundary (phrased that way because it supports interpolating both escaped strings and regex patterns as strings) but interpolating a set of code point matching tokens is an error in this context.
Unicode Escape Sequences:
RegExp.make`\u${2503}`
- what does this do?
Regex.make says it's an error in v
mode, because it's considered to be incomplete token \u
followed by tokens 2
, 5
, 0
, 3
. But Regex.make`\u{${2503}}`
is valid and outputs /\u{2503}/
.
I'm not sure I understand the Expressions table. Does it mean that interpolation values may only appear in these parts of a regex, and everything else is a syntax error?
If that was not the intended meaning, there seem to be a lot possible occurences that are not discussed:
RegExp.make`[${"a"}-${"z"}]`
- is anything but a single-codepoint string valid here?RegExp.make`\u${2503}`
- what does this do? (Also\x
and\c
escapes). At least Control- and Identity escapes don't need to be handled, asRegExp.make`\${"n"} \${"a"}`
(== /\n \a/
) do not make an interpolated template string in the first place (but rather an invalid regex).Also I think the table should use the offical grammar production names. I assume the "context Block" does mean that we consider the "interpolation hole" to produce an
Atom
?