Skip to content

Commit

Permalink
ref. #977 Support ES2019 JSON superset
Browse files Browse the repository at this point in the history
  • Loading branch information
tuchida authored and gbrail committed Jun 30, 2021
1 parent aac4a4e commit 520d594
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
25 changes: 22 additions & 3 deletions src/org/mozilla/javascript/TokenStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -914,11 +914,30 @@ final int getToken() throws IOException {
quoteChar = c;
stringBufferTop = 0;

c = getChar(false);
c = getCharIgnoreLineEnd(false);
strLoop:
while (c != quoteChar) {
if (c == '\n' || c == EOF_CHAR) {
ungetChar(c);
boolean unterminated = false;
if (c == EOF_CHAR) {
unterminated = true;
} else if (c == '\n') {
switch (lineEndChar) {
case '\n':
case '\r':
unterminated = true;
break;
case 0x2028: // <LS>
case 0x2029: // <PS>
// Line/Paragraph separators need to be included as is
c = lineEndChar;
break;
default:
break;
}
}

if (unterminated) {
ungetCharIgnoreLineEnd(c);
tokenEnd = cursor;
parser.addError("msg.unterminated.string.lit");
return Token.ERROR;
Expand Down
1 change: 0 additions & 1 deletion testsrc/org/mozilla/javascript/tests/Test262SuiteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public class Test262SuiteTest {
"String.prototype.matchAll",
"Symbol.matchAll",
"tail-call-optimization",
"json-superset",
"hashbang",
"u180e"));

Expand Down
6 changes: 1 addition & 5 deletions testsrc/test262.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5170,7 +5170,7 @@ language/line-terminators 4/41 (9.76%)
S7.3_A6_T3.js
S7.3_A6_T4.js

language/literals 117/434 (26.96%)
language/literals 113/434 (26.04%)
bigint/numeric-separators/numeric-separator-literal-nonoctal-08-err.js
bigint/numeric-separators/numeric-separator-literal-nonoctal-09-err.js
bigint/legacy-octal-like-invalid-00n.js
Expand Down Expand Up @@ -5214,12 +5214,8 @@ language/literals 117/434 (26.96%)
string/legacy-non-octal-escape-sequence-strict.js strict
string/legacy-octal-escape-sequence-prologue-strict.js
string/legacy-octal-escape-sequence-strict.js strict
string/line-separator.js {unsupported: [json-superset]}
string/line-separator-eval.js {unsupported: [json-superset]}
string/mongolian-vowel-separator.js {unsupported: [u180e]}
string/mongolian-vowel-separator-eval.js {unsupported: [u180e]}
string/paragraph-separator.js {unsupported: [json-superset]}
string/paragraph-separator-eval.js {unsupported: [json-superset]}
string/S7.8.4_A4.3_T1.js strict
string/S7.8.4_A4.3_T2.js strict
string/S7.8.4_A7.1_T4.js
Expand Down

0 comments on commit 520d594

Please sign in to comment.