mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 15:28:39 +09:00
Issue #1732 - Implement JSON superset proposal.
This change makes unicode line and paragraph separators allowed in JS strings, removing the only quirk of the JS string definition that made JSON not a valid subset of JS. Resolves #1732
This commit is contained in:
parent
4ff9d87cb4
commit
34dc51690f
4 changed files with 44 additions and 89 deletions
|
|
@ -603,6 +603,10 @@ TokenStream::TokenBuf::findEOLMax(size_t start, size_t max)
|
|||
if (n >= max)
|
||||
break;
|
||||
n++;
|
||||
|
||||
// This stops at U+2028 LINE SEPARATOR or U+2029 PARAGRAPH SEPARATOR in
|
||||
// string and template literals. These code points do affect line and
|
||||
// column coordinates, even as they encode their literal values.
|
||||
if (TokenBuf::isRawEOLChar(*p++))
|
||||
break;
|
||||
}
|
||||
|
|
@ -2129,8 +2133,9 @@ TokenStream::getStringOrTemplateToken(int untilChar, Token** tp)
|
|||
}
|
||||
break;
|
||||
}
|
||||
} else if (TokenBuf::isRawEOLChar(c)) {
|
||||
} else if (c == '\r' || c == '\n') {
|
||||
if (!parsingTemplate) {
|
||||
// String literals don't allow ASCII line breaks.
|
||||
ungetCharIgnoreEOL(c);
|
||||
error(JSMSG_UNTERMINATED_STRING);
|
||||
return false;
|
||||
|
|
@ -2138,10 +2143,18 @@ TokenStream::getStringOrTemplateToken(int untilChar, Token** tp)
|
|||
if (c == '\r') {
|
||||
c = '\n';
|
||||
if (userbuf.peekRawChar() == '\n')
|
||||
// Treat CRLF as a single line break.
|
||||
skipCharsIgnoreEOL(1);
|
||||
}
|
||||
updateLineInfoForEOL();
|
||||
updateFlagsForEOL();
|
||||
} else if (c == LINE_SEPARATOR || c == PARA_SEPARATOR) {
|
||||
// U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR encode
|
||||
// their literal values in template literals and (as of the
|
||||
// JSON superset proposal) string literals, but they still count
|
||||
// as line terminators when computing line/column coordinates.
|
||||
updateLineInfoForEOL();
|
||||
updateFlagsForEOL();
|
||||
} else if (parsingTemplate && c == '$') {
|
||||
if ((nc = getCharIgnoreEOL()) == '{')
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue