Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: acornjs/acorn
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7.3.1
Choose a base ref
...
head repository: acornjs/acorn
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7.4.0
Choose a head ref
  • 9 commits
  • 19 files changed
  • 3 contributors

Commits on Jun 17, 2020

  1. Copy the full SHA
    3b6128e View commit details

Commits on Jun 24, 2020

  1. Add "MIT License" at the top of acorn License file

    Add a first line that specifies the license type "MIT License" this makes it more clear to developers which license is being used and can help them more easily determine if `acorn` is a package that they are okay to use in their software. [This is also the default for an MIT license for a repository when adding one in GitHub](https://github.com/joekrump/acorn/community/license/new?branch=master&template=mit).
    joekrump authored and marijnh committed Jun 24, 2020
    Copy the full SHA
    31d3b1c View commit details
  2. Copy the full SHA
    4e2c0e2 View commit details

Commits on Aug 3, 2020

  1. update test262

    mysticatea authored and marijnh committed Aug 3, 2020
    Copy the full SHA
    459fa1e View commit details
  2. add logical assignment operators

    mysticatea authored and marijnh committed Aug 3, 2020
    Copy the full SHA
    fe7b3f1 View commit details
  3. update test262

    mysticatea authored and marijnh committed Aug 3, 2020
    Copy the full SHA
    d20ade2 View commit details
  4. add numeric separators

    mysticatea authored and marijnh committed Aug 3, 2020
    Copy the full SHA
    e376a66 View commit details
  5. Copy the full SHA
    856b720 View commit details
  6. Mark version 7.4.0

    marijnh committed Aug 3, 2020
    Copy the full SHA
    54efb62 View commit details
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ Ingvar Stepanyan
Jackson Ray Hamilton
Jesse McCarthy
Jiaxing Wang
Joe Krump
Joel Kemp
Johannes Herr
John-David Dalton
2 changes: 2 additions & 0 deletions acorn-loose/LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
MIT License

Copyright (C) 2012-2018 by various contributors (see AUTHORS)

Permission is hereby granted, free of charge, to any person obtaining a copy
2 changes: 1 addition & 1 deletion acorn-loose/src/expression.js
Original file line number Diff line number Diff line change
@@ -266,7 +266,7 @@ lp.parseExprAtom = function() {
node = this.startNode()
node.value = this.tok.value
node.raw = this.input.slice(this.tok.start, this.tok.end)
if (this.tok.type === tt.num && node.raw.charCodeAt(node.raw.length - 1) === 110) node.bigint = node.raw.slice(0, -1)
if (this.tok.type === tt.num && node.raw.charCodeAt(node.raw.length - 1) === 110) node.bigint = node.raw.slice(0, -1).replace(/_/g, "")
this.next()
return this.finishNode(node, "Literal")

10 changes: 10 additions & 0 deletions acorn-walk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 7.2.0 (2020-06-17)

### New features

Support optional chaining and nullish coalescing.

Support `import.meta`.

Add support for `export * as ns from "source"`.

## 7.1.1 (2020-02-13)

### Bug fixes
2 changes: 2 additions & 0 deletions acorn-walk/LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
MIT License

Copyright (C) 2012-2018 by various contributors (see AUTHORS)

Permission is hereby granted, free of charge, to any person obtaining a copy
2 changes: 1 addition & 1 deletion acorn-walk/package.json
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
"main": "dist/walk.js",
"types": "dist/walk.d.ts",
"module": "dist/walk.mjs",
"version": "7.1.1",
"version": "7.2.0",
"engines": {"node": ">=0.4.0"},
"maintainers": [
{
8 changes: 8 additions & 0 deletions acorn/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 7.4.0 (2020-08-03)

### New features

Add support for logical assignment operators.

Add support for numeric separators.

## 7.3.1 (2020-06-11)

### Bug fixes
2 changes: 2 additions & 0 deletions acorn/LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
MIT License

Copyright (C) 2012-2018 by various contributors (see AUTHORS)

Permission is hereby granted, free of charge, to any person obtaining a copy
1 change: 0 additions & 1 deletion acorn/README.md
Original file line number Diff line number Diff line change
@@ -266,5 +266,4 @@ Plugins for ECMAScript proposals:
- [`acorn-stage3`](https://github.com/acornjs/acorn-stage3): Parse most stage 3 proposals, bundling:
- [`acorn-class-fields`](https://github.com/acornjs/acorn-class-fields): Parse [class fields proposal](https://github.com/tc39/proposal-class-fields)
- [`acorn-import-meta`](https://github.com/acornjs/acorn-import-meta): Parse [import.meta proposal](https://github.com/tc39/proposal-import-meta)
- [`acorn-numeric-separator`](https://github.com/acornjs/acorn-numeric-separator): Parse [numeric separator proposal](https://github.com/tc39/proposal-numeric-separator)
- [`acorn-private-methods`](https://github.com/acornjs/acorn-private-methods): parse [private methods, getters and setters proposal](https://github.com/tc39/proposal-private-methods)n
2 changes: 1 addition & 1 deletion acorn/package.json
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
"main": "dist/acorn.js",
"types": "dist/acorn.d.ts",
"module": "dist/acorn.mjs",
"version": "7.3.1",
"version": "7.4.0",
"engines": {"node": ">=0.4.0"},
"maintainers": [
{
2 changes: 1 addition & 1 deletion acorn/src/expression.js
Original file line number Diff line number Diff line change
@@ -517,7 +517,7 @@ pp.parseLiteral = function(value) {
let node = this.startNode()
node.value = value
node.raw = this.input.slice(this.start, this.end)
if (node.raw.charCodeAt(node.raw.length - 1) === 110) node.bigint = node.raw.slice(0, -1)
if (node.raw.charCodeAt(node.raw.length - 1) === 110) node.bigint = node.raw.slice(0, -1).replace(/_/g, "")
this.next()
return this.finishNode(node, "Literal")
}
2 changes: 1 addition & 1 deletion acorn/src/index.js
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ import {isIdentifierChar, isIdentifierStart} from "./identifier"
import {Token} from "./tokenize"
import {isNewLine, lineBreak, lineBreakG, nonASCIIwhitespace} from "./whitespace"

export const version = "7.3.1"
export const version = "7.4.0"
export {
Parser,
defaultOptions,
74 changes: 61 additions & 13 deletions acorn/src/tokenize.js
Original file line number Diff line number Diff line change
@@ -233,7 +233,13 @@ pp.readToken_mult_modulo_exp = function(code) { // '%*'

pp.readToken_pipe_amp = function(code) { // '|&'
let next = this.input.charCodeAt(this.pos + 1)
if (next === code) return this.finishOp(code === 124 ? tt.logicalOR : tt.logicalAND, 2)
if (next === code) {
if (this.options.ecmaVersion >= 12) {
let next2 = this.input.charCodeAt(this.pos + 2)
if (next2 === 61) return this.finishOp(tt.assign, 3)
}
return this.finishOp(code === 124 ? tt.logicalOR : tt.logicalAND, 2)
}
if (next === 61) return this.finishOp(tt.assign, 2)
return this.finishOp(code === 124 ? tt.bitwiseOR : tt.bitwiseAND, 1)
}
@@ -290,13 +296,20 @@ pp.readToken_eq_excl = function(code) { // '=!'
}

pp.readToken_question = function() { // '?'
if (this.options.ecmaVersion >= 11) {
const ecmaVersion = this.options.ecmaVersion
if (ecmaVersion >= 11) {
let next = this.input.charCodeAt(this.pos + 1)
if (next === 46) {
let next2 = this.input.charCodeAt(this.pos + 2)
if (next2 < 48 || next2 > 57) return this.finishOp(tt.questionDot, 2)
}
if (next === 63) return this.finishOp(tt.coalesce, 2)
if (next === 63) {
if (ecmaVersion >= 12) {
let next2 = this.input.charCodeAt(this.pos + 2)
if (next2 === 61) return this.finishOp(tt.assign, 3)
}
return this.finishOp(tt.coalesce, 2)
}
}
return this.finishOp(tt.question, 1)
}
@@ -425,30 +438,67 @@ pp.readRegexp = function() {
// were read, the integer value otherwise. When `len` is given, this
// will return `null` unless the integer has exactly `len` digits.

pp.readInt = function(radix, len) {
let start = this.pos, total = 0
for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) {
pp.readInt = function(radix, len, maybeLegacyOctalNumericLiteral) {
// `len` is used for character escape sequences. In that case, disallow separators.
const allowSeparators = this.options.ecmaVersion >= 12 && len === undefined

// `maybeLegacyOctalNumericLiteral` is true if it doesn't have prefix (0x,0o,0b)
// and isn't fraction part nor exponent part. In that case, if the first digit
// is zero then disallow separators.
const isLegacyOctalNumericLiteral = maybeLegacyOctalNumericLiteral && this.input.charCodeAt(this.pos) === 48

let start = this.pos, total = 0, lastCode = 0
for (let i = 0, e = len == null ? Infinity : len; i < e; ++i, ++this.pos) {
let code = this.input.charCodeAt(this.pos), val

if (allowSeparators && code === 95) {
if (isLegacyOctalNumericLiteral) this.raiseRecoverable(this.pos, "Numeric separator is not allowed in legacy octal numeric literals")
if (lastCode === 95) this.raiseRecoverable(this.pos, "Numeric separator must be exactly one underscore")
if (i === 0) this.raiseRecoverable(this.pos, "Numeric separator is not allowed at the first of digits")
lastCode = code
continue
}

if (code >= 97) val = code - 97 + 10 // a
else if (code >= 65) val = code - 65 + 10 // A
else if (code >= 48 && code <= 57) val = code - 48 // 0-9
else val = Infinity
if (val >= radix) break
++this.pos
lastCode = code
total = total * radix + val
}

if (allowSeparators && lastCode === 95) this.raiseRecoverable(this.pos - 1, "Numeric separator is not allowed at the last of digits")
if (this.pos === start || len != null && this.pos - start !== len) return null

return total
}

function stringToNumber(str, isLegacyOctalNumericLiteral) {
if (isLegacyOctalNumericLiteral) {
return parseInt(str, 8)
}

// `parseFloat(value)` stops parsing at the first numeric separator then returns a wrong value.
return parseFloat(str.replace(/_/g, ""))
}

function stringToBigInt(str) {
if (typeof BigInt !== "function") {
return null
}

// `BigInt(value)` throws syntax error if the string contains numeric separators.
return BigInt(str.replace(/_/g, ""))
}

pp.readRadixNumber = function(radix) {
let start = this.pos
this.pos += 2 // 0x
let val = this.readInt(radix)
if (val == null) this.raise(this.start + 2, "Expected number in radix " + radix)
if (this.options.ecmaVersion >= 11 && this.input.charCodeAt(this.pos) === 110) {
val = typeof BigInt !== "undefined" ? BigInt(this.input.slice(start, this.pos)) : null
val = stringToBigInt(this.input.slice(start, this.pos))
++this.pos
} else if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number")
return this.finishToken(tt.num, val)
@@ -458,13 +508,12 @@ pp.readRadixNumber = function(radix) {

pp.readNumber = function(startsWithDot) {
let start = this.pos
if (!startsWithDot && this.readInt(10) === null) this.raise(start, "Invalid number")
if (!startsWithDot && this.readInt(10, undefined, true) === null) this.raise(start, "Invalid number")
let octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48
if (octal && this.strict) this.raise(start, "Invalid number")
let next = this.input.charCodeAt(this.pos)
if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) {
let str = this.input.slice(start, this.pos)
let val = typeof BigInt !== "undefined" ? BigInt(str) : null
let val = stringToBigInt(this.input.slice(start, this.pos))
++this.pos
if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number")
return this.finishToken(tt.num, val)
@@ -482,8 +531,7 @@ pp.readNumber = function(startsWithDot) {
}
if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number")

let str = this.input.slice(start, this.pos)
let val = octal ? parseInt(str, 8) : parseFloat(str)
let val = stringToNumber(this.input.slice(start, this.pos), octal)
return this.finishToken(tt.num, val)
}

4 changes: 2 additions & 2 deletions bin/run_test262.js
Original file line number Diff line number Diff line change
@@ -10,11 +10,11 @@ const unsupportedFeatures = [
"class-static-fields-private",
"class-static-fields-public",
"class-static-methods-private",
"numeric-separator-literal",
"logical-assignment-operators",
];

run(
(content, {sourceType}) => parse(content, {sourceType, ecmaVersion: 11, allowHashBang: true, allowAwaitOutsideFunction: true}),
(content, {sourceType}) => parse(content, {sourceType, ecmaVersion: 12, allowHashBang: true, allowAwaitOutsideFunction: true}),
{
testsDirectory: path.dirname(require.resolve("test262/package.json")),
skip: test => (test.attrs.features && unsupportedFeatures.some(f => test.attrs.features.includes(f))),
12 changes: 2 additions & 10 deletions bin/test262.whitelist
Original file line number Diff line number Diff line change
@@ -25,16 +25,7 @@ built-ins/RegExp/property-escapes/generated/Script_Extensions_-_Khitan_Small_Scr
built-ins/RegExp/property-escapes/generated/Script_Extensions_-_Yezidi.js (default)
built-ins/RegExp/property-escapes/generated/Script_Extensions_-_Yezidi.js (strict mode)

language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier.js (default)
language/literals/regexp/named-groups/invalid-non-id-continue-groupspecifier.js (strict mode)
language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-3.js (default)
language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-3.js (strict mode)
language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-6.js (default)
language/literals/regexp/named-groups/invalid-non-id-start-groupspecifier-6.js (strict mode)
language/literals/regexp/named-groups/invalid-u-escape-in-groupspecifier.js (default)
language/literals/regexp/named-groups/invalid-u-escape-in-groupspecifier.js (strict mode)
language/literals/regexp/named-groups/invalid-u-escape-in-groupspecifier-2.js (default)
language/literals/regexp/named-groups/invalid-u-escape-in-groupspecifier-2.js (strict mode)
language/literals/string/legacy-non-octal-escape-sequence-8-strict.js (strict mode)

language/expressions/await/await-BindingIdentifier-in-global.js (default)
language/expressions/await/await-BindingIdentifier-in-global.js (strict mode)
@@ -44,5 +35,6 @@ language/expressions/await/await-in-nested-function.js (default)
language/expressions/await/await-in-nested-function.js (strict mode)
language/expressions/await/await-in-nested-generator.js (default)
language/expressions/await/await-in-nested-generator.js (strict mode)

language/statements/labeled/value-await-non-module.js (default)
language/statements/labeled/value-await-non-module.js (strict mode)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@
"eslint-plugin-standard": "^3.0.1",
"rollup": "^1.7.0",
"rollup-plugin-buble": "^0.19.0",
"test262": "git+https://github.com/tc39/test262.git#2c432e35b261a2474f122631b02eff3e031de383",
"test262": "git+https://github.com/tc39/test262.git#a6c819ad0f049f23f1a37af6b89dbb79fe3b9216",
"test262-parser-runner": "^0.5.0",
"test262-stream": "^1.2.1",
"unicode-13.0.0": "^0.8.0"
2 changes: 2 additions & 0 deletions test/run.js
Original file line number Diff line number Diff line change
@@ -21,6 +21,8 @@
require("./tests-import-meta.js");
require("./tests-nullish-coalescing.js");
require("./tests-optional-chaining.js");
require("./tests-logical-assignment-operators.js");
require("./tests-numeric-separators.js");
var acorn = require("../acorn")
var acorn_loose = require("../acorn-loose")

Loading