Fix: major revision to valid and invalid numeric literal separator "sibling" characters (#745)

This commit is contained in:
Rick Waldron 2017-09-28 23:12:46 -04:00 committed by Henry Zhu
parent 17be9360af
commit 18c6b4e3e9
289 changed files with 589 additions and 84 deletions

View File

@ -43,6 +43,48 @@ const forbiddenNumericSeparatorSiblings = {
],
};
const allowedNumericSeparatorSiblings = {};
allowedNumericSeparatorSiblings.bin = [
// 0 - 1
48,
49,
];
allowedNumericSeparatorSiblings.oct = [
// 0 - 7
...allowedNumericSeparatorSiblings.bin,
50,
51,
52,
53,
54,
55,
];
allowedNumericSeparatorSiblings.dec = [
// 0 - 9
...allowedNumericSeparatorSiblings.oct,
56,
57,
];
allowedNumericSeparatorSiblings.hex = [
// 0 - 9, A - F, a - f,
...allowedNumericSeparatorSiblings.dec,
// A - F
65,
66,
67,
68,
69,
70,
// a - f
97,
98,
99,
100,
101,
102,
];
// Object type used to represent tokens. Note that normally, tokens
// simply exist as properties on the parser object. This is only
// used for the onToken callback and the external tokenizer.
@ -718,6 +760,15 @@ export default class Tokenizer extends LocationParser {
radix === 16
? forbiddenNumericSeparatorSiblings.hex
: forbiddenNumericSeparatorSiblings.decBinOct;
const allowedSiblings =
radix === 16
? allowedNumericSeparatorSiblings.hex
: radix === 10
? allowedNumericSeparatorSiblings.dec
: radix === 8
? allowedNumericSeparatorSiblings.oct
: allowedNumericSeparatorSiblings.bin;
let total = 0;
for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) {
@ -728,6 +779,10 @@ export default class Tokenizer extends LocationParser {
const prev = this.input.charCodeAt(this.state.pos - 1);
const next = this.input.charCodeAt(this.state.pos + 1);
if (code === 95) {
if (allowedSiblings.indexOf(next) === -1) {
this.raise(this.state.pos, "Invalid or unexpected token");
}
if (
forbiddenSiblings.indexOf(prev) > -1 ||
forbiddenSiblings.indexOf(next) > -1 ||

View File

@ -1 +1 @@
1_1_
1_1_

View File

@ -1 +1 @@
0x1_1_
0x1_1_

View File

@ -0,0 +1 @@
(1_)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:2)" }

View File

@ -0,0 +1 @@
(1_1_)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:4)" }

View File

@ -0,0 +1 @@
(1_1__)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:4)" }

View File

@ -0,0 +1 @@
(1__1)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:2)" }

View File

@ -0,0 +1 @@
(1_1_.1_1)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:4)" }

View File

@ -0,0 +1 @@
(1_1._1_1)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:5)" }

View File

@ -0,0 +1 @@
(1_1.1_e1)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:6)" }

View File

@ -0,0 +1 @@
(1_1.1_E1)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:6)" }

View File

@ -0,0 +1 @@
(1_1.1e_1)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:7)" }

View File

@ -0,0 +1 @@
(1_1.1E_1)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:7)" }

View File

@ -1 +1 @@
0xa_1_
0xa_1_

View File

@ -0,0 +1 @@
(0x1_1_)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:6)" }

View File

@ -0,0 +1 @@
(0xa_1_)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:6)" }

View File

@ -0,0 +1 @@
(0x_a_1)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -0,0 +1 @@
(0x__1_1_)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -0,0 +1 @@
(0x_1__1)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -0,0 +1 @@
(0x_1_1_)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -0,0 +1 @@
(0o_1_1)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -0,0 +1 @@
(0o_11)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -0,0 +1 @@
(0o_01_1_)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -0,0 +1 @@
(0b_0_1_1)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -1 +1 @@
0x_a_1
0x_a_1

View File

@ -0,0 +1 @@
(0b_01_1_)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -0,0 +1 @@
(0b01_1_)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:7)" }

View File

@ -0,0 +1 @@
(0o1_1_)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:6)" }

View File

@ -0,0 +1 @@
(0o_1_1_)

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -0,0 +1 @@
{1_}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:2)" }

View File

@ -0,0 +1 @@
{1_1_}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:4)" }

View File

@ -0,0 +1 @@
{1_1__}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:4)" }

View File

@ -0,0 +1 @@
{1__1}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:2)" }

View File

@ -0,0 +1 @@
{1_1_.1_1}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:4)" }

View File

@ -0,0 +1 @@
{1_1._1_1}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:5)" }

View File

@ -1 +1 @@
0x__1_1_
0x__1_1_

View File

@ -0,0 +1 @@
{1_1.1_e1}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:6)" }

View File

@ -0,0 +1 @@
{1_1.1_E1}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:6)" }

View File

@ -0,0 +1 @@
{1_1.1e_1}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:7)" }

View File

@ -0,0 +1 @@
{1_1.1E_1}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:7)" }

View File

@ -0,0 +1 @@
{0x1_1_}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:6)" }

View File

@ -0,0 +1 @@
{0xa_1_}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:6)" }

View File

@ -0,0 +1 @@
{0x_a_1}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -0,0 +1 @@
{0x__1_1_}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -0,0 +1 @@
{0x_1__1}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -0,0 +1 @@
{0x_1_1_}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -1 +1 @@
0x_1__1
0x_1__1

View File

@ -0,0 +1 @@
{0o_1_1}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -0,0 +1 @@
{0o_11}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -0,0 +1 @@
{0o_01_1_}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -0,0 +1 @@
{0b_0_1_1}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -0,0 +1 @@
{0b_01_1_}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:3)" }

View File

@ -0,0 +1 @@
{0b01_1_}

View File

@ -0,0 +1 @@
{ "throws": "Invalid or unexpected token (1:7)" }

Some files were not shown because too many files have changed in this diff Show More