acorn
Advanced tools
Comparing version 8.4.1 to 8.5.0
@@ -0,1 +1,21 @@ | ||
## 8.5.0 (2021-09-06) | ||
### Bug fixes | ||
Improve context-dependent tokenization in a number of corner cases. | ||
Fix location tracking after a 0x2028 or 0x2029 character in a string literal (which before did not increase the line number). | ||
Fix an issue where arrow function bodies in for loop context would inappropriately consume `in` operators. | ||
Fix wrong end locations stored on SequenceExpression nodes. | ||
Implement restriction that `for`/`of` loop LHS can't start with `let`. | ||
### New features | ||
Add support for ES2022 class static blocks. | ||
Allow multiple input files to be passed to the CLI tool. | ||
## 8.4.1 (2021-06-24) | ||
@@ -2,0 +22,0 @@ |
@@ -176,2 +176,5 @@ export as namespace acorn | ||
f_expr: TokContext | ||
f_stat: TokContext | ||
f_expr_gen: TokContext | ||
f_gen: TokContext | ||
} | ||
@@ -178,0 +181,0 @@ |
@@ -7,3 +7,3 @@ 'use strict'; | ||
var infile, forceFile, silent = false, compact = false, tokenize = false; | ||
var inputFilePaths = [], forceFileName = false, fileMode = false, silent = false, compact = false, tokenize = false; | ||
var options = {}; | ||
@@ -14,3 +14,3 @@ | ||
print("usage: " + path.basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6|--ecma7|--ecma8|--ecma9|...|--ecma2015|--ecma2016|--ecma2017|--ecma2018|...]"); | ||
print(" [--tokenize] [--locations] [---allow-hash-bang] [--allow-await-outside-function] [--compact] [--silent] [--module] [--help] [--] [infile]"); | ||
print(" [--tokenize] [--locations] [---allow-hash-bang] [--allow-await-outside-function] [--compact] [--silent] [--module] [--help] [--] [<infile>...]"); | ||
process.exit(status); | ||
@@ -21,5 +21,8 @@ } | ||
var arg = process.argv[i]; | ||
if ((arg === "-" || arg[0] !== "-") && !infile) { infile = arg; } | ||
else if (arg === "--" && !infile && i + 2 === process.argv.length) { forceFile = infile = process.argv[++i]; } | ||
else if (arg === "--locations") { options.locations = true; } | ||
if (arg[0] !== "-" || arg === "-") { inputFilePaths.push(arg); } | ||
else if (arg === "--") { | ||
inputFilePaths.push.apply(inputFilePaths, process.argv.slice(i + 1)); | ||
forceFileName = true; | ||
break | ||
} else if (arg === "--locations") { options.locations = true; } | ||
else if (arg === "--allow-hash-bang") { options.allowHashBang = true; } | ||
@@ -41,17 +44,20 @@ else if (arg === "--allow-await-outside-function") { options.allowAwaitOutsideFunction = true; } | ||
function run(code) { | ||
var result; | ||
function run(codeList) { | ||
var result = [], fileIdx = 0; | ||
try { | ||
if (!tokenize) { | ||
result = acorn.parse(code, options); | ||
} else { | ||
result = []; | ||
var tokenizer = acorn.tokenizer(code, options), token; | ||
do { | ||
token = tokenizer.getToken(); | ||
result.push(token); | ||
} while (token.type !== acorn.tokTypes.eof) | ||
} | ||
codeList.forEach(function (code, idx) { | ||
fileIdx = idx; | ||
if (!tokenize) { | ||
result = acorn.parse(code, options); | ||
options.program = result; | ||
} else { | ||
var tokenizer = acorn.tokenizer(code, options), token; | ||
do { | ||
token = tokenizer.getToken(); | ||
result.push(token); | ||
} while (token.type !== acorn.tokTypes.eof) | ||
} | ||
}); | ||
} catch (e) { | ||
console.error(infile && infile !== "-" ? e.message.replace(/\(\d+:\d+\)$/, function (m) { return m.slice(0, 1) + infile + " " + m.slice(1); }) : e.message); | ||
console.error(fileMode ? e.message.replace(/\(\d+:\d+\)$/, function (m) { return m.slice(0, 1) + inputFilePaths[fileIdx] + " " + m.slice(1); }) : e.message); | ||
process.exit(1); | ||
@@ -62,4 +68,4 @@ } | ||
if (forceFile || infile && infile !== "-") { | ||
run(fs.readFileSync(infile, "utf8")); | ||
if (fileMode = inputFilePaths.length && (forceFileName || !inputFilePaths.includes("-") || inputFilePaths.length !== 1)) { | ||
run(inputFilePaths.map(function (path) { return fs.readFileSync(path, "utf8"); })); | ||
} else { | ||
@@ -69,3 +75,3 @@ var code = ""; | ||
process.stdin.on("data", function (chunk) { return code += chunk; }); | ||
process.stdin.on("end", function () { return run(code); }); | ||
process.stdin.on("end", function () { return run([code]); }); | ||
} |
@@ -19,3 +19,3 @@ { | ||
}, | ||
"version": "8.4.1", | ||
"version": "8.5.0", | ||
"engines": {"node": ">=0.4.0"}, | ||
@@ -22,0 +22,0 @@ "maintainers": [ |
@@ -57,3 +57,3 @@ # Acorn | ||
either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10 (2019), | ||
11 (2020), 12 (2021, partial support), 13 (2022, partial support) | ||
11 (2020), 12 (2021), 13 (2022, partial support) | ||
or `"latest"` (the latest the library supports). This influences | ||
@@ -60,0 +60,0 @@ support for strict mode, the set of reserved words, and support |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
459259
10140