From 9d23ba0a22fe3d1561b7860dc3aefadef72a4514 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sun, 24 Jan 2021 21:48:51 +0000 Subject: support exponentiation operator (#4593) --- lib/parse.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/parse.js') diff --git a/lib/parse.js b/lib/parse.js index 64307a95..38c56d8f 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -81,6 +81,7 @@ var OPERATORS = makePredicate([ "*", "/", "%", + "**", ">>", "<<", ">>>", @@ -630,7 +631,8 @@ var PRECEDENCE = function(a, ret) { ["<", ">", "<=", ">=", "in", "instanceof"], [">>", "<<", ">>>"], ["+", "-"], - ["*", "/", "%"] + ["*", "/", "%"], + ["**"], ], {}); var ATOMIC_START_TOKEN = makePredicate("atom bigint num regexp string"); @@ -1860,7 +1862,7 @@ function parse($TEXT, options) { var prec = op != null ? PRECEDENCE[op] : null; if (prec != null && prec > min_prec) { next(); - var right = expr_op(maybe_await(), prec, no_in); + var right = expr_op(maybe_await(), op == "**" ? prec - 1 : prec, no_in); return expr_op(new AST_Binary({ start : left.start, left : left, -- cgit v1.2.3