Skip to content

Commit 326b647

Browse files
committed
Implement JSON ⊂ ECMAScript
The JavaScript as a superset of JSON proposal has reached stage 4. Only real change we need to make here is to allow unescaped <LS> and <PS> characters in string literals.
1 parent 4d4f566 commit 326b647

File tree

5 files changed

+28
-14
lines changed

5 files changed

+28
-14
lines changed

lib/Parser/Scan.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,6 @@ tokens Scanner<EncodingPolicy>::ScanStringConstant(OLECHAR delim, EncodedCharPtr
10641064
ch = rawch = kchNWL;
10651065
}
10661066

1067-
LEcmaLineBreak:
10681067
// Fall through
10691068
case kchNWL:
10701069
if (stringTemplateMode)
@@ -1124,18 +1123,7 @@ tokens Scanner<EncodingPolicy>::ScanStringConstant(OLECHAR delim, EncodedCharPtr
11241123
LMainDefault:
11251124
if (this->IsMultiUnitChar(ch))
11261125
{
1127-
if ((ch == kchLS || ch == kchPS))
1128-
{
1129-
goto LEcmaLineBreak;
1130-
}
1131-
11321126
rawch = ch = this->template ReadRest<true>(ch, p, last);
1133-
switch (ch)
1134-
{
1135-
case kchLS: // 0x2028, classifies as new line
1136-
case kchPS: // 0x2029, classifies as new line
1137-
goto LEcmaLineBreak;
1138-
}
11391127
}
11401128
break;
11411129

test/es5/Lex_u3.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ undefined
22
undefined
33
str const Left
44
str const right
5-
LS in string - compile failure in ES5: expected.SyntaxError: Unterminated string constant
5+
str%20const%20Left%20%u2028%20str%20const%20right
66
LS in regex literal - compile failure in ES5: expected.SyntaxError: Expected '/'
77
LS%20in%20escape%20sequence%20string%20literal%20%20%3Amore%20string
88
BOM is WS : 91

test/es5/Lex_u3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ eval('x= \"str const Left \u2028 str const right\";write(escape(x))');
2727
}
2828
catch(e)
2929
{
30-
write("LS in string - compile failure in ES5: expected." + e)
30+
write("LS in string - compile failure in ES5: not expected." + e)
3131
}
3232

3333
var re = /falls/

test/es7/json_superset.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
6+
WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js");
7+
8+
var tests = [
9+
{
10+
name: "Unescaped <LS> and <PS> characters are allowed in string literals",
11+
body: function () {
12+
assert.areEqual(eval("'\u2028'"), "\u2028");
13+
assert.areEqual("
", "\u2028");
14+
assert.areEqual(eval("'\u2029'"), "\u2029");
15+
assert.areEqual("
", "\u2029");
16+
}
17+
},
18+
];
19+
20+
testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" });

test/es7/rlexe.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,10 @@
131131
<compile-flags>-args summary -endargs</compile-flags>
132132
</default>
133133
</test>
134+
<test>
135+
<default>
136+
<files>json_superset.js</files>
137+
<compile-flags>-args summary -endargs</compile-flags>
138+
</default>
139+
</test>
134140
</regress-exe>

0 commit comments

Comments
 (0)