From b0e50db4f6af43b7d28428d49039c405e60f3980 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Wed, 9 Feb 2022 20:21:58 +0100 Subject: [PATCH] build --- docs/_snowpack/link/strudel.js | 168 +- docs/_snowpack/pkg/common/index-1e63141f.js | 1090 ++ .../{index-04edb6a1.js => index-67cfdec9.js} | 92 +- docs/_snowpack/pkg/common/index-d01087d6.js | 90 + docs/_snowpack/pkg/estraverse.js | 810 ++ docs/_snowpack/pkg/import-map.json | 6 + docs/_snowpack/pkg/multimap.js | 229 + docs/_snowpack/pkg/react-codemirror2.js | 3 +- docs/_snowpack/pkg/react-dom.js | 3 +- docs/_snowpack/pkg/react.js | 5 +- docs/_snowpack/pkg/shift-ast.js | 106 + docs/_snowpack/pkg/shift-codegen.js | 11828 ++++++++++++++++ docs/_snowpack/pkg/shift-regexp-acceptor.js | 1771 +++ docs/_snowpack/pkg/shift-spec.js | 876 ++ docs/dist/App.js | 128 +- docs/dist/parse.js | 26 +- docs/dist/shapeshifter.js | 26 + docs/dist/shift-parser/early-error-state.js | 409 + docs/dist/shift-parser/early-errors.js | 772 + docs/dist/shift-parser/errors.js | 119 + docs/dist/shift-parser/index.js | 149 + docs/dist/shift-parser/parser.js | 2641 ++++ docs/dist/shift-parser/tokenizer.js | 1505 ++ docs/dist/shift-parser/unicode.js | 11 + docs/dist/shift-parser/utils.js | 105 + docs/dist/shift-reducer/adapt.js | 418 + docs/dist/shift-reducer/clone-reducer.js | 416 + docs/dist/shift-reducer/director.js | 418 + docs/dist/shift-reducer/index.js | 27 + docs/dist/shift-reducer/lazy-clone-reducer.js | 650 + docs/dist/shift-reducer/memoize.js | 914 ++ docs/dist/shift-reducer/monoidal-reducer.js | 430 + docs/dist/shift-reducer/reducers.js | 91 + docs/dist/shift-reducer/thunked-director.js | 418 + .../shift-reducer/thunked-monoidal-reducer.js | 444 + docs/dist/shift-reducer/thunkify-class.js | 416 + docs/dist/shift-reducer/thunkify.js | 416 + docs/dist/shift-traverser/index.js | 61 + docs/dist/tone.js | 79 + docs/dist/tunes.js | 63 +- docs/global.css | 36 +- docs/hot.js | 45 + repl/package.json | 1 + 43 files changed, 28084 insertions(+), 227 deletions(-) create mode 100644 docs/_snowpack/pkg/common/index-1e63141f.js rename docs/_snowpack/pkg/common/{index-04edb6a1.js => index-67cfdec9.js} (75%) create mode 100644 docs/_snowpack/pkg/common/index-d01087d6.js create mode 100644 docs/_snowpack/pkg/estraverse.js create mode 100644 docs/_snowpack/pkg/multimap.js create mode 100644 docs/_snowpack/pkg/shift-ast.js create mode 100644 docs/_snowpack/pkg/shift-codegen.js create mode 100644 docs/_snowpack/pkg/shift-regexp-acceptor.js create mode 100644 docs/_snowpack/pkg/shift-spec.js create mode 100644 docs/dist/shapeshifter.js create mode 100644 docs/dist/shift-parser/early-error-state.js create mode 100644 docs/dist/shift-parser/early-errors.js create mode 100644 docs/dist/shift-parser/errors.js create mode 100644 docs/dist/shift-parser/index.js create mode 100644 docs/dist/shift-parser/parser.js create mode 100644 docs/dist/shift-parser/tokenizer.js create mode 100644 docs/dist/shift-parser/unicode.js create mode 100644 docs/dist/shift-parser/utils.js create mode 100644 docs/dist/shift-reducer/adapt.js create mode 100644 docs/dist/shift-reducer/clone-reducer.js create mode 100644 docs/dist/shift-reducer/director.js create mode 100644 docs/dist/shift-reducer/index.js create mode 100644 docs/dist/shift-reducer/lazy-clone-reducer.js create mode 100644 docs/dist/shift-reducer/memoize.js create mode 100644 docs/dist/shift-reducer/monoidal-reducer.js create mode 100644 docs/dist/shift-reducer/reducers.js create mode 100644 docs/dist/shift-reducer/thunked-director.js create mode 100644 docs/dist/shift-reducer/thunked-monoidal-reducer.js create mode 100644 docs/dist/shift-reducer/thunkify-class.js create mode 100644 docs/dist/shift-reducer/thunkify.js create mode 100644 docs/dist/shift-traverser/index.js create mode 100644 docs/dist/tone.js create mode 100644 docs/hot.js diff --git a/docs/_snowpack/link/strudel.js b/docs/_snowpack/link/strudel.js index 47d7536e..eb531426 100644 --- a/docs/_snowpack/link/strudel.js +++ b/docs/_snowpack/link/strudel.js @@ -1,11 +1,7 @@ import Fraction from "../pkg/fractionjs.js"; -var removeUndefineds = function(xs) { - return xs.filter((x) => x != void 0); -}; -function flatten(arr) { - return [].concat(...arr); -} -var id = (a) => a; +const removeUndefineds = (xs) => xs.filter((x) => x != void 0); +const flatten = (arr) => [].concat(...arr); +const id = (a) => a; function curry(func) { return function curried(...args) { if (args.length >= func.length) { @@ -59,16 +55,16 @@ class TimeSpan { this.end = Fraction(end); } get spanCycles() { - var spans = []; + const spans = []; var begin = this.begin; - var end = this.end; - var end_sam = end.sam(); + const end = this.end; + const end_sam = end.sam(); while (end.gt(begin)) { if (begin.sam().equals(end_sam)) { spans.push(new TimeSpan(begin, this.end)); break; } - var next_begin = begin.nextSam(); + const next_begin = begin.nextSam(); spans.push(new TimeSpan(begin, next_begin)); begin = next_begin; } @@ -78,8 +74,8 @@ class TimeSpan { return new TimeSpan(func_time(this.begin), func_time(this.end)); } intersection(other) { - var intersect_begin = this.begin.max(other.begin); - var intersect_end = this.end.min(other.end); + const intersect_begin = this.begin.max(other.begin); + const intersect_end = this.end.min(other.end); if (intersect_begin.gt(intersect_end)) { return void 0; } @@ -94,7 +90,7 @@ class TimeSpan { return new TimeSpan(intersect_begin, intersect_end); } intersection_e(other) { - var result = this.intersection(other); + const result = this.intersection(other); if (result == void 0) { } return result; @@ -116,7 +112,7 @@ class Hap { this.value = value; } withSpan(func) { - var whole = this.whole ? func(this.whole) : void 0; + const whole = this.whole ? func(this.whole) : void 0; return new Hap(whole, func(this.part), this.value); } withValue(func) { @@ -140,10 +136,8 @@ class Pattern { this.query = query2; } _splitQueries() { - var pat = this; - var q = function(span) { - return flatten(span.spanCycles.map((subspan) => pat.query(subspan))); - }; + const pat = this; + const q = (span) => flatten(span.spanCycles.map((subspan) => pat.query(subspan))); return new Pattern(q); } withQuerySpan(func) { @@ -177,12 +171,12 @@ class Pattern { return this._filterEvents((hap) => hap.hasOnset()); } _appWhole(whole_func, pat_val) { - var pat_func = this; + const pat_func = this; query = function(span) { - var event_funcs = pat_func.query(span); - var event_vals = pat_val.query(span); + const event_funcs = pat_func.query(span); + const event_vals = pat_val.query(span); apply = function(event_func, event_val) { - var s = event_func.part.intersection(event_val.part); + const s = event_func.part.intersection(event_val.part); if (s == void 0) { return void 0; } @@ -193,7 +187,7 @@ class Pattern { return new Pattern(query); } appBoth(pat_val) { - var whole_func = function(span_a, span_b) { + const whole_func = function(span_a, span_b) { if (span_a == void 0 || span_B == void 0) { return void 0; } @@ -202,16 +196,16 @@ class Pattern { return this._appWhole(whole_func, pat_val); } appLeft(pat_val) { - var pat_func = this; - var query2 = function(span) { - var haps = []; - for (var hap_func of pat_func.query(span)) { - var event_vals = pat_val.query(hap_func.part); - for (var hap_val of event_vals) { - var new_whole = hap_func.whole; - var new_part = hap_func.part.intersection_e(hap_val.part); - var new_value = hap_func.value(hap_val.value); - var hap = new Hap(new_whole, new_part, new_value); + const pat_func = this; + const query2 = function(span) { + const haps = []; + for (const hap_func of pat_func.query(span)) { + const event_vals = pat_val.query(hap_func.part); + for (const hap_val of event_vals) { + const new_whole = hap_func.whole; + const new_part = hap_func.part.intersection_e(hap_val.part); + const new_value = hap_func.value(hap_val.value); + const hap = new Hap(new_whole, new_part, new_value); haps.push(hap); } } @@ -220,16 +214,16 @@ class Pattern { return new Pattern(query2); } appRight(pat_val) { - var pat_func = this; - var query2 = function(span) { - var haps = []; - for (var hap_val of pat_val.query(span)) { - var hap_funcs = pat_func.query(hap_val.part); - for (var hap_func of hap_funcs) { - var new_whole = hap_val.whole; - var new_part = hap_func.part.intersection_e(hap_val.part); - var new_value = hap_func.value(hap_val.value); - var hap = new Hap(new_whole, new_part, new_value); + const pat_func = this; + const query2 = function(span) { + const haps = []; + for (const hap_val of pat_val.query(span)) { + const hap_funcs = pat_func.query(hap_val.part); + for (const hap_func of hap_funcs) { + const new_whole = hap_val.whole; + const new_part = hap_func.part.intersection_e(hap_val.part); + const new_value = hap_func.value(hap_val.value); + const hap = new Hap(new_whole, new_part, new_value); haps.push(hap); } } @@ -256,12 +250,12 @@ class Pattern { return this._opleft(other, (a) => (b) => Object.assign({}, a, b)); } _bindWhole(choose_whole, func) { - var pat_val = this; - var query2 = function(span) { - var withWhole = function(a, b) { + const pat_val = this; + const query2 = function(span) { + const withWhole = function(a, b) { return new Hap(choose_whole(a.whole, b.whole), b.part, b.value); }; - var match = function(a) { + const match = function(a) { return func(a.value).query(a.part).map((b) => withWhole(a, b)); }; return flatten(pat_val.query(span).map((a) => match(a))); @@ -269,7 +263,7 @@ class Pattern { return new Pattern(query2); } bind(func) { - var whole_func = function(a, b) { + const whole_func = function(a, b) { if (a == void 0 || b == void 0) { return void 0; } @@ -301,43 +295,43 @@ class Pattern { return patterned; } _fast(factor) { - var fastQuery = this.withQueryTime((t) => t.mul(factor)); + const fastQuery = this.withQueryTime((t) => t.mul(factor)); return fastQuery.withEventTime((t) => t.div(factor)); } - fast(factor) { - return this._patternify(Pattern.prototype._fast)(factor); + fast(...factor) { + return this._patternify(Pattern.prototype._fast)(...factor); } _slow(factor) { return this._fast(1 / factor); } - slow(factor) { - return this._patternify(Pattern.prototype._slow)(factor); + slow(...factor) { + return this._patternify(Pattern.prototype._slow)(...factor); } _early(offset) { offset = Fraction(offset); return this.withQueryTime((t) => t.add(offset)).withEventTime((t) => t.sub(offset)); } - early(factor) { - return this._patternify(Pattern.prototype._early)(factor); + early(...factor) { + return this._patternify(Pattern.prototype._early)(...factor); } _late(offset) { return this._early(0 - offset); } - late(factor) { - return this._patternify(Pattern.prototype._late)(factor); + late(...factor) { + return this._patternify(Pattern.prototype._late)(...factor); } when(binary_pat, func) { - var true_pat = binary_pat._filterValues(id); - var false_pat = binary_pat._filterValues((val) => !val); - var with_pat = true_pat.fmap((_) => (y) => y).appRight(func(this)); - var without_pat = false_pat.fmap((_) => (y) => y).appRight(this); + const true_pat = binary_pat._filterValues(id); + const false_pat = binary_pat._filterValues((val) => !val); + const with_pat = true_pat.fmap((_) => (y) => y).appRight(func(this)); + const without_pat = false_pat.fmap((_) => (y) => y).appRight(this); return stack(with_pat, without_pat); } off(time_pat, func) { return stack([this, func(this._early(time_pat))]); } every(n, func) { - var pats = Array(n - 1).fill(this); + const pats = Array(n - 1).fill(this); pats.unshift(func(this)); return slowcat(...pats); } @@ -345,32 +339,32 @@ class Pattern { return fastcat(...[this, other]); } rev() { - var pat = this; - var query2 = function(span) { - var cycle = span.begin.sam(); - var next_cycle = span.begin.nextSam(); - var reflect = function(to_reflect) { - var reflected = to_reflect.withTime((time) => cycle.add(next_cycle.sub(time))); - var tmp = reflected.begin; + const pat = this; + const query2 = function(span) { + const cycle = span.begin.sam(); + const next_cycle = span.begin.nextSam(); + const reflect = function(to_reflect) { + const reflected = to_reflect.withTime((time) => cycle.add(next_cycle.sub(time))); + const tmp = reflected.begin; reflected.begin = reflected.end; reflected.end = tmp; return reflected; }; - var haps = pat.query(reflect(span)); + const haps = pat.query(reflect(span)); return haps.map((hap) => hap.withSpan(reflect)); }; return new Pattern(query2)._splitQueries(); } jux(func, by = 1) { by /= 2; - var elem_or = function(dict, key, dflt) { + const elem_or = function(dict, key, dflt) { if (key in dict) { return dict[key]; } return dflt; }; - var left = this.withValue((val) => Object.assign({}, val, {pan: elem_or(val, "pan", 0.5) - by})); - var right = this.withValue((val) => Object.assign({}, val, {pan: elem_or(val, "pan", 0.5) + by})); + const left = this.withValue((val) => Object.assign({}, val, {pan: elem_or(val, "pan", 0.5) - by})); + const right = this.withValue((val) => Object.assign({}, val, {pan: elem_or(val, "pan", 0.5) + by})); return stack([left, func(right)]); } } @@ -391,10 +385,8 @@ function reify(thing) { return pure(thing); } function stack(...pats) { - var pats = pats.map((pat) => reify(pat)); - var query2 = function(span) { - return flatten(pats.map((pat) => pat.query(span))); - }; + const reified = pats.map((pat) => reify(pat)); + const query2 = (span) => flatten(reified.map((pat) => pat.query(span))); return new Pattern(query2); } function slowcat(...pats) { @@ -429,15 +421,15 @@ function sequence(...xs) { return _sequenceCount(xs)[0]; } function polymeter(steps = 0, ...args) { - var seqs = args.map((a) => _sequenceCount(a)); + const seqs = args.map((a) => _sequenceCount(a)); if (seqs.length == 0) { return silence; } if (steps == 0) { steps = seqs[0][1]; } - var pats = []; - for (var seq of seqs) { + const pats = []; + for (const seq of seqs) { if (seq[1] == 0) { next; } @@ -453,7 +445,7 @@ function pm(args) { polymeter(args); } function polyrhythm(...xs) { - var seqs = xs.map((a) => sequence(a)); + const seqs = xs.map((a) => sequence(a)); if (seqs.length == 0) { return silence; } @@ -462,6 +454,11 @@ function polyrhythm(...xs) { function pr(args) { polyrhythm(args); } +const fast = curry((a, pat) => pat.fast(a)); +const slow = curry((a, pat) => pat.slow(a)); +const early = curry((a, pat) => pat.early(a)); +const late = curry((a, pat) => pat.late(a)); +const rev = (pat) => pat.rev(); export { Fraction, TimeSpan, @@ -478,5 +475,10 @@ export { polyrhythm, pr, reify, - silence + silence, + fast, + slow, + early, + late, + rev }; diff --git a/docs/_snowpack/pkg/common/index-1e63141f.js b/docs/_snowpack/pkg/common/index-1e63141f.js new file mode 100644 index 00000000..15f53e79 --- /dev/null +++ b/docs/_snowpack/pkg/common/index-1e63141f.js @@ -0,0 +1,1090 @@ +import { g as getDefaultExportFromCjs, c as createCommonjsModule } from './_commonjsHelpers-8c19dec8.js'; + +var dist = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +// Generated by scripts/generate.js. + +/** + * Copyright 2016 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var ArrayAssignmentTarget = exports.ArrayAssignmentTarget = function ArrayAssignmentTarget(_ref) { + var elements = _ref.elements, + rest = _ref.rest; + + _classCallCheck(this, ArrayAssignmentTarget); + + this.type = 'ArrayAssignmentTarget'; + this.elements = elements; + this.rest = rest; +}; + +var ArrayBinding = exports.ArrayBinding = function ArrayBinding(_ref2) { + var elements = _ref2.elements, + rest = _ref2.rest; + + _classCallCheck(this, ArrayBinding); + + this.type = 'ArrayBinding'; + this.elements = elements; + this.rest = rest; +}; + +var ArrayExpression = exports.ArrayExpression = function ArrayExpression(_ref3) { + var elements = _ref3.elements; + + _classCallCheck(this, ArrayExpression); + + this.type = 'ArrayExpression'; + this.elements = elements; +}; + +var ArrowExpression = exports.ArrowExpression = function ArrowExpression(_ref4) { + var isAsync = _ref4.isAsync, + params = _ref4.params, + body = _ref4.body; + + _classCallCheck(this, ArrowExpression); + + this.type = 'ArrowExpression'; + this.isAsync = isAsync; + this.params = params; + this.body = body; +}; + +var AssignmentExpression = exports.AssignmentExpression = function AssignmentExpression(_ref5) { + var binding = _ref5.binding, + expression = _ref5.expression; + + _classCallCheck(this, AssignmentExpression); + + this.type = 'AssignmentExpression'; + this.binding = binding; + this.expression = expression; +}; + +var AssignmentTargetIdentifier = exports.AssignmentTargetIdentifier = function AssignmentTargetIdentifier(_ref6) { + var name = _ref6.name; + + _classCallCheck(this, AssignmentTargetIdentifier); + + this.type = 'AssignmentTargetIdentifier'; + this.name = name; +}; + +var AssignmentTargetPropertyIdentifier = exports.AssignmentTargetPropertyIdentifier = function AssignmentTargetPropertyIdentifier(_ref7) { + var binding = _ref7.binding, + init = _ref7.init; + + _classCallCheck(this, AssignmentTargetPropertyIdentifier); + + this.type = 'AssignmentTargetPropertyIdentifier'; + this.binding = binding; + this.init = init; +}; + +var AssignmentTargetPropertyProperty = exports.AssignmentTargetPropertyProperty = function AssignmentTargetPropertyProperty(_ref8) { + var name = _ref8.name, + binding = _ref8.binding; + + _classCallCheck(this, AssignmentTargetPropertyProperty); + + this.type = 'AssignmentTargetPropertyProperty'; + this.name = name; + this.binding = binding; +}; + +var AssignmentTargetWithDefault = exports.AssignmentTargetWithDefault = function AssignmentTargetWithDefault(_ref9) { + var binding = _ref9.binding, + init = _ref9.init; + + _classCallCheck(this, AssignmentTargetWithDefault); + + this.type = 'AssignmentTargetWithDefault'; + this.binding = binding; + this.init = init; +}; + +var AwaitExpression = exports.AwaitExpression = function AwaitExpression(_ref10) { + var expression = _ref10.expression; + + _classCallCheck(this, AwaitExpression); + + this.type = 'AwaitExpression'; + this.expression = expression; +}; + +var BinaryExpression = exports.BinaryExpression = function BinaryExpression(_ref11) { + var left = _ref11.left, + operator = _ref11.operator, + right = _ref11.right; + + _classCallCheck(this, BinaryExpression); + + this.type = 'BinaryExpression'; + this.left = left; + this.operator = operator; + this.right = right; +}; + +var BindingIdentifier = exports.BindingIdentifier = function BindingIdentifier(_ref12) { + var name = _ref12.name; + + _classCallCheck(this, BindingIdentifier); + + this.type = 'BindingIdentifier'; + this.name = name; +}; + +var BindingPropertyIdentifier = exports.BindingPropertyIdentifier = function BindingPropertyIdentifier(_ref13) { + var binding = _ref13.binding, + init = _ref13.init; + + _classCallCheck(this, BindingPropertyIdentifier); + + this.type = 'BindingPropertyIdentifier'; + this.binding = binding; + this.init = init; +}; + +var BindingPropertyProperty = exports.BindingPropertyProperty = function BindingPropertyProperty(_ref14) { + var name = _ref14.name, + binding = _ref14.binding; + + _classCallCheck(this, BindingPropertyProperty); + + this.type = 'BindingPropertyProperty'; + this.name = name; + this.binding = binding; +}; + +var BindingWithDefault = exports.BindingWithDefault = function BindingWithDefault(_ref15) { + var binding = _ref15.binding, + init = _ref15.init; + + _classCallCheck(this, BindingWithDefault); + + this.type = 'BindingWithDefault'; + this.binding = binding; + this.init = init; +}; + +var Block = exports.Block = function Block(_ref16) { + var statements = _ref16.statements; + + _classCallCheck(this, Block); + + this.type = 'Block'; + this.statements = statements; +}; + +var BlockStatement = exports.BlockStatement = function BlockStatement(_ref17) { + var block = _ref17.block; + + _classCallCheck(this, BlockStatement); + + this.type = 'BlockStatement'; + this.block = block; +}; + +var BreakStatement = exports.BreakStatement = function BreakStatement(_ref18) { + var label = _ref18.label; + + _classCallCheck(this, BreakStatement); + + this.type = 'BreakStatement'; + this.label = label; +}; + +var CallExpression = exports.CallExpression = function CallExpression(_ref19) { + var callee = _ref19.callee, + _arguments = _ref19.arguments; + + _classCallCheck(this, CallExpression); + + this.type = 'CallExpression'; + this.callee = callee; + this.arguments = _arguments; +}; + +var CatchClause = exports.CatchClause = function CatchClause(_ref20) { + var binding = _ref20.binding, + body = _ref20.body; + + _classCallCheck(this, CatchClause); + + this.type = 'CatchClause'; + this.binding = binding; + this.body = body; +}; + +var ClassDeclaration = exports.ClassDeclaration = function ClassDeclaration(_ref21) { + var name = _ref21.name, + _super = _ref21.super, + elements = _ref21.elements; + + _classCallCheck(this, ClassDeclaration); + + this.type = 'ClassDeclaration'; + this.name = name; + this.super = _super; + this.elements = elements; +}; + +var ClassElement = exports.ClassElement = function ClassElement(_ref22) { + var isStatic = _ref22.isStatic, + method = _ref22.method; + + _classCallCheck(this, ClassElement); + + this.type = 'ClassElement'; + this.isStatic = isStatic; + this.method = method; +}; + +var ClassExpression = exports.ClassExpression = function ClassExpression(_ref23) { + var name = _ref23.name, + _super = _ref23.super, + elements = _ref23.elements; + + _classCallCheck(this, ClassExpression); + + this.type = 'ClassExpression'; + this.name = name; + this.super = _super; + this.elements = elements; +}; + +var CompoundAssignmentExpression = exports.CompoundAssignmentExpression = function CompoundAssignmentExpression(_ref24) { + var binding = _ref24.binding, + operator = _ref24.operator, + expression = _ref24.expression; + + _classCallCheck(this, CompoundAssignmentExpression); + + this.type = 'CompoundAssignmentExpression'; + this.binding = binding; + this.operator = operator; + this.expression = expression; +}; + +var ComputedMemberAssignmentTarget = exports.ComputedMemberAssignmentTarget = function ComputedMemberAssignmentTarget(_ref25) { + var object = _ref25.object, + expression = _ref25.expression; + + _classCallCheck(this, ComputedMemberAssignmentTarget); + + this.type = 'ComputedMemberAssignmentTarget'; + this.object = object; + this.expression = expression; +}; + +var ComputedMemberExpression = exports.ComputedMemberExpression = function ComputedMemberExpression(_ref26) { + var object = _ref26.object, + expression = _ref26.expression; + + _classCallCheck(this, ComputedMemberExpression); + + this.type = 'ComputedMemberExpression'; + this.object = object; + this.expression = expression; +}; + +var ComputedPropertyName = exports.ComputedPropertyName = function ComputedPropertyName(_ref27) { + var expression = _ref27.expression; + + _classCallCheck(this, ComputedPropertyName); + + this.type = 'ComputedPropertyName'; + this.expression = expression; +}; + +var ConditionalExpression = exports.ConditionalExpression = function ConditionalExpression(_ref28) { + var test = _ref28.test, + consequent = _ref28.consequent, + alternate = _ref28.alternate; + + _classCallCheck(this, ConditionalExpression); + + this.type = 'ConditionalExpression'; + this.test = test; + this.consequent = consequent; + this.alternate = alternate; +}; + +var ContinueStatement = exports.ContinueStatement = function ContinueStatement(_ref29) { + var label = _ref29.label; + + _classCallCheck(this, ContinueStatement); + + this.type = 'ContinueStatement'; + this.label = label; +}; + +var DataProperty = exports.DataProperty = function DataProperty(_ref30) { + var name = _ref30.name, + expression = _ref30.expression; + + _classCallCheck(this, DataProperty); + + this.type = 'DataProperty'; + this.name = name; + this.expression = expression; +}; + +var DebuggerStatement = exports.DebuggerStatement = function DebuggerStatement() { + _classCallCheck(this, DebuggerStatement); + + this.type = 'DebuggerStatement'; +}; + +var Directive = exports.Directive = function Directive(_ref31) { + var rawValue = _ref31.rawValue; + + _classCallCheck(this, Directive); + + this.type = 'Directive'; + this.rawValue = rawValue; +}; + +var DoWhileStatement = exports.DoWhileStatement = function DoWhileStatement(_ref32) { + var body = _ref32.body, + test = _ref32.test; + + _classCallCheck(this, DoWhileStatement); + + this.type = 'DoWhileStatement'; + this.body = body; + this.test = test; +}; + +var EmptyStatement = exports.EmptyStatement = function EmptyStatement() { + _classCallCheck(this, EmptyStatement); + + this.type = 'EmptyStatement'; +}; + +var Export = exports.Export = function Export(_ref33) { + var declaration = _ref33.declaration; + + _classCallCheck(this, Export); + + this.type = 'Export'; + this.declaration = declaration; +}; + +var ExportAllFrom = exports.ExportAllFrom = function ExportAllFrom(_ref34) { + var moduleSpecifier = _ref34.moduleSpecifier; + + _classCallCheck(this, ExportAllFrom); + + this.type = 'ExportAllFrom'; + this.moduleSpecifier = moduleSpecifier; +}; + +var ExportDefault = exports.ExportDefault = function ExportDefault(_ref35) { + var body = _ref35.body; + + _classCallCheck(this, ExportDefault); + + this.type = 'ExportDefault'; + this.body = body; +}; + +var ExportFrom = exports.ExportFrom = function ExportFrom(_ref36) { + var namedExports = _ref36.namedExports, + moduleSpecifier = _ref36.moduleSpecifier; + + _classCallCheck(this, ExportFrom); + + this.type = 'ExportFrom'; + this.namedExports = namedExports; + this.moduleSpecifier = moduleSpecifier; +}; + +var ExportFromSpecifier = exports.ExportFromSpecifier = function ExportFromSpecifier(_ref37) { + var name = _ref37.name, + exportedName = _ref37.exportedName; + + _classCallCheck(this, ExportFromSpecifier); + + this.type = 'ExportFromSpecifier'; + this.name = name; + this.exportedName = exportedName; +}; + +var ExportLocalSpecifier = exports.ExportLocalSpecifier = function ExportLocalSpecifier(_ref38) { + var name = _ref38.name, + exportedName = _ref38.exportedName; + + _classCallCheck(this, ExportLocalSpecifier); + + this.type = 'ExportLocalSpecifier'; + this.name = name; + this.exportedName = exportedName; +}; + +var ExportLocals = exports.ExportLocals = function ExportLocals(_ref39) { + var namedExports = _ref39.namedExports; + + _classCallCheck(this, ExportLocals); + + this.type = 'ExportLocals'; + this.namedExports = namedExports; +}; + +var ExpressionStatement = exports.ExpressionStatement = function ExpressionStatement(_ref40) { + var expression = _ref40.expression; + + _classCallCheck(this, ExpressionStatement); + + this.type = 'ExpressionStatement'; + this.expression = expression; +}; + +var ForAwaitStatement = exports.ForAwaitStatement = function ForAwaitStatement(_ref41) { + var left = _ref41.left, + right = _ref41.right, + body = _ref41.body; + + _classCallCheck(this, ForAwaitStatement); + + this.type = 'ForAwaitStatement'; + this.left = left; + this.right = right; + this.body = body; +}; + +var ForInStatement = exports.ForInStatement = function ForInStatement(_ref42) { + var left = _ref42.left, + right = _ref42.right, + body = _ref42.body; + + _classCallCheck(this, ForInStatement); + + this.type = 'ForInStatement'; + this.left = left; + this.right = right; + this.body = body; +}; + +var ForOfStatement = exports.ForOfStatement = function ForOfStatement(_ref43) { + var left = _ref43.left, + right = _ref43.right, + body = _ref43.body; + + _classCallCheck(this, ForOfStatement); + + this.type = 'ForOfStatement'; + this.left = left; + this.right = right; + this.body = body; +}; + +var ForStatement = exports.ForStatement = function ForStatement(_ref44) { + var init = _ref44.init, + test = _ref44.test, + update = _ref44.update, + body = _ref44.body; + + _classCallCheck(this, ForStatement); + + this.type = 'ForStatement'; + this.init = init; + this.test = test; + this.update = update; + this.body = body; +}; + +var FormalParameters = exports.FormalParameters = function FormalParameters(_ref45) { + var items = _ref45.items, + rest = _ref45.rest; + + _classCallCheck(this, FormalParameters); + + this.type = 'FormalParameters'; + this.items = items; + this.rest = rest; +}; + +var FunctionBody = exports.FunctionBody = function FunctionBody(_ref46) { + var directives = _ref46.directives, + statements = _ref46.statements; + + _classCallCheck(this, FunctionBody); + + this.type = 'FunctionBody'; + this.directives = directives; + this.statements = statements; +}; + +var FunctionDeclaration = exports.FunctionDeclaration = function FunctionDeclaration(_ref47) { + var isAsync = _ref47.isAsync, + isGenerator = _ref47.isGenerator, + name = _ref47.name, + params = _ref47.params, + body = _ref47.body; + + _classCallCheck(this, FunctionDeclaration); + + this.type = 'FunctionDeclaration'; + this.isAsync = isAsync; + this.isGenerator = isGenerator; + this.name = name; + this.params = params; + this.body = body; +}; + +var FunctionExpression = exports.FunctionExpression = function FunctionExpression(_ref48) { + var isAsync = _ref48.isAsync, + isGenerator = _ref48.isGenerator, + name = _ref48.name, + params = _ref48.params, + body = _ref48.body; + + _classCallCheck(this, FunctionExpression); + + this.type = 'FunctionExpression'; + this.isAsync = isAsync; + this.isGenerator = isGenerator; + this.name = name; + this.params = params; + this.body = body; +}; + +var Getter = exports.Getter = function Getter(_ref49) { + var name = _ref49.name, + body = _ref49.body; + + _classCallCheck(this, Getter); + + this.type = 'Getter'; + this.name = name; + this.body = body; +}; + +var IdentifierExpression = exports.IdentifierExpression = function IdentifierExpression(_ref50) { + var name = _ref50.name; + + _classCallCheck(this, IdentifierExpression); + + this.type = 'IdentifierExpression'; + this.name = name; +}; + +var IfStatement = exports.IfStatement = function IfStatement(_ref51) { + var test = _ref51.test, + consequent = _ref51.consequent, + alternate = _ref51.alternate; + + _classCallCheck(this, IfStatement); + + this.type = 'IfStatement'; + this.test = test; + this.consequent = consequent; + this.alternate = alternate; +}; + +var Import = exports.Import = function Import(_ref52) { + var defaultBinding = _ref52.defaultBinding, + namedImports = _ref52.namedImports, + moduleSpecifier = _ref52.moduleSpecifier; + + _classCallCheck(this, Import); + + this.type = 'Import'; + this.defaultBinding = defaultBinding; + this.namedImports = namedImports; + this.moduleSpecifier = moduleSpecifier; +}; + +var ImportNamespace = exports.ImportNamespace = function ImportNamespace(_ref53) { + var defaultBinding = _ref53.defaultBinding, + namespaceBinding = _ref53.namespaceBinding, + moduleSpecifier = _ref53.moduleSpecifier; + + _classCallCheck(this, ImportNamespace); + + this.type = 'ImportNamespace'; + this.defaultBinding = defaultBinding; + this.namespaceBinding = namespaceBinding; + this.moduleSpecifier = moduleSpecifier; +}; + +var ImportSpecifier = exports.ImportSpecifier = function ImportSpecifier(_ref54) { + var name = _ref54.name, + binding = _ref54.binding; + + _classCallCheck(this, ImportSpecifier); + + this.type = 'ImportSpecifier'; + this.name = name; + this.binding = binding; +}; + +var LabeledStatement = exports.LabeledStatement = function LabeledStatement(_ref55) { + var label = _ref55.label, + body = _ref55.body; + + _classCallCheck(this, LabeledStatement); + + this.type = 'LabeledStatement'; + this.label = label; + this.body = body; +}; + +var LiteralBooleanExpression = exports.LiteralBooleanExpression = function LiteralBooleanExpression(_ref56) { + var value = _ref56.value; + + _classCallCheck(this, LiteralBooleanExpression); + + this.type = 'LiteralBooleanExpression'; + this.value = value; +}; + +var LiteralInfinityExpression = exports.LiteralInfinityExpression = function LiteralInfinityExpression() { + _classCallCheck(this, LiteralInfinityExpression); + + this.type = 'LiteralInfinityExpression'; +}; + +var LiteralNullExpression = exports.LiteralNullExpression = function LiteralNullExpression() { + _classCallCheck(this, LiteralNullExpression); + + this.type = 'LiteralNullExpression'; +}; + +var LiteralNumericExpression = exports.LiteralNumericExpression = function LiteralNumericExpression(_ref57) { + var value = _ref57.value; + + _classCallCheck(this, LiteralNumericExpression); + + this.type = 'LiteralNumericExpression'; + this.value = value; +}; + +var LiteralRegExpExpression = exports.LiteralRegExpExpression = function LiteralRegExpExpression(_ref58) { + var pattern = _ref58.pattern, + global = _ref58.global, + ignoreCase = _ref58.ignoreCase, + multiLine = _ref58.multiLine, + dotAll = _ref58.dotAll, + unicode = _ref58.unicode, + sticky = _ref58.sticky; + + _classCallCheck(this, LiteralRegExpExpression); + + this.type = 'LiteralRegExpExpression'; + this.pattern = pattern; + this.global = global; + this.ignoreCase = ignoreCase; + this.multiLine = multiLine; + this.dotAll = dotAll; + this.unicode = unicode; + this.sticky = sticky; +}; + +var LiteralStringExpression = exports.LiteralStringExpression = function LiteralStringExpression(_ref59) { + var value = _ref59.value; + + _classCallCheck(this, LiteralStringExpression); + + this.type = 'LiteralStringExpression'; + this.value = value; +}; + +var Method = exports.Method = function Method(_ref60) { + var isAsync = _ref60.isAsync, + isGenerator = _ref60.isGenerator, + name = _ref60.name, + params = _ref60.params, + body = _ref60.body; + + _classCallCheck(this, Method); + + this.type = 'Method'; + this.isAsync = isAsync; + this.isGenerator = isGenerator; + this.name = name; + this.params = params; + this.body = body; +}; + +var Module = exports.Module = function Module(_ref61) { + var directives = _ref61.directives, + items = _ref61.items; + + _classCallCheck(this, Module); + + this.type = 'Module'; + this.directives = directives; + this.items = items; +}; + +var NewExpression = exports.NewExpression = function NewExpression(_ref62) { + var callee = _ref62.callee, + _arguments = _ref62.arguments; + + _classCallCheck(this, NewExpression); + + this.type = 'NewExpression'; + this.callee = callee; + this.arguments = _arguments; +}; + +var NewTargetExpression = exports.NewTargetExpression = function NewTargetExpression() { + _classCallCheck(this, NewTargetExpression); + + this.type = 'NewTargetExpression'; +}; + +var ObjectAssignmentTarget = exports.ObjectAssignmentTarget = function ObjectAssignmentTarget(_ref63) { + var properties = _ref63.properties, + rest = _ref63.rest; + + _classCallCheck(this, ObjectAssignmentTarget); + + this.type = 'ObjectAssignmentTarget'; + this.properties = properties; + this.rest = rest; +}; + +var ObjectBinding = exports.ObjectBinding = function ObjectBinding(_ref64) { + var properties = _ref64.properties, + rest = _ref64.rest; + + _classCallCheck(this, ObjectBinding); + + this.type = 'ObjectBinding'; + this.properties = properties; + this.rest = rest; +}; + +var ObjectExpression = exports.ObjectExpression = function ObjectExpression(_ref65) { + var properties = _ref65.properties; + + _classCallCheck(this, ObjectExpression); + + this.type = 'ObjectExpression'; + this.properties = properties; +}; + +var ReturnStatement = exports.ReturnStatement = function ReturnStatement(_ref66) { + var expression = _ref66.expression; + + _classCallCheck(this, ReturnStatement); + + this.type = 'ReturnStatement'; + this.expression = expression; +}; + +var Script = exports.Script = function Script(_ref67) { + var directives = _ref67.directives, + statements = _ref67.statements; + + _classCallCheck(this, Script); + + this.type = 'Script'; + this.directives = directives; + this.statements = statements; +}; + +var Setter = exports.Setter = function Setter(_ref68) { + var name = _ref68.name, + param = _ref68.param, + body = _ref68.body; + + _classCallCheck(this, Setter); + + this.type = 'Setter'; + this.name = name; + this.param = param; + this.body = body; +}; + +var ShorthandProperty = exports.ShorthandProperty = function ShorthandProperty(_ref69) { + var name = _ref69.name; + + _classCallCheck(this, ShorthandProperty); + + this.type = 'ShorthandProperty'; + this.name = name; +}; + +var SpreadElement = exports.SpreadElement = function SpreadElement(_ref70) { + var expression = _ref70.expression; + + _classCallCheck(this, SpreadElement); + + this.type = 'SpreadElement'; + this.expression = expression; +}; + +var SpreadProperty = exports.SpreadProperty = function SpreadProperty(_ref71) { + var expression = _ref71.expression; + + _classCallCheck(this, SpreadProperty); + + this.type = 'SpreadProperty'; + this.expression = expression; +}; + +var StaticMemberAssignmentTarget = exports.StaticMemberAssignmentTarget = function StaticMemberAssignmentTarget(_ref72) { + var object = _ref72.object, + property = _ref72.property; + + _classCallCheck(this, StaticMemberAssignmentTarget); + + this.type = 'StaticMemberAssignmentTarget'; + this.object = object; + this.property = property; +}; + +var StaticMemberExpression = exports.StaticMemberExpression = function StaticMemberExpression(_ref73) { + var object = _ref73.object, + property = _ref73.property; + + _classCallCheck(this, StaticMemberExpression); + + this.type = 'StaticMemberExpression'; + this.object = object; + this.property = property; +}; + +var StaticPropertyName = exports.StaticPropertyName = function StaticPropertyName(_ref74) { + var value = _ref74.value; + + _classCallCheck(this, StaticPropertyName); + + this.type = 'StaticPropertyName'; + this.value = value; +}; + +var Super = exports.Super = function Super() { + _classCallCheck(this, Super); + + this.type = 'Super'; +}; + +var SwitchCase = exports.SwitchCase = function SwitchCase(_ref75) { + var test = _ref75.test, + consequent = _ref75.consequent; + + _classCallCheck(this, SwitchCase); + + this.type = 'SwitchCase'; + this.test = test; + this.consequent = consequent; +}; + +var SwitchDefault = exports.SwitchDefault = function SwitchDefault(_ref76) { + var consequent = _ref76.consequent; + + _classCallCheck(this, SwitchDefault); + + this.type = 'SwitchDefault'; + this.consequent = consequent; +}; + +var SwitchStatement = exports.SwitchStatement = function SwitchStatement(_ref77) { + var discriminant = _ref77.discriminant, + cases = _ref77.cases; + + _classCallCheck(this, SwitchStatement); + + this.type = 'SwitchStatement'; + this.discriminant = discriminant; + this.cases = cases; +}; + +var SwitchStatementWithDefault = exports.SwitchStatementWithDefault = function SwitchStatementWithDefault(_ref78) { + var discriminant = _ref78.discriminant, + preDefaultCases = _ref78.preDefaultCases, + defaultCase = _ref78.defaultCase, + postDefaultCases = _ref78.postDefaultCases; + + _classCallCheck(this, SwitchStatementWithDefault); + + this.type = 'SwitchStatementWithDefault'; + this.discriminant = discriminant; + this.preDefaultCases = preDefaultCases; + this.defaultCase = defaultCase; + this.postDefaultCases = postDefaultCases; +}; + +var TemplateElement = exports.TemplateElement = function TemplateElement(_ref79) { + var rawValue = _ref79.rawValue; + + _classCallCheck(this, TemplateElement); + + this.type = 'TemplateElement'; + this.rawValue = rawValue; +}; + +var TemplateExpression = exports.TemplateExpression = function TemplateExpression(_ref80) { + var tag = _ref80.tag, + elements = _ref80.elements; + + _classCallCheck(this, TemplateExpression); + + this.type = 'TemplateExpression'; + this.tag = tag; + this.elements = elements; +}; + +var ThisExpression = exports.ThisExpression = function ThisExpression() { + _classCallCheck(this, ThisExpression); + + this.type = 'ThisExpression'; +}; + +var ThrowStatement = exports.ThrowStatement = function ThrowStatement(_ref81) { + var expression = _ref81.expression; + + _classCallCheck(this, ThrowStatement); + + this.type = 'ThrowStatement'; + this.expression = expression; +}; + +var TryCatchStatement = exports.TryCatchStatement = function TryCatchStatement(_ref82) { + var body = _ref82.body, + catchClause = _ref82.catchClause; + + _classCallCheck(this, TryCatchStatement); + + this.type = 'TryCatchStatement'; + this.body = body; + this.catchClause = catchClause; +}; + +var TryFinallyStatement = exports.TryFinallyStatement = function TryFinallyStatement(_ref83) { + var body = _ref83.body, + catchClause = _ref83.catchClause, + finalizer = _ref83.finalizer; + + _classCallCheck(this, TryFinallyStatement); + + this.type = 'TryFinallyStatement'; + this.body = body; + this.catchClause = catchClause; + this.finalizer = finalizer; +}; + +var UnaryExpression = exports.UnaryExpression = function UnaryExpression(_ref84) { + var operator = _ref84.operator, + operand = _ref84.operand; + + _classCallCheck(this, UnaryExpression); + + this.type = 'UnaryExpression'; + this.operator = operator; + this.operand = operand; +}; + +var UpdateExpression = exports.UpdateExpression = function UpdateExpression(_ref85) { + var isPrefix = _ref85.isPrefix, + operator = _ref85.operator, + operand = _ref85.operand; + + _classCallCheck(this, UpdateExpression); + + this.type = 'UpdateExpression'; + this.isPrefix = isPrefix; + this.operator = operator; + this.operand = operand; +}; + +var VariableDeclaration = exports.VariableDeclaration = function VariableDeclaration(_ref86) { + var kind = _ref86.kind, + declarators = _ref86.declarators; + + _classCallCheck(this, VariableDeclaration); + + this.type = 'VariableDeclaration'; + this.kind = kind; + this.declarators = declarators; +}; + +var VariableDeclarationStatement = exports.VariableDeclarationStatement = function VariableDeclarationStatement(_ref87) { + var declaration = _ref87.declaration; + + _classCallCheck(this, VariableDeclarationStatement); + + this.type = 'VariableDeclarationStatement'; + this.declaration = declaration; +}; + +var VariableDeclarator = exports.VariableDeclarator = function VariableDeclarator(_ref88) { + var binding = _ref88.binding, + init = _ref88.init; + + _classCallCheck(this, VariableDeclarator); + + this.type = 'VariableDeclarator'; + this.binding = binding; + this.init = init; +}; + +var WhileStatement = exports.WhileStatement = function WhileStatement(_ref89) { + var test = _ref89.test, + body = _ref89.body; + + _classCallCheck(this, WhileStatement); + + this.type = 'WhileStatement'; + this.test = test; + this.body = body; +}; + +var WithStatement = exports.WithStatement = function WithStatement(_ref90) { + var object = _ref90.object, + body = _ref90.body; + + _classCallCheck(this, WithStatement); + + this.type = 'WithStatement'; + this.object = object; + this.body = body; +}; + +var YieldExpression = exports.YieldExpression = function YieldExpression(_ref91) { + var expression = _ref91.expression; + + _classCallCheck(this, YieldExpression); + + this.type = 'YieldExpression'; + this.expression = expression; +}; + +var YieldGeneratorExpression = exports.YieldGeneratorExpression = function YieldGeneratorExpression(_ref92) { + var expression = _ref92.expression; + + _classCallCheck(this, YieldGeneratorExpression); + + this.type = 'YieldGeneratorExpression'; + this.expression = expression; +}; +}); + +var __pika_web_default_export_for_treeshaking__ = /*@__PURE__*/getDefaultExportFromCjs(dist); + +export { __pika_web_default_export_for_treeshaking__ as _, dist as d }; diff --git a/docs/_snowpack/pkg/common/index-04edb6a1.js b/docs/_snowpack/pkg/common/index-67cfdec9.js similarity index 75% rename from docs/_snowpack/pkg/common/index-04edb6a1.js rename to docs/_snowpack/pkg/common/index-67cfdec9.js index 9993b955..4b51ea73 100644 --- a/docs/_snowpack/pkg/common/index-04edb6a1.js +++ b/docs/_snowpack/pkg/common/index-67cfdec9.js @@ -1,93 +1,5 @@ import { c as createCommonjsModule } from './_commonjsHelpers-8c19dec8.js'; - -/* -object-assign -(c) Sindre Sorhus -@license MIT -*/ -/* eslint-disable no-unused-vars */ -var getOwnPropertySymbols = Object.getOwnPropertySymbols; -var hasOwnProperty = Object.prototype.hasOwnProperty; -var propIsEnumerable = Object.prototype.propertyIsEnumerable; - -function toObject(val) { - if (val === null || val === undefined) { - throw new TypeError('Object.assign cannot be called with null or undefined'); - } - - return Object(val); -} - -function shouldUseNative() { - try { - if (!Object.assign) { - return false; - } - - // Detect buggy property enumeration order in older V8 versions. - - // https://bugs.chromium.org/p/v8/issues/detail?id=4118 - var test1 = new String('abc'); // eslint-disable-line no-new-wrappers - test1[5] = 'de'; - if (Object.getOwnPropertyNames(test1)[0] === '5') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test2 = {}; - for (var i = 0; i < 10; i++) { - test2['_' + String.fromCharCode(i)] = i; - } - var order2 = Object.getOwnPropertyNames(test2).map(function (n) { - return test2[n]; - }); - if (order2.join('') !== '0123456789') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test3 = {}; - 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { - test3[letter] = letter; - }); - if (Object.keys(Object.assign({}, test3)).join('') !== - 'abcdefghijklmnopqrst') { - return false; - } - - return true; - } catch (err) { - // We don't expect any of the above to throw, but better to be safe. - return false; - } -} - -var objectAssign = shouldUseNative() ? Object.assign : function (target, source) { - var from; - var to = toObject(target); - var symbols; - - for (var s = 1; s < arguments.length; s++) { - from = Object(arguments[s]); - - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; - } - } - - if (getOwnPropertySymbols) { - symbols = getOwnPropertySymbols(from); - for (var i = 0; i < symbols.length; i++) { - if (propIsEnumerable.call(from, symbols[i])) { - to[symbols[i]] = from[symbols[i]]; - } - } - } - } - - return to; -}; +import { o as objectAssign } from './index-d01087d6.js'; var react_production_min = createCommonjsModule(function (module, exports) { var n=60103,p=60106;exports.Fragment=60107;exports.StrictMode=60108;exports.Profiler=60114;var q=60109,r=60110,t=60112;exports.Suspense=60113;var u=60115,v=60116; @@ -114,4 +26,4 @@ var react = createCommonjsModule(function (module) { } }); -export { objectAssign as o, react as r }; +export { react as r }; diff --git a/docs/_snowpack/pkg/common/index-d01087d6.js b/docs/_snowpack/pkg/common/index-d01087d6.js new file mode 100644 index 00000000..01ea043c --- /dev/null +++ b/docs/_snowpack/pkg/common/index-d01087d6.js @@ -0,0 +1,90 @@ +/* +object-assign +(c) Sindre Sorhus +@license MIT +*/ +/* eslint-disable no-unused-vars */ +var getOwnPropertySymbols = Object.getOwnPropertySymbols; +var hasOwnProperty = Object.prototype.hasOwnProperty; +var propIsEnumerable = Object.prototype.propertyIsEnumerable; + +function toObject(val) { + if (val === null || val === undefined) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } + + return Object(val); +} + +function shouldUseNative() { + try { + if (!Object.assign) { + return false; + } + + // Detect buggy property enumeration order in older V8 versions. + + // https://bugs.chromium.org/p/v8/issues/detail?id=4118 + var test1 = new String('abc'); // eslint-disable-line no-new-wrappers + test1[5] = 'de'; + if (Object.getOwnPropertyNames(test1)[0] === '5') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test2 = {}; + for (var i = 0; i < 10; i++) { + test2['_' + String.fromCharCode(i)] = i; + } + var order2 = Object.getOwnPropertyNames(test2).map(function (n) { + return test2[n]; + }); + if (order2.join('') !== '0123456789') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test3 = {}; + 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { + test3[letter] = letter; + }); + if (Object.keys(Object.assign({}, test3)).join('') !== + 'abcdefghijklmnopqrst') { + return false; + } + + return true; + } catch (err) { + // We don't expect any of the above to throw, but better to be safe. + return false; + } +} + +var objectAssign = shouldUseNative() ? Object.assign : function (target, source) { + var from; + var to = toObject(target); + var symbols; + + for (var s = 1; s < arguments.length; s++) { + from = Object(arguments[s]); + + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + + if (getOwnPropertySymbols) { + symbols = getOwnPropertySymbols(from); + for (var i = 0; i < symbols.length; i++) { + if (propIsEnumerable.call(from, symbols[i])) { + to[symbols[i]] = from[symbols[i]]; + } + } + } + } + + return to; +}; + +export { objectAssign as o }; diff --git a/docs/_snowpack/pkg/estraverse.js b/docs/_snowpack/pkg/estraverse.js new file mode 100644 index 00000000..82acb8b0 --- /dev/null +++ b/docs/_snowpack/pkg/estraverse.js @@ -0,0 +1,810 @@ +import { c as createCommonjsModule } from './common/_commonjsHelpers-8c19dec8.js'; + +var estraverse = createCommonjsModule(function (module, exports) { +/* + Copyright (C) 2012-2013 Yusuke Suzuki + Copyright (C) 2012 Ariya Hidayat + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/*jslint vars:false, bitwise:true*/ +/*jshint indent:4*/ +/*global exports:true*/ +(function clone(exports) { + + var Syntax, + VisitorOption, + VisitorKeys, + BREAK, + SKIP, + REMOVE; + + function deepCopy(obj) { + var ret = {}, key, val; + for (key in obj) { + if (obj.hasOwnProperty(key)) { + val = obj[key]; + if (typeof val === 'object' && val !== null) { + ret[key] = deepCopy(val); + } else { + ret[key] = val; + } + } + } + return ret; + } + + // based on LLVM libc++ upper_bound / lower_bound + // MIT License + + function upperBound(array, func) { + var diff, len, i, current; + + len = array.length; + i = 0; + + while (len) { + diff = len >>> 1; + current = i + diff; + if (func(array[current])) { + len = diff; + } else { + i = current + 1; + len -= diff + 1; + } + } + return i; + } + + Syntax = { + AssignmentExpression: 'AssignmentExpression', + AssignmentPattern: 'AssignmentPattern', + ArrayExpression: 'ArrayExpression', + ArrayPattern: 'ArrayPattern', + ArrowFunctionExpression: 'ArrowFunctionExpression', + AwaitExpression: 'AwaitExpression', // CAUTION: It's deferred to ES7. + BlockStatement: 'BlockStatement', + BinaryExpression: 'BinaryExpression', + BreakStatement: 'BreakStatement', + CallExpression: 'CallExpression', + CatchClause: 'CatchClause', + ChainExpression: 'ChainExpression', + ClassBody: 'ClassBody', + ClassDeclaration: 'ClassDeclaration', + ClassExpression: 'ClassExpression', + ComprehensionBlock: 'ComprehensionBlock', // CAUTION: It's deferred to ES7. + ComprehensionExpression: 'ComprehensionExpression', // CAUTION: It's deferred to ES7. + ConditionalExpression: 'ConditionalExpression', + ContinueStatement: 'ContinueStatement', + DebuggerStatement: 'DebuggerStatement', + DirectiveStatement: 'DirectiveStatement', + DoWhileStatement: 'DoWhileStatement', + EmptyStatement: 'EmptyStatement', + ExportAllDeclaration: 'ExportAllDeclaration', + ExportDefaultDeclaration: 'ExportDefaultDeclaration', + ExportNamedDeclaration: 'ExportNamedDeclaration', + ExportSpecifier: 'ExportSpecifier', + ExpressionStatement: 'ExpressionStatement', + ForStatement: 'ForStatement', + ForInStatement: 'ForInStatement', + ForOfStatement: 'ForOfStatement', + FunctionDeclaration: 'FunctionDeclaration', + FunctionExpression: 'FunctionExpression', + GeneratorExpression: 'GeneratorExpression', // CAUTION: It's deferred to ES7. + Identifier: 'Identifier', + IfStatement: 'IfStatement', + ImportExpression: 'ImportExpression', + ImportDeclaration: 'ImportDeclaration', + ImportDefaultSpecifier: 'ImportDefaultSpecifier', + ImportNamespaceSpecifier: 'ImportNamespaceSpecifier', + ImportSpecifier: 'ImportSpecifier', + Literal: 'Literal', + LabeledStatement: 'LabeledStatement', + LogicalExpression: 'LogicalExpression', + MemberExpression: 'MemberExpression', + MetaProperty: 'MetaProperty', + MethodDefinition: 'MethodDefinition', + ModuleSpecifier: 'ModuleSpecifier', + NewExpression: 'NewExpression', + ObjectExpression: 'ObjectExpression', + ObjectPattern: 'ObjectPattern', + PrivateIdentifier: 'PrivateIdentifier', + Program: 'Program', + Property: 'Property', + PropertyDefinition: 'PropertyDefinition', + RestElement: 'RestElement', + ReturnStatement: 'ReturnStatement', + SequenceExpression: 'SequenceExpression', + SpreadElement: 'SpreadElement', + Super: 'Super', + SwitchStatement: 'SwitchStatement', + SwitchCase: 'SwitchCase', + TaggedTemplateExpression: 'TaggedTemplateExpression', + TemplateElement: 'TemplateElement', + TemplateLiteral: 'TemplateLiteral', + ThisExpression: 'ThisExpression', + ThrowStatement: 'ThrowStatement', + TryStatement: 'TryStatement', + UnaryExpression: 'UnaryExpression', + UpdateExpression: 'UpdateExpression', + VariableDeclaration: 'VariableDeclaration', + VariableDeclarator: 'VariableDeclarator', + WhileStatement: 'WhileStatement', + WithStatement: 'WithStatement', + YieldExpression: 'YieldExpression' + }; + + VisitorKeys = { + AssignmentExpression: ['left', 'right'], + AssignmentPattern: ['left', 'right'], + ArrayExpression: ['elements'], + ArrayPattern: ['elements'], + ArrowFunctionExpression: ['params', 'body'], + AwaitExpression: ['argument'], // CAUTION: It's deferred to ES7. + BlockStatement: ['body'], + BinaryExpression: ['left', 'right'], + BreakStatement: ['label'], + CallExpression: ['callee', 'arguments'], + CatchClause: ['param', 'body'], + ChainExpression: ['expression'], + ClassBody: ['body'], + ClassDeclaration: ['id', 'superClass', 'body'], + ClassExpression: ['id', 'superClass', 'body'], + ComprehensionBlock: ['left', 'right'], // CAUTION: It's deferred to ES7. + ComprehensionExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7. + ConditionalExpression: ['test', 'consequent', 'alternate'], + ContinueStatement: ['label'], + DebuggerStatement: [], + DirectiveStatement: [], + DoWhileStatement: ['body', 'test'], + EmptyStatement: [], + ExportAllDeclaration: ['source'], + ExportDefaultDeclaration: ['declaration'], + ExportNamedDeclaration: ['declaration', 'specifiers', 'source'], + ExportSpecifier: ['exported', 'local'], + ExpressionStatement: ['expression'], + ForStatement: ['init', 'test', 'update', 'body'], + ForInStatement: ['left', 'right', 'body'], + ForOfStatement: ['left', 'right', 'body'], + FunctionDeclaration: ['id', 'params', 'body'], + FunctionExpression: ['id', 'params', 'body'], + GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7. + Identifier: [], + IfStatement: ['test', 'consequent', 'alternate'], + ImportExpression: ['source'], + ImportDeclaration: ['specifiers', 'source'], + ImportDefaultSpecifier: ['local'], + ImportNamespaceSpecifier: ['local'], + ImportSpecifier: ['imported', 'local'], + Literal: [], + LabeledStatement: ['label', 'body'], + LogicalExpression: ['left', 'right'], + MemberExpression: ['object', 'property'], + MetaProperty: ['meta', 'property'], + MethodDefinition: ['key', 'value'], + ModuleSpecifier: [], + NewExpression: ['callee', 'arguments'], + ObjectExpression: ['properties'], + ObjectPattern: ['properties'], + PrivateIdentifier: [], + Program: ['body'], + Property: ['key', 'value'], + PropertyDefinition: ['key', 'value'], + RestElement: [ 'argument' ], + ReturnStatement: ['argument'], + SequenceExpression: ['expressions'], + SpreadElement: ['argument'], + Super: [], + SwitchStatement: ['discriminant', 'cases'], + SwitchCase: ['test', 'consequent'], + TaggedTemplateExpression: ['tag', 'quasi'], + TemplateElement: [], + TemplateLiteral: ['quasis', 'expressions'], + ThisExpression: [], + ThrowStatement: ['argument'], + TryStatement: ['block', 'handler', 'finalizer'], + UnaryExpression: ['argument'], + UpdateExpression: ['argument'], + VariableDeclaration: ['declarations'], + VariableDeclarator: ['id', 'init'], + WhileStatement: ['test', 'body'], + WithStatement: ['object', 'body'], + YieldExpression: ['argument'] + }; + + // unique id + BREAK = {}; + SKIP = {}; + REMOVE = {}; + + VisitorOption = { + Break: BREAK, + Skip: SKIP, + Remove: REMOVE + }; + + function Reference(parent, key) { + this.parent = parent; + this.key = key; + } + + Reference.prototype.replace = function replace(node) { + this.parent[this.key] = node; + }; + + Reference.prototype.remove = function remove() { + if (Array.isArray(this.parent)) { + this.parent.splice(this.key, 1); + return true; + } else { + this.replace(null); + return false; + } + }; + + function Element(node, path, wrap, ref) { + this.node = node; + this.path = path; + this.wrap = wrap; + this.ref = ref; + } + + function Controller() { } + + // API: + // return property path array from root to current node + Controller.prototype.path = function path() { + var i, iz, j, jz, result, element; + + function addToPath(result, path) { + if (Array.isArray(path)) { + for (j = 0, jz = path.length; j < jz; ++j) { + result.push(path[j]); + } + } else { + result.push(path); + } + } + + // root node + if (!this.__current.path) { + return null; + } + + // first node is sentinel, second node is root element + result = []; + for (i = 2, iz = this.__leavelist.length; i < iz; ++i) { + element = this.__leavelist[i]; + addToPath(result, element.path); + } + addToPath(result, this.__current.path); + return result; + }; + + // API: + // return type of current node + Controller.prototype.type = function () { + var node = this.current(); + return node.type || this.__current.wrap; + }; + + // API: + // return array of parent elements + Controller.prototype.parents = function parents() { + var i, iz, result; + + // first node is sentinel + result = []; + for (i = 1, iz = this.__leavelist.length; i < iz; ++i) { + result.push(this.__leavelist[i].node); + } + + return result; + }; + + // API: + // return current node + Controller.prototype.current = function current() { + return this.__current.node; + }; + + Controller.prototype.__execute = function __execute(callback, element) { + var previous, result; + + result = undefined; + + previous = this.__current; + this.__current = element; + this.__state = null; + if (callback) { + result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node); + } + this.__current = previous; + + return result; + }; + + // API: + // notify control skip / break + Controller.prototype.notify = function notify(flag) { + this.__state = flag; + }; + + // API: + // skip child nodes of current node + Controller.prototype.skip = function () { + this.notify(SKIP); + }; + + // API: + // break traversals + Controller.prototype['break'] = function () { + this.notify(BREAK); + }; + + // API: + // remove node + Controller.prototype.remove = function () { + this.notify(REMOVE); + }; + + Controller.prototype.__initialize = function(root, visitor) { + this.visitor = visitor; + this.root = root; + this.__worklist = []; + this.__leavelist = []; + this.__current = null; + this.__state = null; + this.__fallback = null; + if (visitor.fallback === 'iteration') { + this.__fallback = Object.keys; + } else if (typeof visitor.fallback === 'function') { + this.__fallback = visitor.fallback; + } + + this.__keys = VisitorKeys; + if (visitor.keys) { + this.__keys = Object.assign(Object.create(this.__keys), visitor.keys); + } + }; + + function isNode(node) { + if (node == null) { + return false; + } + return typeof node === 'object' && typeof node.type === 'string'; + } + + function isProperty(nodeType, key) { + return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key; + } + + function candidateExistsInLeaveList(leavelist, candidate) { + for (var i = leavelist.length - 1; i >= 0; --i) { + if (leavelist[i].node === candidate) { + return true; + } + } + return false; + } + + Controller.prototype.traverse = function traverse(root, visitor) { + var worklist, + leavelist, + element, + node, + nodeType, + ret, + key, + current, + current2, + candidates, + candidate, + sentinel; + + this.__initialize(root, visitor); + + sentinel = {}; + + // reference + worklist = this.__worklist; + leavelist = this.__leavelist; + + // initialize + worklist.push(new Element(root, null, null, null)); + leavelist.push(new Element(null, null, null, null)); + + while (worklist.length) { + element = worklist.pop(); + + if (element === sentinel) { + element = leavelist.pop(); + + ret = this.__execute(visitor.leave, element); + + if (this.__state === BREAK || ret === BREAK) { + return; + } + continue; + } + + if (element.node) { + + ret = this.__execute(visitor.enter, element); + + if (this.__state === BREAK || ret === BREAK) { + return; + } + + worklist.push(sentinel); + leavelist.push(element); + + if (this.__state === SKIP || ret === SKIP) { + continue; + } + + node = element.node; + nodeType = node.type || element.wrap; + candidates = this.__keys[nodeType]; + if (!candidates) { + if (this.__fallback) { + candidates = this.__fallback(node); + } else { + throw new Error('Unknown node type ' + nodeType + '.'); + } + } + + current = candidates.length; + while ((current -= 1) >= 0) { + key = candidates[current]; + candidate = node[key]; + if (!candidate) { + continue; + } + + if (Array.isArray(candidate)) { + current2 = candidate.length; + while ((current2 -= 1) >= 0) { + if (!candidate[current2]) { + continue; + } + + if (candidateExistsInLeaveList(leavelist, candidate[current2])) { + continue; + } + + if (isProperty(nodeType, candidates[current])) { + element = new Element(candidate[current2], [key, current2], 'Property', null); + } else if (isNode(candidate[current2])) { + element = new Element(candidate[current2], [key, current2], null, null); + } else { + continue; + } + worklist.push(element); + } + } else if (isNode(candidate)) { + if (candidateExistsInLeaveList(leavelist, candidate)) { + continue; + } + + worklist.push(new Element(candidate, key, null, null)); + } + } + } + } + }; + + Controller.prototype.replace = function replace(root, visitor) { + var worklist, + leavelist, + node, + nodeType, + target, + element, + current, + current2, + candidates, + candidate, + sentinel, + outer, + key; + + function removeElem(element) { + var i, + key, + nextElem, + parent; + + if (element.ref.remove()) { + // When the reference is an element of an array. + key = element.ref.key; + parent = element.ref.parent; + + // If removed from array, then decrease following items' keys. + i = worklist.length; + while (i--) { + nextElem = worklist[i]; + if (nextElem.ref && nextElem.ref.parent === parent) { + if (nextElem.ref.key < key) { + break; + } + --nextElem.ref.key; + } + } + } + } + + this.__initialize(root, visitor); + + sentinel = {}; + + // reference + worklist = this.__worklist; + leavelist = this.__leavelist; + + // initialize + outer = { + root: root + }; + element = new Element(root, null, null, new Reference(outer, 'root')); + worklist.push(element); + leavelist.push(element); + + while (worklist.length) { + element = worklist.pop(); + + if (element === sentinel) { + element = leavelist.pop(); + + target = this.__execute(visitor.leave, element); + + // node may be replaced with null, + // so distinguish between undefined and null in this place + if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) { + // replace + element.ref.replace(target); + } + + if (this.__state === REMOVE || target === REMOVE) { + removeElem(element); + } + + if (this.__state === BREAK || target === BREAK) { + return outer.root; + } + continue; + } + + target = this.__execute(visitor.enter, element); + + // node may be replaced with null, + // so distinguish between undefined and null in this place + if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) { + // replace + element.ref.replace(target); + element.node = target; + } + + if (this.__state === REMOVE || target === REMOVE) { + removeElem(element); + element.node = null; + } + + if (this.__state === BREAK || target === BREAK) { + return outer.root; + } + + // node may be null + node = element.node; + if (!node) { + continue; + } + + worklist.push(sentinel); + leavelist.push(element); + + if (this.__state === SKIP || target === SKIP) { + continue; + } + + nodeType = node.type || element.wrap; + candidates = this.__keys[nodeType]; + if (!candidates) { + if (this.__fallback) { + candidates = this.__fallback(node); + } else { + throw new Error('Unknown node type ' + nodeType + '.'); + } + } + + current = candidates.length; + while ((current -= 1) >= 0) { + key = candidates[current]; + candidate = node[key]; + if (!candidate) { + continue; + } + + if (Array.isArray(candidate)) { + current2 = candidate.length; + while ((current2 -= 1) >= 0) { + if (!candidate[current2]) { + continue; + } + if (isProperty(nodeType, candidates[current])) { + element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2)); + } else if (isNode(candidate[current2])) { + element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2)); + } else { + continue; + } + worklist.push(element); + } + } else if (isNode(candidate)) { + worklist.push(new Element(candidate, key, null, new Reference(node, key))); + } + } + } + + return outer.root; + }; + + function traverse(root, visitor) { + var controller = new Controller(); + return controller.traverse(root, visitor); + } + + function replace(root, visitor) { + var controller = new Controller(); + return controller.replace(root, visitor); + } + + function extendCommentRange(comment, tokens) { + var target; + + target = upperBound(tokens, function search(token) { + return token.range[0] > comment.range[0]; + }); + + comment.extendedRange = [comment.range[0], comment.range[1]]; + + if (target !== tokens.length) { + comment.extendedRange[1] = tokens[target].range[0]; + } + + target -= 1; + if (target >= 0) { + comment.extendedRange[0] = tokens[target].range[1]; + } + + return comment; + } + + function attachComments(tree, providedComments, tokens) { + // At first, we should calculate extended comment ranges. + var comments = [], comment, len, i, cursor; + + if (!tree.range) { + throw new Error('attachComments needs range information'); + } + + // tokens array is empty, we attach comments to tree as 'leadingComments' + if (!tokens.length) { + if (providedComments.length) { + for (i = 0, len = providedComments.length; i < len; i += 1) { + comment = deepCopy(providedComments[i]); + comment.extendedRange = [0, tree.range[0]]; + comments.push(comment); + } + tree.leadingComments = comments; + } + return tree; + } + + for (i = 0, len = providedComments.length; i < len; i += 1) { + comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens)); + } + + // This is based on John Freeman's implementation. + cursor = 0; + traverse(tree, { + enter: function (node) { + var comment; + + while (cursor < comments.length) { + comment = comments[cursor]; + if (comment.extendedRange[1] > node.range[0]) { + break; + } + + if (comment.extendedRange[1] === node.range[0]) { + if (!node.leadingComments) { + node.leadingComments = []; + } + node.leadingComments.push(comment); + comments.splice(cursor, 1); + } else { + cursor += 1; + } + } + + // already out of owned node + if (cursor === comments.length) { + return VisitorOption.Break; + } + + if (comments[cursor].extendedRange[0] > node.range[1]) { + return VisitorOption.Skip; + } + } + }); + + cursor = 0; + traverse(tree, { + leave: function (node) { + var comment; + + while (cursor < comments.length) { + comment = comments[cursor]; + if (node.range[1] < comment.extendedRange[0]) { + break; + } + + if (node.range[1] === comment.extendedRange[0]) { + if (!node.trailingComments) { + node.trailingComments = []; + } + node.trailingComments.push(comment); + comments.splice(cursor, 1); + } else { + cursor += 1; + } + } + + // already out of owned node + if (cursor === comments.length) { + return VisitorOption.Break; + } + + if (comments[cursor].extendedRange[0] > node.range[1]) { + return VisitorOption.Skip; + } + } + }); + + return tree; + } + + exports.Syntax = Syntax; + exports.traverse = traverse; + exports.replace = replace; + exports.attachComments = attachComments; + exports.VisitorKeys = VisitorKeys; + exports.VisitorOption = VisitorOption; + exports.Controller = Controller; + exports.cloneEnvironment = function () { return clone({}); }; + + return exports; +}(exports)); +/* vim: set sw=4 ts=4 et tw=80 : */ +}); + +export default estraverse; diff --git a/docs/_snowpack/pkg/import-map.json b/docs/_snowpack/pkg/import-map.json index 314df7d0..a7efb5d4 100644 --- a/docs/_snowpack/pkg/import-map.json +++ b/docs/_snowpack/pkg/import-map.json @@ -5,10 +5,16 @@ "codemirror/mode/javascript/javascript.js": "./codemirror/mode/javascript/javascript.js", "codemirror/mode/pegjs/pegjs.js": "./codemirror/mode/pegjs/pegjs.js", "codemirror/theme/material.css": "./codemirror/theme/material.css", + "estraverse": "./estraverse.js", "fraction.js": "./fractionjs.js", + "multimap": "./multimap.js", "react": "./react.js", "react-codemirror2": "./react-codemirror2.js", "react-dom": "./react-dom.js", + "shift-ast": "./shift-ast.js", + "shift-codegen": "./shift-codegen.js", + "shift-regexp-acceptor": "./shift-regexp-acceptor.js", + "shift-spec": "./shift-spec.js", "tone": "./tone.js" } } \ No newline at end of file diff --git a/docs/_snowpack/pkg/multimap.js b/docs/_snowpack/pkg/multimap.js new file mode 100644 index 00000000..ec0d90bb --- /dev/null +++ b/docs/_snowpack/pkg/multimap.js @@ -0,0 +1,229 @@ +import { c as createCommonjsModule } from './common/_commonjsHelpers-8c19dec8.js'; + +var multimap = createCommonjsModule(function (module, exports) { + +/* global module, define */ + +function mapEach(map, operation){ + var keys = map.keys(); + var next; + while(!(next = keys.next()).done) { + operation(map.get(next.value), next.value, map); + } +} + +var Multimap = (function() { + var mapCtor; + if (typeof Map !== 'undefined') { + mapCtor = Map; + + if (!Map.prototype.keys) { + Map.prototype.keys = function() { + var keys = []; + this.forEach(function(item, key) { + keys.push(key); + }); + return keys; + }; + } + } + + function Multimap(iterable) { + var self = this; + + self._map = mapCtor; + + if (Multimap.Map) { + self._map = Multimap.Map; + } + + self._ = self._map ? new self._map() : {}; + + if (iterable) { + iterable.forEach(function(i) { + self.set(i[0], i[1]); + }); + } + } + + /** + * @param {Object} key + * @return {Array} An array of values, undefined if no such a key; + */ + Multimap.prototype.get = function(key) { + return this._map ? this._.get(key) : this._[key]; + }; + + /** + * @param {Object} key + * @param {Object} val... + */ + Multimap.prototype.set = function(key, val) { + var args = Array.prototype.slice.call(arguments); + + key = args.shift(); + + var entry = this.get(key); + if (!entry) { + entry = []; + if (this._map) + this._.set(key, entry); + else + this._[key] = entry; + } + + Array.prototype.push.apply(entry, args); + return this; + }; + + /** + * @param {Object} key + * @param {Object=} val + * @return {boolean} true if any thing changed + */ + Multimap.prototype.delete = function(key, val) { + if (!this.has(key)) + return false; + + if (arguments.length == 1) { + this._map ? (this._.delete(key)) : (delete this._[key]); + return true; + } else { + var entry = this.get(key); + var idx = entry.indexOf(val); + if (idx != -1) { + entry.splice(idx, 1); + return true; + } + } + + return false; + }; + + /** + * @param {Object} key + * @param {Object=} val + * @return {boolean} whether the map contains 'key' or 'key=>val' pair + */ + Multimap.prototype.has = function(key, val) { + var hasKey = this._map ? this._.has(key) : this._.hasOwnProperty(key); + + if (arguments.length == 1 || !hasKey) + return hasKey; + + var entry = this.get(key) || []; + return entry.indexOf(val) != -1; + }; + + + /** + * @return {Array} all the keys in the map + */ + Multimap.prototype.keys = function() { + if (this._map) + return makeIterator(this._.keys()); + + return makeIterator(Object.keys(this._)); + }; + + /** + * @return {Array} all the values in the map + */ + Multimap.prototype.values = function() { + var vals = []; + this.forEachEntry(function(entry) { + Array.prototype.push.apply(vals, entry); + }); + + return makeIterator(vals); + }; + + /** + * + */ + Multimap.prototype.forEachEntry = function(iter) { + mapEach(this, iter); + }; + + Multimap.prototype.forEach = function(iter) { + var self = this; + self.forEachEntry(function(entry, key) { + entry.forEach(function(item) { + iter(item, key, self); + }); + }); + }; + + + Multimap.prototype.clear = function() { + if (this._map) { + this._.clear(); + } else { + this._ = {}; + } + }; + + Object.defineProperty( + Multimap.prototype, + "size", { + configurable: false, + enumerable: true, + get: function() { + var total = 0; + + mapEach(this, function(value){ + total += value.length; + }); + + return total; + } + }); + + Object.defineProperty( + Multimap.prototype, + "count", { + configurable: false, + enumerable: true, + get: function() { + return this._.size; + } + }); + + var safariNext; + + try{ + safariNext = new Function('iterator', 'makeIterator', 'var keysArray = []; for(var key of iterator){keysArray.push(key);} return makeIterator(keysArray).next;'); + }catch(error){ + // for of not implemented; + } + + function makeIterator(iterator){ + if(Array.isArray(iterator)){ + var nextIndex = 0; + + return { + next: function(){ + return nextIndex < iterator.length ? + {value: iterator[nextIndex++], done: false} : + {done: true}; + } + }; + } + + // Only an issue in safari + if(!iterator.next && safariNext){ + iterator.next = safariNext(iterator, makeIterator); + } + + return iterator; + } + + return Multimap; +})(); + + +if( module && module.exports) + module.exports = Multimap; +}); + +export default multimap; diff --git a/docs/_snowpack/pkg/react-codemirror2.js b/docs/_snowpack/pkg/react-codemirror2.js index 9b35323d..eb301641 100644 --- a/docs/_snowpack/pkg/react-codemirror2.js +++ b/docs/_snowpack/pkg/react-codemirror2.js @@ -1,6 +1,7 @@ import { c as createCommonjsModule, a as commonjsGlobal } from './common/_commonjsHelpers-8c19dec8.js'; -import { r as react } from './common/index-04edb6a1.js'; +import { r as react } from './common/index-67cfdec9.js'; import { c as codemirror } from './common/codemirror-d650d44d.js'; +import './common/index-d01087d6.js'; var reactCodemirror2 = createCommonjsModule(function (module, exports) { diff --git a/docs/_snowpack/pkg/react-dom.js b/docs/_snowpack/pkg/react-dom.js index 2e6bea46..cb70c7d3 100644 --- a/docs/_snowpack/pkg/react-dom.js +++ b/docs/_snowpack/pkg/react-dom.js @@ -1,5 +1,6 @@ import { c as createCommonjsModule } from './common/_commonjsHelpers-8c19dec8.js'; -import { r as react, o as objectAssign } from './common/index-04edb6a1.js'; +import { r as react } from './common/index-67cfdec9.js'; +import { o as objectAssign } from './common/index-d01087d6.js'; var scheduler_production_min = createCommonjsModule(function (module, exports) { var f,g,h,k;if("object"===typeof performance&&"function"===typeof performance.now){var l=performance;exports.unstable_now=function(){return l.now()};}else {var p=Date,q=p.now();exports.unstable_now=function(){return p.now()-q};} diff --git a/docs/_snowpack/pkg/react.js b/docs/_snowpack/pkg/react.js index 45db9969..564097ea 100644 --- a/docs/_snowpack/pkg/react.js +++ b/docs/_snowpack/pkg/react.js @@ -1,6 +1,7 @@ -import { r as react } from './common/index-04edb6a1.js'; -export { r as default } from './common/index-04edb6a1.js'; +import { r as react } from './common/index-67cfdec9.js'; +export { r as default } from './common/index-67cfdec9.js'; import './common/_commonjsHelpers-8c19dec8.js'; +import './common/index-d01087d6.js'; diff --git a/docs/_snowpack/pkg/shift-ast.js b/docs/_snowpack/pkg/shift-ast.js new file mode 100644 index 00000000..a17213f2 --- /dev/null +++ b/docs/_snowpack/pkg/shift-ast.js @@ -0,0 +1,106 @@ +import { _ as __pika_web_default_export_for_treeshaking__, d as dist } from './common/index-1e63141f.js'; +export { d as __moduleExports, _ as default } from './common/index-1e63141f.js'; +import './common/_commonjsHelpers-8c19dec8.js'; + + + +var ArrayAssignmentTarget = dist.ArrayAssignmentTarget; +var ArrayBinding = dist.ArrayBinding; +var ArrayExpression = dist.ArrayExpression; +var ArrowExpression = dist.ArrowExpression; +var AssignmentExpression = dist.AssignmentExpression; +var AssignmentTargetIdentifier = dist.AssignmentTargetIdentifier; +var AssignmentTargetPropertyIdentifier = dist.AssignmentTargetPropertyIdentifier; +var AssignmentTargetPropertyProperty = dist.AssignmentTargetPropertyProperty; +var AssignmentTargetWithDefault = dist.AssignmentTargetWithDefault; +var AwaitExpression = dist.AwaitExpression; +var BinaryExpression = dist.BinaryExpression; +var BindingIdentifier = dist.BindingIdentifier; +var BindingPropertyIdentifier = dist.BindingPropertyIdentifier; +var BindingPropertyProperty = dist.BindingPropertyProperty; +var BindingWithDefault = dist.BindingWithDefault; +var Block = dist.Block; +var BlockStatement = dist.BlockStatement; +var BreakStatement = dist.BreakStatement; +var CallExpression = dist.CallExpression; +var CatchClause = dist.CatchClause; +var ClassDeclaration = dist.ClassDeclaration; +var ClassElement = dist.ClassElement; +var ClassExpression = dist.ClassExpression; +var CompoundAssignmentExpression = dist.CompoundAssignmentExpression; +var ComputedMemberAssignmentTarget = dist.ComputedMemberAssignmentTarget; +var ComputedMemberExpression = dist.ComputedMemberExpression; +var ComputedPropertyName = dist.ComputedPropertyName; +var ConditionalExpression = dist.ConditionalExpression; +var ContinueStatement = dist.ContinueStatement; +var DataProperty = dist.DataProperty; +var DebuggerStatement = dist.DebuggerStatement; +var Directive = dist.Directive; +var DoWhileStatement = dist.DoWhileStatement; +var EmptyStatement = dist.EmptyStatement; +var Export = dist.Export; +var ExportAllFrom = dist.ExportAllFrom; +var ExportDefault = dist.ExportDefault; +var ExportFrom = dist.ExportFrom; +var ExportFromSpecifier = dist.ExportFromSpecifier; +var ExportLocalSpecifier = dist.ExportLocalSpecifier; +var ExportLocals = dist.ExportLocals; +var ExpressionStatement = dist.ExpressionStatement; +var ForAwaitStatement = dist.ForAwaitStatement; +var ForInStatement = dist.ForInStatement; +var ForOfStatement = dist.ForOfStatement; +var ForStatement = dist.ForStatement; +var FormalParameters = dist.FormalParameters; +var FunctionBody = dist.FunctionBody; +var FunctionDeclaration = dist.FunctionDeclaration; +var FunctionExpression = dist.FunctionExpression; +var Getter = dist.Getter; +var IdentifierExpression = dist.IdentifierExpression; +var IfStatement = dist.IfStatement; +var Import = dist.Import; +var ImportNamespace = dist.ImportNamespace; +var ImportSpecifier = dist.ImportSpecifier; +var LabeledStatement = dist.LabeledStatement; +var LiteralBooleanExpression = dist.LiteralBooleanExpression; +var LiteralInfinityExpression = dist.LiteralInfinityExpression; +var LiteralNullExpression = dist.LiteralNullExpression; +var LiteralNumericExpression = dist.LiteralNumericExpression; +var LiteralRegExpExpression = dist.LiteralRegExpExpression; +var LiteralStringExpression = dist.LiteralStringExpression; +var Method = dist.Method; +var Module = dist.Module; +var NewExpression = dist.NewExpression; +var NewTargetExpression = dist.NewTargetExpression; +var ObjectAssignmentTarget = dist.ObjectAssignmentTarget; +var ObjectBinding = dist.ObjectBinding; +var ObjectExpression = dist.ObjectExpression; +var ReturnStatement = dist.ReturnStatement; +var Script = dist.Script; +var Setter = dist.Setter; +var ShorthandProperty = dist.ShorthandProperty; +var SpreadElement = dist.SpreadElement; +var SpreadProperty = dist.SpreadProperty; +var StaticMemberAssignmentTarget = dist.StaticMemberAssignmentTarget; +var StaticMemberExpression = dist.StaticMemberExpression; +var StaticPropertyName = dist.StaticPropertyName; +var Super = dist.Super; +var SwitchCase = dist.SwitchCase; +var SwitchDefault = dist.SwitchDefault; +var SwitchStatement = dist.SwitchStatement; +var SwitchStatementWithDefault = dist.SwitchStatementWithDefault; +var TemplateElement = dist.TemplateElement; +var TemplateExpression = dist.TemplateExpression; +var ThisExpression = dist.ThisExpression; +var ThrowStatement = dist.ThrowStatement; +var TryCatchStatement = dist.TryCatchStatement; +var TryFinallyStatement = dist.TryFinallyStatement; +var UnaryExpression = dist.UnaryExpression; +var UpdateExpression = dist.UpdateExpression; +var VariableDeclaration = dist.VariableDeclaration; +var VariableDeclarationStatement = dist.VariableDeclarationStatement; +var VariableDeclarator = dist.VariableDeclarator; +var WhileStatement = dist.WhileStatement; +var WithStatement = dist.WithStatement; +var YieldExpression = dist.YieldExpression; +var YieldGeneratorExpression = dist.YieldGeneratorExpression; +export { ArrayAssignmentTarget, ArrayBinding, ArrayExpression, ArrowExpression, AssignmentExpression, AssignmentTargetIdentifier, AssignmentTargetPropertyIdentifier, AssignmentTargetPropertyProperty, AssignmentTargetWithDefault, AwaitExpression, BinaryExpression, BindingIdentifier, BindingPropertyIdentifier, BindingPropertyProperty, BindingWithDefault, Block, BlockStatement, BreakStatement, CallExpression, CatchClause, ClassDeclaration, ClassElement, ClassExpression, CompoundAssignmentExpression, ComputedMemberAssignmentTarget, ComputedMemberExpression, ComputedPropertyName, ConditionalExpression, ContinueStatement, DataProperty, DebuggerStatement, Directive, DoWhileStatement, EmptyStatement, Export, ExportAllFrom, ExportDefault, ExportFrom, ExportFromSpecifier, ExportLocalSpecifier, ExportLocals, ExpressionStatement, ForAwaitStatement, ForInStatement, ForOfStatement, ForStatement, FormalParameters, FunctionBody, FunctionDeclaration, FunctionExpression, Getter, IdentifierExpression, IfStatement, Import, ImportNamespace, ImportSpecifier, LabeledStatement, LiteralBooleanExpression, LiteralInfinityExpression, LiteralNullExpression, LiteralNumericExpression, LiteralRegExpExpression, LiteralStringExpression, Method, Module, NewExpression, NewTargetExpression, ObjectAssignmentTarget, ObjectBinding, ObjectExpression, ReturnStatement, Script, Setter, ShorthandProperty, SpreadElement, SpreadProperty, StaticMemberAssignmentTarget, StaticMemberExpression, StaticPropertyName, Super, SwitchCase, SwitchDefault, SwitchStatement, SwitchStatementWithDefault, TemplateElement, TemplateExpression, ThisExpression, ThrowStatement, TryCatchStatement, TryFinallyStatement, UnaryExpression, UpdateExpression, VariableDeclaration, VariableDeclarationStatement, VariableDeclarator, WhileStatement, WithStatement, YieldExpression, YieldGeneratorExpression }; diff --git a/docs/_snowpack/pkg/shift-codegen.js b/docs/_snowpack/pkg/shift-codegen.js new file mode 100644 index 00000000..774c5ec9 --- /dev/null +++ b/docs/_snowpack/pkg/shift-codegen.js @@ -0,0 +1,11828 @@ +import { c as createCommonjsModule, g as getDefaultExportFromCjs } from './common/_commonjsHelpers-8c19dec8.js'; +import { o as objectAssign } from './common/index-d01087d6.js'; +import { d as dist$2 } from './common/index-1e63141f.js'; + +var ast = createCommonjsModule(function (module) { +/* + Copyright (C) 2013 Yusuke Suzuki + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +(function () { + + function isExpression(node) { + if (node == null) { return false; } + switch (node.type) { + case 'ArrayExpression': + case 'AssignmentExpression': + case 'BinaryExpression': + case 'CallExpression': + case 'ConditionalExpression': + case 'FunctionExpression': + case 'Identifier': + case 'Literal': + case 'LogicalExpression': + case 'MemberExpression': + case 'NewExpression': + case 'ObjectExpression': + case 'SequenceExpression': + case 'ThisExpression': + case 'UnaryExpression': + case 'UpdateExpression': + return true; + } + return false; + } + + function isIterationStatement(node) { + if (node == null) { return false; } + switch (node.type) { + case 'DoWhileStatement': + case 'ForInStatement': + case 'ForStatement': + case 'WhileStatement': + return true; + } + return false; + } + + function isStatement(node) { + if (node == null) { return false; } + switch (node.type) { + case 'BlockStatement': + case 'BreakStatement': + case 'ContinueStatement': + case 'DebuggerStatement': + case 'DoWhileStatement': + case 'EmptyStatement': + case 'ExpressionStatement': + case 'ForInStatement': + case 'ForStatement': + case 'IfStatement': + case 'LabeledStatement': + case 'ReturnStatement': + case 'SwitchStatement': + case 'ThrowStatement': + case 'TryStatement': + case 'VariableDeclaration': + case 'WhileStatement': + case 'WithStatement': + return true; + } + return false; + } + + function isSourceElement(node) { + return isStatement(node) || node != null && node.type === 'FunctionDeclaration'; + } + + function trailingStatement(node) { + switch (node.type) { + case 'IfStatement': + if (node.alternate != null) { + return node.alternate; + } + return node.consequent; + + case 'LabeledStatement': + case 'ForStatement': + case 'ForInStatement': + case 'WhileStatement': + case 'WithStatement': + return node.body; + } + return null; + } + + function isProblematicIfStatement(node) { + var current; + + if (node.type !== 'IfStatement') { + return false; + } + if (node.alternate == null) { + return false; + } + current = node.consequent; + do { + if (current.type === 'IfStatement') { + if (current.alternate == null) { + return true; + } + } + current = trailingStatement(current); + } while (current); + + return false; + } + + module.exports = { + isExpression: isExpression, + isStatement: isStatement, + isIterationStatement: isIterationStatement, + isSourceElement: isSourceElement, + isProblematicIfStatement: isProblematicIfStatement, + + trailingStatement: trailingStatement + }; +}()); +/* vim: set sw=4 ts=4 et tw=80 : */ +}); + +var code = createCommonjsModule(function (module) { +/* + Copyright (C) 2013-2014 Yusuke Suzuki + Copyright (C) 2014 Ivan Nikulin + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +(function () { + + var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch; + + // See `tools/generate-identifier-regex.js`. + ES5Regex = { + // ECMAScript 5.1/Unicode v9.0.0 NonAsciiIdentifierStart: + NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/, + // ECMAScript 5.1/Unicode v9.0.0 NonAsciiIdentifierPart: + NonAsciiIdentifierPart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/ + }; + + ES6Regex = { + // ECMAScript 6/Unicode v9.0.0 NonAsciiIdentifierStart: + NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/, + // ECMAScript 6/Unicode v9.0.0 NonAsciiIdentifierPart: + NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/ + }; + + function isDecimalDigit(ch) { + return 0x30 <= ch && ch <= 0x39; // 0..9 + } + + function isHexDigit(ch) { + return 0x30 <= ch && ch <= 0x39 || // 0..9 + 0x61 <= ch && ch <= 0x66 || // a..f + 0x41 <= ch && ch <= 0x46; // A..F + } + + function isOctalDigit(ch) { + return ch >= 0x30 && ch <= 0x37; // 0..7 + } + + // 7.2 White Space + + NON_ASCII_WHITESPACES = [ + 0x1680, + 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, + 0x202F, 0x205F, + 0x3000, + 0xFEFF + ]; + + function isWhiteSpace(ch) { + return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 || + ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0; + } + + // 7.3 Line Terminators + + function isLineTerminator(ch) { + return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029; + } + + // 7.6 Identifier Names and Identifiers + + function fromCodePoint(cp) { + if (cp <= 0xFFFF) { return String.fromCharCode(cp); } + var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800); + var cu2 = String.fromCharCode(((cp - 0x10000) % 0x400) + 0xDC00); + return cu1 + cu2; + } + + IDENTIFIER_START = new Array(0x80); + for(ch = 0; ch < 0x80; ++ch) { + IDENTIFIER_START[ch] = + ch >= 0x61 && ch <= 0x7A || // a..z + ch >= 0x41 && ch <= 0x5A || // A..Z + ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore) + } + + IDENTIFIER_PART = new Array(0x80); + for(ch = 0; ch < 0x80; ++ch) { + IDENTIFIER_PART[ch] = + ch >= 0x61 && ch <= 0x7A || // a..z + ch >= 0x41 && ch <= 0x5A || // A..Z + ch >= 0x30 && ch <= 0x39 || // 0..9 + ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore) + } + + function isIdentifierStartES5(ch) { + return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch)); + } + + function isIdentifierPartES5(ch) { + return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch)); + } + + function isIdentifierStartES6(ch) { + return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch)); + } + + function isIdentifierPartES6(ch) { + return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch)); + } + + module.exports = { + isDecimalDigit: isDecimalDigit, + isHexDigit: isHexDigit, + isOctalDigit: isOctalDigit, + isWhiteSpace: isWhiteSpace, + isLineTerminator: isLineTerminator, + isIdentifierStartES5: isIdentifierStartES5, + isIdentifierPartES5: isIdentifierPartES5, + isIdentifierStartES6: isIdentifierStartES6, + isIdentifierPartES6: isIdentifierPartES6 + }; +}()); +/* vim: set sw=4 ts=4 et tw=80 : */ +}); + +var keyword = createCommonjsModule(function (module) { +/* + Copyright (C) 2013 Yusuke Suzuki + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +(function () { + + var code$1 = code; + + function isStrictModeReservedWordES6(id) { + switch (id) { + case 'implements': + case 'interface': + case 'package': + case 'private': + case 'protected': + case 'public': + case 'static': + case 'let': + return true; + default: + return false; + } + } + + function isKeywordES5(id, strict) { + // yield should not be treated as keyword under non-strict mode. + if (!strict && id === 'yield') { + return false; + } + return isKeywordES6(id, strict); + } + + function isKeywordES6(id, strict) { + if (strict && isStrictModeReservedWordES6(id)) { + return true; + } + + switch (id.length) { + case 2: + return (id === 'if') || (id === 'in') || (id === 'do'); + case 3: + return (id === 'var') || (id === 'for') || (id === 'new') || (id === 'try'); + case 4: + return (id === 'this') || (id === 'else') || (id === 'case') || + (id === 'void') || (id === 'with') || (id === 'enum'); + case 5: + return (id === 'while') || (id === 'break') || (id === 'catch') || + (id === 'throw') || (id === 'const') || (id === 'yield') || + (id === 'class') || (id === 'super'); + case 6: + return (id === 'return') || (id === 'typeof') || (id === 'delete') || + (id === 'switch') || (id === 'export') || (id === 'import'); + case 7: + return (id === 'default') || (id === 'finally') || (id === 'extends'); + case 8: + return (id === 'function') || (id === 'continue') || (id === 'debugger'); + case 10: + return (id === 'instanceof'); + default: + return false; + } + } + + function isReservedWordES5(id, strict) { + return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict); + } + + function isReservedWordES6(id, strict) { + return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict); + } + + function isRestrictedWord(id) { + return id === 'eval' || id === 'arguments'; + } + + function isIdentifierNameES5(id) { + var i, iz, ch; + + if (id.length === 0) { return false; } + + ch = id.charCodeAt(0); + if (!code$1.isIdentifierStartES5(ch)) { + return false; + } + + for (i = 1, iz = id.length; i < iz; ++i) { + ch = id.charCodeAt(i); + if (!code$1.isIdentifierPartES5(ch)) { + return false; + } + } + return true; + } + + function decodeUtf16(lead, trail) { + return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; + } + + function isIdentifierNameES6(id) { + var i, iz, ch, lowCh, check; + + if (id.length === 0) { return false; } + + check = code$1.isIdentifierStartES6; + for (i = 0, iz = id.length; i < iz; ++i) { + ch = id.charCodeAt(i); + if (0xD800 <= ch && ch <= 0xDBFF) { + ++i; + if (i >= iz) { return false; } + lowCh = id.charCodeAt(i); + if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) { + return false; + } + ch = decodeUtf16(ch, lowCh); + } + if (!check(ch)) { + return false; + } + check = code$1.isIdentifierPartES6; + } + return true; + } + + function isIdentifierES5(id, strict) { + return isIdentifierNameES5(id) && !isReservedWordES5(id, strict); + } + + function isIdentifierES6(id, strict) { + return isIdentifierNameES6(id) && !isReservedWordES6(id, strict); + } + + module.exports = { + isKeywordES5: isKeywordES5, + isKeywordES6: isKeywordES6, + isReservedWordES5: isReservedWordES5, + isReservedWordES6: isReservedWordES6, + isRestrictedWord: isRestrictedWord, + isIdentifierNameES5: isIdentifierNameES5, + isIdentifierNameES6: isIdentifierNameES6, + isIdentifierES5: isIdentifierES5, + isIdentifierES6: isIdentifierES6 + }; +}()); +/* vim: set sw=4 ts=4 et tw=80 : */ +}); + +var utils = createCommonjsModule(function (module, exports) { +/* + Copyright (C) 2013 Yusuke Suzuki + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +(function () { + + exports.ast = ast; + exports.code = code; + exports.keyword = keyword; +}()); +/* vim: set sw=4 ts=4 et tw=80 : */ +}); + +var coderep = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +exports.getPrecedence = getPrecedence; +exports.escapeStringLiteral = escapeStringLiteral; + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Precedence = { + Sequence: 0, + Yield: 1, + Assignment: 1, + Conditional: 2, + ArrowFunction: 2, + LogicalOR: 3, + LogicalAND: 4, + BitwiseOR: 5, + BitwiseXOR: 6, + BitwiseAND: 7, + Equality: 8, + Relational: 9, + BitwiseSHIFT: 10, + Additive: 11, + Multiplicative: 12, + Exponential: 13, + Prefix: 14, + Postfix: 15, + New: 16, + Call: 17, + TaggedTemplate: 18, + Member: 19, + Primary: 20 +}; + +exports.Precedence = Precedence; + + +var BinaryPrecedence = { + ',': Precedence.Sequence, + '||': Precedence.LogicalOR, + '&&': Precedence.LogicalAND, + '|': Precedence.BitwiseOR, + '^': Precedence.BitwiseXOR, + '&': Precedence.BitwiseAND, + '==': Precedence.Equality, + '!=': Precedence.Equality, + '===': Precedence.Equality, + '!==': Precedence.Equality, + '<': Precedence.Relational, + '>': Precedence.Relational, + '<=': Precedence.Relational, + '>=': Precedence.Relational, + 'in': Precedence.Relational, + 'instanceof': Precedence.Relational, + '<<': Precedence.BitwiseSHIFT, + '>>': Precedence.BitwiseSHIFT, + '>>>': Precedence.BitwiseSHIFT, + '+': Precedence.Additive, + '-': Precedence.Additive, + '*': Precedence.Multiplicative, + '%': Precedence.Multiplicative, + '/': Precedence.Multiplicative, + '**': Precedence.Exponential +}; + +function getPrecedence(node) { + switch (node.type) { + case 'ArrayExpression': + case 'FunctionExpression': + case 'ClassExpression': + case 'IdentifierExpression': + case 'AssignmentTargetIdentifier': + case 'NewTargetExpression': + case 'Super': + case 'LiteralBooleanExpression': + case 'LiteralNullExpression': + case 'LiteralNumericExpression': + case 'LiteralInfinityExpression': + case 'LiteralRegExpExpression': + case 'LiteralStringExpression': + case 'ObjectExpression': + case 'ThisExpression': + case 'SpreadElement': + case 'FunctionBody': + return Precedence.Primary; + + case 'ArrowExpression': + case 'AssignmentExpression': + case 'CompoundAssignmentExpression': + case 'YieldExpression': + case 'YieldGeneratorExpression': + return Precedence.Assignment; + + case 'ConditionalExpression': + return Precedence.Conditional; + + case 'ComputedMemberExpression': + case 'StaticMemberExpression': + case 'ComputedMemberAssignmentTarget': + case 'StaticMemberAssignmentTarget': + switch (node.object.type) { + case 'CallExpression': + case 'ComputedMemberExpression': + case 'StaticMemberExpression': + case 'TemplateExpression': + return getPrecedence(node.object); + default: + return Precedence.Member; + } + + case 'TemplateExpression': + if (node.tag == null) return Precedence.Member; + switch (node.tag.type) { + case 'CallExpression': + case 'ComputedMemberExpression': + case 'StaticMemberExpression': + case 'TemplateExpression': + return getPrecedence(node.tag); + default: + return Precedence.Member; + } + + case 'BinaryExpression': + return BinaryPrecedence[node.operator]; + + case 'CallExpression': + return Precedence.Call; + case 'NewExpression': + return node.arguments.length === 0 ? Precedence.New : Precedence.Member; + case 'UpdateExpression': + return node.isPrefix ? Precedence.Prefix : Precedence.Postfix; + case 'AwaitExpression': + case 'UnaryExpression': + return Precedence.Prefix; + default: + throw new Error('unreachable: ' + node.type); + } +} + +function escapeStringLiteral(stringValue) { + var result = ''; + var nSingle = 0, + nDouble = 0; + for (var i = 0, l = stringValue.length; i < l; ++i) { + var ch = stringValue[i]; + if (ch === '"') { + ++nDouble; + } else if (ch === '\'') { + ++nSingle; + } + } + var delim = nDouble > nSingle ? '\'' : '"'; + result += delim; + for (var _i = 0; _i < stringValue.length; _i++) { + var _ch = stringValue.charAt(_i); + switch (_ch) { + case delim: + result += '\\' + delim; + break; + case '\n': + result += '\\n'; + break; + case '\r': + result += '\\r'; + break; + case '\\': + result += '\\\\'; + break; + case '\u2028': + result += '\\u2028'; + break; + case '\u2029': + result += '\\u2029'; + break; + default: + result += _ch; + break; + } + } + result += delim; + return result; +} + +var CodeRep = exports.CodeRep = function () { + function CodeRep() { + _classCallCheck(this, CodeRep); + + this.containsIn = false; + this.containsGroup = false; + // restricted lookaheads: {, function, class, let, let [ + this.startsWithCurly = false; + this.startsWithFunctionOrClass = false; + this.startsWithLet = false; + this.startsWithLetSquareBracket = false; + this.endsWithMissingElse = false; + } + + _createClass(CodeRep, [{ + key: 'forEach', + value: function forEach(f) { + // Call a function on every CodeRep represented by this node. Always calls f on a node and then its children, so if you're careful you can modify a node's children online. + f(this); + } + }]); + + return CodeRep; +}(); + +var Empty = exports.Empty = function (_CodeRep) { + _inherits(Empty, _CodeRep); + + function Empty() { + _classCallCheck(this, Empty); + + return _possibleConstructorReturn(this, (Empty.__proto__ || Object.getPrototypeOf(Empty)).call(this)); + } + + _createClass(Empty, [{ + key: 'emit', + value: function emit() {} + }]); + + return Empty; +}(CodeRep); + +var Token = exports.Token = function (_CodeRep2) { + _inherits(Token, _CodeRep2); + + function Token(token) { + var isRegExp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + _classCallCheck(this, Token); + + var _this2 = _possibleConstructorReturn(this, (Token.__proto__ || Object.getPrototypeOf(Token)).call(this)); + + _this2.token = token; + _this2.isRegExp = isRegExp; + return _this2; + } + + _createClass(Token, [{ + key: 'emit', + value: function emit(ts) { + ts.put(this.token, this.isRegExp); + } + }]); + + return Token; +}(CodeRep); + +var RawToken = exports.RawToken = function (_CodeRep3) { + _inherits(RawToken, _CodeRep3); + + function RawToken(token) { + _classCallCheck(this, RawToken); + + var _this3 = _possibleConstructorReturn(this, (RawToken.__proto__ || Object.getPrototypeOf(RawToken)).call(this)); + + _this3.token = token; + return _this3; + } + + _createClass(RawToken, [{ + key: 'emit', + value: function emit(ts) { + ts.putRaw(this.token); + } + }]); + + return RawToken; +}(CodeRep); + +var NumberCodeRep = exports.NumberCodeRep = function (_CodeRep4) { + _inherits(NumberCodeRep, _CodeRep4); + + function NumberCodeRep(number) { + _classCallCheck(this, NumberCodeRep); + + var _this4 = _possibleConstructorReturn(this, (NumberCodeRep.__proto__ || Object.getPrototypeOf(NumberCodeRep)).call(this)); + + _this4.number = number; + return _this4; + } + + _createClass(NumberCodeRep, [{ + key: 'emit', + value: function emit(ts) { + ts.putNumber(this.number); + } + }]); + + return NumberCodeRep; +}(CodeRep); + +var Paren = exports.Paren = function (_CodeRep5) { + _inherits(Paren, _CodeRep5); + + function Paren(expr) { + _classCallCheck(this, Paren); + + var _this5 = _possibleConstructorReturn(this, (Paren.__proto__ || Object.getPrototypeOf(Paren)).call(this)); + + _this5.expr = expr; + return _this5; + } + + _createClass(Paren, [{ + key: 'emit', + value: function emit(ts) { + ts.put('('); + this.expr.emit(ts, false); + ts.put(')'); + } + }, { + key: 'forEach', + value: function forEach(f) { + f(this); + this.expr.forEach(f); + } + }]); + + return Paren; +}(CodeRep); + +var Bracket = exports.Bracket = function (_CodeRep6) { + _inherits(Bracket, _CodeRep6); + + function Bracket(expr) { + _classCallCheck(this, Bracket); + + var _this6 = _possibleConstructorReturn(this, (Bracket.__proto__ || Object.getPrototypeOf(Bracket)).call(this)); + + _this6.expr = expr; + return _this6; + } + + _createClass(Bracket, [{ + key: 'emit', + value: function emit(ts) { + ts.put('['); + this.expr.emit(ts, false); + ts.put(']'); + } + }, { + key: 'forEach', + value: function forEach(f) { + f(this); + this.expr.forEach(f); + } + }]); + + return Bracket; +}(CodeRep); + +var Brace = exports.Brace = function (_CodeRep7) { + _inherits(Brace, _CodeRep7); + + function Brace(expr) { + _classCallCheck(this, Brace); + + var _this7 = _possibleConstructorReturn(this, (Brace.__proto__ || Object.getPrototypeOf(Brace)).call(this)); + + _this7.expr = expr; + return _this7; + } + + _createClass(Brace, [{ + key: 'emit', + value: function emit(ts) { + ts.put('{'); + this.expr.emit(ts, false); + ts.put('}'); + } + }, { + key: 'forEach', + value: function forEach(f) { + f(this); + this.expr.forEach(f); + } + }]); + + return Brace; +}(CodeRep); + +var NoIn = exports.NoIn = function (_CodeRep8) { + _inherits(NoIn, _CodeRep8); + + function NoIn(expr) { + _classCallCheck(this, NoIn); + + var _this8 = _possibleConstructorReturn(this, (NoIn.__proto__ || Object.getPrototypeOf(NoIn)).call(this)); + + _this8.expr = expr; + return _this8; + } + + _createClass(NoIn, [{ + key: 'emit', + value: function emit(ts) { + this.expr.emit(ts, true); + } + }, { + key: 'forEach', + value: function forEach(f) { + f(this); + this.expr.forEach(f); + } + }]); + + return NoIn; +}(CodeRep); + +var ContainsIn = exports.ContainsIn = function (_CodeRep9) { + _inherits(ContainsIn, _CodeRep9); + + function ContainsIn(expr) { + _classCallCheck(this, ContainsIn); + + var _this9 = _possibleConstructorReturn(this, (ContainsIn.__proto__ || Object.getPrototypeOf(ContainsIn)).call(this)); + + _this9.expr = expr; + return _this9; + } + + _createClass(ContainsIn, [{ + key: 'emit', + value: function emit(ts, noIn) { + if (noIn) { + ts.put('('); + this.expr.emit(ts, false); + ts.put(')'); + } else { + this.expr.emit(ts, false); + } + } + }, { + key: 'forEach', + value: function forEach(f) { + f(this); + this.expr.forEach(f); + } + }]); + + return ContainsIn; +}(CodeRep); + +var Seq = exports.Seq = function (_CodeRep10) { + _inherits(Seq, _CodeRep10); + + function Seq(children) { + _classCallCheck(this, Seq); + + var _this10 = _possibleConstructorReturn(this, (Seq.__proto__ || Object.getPrototypeOf(Seq)).call(this)); + + _this10.children = children; + return _this10; + } + + _createClass(Seq, [{ + key: 'emit', + value: function emit(ts, noIn) { + this.children.forEach(function (cr) { + return cr.emit(ts, noIn); + }); + } + }, { + key: 'forEach', + value: function forEach(f) { + f(this); + this.children.forEach(function (x) { + return x.forEach(f); + }); + } + }]); + + return Seq; +}(CodeRep); + +var Semi = exports.Semi = function (_Token) { + _inherits(Semi, _Token); + + function Semi() { + _classCallCheck(this, Semi); + + return _possibleConstructorReturn(this, (Semi.__proto__ || Object.getPrototypeOf(Semi)).call(this, ';')); + } + + return Semi; +}(Token); + +var CommaSep = exports.CommaSep = function (_CodeRep11) { + _inherits(CommaSep, _CodeRep11); + + function CommaSep(children) { + _classCallCheck(this, CommaSep); + + var _this12 = _possibleConstructorReturn(this, (CommaSep.__proto__ || Object.getPrototypeOf(CommaSep)).call(this)); + + _this12.children = children; + return _this12; + } + + _createClass(CommaSep, [{ + key: 'emit', + value: function emit(ts, noIn) { + var first = true; + this.children.forEach(function (cr) { + if (first) { + first = false; + } else { + ts.put(','); + } + cr.emit(ts, noIn); + }); + } + }, { + key: 'forEach', + value: function forEach(f) { + f(this); + this.children.forEach(function (x) { + return x.forEach(f); + }); + } + }]); + + return CommaSep; +}(CodeRep); + +var SemiOp = exports.SemiOp = function (_CodeRep12) { + _inherits(SemiOp, _CodeRep12); + + function SemiOp() { + _classCallCheck(this, SemiOp); + + return _possibleConstructorReturn(this, (SemiOp.__proto__ || Object.getPrototypeOf(SemiOp)).call(this)); + } + + _createClass(SemiOp, [{ + key: 'emit', + value: function emit(ts) { + ts.putOptionalSemi(); + } + }]); + + return SemiOp; +}(CodeRep); +}); + +var minimalCodegen = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + + +var _objectAssign2 = _interopRequireDefault(objectAssign); + + + + + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function p(node, precedence, a) { + return (0, coderep.getPrecedence)(node) < precedence ? paren(a) : a; +} + +function t(token) { + var isRegExp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + return new coderep.Token(token, isRegExp); +} + +function paren(rep) { + return new coderep.Paren(rep); +} + +function brace(rep) { + return new coderep.Brace(rep); +} + +function bracket(rep) { + return new coderep.Bracket(rep); +} + +function noIn(rep) { + return new coderep.NoIn(rep); +} + +function markContainsIn(state) { + return state.containsIn ? new coderep.ContainsIn(state) : state; +} + +function seq() { + for (var _len = arguments.length, reps = Array(_len), _key = 0; _key < _len; _key++) { + reps[_key] = arguments[_key]; + } + + return new coderep.Seq(reps); +} + +function semi() { + return new coderep.Semi(); +} + +function semiOp() { + return new coderep.SemiOp(); +} + +function empty() { + return new coderep.Empty(); +} + +function commaSep(pieces) { + return new coderep.CommaSep(pieces); +} + +function getAssignmentExpr(state) { + return state ? state.containsGroup ? paren(state) : state : empty(); +} + +var MinimalCodeGen = function () { + function MinimalCodeGen() { + _classCallCheck(this, MinimalCodeGen); + } + + _createClass(MinimalCodeGen, [{ + key: 'parenToAvoidBeingDirective', + value: function parenToAvoidBeingDirective(element, original) { + if (element && element.type === 'ExpressionStatement' && element.expression.type === 'LiteralStringExpression') { + return seq(paren(original.children[0]), semiOp()); + } + return original; + } + }, { + key: 'regenerateArrowParams', + value: function regenerateArrowParams(element, original) { + if (element.rest == null && element.items.length === 1 && element.items[0].type === 'BindingIdentifier') { + // FormalParameters unconditionally include parentheses, but they're not necessary here + return this.reduceBindingIdentifier(element.items[0]); + } + return original; + } + }, { + key: 'reduceArrayExpression', + value: function reduceArrayExpression(node, _ref) { + var elements = _ref.elements; + + if (elements.length === 0) { + return bracket(empty()); + } + + var content = commaSep(elements.map(getAssignmentExpr)); + if (elements.length > 0 && elements[elements.length - 1] == null) { + content = seq(content, t(',')); + } + return bracket(content); + } + }, { + key: 'reduceAwaitExpression', + value: function reduceAwaitExpression(node, _ref2) { + var expression = _ref2.expression; + + return seq(t('await'), p(node.expression, (0, coderep.getPrecedence)(node), expression)); + } + }, { + key: 'reduceSpreadElement', + value: function reduceSpreadElement(node, _ref3) { + var expression = _ref3.expression; + + return seq(t('...'), p(node.expression, coderep.Precedence.Assignment, expression)); + } + }, { + key: 'reduceSpreadProperty', + value: function reduceSpreadProperty(node, _ref4) { + var expression = _ref4.expression; + + return seq(t('...'), getAssignmentExpr(expression)); + } + }, { + key: 'reduceAssignmentExpression', + value: function reduceAssignmentExpression(node, _ref5) { + var binding = _ref5.binding, + expression = _ref5.expression; + + var leftCode = binding; + var rightCode = expression; + var containsIn = expression.containsIn; + var startsWithCurly = binding.startsWithCurly; + var startsWithLetSquareBracket = binding.startsWithLetSquareBracket; + var startsWithFunctionOrClass = binding.startsWithFunctionOrClass; + if ((0, coderep.getPrecedence)(node.expression) < (0, coderep.getPrecedence)(node)) { + rightCode = paren(rightCode); + containsIn = false; + } + return (0, _objectAssign2.default)(seq(leftCode, t('='), rightCode), { containsIn: containsIn, startsWithCurly: startsWithCurly, startsWithLetSquareBracket: startsWithLetSquareBracket, startsWithFunctionOrClass: startsWithFunctionOrClass }); + } + }, { + key: 'reduceAssignmentTargetIdentifier', + value: function reduceAssignmentTargetIdentifier(node) { + var a = t(node.name); + if (node.name === 'let') { + a.startsWithLet = true; + } + return a; + } + }, { + key: 'reduceAssignmentTargetWithDefault', + value: function reduceAssignmentTargetWithDefault(node, _ref6) { + var binding = _ref6.binding, + init = _ref6.init; + + return seq(binding, t('='), p(node.init, coderep.Precedence.Assignment, init)); + } + }, { + key: 'reduceCompoundAssignmentExpression', + value: function reduceCompoundAssignmentExpression(node, _ref7) { + var binding = _ref7.binding, + expression = _ref7.expression; + + var leftCode = binding; + var rightCode = expression; + var containsIn = expression.containsIn; + var startsWithCurly = binding.startsWithCurly; + var startsWithLetSquareBracket = binding.startsWithLetSquareBracket; + var startsWithFunctionOrClass = binding.startsWithFunctionOrClass; + if ((0, coderep.getPrecedence)(node.expression) < (0, coderep.getPrecedence)(node)) { + rightCode = paren(rightCode); + containsIn = false; + } + return (0, _objectAssign2.default)(seq(leftCode, t(node.operator), rightCode), { containsIn: containsIn, startsWithCurly: startsWithCurly, startsWithLetSquareBracket: startsWithLetSquareBracket, startsWithFunctionOrClass: startsWithFunctionOrClass }); + } + }, { + key: 'reduceBinaryExpression', + value: function reduceBinaryExpression(node, _ref8) { + var left = _ref8.left, + right = _ref8.right; + + var leftCode = left; + var startsWithCurly = left.startsWithCurly; + var startsWithLetSquareBracket = left.startsWithLetSquareBracket; + var startsWithFunctionOrClass = left.startsWithFunctionOrClass; + var leftContainsIn = left.containsIn; + var isRightAssociative = node.operator === '**'; + if ((0, coderep.getPrecedence)(node.left) < (0, coderep.getPrecedence)(node) || isRightAssociative && ((0, coderep.getPrecedence)(node.left) === (0, coderep.getPrecedence)(node) || node.left.type === 'UnaryExpression')) { + leftCode = paren(leftCode); + startsWithCurly = false; + startsWithLetSquareBracket = false; + startsWithFunctionOrClass = false; + leftContainsIn = false; + } + var rightCode = right; + var rightContainsIn = right.containsIn; + if ((0, coderep.getPrecedence)(node.right) < (0, coderep.getPrecedence)(node) || !isRightAssociative && (0, coderep.getPrecedence)(node.right) === (0, coderep.getPrecedence)(node)) { + rightCode = paren(rightCode); + rightContainsIn = false; + } + return (0, _objectAssign2.default)(seq(leftCode, t(node.operator), rightCode), { + containsIn: leftContainsIn || rightContainsIn || node.operator === 'in', + containsGroup: node.operator === ',', + startsWithCurly: startsWithCurly, + startsWithLetSquareBracket: startsWithLetSquareBracket, + startsWithFunctionOrClass: startsWithFunctionOrClass + }); + } + }, { + key: 'reduceBindingWithDefault', + value: function reduceBindingWithDefault(node, _ref9) { + var binding = _ref9.binding, + init = _ref9.init; + + return seq(binding, t('='), p(node.init, coderep.Precedence.Assignment, init)); + } + }, { + key: 'reduceBindingIdentifier', + value: function reduceBindingIdentifier(node) { + var a = t(node.name); + if (node.name === 'let') { + a.startsWithLet = true; + } + return a; + } + }, { + key: 'reduceArrayAssignmentTarget', + value: function reduceArrayAssignmentTarget(node, _ref10) { + var elements = _ref10.elements, + rest = _ref10.rest; + + var content = void 0; + if (elements.length === 0) { + content = rest == null ? empty() : seq(t('...'), rest); + } else { + elements = elements.concat(rest == null ? [] : [seq(t('...'), rest)]); + content = commaSep(elements.map(getAssignmentExpr)); + if (elements.length > 0 && elements[elements.length - 1] == null) { + content = seq(content, t(',')); + } + } + return bracket(content); + } + }, { + key: 'reduceArrayBinding', + value: function reduceArrayBinding(node, _ref11) { + var elements = _ref11.elements, + rest = _ref11.rest; + + var content = void 0; + if (elements.length === 0) { + content = rest == null ? empty() : seq(t('...'), rest); + } else { + elements = elements.concat(rest == null ? [] : [seq(t('...'), rest)]); + content = commaSep(elements.map(getAssignmentExpr)); + if (elements.length > 0 && elements[elements.length - 1] == null) { + content = seq(content, t(',')); + } + } + return bracket(content); + } + }, { + key: 'reduceObjectAssignmentTarget', + value: function reduceObjectAssignmentTarget(node, _ref12) { + var properties = _ref12.properties, + rest = _ref12.rest; + + var content = commaSep(properties); + if (properties.length === 0) { + content = rest == null ? empty() : seq(t('...'), rest); + } else { + content = rest == null ? content : seq(content, t(','), t('...'), rest); + } + var state = brace(content); + state.startsWithCurly = true; + return state; + } + }, { + key: 'reduceObjectBinding', + value: function reduceObjectBinding(node, _ref13) { + var properties = _ref13.properties, + rest = _ref13.rest; + + var content = commaSep(properties); + if (properties.length === 0) { + content = rest == null ? empty() : seq(t('...'), rest); + } else { + content = rest == null ? content : seq(content, t(','), t('...'), rest); + } + var state = brace(content); + state.startsWithCurly = true; + return state; + } + }, { + key: 'reduceAssignmentTargetPropertyIdentifier', + value: function reduceAssignmentTargetPropertyIdentifier(node, _ref14) { + var binding = _ref14.binding, + init = _ref14.init; + + if (node.init == null) return binding; + return seq(binding, t('='), p(node.init, coderep.Precedence.Assignment, init)); + } + }, { + key: 'reduceAssignmentTargetPropertyProperty', + value: function reduceAssignmentTargetPropertyProperty(node, _ref15) { + var name = _ref15.name, + binding = _ref15.binding; + + return seq(name, t(':'), binding); + } + }, { + key: 'reduceBindingPropertyIdentifier', + value: function reduceBindingPropertyIdentifier(node, _ref16) { + var binding = _ref16.binding, + init = _ref16.init; + + if (node.init == null) return binding; + return seq(binding, t('='), p(node.init, coderep.Precedence.Assignment, init)); + } + }, { + key: 'reduceBindingPropertyProperty', + value: function reduceBindingPropertyProperty(node, _ref17) { + var name = _ref17.name, + binding = _ref17.binding; + + return seq(name, t(':'), binding); + } + }, { + key: 'reduceBlock', + value: function reduceBlock(node, _ref18) { + var statements = _ref18.statements; + + return brace(seq.apply(undefined, _toConsumableArray(statements))); + } + }, { + key: 'reduceBlockStatement', + value: function reduceBlockStatement(node, _ref19) { + var block = _ref19.block; + + return block; + } + }, { + key: 'reduceBreakStatement', + value: function reduceBreakStatement(node) { + return seq(t('break'), node.label ? t(node.label) : empty(), semiOp()); + } + }, { + key: 'reduceCallExpression', + value: function reduceCallExpression(node, _ref20) { + var callee = _ref20.callee, + args = _ref20.arguments; + + var parenthizedArgs = args.map(function (a, i) { + return p(node.arguments[i], coderep.Precedence.Assignment, a); + }); + return (0, _objectAssign2.default)(seq(p(node.callee, (0, coderep.getPrecedence)(node), callee), paren(commaSep(parenthizedArgs))), { + startsWithCurly: callee.startsWithCurly, + startsWithLet: callee.startsWithLet, + startsWithLetSquareBracket: callee.startsWithLetSquareBracket, + startsWithFunctionOrClass: callee.startsWithFunctionOrClass + }); + } + }, { + key: 'reduceCatchClause', + value: function reduceCatchClause(node, _ref21) { + var binding = _ref21.binding, + body = _ref21.body; + + return seq(t('catch'), paren(binding), body); + } + }, { + key: 'reduceClassDeclaration', + value: function reduceClassDeclaration(node, _ref22) { + var name = _ref22.name, + _super = _ref22.super, + elements = _ref22.elements; + + var state = seq(t('class'), node.name.name === '*default*' ? empty() : name); + if (_super != null) { + state = seq(state, t('extends'), p(node.super, coderep.Precedence.New, _super)); + } + state = seq.apply(undefined, [state, t('{')].concat(_toConsumableArray(elements), [t('}')])); + return state; + } + }, { + key: 'reduceClassExpression', + value: function reduceClassExpression(node, _ref23) { + var name = _ref23.name, + _super = _ref23.super, + elements = _ref23.elements; + + var state = t('class'); + if (name != null) { + state = seq(state, name); + } + if (_super != null) { + state = seq(state, t('extends'), p(node.super, coderep.Precedence.New, _super)); + } + state = seq.apply(undefined, [state, t('{')].concat(_toConsumableArray(elements), [t('}')])); + state.startsWithFunctionOrClass = true; + return state; + } + }, { + key: 'reduceClassElement', + value: function reduceClassElement(node, _ref24) { + var method = _ref24.method; + + if (!node.isStatic) return method; + return seq(t('static'), method); + } + }, { + key: 'reduceComputedMemberAssignmentTarget', + value: function reduceComputedMemberAssignmentTarget(node, _ref25) { + var object = _ref25.object, + expression = _ref25.expression; + + var startsWithLetSquareBracket = object.startsWithLetSquareBracket || node.object.type === 'IdentifierExpression' && node.object.name === 'let'; + return (0, _objectAssign2.default)(seq(p(node.object, (0, coderep.getPrecedence)(node), object), bracket(expression)), { + startsWithLet: object.startsWithLet, + startsWithLetSquareBracket: startsWithLetSquareBracket, + startsWithCurly: object.startsWithCurly, + startsWithFunctionOrClass: object.startsWithFunctionOrClass + }); + } + }, { + key: 'reduceComputedMemberExpression', + value: function reduceComputedMemberExpression(node, _ref26) { + var object = _ref26.object, + expression = _ref26.expression; + + var startsWithLetSquareBracket = object.startsWithLetSquareBracket || node.object.type === 'IdentifierExpression' && node.object.name === 'let'; + return (0, _objectAssign2.default)(seq(p(node.object, (0, coderep.getPrecedence)(node), object), bracket(expression)), { + startsWithLet: object.startsWithLet, + startsWithLetSquareBracket: startsWithLetSquareBracket, + startsWithCurly: object.startsWithCurly, + startsWithFunctionOrClass: object.startsWithFunctionOrClass + }); + } + }, { + key: 'reduceComputedPropertyName', + value: function reduceComputedPropertyName(node, _ref27) { + var expression = _ref27.expression; + + return bracket(p(node.expression, coderep.Precedence.Assignment, expression)); + } + }, { + key: 'reduceConditionalExpression', + value: function reduceConditionalExpression(node, _ref28) { + var test = _ref28.test, + consequent = _ref28.consequent, + alternate = _ref28.alternate; + + var containsIn = test.containsIn || alternate.containsIn; + var startsWithCurly = test.startsWithCurly; + var startsWithLetSquareBracket = test.startsWithLetSquareBracket; + var startsWithFunctionOrClass = test.startsWithFunctionOrClass; + return (0, _objectAssign2.default)(seq(p(node.test, coderep.Precedence.LogicalOR, test), t('?'), p(node.consequent, coderep.Precedence.Assignment, consequent), t(':'), p(node.alternate, coderep.Precedence.Assignment, alternate)), { + containsIn: containsIn, + startsWithCurly: startsWithCurly, + startsWithLetSquareBracket: startsWithLetSquareBracket, + startsWithFunctionOrClass: startsWithFunctionOrClass + }); + } + }, { + key: 'reduceContinueStatement', + value: function reduceContinueStatement(node) { + return seq(t('continue'), node.label ? t(node.label) : empty(), semiOp()); + } + }, { + key: 'reduceDataProperty', + value: function reduceDataProperty(node, _ref29) { + var name = _ref29.name, + expression = _ref29.expression; + + return seq(name, t(':'), getAssignmentExpr(expression)); + } + }, { + key: 'reduceDebuggerStatement', + value: function reduceDebuggerStatement() /* node */{ + return seq(t('debugger'), semiOp()); + } + }, { + key: 'reduceDoWhileStatement', + value: function reduceDoWhileStatement(node, _ref30) { + var body = _ref30.body, + test = _ref30.test; + + return seq(t('do'), body, t('while'), paren(test), semiOp()); + } + }, { + key: 'reduceEmptyStatement', + value: function reduceEmptyStatement() /* node */{ + return semi(); + } + }, { + key: 'reduceExpressionStatement', + value: function reduceExpressionStatement(node, _ref31) { + var expression = _ref31.expression; + + var needsParens = expression.startsWithCurly || expression.startsWithLetSquareBracket || expression.startsWithFunctionOrClass; + return seq(needsParens ? paren(expression) : expression, semiOp()); + } + }, { + key: 'reduceForInStatement', + value: function reduceForInStatement(node, _ref32) { + var left = _ref32.left, + right = _ref32.right, + body = _ref32.body; + + left = node.left.type === 'VariableDeclaration' ? noIn(markContainsIn(left)) : left; + return (0, _objectAssign2.default)(seq(t('for'), paren(seq(left.startsWithLet ? paren(left) : left, t('in'), right)), body), { endsWithMissingElse: body.endsWithMissingElse }); + } + }, { + key: 'reduceForOfStatement', + value: function reduceForOfStatement(node, _ref33) { + var left = _ref33.left, + right = _ref33.right, + body = _ref33.body; + + left = node.left.type === 'VariableDeclaration' ? noIn(markContainsIn(left)) : left; + return (0, _objectAssign2.default)(seq(t('for'), paren(seq(left.startsWithLet ? paren(left) : left, t('of'), p(node.right, coderep.Precedence.Assignment, right))), body), { endsWithMissingElse: body.endsWithMissingElse }); + } + }, { + key: 'reduceForStatement', + value: function reduceForStatement(node, _ref34) { + var init = _ref34.init, + test = _ref34.test, + update = _ref34.update, + body = _ref34.body; + + if (init) { + if (init.startsWithLetSquareBracket) { + init = paren(init); + } + init = noIn(markContainsIn(init)); + } + return (0, _objectAssign2.default)(seq(t('for'), paren(seq(init ? init : empty(), semi(), test || empty(), semi(), update || empty())), body), { + endsWithMissingElse: body.endsWithMissingElse + }); + } + }, { + key: 'reduceForAwaitStatement', + value: function reduceForAwaitStatement(node, _ref35) { + var left = _ref35.left, + right = _ref35.right, + body = _ref35.body; + + left = node.left.type === 'VariableDeclaration' ? noIn(markContainsIn(left)) : left; + return (0, _objectAssign2.default)(seq(t('for'), t('await'), paren(seq(left.startsWithLet ? paren(left) : left, t('of'), p(node.right, coderep.Precedence.Assignment, right))), body), { endsWithMissingElse: body.endsWithMissingElse }); + } + }, { + key: 'reduceFunctionBody', + value: function reduceFunctionBody(node, _ref36) { + var directives = _ref36.directives, + statements = _ref36.statements; + + if (statements.length) { + statements[0] = this.parenToAvoidBeingDirective(node.statements[0], statements[0]); + } + return brace(seq.apply(undefined, _toConsumableArray(directives).concat(_toConsumableArray(statements)))); + } + }, { + key: 'reduceFunctionDeclaration', + value: function reduceFunctionDeclaration(node, _ref37) { + var name = _ref37.name, + params = _ref37.params, + body = _ref37.body; + + return seq(node.isAsync ? t('async') : empty(), t('function'), node.isGenerator ? t('*') : empty(), node.name.name === '*default*' ? empty() : name, params, body); + } + }, { + key: 'reduceFunctionExpression', + value: function reduceFunctionExpression(node, _ref38) { + var name = _ref38.name, + params = _ref38.params, + body = _ref38.body; + + var state = seq(node.isAsync ? t('async') : empty(), t('function'), node.isGenerator ? t('*') : empty(), name ? name : empty(), params, body); + state.startsWithFunctionOrClass = true; + return state; + } + }, { + key: 'reduceFormalParameters', + value: function reduceFormalParameters(node, _ref39) { + var items = _ref39.items, + rest = _ref39.rest; + + return paren(commaSep(items.concat(rest == null ? [] : [seq(t('...'), rest)]))); + } + }, { + key: 'reduceArrowExpression', + value: function reduceArrowExpression(node, _ref40) { + var params = _ref40.params, + body = _ref40.body; + + params = this.regenerateArrowParams(node.params, params); + var containsIn = false; + if (node.body.type !== 'FunctionBody') { + if (body.startsWithCurly) { + body = paren(body); + } else if (body.containsIn) { + containsIn = true; + } + } + return (0, _objectAssign2.default)(seq(node.isAsync ? t('async') : empty(), params, t('=>'), p(node.body, coderep.Precedence.Assignment, body)), { containsIn: containsIn }); + } + }, { + key: 'reduceGetter', + value: function reduceGetter(node, _ref41) { + var name = _ref41.name, + body = _ref41.body; + + return seq(t('get'), name, paren(empty()), body); + } + }, { + key: 'reduceIdentifierExpression', + value: function reduceIdentifierExpression(node) { + var a = t(node.name); + if (node.name === 'let') { + a.startsWithLet = true; + } + return a; + } + }, { + key: 'reduceIfStatement', + value: function reduceIfStatement(node, _ref42) { + var test = _ref42.test, + consequent = _ref42.consequent, + alternate = _ref42.alternate; + + if (alternate && consequent.endsWithMissingElse) { + consequent = brace(consequent); + } + return (0, _objectAssign2.default)(seq(t('if'), paren(test), consequent, alternate ? seq(t('else'), alternate) : empty()), { endsWithMissingElse: alternate ? alternate.endsWithMissingElse : true }); + } + }, { + key: 'reduceImport', + value: function reduceImport(node, _ref43) { + var defaultBinding = _ref43.defaultBinding, + namedImports = _ref43.namedImports; + + var bindings = []; + if (defaultBinding != null) { + bindings.push(defaultBinding); + } + if (namedImports.length > 0) { + bindings.push(brace(commaSep(namedImports))); + } + if (bindings.length === 0) { + return seq(t('import'), t((0, coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp()); + } + return seq(t('import'), commaSep(bindings), t('from'), t((0, coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp()); + } + }, { + key: 'reduceImportNamespace', + value: function reduceImportNamespace(node, _ref44) { + var defaultBinding = _ref44.defaultBinding, + namespaceBinding = _ref44.namespaceBinding; + + return seq(t('import'), defaultBinding == null ? empty() : seq(defaultBinding, t(',')), t('*'), t('as'), namespaceBinding, t('from'), t((0, coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp()); + } + }, { + key: 'reduceImportSpecifier', + value: function reduceImportSpecifier(node, _ref45) { + var binding = _ref45.binding; + + if (node.name == null) return binding; + return seq(t(node.name), t('as'), binding); + } + }, { + key: 'reduceExportAllFrom', + value: function reduceExportAllFrom(node) { + return seq(t('export'), t('*'), t('from'), t((0, coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp()); + } + }, { + key: 'reduceExportFrom', + value: function reduceExportFrom(node, _ref46) { + var namedExports = _ref46.namedExports; + + return seq(t('export'), brace(commaSep(namedExports)), t('from'), t((0, coderep.escapeStringLiteral)(node.moduleSpecifier)), semiOp()); + } + }, { + key: 'reduceExportLocals', + value: function reduceExportLocals(node, _ref47) { + var namedExports = _ref47.namedExports; + + return seq(t('export'), brace(commaSep(namedExports)), semiOp()); + } + }, { + key: 'reduceExport', + value: function reduceExport(node, _ref48) { + var declaration = _ref48.declaration; + + switch (node.declaration.type) { + case 'FunctionDeclaration': + case 'ClassDeclaration': + break; + default: + declaration = seq(declaration, semiOp()); + } + return seq(t('export'), declaration); + } + }, { + key: 'reduceExportDefault', + value: function reduceExportDefault(node, _ref49) { + var body = _ref49.body; + + body = body.startsWithFunctionOrClass ? paren(body) : body; + switch (node.body.type) { + case 'FunctionDeclaration': + case 'ClassDeclaration': + return seq(t('export default'), body); + default: + return seq(t('export default'), p(node.body, coderep.Precedence.Assignment, body), semiOp()); + } + } + }, { + key: 'reduceExportFromSpecifier', + value: function reduceExportFromSpecifier(node) { + if (node.exportedName == null) return t(node.name); + return seq(t(node.name), t('as'), t(node.exportedName)); + } + }, { + key: 'reduceExportLocalSpecifier', + value: function reduceExportLocalSpecifier(node, _ref50) { + var name = _ref50.name; + + if (node.exportedName == null) return name; + return seq(name, t('as'), t(node.exportedName)); + } + }, { + key: 'reduceLabeledStatement', + value: function reduceLabeledStatement(node, _ref51) { + var body = _ref51.body; + + return (0, _objectAssign2.default)(seq(t(node.label + ':'), body), { endsWithMissingElse: body.endsWithMissingElse }); + } + }, { + key: 'reduceLiteralBooleanExpression', + value: function reduceLiteralBooleanExpression(node) { + return t(node.value.toString()); + } + }, { + key: 'reduceLiteralNullExpression', + value: function reduceLiteralNullExpression() /* node */{ + return t('null'); + } + }, { + key: 'reduceLiteralInfinityExpression', + value: function reduceLiteralInfinityExpression() /* node */{ + return t('2e308'); + } + }, { + key: 'reduceLiteralNumericExpression', + value: function reduceLiteralNumericExpression(node) { + return new coderep.NumberCodeRep(node.value); + } + }, { + key: 'reduceLiteralRegExpExpression', + value: function reduceLiteralRegExpExpression(node) { + return t('/' + node.pattern + '/' + (node.global ? 'g' : '') + (node.ignoreCase ? 'i' : '') + (node.multiLine ? 'm' : '') + (node.dotAll ? 's' : '') + (node.unicode ? 'u' : '') + (node.sticky ? 'y' : ''), true); + } + }, { + key: 'reduceLiteralStringExpression', + value: function reduceLiteralStringExpression(node) { + return t((0, coderep.escapeStringLiteral)(node.value)); + } + }, { + key: 'reduceMethod', + value: function reduceMethod(node, _ref52) { + var name = _ref52.name, + params = _ref52.params, + body = _ref52.body; + + return seq(node.isAsync ? t('async') : empty(), node.isGenerator ? t('*') : empty(), name, params, body); + } + }, { + key: 'reduceModule', + value: function reduceModule(node, _ref53) { + var directives = _ref53.directives, + items = _ref53.items; + + if (items.length) { + items[0] = this.parenToAvoidBeingDirective(node.items[0], items[0]); + } + return seq.apply(undefined, _toConsumableArray(directives).concat(_toConsumableArray(items))); + } + }, { + key: 'reduceNewExpression', + value: function reduceNewExpression(node, _ref54) { + var callee = _ref54.callee, + args = _ref54.arguments; + + var parenthizedArgs = args.map(function (a, i) { + return p(node.arguments[i], coderep.Precedence.Assignment, a); + }); + var calleeRep = (0, coderep.getPrecedence)(node.callee) === coderep.Precedence.Call ? paren(callee) : p(node.callee, (0, coderep.getPrecedence)(node), callee); + return seq(t('new'), calleeRep, args.length === 0 ? empty() : paren(commaSep(parenthizedArgs))); + } + }, { + key: 'reduceNewTargetExpression', + value: function reduceNewTargetExpression() { + return t('new.target'); + } + }, { + key: 'reduceObjectExpression', + value: function reduceObjectExpression(node, _ref55) { + var properties = _ref55.properties; + + var state = brace(commaSep(properties)); + state.startsWithCurly = true; + return state; + } + }, { + key: 'reduceUpdateExpression', + value: function reduceUpdateExpression(node, _ref56) { + var operand = _ref56.operand; + + if (node.isPrefix) { + return this.reduceUnaryExpression.apply(this, arguments); + } + return (0, _objectAssign2.default)(seq(p(node.operand, coderep.Precedence.New, operand), t(node.operator)), { + startsWithCurly: operand.startsWithCurly, + startsWithLetSquareBracket: operand.startsWithLetSquareBracket, + startsWithFunctionOrClass: operand.startsWithFunctionOrClass + }); + } + }, { + key: 'reduceUnaryExpression', + value: function reduceUnaryExpression(node, _ref57) { + var operand = _ref57.operand; + + return seq(t(node.operator), p(node.operand, (0, coderep.getPrecedence)(node), operand)); + } + }, { + key: 'reduceReturnStatement', + value: function reduceReturnStatement(node, _ref58) { + var expression = _ref58.expression; + + return seq(t('return'), expression || empty(), semiOp()); + } + }, { + key: 'reduceScript', + value: function reduceScript(node, _ref59) { + var directives = _ref59.directives, + statements = _ref59.statements; + + if (statements.length) { + statements[0] = this.parenToAvoidBeingDirective(node.statements[0], statements[0]); + } + return seq.apply(undefined, _toConsumableArray(directives).concat(_toConsumableArray(statements))); + } + }, { + key: 'reduceSetter', + value: function reduceSetter(node, _ref60) { + var name = _ref60.name, + param = _ref60.param, + body = _ref60.body; + + return seq(t('set'), name, paren(param), body); + } + }, { + key: 'reduceShorthandProperty', + value: function reduceShorthandProperty(node, _ref61) { + var name = _ref61.name; + + return name; + } + }, { + key: 'reduceStaticMemberAssignmentTarget', + value: function reduceStaticMemberAssignmentTarget(node, _ref62) { + var object = _ref62.object; + + var state = seq(p(node.object, (0, coderep.getPrecedence)(node), object), t('.'), t(node.property)); + state.startsWithLet = object.startsWithLet; + state.startsWithCurly = object.startsWithCurly; + state.startsWithLetSquareBracket = object.startsWithLetSquareBracket; + state.startsWithFunctionOrClass = object.startsWithFunctionOrClass; + return state; + } + }, { + key: 'reduceStaticMemberExpression', + value: function reduceStaticMemberExpression(node, _ref63) { + var object = _ref63.object; + + var state = seq(p(node.object, (0, coderep.getPrecedence)(node), object), t('.'), t(node.property)); + state.startsWithLet = object.startsWithLet; + state.startsWithCurly = object.startsWithCurly; + state.startsWithLetSquareBracket = object.startsWithLetSquareBracket; + state.startsWithFunctionOrClass = object.startsWithFunctionOrClass; + return state; + } + }, { + key: 'reduceStaticPropertyName', + value: function reduceStaticPropertyName(node) { + if (utils.keyword.isIdentifierNameES6(node.value)) { + return t(node.value); + } + var n = parseFloat(node.value); + if (n >= 0 && n.toString() === node.value) { + return new coderep.NumberCodeRep(n); + } + return t((0, coderep.escapeStringLiteral)(node.value)); + } + }, { + key: 'reduceSuper', + value: function reduceSuper() { + return t('super'); + } + }, { + key: 'reduceSwitchCase', + value: function reduceSwitchCase(node, _ref64) { + var test = _ref64.test, + consequent = _ref64.consequent; + + return seq(t('case'), test, t(':'), seq.apply(undefined, _toConsumableArray(consequent))); + } + }, { + key: 'reduceSwitchDefault', + value: function reduceSwitchDefault(node, _ref65) { + var consequent = _ref65.consequent; + + return seq(t('default:'), seq.apply(undefined, _toConsumableArray(consequent))); + } + }, { + key: 'reduceSwitchStatement', + value: function reduceSwitchStatement(node, _ref66) { + var discriminant = _ref66.discriminant, + cases = _ref66.cases; + + return seq(t('switch'), paren(discriminant), brace(seq.apply(undefined, _toConsumableArray(cases)))); + } + }, { + key: 'reduceSwitchStatementWithDefault', + value: function reduceSwitchStatementWithDefault(node, _ref67) { + var discriminant = _ref67.discriminant, + preDefaultCases = _ref67.preDefaultCases, + defaultCase = _ref67.defaultCase, + postDefaultCases = _ref67.postDefaultCases; + + return seq(t('switch'), paren(discriminant), brace(seq.apply(undefined, _toConsumableArray(preDefaultCases).concat([defaultCase], _toConsumableArray(postDefaultCases))))); + } + }, { + key: 'reduceTemplateExpression', + value: function reduceTemplateExpression(node, _ref68) { + var tag = _ref68.tag, + elements = _ref68.elements; + + var state = node.tag == null ? empty() : p(node.tag, (0, coderep.getPrecedence)(node), tag); + state = seq(state, t('`')); + for (var i = 0, l = node.elements.length; i < l; ++i) { + if (node.elements[i].type === 'TemplateElement') { + state = seq(state, i > 0 ? t('}') : empty(), elements[i], i < l - 1 ? t('${') : empty()); + } else { + state = seq(state, elements[i]); + } + } + state = seq(state, t('`')); + if (node.tag != null) { + state.startsWithCurly = tag.startsWithCurly; + state.startsWithLet = tag.startsWithLet; + state.startsWithLetSquareBracket = tag.startsWithLetSquareBracket; + state.startsWithFunctionOrClass = tag.startsWithFunctionOrClass; + } + return state; + } + }, { + key: 'reduceTemplateElement', + value: function reduceTemplateElement(node) { + return new coderep.RawToken(node.rawValue); + } + }, { + key: 'reduceThisExpression', + value: function reduceThisExpression() /* node */{ + return t('this'); + } + }, { + key: 'reduceThrowStatement', + value: function reduceThrowStatement(node, _ref69) { + var expression = _ref69.expression; + + return seq(t('throw'), expression, semiOp()); + } + }, { + key: 'reduceTryCatchStatement', + value: function reduceTryCatchStatement(node, _ref70) { + var body = _ref70.body, + catchClause = _ref70.catchClause; + + return seq(t('try'), body, catchClause); + } + }, { + key: 'reduceTryFinallyStatement', + value: function reduceTryFinallyStatement(node, _ref71) { + var body = _ref71.body, + catchClause = _ref71.catchClause, + finalizer = _ref71.finalizer; + + return seq(t('try'), body, catchClause || empty(), t('finally'), finalizer); + } + }, { + key: 'reduceYieldExpression', + value: function reduceYieldExpression(node, _ref72) { + var expression = _ref72.expression; + + if (node.expression == null) return t('yield'); + return (0, _objectAssign2.default)(seq(t('yield'), p(node.expression, (0, coderep.getPrecedence)(node), expression)), { containsIn: expression.containsIn }); + } + }, { + key: 'reduceYieldGeneratorExpression', + value: function reduceYieldGeneratorExpression(node, _ref73) { + var expression = _ref73.expression; + + return (0, _objectAssign2.default)(seq(t('yield'), t('*'), p(node.expression, (0, coderep.getPrecedence)(node), expression)), { containsIn: expression.containsIn }); + } + }, { + key: 'reduceDirective', + value: function reduceDirective(node) { + var delim = node.rawValue.match(/(^|[^\\])(\\\\)*"/) ? '\'' : '"'; + return seq(t(delim + node.rawValue + delim), semiOp()); + } + }, { + key: 'reduceVariableDeclaration', + value: function reduceVariableDeclaration(node, _ref74) { + var declarators = _ref74.declarators; + + return seq(t(node.kind), commaSep(declarators)); + } + }, { + key: 'reduceVariableDeclarationStatement', + value: function reduceVariableDeclarationStatement(node, _ref75) { + var declaration = _ref75.declaration; + + return seq(declaration, semiOp()); + } + }, { + key: 'reduceVariableDeclarator', + value: function reduceVariableDeclarator(node, _ref76) { + var binding = _ref76.binding, + init = _ref76.init; + + var containsIn = init && init.containsIn && !init.containsGroup; + if (init) { + if (init.containsGroup) { + init = paren(init); + } else { + init = markContainsIn(init); + } + } + return (0, _objectAssign2.default)(init == null ? binding : seq(binding, t('='), init), { containsIn: containsIn }); + } + }, { + key: 'reduceWhileStatement', + value: function reduceWhileStatement(node, _ref77) { + var test = _ref77.test, + body = _ref77.body; + + return (0, _objectAssign2.default)(seq(t('while'), paren(test), body), { endsWithMissingElse: body.endsWithMissingElse }); + } + }, { + key: 'reduceWithStatement', + value: function reduceWithStatement(node, _ref78) { + var object = _ref78.object, + body = _ref78.body; + + return (0, _objectAssign2.default)(seq(t('with'), paren(object), body), { endsWithMissingElse: body.endsWithMissingElse }); + } + }]); + + return MinimalCodeGen; +}(); + +exports.default = MinimalCodeGen; +}); + +var formattedCodegen = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.FormattedCodeGen = exports.ExtensibleCodeGen = exports.Sep = undefined; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + + +var _objectAssign2 = _interopRequireDefault(objectAssign); + + + + + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var INDENT = ' '; + +var Linebreak = function (_CodeRep) { + _inherits(Linebreak, _CodeRep); + + function Linebreak() { + _classCallCheck(this, Linebreak); + + var _this = _possibleConstructorReturn(this, (Linebreak.__proto__ || Object.getPrototypeOf(Linebreak)).call(this)); + + _this.indentation = 0; + return _this; + } + + _createClass(Linebreak, [{ + key: 'emit', + value: function emit(ts) { + ts.put('\n'); + for (var i = 0; i < this.indentation; ++i) { + ts.put(INDENT); + } + } + }]); + + return Linebreak; +}(coderep.CodeRep); + +function empty() { + return new coderep.Empty(); +} + +function noIn(rep) { + return new coderep.NoIn(rep); +} + +function markContainsIn(state) { + return state.containsIn ? new coderep.ContainsIn(state) : state; +} + +function seq() { + for (var _len = arguments.length, reps = Array(_len), _key = 0; _key < _len; _key++) { + reps[_key] = arguments[_key]; + } + + return new coderep.Seq(reps); +} + +function isEmpty(codeRep) { + return codeRep instanceof coderep.Empty || codeRep instanceof Linebreak || codeRep instanceof coderep.Seq && codeRep.children.every(isEmpty); +} + +var Sep = {}; +var separatorNames = ['ARRAY_EMPTY', 'ARRAY_BEFORE_COMMA', 'ARRAY_AFTER_COMMA', 'SPREAD', 'AWAIT', 'AFTER_FORAWAIT_AWAIT', 'BEFORE_DEFAULT_EQUALS', 'AFTER_DEFAULT_EQUALS', 'REST', 'OBJECT_BEFORE_COMMA', 'OBJECT_AFTER_COMMA', 'BEFORE_PROP', 'AFTER_PROP', 'BEFORE_JUMP_LABEL', 'ARGS_BEFORE_COMMA', 'ARGS_AFTER_COMMA', 'CALL', 'BEFORE_CATCH_BINDING', 'AFTER_CATCH_BINDING', 'BEFORE_CLASS_NAME', 'BEFORE_EXTENDS', 'AFTER_EXTENDS', 'BEFORE_CLASS_DECLARATION_ELEMENTS', 'BEFORE_CLASS_EXPRESSION_ELEMENTS', 'AFTER_STATIC', 'BEFORE_CLASS_ELEMENT', 'AFTER_CLASS_ELEMENT', 'BEFORE_TERNARY_QUESTION', 'AFTER_TERNARY_QUESTION', 'BEFORE_TERNARY_COLON', 'AFTER_TERNARY_COLON', 'COMPUTED_MEMBER_EXPRESSION', 'COMPUTED_MEMBER_ASSIGNMENT_TARGET', 'AFTER_DO', 'BEFORE_DOWHILE_WHILE', 'AFTER_DOWHILE_WHILE', 'AFTER_FORIN_FOR', 'BEFORE_FORIN_IN', 'AFTER_FORIN_FOR', 'BEFORE_FORIN_BODY', 'AFTER_FOROF_FOR', 'BEFORE_FOROF_OF', 'AFTER_FOROF_FOR', 'BEFORE_FOROF_BODY', 'AFTER_FOR_FOR', 'BEFORE_FOR_INIT', 'AFTER_FOR_INIT', 'EMPTY_FOR_INIT', 'BEFORE_FOR_TEST', 'AFTER_FOR_TEST', 'EMPTY_FOR_TEST', 'BEFORE_FOR_UPDATE', 'AFTER_FOR_UPDATE', 'EMPTY_FOR_UPDATE', 'BEFORE_FOR_BODY', 'BEFORE_GENERATOR_STAR', 'AFTER_GENERATOR_STAR', 'BEFORE_FUNCTION_PARAMS', 'BEFORE_FUNCTION_DECLARATION_BODY', 'BEFORE_FUNCTION_EXPRESSION_BODY', 'AFTER_FUNCTION_DIRECTIVES', 'BEFORE_ARROW', 'AFTER_ARROW', 'AFTER_GET', 'BEFORE_GET_PARAMS', 'BEFORE_GET_BODY', 'AFTER_IF', 'AFTER_IF_TEST', 'BEFORE_ELSE', 'AFTER_ELSE', 'PARAMETER_BEFORE_COMMA', 'PARAMETER_AFTER_COMMA', 'NAMED_IMPORT_BEFORE_COMMA', 'NAMED_IMPORT_AFTER_COMMA', 'IMPORT_BEFORE_COMMA', 'IMPORT_AFTER_COMMA', 'BEFORE_IMPORT_BINDINGS', 'BEFORE_IMPORT_MODULE', 'AFTER_IMPORT_BINDINGS', 'AFTER_FROM', 'BEFORE_IMPORT_NAMESPACE', 'BEFORE_IMPORT_STAR', 'AFTER_IMPORT_STAR', 'AFTER_IMPORT_AS', 'AFTER_NAMESPACE_BINDING', 'BEFORE_IMPORT_AS', 'AFTER_IMPORT_AS', 'EXPORTS_BEFORE_COMMA', 'EXPORTS_AFTER_COMMA', 'BEFORE_EXPORT_STAR', 'AFTER_EXPORT_STAR', 'BEFORE_EXPORT_BINDINGS', 'AFTER_EXPORT_FROM_BINDINGS', 'AFTER_EXPORT_LOCAL_BINDINGS', 'AFTER_EXPORT', 'EXPORT_DEFAULT', 'AFTER_EXPORT_DEFAULT', 'BEFORE_EXPORT_AS', 'AFTER_EXPORT_AS', 'BEFORE_LABEL_COLON', 'AFTER_LABEL_COLON', 'AFTER_METHOD_GENERATOR_STAR', 'AFTER_METHOD_ASYNC', 'AFTER_METHOD_NAME', 'BEFORE_METHOD_BODY', 'AFTER_MODULE_DIRECTIVES', 'AFTER_NEW', 'BEFORE_NEW_ARGS', 'EMPTY_NEW_CALL', 'NEW_TARGET_BEFORE_DOT', 'NEW_TARGET_AFTER_DOT', 'RETURN', 'AFTER_SET', 'BEFORE_SET_PARAMS', 'BEFORE_SET_BODY', 'AFTER_SCRIPT_DIRECTIVES', 'BEFORE_STATIC_MEMBER_DOT', 'AFTER_STATIC_MEMBER_DOT', 'BEFORE_STATIC_MEMBER_ASSIGNMENT_TARGET_DOT', 'AFTER_STATIC_MEMBER_ASSIGNMENT_TARGET_DOT', 'BEFORE_CASE_TEST', 'AFTER_CASE_TEST', 'BEFORE_CASE_BODY', 'AFTER_CASE_BODY', 'DEFAULT', 'AFTER_DEFAULT_BODY', 'BEFORE_SWITCH_DISCRIM', 'BEFORE_SWITCH_BODY', 'TEMPLATE_TAG', 'BEFORE_TEMPLATE_EXPRESSION', 'AFTER_TEMPLATE_EXPRESSION', 'THROW', 'AFTER_TRY', 'BEFORE_CATCH', 'BEFORE_FINALLY', 'AFTER_FINALLY', 'VARIABLE_DECLARATION', 'YIELD', 'BEFORE_YIELD_STAR', 'AFTER_YIELD_STAR', 'DECLARATORS_BEFORE_COMMA', 'DECLARATORS_AFTER_COMMA', 'BEFORE_INIT_EQUALS', 'AFTER_INIT_EQUALS', 'AFTER_WHILE', 'BEFORE_WHILE_BODY', 'AFTER_WITH', 'BEFORE_WITH_BODY', 'PAREN_AVOIDING_DIRECTIVE_BEFORE', 'PAREN_AVOIDING_DIRECTIVE_AFTER', 'PRECEDENCE_BEFORE', 'PRECEDENCE_AFTER', 'EXPRESSION_PAREN_BEFORE', 'EXPRESSION_PAREN_AFTER', 'CALL_PAREN_BEFORE', 'CALL_PAREN_AFTER', 'CALL_PAREN_EMPTY', 'CATCH_PAREN_BEFORE', 'CATCH_PAREN_AFTER', 'DO_WHILE_TEST_PAREN_BEFORE', 'DO_WHILE_TEST_PAREN_AFTER', 'EXPRESSION_STATEMENT_PAREN_BEFORE', 'EXPRESSION_STATEMENT_PAREN_AFTER', 'FOR_LET_PAREN_BEFORE', 'FOR_LET_PAREN_AFTER', 'FOR_IN_LET_PAREN_BEFORE', 'FOR_IN_LET_PAREN_AFTER', 'FOR_IN_PAREN_BEFORE', 'FOR_IN_PAREN_AFTER', 'FOR_OF_LET_PAREN_BEFORE', 'FOR_OF_LET_PAREN_AFTER', 'FOR_OF_PAREN_BEFORE', 'FOR_OF_PAREN_AFTER', 'PARAMETERS_PAREN_BEFORE', 'PARAMETERS_PAREN_AFTER', 'PARAMETERS_PAREN_EMPTY', 'ARROW_PARAMETERS_PAREN_BEFORE', 'ARROW_PARAMETERS_PAREN_AFTER', 'ARROW_PARAMETERS_PAREN_EMPTY', 'ARROW_BODY_PAREN_BEFORE', 'ARROW_BODY_PAREN_AFTER', 'BEFORE_ARROW_ASYNC_PARAMS', 'GETTER_PARAMS', 'IF_PAREN_BEFORE', 'IF_PAREN_AFTER', 'EXPORT_PAREN_BEFORE', 'EXPORT_PAREN_AFTER', 'NEW_CALLEE_PAREN_BEFORE', 'NEW_CALLEE_PAREN_AFTER', 'NEW_PAREN_BEFORE', 'NEW_PAREN_AFTER', 'NEW_PAREN_EMPTY', 'SETTER_PARAM_BEFORE', 'SETTER_PARAM_AFTER', 'SWITCH_DISCRIM_PAREN_BEFORE', 'SWITCH_DISCRIM_PAREN_AFTER', 'WHILE_TEST_PAREN_BEFORE', 'WHILE_TEST_PAREN_AFTER', 'WITH_PAREN_BEFORE', 'WITH_PAREN_AFTER', 'OBJECT_BRACE_INITIAL', 'OBJECT_BRACE_FINAL', 'OBJECT_EMPTY', 'BLOCK_BRACE_INITIAL', 'BLOCK_BRACE_FINAL', 'BLOCK_EMPTY', 'CLASS_BRACE_INITIAL', 'CLASS_BRACE_FINAL', 'CLASS_EMPTY', 'CLASS_EXPRESSION_BRACE_INITIAL', 'CLASS_EXPRESSION_BRACE_FINAL', 'CLASS_EXPRESSION_BRACE_EMPTY', 'FUNCTION_BRACE_INITIAL', 'FUNCTION_BRACE_FINAL', 'FUNCTION_EMPTY', 'FUNCTION_EXPRESSION_BRACE_INITIAL', 'FUNCTION_EXPRESSION_BRACE_FINAL', 'FUNCTION_EXPRESSION_EMPTY', 'ARROW_BRACE_INITIAL', 'ARROW_BRACE_FINAL', 'ARROW_BRACE_EMPTY', 'GET_BRACE_INTIAL', 'GET_BRACE_FINAL', 'GET_BRACE_EMPTY', 'MISSING_ELSE_INTIIAL', 'MISSING_ELSE_FINAL', 'MISSING_ELSE_EMPTY', 'IMPORT_BRACE_INTIAL', 'IMPORT_BRACE_FINAL', 'IMPORT_BRACE_EMPTY', 'EXPORT_BRACE_INITIAL', 'EXPORT_BRACE_FINAL', 'EXPORT_BRACE_EMPTY', 'METHOD_BRACE_INTIAL', 'METHOD_BRACE_FINAL', 'METHOD_BRACE_EMPTY', 'SET_BRACE_INTIIAL', 'SET_BRACE_FINAL', 'SET_BRACE_EMPTY', 'SWITCH_BRACE_INTIAL', 'SWITCH_BRACE_FINAL', 'SWITCH_BRACE_EMPTY', 'ARRAY_INITIAL', 'ARRAY_FINAL', 'COMPUTED_MEMBER_BRACKET_INTIAL', 'COMPUTED_MEMBER_BRACKET_FINAL', 'COMPUTED_MEMBER_ASSIGNMENT_TARGET_BRACKET_INTIAL', 'COMPUTED_MEMBER_ASSIGNMENT_TARGET_BRACKET_FINAL', 'COMPUTED_PROPERTY_BRACKET_INTIAL', 'COMPUTED_PROPERTY_BRACKET_FINAL']; +for (var i = 0; i < separatorNames.length; ++i) { + Sep[separatorNames[i]] = { type: separatorNames[i] }; +} + +Sep.BEFORE_ASSIGN_OP = function (op) { + return { + type: 'BEFORE_ASSIGN_OP', + op: op + }; +}; + +Sep.AFTER_ASSIGN_OP = function (op) { + return { + type: 'AFTER_ASSIGN_OP', + op: op + }; +}; + +Sep.BEFORE_BINOP = function (op) { + return { + type: 'BEFORE_BINOP', + op: op + }; +}; + +Sep.AFTER_BINOP = function (op) { + return { + type: 'AFTER_BINOP', + op: op + }; +}; + +Sep.BEFORE_POSTFIX = function (op) { + return { + type: 'BEFORE_POSTFIX', + op: op + }; +}; + +Sep.UNARY = function (op) { + return { + type: 'UNARY', + op: op + }; +}; + +Sep.AFTER_STATEMENT = function (node) { + return { + type: 'AFTER_STATEMENT', + node: node + }; +}; + +Sep.BEFORE_FUNCTION_NAME = function (node) { + return { + type: 'BEFORE_FUNCTION_NAME', + node: node + }; +}; +exports.Sep = Sep; + +var ExtensibleCodeGen = exports.ExtensibleCodeGen = function () { + function ExtensibleCodeGen() { + _classCallCheck(this, ExtensibleCodeGen); + } + + _createClass(ExtensibleCodeGen, [{ + key: 'parenToAvoidBeingDirective', + value: function parenToAvoidBeingDirective(element, original) { + if (element && element.type === 'ExpressionStatement' && element.expression.type === 'LiteralStringExpression') { + return seq(this.paren(original.children[0], Sep.PAREN_AVOIDING_DIRECTIVE_BEFORE, Sep.PAREN_AVOIDING_DIRECTIVE_AFTER), this.semiOp()); + } + return original; + } + }, { + key: 't', + value: function t(token) { + var isRegExp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + return new coderep.Token(token, isRegExp); + } + }, { + key: 'p', + value: function p(node, precedence, a) { + return (0, coderep.getPrecedence)(node) < precedence ? this.paren(a, Sep.PRECEDENCE_BEFORE, Sep.PRECEDENCE_AFTER) : a; + } + }, { + key: 'getAssignmentExpr', + value: function getAssignmentExpr(state) { + return state ? state.containsGroup ? this.paren(state, Sep.EXPRESSION_PAREN_BEFORE, Sep.EXPRESSION_PAREN_AFTER) : state : empty(); + } + }, { + key: 'paren', + value: function paren(rep, first, last, emptySep) { + if (isEmpty(rep)) { + return new coderep.Paren(this.sep(emptySep)); + } + return new coderep.Paren(seq(first ? this.sep(first) : empty(), rep, last ? this.sep(last) : empty())); + } + }, { + key: 'brace', + value: function brace(rep, node, first, last, emptySep) { + if (isEmpty(rep)) { + return new coderep.Brace(this.sep(emptySep)); + } + return new coderep.Brace(seq(this.sep(first), rep, this.sep(last))); + } + }, { + key: 'bracket', + value: function bracket(rep, first, last, emptySep) { + if (isEmpty(rep)) { + return new coderep.Bracket(this.sep(emptySep)); + } + return new coderep.Bracket(seq(this.sep(first), rep, this.sep(last))); + } + }, { + key: 'commaSep', + value: function commaSep(pieces, before, after) { + var _this2 = this; + + var first = true; + pieces = pieces.map(function (p) { + if (first) { + first = false; + return p; + } + return seq(_this2.sep(before), _this2.t(','), _this2.sep(after), p); + }); + return seq.apply(undefined, _toConsumableArray(pieces)); + } + }, { + key: 'semiOp', + value: function semiOp() { + return new coderep.SemiOp(); + } + }, { + key: 'sep', + value: function sep() /* kind */{ + return empty(); + } + }, { + key: 'reduceArrayExpression', + value: function reduceArrayExpression(node, _ref) { + var _this3 = this; + + var elements = _ref.elements; + + if (elements.length === 0) { + return this.bracket(empty(), null, null, Sep.ARRAY_EMPTY); + } + + var content = this.commaSep(elements.map(function (e) { + return _this3.getAssignmentExpr(e); + }), Sep.ARRAY_BEFORE_COMMA, Sep.ARRAY_AFTER_COMMA); + if (elements.length > 0 && elements[elements.length - 1] == null) { + content = seq(content, this.sep(Sep.ARRAY_BEFORE_COMMA), this.t(','), this.sep(Sep.ARRAY_AFTER_COMMA)); + } + return this.bracket(content, Sep.ARRAY_INITIAL, Sep.ARRAY_FINAL); + } + }, { + key: 'reduceAwaitExpression', + value: function reduceAwaitExpression(node, _ref2) { + var expression = _ref2.expression; + + return seq(this.t('await'), this.sep(Sep.AWAIT), this.p(node.expression, (0, coderep.getPrecedence)(node), expression)); + } + }, { + key: 'reduceSpreadElement', + value: function reduceSpreadElement(node, _ref3) { + var expression = _ref3.expression; + + return seq(this.t('...'), this.sep(Sep.SPREAD), this.p(node.expression, coderep.Precedence.Assignment, expression)); + } + }, { + key: 'reduceSpreadProperty', + value: function reduceSpreadProperty(node, _ref4) { + var expression = _ref4.expression; + + return seq(this.t('...'), this.sep(Sep.SPREAD), this.getAssignmentExpr(expression)); + } + }, { + key: 'reduceAssignmentExpression', + value: function reduceAssignmentExpression(node, _ref5) { + var binding = _ref5.binding, + expression = _ref5.expression; + + var leftCode = binding; + var rightCode = expression; + var containsIn = expression.containsIn; + var startsWithCurly = binding.startsWithCurly; + var startsWithLetSquareBracket = binding.startsWithLetSquareBracket; + var startsWithFunctionOrClass = binding.startsWithFunctionOrClass; + if ((0, coderep.getPrecedence)(node.expression) < (0, coderep.getPrecedence)(node)) { + rightCode = this.paren(rightCode, Sep.EXPRESSION_PAREN_BEFORE, Sep.EXPRESSION_PAREN_AFTER); + containsIn = false; + } + return (0, _objectAssign2.default)(seq(leftCode, this.sep(Sep.BEFORE_ASSIGN_OP('=')), this.t('='), this.sep(Sep.AFTER_ASSIGN_OP('=')), rightCode), { containsIn: containsIn, startsWithCurly: startsWithCurly, startsWithLetSquareBracket: startsWithLetSquareBracket, startsWithFunctionOrClass: startsWithFunctionOrClass }); + } + }, { + key: 'reduceAssignmentTargetIdentifier', + value: function reduceAssignmentTargetIdentifier(node) { + var a = this.t(node.name); + if (node.name === 'let') { + a.startsWithLet = true; + } + return a; + } + }, { + key: 'reduceAssignmentTargetWithDefault', + value: function reduceAssignmentTargetWithDefault(node, _ref6) { + var binding = _ref6.binding, + init = _ref6.init; + + return seq(binding, this.sep(Sep.BEFORE_DEFAULT_EQUALS), this.t('='), this.sep(Sep.AFTER_DEFAULT_EQUALS), this.p(node.init, coderep.Precedence.Assignment, init)); + } + }, { + key: 'reduceCompoundAssignmentExpression', + value: function reduceCompoundAssignmentExpression(node, _ref7) { + var binding = _ref7.binding, + expression = _ref7.expression; + + var leftCode = binding; + var rightCode = expression; + var containsIn = expression.containsIn; + var startsWithCurly = binding.startsWithCurly; + var startsWithLetSquareBracket = binding.startsWithLetSquareBracket; + var startsWithFunctionOrClass = binding.startsWithFunctionOrClass; + if ((0, coderep.getPrecedence)(node.expression) < (0, coderep.getPrecedence)(node)) { + rightCode = this.paren(rightCode, Sep.EXPRESSION_PAREN_BEFORE, Sep.EXPRESSION_PAREN_AFTER); + containsIn = false; + } + return (0, _objectAssign2.default)(seq(leftCode, this.sep(Sep.BEFORE_ASSIGN_OP(node.operator)), this.t(node.operator), this.sep(Sep.AFTER_ASSIGN_OP(node.operator)), rightCode), { containsIn: containsIn, startsWithCurly: startsWithCurly, startsWithLetSquareBracket: startsWithLetSquareBracket, startsWithFunctionOrClass: startsWithFunctionOrClass }); + } + }, { + key: 'reduceBinaryExpression', + value: function reduceBinaryExpression(node, _ref8) { + var left = _ref8.left, + right = _ref8.right; + + var leftCode = left; + var startsWithCurly = left.startsWithCurly; + var startsWithLetSquareBracket = left.startsWithLetSquareBracket; + var startsWithFunctionOrClass = left.startsWithFunctionOrClass; + var leftContainsIn = left.containsIn; + var isRightAssociative = node.operator === '**'; + if ((0, coderep.getPrecedence)(node.left) < (0, coderep.getPrecedence)(node) || isRightAssociative && ((0, coderep.getPrecedence)(node.left) === (0, coderep.getPrecedence)(node) || node.left.type === 'UnaryExpression')) { + leftCode = this.paren(leftCode, Sep.EXPRESSION_PAREN_BEFORE, Sep.EXPRESSION_PAREN_AFTER); + startsWithCurly = false; + startsWithLetSquareBracket = false; + startsWithFunctionOrClass = false; + leftContainsIn = false; + } + var rightCode = right; + var rightContainsIn = right.containsIn; + if ((0, coderep.getPrecedence)(node.right) < (0, coderep.getPrecedence)(node) || !isRightAssociative && (0, coderep.getPrecedence)(node.right) === (0, coderep.getPrecedence)(node)) { + rightCode = this.paren(rightCode, Sep.EXPRESSION_PAREN_BEFORE, Sep.EXPRESSION_PAREN_AFTER); + rightContainsIn = false; + } + return (0, _objectAssign2.default)(seq(leftCode, this.sep(Sep.BEFORE_BINOP(node.operator)), this.t(node.operator), this.sep(Sep.AFTER_BINOP(node.operator)), rightCode), { + containsIn: leftContainsIn || rightContainsIn || node.operator === 'in', + containsGroup: node.operator === ',', + startsWithCurly: startsWithCurly, + startsWithLetSquareBracket: startsWithLetSquareBracket, + startsWithFunctionOrClass: startsWithFunctionOrClass + }); + } + }, { + key: 'reduceBindingWithDefault', + value: function reduceBindingWithDefault(node, _ref9) { + var binding = _ref9.binding, + init = _ref9.init; + + return seq(binding, this.sep(Sep.BEFORE_DEFAULT_EQUALS), this.t('='), this.sep(Sep.AFTER_DEFAULT_EQUALS), this.p(node.init, coderep.Precedence.Assignment, init)); + } + }, { + key: 'reduceBindingIdentifier', + value: function reduceBindingIdentifier(node) { + var a = this.t(node.name); + if (node.name === 'let') { + a.startsWithLet = true; + } + return a; + } + }, { + key: 'reduceArrayAssignmentTarget', + value: function reduceArrayAssignmentTarget(node, _ref10) { + var _this4 = this; + + var elements = _ref10.elements, + rest = _ref10.rest; + + var content = void 0; + if (elements.length === 0) { + content = rest == null ? empty() : seq(this.t('...'), this.sep(Sep.REST), rest); + } else { + elements = elements.concat(rest == null ? [] : [seq(this.t('...'), this.sep(Sep.REST), rest)]); + content = this.commaSep(elements.map(function (e) { + return _this4.getAssignmentExpr(e); + }), Sep.ARRAY_BEFORE_COMMA, Sep.ARRAY_AFTER_COMMA); + if (elements.length > 0 && elements[elements.length - 1] == null) { + content = seq(content, this.sep(Sep.ARRAY_BEFORE_COMMA), this.t(','), this.sep(Sep.ARRAY_AFTER_COMMA)); + } + } + return this.bracket(content, Sep.ARRAY_INITIAL, Sep.ARRAY_FINAL, Sep.ARRAY_EMPTY); + } + }, { + key: 'reduceArrayBinding', + value: function reduceArrayBinding(node, _ref11) { + var _this5 = this; + + var elements = _ref11.elements, + rest = _ref11.rest; + + var content = void 0; + if (elements.length === 0) { + content = rest == null ? empty() : seq(this.t('...'), this.sep(Sep.REST), rest); + } else { + elements = elements.concat(rest == null ? [] : [seq(this.t('...'), this.sep(Sep.REST), rest)]); + content = this.commaSep(elements.map(function (e) { + return _this5.getAssignmentExpr(e); + }), Sep.ARRAY_BEFORE_COMMA, Sep.ARRAY_AFTER_COMMA); + if (elements.length > 0 && elements[elements.length - 1] == null) { + content = seq(content, this.sep(Sep.ARRAY_BEFORE_COMMA), this.t(','), this.sep(Sep.ARRAY_AFTER_COMMA)); + } + } + return this.bracket(content, Sep.ARRAY_INITIAL, Sep.ARRAY_FINAL, Sep.ARRAY_EMPTY); + } + }, { + key: 'reduceObjectAssignmentTarget', + value: function reduceObjectAssignmentTarget(node, _ref12) { + var properties = _ref12.properties, + rest = _ref12.rest; + + var content = void 0; + if (properties.length === 0) { + content = rest == null ? empty() : seq(this.t('...'), this.sep(Sep.REST), rest); + } else { + content = this.commaSep(properties, Sep.OBJECT_BEFORE_COMMA, Sep.OBJECT_AFTER_COMMA); + content = rest == null ? content : this.commaSep([content, seq(this.t('...'), this.sep(Sep.REST), rest)], Sep.OBJECT_BEFORE_COMMA, Sep.OBJECT_AFTER_COMMA); + } + var state = this.brace(content, node, Sep.OBJECT_BRACE_INITIAL, Sep.OBJECT_BRACE_FINAL, Sep.OBJECT_EMPTY); + state.startsWithCurly = true; + return state; + } + }, { + key: 'reduceObjectBinding', + value: function reduceObjectBinding(node, _ref13) { + var properties = _ref13.properties, + rest = _ref13.rest; + + var content = void 0; + if (properties.length === 0) { + content = rest == null ? empty() : seq(this.t('...'), this.sep(Sep.REST), rest); + } else { + content = this.commaSep(properties, Sep.OBJECT_BEFORE_COMMA, Sep.OBJECT_AFTER_COMMA); + content = rest == null ? content : this.commaSep([content, seq(this.t('...'), this.sep(Sep.REST), rest)], Sep.OBJECT_BEFORE_COMMA, Sep.OBJECT_AFTER_COMMA); + } + var state = this.brace(content, node, Sep.OBJECT_BRACE_INITIAL, Sep.OBJECT_BRACE_FINAL, Sep.OBJECT_EMPTY); + state.startsWithCurly = true; + return state; + } + }, { + key: 'reduceAssignmentTargetPropertyIdentifier', + value: function reduceAssignmentTargetPropertyIdentifier(node, _ref14) { + var binding = _ref14.binding, + init = _ref14.init; + + if (node.init == null) return binding; + return seq(binding, this.sep(Sep.BEFORE_DEFAULT_EQUALS), this.t('='), this.sep(Sep.AFTER_DEFAULT_EQUALS), this.p(node.init, coderep.Precedence.Assignment, init)); + } + }, { + key: 'reduceAssignmentTargetPropertyProperty', + value: function reduceAssignmentTargetPropertyProperty(node, _ref15) { + var name = _ref15.name, + binding = _ref15.binding; + + return seq(name, this.sep(Sep.BEFORE_PROP), this.t(':'), this.sep(Sep.AFTER_PROP), binding); + } + }, { + key: 'reduceBindingPropertyIdentifier', + value: function reduceBindingPropertyIdentifier(node, _ref16) { + var binding = _ref16.binding, + init = _ref16.init; + + if (node.init == null) return binding; + return seq(binding, this.sep(Sep.BEFORE_DEFAULT_EQUALS), this.t('='), this.sep(Sep.AFTER_DEFAULT_EQUALS), this.p(node.init, coderep.Precedence.Assignment, init)); + } + }, { + key: 'reduceBindingPropertyProperty', + value: function reduceBindingPropertyProperty(node, _ref17) { + var name = _ref17.name, + binding = _ref17.binding; + + return seq(name, this.sep(Sep.BEFORE_PROP), this.t(':'), this.sep(Sep.AFTER_PROP), binding); + } + }, { + key: 'reduceBlock', + value: function reduceBlock(node, _ref18) { + var statements = _ref18.statements; + + return this.brace(seq.apply(undefined, _toConsumableArray(statements)), node, Sep.BLOCK_BRACE_INITIAL, Sep.BLOCK_BRACE_FINAL, Sep.BLOCK_EMPTY); + } + }, { + key: 'reduceBlockStatement', + value: function reduceBlockStatement(node, _ref19) { + var block = _ref19.block; + + return seq(block, this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceBreakStatement', + value: function reduceBreakStatement(node) { + return seq(this.t('break'), node.label ? seq(this.sep(Sep.BEFORE_JUMP_LABEL), this.t(node.label)) : empty(), this.semiOp(), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceCallExpression', + value: function reduceCallExpression(node, _ref20) { + var _this6 = this; + + var callee = _ref20.callee, + args = _ref20.arguments; + + var parenthizedArgs = args.map(function (a, i) { + return _this6.p(node.arguments[i], coderep.Precedence.Assignment, a); + }); + return (0, _objectAssign2.default)(seq(this.p(node.callee, (0, coderep.getPrecedence)(node), callee), this.sep(Sep.CALL), this.paren(this.commaSep(parenthizedArgs, Sep.ARGS_BEFORE_COMMA, Sep.ARGS_AFTER_COMMA), Sep.CALL_PAREN_BEFORE, Sep.CALL_PAREN_AFTER, Sep.CALL_PAREN_EMPTY)), { + startsWithCurly: callee.startsWithCurly, + startsWithLet: callee.startsWithLet, + startsWithLetSquareBracket: callee.startsWithLetSquareBracket, + startsWithFunctionOrClass: callee.startsWithFunctionOrClass + }); + } + }, { + key: 'reduceCatchClause', + value: function reduceCatchClause(node, _ref21) { + var binding = _ref21.binding, + body = _ref21.body; + + return seq(this.t('catch'), this.sep(Sep.BEFORE_CATCH_BINDING), this.paren(binding, Sep.CATCH_PAREN_BEFORE, Sep.CATCH_PAREN_AFTER), this.sep(Sep.AFTER_CATCH_BINDING), body); + } + }, { + key: 'reduceClassDeclaration', + value: function reduceClassDeclaration(node, _ref22) { + var name = _ref22.name, + _super = _ref22.super, + elements = _ref22.elements; + + var state = seq(this.t('class'), node.name.name === '*default*' ? empty() : seq(this.sep(Sep.BEFORE_CLASS_NAME), name)); + if (_super != null) { + state = seq(state, this.sep(Sep.BEFORE_EXTENDS), this.t('extends'), this.sep(Sep.AFTER_EXTENDS), this.p(node.super, coderep.Precedence.New, _super)); + } + state = seq(state, this.sep(Sep.BEFORE_CLASS_DECLARATION_ELEMENTS), this.brace(seq.apply(undefined, _toConsumableArray(elements)), node, Sep.CLASS_BRACE_INITIAL, Sep.CLASS_BRACE_FINAL, Sep.CLASS_EMPTY), this.sep(Sep.AFTER_STATEMENT(node))); + return state; + } + }, { + key: 'reduceClassExpression', + value: function reduceClassExpression(node, _ref23) { + var name = _ref23.name, + _super = _ref23.super, + elements = _ref23.elements; + + var state = this.t('class'); + if (name != null) { + state = seq(state, this.sep(Sep.BEFORE_CLASS_NAME), name); + } + if (_super != null) { + state = seq(state, this.sep(Sep.BEFORE_EXTENDS), this.t('extends'), this.sep(Sep.AFTER_EXTENDS), this.p(node.super, coderep.Precedence.New, _super)); + } + state = seq(state, this.sep(Sep.BEFORE_CLASS_EXPRESSION_ELEMENTS), this.brace(seq.apply(undefined, _toConsumableArray(elements)), node, Sep.CLASS_EXPRESSION_BRACE_INITIAL, Sep.CLASS_EXPRESSION_BRACE_FINAL, Sep.CLASS_EXPRESSION_BRACE_EMPTY)); + state.startsWithFunctionOrClass = true; + return state; + } + }, { + key: 'reduceClassElement', + value: function reduceClassElement(node, _ref24) { + var method = _ref24.method; + + method = seq(this.sep(Sep.BEFORE_CLASS_ELEMENT), method, this.sep(Sep.AFTER_CLASS_ELEMENT)); + if (!node.isStatic) return method; + return seq(this.t('static'), this.sep(Sep.AFTER_STATIC), method); + } + }, { + key: 'reduceComputedMemberAssignmentTarget', + value: function reduceComputedMemberAssignmentTarget(node, _ref25) { + var object = _ref25.object, + expression = _ref25.expression; + + var startsWithLetSquareBracket = object.startsWithLetSquareBracket || node.object.type === 'IdentifierExpression' && node.object.name === 'let'; + return (0, _objectAssign2.default)(seq(this.p(node.object, (0, coderep.getPrecedence)(node), object), this.sep(Sep.COMPUTED_MEMBER_ASSIGNMENT_TARGET), this.bracket(expression, Sep.COMPUTED_MEMBER_ASSIGNMENT_TARGET_BRACKET_INTIAL, Sep.COMPUTED_MEMBER_ASSIGNMENT_TARGET_BRACKET_FINAL)), { + startsWithLet: object.startsWithLet, + startsWithLetSquareBracket: startsWithLetSquareBracket, + startsWithCurly: object.startsWithCurly, + startsWithFunctionOrClass: object.startsWithFunctionOrClass + }); + } + }, { + key: 'reduceComputedMemberExpression', + value: function reduceComputedMemberExpression(node, _ref26) { + var object = _ref26.object, + expression = _ref26.expression; + + var startsWithLetSquareBracket = object.startsWithLetSquareBracket || node.object.type === 'IdentifierExpression' && node.object.name === 'let'; + return (0, _objectAssign2.default)(seq(this.p(node.object, (0, coderep.getPrecedence)(node), object), this.sep(Sep.COMPUTED_MEMBER_EXPRESSION), this.bracket(expression, Sep.COMPUTED_MEMBER_BRACKET_INTIAL, Sep.COMPUTED_MEMBER_BRACKET_FINAL)), { + startsWithLet: object.startsWithLet, + startsWithLetSquareBracket: startsWithLetSquareBracket, + startsWithCurly: object.startsWithCurly, + startsWithFunctionOrClass: object.startsWithFunctionOrClass + }); + } + }, { + key: 'reduceComputedPropertyName', + value: function reduceComputedPropertyName(node, _ref27) { + var expression = _ref27.expression; + + return this.bracket(this.p(node.expression, coderep.Precedence.Assignment, expression), Sep.COMPUTED_PROPERTY_BRACKET_INTIAL, Sep.COMPUTED_PROPERTY_BRACKET_FINAL); + } + }, { + key: 'reduceConditionalExpression', + value: function reduceConditionalExpression(node, _ref28) { + var test = _ref28.test, + consequent = _ref28.consequent, + alternate = _ref28.alternate; + + var containsIn = test.containsIn || alternate.containsIn; + var startsWithCurly = test.startsWithCurly; + var startsWithLetSquareBracket = test.startsWithLetSquareBracket; + var startsWithFunctionOrClass = test.startsWithFunctionOrClass; + return (0, _objectAssign2.default)(seq(this.p(node.test, coderep.Precedence.LogicalOR, test), this.sep(Sep.BEFORE_TERNARY_QUESTION), this.t('?'), this.sep(Sep.AFTER_TERNARY_QUESTION), this.p(node.consequent, coderep.Precedence.Assignment, consequent), this.sep(Sep.BEFORE_TERNARY_COLON), this.t(':'), this.sep(Sep.AFTER_TERNARY_COLON), this.p(node.alternate, coderep.Precedence.Assignment, alternate)), { + containsIn: containsIn, + startsWithCurly: startsWithCurly, + startsWithLetSquareBracket: startsWithLetSquareBracket, + startsWithFunctionOrClass: startsWithFunctionOrClass + }); + } + }, { + key: 'reduceContinueStatement', + value: function reduceContinueStatement(node) { + return seq(this.t('continue'), node.label ? seq(this.sep(Sep.BEFORE_JUMP_LABEL), this.t(node.label)) : empty(), this.semiOp(), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceDataProperty', + value: function reduceDataProperty(node, _ref29) { + var name = _ref29.name, + expression = _ref29.expression; + + return seq(name, this.sep(Sep.BEFORE_PROP), this.t(':'), this.sep(Sep.AFTER_PROP), this.getAssignmentExpr(expression)); + } + }, { + key: 'reduceDebuggerStatement', + value: function reduceDebuggerStatement(node) { + return seq(this.t('debugger'), this.semiOp(), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceDoWhileStatement', + value: function reduceDoWhileStatement(node, _ref30) { + var body = _ref30.body, + test = _ref30.test; + + return seq(this.t('do'), this.sep(Sep.AFTER_DO), body, this.sep(Sep.BEFORE_DOWHILE_WHILE), this.t('while'), this.sep(Sep.AFTER_DOWHILE_WHILE), this.paren(test, Sep.DO_WHILE_TEST_PAREN_BEFORE, Sep.DO_WHILE_TEST_PAREN_AFTER), this.semiOp(), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceEmptyStatement', + value: function reduceEmptyStatement(node) { + return seq(this.t(';'), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceExpressionStatement', + value: function reduceExpressionStatement(node, _ref31) { + var expression = _ref31.expression; + + var needsParens = expression.startsWithCurly || expression.startsWithLetSquareBracket || expression.startsWithFunctionOrClass; + return seq(needsParens ? this.paren(expression, Sep.EXPRESSION_STATEMENT_PAREN_BEFORE, Sep.EXPRESSION_STATEMENT_PAREN_AFTER) : expression, this.semiOp(), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceForInStatement', + value: function reduceForInStatement(node, _ref32) { + var left = _ref32.left, + right = _ref32.right, + body = _ref32.body; + + left = node.left.type === 'VariableDeclaration' ? noIn(markContainsIn(left)) : left; + return (0, _objectAssign2.default)(seq(this.t('for'), this.sep(Sep.AFTER_FORIN_FOR), this.paren(seq(left.startsWithLet ? this.paren(left, Sep.FOR_IN_LET_PAREN_BEFORE, Sep.FOR_IN_LET_PAREN_AFTER) : left, this.sep(Sep.BEFORE_FORIN_IN), this.t('in'), this.sep(Sep.AFTER_FORIN_FOR), right), Sep.FOR_IN_PAREN_BEFORE, Sep.FOR_IN_PAREN_AFTER), this.sep(Sep.BEFORE_FORIN_BODY), body, this.sep(Sep.AFTER_STATEMENT(node))), { endsWithMissingElse: body.endsWithMissingElse }); + } + }, { + key: 'reduceForOfStatement', + value: function reduceForOfStatement(node, _ref33) { + var left = _ref33.left, + right = _ref33.right, + body = _ref33.body; + + left = node.left.type === 'VariableDeclaration' ? noIn(markContainsIn(left)) : left; + return (0, _objectAssign2.default)(seq(this.t('for'), this.sep(Sep.AFTER_FOROF_FOR), this.paren(seq(left.startsWithLet ? this.paren(left, Sep.FOR_OF_LET_PAREN_BEFORE, Sep.FOR_OF_LET_PAREN_AFTER) : left, this.sep(Sep.BEFORE_FOROF_OF), this.t('of'), this.sep(Sep.AFTER_FOROF_FOR), this.p(node.right, coderep.Precedence.Assignment, right)), Sep.FOR_OF_PAREN_BEFORE, Sep.FOR_OF_PAREN_AFTER), this.sep(Sep.BEFORE_FOROF_BODY), body, this.sep(Sep.AFTER_STATEMENT(node))), { endsWithMissingElse: body.endsWithMissingElse }); + } + }, { + key: 'reduceForStatement', + value: function reduceForStatement(node, _ref34) { + var init = _ref34.init, + test = _ref34.test, + update = _ref34.update, + body = _ref34.body; + + if (init) { + if (init.startsWithLetSquareBracket) { + init = this.paren(init, Sep.FOR_LET_PAREN_BEFORE, Sep.FOR_LET_PAREN_AFTER); + } + init = noIn(markContainsIn(init)); + } + return (0, _objectAssign2.default)(seq(this.t('for'), this.sep(Sep.AFTER_FOR_FOR), this.paren(seq(init ? seq(this.sep(Sep.BEFORE_FOR_INIT), init, this.sep(Sep.AFTER_FOR_INIT)) : this.sep(Sep.EMPTY_FOR_INIT), this.t(';'), test ? seq(this.sep(Sep.BEFORE_FOR_TEST), test, this.sep(Sep.AFTER_FOR_TEST)) : this.sep(Sep.EMPTY_FOR_TEST), this.t(';'), update ? seq(this.sep(Sep.BEFORE_FOR_UPDATE), update, this.sep(Sep.AFTER_FOR_UPDATE)) : this.sep(Sep.EMPTY_FOR_UPDATE))), this.sep(Sep.BEFORE_FOR_BODY), body, this.sep(Sep.AFTER_STATEMENT(node))), { + endsWithMissingElse: body.endsWithMissingElse + }); + } + }, { + key: 'reduceForAwaitStatement', + value: function reduceForAwaitStatement(node, _ref35) { + var left = _ref35.left, + right = _ref35.right, + body = _ref35.body; + + left = node.left.type === 'VariableDeclaration' ? noIn(markContainsIn(left)) : left; + return (0, _objectAssign2.default)(seq(this.t('for'), this.sep(Sep.AFTER_FOROF_FOR), this.t('await'), this.sep(Sep.AFTER_FORAWAIT_AWAIT), this.paren(seq(left.startsWithLet ? this.paren(left, Sep.FOR_OF_LET_PAREN_BEFORE, Sep.FOR_OF_LET_PAREN_AFTER) : left, this.sep(Sep.BEFORE_FOROF_OF), this.t('of'), this.sep(Sep.AFTER_FOROF_FOR), this.p(node.right, coderep.Precedence.Assignment, right)), Sep.FOR_OF_PAREN_BEFORE, Sep.FOR_OF_PAREN_AFTER), this.sep(Sep.BEFORE_FOROF_BODY), body, this.sep(Sep.AFTER_STATEMENT(node))), { endsWithMissingElse: body.endsWithMissingElse }); + } + }, { + key: 'reduceFunctionBody', + value: function reduceFunctionBody(node, _ref36) { + var directives = _ref36.directives, + statements = _ref36.statements; + + if (statements.length) { + statements[0] = this.parenToAvoidBeingDirective(node.statements[0], statements[0]); + } + return seq.apply(undefined, _toConsumableArray(directives).concat([directives.length ? this.sep(Sep.AFTER_FUNCTION_DIRECTIVES) : empty()], _toConsumableArray(statements))); + } + }, { + key: 'reduceFunctionDeclaration', + value: function reduceFunctionDeclaration(node, _ref37) { + var name = _ref37.name, + params = _ref37.params, + body = _ref37.body; + + return seq(node.isAsync ? this.t('async') : empty(), this.t('function'), node.isGenerator ? seq(this.sep(Sep.BEFORE_GENERATOR_STAR), this.t('*'), this.sep(Sep.AFTER_GENERATOR_STAR)) : empty(), this.sep(Sep.BEFORE_FUNCTION_NAME(node)), node.name.name === '*default*' ? empty() : name, this.sep(Sep.BEFORE_FUNCTION_PARAMS), this.paren(params, Sep.PARAMETERS_PAREN_BEFORE, Sep.PARAMETERS_PAREN_AFTER, Sep.PARAMETERS_PAREN_EMPTY), this.sep(Sep.BEFORE_FUNCTION_DECLARATION_BODY), this.brace(body, node, Sep.FUNCTION_BRACE_INITIAL, Sep.FUNCTION_BRACE_FINAL, Sep.FUNCTION_EMPTY), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceFunctionExpression', + value: function reduceFunctionExpression(node, _ref38) { + var name = _ref38.name, + params = _ref38.params, + body = _ref38.body; + + var state = seq(node.isAsync ? this.t('async') : empty(), this.t('function'), node.isGenerator ? seq(this.sep(Sep.BEFORE_GENERATOR_STAR), this.t('*'), this.sep(Sep.AFTER_GENERATOR_STAR)) : empty(), this.sep(Sep.BEFORE_FUNCTION_NAME(node)), name ? name : empty(), this.sep(Sep.BEFORE_FUNCTION_PARAMS), this.paren(params, Sep.PARAMETERS_PAREN_BEFORE, Sep.PARAMETERS_PAREN_AFTER, Sep.PARAMETERS_PAREN_EMPTY), this.sep(Sep.BEFORE_FUNCTION_EXPRESSION_BODY), this.brace(body, node, Sep.FUNCTION_EXPRESSION_BRACE_INITIAL, Sep.FUNCTION_EXPRESSION_BRACE_FINAL, Sep.FUNCTION_EXPRESSION_EMPTY)); + state.startsWithFunctionOrClass = true; + return state; + } + }, { + key: 'reduceFormalParameters', + value: function reduceFormalParameters(node, _ref39) { + var items = _ref39.items, + rest = _ref39.rest; + + return this.commaSep(items.concat(rest == null ? [] : [seq(this.t('...'), this.sep(Sep.REST), rest)]), Sep.PARAMETER_BEFORE_COMMA, Sep.PARAMETER_AFTER_COMMA); + } + }, { + key: 'reduceArrowExpression', + value: function reduceArrowExpression(node, _ref40) { + var params = _ref40.params, + body = _ref40.body; + + if (node.params.rest != null || node.params.items.length !== 1 || node.params.items[0].type !== 'BindingIdentifier') { + params = this.paren(params, Sep.ARROW_PARAMETERS_PAREN_BEFORE, Sep.ARROW_PARAMETERS_PAREN_AFTER, Sep.ARROW_PARAMETERS_PAREN_EMPTY); + } + var containsIn = false; + if (node.body.type === 'FunctionBody') { + body = this.brace(body, node, Sep.ARROW_BRACE_INITIAL, Sep.ARROW_BRACE_FINAL, Sep.ARROW_BRACE_EMPTY); + } else if (body.startsWithCurly) { + body = this.paren(body, Sep.ARROW_BODY_PAREN_BEFORE, Sep.ARROW_BODY_PAREN_AFTER); + } else if (body.containsIn) { + containsIn = true; + } + return (0, _objectAssign2.default)(seq(node.isAsync ? seq(this.t('async'), this.sep(Sep.BEFORE_ARROW_ASYNC_PARAMS)) : empty(), params, this.sep(Sep.BEFORE_ARROW), this.t('=>'), this.sep(Sep.AFTER_ARROW), this.p(node.body, coderep.Precedence.Assignment, body)), { containsIn: containsIn }); + } + }, { + key: 'reduceGetter', + value: function reduceGetter(node, _ref41) { + var name = _ref41.name, + body = _ref41.body; + + return seq(this.t('get'), this.sep(Sep.AFTER_GET), name, this.sep(Sep.BEFORE_GET_PARAMS), this.paren(empty(), null, null, Sep.GETTER_PARAMS), this.sep(Sep.BEFORE_GET_BODY), this.brace(body, node, Sep.GET_BRACE_INTIAL, Sep.GET_BRACE_FINAL, Sep.GET_BRACE_EMPTY)); + } + }, { + key: 'reduceIdentifierExpression', + value: function reduceIdentifierExpression(node) { + var a = this.t(node.name); + if (node.name === 'let') { + a.startsWithLet = true; + } + return a; + } + }, { + key: 'reduceIfStatement', + value: function reduceIfStatement(node, _ref42) { + var test = _ref42.test, + consequent = _ref42.consequent, + alternate = _ref42.alternate; + + if (alternate && consequent.endsWithMissingElse) { + consequent = this.brace(consequent, node, Sep.MISSING_ELSE_INTIIAL, Sep.MISSING_ELSE_FINAL, Sep.MISSING_ELSE_EMPTY); + } + return (0, _objectAssign2.default)(seq(this.t('if'), this.sep(Sep.AFTER_IF), this.paren(test, Sep.IF_PAREN_BEFORE, Sep.IF_PAREN_AFTER), this.sep(Sep.AFTER_IF_TEST), consequent, alternate ? seq(this.sep(Sep.BEFORE_ELSE), this.t('else'), this.sep(Sep.AFTER_ELSE), alternate) : empty(), this.sep(Sep.AFTER_STATEMENT(node))), { endsWithMissingElse: alternate ? alternate.endsWithMissingElse : true }); + } + }, { + key: 'reduceImport', + value: function reduceImport(node, _ref43) { + var defaultBinding = _ref43.defaultBinding, + namedImports = _ref43.namedImports; + + var bindings = []; + if (defaultBinding != null) { + bindings.push(defaultBinding); + } + if (namedImports.length > 0) { + bindings.push(this.brace(this.commaSep(namedImports, Sep.NAMED_IMPORT_BEFORE_COMMA, Sep.NAMED_IMPORT_AFTER_COMMA), node, Sep.IMPORT_BRACE_INTIAL, Sep.IMPORT_BRACE_FINAL, Sep.IMPORT_BRACE_EMPTY)); + } + if (bindings.length === 0) { + return seq(this.t('import'), this.sep(Sep.BEFORE_IMPORT_MODULE), this.t((0, coderep.escapeStringLiteral)(node.moduleSpecifier)), this.semiOp(), this.sep(Sep.AFTER_STATEMENT(node))); + } + return seq(this.t('import'), this.sep(Sep.BEFORE_IMPORT_BINDINGS), this.commaSep(bindings, Sep.IMPORT_BEFORE_COMMA, Sep.IMPORT_AFTER_COMMA), this.sep(Sep.AFTER_IMPORT_BINDINGS), this.t('from'), this.sep(Sep.AFTER_FROM), this.t((0, coderep.escapeStringLiteral)(node.moduleSpecifier)), this.semiOp(), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceImportNamespace', + value: function reduceImportNamespace(node, _ref44) { + var defaultBinding = _ref44.defaultBinding, + namespaceBinding = _ref44.namespaceBinding; + + return seq(this.t('import'), this.sep(Sep.BEFORE_IMPORT_NAMESPACE), defaultBinding == null ? empty() : seq(defaultBinding, this.sep(Sep.IMPORT_BEFORE_COMMA), this.t(','), this.sep(Sep.IMPORT_AFTER_COMMA)), this.sep(Sep.BEFORE_IMPORT_STAR), this.t('*'), this.sep(Sep.AFTER_IMPORT_STAR), this.t('as'), this.sep(Sep.AFTER_IMPORT_AS), namespaceBinding, this.sep(Sep.AFTER_NAMESPACE_BINDING), this.t('from'), this.sep(Sep.AFTER_FROM), this.t((0, coderep.escapeStringLiteral)(node.moduleSpecifier)), this.semiOp(), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceImportSpecifier', + value: function reduceImportSpecifier(node, _ref45) { + var binding = _ref45.binding; + + if (node.name == null) return binding; + return seq(this.t(node.name), this.sep(Sep.BEFORE_IMPORT_AS), this.t('as'), this.sep(Sep.AFTER_IMPORT_AS), binding); + } + }, { + key: 'reduceExportAllFrom', + value: function reduceExportAllFrom(node) { + return seq(this.t('export'), this.sep(Sep.BEFORE_EXPORT_STAR), this.t('*'), this.sep(Sep.AFTER_EXPORT_STAR), this.t('from'), this.sep(Sep.AFTER_FROM), this.t((0, coderep.escapeStringLiteral)(node.moduleSpecifier)), this.semiOp(), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceExportFrom', + value: function reduceExportFrom(node, _ref46) { + var namedExports = _ref46.namedExports; + + return seq(this.t('export'), this.sep(Sep.BEFORE_EXPORT_BINDINGS), this.brace(this.commaSep(namedExports, Sep.EXPORTS_BEFORE_COMMA, Sep.EXPORTS_AFTER_COMMA), node, Sep.EXPORT_BRACE_INITIAL, Sep.EXPORT_BRACE_FINAL, Sep.EXPORT_BRACE_EMPTY), this.sep(Sep.AFTER_EXPORT_FROM_BINDINGS), this.t('from'), this.sep(Sep.AFTER_FROM), this.t((0, coderep.escapeStringLiteral)(node.moduleSpecifier)), this.semiOp(), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceExportLocals', + value: function reduceExportLocals(node, _ref47) { + var namedExports = _ref47.namedExports; + + return seq(this.t('export'), this.sep(Sep.BEFORE_EXPORT_BINDINGS), this.brace(this.commaSep(namedExports, Sep.EXPORTS_BEFORE_COMMA, Sep.EXPORTS_AFTER_COMMA), node, Sep.EXPORT_BRACE_INITIAL, Sep.EXPORT_BRACE_FINAL, Sep.EXPORT_BRACE_EMPTY), this.sep(Sep.AFTER_EXPORT_LOCAL_BINDINGS), this.semiOp(), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceExport', + value: function reduceExport(node, _ref48) { + var declaration = _ref48.declaration; + + switch (node.declaration.type) { + case 'FunctionDeclaration': + case 'ClassDeclaration': + break; + default: + declaration = seq(declaration, this.semiOp(), this.sep(Sep.AFTER_STATEMENT(node))); + } + return seq(this.t('export'), this.sep(Sep.AFTER_EXPORT), declaration); + } + }, { + key: 'reduceExportDefault', + value: function reduceExportDefault(node, _ref49) { + var body = _ref49.body; + + body = body.startsWithFunctionOrClass ? this.paren(body, Sep.EXPORT_PAREN_BEFORE, Sep.EXPORT_PAREN_AFTER) : body; + switch (node.body.type) { + case 'FunctionDeclaration': + case 'ClassDeclaration': + return seq(this.t('export'), this.sep(Sep.EXPORT_DEFAULT), this.t('default'), this.sep(Sep.AFTER_EXPORT_DEFAULT), body); + default: + return seq(this.t('export'), this.sep(Sep.EXPORT_DEFAULT), this.t('default'), this.sep(Sep.AFTER_EXPORT_DEFAULT), this.p(node.body, coderep.Precedence.Assignment, body), this.semiOp(), this.sep(Sep.AFTER_STATEMENT(node))); + } + } + }, { + key: 'reduceExportFromSpecifier', + value: function reduceExportFromSpecifier(node) { + if (node.exportedName == null) return this.t(node.name); + return seq(this.t(node.name), this.sep(Sep.BEFORE_EXPORT_AS), this.t('as'), this.sep(Sep.AFTER_EXPORT_AS), this.t(node.exportedName)); + } + }, { + key: 'reduceExportLocalSpecifier', + value: function reduceExportLocalSpecifier(node, _ref50) { + var name = _ref50.name; + + if (node.exportedName == null) return name; + return seq(name, this.sep(Sep.BEFORE_EXPORT_AS), this.t('as'), this.sep(Sep.AFTER_EXPORT_AS), this.t(node.exportedName)); + } + }, { + key: 'reduceLabeledStatement', + value: function reduceLabeledStatement(node, _ref51) { + var body = _ref51.body; + + return (0, _objectAssign2.default)(seq(this.t(node.label), this.sep(Sep.BEFORE_LABEL_COLON), this.t(':'), this.sep(Sep.AFTER_LABEL_COLON), body), { endsWithMissingElse: body.endsWithMissingElse }); + } + }, { + key: 'reduceLiteralBooleanExpression', + value: function reduceLiteralBooleanExpression(node) { + return this.t(node.value.toString()); + } + }, { + key: 'reduceLiteralNullExpression', + value: function reduceLiteralNullExpression() /* node */{ + return this.t('null'); + } + }, { + key: 'reduceLiteralInfinityExpression', + value: function reduceLiteralInfinityExpression() /* node */{ + return this.t('2e308'); + } + }, { + key: 'reduceLiteralNumericExpression', + value: function reduceLiteralNumericExpression(node) { + return new coderep.NumberCodeRep(node.value); + } + }, { + key: 'reduceLiteralRegExpExpression', + value: function reduceLiteralRegExpExpression(node) { + return this.t('/' + node.pattern + '/' + (node.global ? 'g' : '') + (node.ignoreCase ? 'i' : '') + (node.multiLine ? 'm' : '') + (node.dotAll ? 's' : '') + (node.unicode ? 'u' : '') + (node.sticky ? 'y' : ''), true); + } + }, { + key: 'reduceLiteralStringExpression', + value: function reduceLiteralStringExpression(node) { + return this.t((0, coderep.escapeStringLiteral)(node.value)); + } + }, { + key: 'reduceMethod', + value: function reduceMethod(node, _ref52) { + var name = _ref52.name, + params = _ref52.params, + body = _ref52.body; + + return seq(node.isAsync ? seq(this.t('async'), this.sep(Sep.AFTER_METHOD_ASYNC)) : empty(), node.isGenerator ? seq(this.t('*'), this.sep(Sep.AFTER_METHOD_GENERATOR_STAR)) : empty(), name, this.sep(Sep.AFTER_METHOD_NAME), this.paren(params, Sep.PARAMETERS_PAREN_BEFORE, Sep.PARAMETERS_PAREN_AFTER, Sep.PARAMETERS_PAREN_EMPTY), this.sep(Sep.BEFORE_METHOD_BODY), this.brace(body, node, Sep.METHOD_BRACE_INTIAL, Sep.METHOD_BRACE_FINAL, Sep.METHOD_BRACE_EMPTY)); + } + }, { + key: 'reduceModule', + value: function reduceModule(node, _ref53) { + var directives = _ref53.directives, + items = _ref53.items; + + if (items.length) { + items[0] = this.parenToAvoidBeingDirective(node.items[0], items[0]); + } + return seq.apply(undefined, _toConsumableArray(directives).concat([directives.length ? this.sep(Sep.AFTER_MODULE_DIRECTIVES) : empty()], _toConsumableArray(items))); + } + }, { + key: 'reduceNewExpression', + value: function reduceNewExpression(node, _ref54) { + var _this7 = this; + + var callee = _ref54.callee, + args = _ref54.arguments; + + var parenthizedArgs = args.map(function (a, i) { + return _this7.p(node.arguments[i], coderep.Precedence.Assignment, a); + }); + var calleeRep = (0, coderep.getPrecedence)(node.callee) === coderep.Precedence.Call ? this.paren(callee, Sep.NEW_CALLEE_PAREN_BEFORE, Sep.NEW_CALLEE_PAREN_AFTER) : this.p(node.callee, (0, coderep.getPrecedence)(node), callee); + return seq(this.t('new'), this.sep(Sep.AFTER_NEW), calleeRep, args.length === 0 ? this.sep(Sep.EMPTY_NEW_CALL) : seq(this.sep(Sep.BEFORE_NEW_ARGS), this.paren(this.commaSep(parenthizedArgs, Sep.ARGS_BEFORE_COMMA, Sep.ARGS_AFTER_COMMA), Sep.NEW_PAREN_BEFORE, Sep.NEW_PAREN_AFTER, Sep.NEW_PAREN_EMPTY))); + } + }, { + key: 'reduceNewTargetExpression', + value: function reduceNewTargetExpression() { + return seq(this.t('new'), this.sep(Sep.NEW_TARGET_BEFORE_DOT), this.t('.'), this.sep(Sep.NEW_TARGET_AFTER_DOT), this.t('target')); + } + }, { + key: 'reduceObjectExpression', + value: function reduceObjectExpression(node, _ref55) { + var properties = _ref55.properties; + + var state = this.brace(this.commaSep(properties, Sep.OBJECT_BEFORE_COMMA, Sep.OBJECT_AFTER_COMMA), node, Sep.OBJECT_BRACE_INITIAL, Sep.OBJECT_BRACE_FINAL, Sep.OBJECT_EMPTY); + state.startsWithCurly = true; + return state; + } + }, { + key: 'reduceUpdateExpression', + value: function reduceUpdateExpression(node, _ref56) { + var operand = _ref56.operand; + + if (node.isPrefix) { + return this.reduceUnaryExpression.apply(this, arguments); + } + return (0, _objectAssign2.default)(seq(this.p(node.operand, coderep.Precedence.New, operand), this.sep(Sep.BEFORE_POSTFIX(node.operator)), this.t(node.operator)), { + startsWithCurly: operand.startsWithCurly, + startsWithLetSquareBracket: operand.startsWithLetSquareBracket, + startsWithFunctionOrClass: operand.startsWithFunctionOrClass + }); + } + }, { + key: 'reduceUnaryExpression', + value: function reduceUnaryExpression(node, _ref57) { + var operand = _ref57.operand; + + return seq(this.t(node.operator), this.sep(Sep.UNARY(node.operator)), this.p(node.operand, (0, coderep.getPrecedence)(node), operand)); + } + }, { + key: 'reduceReturnStatement', + value: function reduceReturnStatement(node, _ref58) { + var expression = _ref58.expression; + + return seq(this.t('return'), expression ? seq(this.sep(Sep.RETURN), expression) : empty(), this.semiOp(), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceScript', + value: function reduceScript(node, _ref59) { + var directives = _ref59.directives, + statements = _ref59.statements; + + if (statements.length) { + statements[0] = this.parenToAvoidBeingDirective(node.statements[0], statements[0]); + } + return seq.apply(undefined, _toConsumableArray(directives).concat([directives.length ? this.sep(Sep.AFTER_SCRIPT_DIRECTIVES) : empty()], _toConsumableArray(statements))); + } + }, { + key: 'reduceSetter', + value: function reduceSetter(node, _ref60) { + var name = _ref60.name, + param = _ref60.param, + body = _ref60.body; + + return seq(this.t('set'), this.sep(Sep.AFTER_SET), name, this.sep(Sep.BEFORE_SET_PARAMS), this.paren(param, Sep.SETTER_PARAM_BEFORE, Sep.SETTER_PARAM_AFTER), this.sep(Sep.BEFORE_SET_BODY), this.brace(body, node, Sep.SET_BRACE_INTIIAL, Sep.SET_BRACE_FINAL, Sep.SET_BRACE_EMPTY)); + } + }, { + key: 'reduceShorthandProperty', + value: function reduceShorthandProperty(node, _ref61) { + var name = _ref61.name; + + return name; + } + }, { + key: 'reduceStaticMemberAssignmentTarget', + value: function reduceStaticMemberAssignmentTarget(node, _ref62) { + var object = _ref62.object; + + var state = seq(this.p(node.object, (0, coderep.getPrecedence)(node), object), this.sep(Sep.BEFORE_STATIC_MEMBER_ASSIGNMENT_TARGET_DOT), this.t('.'), this.sep(Sep.AFTER_STATIC_MEMBER_ASSIGNMENT_TARGET_DOT), this.t(node.property)); + state.startsWithLet = object.startsWithLet; + state.startsWithCurly = object.startsWithCurly; + state.startsWithLetSquareBracket = object.startsWithLetSquareBracket; + state.startsWithFunctionOrClass = object.startsWithFunctionOrClass; + return state; + } + }, { + key: 'reduceStaticMemberExpression', + value: function reduceStaticMemberExpression(node, _ref63) { + var object = _ref63.object; + + var state = seq(this.p(node.object, (0, coderep.getPrecedence)(node), object), this.sep(Sep.BEFORE_STATIC_MEMBER_DOT), this.t('.'), this.sep(Sep.AFTER_STATIC_MEMBER_DOT), this.t(node.property)); + state.startsWithLet = object.startsWithLet; + state.startsWithCurly = object.startsWithCurly; + state.startsWithLetSquareBracket = object.startsWithLetSquareBracket; + state.startsWithFunctionOrClass = object.startsWithFunctionOrClass; + return state; + } + }, { + key: 'reduceStaticPropertyName', + value: function reduceStaticPropertyName(node) { + if (utils.keyword.isIdentifierNameES6(node.value)) { + return this.t(node.value); + } + var n = parseFloat(node.value); + if (n >= 0 && n.toString() === node.value) { + return new coderep.NumberCodeRep(n); + } + return this.t((0, coderep.escapeStringLiteral)(node.value)); + } + }, { + key: 'reduceSuper', + value: function reduceSuper() { + return this.t('super'); + } + }, { + key: 'reduceSwitchCase', + value: function reduceSwitchCase(node, _ref64) { + var test = _ref64.test, + consequent = _ref64.consequent; + + return seq(this.t('case'), this.sep(Sep.BEFORE_CASE_TEST), test, this.sep(Sep.AFTER_CASE_TEST), this.t(':'), this.sep(Sep.BEFORE_CASE_BODY), seq.apply(undefined, _toConsumableArray(consequent)), this.sep(Sep.AFTER_CASE_BODY)); + } + }, { + key: 'reduceSwitchDefault', + value: function reduceSwitchDefault(node, _ref65) { + var consequent = _ref65.consequent; + + return seq(this.t('default'), this.sep(Sep.DEFAULT), this.t(':'), this.sep(Sep.BEFORE_CASE_BODY), seq.apply(undefined, _toConsumableArray(consequent)), this.sep(Sep.AFTER_DEFAULT_BODY)); + } + }, { + key: 'reduceSwitchStatement', + value: function reduceSwitchStatement(node, _ref66) { + var discriminant = _ref66.discriminant, + cases = _ref66.cases; + + return seq(this.t('switch'), this.sep(Sep.BEFORE_SWITCH_DISCRIM), this.paren(discriminant, Sep.SWITCH_DISCRIM_PAREN_BEFORE, Sep.SWITCH_DISCRIM_PAREN_AFTER), this.sep(Sep.BEFORE_SWITCH_BODY), this.brace(seq.apply(undefined, _toConsumableArray(cases)), node, Sep.SWITCH_BRACE_INTIAL, Sep.SWITCH_BRACE_FINAL, Sep.SWITCH_BRACE_EMPTY), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceSwitchStatementWithDefault', + value: function reduceSwitchStatementWithDefault(node, _ref67) { + var discriminant = _ref67.discriminant, + preDefaultCases = _ref67.preDefaultCases, + defaultCase = _ref67.defaultCase, + postDefaultCases = _ref67.postDefaultCases; + + return seq(this.t('switch'), this.sep(Sep.BEFORE_SWITCH_DISCRIM), this.paren(discriminant, Sep.SWITCH_DISCRIM_PAREN_BEFORE, Sep.SWITCH_DISCRIM_PAREN_AFTER), this.sep(Sep.BEFORE_SWITCH_BODY), this.brace(seq.apply(undefined, _toConsumableArray(preDefaultCases).concat([defaultCase], _toConsumableArray(postDefaultCases))), node, Sep.SWITCH_BRACE_INTIAL, Sep.SWITCH_BRACE_FINAL, Sep.SWITCH_BRACE_EMPTY), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceTemplateExpression', + value: function reduceTemplateExpression(node, _ref68) { + var tag = _ref68.tag, + elements = _ref68.elements; + + var state = node.tag == null ? empty() : seq(this.p(node.tag, (0, coderep.getPrecedence)(node), tag), this.sep(Sep.TEMPLATE_TAG)); + state = seq(state, this.t('`')); + for (var _i = 0, l = node.elements.length; _i < l; ++_i) { + if (node.elements[_i].type === 'TemplateElement') { + var d = ''; + if (_i > 0) d += '}'; + d += node.elements[_i].rawValue; + if (_i < l - 1) d += '${'; + state = seq(state, this.t(d)); + } else { + state = seq(state, this.sep(Sep.BEFORE_TEMPLATE_EXPRESSION), elements[_i], this.sep(Sep.AFTER_TEMPLATE_EXPRESSION)); + } + } + state = seq(state, this.t('`')); + if (node.tag != null) { + state.startsWithCurly = tag.startsWithCurly; + state.startsWithLet = tag.startsWithLet; + state.startsWithLetSquareBracket = tag.startsWithLetSquareBracket; + state.startsWithFunctionOrClass = tag.startsWithFunctionOrClass; + } + return state; + } + }, { + key: 'reduceTemplateElement', + value: function reduceTemplateElement(node) { + return this.t(node.rawValue); + } + }, { + key: 'reduceThisExpression', + value: function reduceThisExpression() /* node */{ + return this.t('this'); + } + }, { + key: 'reduceThrowStatement', + value: function reduceThrowStatement(node, _ref69) { + var expression = _ref69.expression; + + return seq(this.t('throw'), this.sep(Sep.THROW), expression, this.semiOp(), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceTryCatchStatement', + value: function reduceTryCatchStatement(node, _ref70) { + var body = _ref70.body, + catchClause = _ref70.catchClause; + + return seq(this.t('try'), this.sep(Sep.AFTER_TRY), body, this.sep(Sep.BEFORE_CATCH), catchClause, this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceTryFinallyStatement', + value: function reduceTryFinallyStatement(node, _ref71) { + var body = _ref71.body, + catchClause = _ref71.catchClause, + finalizer = _ref71.finalizer; + + return seq(this.t('try'), this.sep(Sep.AFTER_TRY), body, catchClause ? seq(this.sep(Sep.BEFORE_CATCH), catchClause) : empty(), this.sep(Sep.BEFORE_FINALLY), this.t('finally'), this.sep(Sep.AFTER_FINALLY), finalizer, this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceYieldExpression', + value: function reduceYieldExpression(node, _ref72) { + var expression = _ref72.expression; + + if (node.expression == null) return this.t('yield'); + return (0, _objectAssign2.default)(seq(this.t('yield'), this.sep(Sep.YIELD), this.p(node.expression, (0, coderep.getPrecedence)(node), expression)), { containsIn: expression.containsIn }); + } + }, { + key: 'reduceYieldGeneratorExpression', + value: function reduceYieldGeneratorExpression(node, _ref73) { + var expression = _ref73.expression; + + return (0, _objectAssign2.default)(seq(this.t('yield'), this.sep(Sep.BEFORE_YIELD_STAR), this.t('*'), this.sep(Sep.AFTER_YIELD_STAR), this.p(node.expression, (0, coderep.getPrecedence)(node), expression)), { containsIn: expression.containsIn }); + } + }, { + key: 'reduceDirective', + value: function reduceDirective(node) { + var delim = node.rawValue.match(/(^|[^\\])(\\\\)*"/) ? '\'' : '"'; + return seq(this.t(delim + node.rawValue + delim), this.semiOp(), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceVariableDeclaration', + value: function reduceVariableDeclaration(node, _ref74) { + var declarators = _ref74.declarators; + + return seq(this.t(node.kind), this.sep(Sep.VARIABLE_DECLARATION), this.commaSep(declarators, Sep.DECLARATORS_BEFORE_COMMA, Sep.DECLARATORS_AFTER_COMMA)); + } + }, { + key: 'reduceVariableDeclarationStatement', + value: function reduceVariableDeclarationStatement(node, _ref75) { + var declaration = _ref75.declaration; + + return seq(declaration, this.semiOp(), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceVariableDeclarator', + value: function reduceVariableDeclarator(node, _ref76) { + var binding = _ref76.binding, + init = _ref76.init; + + var containsIn = init && init.containsIn && !init.containsGroup; + if (init) { + if (init.containsGroup) { + init = this.paren(init, Sep.EXPRESSION_PAREN_BEFORE, Sep.EXPRESSION_PAREN_AFTER); + } else { + init = markContainsIn(init); + } + } + return (0, _objectAssign2.default)(init == null ? binding : seq(binding, this.sep(Sep.BEFORE_INIT_EQUALS), this.t('='), this.sep(Sep.AFTER_INIT_EQUALS), init), { containsIn: containsIn }); + } + }, { + key: 'reduceWhileStatement', + value: function reduceWhileStatement(node, _ref77) { + var test = _ref77.test, + body = _ref77.body; + + return (0, _objectAssign2.default)(seq(this.t('while'), this.sep(Sep.AFTER_WHILE), this.paren(test, Sep.WHILE_TEST_PAREN_BEFORE, Sep.WHILE_TEST_PAREN_AFTER), this.sep(Sep.BEFORE_WHILE_BODY), body, this.sep(Sep.AFTER_STATEMENT(node))), { endsWithMissingElse: body.endsWithMissingElse }); + } + }, { + key: 'reduceWithStatement', + value: function reduceWithStatement(node, _ref78) { + var object = _ref78.object, + body = _ref78.body; + + return (0, _objectAssign2.default)(seq(this.t('with'), this.sep(Sep.AFTER_WITH), this.paren(object, Sep.WITH_PAREN_BEFORE, Sep.WITH_PAREN_AFTER), this.sep(Sep.BEFORE_WITH_BODY), body, this.sep(Sep.AFTER_STATEMENT(node))), { endsWithMissingElse: body.endsWithMissingElse }); + } + }]); + + return ExtensibleCodeGen; +}(); + +function withoutTrailingLinebreak(state) { + if (state && state instanceof coderep.Seq) { + var lastChild = state.children[state.children.length - 1]; + /* istanbul ignore next */ + while (lastChild instanceof coderep.Empty) { + state.children.pop(); + lastChild = state.children[state.children.length - 1]; + } + /* istanbul ignore else */ + if (lastChild instanceof coderep.Seq) { + withoutTrailingLinebreak(lastChild); + } else if (lastChild instanceof Linebreak) { + state.children.pop(); + } + } + return state; +} + +function indent(rep, includingFinal) { + var finalLinebreak = void 0; + function indentNode(node) { + if (node instanceof Linebreak) { + finalLinebreak = node; + ++node.indentation; + } + } + rep.forEach(indentNode); + if (!includingFinal) { + --finalLinebreak.indentation; + } + return rep; +} + +var FormattedCodeGen = exports.FormattedCodeGen = function (_ExtensibleCodeGen) { + _inherits(FormattedCodeGen, _ExtensibleCodeGen); + + function FormattedCodeGen() { + _classCallCheck(this, FormattedCodeGen); + + return _possibleConstructorReturn(this, (FormattedCodeGen.__proto__ || Object.getPrototypeOf(FormattedCodeGen)).apply(this, arguments)); + } + + _createClass(FormattedCodeGen, [{ + key: 'parenToAvoidBeingDirective', + value: function parenToAvoidBeingDirective(element, original) { + if (element && element.type === 'ExpressionStatement' && element.expression.type === 'LiteralStringExpression') { + return seq(this.paren(original.children[0], Sep.PAREN_AVOIDING_DIRECTIVE_BEFORE, Sep.PAREN_AVOIDING_DIRECTIVE_AFTER), this.semiOp(), this.sep(Sep.AFTER_STATEMENT(element))); + } + return original; + } + }, { + key: 'brace', + value: function brace(rep, node) { + if (isEmpty(rep)) { + return this.t('{}'); + } + + switch (node.type) { + case 'ObjectAssignmentTarget': + case 'ObjectBinding': + case 'Import': + case 'ExportFrom': + case 'ExportLocals': + case 'ObjectExpression': + return new coderep.Brace(rep); + } + + rep = seq(new Linebreak(), rep); + indent(rep, false); + return new coderep.Brace(rep); + } + }, { + key: 'reduceDoWhileStatement', + value: function reduceDoWhileStatement(node, _ref79) { + var body = _ref79.body, + test = _ref79.test; + + return seq(this.t('do'), this.sep(Sep.AFTER_DO), withoutTrailingLinebreak(body), this.sep(Sep.BEFORE_DOWHILE_WHILE), this.t('while'), this.sep(Sep.AFTER_DOWHILE_WHILE), this.paren(test, Sep.DO_WHILE_TEST_PAREN_BEFORE, Sep.DO_WHILE_TEST_PAREN_AFTER), this.semiOp(), this.sep(Sep.AFTER_STATEMENT(node))); + } + }, { + key: 'reduceIfStatement', + value: function reduceIfStatement(node, _ref80) { + var test = _ref80.test, + consequent = _ref80.consequent, + alternate = _ref80.alternate; + + if (alternate && consequent.endsWithMissingElse) { + consequent = this.brace(consequent, node); + } + return (0, _objectAssign2.default)(seq(this.t('if'), this.sep(Sep.AFTER_IF), this.paren(test, Sep.IF_PAREN_BEFORE, Sep.IF_PAREN_AFTER), this.sep(Sep.AFTER_IF_TEST), withoutTrailingLinebreak(consequent), alternate ? seq(this.sep(Sep.BEFORE_ELSE), this.t('else'), this.sep(Sep.AFTER_ELSE), withoutTrailingLinebreak(alternate)) : empty(), this.sep(Sep.AFTER_STATEMENT(node))), { endsWithMissingElse: alternate ? alternate.endsWithMissingElse : true }); + } + }, { + key: 'reduceSwitchCase', + value: function reduceSwitchCase(node, _ref81) { + var test = _ref81.test, + consequent = _ref81.consequent; + + consequent = indent(withoutTrailingLinebreak(seq.apply(undefined, [this.sep(Sep.BEFORE_CASE_BODY)].concat(_toConsumableArray(consequent)))), true); + return seq(this.t('case'), this.sep(Sep.BEFORE_CASE_TEST), test, this.sep(Sep.AFTER_CASE_TEST), this.t(':'), consequent, this.sep(Sep.AFTER_CASE_BODY)); + } + }, { + key: 'reduceSwitchDefault', + value: function reduceSwitchDefault(node, _ref82) { + var consequent = _ref82.consequent; + + consequent = indent(withoutTrailingLinebreak(seq.apply(undefined, [this.sep(Sep.BEFORE_CASE_BODY)].concat(_toConsumableArray(consequent)))), true); + return seq(this.t('default'), this.sep(Sep.DEFAULT), this.t(':'), consequent, this.sep(Sep.AFTER_DEFAULT_BODY)); + } + }, { + key: 'sep', + value: function sep(separator) { + switch (separator.type) { + case 'AWAIT': + case 'AFTER_FORAWAIT_AWAIT': + case 'ARRAY_AFTER_COMMA': + case 'OBJECT_AFTER_COMMA': + case 'ARGS_AFTER_COMMA': + case 'PARAMETER_AFTER_COMMA': + case 'DECLARATORS_AFTER_COMMA': + case 'NAMED_IMPORT_AFTER_COMMA': + case 'IMPORT_AFTER_COMMA': + case 'BEFORE_DEFAULT_EQUALS': + case 'AFTER_DEFAULT_EQUALS': + case 'AFTER_PROP': + case 'BEFORE_JUMP_LABEL': + case 'BEFORE_CATCH_BINDING': + case 'AFTER_CATCH_BINDING': + case 'BEFORE_CLASS_NAME': + case 'BEFORE_EXTENDS': + case 'AFTER_EXTENDS': + case 'BEFORE_CLASS_DECLARATION_ELEMENTS': + case 'BEFORE_CLASS_EXPRESSION_ELEMENTS': + case 'AFTER_STATIC': + case 'BEFORE_TERNARY_QUESTION': + case 'AFTER_TERNARY_QUESTION': + case 'BEFORE_TERNARY_COLON': + case 'AFTER_TERNARY_COLON': + case 'AFTER_DO': + case 'BEFORE_DOWHILE_WHILE': + case 'AFTER_DOWHILE_WHILE': + case 'AFTER_FORIN_FOR': + case 'BEFORE_FORIN_IN': + case 'BEFORE_FORIN_BODY': + case 'BEFORE_FOROF_OF': + case 'AFTER_FOROF_FOR': + case 'BEFORE_FOROF_BODY': + case 'AFTER_FOR_FOR': + case 'BEFORE_FOR_TEST': + case 'BEFORE_FOR_UPDATE': + case 'BEFORE_FOR_BODY': + case 'BEFORE_FUNCTION_DECLARATION_BODY': + case 'BEFORE_FUNCTION_EXPRESSION_BODY': + case 'BEFORE_ARROW': + case 'AFTER_ARROW': + case 'BEFORE_ARROW_ASYNC_PARAMS': + case 'AFTER_GET': + case 'BEFORE_GET_BODY': + case 'AFTER_IF': + case 'AFTER_IF_TEST': + case 'BEFORE_ELSE': + case 'AFTER_ELSE': + case 'BEFORE_IMPORT_BINDINGS': + case 'BEFORE_IMPORT_MODULE': + case 'AFTER_IMPORT_BINDINGS': + case 'AFTER_FROM': + case 'BEFORE_IMPORT_NAMESPACE': + case 'BEFORE_IMPORT_STAR': + case 'AFTER_IMPORT_STAR': + case 'AFTER_NAMESPACE_BINDING': + case 'BEFORE_IMPORT_AS': + case 'AFTER_IMPORT_AS': + case 'EXPORTS_AFTER_COMMA': + case 'BEFORE_EXPORT_STAR': + case 'AFTER_EXPORT_STAR': + case 'BEFORE_EXPORT_BINDINGS': + case 'AFTER_EXPORT_FROM_BINDINGS': + case 'AFTER_EXPORT': + case 'AFTER_EXPORT_DEFAULT': + case 'BEFORE_EXPORT_AS': + case 'AFTER_EXPORT_AS': + case 'AFTER_LABEL_COLON': + case 'AFTER_METHOD_ASYNC': + case 'BEFORE_METHOD_BODY': + case 'AFTER_NEW': + case 'RETURN': + case 'AFTER_SET': + case 'BEFORE_SET_BODY': + case 'BEFORE_SET_PARAMS': + case 'BEFORE_CASE_TEST': + case 'BEFORE_SWITCH_DISCRIM': + case 'BEFORE_SWITCH_BODY': + case 'THROW': + case 'AFTER_TRY': + case 'BEFORE_CATCH': + case 'BEFORE_FINALLY': + case 'AFTER_FINALLY': + case 'VARIABLE_DECLARATION': + case 'YIELD': + case 'AFTER_YIELD_STAR': + case 'BEFORE_INIT_EQUALS': + case 'AFTER_INIT_EQUALS': + case 'AFTER_WHILE': + case 'BEFORE_WHILE_BODY': + case 'AFTER_WITH': + case 'BEFORE_WITH_BODY': + case 'BEFORE_FUNCTION_NAME': + case 'AFTER_BINOP': + case 'BEFORE_ASSIGN_OP': + case 'AFTER_ASSIGN_OP': + return this.t(' '); + case 'AFTER_STATEMENT': + switch (separator.node.type) { + case 'ForInStatement': + case 'ForOfStatement': + case 'ForStatement': + case 'WhileStatement': + case 'WithStatement': + return empty(); // because those already end with an AFTER_STATEMENT + default: + return new Linebreak(); + } + case 'AFTER_CLASS_ELEMENT': + case 'BEFORE_CASE_BODY': + case 'AFTER_CASE_BODY': + case 'AFTER_DEFAULT_BODY': + return new Linebreak(); + case 'BEFORE_BINOP': + return separator.op === ',' ? empty() : this.t(' '); + case 'UNARY': + return separator.op === 'delete' || separator.op === 'void' || separator.op === 'typeof' ? this.t(' ') : empty(); + default: + return empty(); + } + } + }]); + + return FormattedCodeGen; +}(ExtensibleCodeGen); +}); + +var director_1 = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.reduce = reduce; +// Generated by generate-director.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var director = { + ArrayAssignmentTarget: function ArrayAssignmentTarget(reducer, node) { + var _this = this; + + return reducer.reduceArrayAssignmentTarget(node, { elements: node.elements.map(function (v) { + return v && _this[v.type](reducer, v); + }), rest: node.rest && this[node.rest.type](reducer, node.rest) }); + }, + ArrayBinding: function ArrayBinding(reducer, node) { + var _this2 = this; + + return reducer.reduceArrayBinding(node, { elements: node.elements.map(function (v) { + return v && _this2[v.type](reducer, v); + }), rest: node.rest && this[node.rest.type](reducer, node.rest) }); + }, + ArrayExpression: function ArrayExpression(reducer, node) { + var _this3 = this; + + return reducer.reduceArrayExpression(node, { elements: node.elements.map(function (v) { + return v && _this3[v.type](reducer, v); + }) }); + }, + ArrowExpression: function ArrowExpression(reducer, node) { + return reducer.reduceArrowExpression(node, { params: this.FormalParameters(reducer, node.params), body: this[node.body.type](reducer, node.body) }); + }, + AssignmentExpression: function AssignmentExpression(reducer, node) { + return reducer.reduceAssignmentExpression(node, { binding: this[node.binding.type](reducer, node.binding), expression: this[node.expression.type](reducer, node.expression) }); + }, + AssignmentTargetIdentifier: function AssignmentTargetIdentifier(reducer, node) { + return reducer.reduceAssignmentTargetIdentifier(node); + }, + AssignmentTargetPropertyIdentifier: function AssignmentTargetPropertyIdentifier(reducer, node) { + return reducer.reduceAssignmentTargetPropertyIdentifier(node, { binding: this.AssignmentTargetIdentifier(reducer, node.binding), init: node.init && this[node.init.type](reducer, node.init) }); + }, + AssignmentTargetPropertyProperty: function AssignmentTargetPropertyProperty(reducer, node) { + return reducer.reduceAssignmentTargetPropertyProperty(node, { name: this[node.name.type](reducer, node.name), binding: this[node.binding.type](reducer, node.binding) }); + }, + AssignmentTargetWithDefault: function AssignmentTargetWithDefault(reducer, node) { + return reducer.reduceAssignmentTargetWithDefault(node, { binding: this[node.binding.type](reducer, node.binding), init: this[node.init.type](reducer, node.init) }); + }, + AwaitExpression: function AwaitExpression(reducer, node) { + return reducer.reduceAwaitExpression(node, { expression: this[node.expression.type](reducer, node.expression) }); + }, + BinaryExpression: function BinaryExpression(reducer, node) { + return reducer.reduceBinaryExpression(node, { left: this[node.left.type](reducer, node.left), right: this[node.right.type](reducer, node.right) }); + }, + BindingIdentifier: function BindingIdentifier(reducer, node) { + return reducer.reduceBindingIdentifier(node); + }, + BindingPropertyIdentifier: function BindingPropertyIdentifier(reducer, node) { + return reducer.reduceBindingPropertyIdentifier(node, { binding: this.BindingIdentifier(reducer, node.binding), init: node.init && this[node.init.type](reducer, node.init) }); + }, + BindingPropertyProperty: function BindingPropertyProperty(reducer, node) { + return reducer.reduceBindingPropertyProperty(node, { name: this[node.name.type](reducer, node.name), binding: this[node.binding.type](reducer, node.binding) }); + }, + BindingWithDefault: function BindingWithDefault(reducer, node) { + return reducer.reduceBindingWithDefault(node, { binding: this[node.binding.type](reducer, node.binding), init: this[node.init.type](reducer, node.init) }); + }, + Block: function Block(reducer, node) { + var _this4 = this; + + return reducer.reduceBlock(node, { statements: node.statements.map(function (v) { + return _this4[v.type](reducer, v); + }) }); + }, + BlockStatement: function BlockStatement(reducer, node) { + return reducer.reduceBlockStatement(node, { block: this.Block(reducer, node.block) }); + }, + BreakStatement: function BreakStatement(reducer, node) { + return reducer.reduceBreakStatement(node); + }, + CallExpression: function CallExpression(reducer, node) { + var _this5 = this; + + return reducer.reduceCallExpression(node, { callee: this[node.callee.type](reducer, node.callee), arguments: node.arguments.map(function (v) { + return _this5[v.type](reducer, v); + }) }); + }, + CatchClause: function CatchClause(reducer, node) { + return reducer.reduceCatchClause(node, { binding: this[node.binding.type](reducer, node.binding), body: this.Block(reducer, node.body) }); + }, + ClassDeclaration: function ClassDeclaration(reducer, node) { + var _this6 = this; + + return reducer.reduceClassDeclaration(node, { name: this.BindingIdentifier(reducer, node.name), super: node.super && this[node.super.type](reducer, node.super), elements: node.elements.map(function (v) { + return _this6.ClassElement(reducer, v); + }) }); + }, + ClassElement: function ClassElement(reducer, node) { + return reducer.reduceClassElement(node, { method: this[node.method.type](reducer, node.method) }); + }, + ClassExpression: function ClassExpression(reducer, node) { + var _this7 = this; + + return reducer.reduceClassExpression(node, { name: node.name && this.BindingIdentifier(reducer, node.name), super: node.super && this[node.super.type](reducer, node.super), elements: node.elements.map(function (v) { + return _this7.ClassElement(reducer, v); + }) }); + }, + CompoundAssignmentExpression: function CompoundAssignmentExpression(reducer, node) { + return reducer.reduceCompoundAssignmentExpression(node, { binding: this[node.binding.type](reducer, node.binding), expression: this[node.expression.type](reducer, node.expression) }); + }, + ComputedMemberAssignmentTarget: function ComputedMemberAssignmentTarget(reducer, node) { + return reducer.reduceComputedMemberAssignmentTarget(node, { object: this[node.object.type](reducer, node.object), expression: this[node.expression.type](reducer, node.expression) }); + }, + ComputedMemberExpression: function ComputedMemberExpression(reducer, node) { + return reducer.reduceComputedMemberExpression(node, { object: this[node.object.type](reducer, node.object), expression: this[node.expression.type](reducer, node.expression) }); + }, + ComputedPropertyName: function ComputedPropertyName(reducer, node) { + return reducer.reduceComputedPropertyName(node, { expression: this[node.expression.type](reducer, node.expression) }); + }, + ConditionalExpression: function ConditionalExpression(reducer, node) { + return reducer.reduceConditionalExpression(node, { test: this[node.test.type](reducer, node.test), consequent: this[node.consequent.type](reducer, node.consequent), alternate: this[node.alternate.type](reducer, node.alternate) }); + }, + ContinueStatement: function ContinueStatement(reducer, node) { + return reducer.reduceContinueStatement(node); + }, + DataProperty: function DataProperty(reducer, node) { + return reducer.reduceDataProperty(node, { name: this[node.name.type](reducer, node.name), expression: this[node.expression.type](reducer, node.expression) }); + }, + DebuggerStatement: function DebuggerStatement(reducer, node) { + return reducer.reduceDebuggerStatement(node); + }, + Directive: function Directive(reducer, node) { + return reducer.reduceDirective(node); + }, + DoWhileStatement: function DoWhileStatement(reducer, node) { + return reducer.reduceDoWhileStatement(node, { body: this[node.body.type](reducer, node.body), test: this[node.test.type](reducer, node.test) }); + }, + EmptyStatement: function EmptyStatement(reducer, node) { + return reducer.reduceEmptyStatement(node); + }, + Export: function Export(reducer, node) { + return reducer.reduceExport(node, { declaration: this[node.declaration.type](reducer, node.declaration) }); + }, + ExportAllFrom: function ExportAllFrom(reducer, node) { + return reducer.reduceExportAllFrom(node); + }, + ExportDefault: function ExportDefault(reducer, node) { + return reducer.reduceExportDefault(node, { body: this[node.body.type](reducer, node.body) }); + }, + ExportFrom: function ExportFrom(reducer, node) { + var _this8 = this; + + return reducer.reduceExportFrom(node, { namedExports: node.namedExports.map(function (v) { + return _this8.ExportFromSpecifier(reducer, v); + }) }); + }, + ExportFromSpecifier: function ExportFromSpecifier(reducer, node) { + return reducer.reduceExportFromSpecifier(node); + }, + ExportLocalSpecifier: function ExportLocalSpecifier(reducer, node) { + return reducer.reduceExportLocalSpecifier(node, { name: this.IdentifierExpression(reducer, node.name) }); + }, + ExportLocals: function ExportLocals(reducer, node) { + var _this9 = this; + + return reducer.reduceExportLocals(node, { namedExports: node.namedExports.map(function (v) { + return _this9.ExportLocalSpecifier(reducer, v); + }) }); + }, + ExpressionStatement: function ExpressionStatement(reducer, node) { + return reducer.reduceExpressionStatement(node, { expression: this[node.expression.type](reducer, node.expression) }); + }, + ForAwaitStatement: function ForAwaitStatement(reducer, node) { + return reducer.reduceForAwaitStatement(node, { left: this[node.left.type](reducer, node.left), right: this[node.right.type](reducer, node.right), body: this[node.body.type](reducer, node.body) }); + }, + ForInStatement: function ForInStatement(reducer, node) { + return reducer.reduceForInStatement(node, { left: this[node.left.type](reducer, node.left), right: this[node.right.type](reducer, node.right), body: this[node.body.type](reducer, node.body) }); + }, + ForOfStatement: function ForOfStatement(reducer, node) { + return reducer.reduceForOfStatement(node, { left: this[node.left.type](reducer, node.left), right: this[node.right.type](reducer, node.right), body: this[node.body.type](reducer, node.body) }); + }, + ForStatement: function ForStatement(reducer, node) { + return reducer.reduceForStatement(node, { init: node.init && this[node.init.type](reducer, node.init), test: node.test && this[node.test.type](reducer, node.test), update: node.update && this[node.update.type](reducer, node.update), body: this[node.body.type](reducer, node.body) }); + }, + FormalParameters: function FormalParameters(reducer, node) { + var _this10 = this; + + return reducer.reduceFormalParameters(node, { items: node.items.map(function (v) { + return _this10[v.type](reducer, v); + }), rest: node.rest && this[node.rest.type](reducer, node.rest) }); + }, + FunctionBody: function FunctionBody(reducer, node) { + var _this11 = this; + + return reducer.reduceFunctionBody(node, { directives: node.directives.map(function (v) { + return _this11.Directive(reducer, v); + }), statements: node.statements.map(function (v) { + return _this11[v.type](reducer, v); + }) }); + }, + FunctionDeclaration: function FunctionDeclaration(reducer, node) { + return reducer.reduceFunctionDeclaration(node, { name: this.BindingIdentifier(reducer, node.name), params: this.FormalParameters(reducer, node.params), body: this.FunctionBody(reducer, node.body) }); + }, + FunctionExpression: function FunctionExpression(reducer, node) { + return reducer.reduceFunctionExpression(node, { name: node.name && this.BindingIdentifier(reducer, node.name), params: this.FormalParameters(reducer, node.params), body: this.FunctionBody(reducer, node.body) }); + }, + Getter: function Getter(reducer, node) { + return reducer.reduceGetter(node, { name: this[node.name.type](reducer, node.name), body: this.FunctionBody(reducer, node.body) }); + }, + IdentifierExpression: function IdentifierExpression(reducer, node) { + return reducer.reduceIdentifierExpression(node); + }, + IfStatement: function IfStatement(reducer, node) { + return reducer.reduceIfStatement(node, { test: this[node.test.type](reducer, node.test), consequent: this[node.consequent.type](reducer, node.consequent), alternate: node.alternate && this[node.alternate.type](reducer, node.alternate) }); + }, + Import: function Import(reducer, node) { + var _this12 = this; + + return reducer.reduceImport(node, { defaultBinding: node.defaultBinding && this.BindingIdentifier(reducer, node.defaultBinding), namedImports: node.namedImports.map(function (v) { + return _this12.ImportSpecifier(reducer, v); + }) }); + }, + ImportNamespace: function ImportNamespace(reducer, node) { + return reducer.reduceImportNamespace(node, { defaultBinding: node.defaultBinding && this.BindingIdentifier(reducer, node.defaultBinding), namespaceBinding: this.BindingIdentifier(reducer, node.namespaceBinding) }); + }, + ImportSpecifier: function ImportSpecifier(reducer, node) { + return reducer.reduceImportSpecifier(node, { binding: this.BindingIdentifier(reducer, node.binding) }); + }, + LabeledStatement: function LabeledStatement(reducer, node) { + return reducer.reduceLabeledStatement(node, { body: this[node.body.type](reducer, node.body) }); + }, + LiteralBooleanExpression: function LiteralBooleanExpression(reducer, node) { + return reducer.reduceLiteralBooleanExpression(node); + }, + LiteralInfinityExpression: function LiteralInfinityExpression(reducer, node) { + return reducer.reduceLiteralInfinityExpression(node); + }, + LiteralNullExpression: function LiteralNullExpression(reducer, node) { + return reducer.reduceLiteralNullExpression(node); + }, + LiteralNumericExpression: function LiteralNumericExpression(reducer, node) { + return reducer.reduceLiteralNumericExpression(node); + }, + LiteralRegExpExpression: function LiteralRegExpExpression(reducer, node) { + return reducer.reduceLiteralRegExpExpression(node); + }, + LiteralStringExpression: function LiteralStringExpression(reducer, node) { + return reducer.reduceLiteralStringExpression(node); + }, + Method: function Method(reducer, node) { + return reducer.reduceMethod(node, { name: this[node.name.type](reducer, node.name), params: this.FormalParameters(reducer, node.params), body: this.FunctionBody(reducer, node.body) }); + }, + Module: function Module(reducer, node) { + var _this13 = this; + + return reducer.reduceModule(node, { directives: node.directives.map(function (v) { + return _this13.Directive(reducer, v); + }), items: node.items.map(function (v) { + return _this13[v.type](reducer, v); + }) }); + }, + NewExpression: function NewExpression(reducer, node) { + var _this14 = this; + + return reducer.reduceNewExpression(node, { callee: this[node.callee.type](reducer, node.callee), arguments: node.arguments.map(function (v) { + return _this14[v.type](reducer, v); + }) }); + }, + NewTargetExpression: function NewTargetExpression(reducer, node) { + return reducer.reduceNewTargetExpression(node); + }, + ObjectAssignmentTarget: function ObjectAssignmentTarget(reducer, node) { + var _this15 = this; + + return reducer.reduceObjectAssignmentTarget(node, { properties: node.properties.map(function (v) { + return _this15[v.type](reducer, v); + }), rest: node.rest && this[node.rest.type](reducer, node.rest) }); + }, + ObjectBinding: function ObjectBinding(reducer, node) { + var _this16 = this; + + return reducer.reduceObjectBinding(node, { properties: node.properties.map(function (v) { + return _this16[v.type](reducer, v); + }), rest: node.rest && this[node.rest.type](reducer, node.rest) }); + }, + ObjectExpression: function ObjectExpression(reducer, node) { + var _this17 = this; + + return reducer.reduceObjectExpression(node, { properties: node.properties.map(function (v) { + return _this17[v.type](reducer, v); + }) }); + }, + ReturnStatement: function ReturnStatement(reducer, node) { + return reducer.reduceReturnStatement(node, { expression: node.expression && this[node.expression.type](reducer, node.expression) }); + }, + Script: function Script(reducer, node) { + var _this18 = this; + + return reducer.reduceScript(node, { directives: node.directives.map(function (v) { + return _this18.Directive(reducer, v); + }), statements: node.statements.map(function (v) { + return _this18[v.type](reducer, v); + }) }); + }, + Setter: function Setter(reducer, node) { + return reducer.reduceSetter(node, { name: this[node.name.type](reducer, node.name), param: this[node.param.type](reducer, node.param), body: this.FunctionBody(reducer, node.body) }); + }, + ShorthandProperty: function ShorthandProperty(reducer, node) { + return reducer.reduceShorthandProperty(node, { name: this.IdentifierExpression(reducer, node.name) }); + }, + SpreadElement: function SpreadElement(reducer, node) { + return reducer.reduceSpreadElement(node, { expression: this[node.expression.type](reducer, node.expression) }); + }, + SpreadProperty: function SpreadProperty(reducer, node) { + return reducer.reduceSpreadProperty(node, { expression: this[node.expression.type](reducer, node.expression) }); + }, + StaticMemberAssignmentTarget: function StaticMemberAssignmentTarget(reducer, node) { + return reducer.reduceStaticMemberAssignmentTarget(node, { object: this[node.object.type](reducer, node.object) }); + }, + StaticMemberExpression: function StaticMemberExpression(reducer, node) { + return reducer.reduceStaticMemberExpression(node, { object: this[node.object.type](reducer, node.object) }); + }, + StaticPropertyName: function StaticPropertyName(reducer, node) { + return reducer.reduceStaticPropertyName(node); + }, + Super: function Super(reducer, node) { + return reducer.reduceSuper(node); + }, + SwitchCase: function SwitchCase(reducer, node) { + var _this19 = this; + + return reducer.reduceSwitchCase(node, { test: this[node.test.type](reducer, node.test), consequent: node.consequent.map(function (v) { + return _this19[v.type](reducer, v); + }) }); + }, + SwitchDefault: function SwitchDefault(reducer, node) { + var _this20 = this; + + return reducer.reduceSwitchDefault(node, { consequent: node.consequent.map(function (v) { + return _this20[v.type](reducer, v); + }) }); + }, + SwitchStatement: function SwitchStatement(reducer, node) { + var _this21 = this; + + return reducer.reduceSwitchStatement(node, { discriminant: this[node.discriminant.type](reducer, node.discriminant), cases: node.cases.map(function (v) { + return _this21.SwitchCase(reducer, v); + }) }); + }, + SwitchStatementWithDefault: function SwitchStatementWithDefault(reducer, node) { + var _this22 = this; + + return reducer.reduceSwitchStatementWithDefault(node, { discriminant: this[node.discriminant.type](reducer, node.discriminant), preDefaultCases: node.preDefaultCases.map(function (v) { + return _this22.SwitchCase(reducer, v); + }), defaultCase: this.SwitchDefault(reducer, node.defaultCase), postDefaultCases: node.postDefaultCases.map(function (v) { + return _this22.SwitchCase(reducer, v); + }) }); + }, + TemplateElement: function TemplateElement(reducer, node) { + return reducer.reduceTemplateElement(node); + }, + TemplateExpression: function TemplateExpression(reducer, node) { + var _this23 = this; + + return reducer.reduceTemplateExpression(node, { tag: node.tag && this[node.tag.type](reducer, node.tag), elements: node.elements.map(function (v) { + return _this23[v.type](reducer, v); + }) }); + }, + ThisExpression: function ThisExpression(reducer, node) { + return reducer.reduceThisExpression(node); + }, + ThrowStatement: function ThrowStatement(reducer, node) { + return reducer.reduceThrowStatement(node, { expression: this[node.expression.type](reducer, node.expression) }); + }, + TryCatchStatement: function TryCatchStatement(reducer, node) { + return reducer.reduceTryCatchStatement(node, { body: this.Block(reducer, node.body), catchClause: this.CatchClause(reducer, node.catchClause) }); + }, + TryFinallyStatement: function TryFinallyStatement(reducer, node) { + return reducer.reduceTryFinallyStatement(node, { body: this.Block(reducer, node.body), catchClause: node.catchClause && this.CatchClause(reducer, node.catchClause), finalizer: this.Block(reducer, node.finalizer) }); + }, + UnaryExpression: function UnaryExpression(reducer, node) { + return reducer.reduceUnaryExpression(node, { operand: this[node.operand.type](reducer, node.operand) }); + }, + UpdateExpression: function UpdateExpression(reducer, node) { + return reducer.reduceUpdateExpression(node, { operand: this[node.operand.type](reducer, node.operand) }); + }, + VariableDeclaration: function VariableDeclaration(reducer, node) { + var _this24 = this; + + return reducer.reduceVariableDeclaration(node, { declarators: node.declarators.map(function (v) { + return _this24.VariableDeclarator(reducer, v); + }) }); + }, + VariableDeclarationStatement: function VariableDeclarationStatement(reducer, node) { + return reducer.reduceVariableDeclarationStatement(node, { declaration: this.VariableDeclaration(reducer, node.declaration) }); + }, + VariableDeclarator: function VariableDeclarator(reducer, node) { + return reducer.reduceVariableDeclarator(node, { binding: this[node.binding.type](reducer, node.binding), init: node.init && this[node.init.type](reducer, node.init) }); + }, + WhileStatement: function WhileStatement(reducer, node) { + return reducer.reduceWhileStatement(node, { test: this[node.test.type](reducer, node.test), body: this[node.body.type](reducer, node.body) }); + }, + WithStatement: function WithStatement(reducer, node) { + return reducer.reduceWithStatement(node, { object: this[node.object.type](reducer, node.object), body: this[node.body.type](reducer, node.body) }); + }, + YieldExpression: function YieldExpression(reducer, node) { + return reducer.reduceYieldExpression(node, { expression: node.expression && this[node.expression.type](reducer, node.expression) }); + }, + YieldGeneratorExpression: function YieldGeneratorExpression(reducer, node) { + return reducer.reduceYieldGeneratorExpression(node, { expression: this[node.expression.type](reducer, node.expression) }); + } +}; + +function reduce(reducer, node) { + return director[node.type](reducer, node); +} +}); + +var thunkedDirector = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.thunkedReduce = thunkedReduce; +// Generated by generate-director.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var director = { + ArrayAssignmentTarget: function ArrayAssignmentTarget(reducer, node) { + var _this = this; + + return reducer.reduceArrayAssignmentTarget(node, { elements: node.elements.map(function (v) { + return v && function () { + return _this[v.type](reducer, v); + }; + }), rest: node.rest && function () { + return _this[node.rest.type](reducer, node.rest); + } }); + }, + ArrayBinding: function ArrayBinding(reducer, node) { + var _this2 = this; + + return reducer.reduceArrayBinding(node, { elements: node.elements.map(function (v) { + return v && function () { + return _this2[v.type](reducer, v); + }; + }), rest: node.rest && function () { + return _this2[node.rest.type](reducer, node.rest); + } }); + }, + ArrayExpression: function ArrayExpression(reducer, node) { + var _this3 = this; + + return reducer.reduceArrayExpression(node, { elements: node.elements.map(function (v) { + return v && function () { + return _this3[v.type](reducer, v); + }; + }) }); + }, + ArrowExpression: function ArrowExpression(reducer, node) { + var _this4 = this; + + return reducer.reduceArrowExpression(node, { params: function params() { + return _this4.FormalParameters(reducer, node.params); + }, body: function body() { + return _this4[node.body.type](reducer, node.body); + } }); + }, + AssignmentExpression: function AssignmentExpression(reducer, node) { + var _this5 = this; + + return reducer.reduceAssignmentExpression(node, { binding: function binding() { + return _this5[node.binding.type](reducer, node.binding); + }, expression: function expression() { + return _this5[node.expression.type](reducer, node.expression); + } }); + }, + AssignmentTargetIdentifier: function AssignmentTargetIdentifier(reducer, node) { + return reducer.reduceAssignmentTargetIdentifier(node); + }, + AssignmentTargetPropertyIdentifier: function AssignmentTargetPropertyIdentifier(reducer, node) { + var _this6 = this; + + return reducer.reduceAssignmentTargetPropertyIdentifier(node, { binding: function binding() { + return _this6.AssignmentTargetIdentifier(reducer, node.binding); + }, init: node.init && function () { + return _this6[node.init.type](reducer, node.init); + } }); + }, + AssignmentTargetPropertyProperty: function AssignmentTargetPropertyProperty(reducer, node) { + var _this7 = this; + + return reducer.reduceAssignmentTargetPropertyProperty(node, { name: function name() { + return _this7[node.name.type](reducer, node.name); + }, binding: function binding() { + return _this7[node.binding.type](reducer, node.binding); + } }); + }, + AssignmentTargetWithDefault: function AssignmentTargetWithDefault(reducer, node) { + var _this8 = this; + + return reducer.reduceAssignmentTargetWithDefault(node, { binding: function binding() { + return _this8[node.binding.type](reducer, node.binding); + }, init: function init() { + return _this8[node.init.type](reducer, node.init); + } }); + }, + AwaitExpression: function AwaitExpression(reducer, node) { + var _this9 = this; + + return reducer.reduceAwaitExpression(node, { expression: function expression() { + return _this9[node.expression.type](reducer, node.expression); + } }); + }, + BinaryExpression: function BinaryExpression(reducer, node) { + var _this10 = this; + + return reducer.reduceBinaryExpression(node, { left: function left() { + return _this10[node.left.type](reducer, node.left); + }, right: function right() { + return _this10[node.right.type](reducer, node.right); + } }); + }, + BindingIdentifier: function BindingIdentifier(reducer, node) { + return reducer.reduceBindingIdentifier(node); + }, + BindingPropertyIdentifier: function BindingPropertyIdentifier(reducer, node) { + var _this11 = this; + + return reducer.reduceBindingPropertyIdentifier(node, { binding: function binding() { + return _this11.BindingIdentifier(reducer, node.binding); + }, init: node.init && function () { + return _this11[node.init.type](reducer, node.init); + } }); + }, + BindingPropertyProperty: function BindingPropertyProperty(reducer, node) { + var _this12 = this; + + return reducer.reduceBindingPropertyProperty(node, { name: function name() { + return _this12[node.name.type](reducer, node.name); + }, binding: function binding() { + return _this12[node.binding.type](reducer, node.binding); + } }); + }, + BindingWithDefault: function BindingWithDefault(reducer, node) { + var _this13 = this; + + return reducer.reduceBindingWithDefault(node, { binding: function binding() { + return _this13[node.binding.type](reducer, node.binding); + }, init: function init() { + return _this13[node.init.type](reducer, node.init); + } }); + }, + Block: function Block(reducer, node) { + var _this14 = this; + + return reducer.reduceBlock(node, { statements: node.statements.map(function (v) { + return function () { + return _this14[v.type](reducer, v); + }; + }) }); + }, + BlockStatement: function BlockStatement(reducer, node) { + var _this15 = this; + + return reducer.reduceBlockStatement(node, { block: function block() { + return _this15.Block(reducer, node.block); + } }); + }, + BreakStatement: function BreakStatement(reducer, node) { + return reducer.reduceBreakStatement(node); + }, + CallExpression: function CallExpression(reducer, node) { + var _this16 = this; + + return reducer.reduceCallExpression(node, { callee: function callee() { + return _this16[node.callee.type](reducer, node.callee); + }, arguments: node.arguments.map(function (v) { + return function () { + return _this16[v.type](reducer, v); + }; + }) }); + }, + CatchClause: function CatchClause(reducer, node) { + var _this17 = this; + + return reducer.reduceCatchClause(node, { binding: function binding() { + return _this17[node.binding.type](reducer, node.binding); + }, body: function body() { + return _this17.Block(reducer, node.body); + } }); + }, + ClassDeclaration: function ClassDeclaration(reducer, node) { + var _this18 = this; + + return reducer.reduceClassDeclaration(node, { name: function name() { + return _this18.BindingIdentifier(reducer, node.name); + }, super: node.super && function () { + return _this18[node.super.type](reducer, node.super); + }, elements: node.elements.map(function (v) { + return function () { + return _this18.ClassElement(reducer, v); + }; + }) }); + }, + ClassElement: function ClassElement(reducer, node) { + var _this19 = this; + + return reducer.reduceClassElement(node, { method: function method() { + return _this19[node.method.type](reducer, node.method); + } }); + }, + ClassExpression: function ClassExpression(reducer, node) { + var _this20 = this; + + return reducer.reduceClassExpression(node, { name: node.name && function () { + return _this20.BindingIdentifier(reducer, node.name); + }, super: node.super && function () { + return _this20[node.super.type](reducer, node.super); + }, elements: node.elements.map(function (v) { + return function () { + return _this20.ClassElement(reducer, v); + }; + }) }); + }, + CompoundAssignmentExpression: function CompoundAssignmentExpression(reducer, node) { + var _this21 = this; + + return reducer.reduceCompoundAssignmentExpression(node, { binding: function binding() { + return _this21[node.binding.type](reducer, node.binding); + }, expression: function expression() { + return _this21[node.expression.type](reducer, node.expression); + } }); + }, + ComputedMemberAssignmentTarget: function ComputedMemberAssignmentTarget(reducer, node) { + var _this22 = this; + + return reducer.reduceComputedMemberAssignmentTarget(node, { object: function object() { + return _this22[node.object.type](reducer, node.object); + }, expression: function expression() { + return _this22[node.expression.type](reducer, node.expression); + } }); + }, + ComputedMemberExpression: function ComputedMemberExpression(reducer, node) { + var _this23 = this; + + return reducer.reduceComputedMemberExpression(node, { object: function object() { + return _this23[node.object.type](reducer, node.object); + }, expression: function expression() { + return _this23[node.expression.type](reducer, node.expression); + } }); + }, + ComputedPropertyName: function ComputedPropertyName(reducer, node) { + var _this24 = this; + + return reducer.reduceComputedPropertyName(node, { expression: function expression() { + return _this24[node.expression.type](reducer, node.expression); + } }); + }, + ConditionalExpression: function ConditionalExpression(reducer, node) { + var _this25 = this; + + return reducer.reduceConditionalExpression(node, { test: function test() { + return _this25[node.test.type](reducer, node.test); + }, consequent: function consequent() { + return _this25[node.consequent.type](reducer, node.consequent); + }, alternate: function alternate() { + return _this25[node.alternate.type](reducer, node.alternate); + } }); + }, + ContinueStatement: function ContinueStatement(reducer, node) { + return reducer.reduceContinueStatement(node); + }, + DataProperty: function DataProperty(reducer, node) { + var _this26 = this; + + return reducer.reduceDataProperty(node, { name: function name() { + return _this26[node.name.type](reducer, node.name); + }, expression: function expression() { + return _this26[node.expression.type](reducer, node.expression); + } }); + }, + DebuggerStatement: function DebuggerStatement(reducer, node) { + return reducer.reduceDebuggerStatement(node); + }, + Directive: function Directive(reducer, node) { + return reducer.reduceDirective(node); + }, + DoWhileStatement: function DoWhileStatement(reducer, node) { + var _this27 = this; + + return reducer.reduceDoWhileStatement(node, { body: function body() { + return _this27[node.body.type](reducer, node.body); + }, test: function test() { + return _this27[node.test.type](reducer, node.test); + } }); + }, + EmptyStatement: function EmptyStatement(reducer, node) { + return reducer.reduceEmptyStatement(node); + }, + Export: function Export(reducer, node) { + var _this28 = this; + + return reducer.reduceExport(node, { declaration: function declaration() { + return _this28[node.declaration.type](reducer, node.declaration); + } }); + }, + ExportAllFrom: function ExportAllFrom(reducer, node) { + return reducer.reduceExportAllFrom(node); + }, + ExportDefault: function ExportDefault(reducer, node) { + var _this29 = this; + + return reducer.reduceExportDefault(node, { body: function body() { + return _this29[node.body.type](reducer, node.body); + } }); + }, + ExportFrom: function ExportFrom(reducer, node) { + var _this30 = this; + + return reducer.reduceExportFrom(node, { namedExports: node.namedExports.map(function (v) { + return function () { + return _this30.ExportFromSpecifier(reducer, v); + }; + }) }); + }, + ExportFromSpecifier: function ExportFromSpecifier(reducer, node) { + return reducer.reduceExportFromSpecifier(node); + }, + ExportLocalSpecifier: function ExportLocalSpecifier(reducer, node) { + var _this31 = this; + + return reducer.reduceExportLocalSpecifier(node, { name: function name() { + return _this31.IdentifierExpression(reducer, node.name); + } }); + }, + ExportLocals: function ExportLocals(reducer, node) { + var _this32 = this; + + return reducer.reduceExportLocals(node, { namedExports: node.namedExports.map(function (v) { + return function () { + return _this32.ExportLocalSpecifier(reducer, v); + }; + }) }); + }, + ExpressionStatement: function ExpressionStatement(reducer, node) { + var _this33 = this; + + return reducer.reduceExpressionStatement(node, { expression: function expression() { + return _this33[node.expression.type](reducer, node.expression); + } }); + }, + ForAwaitStatement: function ForAwaitStatement(reducer, node) { + var _this34 = this; + + return reducer.reduceForAwaitStatement(node, { left: function left() { + return _this34[node.left.type](reducer, node.left); + }, right: function right() { + return _this34[node.right.type](reducer, node.right); + }, body: function body() { + return _this34[node.body.type](reducer, node.body); + } }); + }, + ForInStatement: function ForInStatement(reducer, node) { + var _this35 = this; + + return reducer.reduceForInStatement(node, { left: function left() { + return _this35[node.left.type](reducer, node.left); + }, right: function right() { + return _this35[node.right.type](reducer, node.right); + }, body: function body() { + return _this35[node.body.type](reducer, node.body); + } }); + }, + ForOfStatement: function ForOfStatement(reducer, node) { + var _this36 = this; + + return reducer.reduceForOfStatement(node, { left: function left() { + return _this36[node.left.type](reducer, node.left); + }, right: function right() { + return _this36[node.right.type](reducer, node.right); + }, body: function body() { + return _this36[node.body.type](reducer, node.body); + } }); + }, + ForStatement: function ForStatement(reducer, node) { + var _this37 = this; + + return reducer.reduceForStatement(node, { init: node.init && function () { + return _this37[node.init.type](reducer, node.init); + }, test: node.test && function () { + return _this37[node.test.type](reducer, node.test); + }, update: node.update && function () { + return _this37[node.update.type](reducer, node.update); + }, body: function body() { + return _this37[node.body.type](reducer, node.body); + } }); + }, + FormalParameters: function FormalParameters(reducer, node) { + var _this38 = this; + + return reducer.reduceFormalParameters(node, { items: node.items.map(function (v) { + return function () { + return _this38[v.type](reducer, v); + }; + }), rest: node.rest && function () { + return _this38[node.rest.type](reducer, node.rest); + } }); + }, + FunctionBody: function FunctionBody(reducer, node) { + var _this39 = this; + + return reducer.reduceFunctionBody(node, { directives: node.directives.map(function (v) { + return function () { + return _this39.Directive(reducer, v); + }; + }), statements: node.statements.map(function (v) { + return function () { + return _this39[v.type](reducer, v); + }; + }) }); + }, + FunctionDeclaration: function FunctionDeclaration(reducer, node) { + var _this40 = this; + + return reducer.reduceFunctionDeclaration(node, { name: function name() { + return _this40.BindingIdentifier(reducer, node.name); + }, params: function params() { + return _this40.FormalParameters(reducer, node.params); + }, body: function body() { + return _this40.FunctionBody(reducer, node.body); + } }); + }, + FunctionExpression: function FunctionExpression(reducer, node) { + var _this41 = this; + + return reducer.reduceFunctionExpression(node, { name: node.name && function () { + return _this41.BindingIdentifier(reducer, node.name); + }, params: function params() { + return _this41.FormalParameters(reducer, node.params); + }, body: function body() { + return _this41.FunctionBody(reducer, node.body); + } }); + }, + Getter: function Getter(reducer, node) { + var _this42 = this; + + return reducer.reduceGetter(node, { name: function name() { + return _this42[node.name.type](reducer, node.name); + }, body: function body() { + return _this42.FunctionBody(reducer, node.body); + } }); + }, + IdentifierExpression: function IdentifierExpression(reducer, node) { + return reducer.reduceIdentifierExpression(node); + }, + IfStatement: function IfStatement(reducer, node) { + var _this43 = this; + + return reducer.reduceIfStatement(node, { test: function test() { + return _this43[node.test.type](reducer, node.test); + }, consequent: function consequent() { + return _this43[node.consequent.type](reducer, node.consequent); + }, alternate: node.alternate && function () { + return _this43[node.alternate.type](reducer, node.alternate); + } }); + }, + Import: function Import(reducer, node) { + var _this44 = this; + + return reducer.reduceImport(node, { defaultBinding: node.defaultBinding && function () { + return _this44.BindingIdentifier(reducer, node.defaultBinding); + }, namedImports: node.namedImports.map(function (v) { + return function () { + return _this44.ImportSpecifier(reducer, v); + }; + }) }); + }, + ImportNamespace: function ImportNamespace(reducer, node) { + var _this45 = this; + + return reducer.reduceImportNamespace(node, { defaultBinding: node.defaultBinding && function () { + return _this45.BindingIdentifier(reducer, node.defaultBinding); + }, namespaceBinding: function namespaceBinding() { + return _this45.BindingIdentifier(reducer, node.namespaceBinding); + } }); + }, + ImportSpecifier: function ImportSpecifier(reducer, node) { + var _this46 = this; + + return reducer.reduceImportSpecifier(node, { binding: function binding() { + return _this46.BindingIdentifier(reducer, node.binding); + } }); + }, + LabeledStatement: function LabeledStatement(reducer, node) { + var _this47 = this; + + return reducer.reduceLabeledStatement(node, { body: function body() { + return _this47[node.body.type](reducer, node.body); + } }); + }, + LiteralBooleanExpression: function LiteralBooleanExpression(reducer, node) { + return reducer.reduceLiteralBooleanExpression(node); + }, + LiteralInfinityExpression: function LiteralInfinityExpression(reducer, node) { + return reducer.reduceLiteralInfinityExpression(node); + }, + LiteralNullExpression: function LiteralNullExpression(reducer, node) { + return reducer.reduceLiteralNullExpression(node); + }, + LiteralNumericExpression: function LiteralNumericExpression(reducer, node) { + return reducer.reduceLiteralNumericExpression(node); + }, + LiteralRegExpExpression: function LiteralRegExpExpression(reducer, node) { + return reducer.reduceLiteralRegExpExpression(node); + }, + LiteralStringExpression: function LiteralStringExpression(reducer, node) { + return reducer.reduceLiteralStringExpression(node); + }, + Method: function Method(reducer, node) { + var _this48 = this; + + return reducer.reduceMethod(node, { name: function name() { + return _this48[node.name.type](reducer, node.name); + }, params: function params() { + return _this48.FormalParameters(reducer, node.params); + }, body: function body() { + return _this48.FunctionBody(reducer, node.body); + } }); + }, + Module: function Module(reducer, node) { + var _this49 = this; + + return reducer.reduceModule(node, { directives: node.directives.map(function (v) { + return function () { + return _this49.Directive(reducer, v); + }; + }), items: node.items.map(function (v) { + return function () { + return _this49[v.type](reducer, v); + }; + }) }); + }, + NewExpression: function NewExpression(reducer, node) { + var _this50 = this; + + return reducer.reduceNewExpression(node, { callee: function callee() { + return _this50[node.callee.type](reducer, node.callee); + }, arguments: node.arguments.map(function (v) { + return function () { + return _this50[v.type](reducer, v); + }; + }) }); + }, + NewTargetExpression: function NewTargetExpression(reducer, node) { + return reducer.reduceNewTargetExpression(node); + }, + ObjectAssignmentTarget: function ObjectAssignmentTarget(reducer, node) { + var _this51 = this; + + return reducer.reduceObjectAssignmentTarget(node, { properties: node.properties.map(function (v) { + return function () { + return _this51[v.type](reducer, v); + }; + }), rest: node.rest && function () { + return _this51[node.rest.type](reducer, node.rest); + } }); + }, + ObjectBinding: function ObjectBinding(reducer, node) { + var _this52 = this; + + return reducer.reduceObjectBinding(node, { properties: node.properties.map(function (v) { + return function () { + return _this52[v.type](reducer, v); + }; + }), rest: node.rest && function () { + return _this52[node.rest.type](reducer, node.rest); + } }); + }, + ObjectExpression: function ObjectExpression(reducer, node) { + var _this53 = this; + + return reducer.reduceObjectExpression(node, { properties: node.properties.map(function (v) { + return function () { + return _this53[v.type](reducer, v); + }; + }) }); + }, + ReturnStatement: function ReturnStatement(reducer, node) { + var _this54 = this; + + return reducer.reduceReturnStatement(node, { expression: node.expression && function () { + return _this54[node.expression.type](reducer, node.expression); + } }); + }, + Script: function Script(reducer, node) { + var _this55 = this; + + return reducer.reduceScript(node, { directives: node.directives.map(function (v) { + return function () { + return _this55.Directive(reducer, v); + }; + }), statements: node.statements.map(function (v) { + return function () { + return _this55[v.type](reducer, v); + }; + }) }); + }, + Setter: function Setter(reducer, node) { + var _this56 = this; + + return reducer.reduceSetter(node, { name: function name() { + return _this56[node.name.type](reducer, node.name); + }, param: function param() { + return _this56[node.param.type](reducer, node.param); + }, body: function body() { + return _this56.FunctionBody(reducer, node.body); + } }); + }, + ShorthandProperty: function ShorthandProperty(reducer, node) { + var _this57 = this; + + return reducer.reduceShorthandProperty(node, { name: function name() { + return _this57.IdentifierExpression(reducer, node.name); + } }); + }, + SpreadElement: function SpreadElement(reducer, node) { + var _this58 = this; + + return reducer.reduceSpreadElement(node, { expression: function expression() { + return _this58[node.expression.type](reducer, node.expression); + } }); + }, + SpreadProperty: function SpreadProperty(reducer, node) { + var _this59 = this; + + return reducer.reduceSpreadProperty(node, { expression: function expression() { + return _this59[node.expression.type](reducer, node.expression); + } }); + }, + StaticMemberAssignmentTarget: function StaticMemberAssignmentTarget(reducer, node) { + var _this60 = this; + + return reducer.reduceStaticMemberAssignmentTarget(node, { object: function object() { + return _this60[node.object.type](reducer, node.object); + } }); + }, + StaticMemberExpression: function StaticMemberExpression(reducer, node) { + var _this61 = this; + + return reducer.reduceStaticMemberExpression(node, { object: function object() { + return _this61[node.object.type](reducer, node.object); + } }); + }, + StaticPropertyName: function StaticPropertyName(reducer, node) { + return reducer.reduceStaticPropertyName(node); + }, + Super: function Super(reducer, node) { + return reducer.reduceSuper(node); + }, + SwitchCase: function SwitchCase(reducer, node) { + var _this62 = this; + + return reducer.reduceSwitchCase(node, { test: function test() { + return _this62[node.test.type](reducer, node.test); + }, consequent: node.consequent.map(function (v) { + return function () { + return _this62[v.type](reducer, v); + }; + }) }); + }, + SwitchDefault: function SwitchDefault(reducer, node) { + var _this63 = this; + + return reducer.reduceSwitchDefault(node, { consequent: node.consequent.map(function (v) { + return function () { + return _this63[v.type](reducer, v); + }; + }) }); + }, + SwitchStatement: function SwitchStatement(reducer, node) { + var _this64 = this; + + return reducer.reduceSwitchStatement(node, { discriminant: function discriminant() { + return _this64[node.discriminant.type](reducer, node.discriminant); + }, cases: node.cases.map(function (v) { + return function () { + return _this64.SwitchCase(reducer, v); + }; + }) }); + }, + SwitchStatementWithDefault: function SwitchStatementWithDefault(reducer, node) { + var _this65 = this; + + return reducer.reduceSwitchStatementWithDefault(node, { discriminant: function discriminant() { + return _this65[node.discriminant.type](reducer, node.discriminant); + }, preDefaultCases: node.preDefaultCases.map(function (v) { + return function () { + return _this65.SwitchCase(reducer, v); + }; + }), defaultCase: function defaultCase() { + return _this65.SwitchDefault(reducer, node.defaultCase); + }, postDefaultCases: node.postDefaultCases.map(function (v) { + return function () { + return _this65.SwitchCase(reducer, v); + }; + }) }); + }, + TemplateElement: function TemplateElement(reducer, node) { + return reducer.reduceTemplateElement(node); + }, + TemplateExpression: function TemplateExpression(reducer, node) { + var _this66 = this; + + return reducer.reduceTemplateExpression(node, { tag: node.tag && function () { + return _this66[node.tag.type](reducer, node.tag); + }, elements: node.elements.map(function (v) { + return function () { + return _this66[v.type](reducer, v); + }; + }) }); + }, + ThisExpression: function ThisExpression(reducer, node) { + return reducer.reduceThisExpression(node); + }, + ThrowStatement: function ThrowStatement(reducer, node) { + var _this67 = this; + + return reducer.reduceThrowStatement(node, { expression: function expression() { + return _this67[node.expression.type](reducer, node.expression); + } }); + }, + TryCatchStatement: function TryCatchStatement(reducer, node) { + var _this68 = this; + + return reducer.reduceTryCatchStatement(node, { body: function body() { + return _this68.Block(reducer, node.body); + }, catchClause: function catchClause() { + return _this68.CatchClause(reducer, node.catchClause); + } }); + }, + TryFinallyStatement: function TryFinallyStatement(reducer, node) { + var _this69 = this; + + return reducer.reduceTryFinallyStatement(node, { body: function body() { + return _this69.Block(reducer, node.body); + }, catchClause: node.catchClause && function () { + return _this69.CatchClause(reducer, node.catchClause); + }, finalizer: function finalizer() { + return _this69.Block(reducer, node.finalizer); + } }); + }, + UnaryExpression: function UnaryExpression(reducer, node) { + var _this70 = this; + + return reducer.reduceUnaryExpression(node, { operand: function operand() { + return _this70[node.operand.type](reducer, node.operand); + } }); + }, + UpdateExpression: function UpdateExpression(reducer, node) { + var _this71 = this; + + return reducer.reduceUpdateExpression(node, { operand: function operand() { + return _this71[node.operand.type](reducer, node.operand); + } }); + }, + VariableDeclaration: function VariableDeclaration(reducer, node) { + var _this72 = this; + + return reducer.reduceVariableDeclaration(node, { declarators: node.declarators.map(function (v) { + return function () { + return _this72.VariableDeclarator(reducer, v); + }; + }) }); + }, + VariableDeclarationStatement: function VariableDeclarationStatement(reducer, node) { + var _this73 = this; + + return reducer.reduceVariableDeclarationStatement(node, { declaration: function declaration() { + return _this73.VariableDeclaration(reducer, node.declaration); + } }); + }, + VariableDeclarator: function VariableDeclarator(reducer, node) { + var _this74 = this; + + return reducer.reduceVariableDeclarator(node, { binding: function binding() { + return _this74[node.binding.type](reducer, node.binding); + }, init: node.init && function () { + return _this74[node.init.type](reducer, node.init); + } }); + }, + WhileStatement: function WhileStatement(reducer, node) { + var _this75 = this; + + return reducer.reduceWhileStatement(node, { test: function test() { + return _this75[node.test.type](reducer, node.test); + }, body: function body() { + return _this75[node.body.type](reducer, node.body); + } }); + }, + WithStatement: function WithStatement(reducer, node) { + var _this76 = this; + + return reducer.reduceWithStatement(node, { object: function object() { + return _this76[node.object.type](reducer, node.object); + }, body: function body() { + return _this76[node.body.type](reducer, node.body); + } }); + }, + YieldExpression: function YieldExpression(reducer, node) { + var _this77 = this; + + return reducer.reduceYieldExpression(node, { expression: node.expression && function () { + return _this77[node.expression.type](reducer, node.expression); + } }); + }, + YieldGeneratorExpression: function YieldGeneratorExpression(reducer, node) { + var _this78 = this; + + return reducer.reduceYieldGeneratorExpression(node, { expression: function expression() { + return _this78[node.expression.type](reducer, node.expression); + } }); + } +}; + +function thunkedReduce(reducer, node) { + return director[node.type](reducer, node); +} +}); + +var thunkify_1 = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = thunkify; +// Generated by generate-thunkify.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function thunkify(reducer) { + return { + reduceArrayAssignmentTarget: function reduceArrayAssignmentTarget(node, _ref) { + var elements = _ref.elements, + rest = _ref.rest; + + return reducer.reduceArrayAssignmentTarget(node, { elements: elements.map(function (n) { + return n == null ? null : n(); + }), rest: rest == null ? null : rest() }); + }, + reduceArrayBinding: function reduceArrayBinding(node, _ref2) { + var elements = _ref2.elements, + rest = _ref2.rest; + + return reducer.reduceArrayBinding(node, { elements: elements.map(function (n) { + return n == null ? null : n(); + }), rest: rest == null ? null : rest() }); + }, + reduceArrayExpression: function reduceArrayExpression(node, _ref3) { + var elements = _ref3.elements; + + return reducer.reduceArrayExpression(node, { elements: elements.map(function (n) { + return n == null ? null : n(); + }) }); + }, + reduceArrowExpression: function reduceArrowExpression(node, _ref4) { + var params = _ref4.params, + body = _ref4.body; + + return reducer.reduceArrowExpression(node, { params: params(), body: body() }); + }, + reduceAssignmentExpression: function reduceAssignmentExpression(node, _ref5) { + var binding = _ref5.binding, + expression = _ref5.expression; + + return reducer.reduceAssignmentExpression(node, { binding: binding(), expression: expression() }); + }, + reduceAssignmentTargetIdentifier: function reduceAssignmentTargetIdentifier(node) { + return reducer.reduceAssignmentTargetIdentifier(node); + }, + reduceAssignmentTargetPropertyIdentifier: function reduceAssignmentTargetPropertyIdentifier(node, _ref6) { + var binding = _ref6.binding, + init = _ref6.init; + + return reducer.reduceAssignmentTargetPropertyIdentifier(node, { binding: binding(), init: init == null ? null : init() }); + }, + reduceAssignmentTargetPropertyProperty: function reduceAssignmentTargetPropertyProperty(node, _ref7) { + var name = _ref7.name, + binding = _ref7.binding; + + return reducer.reduceAssignmentTargetPropertyProperty(node, { name: name(), binding: binding() }); + }, + reduceAssignmentTargetWithDefault: function reduceAssignmentTargetWithDefault(node, _ref8) { + var binding = _ref8.binding, + init = _ref8.init; + + return reducer.reduceAssignmentTargetWithDefault(node, { binding: binding(), init: init() }); + }, + reduceAwaitExpression: function reduceAwaitExpression(node, _ref9) { + var expression = _ref9.expression; + + return reducer.reduceAwaitExpression(node, { expression: expression() }); + }, + reduceBinaryExpression: function reduceBinaryExpression(node, _ref10) { + var left = _ref10.left, + right = _ref10.right; + + return reducer.reduceBinaryExpression(node, { left: left(), right: right() }); + }, + reduceBindingIdentifier: function reduceBindingIdentifier(node) { + return reducer.reduceBindingIdentifier(node); + }, + reduceBindingPropertyIdentifier: function reduceBindingPropertyIdentifier(node, _ref11) { + var binding = _ref11.binding, + init = _ref11.init; + + return reducer.reduceBindingPropertyIdentifier(node, { binding: binding(), init: init == null ? null : init() }); + }, + reduceBindingPropertyProperty: function reduceBindingPropertyProperty(node, _ref12) { + var name = _ref12.name, + binding = _ref12.binding; + + return reducer.reduceBindingPropertyProperty(node, { name: name(), binding: binding() }); + }, + reduceBindingWithDefault: function reduceBindingWithDefault(node, _ref13) { + var binding = _ref13.binding, + init = _ref13.init; + + return reducer.reduceBindingWithDefault(node, { binding: binding(), init: init() }); + }, + reduceBlock: function reduceBlock(node, _ref14) { + var statements = _ref14.statements; + + return reducer.reduceBlock(node, { statements: statements.map(function (n) { + return n(); + }) }); + }, + reduceBlockStatement: function reduceBlockStatement(node, _ref15) { + var block = _ref15.block; + + return reducer.reduceBlockStatement(node, { block: block() }); + }, + reduceBreakStatement: function reduceBreakStatement(node) { + return reducer.reduceBreakStatement(node); + }, + reduceCallExpression: function reduceCallExpression(node, _ref16) { + var callee = _ref16.callee, + _arguments = _ref16.arguments; + + return reducer.reduceCallExpression(node, { callee: callee(), arguments: _arguments.map(function (n) { + return n(); + }) }); + }, + reduceCatchClause: function reduceCatchClause(node, _ref17) { + var binding = _ref17.binding, + body = _ref17.body; + + return reducer.reduceCatchClause(node, { binding: binding(), body: body() }); + }, + reduceClassDeclaration: function reduceClassDeclaration(node, _ref18) { + var name = _ref18.name, + _super = _ref18.super, + elements = _ref18.elements; + + return reducer.reduceClassDeclaration(node, { name: name(), super: _super == null ? null : _super(), elements: elements.map(function (n) { + return n(); + }) }); + }, + reduceClassElement: function reduceClassElement(node, _ref19) { + var method = _ref19.method; + + return reducer.reduceClassElement(node, { method: method() }); + }, + reduceClassExpression: function reduceClassExpression(node, _ref20) { + var name = _ref20.name, + _super = _ref20.super, + elements = _ref20.elements; + + return reducer.reduceClassExpression(node, { name: name == null ? null : name(), super: _super == null ? null : _super(), elements: elements.map(function (n) { + return n(); + }) }); + }, + reduceCompoundAssignmentExpression: function reduceCompoundAssignmentExpression(node, _ref21) { + var binding = _ref21.binding, + expression = _ref21.expression; + + return reducer.reduceCompoundAssignmentExpression(node, { binding: binding(), expression: expression() }); + }, + reduceComputedMemberAssignmentTarget: function reduceComputedMemberAssignmentTarget(node, _ref22) { + var object = _ref22.object, + expression = _ref22.expression; + + return reducer.reduceComputedMemberAssignmentTarget(node, { object: object(), expression: expression() }); + }, + reduceComputedMemberExpression: function reduceComputedMemberExpression(node, _ref23) { + var object = _ref23.object, + expression = _ref23.expression; + + return reducer.reduceComputedMemberExpression(node, { object: object(), expression: expression() }); + }, + reduceComputedPropertyName: function reduceComputedPropertyName(node, _ref24) { + var expression = _ref24.expression; + + return reducer.reduceComputedPropertyName(node, { expression: expression() }); + }, + reduceConditionalExpression: function reduceConditionalExpression(node, _ref25) { + var test = _ref25.test, + consequent = _ref25.consequent, + alternate = _ref25.alternate; + + return reducer.reduceConditionalExpression(node, { test: test(), consequent: consequent(), alternate: alternate() }); + }, + reduceContinueStatement: function reduceContinueStatement(node) { + return reducer.reduceContinueStatement(node); + }, + reduceDataProperty: function reduceDataProperty(node, _ref26) { + var name = _ref26.name, + expression = _ref26.expression; + + return reducer.reduceDataProperty(node, { name: name(), expression: expression() }); + }, + reduceDebuggerStatement: function reduceDebuggerStatement(node) { + return reducer.reduceDebuggerStatement(node); + }, + reduceDirective: function reduceDirective(node) { + return reducer.reduceDirective(node); + }, + reduceDoWhileStatement: function reduceDoWhileStatement(node, _ref27) { + var body = _ref27.body, + test = _ref27.test; + + return reducer.reduceDoWhileStatement(node, { body: body(), test: test() }); + }, + reduceEmptyStatement: function reduceEmptyStatement(node) { + return reducer.reduceEmptyStatement(node); + }, + reduceExport: function reduceExport(node, _ref28) { + var declaration = _ref28.declaration; + + return reducer.reduceExport(node, { declaration: declaration() }); + }, + reduceExportAllFrom: function reduceExportAllFrom(node) { + return reducer.reduceExportAllFrom(node); + }, + reduceExportDefault: function reduceExportDefault(node, _ref29) { + var body = _ref29.body; + + return reducer.reduceExportDefault(node, { body: body() }); + }, + reduceExportFrom: function reduceExportFrom(node, _ref30) { + var namedExports = _ref30.namedExports; + + return reducer.reduceExportFrom(node, { namedExports: namedExports.map(function (n) { + return n(); + }) }); + }, + reduceExportFromSpecifier: function reduceExportFromSpecifier(node) { + return reducer.reduceExportFromSpecifier(node); + }, + reduceExportLocalSpecifier: function reduceExportLocalSpecifier(node, _ref31) { + var name = _ref31.name; + + return reducer.reduceExportLocalSpecifier(node, { name: name() }); + }, + reduceExportLocals: function reduceExportLocals(node, _ref32) { + var namedExports = _ref32.namedExports; + + return reducer.reduceExportLocals(node, { namedExports: namedExports.map(function (n) { + return n(); + }) }); + }, + reduceExpressionStatement: function reduceExpressionStatement(node, _ref33) { + var expression = _ref33.expression; + + return reducer.reduceExpressionStatement(node, { expression: expression() }); + }, + reduceForAwaitStatement: function reduceForAwaitStatement(node, _ref34) { + var left = _ref34.left, + right = _ref34.right, + body = _ref34.body; + + return reducer.reduceForAwaitStatement(node, { left: left(), right: right(), body: body() }); + }, + reduceForInStatement: function reduceForInStatement(node, _ref35) { + var left = _ref35.left, + right = _ref35.right, + body = _ref35.body; + + return reducer.reduceForInStatement(node, { left: left(), right: right(), body: body() }); + }, + reduceForOfStatement: function reduceForOfStatement(node, _ref36) { + var left = _ref36.left, + right = _ref36.right, + body = _ref36.body; + + return reducer.reduceForOfStatement(node, { left: left(), right: right(), body: body() }); + }, + reduceForStatement: function reduceForStatement(node, _ref37) { + var init = _ref37.init, + test = _ref37.test, + update = _ref37.update, + body = _ref37.body; + + return reducer.reduceForStatement(node, { init: init == null ? null : init(), test: test == null ? null : test(), update: update == null ? null : update(), body: body() }); + }, + reduceFormalParameters: function reduceFormalParameters(node, _ref38) { + var items = _ref38.items, + rest = _ref38.rest; + + return reducer.reduceFormalParameters(node, { items: items.map(function (n) { + return n(); + }), rest: rest == null ? null : rest() }); + }, + reduceFunctionBody: function reduceFunctionBody(node, _ref39) { + var directives = _ref39.directives, + statements = _ref39.statements; + + return reducer.reduceFunctionBody(node, { directives: directives.map(function (n) { + return n(); + }), statements: statements.map(function (n) { + return n(); + }) }); + }, + reduceFunctionDeclaration: function reduceFunctionDeclaration(node, _ref40) { + var name = _ref40.name, + params = _ref40.params, + body = _ref40.body; + + return reducer.reduceFunctionDeclaration(node, { name: name(), params: params(), body: body() }); + }, + reduceFunctionExpression: function reduceFunctionExpression(node, _ref41) { + var name = _ref41.name, + params = _ref41.params, + body = _ref41.body; + + return reducer.reduceFunctionExpression(node, { name: name == null ? null : name(), params: params(), body: body() }); + }, + reduceGetter: function reduceGetter(node, _ref42) { + var name = _ref42.name, + body = _ref42.body; + + return reducer.reduceGetter(node, { name: name(), body: body() }); + }, + reduceIdentifierExpression: function reduceIdentifierExpression(node) { + return reducer.reduceIdentifierExpression(node); + }, + reduceIfStatement: function reduceIfStatement(node, _ref43) { + var test = _ref43.test, + consequent = _ref43.consequent, + alternate = _ref43.alternate; + + return reducer.reduceIfStatement(node, { test: test(), consequent: consequent(), alternate: alternate == null ? null : alternate() }); + }, + reduceImport: function reduceImport(node, _ref44) { + var defaultBinding = _ref44.defaultBinding, + namedImports = _ref44.namedImports; + + return reducer.reduceImport(node, { defaultBinding: defaultBinding == null ? null : defaultBinding(), namedImports: namedImports.map(function (n) { + return n(); + }) }); + }, + reduceImportNamespace: function reduceImportNamespace(node, _ref45) { + var defaultBinding = _ref45.defaultBinding, + namespaceBinding = _ref45.namespaceBinding; + + return reducer.reduceImportNamespace(node, { defaultBinding: defaultBinding == null ? null : defaultBinding(), namespaceBinding: namespaceBinding() }); + }, + reduceImportSpecifier: function reduceImportSpecifier(node, _ref46) { + var binding = _ref46.binding; + + return reducer.reduceImportSpecifier(node, { binding: binding() }); + }, + reduceLabeledStatement: function reduceLabeledStatement(node, _ref47) { + var body = _ref47.body; + + return reducer.reduceLabeledStatement(node, { body: body() }); + }, + reduceLiteralBooleanExpression: function reduceLiteralBooleanExpression(node) { + return reducer.reduceLiteralBooleanExpression(node); + }, + reduceLiteralInfinityExpression: function reduceLiteralInfinityExpression(node) { + return reducer.reduceLiteralInfinityExpression(node); + }, + reduceLiteralNullExpression: function reduceLiteralNullExpression(node) { + return reducer.reduceLiteralNullExpression(node); + }, + reduceLiteralNumericExpression: function reduceLiteralNumericExpression(node) { + return reducer.reduceLiteralNumericExpression(node); + }, + reduceLiteralRegExpExpression: function reduceLiteralRegExpExpression(node) { + return reducer.reduceLiteralRegExpExpression(node); + }, + reduceLiteralStringExpression: function reduceLiteralStringExpression(node) { + return reducer.reduceLiteralStringExpression(node); + }, + reduceMethod: function reduceMethod(node, _ref48) { + var name = _ref48.name, + params = _ref48.params, + body = _ref48.body; + + return reducer.reduceMethod(node, { name: name(), params: params(), body: body() }); + }, + reduceModule: function reduceModule(node, _ref49) { + var directives = _ref49.directives, + items = _ref49.items; + + return reducer.reduceModule(node, { directives: directives.map(function (n) { + return n(); + }), items: items.map(function (n) { + return n(); + }) }); + }, + reduceNewExpression: function reduceNewExpression(node, _ref50) { + var callee = _ref50.callee, + _arguments = _ref50.arguments; + + return reducer.reduceNewExpression(node, { callee: callee(), arguments: _arguments.map(function (n) { + return n(); + }) }); + }, + reduceNewTargetExpression: function reduceNewTargetExpression(node) { + return reducer.reduceNewTargetExpression(node); + }, + reduceObjectAssignmentTarget: function reduceObjectAssignmentTarget(node, _ref51) { + var properties = _ref51.properties, + rest = _ref51.rest; + + return reducer.reduceObjectAssignmentTarget(node, { properties: properties.map(function (n) { + return n(); + }), rest: rest == null ? null : rest() }); + }, + reduceObjectBinding: function reduceObjectBinding(node, _ref52) { + var properties = _ref52.properties, + rest = _ref52.rest; + + return reducer.reduceObjectBinding(node, { properties: properties.map(function (n) { + return n(); + }), rest: rest == null ? null : rest() }); + }, + reduceObjectExpression: function reduceObjectExpression(node, _ref53) { + var properties = _ref53.properties; + + return reducer.reduceObjectExpression(node, { properties: properties.map(function (n) { + return n(); + }) }); + }, + reduceReturnStatement: function reduceReturnStatement(node, _ref54) { + var expression = _ref54.expression; + + return reducer.reduceReturnStatement(node, { expression: expression == null ? null : expression() }); + }, + reduceScript: function reduceScript(node, _ref55) { + var directives = _ref55.directives, + statements = _ref55.statements; + + return reducer.reduceScript(node, { directives: directives.map(function (n) { + return n(); + }), statements: statements.map(function (n) { + return n(); + }) }); + }, + reduceSetter: function reduceSetter(node, _ref56) { + var name = _ref56.name, + param = _ref56.param, + body = _ref56.body; + + return reducer.reduceSetter(node, { name: name(), param: param(), body: body() }); + }, + reduceShorthandProperty: function reduceShorthandProperty(node, _ref57) { + var name = _ref57.name; + + return reducer.reduceShorthandProperty(node, { name: name() }); + }, + reduceSpreadElement: function reduceSpreadElement(node, _ref58) { + var expression = _ref58.expression; + + return reducer.reduceSpreadElement(node, { expression: expression() }); + }, + reduceSpreadProperty: function reduceSpreadProperty(node, _ref59) { + var expression = _ref59.expression; + + return reducer.reduceSpreadProperty(node, { expression: expression() }); + }, + reduceStaticMemberAssignmentTarget: function reduceStaticMemberAssignmentTarget(node, _ref60) { + var object = _ref60.object; + + return reducer.reduceStaticMemberAssignmentTarget(node, { object: object() }); + }, + reduceStaticMemberExpression: function reduceStaticMemberExpression(node, _ref61) { + var object = _ref61.object; + + return reducer.reduceStaticMemberExpression(node, { object: object() }); + }, + reduceStaticPropertyName: function reduceStaticPropertyName(node) { + return reducer.reduceStaticPropertyName(node); + }, + reduceSuper: function reduceSuper(node) { + return reducer.reduceSuper(node); + }, + reduceSwitchCase: function reduceSwitchCase(node, _ref62) { + var test = _ref62.test, + consequent = _ref62.consequent; + + return reducer.reduceSwitchCase(node, { test: test(), consequent: consequent.map(function (n) { + return n(); + }) }); + }, + reduceSwitchDefault: function reduceSwitchDefault(node, _ref63) { + var consequent = _ref63.consequent; + + return reducer.reduceSwitchDefault(node, { consequent: consequent.map(function (n) { + return n(); + }) }); + }, + reduceSwitchStatement: function reduceSwitchStatement(node, _ref64) { + var discriminant = _ref64.discriminant, + cases = _ref64.cases; + + return reducer.reduceSwitchStatement(node, { discriminant: discriminant(), cases: cases.map(function (n) { + return n(); + }) }); + }, + reduceSwitchStatementWithDefault: function reduceSwitchStatementWithDefault(node, _ref65) { + var discriminant = _ref65.discriminant, + preDefaultCases = _ref65.preDefaultCases, + defaultCase = _ref65.defaultCase, + postDefaultCases = _ref65.postDefaultCases; + + return reducer.reduceSwitchStatementWithDefault(node, { discriminant: discriminant(), preDefaultCases: preDefaultCases.map(function (n) { + return n(); + }), defaultCase: defaultCase(), postDefaultCases: postDefaultCases.map(function (n) { + return n(); + }) }); + }, + reduceTemplateElement: function reduceTemplateElement(node) { + return reducer.reduceTemplateElement(node); + }, + reduceTemplateExpression: function reduceTemplateExpression(node, _ref66) { + var tag = _ref66.tag, + elements = _ref66.elements; + + return reducer.reduceTemplateExpression(node, { tag: tag == null ? null : tag(), elements: elements.map(function (n) { + return n(); + }) }); + }, + reduceThisExpression: function reduceThisExpression(node) { + return reducer.reduceThisExpression(node); + }, + reduceThrowStatement: function reduceThrowStatement(node, _ref67) { + var expression = _ref67.expression; + + return reducer.reduceThrowStatement(node, { expression: expression() }); + }, + reduceTryCatchStatement: function reduceTryCatchStatement(node, _ref68) { + var body = _ref68.body, + catchClause = _ref68.catchClause; + + return reducer.reduceTryCatchStatement(node, { body: body(), catchClause: catchClause() }); + }, + reduceTryFinallyStatement: function reduceTryFinallyStatement(node, _ref69) { + var body = _ref69.body, + catchClause = _ref69.catchClause, + finalizer = _ref69.finalizer; + + return reducer.reduceTryFinallyStatement(node, { body: body(), catchClause: catchClause == null ? null : catchClause(), finalizer: finalizer() }); + }, + reduceUnaryExpression: function reduceUnaryExpression(node, _ref70) { + var operand = _ref70.operand; + + return reducer.reduceUnaryExpression(node, { operand: operand() }); + }, + reduceUpdateExpression: function reduceUpdateExpression(node, _ref71) { + var operand = _ref71.operand; + + return reducer.reduceUpdateExpression(node, { operand: operand() }); + }, + reduceVariableDeclaration: function reduceVariableDeclaration(node, _ref72) { + var declarators = _ref72.declarators; + + return reducer.reduceVariableDeclaration(node, { declarators: declarators.map(function (n) { + return n(); + }) }); + }, + reduceVariableDeclarationStatement: function reduceVariableDeclarationStatement(node, _ref73) { + var declaration = _ref73.declaration; + + return reducer.reduceVariableDeclarationStatement(node, { declaration: declaration() }); + }, + reduceVariableDeclarator: function reduceVariableDeclarator(node, _ref74) { + var binding = _ref74.binding, + init = _ref74.init; + + return reducer.reduceVariableDeclarator(node, { binding: binding(), init: init == null ? null : init() }); + }, + reduceWhileStatement: function reduceWhileStatement(node, _ref75) { + var test = _ref75.test, + body = _ref75.body; + + return reducer.reduceWhileStatement(node, { test: test(), body: body() }); + }, + reduceWithStatement: function reduceWithStatement(node, _ref76) { + var object = _ref76.object, + body = _ref76.body; + + return reducer.reduceWithStatement(node, { object: object(), body: body() }); + }, + reduceYieldExpression: function reduceYieldExpression(node, _ref77) { + var expression = _ref77.expression; + + return reducer.reduceYieldExpression(node, { expression: expression == null ? null : expression() }); + }, + reduceYieldGeneratorExpression: function reduceYieldGeneratorExpression(node, _ref78) { + var expression = _ref78.expression; + + return reducer.reduceYieldGeneratorExpression(node, { expression: expression() }); + } + }; +} +}); + +var thunkifyClass_1 = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + +exports.default = thunkifyClass; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +// Generated by generate-thunkify.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function thunkifyClass(reducerClass) { + return function (_reducerClass) { + _inherits(_class, _reducerClass); + + function _class() { + _classCallCheck(this, _class); + + return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments)); + } + + _createClass(_class, [{ + key: "reduceArrayAssignmentTarget", + value: function reduceArrayAssignmentTarget(node, _ref) { + var elements = _ref.elements, + rest = _ref.rest; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceArrayAssignmentTarget", this).call(this, node, { elements: elements.map(function (n) { + return n == null ? null : n(); + }), rest: rest == null ? null : rest() }); + } + }, { + key: "reduceArrayBinding", + value: function reduceArrayBinding(node, _ref2) { + var elements = _ref2.elements, + rest = _ref2.rest; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceArrayBinding", this).call(this, node, { elements: elements.map(function (n) { + return n == null ? null : n(); + }), rest: rest == null ? null : rest() }); + } + }, { + key: "reduceArrayExpression", + value: function reduceArrayExpression(node, _ref3) { + var elements = _ref3.elements; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceArrayExpression", this).call(this, node, { elements: elements.map(function (n) { + return n == null ? null : n(); + }) }); + } + }, { + key: "reduceArrowExpression", + value: function reduceArrowExpression(node, _ref4) { + var params = _ref4.params, + body = _ref4.body; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceArrowExpression", this).call(this, node, { params: params(), body: body() }); + } + }, { + key: "reduceAssignmentExpression", + value: function reduceAssignmentExpression(node, _ref5) { + var binding = _ref5.binding, + expression = _ref5.expression; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceAssignmentExpression", this).call(this, node, { binding: binding(), expression: expression() }); + } + }, { + key: "reduceAssignmentTargetIdentifier", + value: function reduceAssignmentTargetIdentifier(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceAssignmentTargetIdentifier", this).call(this, node); + } + }, { + key: "reduceAssignmentTargetPropertyIdentifier", + value: function reduceAssignmentTargetPropertyIdentifier(node, _ref6) { + var binding = _ref6.binding, + init = _ref6.init; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceAssignmentTargetPropertyIdentifier", this).call(this, node, { binding: binding(), init: init == null ? null : init() }); + } + }, { + key: "reduceAssignmentTargetPropertyProperty", + value: function reduceAssignmentTargetPropertyProperty(node, _ref7) { + var name = _ref7.name, + binding = _ref7.binding; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceAssignmentTargetPropertyProperty", this).call(this, node, { name: name(), binding: binding() }); + } + }, { + key: "reduceAssignmentTargetWithDefault", + value: function reduceAssignmentTargetWithDefault(node, _ref8) { + var binding = _ref8.binding, + init = _ref8.init; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceAssignmentTargetWithDefault", this).call(this, node, { binding: binding(), init: init() }); + } + }, { + key: "reduceAwaitExpression", + value: function reduceAwaitExpression(node, _ref9) { + var expression = _ref9.expression; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceAwaitExpression", this).call(this, node, { expression: expression() }); + } + }, { + key: "reduceBinaryExpression", + value: function reduceBinaryExpression(node, _ref10) { + var left = _ref10.left, + right = _ref10.right; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceBinaryExpression", this).call(this, node, { left: left(), right: right() }); + } + }, { + key: "reduceBindingIdentifier", + value: function reduceBindingIdentifier(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceBindingIdentifier", this).call(this, node); + } + }, { + key: "reduceBindingPropertyIdentifier", + value: function reduceBindingPropertyIdentifier(node, _ref11) { + var binding = _ref11.binding, + init = _ref11.init; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceBindingPropertyIdentifier", this).call(this, node, { binding: binding(), init: init == null ? null : init() }); + } + }, { + key: "reduceBindingPropertyProperty", + value: function reduceBindingPropertyProperty(node, _ref12) { + var name = _ref12.name, + binding = _ref12.binding; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceBindingPropertyProperty", this).call(this, node, { name: name(), binding: binding() }); + } + }, { + key: "reduceBindingWithDefault", + value: function reduceBindingWithDefault(node, _ref13) { + var binding = _ref13.binding, + init = _ref13.init; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceBindingWithDefault", this).call(this, node, { binding: binding(), init: init() }); + } + }, { + key: "reduceBlock", + value: function reduceBlock(node, _ref14) { + var statements = _ref14.statements; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceBlock", this).call(this, node, { statements: statements.map(function (n) { + return n(); + }) }); + } + }, { + key: "reduceBlockStatement", + value: function reduceBlockStatement(node, _ref15) { + var block = _ref15.block; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceBlockStatement", this).call(this, node, { block: block() }); + } + }, { + key: "reduceBreakStatement", + value: function reduceBreakStatement(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceBreakStatement", this).call(this, node); + } + }, { + key: "reduceCallExpression", + value: function reduceCallExpression(node, _ref16) { + var callee = _ref16.callee, + _arguments = _ref16.arguments; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceCallExpression", this).call(this, node, { callee: callee(), arguments: _arguments.map(function (n) { + return n(); + }) }); + } + }, { + key: "reduceCatchClause", + value: function reduceCatchClause(node, _ref17) { + var binding = _ref17.binding, + body = _ref17.body; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceCatchClause", this).call(this, node, { binding: binding(), body: body() }); + } + }, { + key: "reduceClassDeclaration", + value: function reduceClassDeclaration(node, _ref18) { + var name = _ref18.name, + _super = _ref18.super, + elements = _ref18.elements; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceClassDeclaration", this).call(this, node, { name: name(), super: _super == null ? null : _super(), elements: elements.map(function (n) { + return n(); + }) }); + } + }, { + key: "reduceClassElement", + value: function reduceClassElement(node, _ref19) { + var method = _ref19.method; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceClassElement", this).call(this, node, { method: method() }); + } + }, { + key: "reduceClassExpression", + value: function reduceClassExpression(node, _ref20) { + var name = _ref20.name, + _super = _ref20.super, + elements = _ref20.elements; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceClassExpression", this).call(this, node, { name: name == null ? null : name(), super: _super == null ? null : _super(), elements: elements.map(function (n) { + return n(); + }) }); + } + }, { + key: "reduceCompoundAssignmentExpression", + value: function reduceCompoundAssignmentExpression(node, _ref21) { + var binding = _ref21.binding, + expression = _ref21.expression; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceCompoundAssignmentExpression", this).call(this, node, { binding: binding(), expression: expression() }); + } + }, { + key: "reduceComputedMemberAssignmentTarget", + value: function reduceComputedMemberAssignmentTarget(node, _ref22) { + var object = _ref22.object, + expression = _ref22.expression; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceComputedMemberAssignmentTarget", this).call(this, node, { object: object(), expression: expression() }); + } + }, { + key: "reduceComputedMemberExpression", + value: function reduceComputedMemberExpression(node, _ref23) { + var object = _ref23.object, + expression = _ref23.expression; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceComputedMemberExpression", this).call(this, node, { object: object(), expression: expression() }); + } + }, { + key: "reduceComputedPropertyName", + value: function reduceComputedPropertyName(node, _ref24) { + var expression = _ref24.expression; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceComputedPropertyName", this).call(this, node, { expression: expression() }); + } + }, { + key: "reduceConditionalExpression", + value: function reduceConditionalExpression(node, _ref25) { + var test = _ref25.test, + consequent = _ref25.consequent, + alternate = _ref25.alternate; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceConditionalExpression", this).call(this, node, { test: test(), consequent: consequent(), alternate: alternate() }); + } + }, { + key: "reduceContinueStatement", + value: function reduceContinueStatement(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceContinueStatement", this).call(this, node); + } + }, { + key: "reduceDataProperty", + value: function reduceDataProperty(node, _ref26) { + var name = _ref26.name, + expression = _ref26.expression; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceDataProperty", this).call(this, node, { name: name(), expression: expression() }); + } + }, { + key: "reduceDebuggerStatement", + value: function reduceDebuggerStatement(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceDebuggerStatement", this).call(this, node); + } + }, { + key: "reduceDirective", + value: function reduceDirective(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceDirective", this).call(this, node); + } + }, { + key: "reduceDoWhileStatement", + value: function reduceDoWhileStatement(node, _ref27) { + var body = _ref27.body, + test = _ref27.test; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceDoWhileStatement", this).call(this, node, { body: body(), test: test() }); + } + }, { + key: "reduceEmptyStatement", + value: function reduceEmptyStatement(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceEmptyStatement", this).call(this, node); + } + }, { + key: "reduceExport", + value: function reduceExport(node, _ref28) { + var declaration = _ref28.declaration; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceExport", this).call(this, node, { declaration: declaration() }); + } + }, { + key: "reduceExportAllFrom", + value: function reduceExportAllFrom(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceExportAllFrom", this).call(this, node); + } + }, { + key: "reduceExportDefault", + value: function reduceExportDefault(node, _ref29) { + var body = _ref29.body; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceExportDefault", this).call(this, node, { body: body() }); + } + }, { + key: "reduceExportFrom", + value: function reduceExportFrom(node, _ref30) { + var namedExports = _ref30.namedExports; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceExportFrom", this).call(this, node, { namedExports: namedExports.map(function (n) { + return n(); + }) }); + } + }, { + key: "reduceExportFromSpecifier", + value: function reduceExportFromSpecifier(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceExportFromSpecifier", this).call(this, node); + } + }, { + key: "reduceExportLocalSpecifier", + value: function reduceExportLocalSpecifier(node, _ref31) { + var name = _ref31.name; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceExportLocalSpecifier", this).call(this, node, { name: name() }); + } + }, { + key: "reduceExportLocals", + value: function reduceExportLocals(node, _ref32) { + var namedExports = _ref32.namedExports; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceExportLocals", this).call(this, node, { namedExports: namedExports.map(function (n) { + return n(); + }) }); + } + }, { + key: "reduceExpressionStatement", + value: function reduceExpressionStatement(node, _ref33) { + var expression = _ref33.expression; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceExpressionStatement", this).call(this, node, { expression: expression() }); + } + }, { + key: "reduceForAwaitStatement", + value: function reduceForAwaitStatement(node, _ref34) { + var left = _ref34.left, + right = _ref34.right, + body = _ref34.body; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceForAwaitStatement", this).call(this, node, { left: left(), right: right(), body: body() }); + } + }, { + key: "reduceForInStatement", + value: function reduceForInStatement(node, _ref35) { + var left = _ref35.left, + right = _ref35.right, + body = _ref35.body; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceForInStatement", this).call(this, node, { left: left(), right: right(), body: body() }); + } + }, { + key: "reduceForOfStatement", + value: function reduceForOfStatement(node, _ref36) { + var left = _ref36.left, + right = _ref36.right, + body = _ref36.body; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceForOfStatement", this).call(this, node, { left: left(), right: right(), body: body() }); + } + }, { + key: "reduceForStatement", + value: function reduceForStatement(node, _ref37) { + var init = _ref37.init, + test = _ref37.test, + update = _ref37.update, + body = _ref37.body; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceForStatement", this).call(this, node, { init: init == null ? null : init(), test: test == null ? null : test(), update: update == null ? null : update(), body: body() }); + } + }, { + key: "reduceFormalParameters", + value: function reduceFormalParameters(node, _ref38) { + var items = _ref38.items, + rest = _ref38.rest; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceFormalParameters", this).call(this, node, { items: items.map(function (n) { + return n(); + }), rest: rest == null ? null : rest() }); + } + }, { + key: "reduceFunctionBody", + value: function reduceFunctionBody(node, _ref39) { + var directives = _ref39.directives, + statements = _ref39.statements; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceFunctionBody", this).call(this, node, { directives: directives.map(function (n) { + return n(); + }), statements: statements.map(function (n) { + return n(); + }) }); + } + }, { + key: "reduceFunctionDeclaration", + value: function reduceFunctionDeclaration(node, _ref40) { + var name = _ref40.name, + params = _ref40.params, + body = _ref40.body; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceFunctionDeclaration", this).call(this, node, { name: name(), params: params(), body: body() }); + } + }, { + key: "reduceFunctionExpression", + value: function reduceFunctionExpression(node, _ref41) { + var name = _ref41.name, + params = _ref41.params, + body = _ref41.body; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceFunctionExpression", this).call(this, node, { name: name == null ? null : name(), params: params(), body: body() }); + } + }, { + key: "reduceGetter", + value: function reduceGetter(node, _ref42) { + var name = _ref42.name, + body = _ref42.body; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceGetter", this).call(this, node, { name: name(), body: body() }); + } + }, { + key: "reduceIdentifierExpression", + value: function reduceIdentifierExpression(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceIdentifierExpression", this).call(this, node); + } + }, { + key: "reduceIfStatement", + value: function reduceIfStatement(node, _ref43) { + var test = _ref43.test, + consequent = _ref43.consequent, + alternate = _ref43.alternate; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceIfStatement", this).call(this, node, { test: test(), consequent: consequent(), alternate: alternate == null ? null : alternate() }); + } + }, { + key: "reduceImport", + value: function reduceImport(node, _ref44) { + var defaultBinding = _ref44.defaultBinding, + namedImports = _ref44.namedImports; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceImport", this).call(this, node, { defaultBinding: defaultBinding == null ? null : defaultBinding(), namedImports: namedImports.map(function (n) { + return n(); + }) }); + } + }, { + key: "reduceImportNamespace", + value: function reduceImportNamespace(node, _ref45) { + var defaultBinding = _ref45.defaultBinding, + namespaceBinding = _ref45.namespaceBinding; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceImportNamespace", this).call(this, node, { defaultBinding: defaultBinding == null ? null : defaultBinding(), namespaceBinding: namespaceBinding() }); + } + }, { + key: "reduceImportSpecifier", + value: function reduceImportSpecifier(node, _ref46) { + var binding = _ref46.binding; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceImportSpecifier", this).call(this, node, { binding: binding() }); + } + }, { + key: "reduceLabeledStatement", + value: function reduceLabeledStatement(node, _ref47) { + var body = _ref47.body; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceLabeledStatement", this).call(this, node, { body: body() }); + } + }, { + key: "reduceLiteralBooleanExpression", + value: function reduceLiteralBooleanExpression(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceLiteralBooleanExpression", this).call(this, node); + } + }, { + key: "reduceLiteralInfinityExpression", + value: function reduceLiteralInfinityExpression(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceLiteralInfinityExpression", this).call(this, node); + } + }, { + key: "reduceLiteralNullExpression", + value: function reduceLiteralNullExpression(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceLiteralNullExpression", this).call(this, node); + } + }, { + key: "reduceLiteralNumericExpression", + value: function reduceLiteralNumericExpression(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceLiteralNumericExpression", this).call(this, node); + } + }, { + key: "reduceLiteralRegExpExpression", + value: function reduceLiteralRegExpExpression(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceLiteralRegExpExpression", this).call(this, node); + } + }, { + key: "reduceLiteralStringExpression", + value: function reduceLiteralStringExpression(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceLiteralStringExpression", this).call(this, node); + } + }, { + key: "reduceMethod", + value: function reduceMethod(node, _ref48) { + var name = _ref48.name, + params = _ref48.params, + body = _ref48.body; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceMethod", this).call(this, node, { name: name(), params: params(), body: body() }); + } + }, { + key: "reduceModule", + value: function reduceModule(node, _ref49) { + var directives = _ref49.directives, + items = _ref49.items; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceModule", this).call(this, node, { directives: directives.map(function (n) { + return n(); + }), items: items.map(function (n) { + return n(); + }) }); + } + }, { + key: "reduceNewExpression", + value: function reduceNewExpression(node, _ref50) { + var callee = _ref50.callee, + _arguments = _ref50.arguments; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceNewExpression", this).call(this, node, { callee: callee(), arguments: _arguments.map(function (n) { + return n(); + }) }); + } + }, { + key: "reduceNewTargetExpression", + value: function reduceNewTargetExpression(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceNewTargetExpression", this).call(this, node); + } + }, { + key: "reduceObjectAssignmentTarget", + value: function reduceObjectAssignmentTarget(node, _ref51) { + var properties = _ref51.properties, + rest = _ref51.rest; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceObjectAssignmentTarget", this).call(this, node, { properties: properties.map(function (n) { + return n(); + }), rest: rest == null ? null : rest() }); + } + }, { + key: "reduceObjectBinding", + value: function reduceObjectBinding(node, _ref52) { + var properties = _ref52.properties, + rest = _ref52.rest; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceObjectBinding", this).call(this, node, { properties: properties.map(function (n) { + return n(); + }), rest: rest == null ? null : rest() }); + } + }, { + key: "reduceObjectExpression", + value: function reduceObjectExpression(node, _ref53) { + var properties = _ref53.properties; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceObjectExpression", this).call(this, node, { properties: properties.map(function (n) { + return n(); + }) }); + } + }, { + key: "reduceReturnStatement", + value: function reduceReturnStatement(node, _ref54) { + var expression = _ref54.expression; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceReturnStatement", this).call(this, node, { expression: expression == null ? null : expression() }); + } + }, { + key: "reduceScript", + value: function reduceScript(node, _ref55) { + var directives = _ref55.directives, + statements = _ref55.statements; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceScript", this).call(this, node, { directives: directives.map(function (n) { + return n(); + }), statements: statements.map(function (n) { + return n(); + }) }); + } + }, { + key: "reduceSetter", + value: function reduceSetter(node, _ref56) { + var name = _ref56.name, + param = _ref56.param, + body = _ref56.body; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceSetter", this).call(this, node, { name: name(), param: param(), body: body() }); + } + }, { + key: "reduceShorthandProperty", + value: function reduceShorthandProperty(node, _ref57) { + var name = _ref57.name; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceShorthandProperty", this).call(this, node, { name: name() }); + } + }, { + key: "reduceSpreadElement", + value: function reduceSpreadElement(node, _ref58) { + var expression = _ref58.expression; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceSpreadElement", this).call(this, node, { expression: expression() }); + } + }, { + key: "reduceSpreadProperty", + value: function reduceSpreadProperty(node, _ref59) { + var expression = _ref59.expression; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceSpreadProperty", this).call(this, node, { expression: expression() }); + } + }, { + key: "reduceStaticMemberAssignmentTarget", + value: function reduceStaticMemberAssignmentTarget(node, _ref60) { + var object = _ref60.object; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceStaticMemberAssignmentTarget", this).call(this, node, { object: object() }); + } + }, { + key: "reduceStaticMemberExpression", + value: function reduceStaticMemberExpression(node, _ref61) { + var object = _ref61.object; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceStaticMemberExpression", this).call(this, node, { object: object() }); + } + }, { + key: "reduceStaticPropertyName", + value: function reduceStaticPropertyName(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceStaticPropertyName", this).call(this, node); + } + }, { + key: "reduceSuper", + value: function reduceSuper(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceSuper", this).call(this, node); + } + }, { + key: "reduceSwitchCase", + value: function reduceSwitchCase(node, _ref62) { + var test = _ref62.test, + consequent = _ref62.consequent; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceSwitchCase", this).call(this, node, { test: test(), consequent: consequent.map(function (n) { + return n(); + }) }); + } + }, { + key: "reduceSwitchDefault", + value: function reduceSwitchDefault(node, _ref63) { + var consequent = _ref63.consequent; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceSwitchDefault", this).call(this, node, { consequent: consequent.map(function (n) { + return n(); + }) }); + } + }, { + key: "reduceSwitchStatement", + value: function reduceSwitchStatement(node, _ref64) { + var discriminant = _ref64.discriminant, + cases = _ref64.cases; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceSwitchStatement", this).call(this, node, { discriminant: discriminant(), cases: cases.map(function (n) { + return n(); + }) }); + } + }, { + key: "reduceSwitchStatementWithDefault", + value: function reduceSwitchStatementWithDefault(node, _ref65) { + var discriminant = _ref65.discriminant, + preDefaultCases = _ref65.preDefaultCases, + defaultCase = _ref65.defaultCase, + postDefaultCases = _ref65.postDefaultCases; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceSwitchStatementWithDefault", this).call(this, node, { discriminant: discriminant(), preDefaultCases: preDefaultCases.map(function (n) { + return n(); + }), defaultCase: defaultCase(), postDefaultCases: postDefaultCases.map(function (n) { + return n(); + }) }); + } + }, { + key: "reduceTemplateElement", + value: function reduceTemplateElement(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceTemplateElement", this).call(this, node); + } + }, { + key: "reduceTemplateExpression", + value: function reduceTemplateExpression(node, _ref66) { + var tag = _ref66.tag, + elements = _ref66.elements; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceTemplateExpression", this).call(this, node, { tag: tag == null ? null : tag(), elements: elements.map(function (n) { + return n(); + }) }); + } + }, { + key: "reduceThisExpression", + value: function reduceThisExpression(node) { + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceThisExpression", this).call(this, node); + } + }, { + key: "reduceThrowStatement", + value: function reduceThrowStatement(node, _ref67) { + var expression = _ref67.expression; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceThrowStatement", this).call(this, node, { expression: expression() }); + } + }, { + key: "reduceTryCatchStatement", + value: function reduceTryCatchStatement(node, _ref68) { + var body = _ref68.body, + catchClause = _ref68.catchClause; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceTryCatchStatement", this).call(this, node, { body: body(), catchClause: catchClause() }); + } + }, { + key: "reduceTryFinallyStatement", + value: function reduceTryFinallyStatement(node, _ref69) { + var body = _ref69.body, + catchClause = _ref69.catchClause, + finalizer = _ref69.finalizer; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceTryFinallyStatement", this).call(this, node, { body: body(), catchClause: catchClause == null ? null : catchClause(), finalizer: finalizer() }); + } + }, { + key: "reduceUnaryExpression", + value: function reduceUnaryExpression(node, _ref70) { + var operand = _ref70.operand; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceUnaryExpression", this).call(this, node, { operand: operand() }); + } + }, { + key: "reduceUpdateExpression", + value: function reduceUpdateExpression(node, _ref71) { + var operand = _ref71.operand; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceUpdateExpression", this).call(this, node, { operand: operand() }); + } + }, { + key: "reduceVariableDeclaration", + value: function reduceVariableDeclaration(node, _ref72) { + var declarators = _ref72.declarators; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceVariableDeclaration", this).call(this, node, { declarators: declarators.map(function (n) { + return n(); + }) }); + } + }, { + key: "reduceVariableDeclarationStatement", + value: function reduceVariableDeclarationStatement(node, _ref73) { + var declaration = _ref73.declaration; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceVariableDeclarationStatement", this).call(this, node, { declaration: declaration() }); + } + }, { + key: "reduceVariableDeclarator", + value: function reduceVariableDeclarator(node, _ref74) { + var binding = _ref74.binding, + init = _ref74.init; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceVariableDeclarator", this).call(this, node, { binding: binding(), init: init == null ? null : init() }); + } + }, { + key: "reduceWhileStatement", + value: function reduceWhileStatement(node, _ref75) { + var test = _ref75.test, + body = _ref75.body; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceWhileStatement", this).call(this, node, { test: test(), body: body() }); + } + }, { + key: "reduceWithStatement", + value: function reduceWithStatement(node, _ref76) { + var object = _ref76.object, + body = _ref76.body; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceWithStatement", this).call(this, node, { object: object(), body: body() }); + } + }, { + key: "reduceYieldExpression", + value: function reduceYieldExpression(node, _ref77) { + var expression = _ref77.expression; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceYieldExpression", this).call(this, node, { expression: expression == null ? null : expression() }); + } + }, { + key: "reduceYieldGeneratorExpression", + value: function reduceYieldGeneratorExpression(node, _ref78) { + var expression = _ref78.expression; + + return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), "reduceYieldGeneratorExpression", this).call(this, node, { expression: expression() }); + } + }]); + + return _class; + }(reducerClass); +} +}); + +var memoize_1 = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = memoize; + + + +var Shift = _interopRequireWildcard(dist$2); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function memoize(reducer) { + var cache = new WeakMap(); + return { + reduceArrayAssignmentTarget: function reduceArrayAssignmentTarget(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceArrayAssignmentTarget(node, arg); + cache.set(node, res); + return res; + }, + reduceArrayBinding: function reduceArrayBinding(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceArrayBinding(node, arg); + cache.set(node, res); + return res; + }, + reduceArrayExpression: function reduceArrayExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceArrayExpression(node, arg); + cache.set(node, res); + return res; + }, + reduceArrowExpression: function reduceArrowExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceArrowExpression(node, arg); + cache.set(node, res); + return res; + }, + reduceAssignmentExpression: function reduceAssignmentExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceAssignmentExpression(node, arg); + cache.set(node, res); + return res; + }, + reduceAssignmentTargetIdentifier: function reduceAssignmentTargetIdentifier(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceAssignmentTargetIdentifier(node); + cache.set(node, res); + return res; + }, + reduceAssignmentTargetPropertyIdentifier: function reduceAssignmentTargetPropertyIdentifier(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceAssignmentTargetPropertyIdentifier(node, arg); + cache.set(node, res); + return res; + }, + reduceAssignmentTargetPropertyProperty: function reduceAssignmentTargetPropertyProperty(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceAssignmentTargetPropertyProperty(node, arg); + cache.set(node, res); + return res; + }, + reduceAssignmentTargetWithDefault: function reduceAssignmentTargetWithDefault(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceAssignmentTargetWithDefault(node, arg); + cache.set(node, res); + return res; + }, + reduceAwaitExpression: function reduceAwaitExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceAwaitExpression(node, arg); + cache.set(node, res); + return res; + }, + reduceBinaryExpression: function reduceBinaryExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceBinaryExpression(node, arg); + cache.set(node, res); + return res; + }, + reduceBindingIdentifier: function reduceBindingIdentifier(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceBindingIdentifier(node); + cache.set(node, res); + return res; + }, + reduceBindingPropertyIdentifier: function reduceBindingPropertyIdentifier(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceBindingPropertyIdentifier(node, arg); + cache.set(node, res); + return res; + }, + reduceBindingPropertyProperty: function reduceBindingPropertyProperty(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceBindingPropertyProperty(node, arg); + cache.set(node, res); + return res; + }, + reduceBindingWithDefault: function reduceBindingWithDefault(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceBindingWithDefault(node, arg); + cache.set(node, res); + return res; + }, + reduceBlock: function reduceBlock(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceBlock(node, arg); + cache.set(node, res); + return res; + }, + reduceBlockStatement: function reduceBlockStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceBlockStatement(node, arg); + cache.set(node, res); + return res; + }, + reduceBreakStatement: function reduceBreakStatement(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceBreakStatement(node); + cache.set(node, res); + return res; + }, + reduceCallExpression: function reduceCallExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceCallExpression(node, arg); + cache.set(node, res); + return res; + }, + reduceCatchClause: function reduceCatchClause(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceCatchClause(node, arg); + cache.set(node, res); + return res; + }, + reduceClassDeclaration: function reduceClassDeclaration(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceClassDeclaration(node, arg); + cache.set(node, res); + return res; + }, + reduceClassElement: function reduceClassElement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceClassElement(node, arg); + cache.set(node, res); + return res; + }, + reduceClassExpression: function reduceClassExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceClassExpression(node, arg); + cache.set(node, res); + return res; + }, + reduceCompoundAssignmentExpression: function reduceCompoundAssignmentExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceCompoundAssignmentExpression(node, arg); + cache.set(node, res); + return res; + }, + reduceComputedMemberAssignmentTarget: function reduceComputedMemberAssignmentTarget(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceComputedMemberAssignmentTarget(node, arg); + cache.set(node, res); + return res; + }, + reduceComputedMemberExpression: function reduceComputedMemberExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceComputedMemberExpression(node, arg); + cache.set(node, res); + return res; + }, + reduceComputedPropertyName: function reduceComputedPropertyName(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceComputedPropertyName(node, arg); + cache.set(node, res); + return res; + }, + reduceConditionalExpression: function reduceConditionalExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceConditionalExpression(node, arg); + cache.set(node, res); + return res; + }, + reduceContinueStatement: function reduceContinueStatement(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceContinueStatement(node); + cache.set(node, res); + return res; + }, + reduceDataProperty: function reduceDataProperty(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceDataProperty(node, arg); + cache.set(node, res); + return res; + }, + reduceDebuggerStatement: function reduceDebuggerStatement(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceDebuggerStatement(node); + cache.set(node, res); + return res; + }, + reduceDirective: function reduceDirective(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceDirective(node); + cache.set(node, res); + return res; + }, + reduceDoWhileStatement: function reduceDoWhileStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceDoWhileStatement(node, arg); + cache.set(node, res); + return res; + }, + reduceEmptyStatement: function reduceEmptyStatement(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceEmptyStatement(node); + cache.set(node, res); + return res; + }, + reduceExport: function reduceExport(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceExport(node, arg); + cache.set(node, res); + return res; + }, + reduceExportAllFrom: function reduceExportAllFrom(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceExportAllFrom(node); + cache.set(node, res); + return res; + }, + reduceExportDefault: function reduceExportDefault(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceExportDefault(node, arg); + cache.set(node, res); + return res; + }, + reduceExportFrom: function reduceExportFrom(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceExportFrom(node, arg); + cache.set(node, res); + return res; + }, + reduceExportFromSpecifier: function reduceExportFromSpecifier(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceExportFromSpecifier(node); + cache.set(node, res); + return res; + }, + reduceExportLocalSpecifier: function reduceExportLocalSpecifier(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceExportLocalSpecifier(node, arg); + cache.set(node, res); + return res; + }, + reduceExportLocals: function reduceExportLocals(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceExportLocals(node, arg); + cache.set(node, res); + return res; + }, + reduceExpressionStatement: function reduceExpressionStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceExpressionStatement(node, arg); + cache.set(node, res); + return res; + }, + reduceForAwaitStatement: function reduceForAwaitStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceForAwaitStatement(node, arg); + cache.set(node, res); + return res; + }, + reduceForInStatement: function reduceForInStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceForInStatement(node, arg); + cache.set(node, res); + return res; + }, + reduceForOfStatement: function reduceForOfStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceForOfStatement(node, arg); + cache.set(node, res); + return res; + }, + reduceForStatement: function reduceForStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceForStatement(node, arg); + cache.set(node, res); + return res; + }, + reduceFormalParameters: function reduceFormalParameters(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceFormalParameters(node, arg); + cache.set(node, res); + return res; + }, + reduceFunctionBody: function reduceFunctionBody(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceFunctionBody(node, arg); + cache.set(node, res); + return res; + }, + reduceFunctionDeclaration: function reduceFunctionDeclaration(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceFunctionDeclaration(node, arg); + cache.set(node, res); + return res; + }, + reduceFunctionExpression: function reduceFunctionExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceFunctionExpression(node, arg); + cache.set(node, res); + return res; + }, + reduceGetter: function reduceGetter(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceGetter(node, arg); + cache.set(node, res); + return res; + }, + reduceIdentifierExpression: function reduceIdentifierExpression(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceIdentifierExpression(node); + cache.set(node, res); + return res; + }, + reduceIfStatement: function reduceIfStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceIfStatement(node, arg); + cache.set(node, res); + return res; + }, + reduceImport: function reduceImport(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceImport(node, arg); + cache.set(node, res); + return res; + }, + reduceImportNamespace: function reduceImportNamespace(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceImportNamespace(node, arg); + cache.set(node, res); + return res; + }, + reduceImportSpecifier: function reduceImportSpecifier(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceImportSpecifier(node, arg); + cache.set(node, res); + return res; + }, + reduceLabeledStatement: function reduceLabeledStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceLabeledStatement(node, arg); + cache.set(node, res); + return res; + }, + reduceLiteralBooleanExpression: function reduceLiteralBooleanExpression(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceLiteralBooleanExpression(node); + cache.set(node, res); + return res; + }, + reduceLiteralInfinityExpression: function reduceLiteralInfinityExpression(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceLiteralInfinityExpression(node); + cache.set(node, res); + return res; + }, + reduceLiteralNullExpression: function reduceLiteralNullExpression(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceLiteralNullExpression(node); + cache.set(node, res); + return res; + }, + reduceLiteralNumericExpression: function reduceLiteralNumericExpression(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceLiteralNumericExpression(node); + cache.set(node, res); + return res; + }, + reduceLiteralRegExpExpression: function reduceLiteralRegExpExpression(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceLiteralRegExpExpression(node); + cache.set(node, res); + return res; + }, + reduceLiteralStringExpression: function reduceLiteralStringExpression(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceLiteralStringExpression(node); + cache.set(node, res); + return res; + }, + reduceMethod: function reduceMethod(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceMethod(node, arg); + cache.set(node, res); + return res; + }, + reduceModule: function reduceModule(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceModule(node, arg); + cache.set(node, res); + return res; + }, + reduceNewExpression: function reduceNewExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceNewExpression(node, arg); + cache.set(node, res); + return res; + }, + reduceNewTargetExpression: function reduceNewTargetExpression(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceNewTargetExpression(node); + cache.set(node, res); + return res; + }, + reduceObjectAssignmentTarget: function reduceObjectAssignmentTarget(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceObjectAssignmentTarget(node, arg); + cache.set(node, res); + return res; + }, + reduceObjectBinding: function reduceObjectBinding(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceObjectBinding(node, arg); + cache.set(node, res); + return res; + }, + reduceObjectExpression: function reduceObjectExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceObjectExpression(node, arg); + cache.set(node, res); + return res; + }, + reduceReturnStatement: function reduceReturnStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceReturnStatement(node, arg); + cache.set(node, res); + return res; + }, + reduceScript: function reduceScript(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceScript(node, arg); + cache.set(node, res); + return res; + }, + reduceSetter: function reduceSetter(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceSetter(node, arg); + cache.set(node, res); + return res; + }, + reduceShorthandProperty: function reduceShorthandProperty(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceShorthandProperty(node, arg); + cache.set(node, res); + return res; + }, + reduceSpreadElement: function reduceSpreadElement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceSpreadElement(node, arg); + cache.set(node, res); + return res; + }, + reduceSpreadProperty: function reduceSpreadProperty(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceSpreadProperty(node, arg); + cache.set(node, res); + return res; + }, + reduceStaticMemberAssignmentTarget: function reduceStaticMemberAssignmentTarget(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceStaticMemberAssignmentTarget(node, arg); + cache.set(node, res); + return res; + }, + reduceStaticMemberExpression: function reduceStaticMemberExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceStaticMemberExpression(node, arg); + cache.set(node, res); + return res; + }, + reduceStaticPropertyName: function reduceStaticPropertyName(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceStaticPropertyName(node); + cache.set(node, res); + return res; + }, + reduceSuper: function reduceSuper(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceSuper(node); + cache.set(node, res); + return res; + }, + reduceSwitchCase: function reduceSwitchCase(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceSwitchCase(node, arg); + cache.set(node, res); + return res; + }, + reduceSwitchDefault: function reduceSwitchDefault(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceSwitchDefault(node, arg); + cache.set(node, res); + return res; + }, + reduceSwitchStatement: function reduceSwitchStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceSwitchStatement(node, arg); + cache.set(node, res); + return res; + }, + reduceSwitchStatementWithDefault: function reduceSwitchStatementWithDefault(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceSwitchStatementWithDefault(node, arg); + cache.set(node, res); + return res; + }, + reduceTemplateElement: function reduceTemplateElement(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceTemplateElement(node); + cache.set(node, res); + return res; + }, + reduceTemplateExpression: function reduceTemplateExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceTemplateExpression(node, arg); + cache.set(node, res); + return res; + }, + reduceThisExpression: function reduceThisExpression(node) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceThisExpression(node); + cache.set(node, res); + return res; + }, + reduceThrowStatement: function reduceThrowStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceThrowStatement(node, arg); + cache.set(node, res); + return res; + }, + reduceTryCatchStatement: function reduceTryCatchStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceTryCatchStatement(node, arg); + cache.set(node, res); + return res; + }, + reduceTryFinallyStatement: function reduceTryFinallyStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceTryFinallyStatement(node, arg); + cache.set(node, res); + return res; + }, + reduceUnaryExpression: function reduceUnaryExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceUnaryExpression(node, arg); + cache.set(node, res); + return res; + }, + reduceUpdateExpression: function reduceUpdateExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceUpdateExpression(node, arg); + cache.set(node, res); + return res; + }, + reduceVariableDeclaration: function reduceVariableDeclaration(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceVariableDeclaration(node, arg); + cache.set(node, res); + return res; + }, + reduceVariableDeclarationStatement: function reduceVariableDeclarationStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceVariableDeclarationStatement(node, arg); + cache.set(node, res); + return res; + }, + reduceVariableDeclarator: function reduceVariableDeclarator(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceVariableDeclarator(node, arg); + cache.set(node, res); + return res; + }, + reduceWhileStatement: function reduceWhileStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceWhileStatement(node, arg); + cache.set(node, res); + return res; + }, + reduceWithStatement: function reduceWithStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceWithStatement(node, arg); + cache.set(node, res); + return res; + }, + reduceYieldExpression: function reduceYieldExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceYieldExpression(node, arg); + cache.set(node, res); + return res; + }, + reduceYieldGeneratorExpression: function reduceYieldGeneratorExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + var res = reducer.reduceYieldGeneratorExpression(node, arg); + cache.set(node, res); + return res; + } + }; +} // Generated by generate-memoize.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +}); + +var cloneReducer = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); // Generated by generate-clone-reducer.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +var Shift = _interopRequireWildcard(dist$2); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var CloneReducer = function () { + function CloneReducer() { + _classCallCheck(this, CloneReducer); + } + + _createClass(CloneReducer, [{ + key: 'reduceArrayAssignmentTarget', + value: function reduceArrayAssignmentTarget(node, _ref) { + var elements = _ref.elements, + rest = _ref.rest; + + return new Shift.ArrayAssignmentTarget({ elements: elements, rest: rest }); + } + }, { + key: 'reduceArrayBinding', + value: function reduceArrayBinding(node, _ref2) { + var elements = _ref2.elements, + rest = _ref2.rest; + + return new Shift.ArrayBinding({ elements: elements, rest: rest }); + } + }, { + key: 'reduceArrayExpression', + value: function reduceArrayExpression(node, _ref3) { + var elements = _ref3.elements; + + return new Shift.ArrayExpression({ elements: elements }); + } + }, { + key: 'reduceArrowExpression', + value: function reduceArrowExpression(node, _ref4) { + var params = _ref4.params, + body = _ref4.body; + + return new Shift.ArrowExpression({ isAsync: node.isAsync, params: params, body: body }); + } + }, { + key: 'reduceAssignmentExpression', + value: function reduceAssignmentExpression(node, _ref5) { + var binding = _ref5.binding, + expression = _ref5.expression; + + return new Shift.AssignmentExpression({ binding: binding, expression: expression }); + } + }, { + key: 'reduceAssignmentTargetIdentifier', + value: function reduceAssignmentTargetIdentifier(node) { + return new Shift.AssignmentTargetIdentifier({ name: node.name }); + } + }, { + key: 'reduceAssignmentTargetPropertyIdentifier', + value: function reduceAssignmentTargetPropertyIdentifier(node, _ref6) { + var binding = _ref6.binding, + init = _ref6.init; + + return new Shift.AssignmentTargetPropertyIdentifier({ binding: binding, init: init }); + } + }, { + key: 'reduceAssignmentTargetPropertyProperty', + value: function reduceAssignmentTargetPropertyProperty(node, _ref7) { + var name = _ref7.name, + binding = _ref7.binding; + + return new Shift.AssignmentTargetPropertyProperty({ name: name, binding: binding }); + } + }, { + key: 'reduceAssignmentTargetWithDefault', + value: function reduceAssignmentTargetWithDefault(node, _ref8) { + var binding = _ref8.binding, + init = _ref8.init; + + return new Shift.AssignmentTargetWithDefault({ binding: binding, init: init }); + } + }, { + key: 'reduceAwaitExpression', + value: function reduceAwaitExpression(node, _ref9) { + var expression = _ref9.expression; + + return new Shift.AwaitExpression({ expression: expression }); + } + }, { + key: 'reduceBinaryExpression', + value: function reduceBinaryExpression(node, _ref10) { + var left = _ref10.left, + right = _ref10.right; + + return new Shift.BinaryExpression({ left: left, operator: node.operator, right: right }); + } + }, { + key: 'reduceBindingIdentifier', + value: function reduceBindingIdentifier(node) { + return new Shift.BindingIdentifier({ name: node.name }); + } + }, { + key: 'reduceBindingPropertyIdentifier', + value: function reduceBindingPropertyIdentifier(node, _ref11) { + var binding = _ref11.binding, + init = _ref11.init; + + return new Shift.BindingPropertyIdentifier({ binding: binding, init: init }); + } + }, { + key: 'reduceBindingPropertyProperty', + value: function reduceBindingPropertyProperty(node, _ref12) { + var name = _ref12.name, + binding = _ref12.binding; + + return new Shift.BindingPropertyProperty({ name: name, binding: binding }); + } + }, { + key: 'reduceBindingWithDefault', + value: function reduceBindingWithDefault(node, _ref13) { + var binding = _ref13.binding, + init = _ref13.init; + + return new Shift.BindingWithDefault({ binding: binding, init: init }); + } + }, { + key: 'reduceBlock', + value: function reduceBlock(node, _ref14) { + var statements = _ref14.statements; + + return new Shift.Block({ statements: statements }); + } + }, { + key: 'reduceBlockStatement', + value: function reduceBlockStatement(node, _ref15) { + var block = _ref15.block; + + return new Shift.BlockStatement({ block: block }); + } + }, { + key: 'reduceBreakStatement', + value: function reduceBreakStatement(node) { + return new Shift.BreakStatement({ label: node.label }); + } + }, { + key: 'reduceCallExpression', + value: function reduceCallExpression(node, _ref16) { + var callee = _ref16.callee, + _arguments = _ref16.arguments; + + return new Shift.CallExpression({ callee: callee, arguments: _arguments }); + } + }, { + key: 'reduceCatchClause', + value: function reduceCatchClause(node, _ref17) { + var binding = _ref17.binding, + body = _ref17.body; + + return new Shift.CatchClause({ binding: binding, body: body }); + } + }, { + key: 'reduceClassDeclaration', + value: function reduceClassDeclaration(node, _ref18) { + var name = _ref18.name, + _super = _ref18.super, + elements = _ref18.elements; + + return new Shift.ClassDeclaration({ name: name, super: _super, elements: elements }); + } + }, { + key: 'reduceClassElement', + value: function reduceClassElement(node, _ref19) { + var method = _ref19.method; + + return new Shift.ClassElement({ isStatic: node.isStatic, method: method }); + } + }, { + key: 'reduceClassExpression', + value: function reduceClassExpression(node, _ref20) { + var name = _ref20.name, + _super = _ref20.super, + elements = _ref20.elements; + + return new Shift.ClassExpression({ name: name, super: _super, elements: elements }); + } + }, { + key: 'reduceCompoundAssignmentExpression', + value: function reduceCompoundAssignmentExpression(node, _ref21) { + var binding = _ref21.binding, + expression = _ref21.expression; + + return new Shift.CompoundAssignmentExpression({ binding: binding, operator: node.operator, expression: expression }); + } + }, { + key: 'reduceComputedMemberAssignmentTarget', + value: function reduceComputedMemberAssignmentTarget(node, _ref22) { + var object = _ref22.object, + expression = _ref22.expression; + + return new Shift.ComputedMemberAssignmentTarget({ object: object, expression: expression }); + } + }, { + key: 'reduceComputedMemberExpression', + value: function reduceComputedMemberExpression(node, _ref23) { + var object = _ref23.object, + expression = _ref23.expression; + + return new Shift.ComputedMemberExpression({ object: object, expression: expression }); + } + }, { + key: 'reduceComputedPropertyName', + value: function reduceComputedPropertyName(node, _ref24) { + var expression = _ref24.expression; + + return new Shift.ComputedPropertyName({ expression: expression }); + } + }, { + key: 'reduceConditionalExpression', + value: function reduceConditionalExpression(node, _ref25) { + var test = _ref25.test, + consequent = _ref25.consequent, + alternate = _ref25.alternate; + + return new Shift.ConditionalExpression({ test: test, consequent: consequent, alternate: alternate }); + } + }, { + key: 'reduceContinueStatement', + value: function reduceContinueStatement(node) { + return new Shift.ContinueStatement({ label: node.label }); + } + }, { + key: 'reduceDataProperty', + value: function reduceDataProperty(node, _ref26) { + var name = _ref26.name, + expression = _ref26.expression; + + return new Shift.DataProperty({ name: name, expression: expression }); + } + }, { + key: 'reduceDebuggerStatement', + value: function reduceDebuggerStatement(node) { + return new Shift.DebuggerStatement(); + } + }, { + key: 'reduceDirective', + value: function reduceDirective(node) { + return new Shift.Directive({ rawValue: node.rawValue }); + } + }, { + key: 'reduceDoWhileStatement', + value: function reduceDoWhileStatement(node, _ref27) { + var body = _ref27.body, + test = _ref27.test; + + return new Shift.DoWhileStatement({ body: body, test: test }); + } + }, { + key: 'reduceEmptyStatement', + value: function reduceEmptyStatement(node) { + return new Shift.EmptyStatement(); + } + }, { + key: 'reduceExport', + value: function reduceExport(node, _ref28) { + var declaration = _ref28.declaration; + + return new Shift.Export({ declaration: declaration }); + } + }, { + key: 'reduceExportAllFrom', + value: function reduceExportAllFrom(node) { + return new Shift.ExportAllFrom({ moduleSpecifier: node.moduleSpecifier }); + } + }, { + key: 'reduceExportDefault', + value: function reduceExportDefault(node, _ref29) { + var body = _ref29.body; + + return new Shift.ExportDefault({ body: body }); + } + }, { + key: 'reduceExportFrom', + value: function reduceExportFrom(node, _ref30) { + var namedExports = _ref30.namedExports; + + return new Shift.ExportFrom({ namedExports: namedExports, moduleSpecifier: node.moduleSpecifier }); + } + }, { + key: 'reduceExportFromSpecifier', + value: function reduceExportFromSpecifier(node) { + return new Shift.ExportFromSpecifier({ name: node.name, exportedName: node.exportedName }); + } + }, { + key: 'reduceExportLocalSpecifier', + value: function reduceExportLocalSpecifier(node, _ref31) { + var name = _ref31.name; + + return new Shift.ExportLocalSpecifier({ name: name, exportedName: node.exportedName }); + } + }, { + key: 'reduceExportLocals', + value: function reduceExportLocals(node, _ref32) { + var namedExports = _ref32.namedExports; + + return new Shift.ExportLocals({ namedExports: namedExports }); + } + }, { + key: 'reduceExpressionStatement', + value: function reduceExpressionStatement(node, _ref33) { + var expression = _ref33.expression; + + return new Shift.ExpressionStatement({ expression: expression }); + } + }, { + key: 'reduceForAwaitStatement', + value: function reduceForAwaitStatement(node, _ref34) { + var left = _ref34.left, + right = _ref34.right, + body = _ref34.body; + + return new Shift.ForAwaitStatement({ left: left, right: right, body: body }); + } + }, { + key: 'reduceForInStatement', + value: function reduceForInStatement(node, _ref35) { + var left = _ref35.left, + right = _ref35.right, + body = _ref35.body; + + return new Shift.ForInStatement({ left: left, right: right, body: body }); + } + }, { + key: 'reduceForOfStatement', + value: function reduceForOfStatement(node, _ref36) { + var left = _ref36.left, + right = _ref36.right, + body = _ref36.body; + + return new Shift.ForOfStatement({ left: left, right: right, body: body }); + } + }, { + key: 'reduceForStatement', + value: function reduceForStatement(node, _ref37) { + var init = _ref37.init, + test = _ref37.test, + update = _ref37.update, + body = _ref37.body; + + return new Shift.ForStatement({ init: init, test: test, update: update, body: body }); + } + }, { + key: 'reduceFormalParameters', + value: function reduceFormalParameters(node, _ref38) { + var items = _ref38.items, + rest = _ref38.rest; + + return new Shift.FormalParameters({ items: items, rest: rest }); + } + }, { + key: 'reduceFunctionBody', + value: function reduceFunctionBody(node, _ref39) { + var directives = _ref39.directives, + statements = _ref39.statements; + + return new Shift.FunctionBody({ directives: directives, statements: statements }); + } + }, { + key: 'reduceFunctionDeclaration', + value: function reduceFunctionDeclaration(node, _ref40) { + var name = _ref40.name, + params = _ref40.params, + body = _ref40.body; + + return new Shift.FunctionDeclaration({ isAsync: node.isAsync, isGenerator: node.isGenerator, name: name, params: params, body: body }); + } + }, { + key: 'reduceFunctionExpression', + value: function reduceFunctionExpression(node, _ref41) { + var name = _ref41.name, + params = _ref41.params, + body = _ref41.body; + + return new Shift.FunctionExpression({ isAsync: node.isAsync, isGenerator: node.isGenerator, name: name, params: params, body: body }); + } + }, { + key: 'reduceGetter', + value: function reduceGetter(node, _ref42) { + var name = _ref42.name, + body = _ref42.body; + + return new Shift.Getter({ name: name, body: body }); + } + }, { + key: 'reduceIdentifierExpression', + value: function reduceIdentifierExpression(node) { + return new Shift.IdentifierExpression({ name: node.name }); + } + }, { + key: 'reduceIfStatement', + value: function reduceIfStatement(node, _ref43) { + var test = _ref43.test, + consequent = _ref43.consequent, + alternate = _ref43.alternate; + + return new Shift.IfStatement({ test: test, consequent: consequent, alternate: alternate }); + } + }, { + key: 'reduceImport', + value: function reduceImport(node, _ref44) { + var defaultBinding = _ref44.defaultBinding, + namedImports = _ref44.namedImports; + + return new Shift.Import({ defaultBinding: defaultBinding, namedImports: namedImports, moduleSpecifier: node.moduleSpecifier }); + } + }, { + key: 'reduceImportNamespace', + value: function reduceImportNamespace(node, _ref45) { + var defaultBinding = _ref45.defaultBinding, + namespaceBinding = _ref45.namespaceBinding; + + return new Shift.ImportNamespace({ defaultBinding: defaultBinding, namespaceBinding: namespaceBinding, moduleSpecifier: node.moduleSpecifier }); + } + }, { + key: 'reduceImportSpecifier', + value: function reduceImportSpecifier(node, _ref46) { + var binding = _ref46.binding; + + return new Shift.ImportSpecifier({ name: node.name, binding: binding }); + } + }, { + key: 'reduceLabeledStatement', + value: function reduceLabeledStatement(node, _ref47) { + var body = _ref47.body; + + return new Shift.LabeledStatement({ label: node.label, body: body }); + } + }, { + key: 'reduceLiteralBooleanExpression', + value: function reduceLiteralBooleanExpression(node) { + return new Shift.LiteralBooleanExpression({ value: node.value }); + } + }, { + key: 'reduceLiteralInfinityExpression', + value: function reduceLiteralInfinityExpression(node) { + return new Shift.LiteralInfinityExpression(); + } + }, { + key: 'reduceLiteralNullExpression', + value: function reduceLiteralNullExpression(node) { + return new Shift.LiteralNullExpression(); + } + }, { + key: 'reduceLiteralNumericExpression', + value: function reduceLiteralNumericExpression(node) { + return new Shift.LiteralNumericExpression({ value: node.value }); + } + }, { + key: 'reduceLiteralRegExpExpression', + value: function reduceLiteralRegExpExpression(node) { + return new Shift.LiteralRegExpExpression({ pattern: node.pattern, global: node.global, ignoreCase: node.ignoreCase, multiLine: node.multiLine, dotAll: node.dotAll, unicode: node.unicode, sticky: node.sticky }); + } + }, { + key: 'reduceLiteralStringExpression', + value: function reduceLiteralStringExpression(node) { + return new Shift.LiteralStringExpression({ value: node.value }); + } + }, { + key: 'reduceMethod', + value: function reduceMethod(node, _ref48) { + var name = _ref48.name, + params = _ref48.params, + body = _ref48.body; + + return new Shift.Method({ isAsync: node.isAsync, isGenerator: node.isGenerator, name: name, params: params, body: body }); + } + }, { + key: 'reduceModule', + value: function reduceModule(node, _ref49) { + var directives = _ref49.directives, + items = _ref49.items; + + return new Shift.Module({ directives: directives, items: items }); + } + }, { + key: 'reduceNewExpression', + value: function reduceNewExpression(node, _ref50) { + var callee = _ref50.callee, + _arguments = _ref50.arguments; + + return new Shift.NewExpression({ callee: callee, arguments: _arguments }); + } + }, { + key: 'reduceNewTargetExpression', + value: function reduceNewTargetExpression(node) { + return new Shift.NewTargetExpression(); + } + }, { + key: 'reduceObjectAssignmentTarget', + value: function reduceObjectAssignmentTarget(node, _ref51) { + var properties = _ref51.properties, + rest = _ref51.rest; + + return new Shift.ObjectAssignmentTarget({ properties: properties, rest: rest }); + } + }, { + key: 'reduceObjectBinding', + value: function reduceObjectBinding(node, _ref52) { + var properties = _ref52.properties, + rest = _ref52.rest; + + return new Shift.ObjectBinding({ properties: properties, rest: rest }); + } + }, { + key: 'reduceObjectExpression', + value: function reduceObjectExpression(node, _ref53) { + var properties = _ref53.properties; + + return new Shift.ObjectExpression({ properties: properties }); + } + }, { + key: 'reduceReturnStatement', + value: function reduceReturnStatement(node, _ref54) { + var expression = _ref54.expression; + + return new Shift.ReturnStatement({ expression: expression }); + } + }, { + key: 'reduceScript', + value: function reduceScript(node, _ref55) { + var directives = _ref55.directives, + statements = _ref55.statements; + + return new Shift.Script({ directives: directives, statements: statements }); + } + }, { + key: 'reduceSetter', + value: function reduceSetter(node, _ref56) { + var name = _ref56.name, + param = _ref56.param, + body = _ref56.body; + + return new Shift.Setter({ name: name, param: param, body: body }); + } + }, { + key: 'reduceShorthandProperty', + value: function reduceShorthandProperty(node, _ref57) { + var name = _ref57.name; + + return new Shift.ShorthandProperty({ name: name }); + } + }, { + key: 'reduceSpreadElement', + value: function reduceSpreadElement(node, _ref58) { + var expression = _ref58.expression; + + return new Shift.SpreadElement({ expression: expression }); + } + }, { + key: 'reduceSpreadProperty', + value: function reduceSpreadProperty(node, _ref59) { + var expression = _ref59.expression; + + return new Shift.SpreadProperty({ expression: expression }); + } + }, { + key: 'reduceStaticMemberAssignmentTarget', + value: function reduceStaticMemberAssignmentTarget(node, _ref60) { + var object = _ref60.object; + + return new Shift.StaticMemberAssignmentTarget({ object: object, property: node.property }); + } + }, { + key: 'reduceStaticMemberExpression', + value: function reduceStaticMemberExpression(node, _ref61) { + var object = _ref61.object; + + return new Shift.StaticMemberExpression({ object: object, property: node.property }); + } + }, { + key: 'reduceStaticPropertyName', + value: function reduceStaticPropertyName(node) { + return new Shift.StaticPropertyName({ value: node.value }); + } + }, { + key: 'reduceSuper', + value: function reduceSuper(node) { + return new Shift.Super(); + } + }, { + key: 'reduceSwitchCase', + value: function reduceSwitchCase(node, _ref62) { + var test = _ref62.test, + consequent = _ref62.consequent; + + return new Shift.SwitchCase({ test: test, consequent: consequent }); + } + }, { + key: 'reduceSwitchDefault', + value: function reduceSwitchDefault(node, _ref63) { + var consequent = _ref63.consequent; + + return new Shift.SwitchDefault({ consequent: consequent }); + } + }, { + key: 'reduceSwitchStatement', + value: function reduceSwitchStatement(node, _ref64) { + var discriminant = _ref64.discriminant, + cases = _ref64.cases; + + return new Shift.SwitchStatement({ discriminant: discriminant, cases: cases }); + } + }, { + key: 'reduceSwitchStatementWithDefault', + value: function reduceSwitchStatementWithDefault(node, _ref65) { + var discriminant = _ref65.discriminant, + preDefaultCases = _ref65.preDefaultCases, + defaultCase = _ref65.defaultCase, + postDefaultCases = _ref65.postDefaultCases; + + return new Shift.SwitchStatementWithDefault({ discriminant: discriminant, preDefaultCases: preDefaultCases, defaultCase: defaultCase, postDefaultCases: postDefaultCases }); + } + }, { + key: 'reduceTemplateElement', + value: function reduceTemplateElement(node) { + return new Shift.TemplateElement({ rawValue: node.rawValue }); + } + }, { + key: 'reduceTemplateExpression', + value: function reduceTemplateExpression(node, _ref66) { + var tag = _ref66.tag, + elements = _ref66.elements; + + return new Shift.TemplateExpression({ tag: tag, elements: elements }); + } + }, { + key: 'reduceThisExpression', + value: function reduceThisExpression(node) { + return new Shift.ThisExpression(); + } + }, { + key: 'reduceThrowStatement', + value: function reduceThrowStatement(node, _ref67) { + var expression = _ref67.expression; + + return new Shift.ThrowStatement({ expression: expression }); + } + }, { + key: 'reduceTryCatchStatement', + value: function reduceTryCatchStatement(node, _ref68) { + var body = _ref68.body, + catchClause = _ref68.catchClause; + + return new Shift.TryCatchStatement({ body: body, catchClause: catchClause }); + } + }, { + key: 'reduceTryFinallyStatement', + value: function reduceTryFinallyStatement(node, _ref69) { + var body = _ref69.body, + catchClause = _ref69.catchClause, + finalizer = _ref69.finalizer; + + return new Shift.TryFinallyStatement({ body: body, catchClause: catchClause, finalizer: finalizer }); + } + }, { + key: 'reduceUnaryExpression', + value: function reduceUnaryExpression(node, _ref70) { + var operand = _ref70.operand; + + return new Shift.UnaryExpression({ operator: node.operator, operand: operand }); + } + }, { + key: 'reduceUpdateExpression', + value: function reduceUpdateExpression(node, _ref71) { + var operand = _ref71.operand; + + return new Shift.UpdateExpression({ isPrefix: node.isPrefix, operator: node.operator, operand: operand }); + } + }, { + key: 'reduceVariableDeclaration', + value: function reduceVariableDeclaration(node, _ref72) { + var declarators = _ref72.declarators; + + return new Shift.VariableDeclaration({ kind: node.kind, declarators: declarators }); + } + }, { + key: 'reduceVariableDeclarationStatement', + value: function reduceVariableDeclarationStatement(node, _ref73) { + var declaration = _ref73.declaration; + + return new Shift.VariableDeclarationStatement({ declaration: declaration }); + } + }, { + key: 'reduceVariableDeclarator', + value: function reduceVariableDeclarator(node, _ref74) { + var binding = _ref74.binding, + init = _ref74.init; + + return new Shift.VariableDeclarator({ binding: binding, init: init }); + } + }, { + key: 'reduceWhileStatement', + value: function reduceWhileStatement(node, _ref75) { + var test = _ref75.test, + body = _ref75.body; + + return new Shift.WhileStatement({ test: test, body: body }); + } + }, { + key: 'reduceWithStatement', + value: function reduceWithStatement(node, _ref76) { + var object = _ref76.object, + body = _ref76.body; + + return new Shift.WithStatement({ object: object, body: body }); + } + }, { + key: 'reduceYieldExpression', + value: function reduceYieldExpression(node, _ref77) { + var expression = _ref77.expression; + + return new Shift.YieldExpression({ expression: expression }); + } + }, { + key: 'reduceYieldGeneratorExpression', + value: function reduceYieldGeneratorExpression(node, _ref78) { + var expression = _ref78.expression; + + return new Shift.YieldGeneratorExpression({ expression: expression }); + } + }]); + + return CloneReducer; +}(); + +exports.default = CloneReducer; +}); + +var lazyCloneReducer = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); // Generated by generate-lazy-clone-reducer.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +var Shift = _interopRequireWildcard(dist$2); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var LazyCloneReducer = function () { + function LazyCloneReducer() { + _classCallCheck(this, LazyCloneReducer); + } + + _createClass(LazyCloneReducer, [{ + key: 'reduceArrayAssignmentTarget', + value: function reduceArrayAssignmentTarget(node, _ref) { + var elements = _ref.elements, + rest = _ref.rest; + + if (node.elements.length === elements.length && node.elements.every(function (v, i) { + return v === elements[i]; + }) && node.rest === rest) { + return node; + } + return new Shift.ArrayAssignmentTarget({ elements: elements, rest: rest }); + } + }, { + key: 'reduceArrayBinding', + value: function reduceArrayBinding(node, _ref2) { + var elements = _ref2.elements, + rest = _ref2.rest; + + if (node.elements.length === elements.length && node.elements.every(function (v, i) { + return v === elements[i]; + }) && node.rest === rest) { + return node; + } + return new Shift.ArrayBinding({ elements: elements, rest: rest }); + } + }, { + key: 'reduceArrayExpression', + value: function reduceArrayExpression(node, _ref3) { + var elements = _ref3.elements; + + if (node.elements.length === elements.length && node.elements.every(function (v, i) { + return v === elements[i]; + })) { + return node; + } + return new Shift.ArrayExpression({ elements: elements }); + } + }, { + key: 'reduceArrowExpression', + value: function reduceArrowExpression(node, _ref4) { + var params = _ref4.params, + body = _ref4.body; + + if (node.params === params && node.body === body) { + return node; + } + return new Shift.ArrowExpression({ isAsync: node.isAsync, params: params, body: body }); + } + }, { + key: 'reduceAssignmentExpression', + value: function reduceAssignmentExpression(node, _ref5) { + var binding = _ref5.binding, + expression = _ref5.expression; + + if (node.binding === binding && node.expression === expression) { + return node; + } + return new Shift.AssignmentExpression({ binding: binding, expression: expression }); + } + }, { + key: 'reduceAssignmentTargetIdentifier', + value: function reduceAssignmentTargetIdentifier(node) { + return node; + } + }, { + key: 'reduceAssignmentTargetPropertyIdentifier', + value: function reduceAssignmentTargetPropertyIdentifier(node, _ref6) { + var binding = _ref6.binding, + init = _ref6.init; + + if (node.binding === binding && node.init === init) { + return node; + } + return new Shift.AssignmentTargetPropertyIdentifier({ binding: binding, init: init }); + } + }, { + key: 'reduceAssignmentTargetPropertyProperty', + value: function reduceAssignmentTargetPropertyProperty(node, _ref7) { + var name = _ref7.name, + binding = _ref7.binding; + + if (node.name === name && node.binding === binding) { + return node; + } + return new Shift.AssignmentTargetPropertyProperty({ name: name, binding: binding }); + } + }, { + key: 'reduceAssignmentTargetWithDefault', + value: function reduceAssignmentTargetWithDefault(node, _ref8) { + var binding = _ref8.binding, + init = _ref8.init; + + if (node.binding === binding && node.init === init) { + return node; + } + return new Shift.AssignmentTargetWithDefault({ binding: binding, init: init }); + } + }, { + key: 'reduceAwaitExpression', + value: function reduceAwaitExpression(node, _ref9) { + var expression = _ref9.expression; + + if (node.expression === expression) { + return node; + } + return new Shift.AwaitExpression({ expression: expression }); + } + }, { + key: 'reduceBinaryExpression', + value: function reduceBinaryExpression(node, _ref10) { + var left = _ref10.left, + right = _ref10.right; + + if (node.left === left && node.right === right) { + return node; + } + return new Shift.BinaryExpression({ left: left, operator: node.operator, right: right }); + } + }, { + key: 'reduceBindingIdentifier', + value: function reduceBindingIdentifier(node) { + return node; + } + }, { + key: 'reduceBindingPropertyIdentifier', + value: function reduceBindingPropertyIdentifier(node, _ref11) { + var binding = _ref11.binding, + init = _ref11.init; + + if (node.binding === binding && node.init === init) { + return node; + } + return new Shift.BindingPropertyIdentifier({ binding: binding, init: init }); + } + }, { + key: 'reduceBindingPropertyProperty', + value: function reduceBindingPropertyProperty(node, _ref12) { + var name = _ref12.name, + binding = _ref12.binding; + + if (node.name === name && node.binding === binding) { + return node; + } + return new Shift.BindingPropertyProperty({ name: name, binding: binding }); + } + }, { + key: 'reduceBindingWithDefault', + value: function reduceBindingWithDefault(node, _ref13) { + var binding = _ref13.binding, + init = _ref13.init; + + if (node.binding === binding && node.init === init) { + return node; + } + return new Shift.BindingWithDefault({ binding: binding, init: init }); + } + }, { + key: 'reduceBlock', + value: function reduceBlock(node, _ref14) { + var statements = _ref14.statements; + + if (node.statements.length === statements.length && node.statements.every(function (v, i) { + return v === statements[i]; + })) { + return node; + } + return new Shift.Block({ statements: statements }); + } + }, { + key: 'reduceBlockStatement', + value: function reduceBlockStatement(node, _ref15) { + var block = _ref15.block; + + if (node.block === block) { + return node; + } + return new Shift.BlockStatement({ block: block }); + } + }, { + key: 'reduceBreakStatement', + value: function reduceBreakStatement(node) { + return node; + } + }, { + key: 'reduceCallExpression', + value: function reduceCallExpression(node, _ref16) { + var callee = _ref16.callee, + _arguments = _ref16.arguments; + + if (node.callee === callee && node.arguments.length === _arguments.length && node.arguments.every(function (v, i) { + return v === _arguments[i]; + })) { + return node; + } + return new Shift.CallExpression({ callee: callee, arguments: _arguments }); + } + }, { + key: 'reduceCatchClause', + value: function reduceCatchClause(node, _ref17) { + var binding = _ref17.binding, + body = _ref17.body; + + if (node.binding === binding && node.body === body) { + return node; + } + return new Shift.CatchClause({ binding: binding, body: body }); + } + }, { + key: 'reduceClassDeclaration', + value: function reduceClassDeclaration(node, _ref18) { + var name = _ref18.name, + _super = _ref18.super, + elements = _ref18.elements; + + if (node.name === name && node.super === _super && node.elements.length === elements.length && node.elements.every(function (v, i) { + return v === elements[i]; + })) { + return node; + } + return new Shift.ClassDeclaration({ name: name, super: _super, elements: elements }); + } + }, { + key: 'reduceClassElement', + value: function reduceClassElement(node, _ref19) { + var method = _ref19.method; + + if (node.method === method) { + return node; + } + return new Shift.ClassElement({ isStatic: node.isStatic, method: method }); + } + }, { + key: 'reduceClassExpression', + value: function reduceClassExpression(node, _ref20) { + var name = _ref20.name, + _super = _ref20.super, + elements = _ref20.elements; + + if (node.name === name && node.super === _super && node.elements.length === elements.length && node.elements.every(function (v, i) { + return v === elements[i]; + })) { + return node; + } + return new Shift.ClassExpression({ name: name, super: _super, elements: elements }); + } + }, { + key: 'reduceCompoundAssignmentExpression', + value: function reduceCompoundAssignmentExpression(node, _ref21) { + var binding = _ref21.binding, + expression = _ref21.expression; + + if (node.binding === binding && node.expression === expression) { + return node; + } + return new Shift.CompoundAssignmentExpression({ binding: binding, operator: node.operator, expression: expression }); + } + }, { + key: 'reduceComputedMemberAssignmentTarget', + value: function reduceComputedMemberAssignmentTarget(node, _ref22) { + var object = _ref22.object, + expression = _ref22.expression; + + if (node.object === object && node.expression === expression) { + return node; + } + return new Shift.ComputedMemberAssignmentTarget({ object: object, expression: expression }); + } + }, { + key: 'reduceComputedMemberExpression', + value: function reduceComputedMemberExpression(node, _ref23) { + var object = _ref23.object, + expression = _ref23.expression; + + if (node.object === object && node.expression === expression) { + return node; + } + return new Shift.ComputedMemberExpression({ object: object, expression: expression }); + } + }, { + key: 'reduceComputedPropertyName', + value: function reduceComputedPropertyName(node, _ref24) { + var expression = _ref24.expression; + + if (node.expression === expression) { + return node; + } + return new Shift.ComputedPropertyName({ expression: expression }); + } + }, { + key: 'reduceConditionalExpression', + value: function reduceConditionalExpression(node, _ref25) { + var test = _ref25.test, + consequent = _ref25.consequent, + alternate = _ref25.alternate; + + if (node.test === test && node.consequent === consequent && node.alternate === alternate) { + return node; + } + return new Shift.ConditionalExpression({ test: test, consequent: consequent, alternate: alternate }); + } + }, { + key: 'reduceContinueStatement', + value: function reduceContinueStatement(node) { + return node; + } + }, { + key: 'reduceDataProperty', + value: function reduceDataProperty(node, _ref26) { + var name = _ref26.name, + expression = _ref26.expression; + + if (node.name === name && node.expression === expression) { + return node; + } + return new Shift.DataProperty({ name: name, expression: expression }); + } + }, { + key: 'reduceDebuggerStatement', + value: function reduceDebuggerStatement(node) { + return node; + } + }, { + key: 'reduceDirective', + value: function reduceDirective(node) { + return node; + } + }, { + key: 'reduceDoWhileStatement', + value: function reduceDoWhileStatement(node, _ref27) { + var body = _ref27.body, + test = _ref27.test; + + if (node.body === body && node.test === test) { + return node; + } + return new Shift.DoWhileStatement({ body: body, test: test }); + } + }, { + key: 'reduceEmptyStatement', + value: function reduceEmptyStatement(node) { + return node; + } + }, { + key: 'reduceExport', + value: function reduceExport(node, _ref28) { + var declaration = _ref28.declaration; + + if (node.declaration === declaration) { + return node; + } + return new Shift.Export({ declaration: declaration }); + } + }, { + key: 'reduceExportAllFrom', + value: function reduceExportAllFrom(node) { + return node; + } + }, { + key: 'reduceExportDefault', + value: function reduceExportDefault(node, _ref29) { + var body = _ref29.body; + + if (node.body === body) { + return node; + } + return new Shift.ExportDefault({ body: body }); + } + }, { + key: 'reduceExportFrom', + value: function reduceExportFrom(node, _ref30) { + var namedExports = _ref30.namedExports; + + if (node.namedExports.length === namedExports.length && node.namedExports.every(function (v, i) { + return v === namedExports[i]; + })) { + return node; + } + return new Shift.ExportFrom({ namedExports: namedExports, moduleSpecifier: node.moduleSpecifier }); + } + }, { + key: 'reduceExportFromSpecifier', + value: function reduceExportFromSpecifier(node) { + return node; + } + }, { + key: 'reduceExportLocalSpecifier', + value: function reduceExportLocalSpecifier(node, _ref31) { + var name = _ref31.name; + + if (node.name === name) { + return node; + } + return new Shift.ExportLocalSpecifier({ name: name, exportedName: node.exportedName }); + } + }, { + key: 'reduceExportLocals', + value: function reduceExportLocals(node, _ref32) { + var namedExports = _ref32.namedExports; + + if (node.namedExports.length === namedExports.length && node.namedExports.every(function (v, i) { + return v === namedExports[i]; + })) { + return node; + } + return new Shift.ExportLocals({ namedExports: namedExports }); + } + }, { + key: 'reduceExpressionStatement', + value: function reduceExpressionStatement(node, _ref33) { + var expression = _ref33.expression; + + if (node.expression === expression) { + return node; + } + return new Shift.ExpressionStatement({ expression: expression }); + } + }, { + key: 'reduceForAwaitStatement', + value: function reduceForAwaitStatement(node, _ref34) { + var left = _ref34.left, + right = _ref34.right, + body = _ref34.body; + + if (node.left === left && node.right === right && node.body === body) { + return node; + } + return new Shift.ForAwaitStatement({ left: left, right: right, body: body }); + } + }, { + key: 'reduceForInStatement', + value: function reduceForInStatement(node, _ref35) { + var left = _ref35.left, + right = _ref35.right, + body = _ref35.body; + + if (node.left === left && node.right === right && node.body === body) { + return node; + } + return new Shift.ForInStatement({ left: left, right: right, body: body }); + } + }, { + key: 'reduceForOfStatement', + value: function reduceForOfStatement(node, _ref36) { + var left = _ref36.left, + right = _ref36.right, + body = _ref36.body; + + if (node.left === left && node.right === right && node.body === body) { + return node; + } + return new Shift.ForOfStatement({ left: left, right: right, body: body }); + } + }, { + key: 'reduceForStatement', + value: function reduceForStatement(node, _ref37) { + var init = _ref37.init, + test = _ref37.test, + update = _ref37.update, + body = _ref37.body; + + if (node.init === init && node.test === test && node.update === update && node.body === body) { + return node; + } + return new Shift.ForStatement({ init: init, test: test, update: update, body: body }); + } + }, { + key: 'reduceFormalParameters', + value: function reduceFormalParameters(node, _ref38) { + var items = _ref38.items, + rest = _ref38.rest; + + if (node.items.length === items.length && node.items.every(function (v, i) { + return v === items[i]; + }) && node.rest === rest) { + return node; + } + return new Shift.FormalParameters({ items: items, rest: rest }); + } + }, { + key: 'reduceFunctionBody', + value: function reduceFunctionBody(node, _ref39) { + var directives = _ref39.directives, + statements = _ref39.statements; + + if (node.directives.length === directives.length && node.directives.every(function (v, i) { + return v === directives[i]; + }) && node.statements.length === statements.length && node.statements.every(function (v, i) { + return v === statements[i]; + })) { + return node; + } + return new Shift.FunctionBody({ directives: directives, statements: statements }); + } + }, { + key: 'reduceFunctionDeclaration', + value: function reduceFunctionDeclaration(node, _ref40) { + var name = _ref40.name, + params = _ref40.params, + body = _ref40.body; + + if (node.name === name && node.params === params && node.body === body) { + return node; + } + return new Shift.FunctionDeclaration({ isAsync: node.isAsync, isGenerator: node.isGenerator, name: name, params: params, body: body }); + } + }, { + key: 'reduceFunctionExpression', + value: function reduceFunctionExpression(node, _ref41) { + var name = _ref41.name, + params = _ref41.params, + body = _ref41.body; + + if (node.name === name && node.params === params && node.body === body) { + return node; + } + return new Shift.FunctionExpression({ isAsync: node.isAsync, isGenerator: node.isGenerator, name: name, params: params, body: body }); + } + }, { + key: 'reduceGetter', + value: function reduceGetter(node, _ref42) { + var name = _ref42.name, + body = _ref42.body; + + if (node.name === name && node.body === body) { + return node; + } + return new Shift.Getter({ name: name, body: body }); + } + }, { + key: 'reduceIdentifierExpression', + value: function reduceIdentifierExpression(node) { + return node; + } + }, { + key: 'reduceIfStatement', + value: function reduceIfStatement(node, _ref43) { + var test = _ref43.test, + consequent = _ref43.consequent, + alternate = _ref43.alternate; + + if (node.test === test && node.consequent === consequent && node.alternate === alternate) { + return node; + } + return new Shift.IfStatement({ test: test, consequent: consequent, alternate: alternate }); + } + }, { + key: 'reduceImport', + value: function reduceImport(node, _ref44) { + var defaultBinding = _ref44.defaultBinding, + namedImports = _ref44.namedImports; + + if (node.defaultBinding === defaultBinding && node.namedImports.length === namedImports.length && node.namedImports.every(function (v, i) { + return v === namedImports[i]; + })) { + return node; + } + return new Shift.Import({ defaultBinding: defaultBinding, namedImports: namedImports, moduleSpecifier: node.moduleSpecifier }); + } + }, { + key: 'reduceImportNamespace', + value: function reduceImportNamespace(node, _ref45) { + var defaultBinding = _ref45.defaultBinding, + namespaceBinding = _ref45.namespaceBinding; + + if (node.defaultBinding === defaultBinding && node.namespaceBinding === namespaceBinding) { + return node; + } + return new Shift.ImportNamespace({ defaultBinding: defaultBinding, namespaceBinding: namespaceBinding, moduleSpecifier: node.moduleSpecifier }); + } + }, { + key: 'reduceImportSpecifier', + value: function reduceImportSpecifier(node, _ref46) { + var binding = _ref46.binding; + + if (node.binding === binding) { + return node; + } + return new Shift.ImportSpecifier({ name: node.name, binding: binding }); + } + }, { + key: 'reduceLabeledStatement', + value: function reduceLabeledStatement(node, _ref47) { + var body = _ref47.body; + + if (node.body === body) { + return node; + } + return new Shift.LabeledStatement({ label: node.label, body: body }); + } + }, { + key: 'reduceLiteralBooleanExpression', + value: function reduceLiteralBooleanExpression(node) { + return node; + } + }, { + key: 'reduceLiteralInfinityExpression', + value: function reduceLiteralInfinityExpression(node) { + return node; + } + }, { + key: 'reduceLiteralNullExpression', + value: function reduceLiteralNullExpression(node) { + return node; + } + }, { + key: 'reduceLiteralNumericExpression', + value: function reduceLiteralNumericExpression(node) { + return node; + } + }, { + key: 'reduceLiteralRegExpExpression', + value: function reduceLiteralRegExpExpression(node) { + return node; + } + }, { + key: 'reduceLiteralStringExpression', + value: function reduceLiteralStringExpression(node) { + return node; + } + }, { + key: 'reduceMethod', + value: function reduceMethod(node, _ref48) { + var name = _ref48.name, + params = _ref48.params, + body = _ref48.body; + + if (node.name === name && node.params === params && node.body === body) { + return node; + } + return new Shift.Method({ isAsync: node.isAsync, isGenerator: node.isGenerator, name: name, params: params, body: body }); + } + }, { + key: 'reduceModule', + value: function reduceModule(node, _ref49) { + var directives = _ref49.directives, + items = _ref49.items; + + if (node.directives.length === directives.length && node.directives.every(function (v, i) { + return v === directives[i]; + }) && node.items.length === items.length && node.items.every(function (v, i) { + return v === items[i]; + })) { + return node; + } + return new Shift.Module({ directives: directives, items: items }); + } + }, { + key: 'reduceNewExpression', + value: function reduceNewExpression(node, _ref50) { + var callee = _ref50.callee, + _arguments = _ref50.arguments; + + if (node.callee === callee && node.arguments.length === _arguments.length && node.arguments.every(function (v, i) { + return v === _arguments[i]; + })) { + return node; + } + return new Shift.NewExpression({ callee: callee, arguments: _arguments }); + } + }, { + key: 'reduceNewTargetExpression', + value: function reduceNewTargetExpression(node) { + return node; + } + }, { + key: 'reduceObjectAssignmentTarget', + value: function reduceObjectAssignmentTarget(node, _ref51) { + var properties = _ref51.properties, + rest = _ref51.rest; + + if (node.properties.length === properties.length && node.properties.every(function (v, i) { + return v === properties[i]; + }) && node.rest === rest) { + return node; + } + return new Shift.ObjectAssignmentTarget({ properties: properties, rest: rest }); + } + }, { + key: 'reduceObjectBinding', + value: function reduceObjectBinding(node, _ref52) { + var properties = _ref52.properties, + rest = _ref52.rest; + + if (node.properties.length === properties.length && node.properties.every(function (v, i) { + return v === properties[i]; + }) && node.rest === rest) { + return node; + } + return new Shift.ObjectBinding({ properties: properties, rest: rest }); + } + }, { + key: 'reduceObjectExpression', + value: function reduceObjectExpression(node, _ref53) { + var properties = _ref53.properties; + + if (node.properties.length === properties.length && node.properties.every(function (v, i) { + return v === properties[i]; + })) { + return node; + } + return new Shift.ObjectExpression({ properties: properties }); + } + }, { + key: 'reduceReturnStatement', + value: function reduceReturnStatement(node, _ref54) { + var expression = _ref54.expression; + + if (node.expression === expression) { + return node; + } + return new Shift.ReturnStatement({ expression: expression }); + } + }, { + key: 'reduceScript', + value: function reduceScript(node, _ref55) { + var directives = _ref55.directives, + statements = _ref55.statements; + + if (node.directives.length === directives.length && node.directives.every(function (v, i) { + return v === directives[i]; + }) && node.statements.length === statements.length && node.statements.every(function (v, i) { + return v === statements[i]; + })) { + return node; + } + return new Shift.Script({ directives: directives, statements: statements }); + } + }, { + key: 'reduceSetter', + value: function reduceSetter(node, _ref56) { + var name = _ref56.name, + param = _ref56.param, + body = _ref56.body; + + if (node.name === name && node.param === param && node.body === body) { + return node; + } + return new Shift.Setter({ name: name, param: param, body: body }); + } + }, { + key: 'reduceShorthandProperty', + value: function reduceShorthandProperty(node, _ref57) { + var name = _ref57.name; + + if (node.name === name) { + return node; + } + return new Shift.ShorthandProperty({ name: name }); + } + }, { + key: 'reduceSpreadElement', + value: function reduceSpreadElement(node, _ref58) { + var expression = _ref58.expression; + + if (node.expression === expression) { + return node; + } + return new Shift.SpreadElement({ expression: expression }); + } + }, { + key: 'reduceSpreadProperty', + value: function reduceSpreadProperty(node, _ref59) { + var expression = _ref59.expression; + + if (node.expression === expression) { + return node; + } + return new Shift.SpreadProperty({ expression: expression }); + } + }, { + key: 'reduceStaticMemberAssignmentTarget', + value: function reduceStaticMemberAssignmentTarget(node, _ref60) { + var object = _ref60.object; + + if (node.object === object) { + return node; + } + return new Shift.StaticMemberAssignmentTarget({ object: object, property: node.property }); + } + }, { + key: 'reduceStaticMemberExpression', + value: function reduceStaticMemberExpression(node, _ref61) { + var object = _ref61.object; + + if (node.object === object) { + return node; + } + return new Shift.StaticMemberExpression({ object: object, property: node.property }); + } + }, { + key: 'reduceStaticPropertyName', + value: function reduceStaticPropertyName(node) { + return node; + } + }, { + key: 'reduceSuper', + value: function reduceSuper(node) { + return node; + } + }, { + key: 'reduceSwitchCase', + value: function reduceSwitchCase(node, _ref62) { + var test = _ref62.test, + consequent = _ref62.consequent; + + if (node.test === test && node.consequent.length === consequent.length && node.consequent.every(function (v, i) { + return v === consequent[i]; + })) { + return node; + } + return new Shift.SwitchCase({ test: test, consequent: consequent }); + } + }, { + key: 'reduceSwitchDefault', + value: function reduceSwitchDefault(node, _ref63) { + var consequent = _ref63.consequent; + + if (node.consequent.length === consequent.length && node.consequent.every(function (v, i) { + return v === consequent[i]; + })) { + return node; + } + return new Shift.SwitchDefault({ consequent: consequent }); + } + }, { + key: 'reduceSwitchStatement', + value: function reduceSwitchStatement(node, _ref64) { + var discriminant = _ref64.discriminant, + cases = _ref64.cases; + + if (node.discriminant === discriminant && node.cases.length === cases.length && node.cases.every(function (v, i) { + return v === cases[i]; + })) { + return node; + } + return new Shift.SwitchStatement({ discriminant: discriminant, cases: cases }); + } + }, { + key: 'reduceSwitchStatementWithDefault', + value: function reduceSwitchStatementWithDefault(node, _ref65) { + var discriminant = _ref65.discriminant, + preDefaultCases = _ref65.preDefaultCases, + defaultCase = _ref65.defaultCase, + postDefaultCases = _ref65.postDefaultCases; + + if (node.discriminant === discriminant && node.preDefaultCases.length === preDefaultCases.length && node.preDefaultCases.every(function (v, i) { + return v === preDefaultCases[i]; + }) && node.defaultCase === defaultCase && node.postDefaultCases.length === postDefaultCases.length && node.postDefaultCases.every(function (v, i) { + return v === postDefaultCases[i]; + })) { + return node; + } + return new Shift.SwitchStatementWithDefault({ discriminant: discriminant, preDefaultCases: preDefaultCases, defaultCase: defaultCase, postDefaultCases: postDefaultCases }); + } + }, { + key: 'reduceTemplateElement', + value: function reduceTemplateElement(node) { + return node; + } + }, { + key: 'reduceTemplateExpression', + value: function reduceTemplateExpression(node, _ref66) { + var tag = _ref66.tag, + elements = _ref66.elements; + + if (node.tag === tag && node.elements.length === elements.length && node.elements.every(function (v, i) { + return v === elements[i]; + })) { + return node; + } + return new Shift.TemplateExpression({ tag: tag, elements: elements }); + } + }, { + key: 'reduceThisExpression', + value: function reduceThisExpression(node) { + return node; + } + }, { + key: 'reduceThrowStatement', + value: function reduceThrowStatement(node, _ref67) { + var expression = _ref67.expression; + + if (node.expression === expression) { + return node; + } + return new Shift.ThrowStatement({ expression: expression }); + } + }, { + key: 'reduceTryCatchStatement', + value: function reduceTryCatchStatement(node, _ref68) { + var body = _ref68.body, + catchClause = _ref68.catchClause; + + if (node.body === body && node.catchClause === catchClause) { + return node; + } + return new Shift.TryCatchStatement({ body: body, catchClause: catchClause }); + } + }, { + key: 'reduceTryFinallyStatement', + value: function reduceTryFinallyStatement(node, _ref69) { + var body = _ref69.body, + catchClause = _ref69.catchClause, + finalizer = _ref69.finalizer; + + if (node.body === body && node.catchClause === catchClause && node.finalizer === finalizer) { + return node; + } + return new Shift.TryFinallyStatement({ body: body, catchClause: catchClause, finalizer: finalizer }); + } + }, { + key: 'reduceUnaryExpression', + value: function reduceUnaryExpression(node, _ref70) { + var operand = _ref70.operand; + + if (node.operand === operand) { + return node; + } + return new Shift.UnaryExpression({ operator: node.operator, operand: operand }); + } + }, { + key: 'reduceUpdateExpression', + value: function reduceUpdateExpression(node, _ref71) { + var operand = _ref71.operand; + + if (node.operand === operand) { + return node; + } + return new Shift.UpdateExpression({ isPrefix: node.isPrefix, operator: node.operator, operand: operand }); + } + }, { + key: 'reduceVariableDeclaration', + value: function reduceVariableDeclaration(node, _ref72) { + var declarators = _ref72.declarators; + + if (node.declarators.length === declarators.length && node.declarators.every(function (v, i) { + return v === declarators[i]; + })) { + return node; + } + return new Shift.VariableDeclaration({ kind: node.kind, declarators: declarators }); + } + }, { + key: 'reduceVariableDeclarationStatement', + value: function reduceVariableDeclarationStatement(node, _ref73) { + var declaration = _ref73.declaration; + + if (node.declaration === declaration) { + return node; + } + return new Shift.VariableDeclarationStatement({ declaration: declaration }); + } + }, { + key: 'reduceVariableDeclarator', + value: function reduceVariableDeclarator(node, _ref74) { + var binding = _ref74.binding, + init = _ref74.init; + + if (node.binding === binding && node.init === init) { + return node; + } + return new Shift.VariableDeclarator({ binding: binding, init: init }); + } + }, { + key: 'reduceWhileStatement', + value: function reduceWhileStatement(node, _ref75) { + var test = _ref75.test, + body = _ref75.body; + + if (node.test === test && node.body === body) { + return node; + } + return new Shift.WhileStatement({ test: test, body: body }); + } + }, { + key: 'reduceWithStatement', + value: function reduceWithStatement(node, _ref76) { + var object = _ref76.object, + body = _ref76.body; + + if (node.object === object && node.body === body) { + return node; + } + return new Shift.WithStatement({ object: object, body: body }); + } + }, { + key: 'reduceYieldExpression', + value: function reduceYieldExpression(node, _ref77) { + var expression = _ref77.expression; + + if (node.expression === expression) { + return node; + } + return new Shift.YieldExpression({ expression: expression }); + } + }, { + key: 'reduceYieldGeneratorExpression', + value: function reduceYieldGeneratorExpression(node, _ref78) { + var expression = _ref78.expression; + + if (node.expression === expression) { + return node; + } + return new Shift.YieldGeneratorExpression({ expression: expression }); + } + }]); + + return LazyCloneReducer; +}(); + +exports.default = LazyCloneReducer; +}); + +var monoidalReducer = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); // Generated by generate-monoidal-reducer.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +var _shiftAst2 = _interopRequireDefault(dist$2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var MonoidalReducer = function () { + function MonoidalReducer(monoid) { + _classCallCheck(this, MonoidalReducer); + + var identity = monoid.empty(); + this.identity = identity; + var concat = void 0; + if (monoid.prototype && typeof monoid.prototype.concat === 'function') { + concat = Function.prototype.call.bind(monoid.prototype.concat); + } else if (typeof monoid.concat === 'function') { + concat = monoid.concat; + } else { + throw new TypeError('Monoid must provide a `concat` method'); + } + this.append = function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return args.reduce(concat, identity); + }; + } + + _createClass(MonoidalReducer, [{ + key: 'reduceArrayAssignmentTarget', + value: function reduceArrayAssignmentTarget(node, _ref) { + var elements = _ref.elements, + rest = _ref.rest; + + return this.append.apply(this, _toConsumableArray(elements.filter(function (n) { + return n != null; + })).concat([rest == null ? this.identity : rest])); + } + }, { + key: 'reduceArrayBinding', + value: function reduceArrayBinding(node, _ref2) { + var elements = _ref2.elements, + rest = _ref2.rest; + + return this.append.apply(this, _toConsumableArray(elements.filter(function (n) { + return n != null; + })).concat([rest == null ? this.identity : rest])); + } + }, { + key: 'reduceArrayExpression', + value: function reduceArrayExpression(node, _ref3) { + var elements = _ref3.elements; + + return this.append.apply(this, _toConsumableArray(elements.filter(function (n) { + return n != null; + }))); + } + }, { + key: 'reduceArrowExpression', + value: function reduceArrowExpression(node, _ref4) { + var params = _ref4.params, + body = _ref4.body; + + return this.append(params, body); + } + }, { + key: 'reduceAssignmentExpression', + value: function reduceAssignmentExpression(node, _ref5) { + var binding = _ref5.binding, + expression = _ref5.expression; + + return this.append(binding, expression); + } + }, { + key: 'reduceAssignmentTargetIdentifier', + value: function reduceAssignmentTargetIdentifier(node) { + return this.identity; + } + }, { + key: 'reduceAssignmentTargetPropertyIdentifier', + value: function reduceAssignmentTargetPropertyIdentifier(node, _ref6) { + var binding = _ref6.binding, + init = _ref6.init; + + return this.append(binding, init == null ? this.identity : init); + } + }, { + key: 'reduceAssignmentTargetPropertyProperty', + value: function reduceAssignmentTargetPropertyProperty(node, _ref7) { + var name = _ref7.name, + binding = _ref7.binding; + + return this.append(name, binding); + } + }, { + key: 'reduceAssignmentTargetWithDefault', + value: function reduceAssignmentTargetWithDefault(node, _ref8) { + var binding = _ref8.binding, + init = _ref8.init; + + return this.append(binding, init); + } + }, { + key: 'reduceAwaitExpression', + value: function reduceAwaitExpression(node, _ref9) { + var expression = _ref9.expression; + + return expression; + } + }, { + key: 'reduceBinaryExpression', + value: function reduceBinaryExpression(node, _ref10) { + var left = _ref10.left, + right = _ref10.right; + + return this.append(left, right); + } + }, { + key: 'reduceBindingIdentifier', + value: function reduceBindingIdentifier(node) { + return this.identity; + } + }, { + key: 'reduceBindingPropertyIdentifier', + value: function reduceBindingPropertyIdentifier(node, _ref11) { + var binding = _ref11.binding, + init = _ref11.init; + + return this.append(binding, init == null ? this.identity : init); + } + }, { + key: 'reduceBindingPropertyProperty', + value: function reduceBindingPropertyProperty(node, _ref12) { + var name = _ref12.name, + binding = _ref12.binding; + + return this.append(name, binding); + } + }, { + key: 'reduceBindingWithDefault', + value: function reduceBindingWithDefault(node, _ref13) { + var binding = _ref13.binding, + init = _ref13.init; + + return this.append(binding, init); + } + }, { + key: 'reduceBlock', + value: function reduceBlock(node, _ref14) { + var statements = _ref14.statements; + + return this.append.apply(this, _toConsumableArray(statements)); + } + }, { + key: 'reduceBlockStatement', + value: function reduceBlockStatement(node, _ref15) { + var block = _ref15.block; + + return block; + } + }, { + key: 'reduceBreakStatement', + value: function reduceBreakStatement(node) { + return this.identity; + } + }, { + key: 'reduceCallExpression', + value: function reduceCallExpression(node, _ref16) { + var callee = _ref16.callee, + _arguments = _ref16.arguments; + + return this.append.apply(this, [callee].concat(_toConsumableArray(_arguments))); + } + }, { + key: 'reduceCatchClause', + value: function reduceCatchClause(node, _ref17) { + var binding = _ref17.binding, + body = _ref17.body; + + return this.append(binding, body); + } + }, { + key: 'reduceClassDeclaration', + value: function reduceClassDeclaration(node, _ref18) { + var name = _ref18.name, + _super = _ref18.super, + elements = _ref18.elements; + + return this.append.apply(this, [name, _super == null ? this.identity : _super].concat(_toConsumableArray(elements))); + } + }, { + key: 'reduceClassElement', + value: function reduceClassElement(node, _ref19) { + var method = _ref19.method; + + return method; + } + }, { + key: 'reduceClassExpression', + value: function reduceClassExpression(node, _ref20) { + var name = _ref20.name, + _super = _ref20.super, + elements = _ref20.elements; + + return this.append.apply(this, [name == null ? this.identity : name, _super == null ? this.identity : _super].concat(_toConsumableArray(elements))); + } + }, { + key: 'reduceCompoundAssignmentExpression', + value: function reduceCompoundAssignmentExpression(node, _ref21) { + var binding = _ref21.binding, + expression = _ref21.expression; + + return this.append(binding, expression); + } + }, { + key: 'reduceComputedMemberAssignmentTarget', + value: function reduceComputedMemberAssignmentTarget(node, _ref22) { + var object = _ref22.object, + expression = _ref22.expression; + + return this.append(object, expression); + } + }, { + key: 'reduceComputedMemberExpression', + value: function reduceComputedMemberExpression(node, _ref23) { + var object = _ref23.object, + expression = _ref23.expression; + + return this.append(object, expression); + } + }, { + key: 'reduceComputedPropertyName', + value: function reduceComputedPropertyName(node, _ref24) { + var expression = _ref24.expression; + + return expression; + } + }, { + key: 'reduceConditionalExpression', + value: function reduceConditionalExpression(node, _ref25) { + var test = _ref25.test, + consequent = _ref25.consequent, + alternate = _ref25.alternate; + + return this.append(test, consequent, alternate); + } + }, { + key: 'reduceContinueStatement', + value: function reduceContinueStatement(node) { + return this.identity; + } + }, { + key: 'reduceDataProperty', + value: function reduceDataProperty(node, _ref26) { + var name = _ref26.name, + expression = _ref26.expression; + + return this.append(name, expression); + } + }, { + key: 'reduceDebuggerStatement', + value: function reduceDebuggerStatement(node) { + return this.identity; + } + }, { + key: 'reduceDirective', + value: function reduceDirective(node) { + return this.identity; + } + }, { + key: 'reduceDoWhileStatement', + value: function reduceDoWhileStatement(node, _ref27) { + var body = _ref27.body, + test = _ref27.test; + + return this.append(body, test); + } + }, { + key: 'reduceEmptyStatement', + value: function reduceEmptyStatement(node) { + return this.identity; + } + }, { + key: 'reduceExport', + value: function reduceExport(node, _ref28) { + var declaration = _ref28.declaration; + + return declaration; + } + }, { + key: 'reduceExportAllFrom', + value: function reduceExportAllFrom(node) { + return this.identity; + } + }, { + key: 'reduceExportDefault', + value: function reduceExportDefault(node, _ref29) { + var body = _ref29.body; + + return body; + } + }, { + key: 'reduceExportFrom', + value: function reduceExportFrom(node, _ref30) { + var namedExports = _ref30.namedExports; + + return this.append.apply(this, _toConsumableArray(namedExports)); + } + }, { + key: 'reduceExportFromSpecifier', + value: function reduceExportFromSpecifier(node) { + return this.identity; + } + }, { + key: 'reduceExportLocalSpecifier', + value: function reduceExportLocalSpecifier(node, _ref31) { + var name = _ref31.name; + + return name; + } + }, { + key: 'reduceExportLocals', + value: function reduceExportLocals(node, _ref32) { + var namedExports = _ref32.namedExports; + + return this.append.apply(this, _toConsumableArray(namedExports)); + } + }, { + key: 'reduceExpressionStatement', + value: function reduceExpressionStatement(node, _ref33) { + var expression = _ref33.expression; + + return expression; + } + }, { + key: 'reduceForAwaitStatement', + value: function reduceForAwaitStatement(node, _ref34) { + var left = _ref34.left, + right = _ref34.right, + body = _ref34.body; + + return this.append(left, right, body); + } + }, { + key: 'reduceForInStatement', + value: function reduceForInStatement(node, _ref35) { + var left = _ref35.left, + right = _ref35.right, + body = _ref35.body; + + return this.append(left, right, body); + } + }, { + key: 'reduceForOfStatement', + value: function reduceForOfStatement(node, _ref36) { + var left = _ref36.left, + right = _ref36.right, + body = _ref36.body; + + return this.append(left, right, body); + } + }, { + key: 'reduceForStatement', + value: function reduceForStatement(node, _ref37) { + var init = _ref37.init, + test = _ref37.test, + update = _ref37.update, + body = _ref37.body; + + return this.append(init == null ? this.identity : init, test == null ? this.identity : test, update == null ? this.identity : update, body); + } + }, { + key: 'reduceFormalParameters', + value: function reduceFormalParameters(node, _ref38) { + var items = _ref38.items, + rest = _ref38.rest; + + return this.append.apply(this, _toConsumableArray(items).concat([rest == null ? this.identity : rest])); + } + }, { + key: 'reduceFunctionBody', + value: function reduceFunctionBody(node, _ref39) { + var directives = _ref39.directives, + statements = _ref39.statements; + + return this.append.apply(this, _toConsumableArray(directives).concat(_toConsumableArray(statements))); + } + }, { + key: 'reduceFunctionDeclaration', + value: function reduceFunctionDeclaration(node, _ref40) { + var name = _ref40.name, + params = _ref40.params, + body = _ref40.body; + + return this.append(name, params, body); + } + }, { + key: 'reduceFunctionExpression', + value: function reduceFunctionExpression(node, _ref41) { + var name = _ref41.name, + params = _ref41.params, + body = _ref41.body; + + return this.append(name == null ? this.identity : name, params, body); + } + }, { + key: 'reduceGetter', + value: function reduceGetter(node, _ref42) { + var name = _ref42.name, + body = _ref42.body; + + return this.append(name, body); + } + }, { + key: 'reduceIdentifierExpression', + value: function reduceIdentifierExpression(node) { + return this.identity; + } + }, { + key: 'reduceIfStatement', + value: function reduceIfStatement(node, _ref43) { + var test = _ref43.test, + consequent = _ref43.consequent, + alternate = _ref43.alternate; + + return this.append(test, consequent, alternate == null ? this.identity : alternate); + } + }, { + key: 'reduceImport', + value: function reduceImport(node, _ref44) { + var defaultBinding = _ref44.defaultBinding, + namedImports = _ref44.namedImports; + + return this.append.apply(this, [defaultBinding == null ? this.identity : defaultBinding].concat(_toConsumableArray(namedImports))); + } + }, { + key: 'reduceImportNamespace', + value: function reduceImportNamespace(node, _ref45) { + var defaultBinding = _ref45.defaultBinding, + namespaceBinding = _ref45.namespaceBinding; + + return this.append(defaultBinding == null ? this.identity : defaultBinding, namespaceBinding); + } + }, { + key: 'reduceImportSpecifier', + value: function reduceImportSpecifier(node, _ref46) { + var binding = _ref46.binding; + + return binding; + } + }, { + key: 'reduceLabeledStatement', + value: function reduceLabeledStatement(node, _ref47) { + var body = _ref47.body; + + return body; + } + }, { + key: 'reduceLiteralBooleanExpression', + value: function reduceLiteralBooleanExpression(node) { + return this.identity; + } + }, { + key: 'reduceLiteralInfinityExpression', + value: function reduceLiteralInfinityExpression(node) { + return this.identity; + } + }, { + key: 'reduceLiteralNullExpression', + value: function reduceLiteralNullExpression(node) { + return this.identity; + } + }, { + key: 'reduceLiteralNumericExpression', + value: function reduceLiteralNumericExpression(node) { + return this.identity; + } + }, { + key: 'reduceLiteralRegExpExpression', + value: function reduceLiteralRegExpExpression(node) { + return this.identity; + } + }, { + key: 'reduceLiteralStringExpression', + value: function reduceLiteralStringExpression(node) { + return this.identity; + } + }, { + key: 'reduceMethod', + value: function reduceMethod(node, _ref48) { + var name = _ref48.name, + params = _ref48.params, + body = _ref48.body; + + return this.append(name, params, body); + } + }, { + key: 'reduceModule', + value: function reduceModule(node, _ref49) { + var directives = _ref49.directives, + items = _ref49.items; + + return this.append.apply(this, _toConsumableArray(directives).concat(_toConsumableArray(items))); + } + }, { + key: 'reduceNewExpression', + value: function reduceNewExpression(node, _ref50) { + var callee = _ref50.callee, + _arguments = _ref50.arguments; + + return this.append.apply(this, [callee].concat(_toConsumableArray(_arguments))); + } + }, { + key: 'reduceNewTargetExpression', + value: function reduceNewTargetExpression(node) { + return this.identity; + } + }, { + key: 'reduceObjectAssignmentTarget', + value: function reduceObjectAssignmentTarget(node, _ref51) { + var properties = _ref51.properties, + rest = _ref51.rest; + + return this.append.apply(this, _toConsumableArray(properties).concat([rest == null ? this.identity : rest])); + } + }, { + key: 'reduceObjectBinding', + value: function reduceObjectBinding(node, _ref52) { + var properties = _ref52.properties, + rest = _ref52.rest; + + return this.append.apply(this, _toConsumableArray(properties).concat([rest == null ? this.identity : rest])); + } + }, { + key: 'reduceObjectExpression', + value: function reduceObjectExpression(node, _ref53) { + var properties = _ref53.properties; + + return this.append.apply(this, _toConsumableArray(properties)); + } + }, { + key: 'reduceReturnStatement', + value: function reduceReturnStatement(node, _ref54) { + var expression = _ref54.expression; + + return expression == null ? this.identity : expression; + } + }, { + key: 'reduceScript', + value: function reduceScript(node, _ref55) { + var directives = _ref55.directives, + statements = _ref55.statements; + + return this.append.apply(this, _toConsumableArray(directives).concat(_toConsumableArray(statements))); + } + }, { + key: 'reduceSetter', + value: function reduceSetter(node, _ref56) { + var name = _ref56.name, + param = _ref56.param, + body = _ref56.body; + + return this.append(name, param, body); + } + }, { + key: 'reduceShorthandProperty', + value: function reduceShorthandProperty(node, _ref57) { + var name = _ref57.name; + + return name; + } + }, { + key: 'reduceSpreadElement', + value: function reduceSpreadElement(node, _ref58) { + var expression = _ref58.expression; + + return expression; + } + }, { + key: 'reduceSpreadProperty', + value: function reduceSpreadProperty(node, _ref59) { + var expression = _ref59.expression; + + return expression; + } + }, { + key: 'reduceStaticMemberAssignmentTarget', + value: function reduceStaticMemberAssignmentTarget(node, _ref60) { + var object = _ref60.object; + + return object; + } + }, { + key: 'reduceStaticMemberExpression', + value: function reduceStaticMemberExpression(node, _ref61) { + var object = _ref61.object; + + return object; + } + }, { + key: 'reduceStaticPropertyName', + value: function reduceStaticPropertyName(node) { + return this.identity; + } + }, { + key: 'reduceSuper', + value: function reduceSuper(node) { + return this.identity; + } + }, { + key: 'reduceSwitchCase', + value: function reduceSwitchCase(node, _ref62) { + var test = _ref62.test, + consequent = _ref62.consequent; + + return this.append.apply(this, [test].concat(_toConsumableArray(consequent))); + } + }, { + key: 'reduceSwitchDefault', + value: function reduceSwitchDefault(node, _ref63) { + var consequent = _ref63.consequent; + + return this.append.apply(this, _toConsumableArray(consequent)); + } + }, { + key: 'reduceSwitchStatement', + value: function reduceSwitchStatement(node, _ref64) { + var discriminant = _ref64.discriminant, + cases = _ref64.cases; + + return this.append.apply(this, [discriminant].concat(_toConsumableArray(cases))); + } + }, { + key: 'reduceSwitchStatementWithDefault', + value: function reduceSwitchStatementWithDefault(node, _ref65) { + var discriminant = _ref65.discriminant, + preDefaultCases = _ref65.preDefaultCases, + defaultCase = _ref65.defaultCase, + postDefaultCases = _ref65.postDefaultCases; + + return this.append.apply(this, [discriminant].concat(_toConsumableArray(preDefaultCases), [defaultCase], _toConsumableArray(postDefaultCases))); + } + }, { + key: 'reduceTemplateElement', + value: function reduceTemplateElement(node) { + return this.identity; + } + }, { + key: 'reduceTemplateExpression', + value: function reduceTemplateExpression(node, _ref66) { + var tag = _ref66.tag, + elements = _ref66.elements; + + return this.append.apply(this, [tag == null ? this.identity : tag].concat(_toConsumableArray(elements))); + } + }, { + key: 'reduceThisExpression', + value: function reduceThisExpression(node) { + return this.identity; + } + }, { + key: 'reduceThrowStatement', + value: function reduceThrowStatement(node, _ref67) { + var expression = _ref67.expression; + + return expression; + } + }, { + key: 'reduceTryCatchStatement', + value: function reduceTryCatchStatement(node, _ref68) { + var body = _ref68.body, + catchClause = _ref68.catchClause; + + return this.append(body, catchClause); + } + }, { + key: 'reduceTryFinallyStatement', + value: function reduceTryFinallyStatement(node, _ref69) { + var body = _ref69.body, + catchClause = _ref69.catchClause, + finalizer = _ref69.finalizer; + + return this.append(body, catchClause == null ? this.identity : catchClause, finalizer); + } + }, { + key: 'reduceUnaryExpression', + value: function reduceUnaryExpression(node, _ref70) { + var operand = _ref70.operand; + + return operand; + } + }, { + key: 'reduceUpdateExpression', + value: function reduceUpdateExpression(node, _ref71) { + var operand = _ref71.operand; + + return operand; + } + }, { + key: 'reduceVariableDeclaration', + value: function reduceVariableDeclaration(node, _ref72) { + var declarators = _ref72.declarators; + + return this.append.apply(this, _toConsumableArray(declarators)); + } + }, { + key: 'reduceVariableDeclarationStatement', + value: function reduceVariableDeclarationStatement(node, _ref73) { + var declaration = _ref73.declaration; + + return declaration; + } + }, { + key: 'reduceVariableDeclarator', + value: function reduceVariableDeclarator(node, _ref74) { + var binding = _ref74.binding, + init = _ref74.init; + + return this.append(binding, init == null ? this.identity : init); + } + }, { + key: 'reduceWhileStatement', + value: function reduceWhileStatement(node, _ref75) { + var test = _ref75.test, + body = _ref75.body; + + return this.append(test, body); + } + }, { + key: 'reduceWithStatement', + value: function reduceWithStatement(node, _ref76) { + var object = _ref76.object, + body = _ref76.body; + + return this.append(object, body); + } + }, { + key: 'reduceYieldExpression', + value: function reduceYieldExpression(node, _ref77) { + var expression = _ref77.expression; + + return expression == null ? this.identity : expression; + } + }, { + key: 'reduceYieldGeneratorExpression', + value: function reduceYieldGeneratorExpression(node, _ref78) { + var expression = _ref78.expression; + + return expression; + } + }]); + + return MonoidalReducer; +}(); + +exports.default = MonoidalReducer; +}); + +var thunkedMonoidalReducer = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); // Generated by generate-monoidal-reducer.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +var _shiftAst2 = _interopRequireDefault(dist$2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var MonoidalReducer = function () { + function MonoidalReducer(monoid) { + _classCallCheck(this, MonoidalReducer); + + var identity = monoid.empty(); + this.identity = identity; + + var concatThunk = void 0; + if (monoid.prototype && typeof monoid.prototype.concatThunk === 'function') { + concatThunk = Function.prototype.call.bind(monoid.prototype.concatThunk); + } else if (typeof monoid.concatThunk === 'function') { + concatThunk = monoid.concatThunk; + } else { + var concat = void 0; + if (monoid.prototype && typeof monoid.prototype.concat === 'function') { + concat = Function.prototype.call.bind(monoid.prototype.concat); + } else if (typeof monoid.concat === 'function') { + concat = monoid.concat; + } else { + throw new TypeError('Monoid must provide a `concatThunk` or `concat` method'); + } + if (typeof monoid.isAbsorbing === 'function') { + var isAbsorbing = monoid.isAbsorbing; + concatThunk = function concatThunk(a, b) { + return isAbsorbing(a) ? a : concat(a, b()); + }; + } else { + concatThunk = function concatThunk(a, b) { + return concat(a, b()); + }; + } + } + this.append = function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return args.reduce(concatThunk, identity); + }; + } + + _createClass(MonoidalReducer, [{ + key: 'reduceArrayAssignmentTarget', + value: function reduceArrayAssignmentTarget(node, _ref) { + var _this = this; + + var elements = _ref.elements, + rest = _ref.rest; + + return this.append.apply(this, _toConsumableArray(elements.filter(function (n) { + return n != null; + })).concat([rest == null ? function () { + return _this.identity; + } : rest])); + } + }, { + key: 'reduceArrayBinding', + value: function reduceArrayBinding(node, _ref2) { + var _this2 = this; + + var elements = _ref2.elements, + rest = _ref2.rest; + + return this.append.apply(this, _toConsumableArray(elements.filter(function (n) { + return n != null; + })).concat([rest == null ? function () { + return _this2.identity; + } : rest])); + } + }, { + key: 'reduceArrayExpression', + value: function reduceArrayExpression(node, _ref3) { + var elements = _ref3.elements; + + return this.append.apply(this, _toConsumableArray(elements.filter(function (n) { + return n != null; + }))); + } + }, { + key: 'reduceArrowExpression', + value: function reduceArrowExpression(node, _ref4) { + var params = _ref4.params, + body = _ref4.body; + + return this.append(params, body); + } + }, { + key: 'reduceAssignmentExpression', + value: function reduceAssignmentExpression(node, _ref5) { + var binding = _ref5.binding, + expression = _ref5.expression; + + return this.append(binding, expression); + } + }, { + key: 'reduceAssignmentTargetIdentifier', + value: function reduceAssignmentTargetIdentifier(node) { + return this.identity; + } + }, { + key: 'reduceAssignmentTargetPropertyIdentifier', + value: function reduceAssignmentTargetPropertyIdentifier(node, _ref6) { + var _this3 = this; + + var binding = _ref6.binding, + init = _ref6.init; + + return this.append(binding, init == null ? function () { + return _this3.identity; + } : init); + } + }, { + key: 'reduceAssignmentTargetPropertyProperty', + value: function reduceAssignmentTargetPropertyProperty(node, _ref7) { + var name = _ref7.name, + binding = _ref7.binding; + + return this.append(name, binding); + } + }, { + key: 'reduceAssignmentTargetWithDefault', + value: function reduceAssignmentTargetWithDefault(node, _ref8) { + var binding = _ref8.binding, + init = _ref8.init; + + return this.append(binding, init); + } + }, { + key: 'reduceAwaitExpression', + value: function reduceAwaitExpression(node, _ref9) { + var expression = _ref9.expression; + + return expression(); + } + }, { + key: 'reduceBinaryExpression', + value: function reduceBinaryExpression(node, _ref10) { + var left = _ref10.left, + right = _ref10.right; + + return this.append(left, right); + } + }, { + key: 'reduceBindingIdentifier', + value: function reduceBindingIdentifier(node) { + return this.identity; + } + }, { + key: 'reduceBindingPropertyIdentifier', + value: function reduceBindingPropertyIdentifier(node, _ref11) { + var _this4 = this; + + var binding = _ref11.binding, + init = _ref11.init; + + return this.append(binding, init == null ? function () { + return _this4.identity; + } : init); + } + }, { + key: 'reduceBindingPropertyProperty', + value: function reduceBindingPropertyProperty(node, _ref12) { + var name = _ref12.name, + binding = _ref12.binding; + + return this.append(name, binding); + } + }, { + key: 'reduceBindingWithDefault', + value: function reduceBindingWithDefault(node, _ref13) { + var binding = _ref13.binding, + init = _ref13.init; + + return this.append(binding, init); + } + }, { + key: 'reduceBlock', + value: function reduceBlock(node, _ref14) { + var statements = _ref14.statements; + + return this.append.apply(this, _toConsumableArray(statements)); + } + }, { + key: 'reduceBlockStatement', + value: function reduceBlockStatement(node, _ref15) { + var block = _ref15.block; + + return block(); + } + }, { + key: 'reduceBreakStatement', + value: function reduceBreakStatement(node) { + return this.identity; + } + }, { + key: 'reduceCallExpression', + value: function reduceCallExpression(node, _ref16) { + var callee = _ref16.callee, + _arguments = _ref16.arguments; + + return this.append.apply(this, [callee].concat(_toConsumableArray(_arguments))); + } + }, { + key: 'reduceCatchClause', + value: function reduceCatchClause(node, _ref17) { + var binding = _ref17.binding, + body = _ref17.body; + + return this.append(binding, body); + } + }, { + key: 'reduceClassDeclaration', + value: function reduceClassDeclaration(node, _ref18) { + var _this5 = this; + + var name = _ref18.name, + _super = _ref18.super, + elements = _ref18.elements; + + return this.append.apply(this, [name, _super == null ? function () { + return _this5.identity; + } : _super].concat(_toConsumableArray(elements))); + } + }, { + key: 'reduceClassElement', + value: function reduceClassElement(node, _ref19) { + var method = _ref19.method; + + return method(); + } + }, { + key: 'reduceClassExpression', + value: function reduceClassExpression(node, _ref20) { + var _this6 = this; + + var name = _ref20.name, + _super = _ref20.super, + elements = _ref20.elements; + + return this.append.apply(this, [name == null ? function () { + return _this6.identity; + } : name, _super == null ? function () { + return _this6.identity; + } : _super].concat(_toConsumableArray(elements))); + } + }, { + key: 'reduceCompoundAssignmentExpression', + value: function reduceCompoundAssignmentExpression(node, _ref21) { + var binding = _ref21.binding, + expression = _ref21.expression; + + return this.append(binding, expression); + } + }, { + key: 'reduceComputedMemberAssignmentTarget', + value: function reduceComputedMemberAssignmentTarget(node, _ref22) { + var object = _ref22.object, + expression = _ref22.expression; + + return this.append(object, expression); + } + }, { + key: 'reduceComputedMemberExpression', + value: function reduceComputedMemberExpression(node, _ref23) { + var object = _ref23.object, + expression = _ref23.expression; + + return this.append(object, expression); + } + }, { + key: 'reduceComputedPropertyName', + value: function reduceComputedPropertyName(node, _ref24) { + var expression = _ref24.expression; + + return expression(); + } + }, { + key: 'reduceConditionalExpression', + value: function reduceConditionalExpression(node, _ref25) { + var test = _ref25.test, + consequent = _ref25.consequent, + alternate = _ref25.alternate; + + return this.append(test, consequent, alternate); + } + }, { + key: 'reduceContinueStatement', + value: function reduceContinueStatement(node) { + return this.identity; + } + }, { + key: 'reduceDataProperty', + value: function reduceDataProperty(node, _ref26) { + var name = _ref26.name, + expression = _ref26.expression; + + return this.append(name, expression); + } + }, { + key: 'reduceDebuggerStatement', + value: function reduceDebuggerStatement(node) { + return this.identity; + } + }, { + key: 'reduceDirective', + value: function reduceDirective(node) { + return this.identity; + } + }, { + key: 'reduceDoWhileStatement', + value: function reduceDoWhileStatement(node, _ref27) { + var body = _ref27.body, + test = _ref27.test; + + return this.append(body, test); + } + }, { + key: 'reduceEmptyStatement', + value: function reduceEmptyStatement(node) { + return this.identity; + } + }, { + key: 'reduceExport', + value: function reduceExport(node, _ref28) { + var declaration = _ref28.declaration; + + return declaration(); + } + }, { + key: 'reduceExportAllFrom', + value: function reduceExportAllFrom(node) { + return this.identity; + } + }, { + key: 'reduceExportDefault', + value: function reduceExportDefault(node, _ref29) { + var body = _ref29.body; + + return body(); + } + }, { + key: 'reduceExportFrom', + value: function reduceExportFrom(node, _ref30) { + var namedExports = _ref30.namedExports; + + return this.append.apply(this, _toConsumableArray(namedExports)); + } + }, { + key: 'reduceExportFromSpecifier', + value: function reduceExportFromSpecifier(node) { + return this.identity; + } + }, { + key: 'reduceExportLocalSpecifier', + value: function reduceExportLocalSpecifier(node, _ref31) { + var name = _ref31.name; + + return name(); + } + }, { + key: 'reduceExportLocals', + value: function reduceExportLocals(node, _ref32) { + var namedExports = _ref32.namedExports; + + return this.append.apply(this, _toConsumableArray(namedExports)); + } + }, { + key: 'reduceExpressionStatement', + value: function reduceExpressionStatement(node, _ref33) { + var expression = _ref33.expression; + + return expression(); + } + }, { + key: 'reduceForAwaitStatement', + value: function reduceForAwaitStatement(node, _ref34) { + var left = _ref34.left, + right = _ref34.right, + body = _ref34.body; + + return this.append(left, right, body); + } + }, { + key: 'reduceForInStatement', + value: function reduceForInStatement(node, _ref35) { + var left = _ref35.left, + right = _ref35.right, + body = _ref35.body; + + return this.append(left, right, body); + } + }, { + key: 'reduceForOfStatement', + value: function reduceForOfStatement(node, _ref36) { + var left = _ref36.left, + right = _ref36.right, + body = _ref36.body; + + return this.append(left, right, body); + } + }, { + key: 'reduceForStatement', + value: function reduceForStatement(node, _ref37) { + var _this7 = this; + + var init = _ref37.init, + test = _ref37.test, + update = _ref37.update, + body = _ref37.body; + + return this.append(init == null ? function () { + return _this7.identity; + } : init, test == null ? function () { + return _this7.identity; + } : test, update == null ? function () { + return _this7.identity; + } : update, body); + } + }, { + key: 'reduceFormalParameters', + value: function reduceFormalParameters(node, _ref38) { + var _this8 = this; + + var items = _ref38.items, + rest = _ref38.rest; + + return this.append.apply(this, _toConsumableArray(items).concat([rest == null ? function () { + return _this8.identity; + } : rest])); + } + }, { + key: 'reduceFunctionBody', + value: function reduceFunctionBody(node, _ref39) { + var directives = _ref39.directives, + statements = _ref39.statements; + + return this.append.apply(this, _toConsumableArray(directives).concat(_toConsumableArray(statements))); + } + }, { + key: 'reduceFunctionDeclaration', + value: function reduceFunctionDeclaration(node, _ref40) { + var name = _ref40.name, + params = _ref40.params, + body = _ref40.body; + + return this.append(name, params, body); + } + }, { + key: 'reduceFunctionExpression', + value: function reduceFunctionExpression(node, _ref41) { + var _this9 = this; + + var name = _ref41.name, + params = _ref41.params, + body = _ref41.body; + + return this.append(name == null ? function () { + return _this9.identity; + } : name, params, body); + } + }, { + key: 'reduceGetter', + value: function reduceGetter(node, _ref42) { + var name = _ref42.name, + body = _ref42.body; + + return this.append(name, body); + } + }, { + key: 'reduceIdentifierExpression', + value: function reduceIdentifierExpression(node) { + return this.identity; + } + }, { + key: 'reduceIfStatement', + value: function reduceIfStatement(node, _ref43) { + var _this10 = this; + + var test = _ref43.test, + consequent = _ref43.consequent, + alternate = _ref43.alternate; + + return this.append(test, consequent, alternate == null ? function () { + return _this10.identity; + } : alternate); + } + }, { + key: 'reduceImport', + value: function reduceImport(node, _ref44) { + var _this11 = this; + + var defaultBinding = _ref44.defaultBinding, + namedImports = _ref44.namedImports; + + return this.append.apply(this, [defaultBinding == null ? function () { + return _this11.identity; + } : defaultBinding].concat(_toConsumableArray(namedImports))); + } + }, { + key: 'reduceImportNamespace', + value: function reduceImportNamespace(node, _ref45) { + var _this12 = this; + + var defaultBinding = _ref45.defaultBinding, + namespaceBinding = _ref45.namespaceBinding; + + return this.append(defaultBinding == null ? function () { + return _this12.identity; + } : defaultBinding, namespaceBinding); + } + }, { + key: 'reduceImportSpecifier', + value: function reduceImportSpecifier(node, _ref46) { + var binding = _ref46.binding; + + return binding(); + } + }, { + key: 'reduceLabeledStatement', + value: function reduceLabeledStatement(node, _ref47) { + var body = _ref47.body; + + return body(); + } + }, { + key: 'reduceLiteralBooleanExpression', + value: function reduceLiteralBooleanExpression(node) { + return this.identity; + } + }, { + key: 'reduceLiteralInfinityExpression', + value: function reduceLiteralInfinityExpression(node) { + return this.identity; + } + }, { + key: 'reduceLiteralNullExpression', + value: function reduceLiteralNullExpression(node) { + return this.identity; + } + }, { + key: 'reduceLiteralNumericExpression', + value: function reduceLiteralNumericExpression(node) { + return this.identity; + } + }, { + key: 'reduceLiteralRegExpExpression', + value: function reduceLiteralRegExpExpression(node) { + return this.identity; + } + }, { + key: 'reduceLiteralStringExpression', + value: function reduceLiteralStringExpression(node) { + return this.identity; + } + }, { + key: 'reduceMethod', + value: function reduceMethod(node, _ref48) { + var name = _ref48.name, + params = _ref48.params, + body = _ref48.body; + + return this.append(name, params, body); + } + }, { + key: 'reduceModule', + value: function reduceModule(node, _ref49) { + var directives = _ref49.directives, + items = _ref49.items; + + return this.append.apply(this, _toConsumableArray(directives).concat(_toConsumableArray(items))); + } + }, { + key: 'reduceNewExpression', + value: function reduceNewExpression(node, _ref50) { + var callee = _ref50.callee, + _arguments = _ref50.arguments; + + return this.append.apply(this, [callee].concat(_toConsumableArray(_arguments))); + } + }, { + key: 'reduceNewTargetExpression', + value: function reduceNewTargetExpression(node) { + return this.identity; + } + }, { + key: 'reduceObjectAssignmentTarget', + value: function reduceObjectAssignmentTarget(node, _ref51) { + var _this13 = this; + + var properties = _ref51.properties, + rest = _ref51.rest; + + return this.append.apply(this, _toConsumableArray(properties).concat([rest == null ? function () { + return _this13.identity; + } : rest])); + } + }, { + key: 'reduceObjectBinding', + value: function reduceObjectBinding(node, _ref52) { + var _this14 = this; + + var properties = _ref52.properties, + rest = _ref52.rest; + + return this.append.apply(this, _toConsumableArray(properties).concat([rest == null ? function () { + return _this14.identity; + } : rest])); + } + }, { + key: 'reduceObjectExpression', + value: function reduceObjectExpression(node, _ref53) { + var properties = _ref53.properties; + + return this.append.apply(this, _toConsumableArray(properties)); + } + }, { + key: 'reduceReturnStatement', + value: function reduceReturnStatement(node, _ref54) { + var expression = _ref54.expression; + + return expression == null ? this.identity : expression(); + } + }, { + key: 'reduceScript', + value: function reduceScript(node, _ref55) { + var directives = _ref55.directives, + statements = _ref55.statements; + + return this.append.apply(this, _toConsumableArray(directives).concat(_toConsumableArray(statements))); + } + }, { + key: 'reduceSetter', + value: function reduceSetter(node, _ref56) { + var name = _ref56.name, + param = _ref56.param, + body = _ref56.body; + + return this.append(name, param, body); + } + }, { + key: 'reduceShorthandProperty', + value: function reduceShorthandProperty(node, _ref57) { + var name = _ref57.name; + + return name(); + } + }, { + key: 'reduceSpreadElement', + value: function reduceSpreadElement(node, _ref58) { + var expression = _ref58.expression; + + return expression(); + } + }, { + key: 'reduceSpreadProperty', + value: function reduceSpreadProperty(node, _ref59) { + var expression = _ref59.expression; + + return expression(); + } + }, { + key: 'reduceStaticMemberAssignmentTarget', + value: function reduceStaticMemberAssignmentTarget(node, _ref60) { + var object = _ref60.object; + + return object(); + } + }, { + key: 'reduceStaticMemberExpression', + value: function reduceStaticMemberExpression(node, _ref61) { + var object = _ref61.object; + + return object(); + } + }, { + key: 'reduceStaticPropertyName', + value: function reduceStaticPropertyName(node) { + return this.identity; + } + }, { + key: 'reduceSuper', + value: function reduceSuper(node) { + return this.identity; + } + }, { + key: 'reduceSwitchCase', + value: function reduceSwitchCase(node, _ref62) { + var test = _ref62.test, + consequent = _ref62.consequent; + + return this.append.apply(this, [test].concat(_toConsumableArray(consequent))); + } + }, { + key: 'reduceSwitchDefault', + value: function reduceSwitchDefault(node, _ref63) { + var consequent = _ref63.consequent; + + return this.append.apply(this, _toConsumableArray(consequent)); + } + }, { + key: 'reduceSwitchStatement', + value: function reduceSwitchStatement(node, _ref64) { + var discriminant = _ref64.discriminant, + cases = _ref64.cases; + + return this.append.apply(this, [discriminant].concat(_toConsumableArray(cases))); + } + }, { + key: 'reduceSwitchStatementWithDefault', + value: function reduceSwitchStatementWithDefault(node, _ref65) { + var discriminant = _ref65.discriminant, + preDefaultCases = _ref65.preDefaultCases, + defaultCase = _ref65.defaultCase, + postDefaultCases = _ref65.postDefaultCases; + + return this.append.apply(this, [discriminant].concat(_toConsumableArray(preDefaultCases), [defaultCase], _toConsumableArray(postDefaultCases))); + } + }, { + key: 'reduceTemplateElement', + value: function reduceTemplateElement(node) { + return this.identity; + } + }, { + key: 'reduceTemplateExpression', + value: function reduceTemplateExpression(node, _ref66) { + var _this15 = this; + + var tag = _ref66.tag, + elements = _ref66.elements; + + return this.append.apply(this, [tag == null ? function () { + return _this15.identity; + } : tag].concat(_toConsumableArray(elements))); + } + }, { + key: 'reduceThisExpression', + value: function reduceThisExpression(node) { + return this.identity; + } + }, { + key: 'reduceThrowStatement', + value: function reduceThrowStatement(node, _ref67) { + var expression = _ref67.expression; + + return expression(); + } + }, { + key: 'reduceTryCatchStatement', + value: function reduceTryCatchStatement(node, _ref68) { + var body = _ref68.body, + catchClause = _ref68.catchClause; + + return this.append(body, catchClause); + } + }, { + key: 'reduceTryFinallyStatement', + value: function reduceTryFinallyStatement(node, _ref69) { + var _this16 = this; + + var body = _ref69.body, + catchClause = _ref69.catchClause, + finalizer = _ref69.finalizer; + + return this.append(body, catchClause == null ? function () { + return _this16.identity; + } : catchClause, finalizer); + } + }, { + key: 'reduceUnaryExpression', + value: function reduceUnaryExpression(node, _ref70) { + var operand = _ref70.operand; + + return operand(); + } + }, { + key: 'reduceUpdateExpression', + value: function reduceUpdateExpression(node, _ref71) { + var operand = _ref71.operand; + + return operand(); + } + }, { + key: 'reduceVariableDeclaration', + value: function reduceVariableDeclaration(node, _ref72) { + var declarators = _ref72.declarators; + + return this.append.apply(this, _toConsumableArray(declarators)); + } + }, { + key: 'reduceVariableDeclarationStatement', + value: function reduceVariableDeclarationStatement(node, _ref73) { + var declaration = _ref73.declaration; + + return declaration(); + } + }, { + key: 'reduceVariableDeclarator', + value: function reduceVariableDeclarator(node, _ref74) { + var _this17 = this; + + var binding = _ref74.binding, + init = _ref74.init; + + return this.append(binding, init == null ? function () { + return _this17.identity; + } : init); + } + }, { + key: 'reduceWhileStatement', + value: function reduceWhileStatement(node, _ref75) { + var test = _ref75.test, + body = _ref75.body; + + return this.append(test, body); + } + }, { + key: 'reduceWithStatement', + value: function reduceWithStatement(node, _ref76) { + var object = _ref76.object, + body = _ref76.body; + + return this.append(object, body); + } + }, { + key: 'reduceYieldExpression', + value: function reduceYieldExpression(node, _ref77) { + var expression = _ref77.expression; + + return expression == null ? this.identity : expression(); + } + }, { + key: 'reduceYieldGeneratorExpression', + value: function reduceYieldGeneratorExpression(node, _ref78) { + var expression = _ref78.expression; + + return expression(); + } + }]); + + return MonoidalReducer; +}(); + +exports.default = MonoidalReducer; +}); + +var adapt = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; // Generated by generate-adapt.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +var Shift = _interopRequireWildcard(dist$2); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +exports.default = function (fn, reducer) { + var _obj; + + return _obj = { + __proto__: reducer, + + reduceArrayAssignmentTarget: function reduceArrayAssignmentTarget(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceArrayAssignmentTarget', this).call(this, node, data), node); + }, + reduceArrayBinding: function reduceArrayBinding(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceArrayBinding', this).call(this, node, data), node); + }, + reduceArrayExpression: function reduceArrayExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceArrayExpression', this).call(this, node, data), node); + }, + reduceArrowExpression: function reduceArrowExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceArrowExpression', this).call(this, node, data), node); + }, + reduceAssignmentExpression: function reduceAssignmentExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceAssignmentExpression', this).call(this, node, data), node); + }, + reduceAssignmentTargetIdentifier: function reduceAssignmentTargetIdentifier(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceAssignmentTargetIdentifier', this).call(this, node, data), node); + }, + reduceAssignmentTargetPropertyIdentifier: function reduceAssignmentTargetPropertyIdentifier(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceAssignmentTargetPropertyIdentifier', this).call(this, node, data), node); + }, + reduceAssignmentTargetPropertyProperty: function reduceAssignmentTargetPropertyProperty(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceAssignmentTargetPropertyProperty', this).call(this, node, data), node); + }, + reduceAssignmentTargetWithDefault: function reduceAssignmentTargetWithDefault(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceAssignmentTargetWithDefault', this).call(this, node, data), node); + }, + reduceAwaitExpression: function reduceAwaitExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceAwaitExpression', this).call(this, node, data), node); + }, + reduceBinaryExpression: function reduceBinaryExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceBinaryExpression', this).call(this, node, data), node); + }, + reduceBindingIdentifier: function reduceBindingIdentifier(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceBindingIdentifier', this).call(this, node, data), node); + }, + reduceBindingPropertyIdentifier: function reduceBindingPropertyIdentifier(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceBindingPropertyIdentifier', this).call(this, node, data), node); + }, + reduceBindingPropertyProperty: function reduceBindingPropertyProperty(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceBindingPropertyProperty', this).call(this, node, data), node); + }, + reduceBindingWithDefault: function reduceBindingWithDefault(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceBindingWithDefault', this).call(this, node, data), node); + }, + reduceBlock: function reduceBlock(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceBlock', this).call(this, node, data), node); + }, + reduceBlockStatement: function reduceBlockStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceBlockStatement', this).call(this, node, data), node); + }, + reduceBreakStatement: function reduceBreakStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceBreakStatement', this).call(this, node, data), node); + }, + reduceCallExpression: function reduceCallExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceCallExpression', this).call(this, node, data), node); + }, + reduceCatchClause: function reduceCatchClause(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceCatchClause', this).call(this, node, data), node); + }, + reduceClassDeclaration: function reduceClassDeclaration(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceClassDeclaration', this).call(this, node, data), node); + }, + reduceClassElement: function reduceClassElement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceClassElement', this).call(this, node, data), node); + }, + reduceClassExpression: function reduceClassExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceClassExpression', this).call(this, node, data), node); + }, + reduceCompoundAssignmentExpression: function reduceCompoundAssignmentExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceCompoundAssignmentExpression', this).call(this, node, data), node); + }, + reduceComputedMemberAssignmentTarget: function reduceComputedMemberAssignmentTarget(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceComputedMemberAssignmentTarget', this).call(this, node, data), node); + }, + reduceComputedMemberExpression: function reduceComputedMemberExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceComputedMemberExpression', this).call(this, node, data), node); + }, + reduceComputedPropertyName: function reduceComputedPropertyName(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceComputedPropertyName', this).call(this, node, data), node); + }, + reduceConditionalExpression: function reduceConditionalExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceConditionalExpression', this).call(this, node, data), node); + }, + reduceContinueStatement: function reduceContinueStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceContinueStatement', this).call(this, node, data), node); + }, + reduceDataProperty: function reduceDataProperty(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceDataProperty', this).call(this, node, data), node); + }, + reduceDebuggerStatement: function reduceDebuggerStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceDebuggerStatement', this).call(this, node, data), node); + }, + reduceDirective: function reduceDirective(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceDirective', this).call(this, node, data), node); + }, + reduceDoWhileStatement: function reduceDoWhileStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceDoWhileStatement', this).call(this, node, data), node); + }, + reduceEmptyStatement: function reduceEmptyStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceEmptyStatement', this).call(this, node, data), node); + }, + reduceExport: function reduceExport(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceExport', this).call(this, node, data), node); + }, + reduceExportAllFrom: function reduceExportAllFrom(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceExportAllFrom', this).call(this, node, data), node); + }, + reduceExportDefault: function reduceExportDefault(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceExportDefault', this).call(this, node, data), node); + }, + reduceExportFrom: function reduceExportFrom(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceExportFrom', this).call(this, node, data), node); + }, + reduceExportFromSpecifier: function reduceExportFromSpecifier(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceExportFromSpecifier', this).call(this, node, data), node); + }, + reduceExportLocalSpecifier: function reduceExportLocalSpecifier(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceExportLocalSpecifier', this).call(this, node, data), node); + }, + reduceExportLocals: function reduceExportLocals(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceExportLocals', this).call(this, node, data), node); + }, + reduceExpressionStatement: function reduceExpressionStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceExpressionStatement', this).call(this, node, data), node); + }, + reduceForAwaitStatement: function reduceForAwaitStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceForAwaitStatement', this).call(this, node, data), node); + }, + reduceForInStatement: function reduceForInStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceForInStatement', this).call(this, node, data), node); + }, + reduceForOfStatement: function reduceForOfStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceForOfStatement', this).call(this, node, data), node); + }, + reduceForStatement: function reduceForStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceForStatement', this).call(this, node, data), node); + }, + reduceFormalParameters: function reduceFormalParameters(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceFormalParameters', this).call(this, node, data), node); + }, + reduceFunctionBody: function reduceFunctionBody(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceFunctionBody', this).call(this, node, data), node); + }, + reduceFunctionDeclaration: function reduceFunctionDeclaration(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceFunctionDeclaration', this).call(this, node, data), node); + }, + reduceFunctionExpression: function reduceFunctionExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceFunctionExpression', this).call(this, node, data), node); + }, + reduceGetter: function reduceGetter(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceGetter', this).call(this, node, data), node); + }, + reduceIdentifierExpression: function reduceIdentifierExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceIdentifierExpression', this).call(this, node, data), node); + }, + reduceIfStatement: function reduceIfStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceIfStatement', this).call(this, node, data), node); + }, + reduceImport: function reduceImport(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceImport', this).call(this, node, data), node); + }, + reduceImportNamespace: function reduceImportNamespace(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceImportNamespace', this).call(this, node, data), node); + }, + reduceImportSpecifier: function reduceImportSpecifier(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceImportSpecifier', this).call(this, node, data), node); + }, + reduceLabeledStatement: function reduceLabeledStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceLabeledStatement', this).call(this, node, data), node); + }, + reduceLiteralBooleanExpression: function reduceLiteralBooleanExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceLiteralBooleanExpression', this).call(this, node, data), node); + }, + reduceLiteralInfinityExpression: function reduceLiteralInfinityExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceLiteralInfinityExpression', this).call(this, node, data), node); + }, + reduceLiteralNullExpression: function reduceLiteralNullExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceLiteralNullExpression', this).call(this, node, data), node); + }, + reduceLiteralNumericExpression: function reduceLiteralNumericExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceLiteralNumericExpression', this).call(this, node, data), node); + }, + reduceLiteralRegExpExpression: function reduceLiteralRegExpExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceLiteralRegExpExpression', this).call(this, node, data), node); + }, + reduceLiteralStringExpression: function reduceLiteralStringExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceLiteralStringExpression', this).call(this, node, data), node); + }, + reduceMethod: function reduceMethod(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceMethod', this).call(this, node, data), node); + }, + reduceModule: function reduceModule(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceModule', this).call(this, node, data), node); + }, + reduceNewExpression: function reduceNewExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceNewExpression', this).call(this, node, data), node); + }, + reduceNewTargetExpression: function reduceNewTargetExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceNewTargetExpression', this).call(this, node, data), node); + }, + reduceObjectAssignmentTarget: function reduceObjectAssignmentTarget(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceObjectAssignmentTarget', this).call(this, node, data), node); + }, + reduceObjectBinding: function reduceObjectBinding(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceObjectBinding', this).call(this, node, data), node); + }, + reduceObjectExpression: function reduceObjectExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceObjectExpression', this).call(this, node, data), node); + }, + reduceReturnStatement: function reduceReturnStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceReturnStatement', this).call(this, node, data), node); + }, + reduceScript: function reduceScript(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceScript', this).call(this, node, data), node); + }, + reduceSetter: function reduceSetter(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceSetter', this).call(this, node, data), node); + }, + reduceShorthandProperty: function reduceShorthandProperty(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceShorthandProperty', this).call(this, node, data), node); + }, + reduceSpreadElement: function reduceSpreadElement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceSpreadElement', this).call(this, node, data), node); + }, + reduceSpreadProperty: function reduceSpreadProperty(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceSpreadProperty', this).call(this, node, data), node); + }, + reduceStaticMemberAssignmentTarget: function reduceStaticMemberAssignmentTarget(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceStaticMemberAssignmentTarget', this).call(this, node, data), node); + }, + reduceStaticMemberExpression: function reduceStaticMemberExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceStaticMemberExpression', this).call(this, node, data), node); + }, + reduceStaticPropertyName: function reduceStaticPropertyName(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceStaticPropertyName', this).call(this, node, data), node); + }, + reduceSuper: function reduceSuper(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceSuper', this).call(this, node, data), node); + }, + reduceSwitchCase: function reduceSwitchCase(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceSwitchCase', this).call(this, node, data), node); + }, + reduceSwitchDefault: function reduceSwitchDefault(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceSwitchDefault', this).call(this, node, data), node); + }, + reduceSwitchStatement: function reduceSwitchStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceSwitchStatement', this).call(this, node, data), node); + }, + reduceSwitchStatementWithDefault: function reduceSwitchStatementWithDefault(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceSwitchStatementWithDefault', this).call(this, node, data), node); + }, + reduceTemplateElement: function reduceTemplateElement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceTemplateElement', this).call(this, node, data), node); + }, + reduceTemplateExpression: function reduceTemplateExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceTemplateExpression', this).call(this, node, data), node); + }, + reduceThisExpression: function reduceThisExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceThisExpression', this).call(this, node, data), node); + }, + reduceThrowStatement: function reduceThrowStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceThrowStatement', this).call(this, node, data), node); + }, + reduceTryCatchStatement: function reduceTryCatchStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceTryCatchStatement', this).call(this, node, data), node); + }, + reduceTryFinallyStatement: function reduceTryFinallyStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceTryFinallyStatement', this).call(this, node, data), node); + }, + reduceUnaryExpression: function reduceUnaryExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceUnaryExpression', this).call(this, node, data), node); + }, + reduceUpdateExpression: function reduceUpdateExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceUpdateExpression', this).call(this, node, data), node); + }, + reduceVariableDeclaration: function reduceVariableDeclaration(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceVariableDeclaration', this).call(this, node, data), node); + }, + reduceVariableDeclarationStatement: function reduceVariableDeclarationStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceVariableDeclarationStatement', this).call(this, node, data), node); + }, + reduceVariableDeclarator: function reduceVariableDeclarator(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceVariableDeclarator', this).call(this, node, data), node); + }, + reduceWhileStatement: function reduceWhileStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceWhileStatement', this).call(this, node, data), node); + }, + reduceWithStatement: function reduceWithStatement(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceWithStatement', this).call(this, node, data), node); + }, + reduceYieldExpression: function reduceYieldExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceYieldExpression', this).call(this, node, data), node); + }, + reduceYieldGeneratorExpression: function reduceYieldGeneratorExpression(node, data) { + return fn(_get(_obj.__proto__ || Object.getPrototypeOf(_obj), 'reduceYieldGeneratorExpression', this).call(this, node, data), node); + } + }; +}; +}); + +var reducers = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.ThunkedOrReducer = exports.OrReducer = exports.ThunkedAndReducer = exports.AndReducer = exports.ThunkedConcatReducer = exports.ConcatReducer = exports.ThunkedPlusReducer = exports.PlusReducer = undefined; + + + +var _monoidalReducer2 = _interopRequireDefault(monoidalReducer); + + + +var _thunkedMonoidalReducer2 = _interopRequireDefault(thunkedMonoidalReducer); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var PlusMonoid = { + empty: function empty() { + return 0; + }, + concat: function concat(a, b) { + return a + b; + } +}; + +var ConcatMonoid = { + empty: function empty() { + return []; + }, + concat: function concat(a, b) { + return a.concat(b); + } +}; + +var AndMonoid = { + empty: function empty() { + return true; + }, + concat: function concat(a, b) { + return a && b; + }, + concatThunk: function concatThunk(a, b) { + return a && b(); + } +}; + +var OrMonoid = { + empty: function empty() { + return false; + }, + concat: function concat(a, b) { + return a || b; + }, + concatThunk: function concatThunk(a, b) { + return a || b(); + } +}; + +var PlusReducer = exports.PlusReducer = function (_MonoidalReducer) { + _inherits(PlusReducer, _MonoidalReducer); + + function PlusReducer() { + _classCallCheck(this, PlusReducer); + + return _possibleConstructorReturn(this, (PlusReducer.__proto__ || Object.getPrototypeOf(PlusReducer)).call(this, PlusMonoid)); + } + + return PlusReducer; +}(_monoidalReducer2.default); + +var ThunkedPlusReducer = exports.ThunkedPlusReducer = function (_ThunkedMonoidalReduc) { + _inherits(ThunkedPlusReducer, _ThunkedMonoidalReduc); + + function ThunkedPlusReducer() { + _classCallCheck(this, ThunkedPlusReducer); + + return _possibleConstructorReturn(this, (ThunkedPlusReducer.__proto__ || Object.getPrototypeOf(ThunkedPlusReducer)).call(this, PlusMonoid)); + } + + return ThunkedPlusReducer; +}(_thunkedMonoidalReducer2.default); + +var ConcatReducer = exports.ConcatReducer = function (_MonoidalReducer2) { + _inherits(ConcatReducer, _MonoidalReducer2); + + function ConcatReducer() { + _classCallCheck(this, ConcatReducer); + + return _possibleConstructorReturn(this, (ConcatReducer.__proto__ || Object.getPrototypeOf(ConcatReducer)).call(this, ConcatMonoid)); + } + + return ConcatReducer; +}(_monoidalReducer2.default); + +var ThunkedConcatReducer = exports.ThunkedConcatReducer = function (_ThunkedMonoidalReduc2) { + _inherits(ThunkedConcatReducer, _ThunkedMonoidalReduc2); + + function ThunkedConcatReducer() { + _classCallCheck(this, ThunkedConcatReducer); + + return _possibleConstructorReturn(this, (ThunkedConcatReducer.__proto__ || Object.getPrototypeOf(ThunkedConcatReducer)).call(this, ConcatMonoid)); + } + + return ThunkedConcatReducer; +}(_thunkedMonoidalReducer2.default); + +var AndReducer = exports.AndReducer = function (_MonoidalReducer3) { + _inherits(AndReducer, _MonoidalReducer3); + + function AndReducer() { + _classCallCheck(this, AndReducer); + + return _possibleConstructorReturn(this, (AndReducer.__proto__ || Object.getPrototypeOf(AndReducer)).call(this, AndMonoid)); + } + + return AndReducer; +}(_monoidalReducer2.default); + +var ThunkedAndReducer = exports.ThunkedAndReducer = function (_ThunkedMonoidalReduc3) { + _inherits(ThunkedAndReducer, _ThunkedMonoidalReduc3); + + function ThunkedAndReducer() { + _classCallCheck(this, ThunkedAndReducer); + + return _possibleConstructorReturn(this, (ThunkedAndReducer.__proto__ || Object.getPrototypeOf(ThunkedAndReducer)).call(this, AndMonoid)); + } + + return ThunkedAndReducer; +}(_thunkedMonoidalReducer2.default); + +var OrReducer = exports.OrReducer = function (_MonoidalReducer4) { + _inherits(OrReducer, _MonoidalReducer4); + + function OrReducer() { + _classCallCheck(this, OrReducer); + + return _possibleConstructorReturn(this, (OrReducer.__proto__ || Object.getPrototypeOf(OrReducer)).call(this, OrMonoid)); + } + + return OrReducer; +}(_monoidalReducer2.default); + +var ThunkedOrReducer = exports.ThunkedOrReducer = function (_ThunkedMonoidalReduc4) { + _inherits(ThunkedOrReducer, _ThunkedMonoidalReduc4); + + function ThunkedOrReducer() { + _classCallCheck(this, ThunkedOrReducer); + + return _possibleConstructorReturn(this, (ThunkedOrReducer.__proto__ || Object.getPrototypeOf(ThunkedOrReducer)).call(this, OrMonoid)); + } + + return ThunkedOrReducer; +}(_thunkedMonoidalReducer2.default); +}); + +var dist = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); + + + +Object.defineProperty(exports, 'reduce', { + enumerable: true, + get: function get() { + return director_1.reduce; + } +}); +Object.defineProperty(exports, 'default', { + enumerable: true, + get: function get() { + return director_1.reduce; + } +}); + + + +Object.defineProperty(exports, 'thunkedReduce', { + enumerable: true, + get: function get() { + return thunkedDirector.thunkedReduce; + } +}); + + + +Object.defineProperty(exports, 'thunkify', { + enumerable: true, + get: function get() { + return _interopRequireDefault(thunkify_1).default; + } +}); + + + +Object.defineProperty(exports, 'thunkifyClass', { + enumerable: true, + get: function get() { + return _interopRequireDefault(thunkifyClass_1).default; + } +}); + + + +Object.defineProperty(exports, 'memoize', { + enumerable: true, + get: function get() { + return _interopRequireDefault(memoize_1).default; + } +}); + + + +Object.defineProperty(exports, 'CloneReducer', { + enumerable: true, + get: function get() { + return _interopRequireDefault(cloneReducer).default; + } +}); + + + +Object.defineProperty(exports, 'LazyCloneReducer', { + enumerable: true, + get: function get() { + return _interopRequireDefault(lazyCloneReducer).default; + } +}); + + + +Object.defineProperty(exports, 'MonoidalReducer', { + enumerable: true, + get: function get() { + return _interopRequireDefault(monoidalReducer).default; + } +}); + + + +Object.defineProperty(exports, 'ThunkedMonoidalReducer', { + enumerable: true, + get: function get() { + return _interopRequireDefault(thunkedMonoidalReducer).default; + } +}); + + + +Object.defineProperty(exports, 'adapt', { + enumerable: true, + get: function get() { + return _interopRequireDefault(adapt).default; + } +}); + + + +Object.defineProperty(exports, 'PlusReducer', { + enumerable: true, + get: function get() { + return reducers.PlusReducer; + } +}); +Object.defineProperty(exports, 'ThunkedPlusReducer', { + enumerable: true, + get: function get() { + return reducers.ThunkedPlusReducer; + } +}); +Object.defineProperty(exports, 'ConcatReducer', { + enumerable: true, + get: function get() { + return reducers.ConcatReducer; + } +}); +Object.defineProperty(exports, 'ThunkedConcatReducer', { + enumerable: true, + get: function get() { + return reducers.ThunkedConcatReducer; + } +}); +Object.defineProperty(exports, 'AndReducer', { + enumerable: true, + get: function get() { + return reducers.AndReducer; + } +}); +Object.defineProperty(exports, 'ThunkedAndReducer', { + enumerable: true, + get: function get() { + return reducers.ThunkedAndReducer; + } +}); +Object.defineProperty(exports, 'OrReducer', { + enumerable: true, + get: function get() { + return reducers.OrReducer; + } +}); +Object.defineProperty(exports, 'ThunkedOrReducer', { + enumerable: true, + get: function get() { + return reducers.ThunkedOrReducer; + } +}); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +}); + +var unicode = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); +// Generated by scripts/generate-unicode-data.js + +var whitespaceArray = exports.whitespaceArray = [5760, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8202, 8239, 8287, 12288, 65279]; +var whitespaceBool = exports.whitespaceBool = [false, false, false, false, false, false, false, false, false, true, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]; + +var idStartLargeRegex = exports.idStartLargeRegex = /^[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]$/; +var idStartBool = exports.idStartBool = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false]; + +var idContinueLargeRegex = exports.idContinueLargeRegex = /^[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]$/; +var idContinueBool = exports.idContinueBool = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false]; +}); + +var tokenStream = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.TokenStream = undefined; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** + * Copyright 2014 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +exports.needsDoubleDot = needsDoubleDot; + + + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function isIdentifierPartES6(char) { + var charCode = char.charCodeAt(0); + if (charCode < 128) { + return unicode.idContinueBool[charCode]; + } + return unicode.idContinueLargeRegex.test(char); +} + +function needsDoubleDot(fragment) { + return fragment.indexOf('.') < 0 && fragment.indexOf('e') < 0 && fragment.indexOf('x') < 0; +} + +function renderNumber(n) { + var s = void 0; + if (n >= 1e3 && n % 10 === 0) { + s = n.toString(10); + if (/[eE]/.test(s)) { + return s.replace(/[eE]\+/, 'e'); + } + return n.toString(10).replace(/0{3,}$/, function (match) { + return 'e' + match.length; + }); + } else if (n % 1 === 0) { + if (n > 1e15 && n < 1e20) { + return '0x' + n.toString(16).toUpperCase(); + } + return n.toString(10).replace(/[eE]\+/, 'e'); + } + return n.toString(10).replace(/^0\./, '.').replace(/[eE]\+/, 'e'); +} + +var TokenStream = exports.TokenStream = function () { + function TokenStream() { + _classCallCheck(this, TokenStream); + + this.result = ''; + this.lastNumber = null; + this.lastCodePoint = null; + this.lastTokenStr = ''; + this.optionalSemi = false; + this.previousWasRegExp = false; + this.partialHtmlComment = false; + } + + _createClass(TokenStream, [{ + key: 'putNumber', + value: function putNumber(number) { + var tokenStr = renderNumber(number); + this.put(tokenStr); + this.lastNumber = tokenStr; + } + }, { + key: 'putOptionalSemi', + value: function putOptionalSemi() { + this.optionalSemi = true; + } + }, { + key: 'putRaw', + value: function putRaw(tokenStr) { + this.result += tokenStr; + this.lastTokenStr = tokenStr; + } + }, { + key: 'put', + value: function put(tokenStr, isRegExp) { + if (this.optionalSemi) { + this.optionalSemi = false; + if (tokenStr !== '}') { + this.result += ';'; + this.lastCodePoint = ';'; + this.previousWasRegExp = false; + } + } + if (this.lastNumber !== null && tokenStr.length === 1) { + if (tokenStr === '.') { + this.result += needsDoubleDot(this.lastNumber) ? '..' : '.'; + this.lastNumber = null; + this.lastCodePoint = '.'; + return; + } + } + var tokenStrCodePointCount = [].concat(_toConsumableArray(tokenStr)).length; // slow, no unicode length? + if (tokenStrCodePointCount > 0) { + this.lastNumber = null; + var rightCodePoint = String.fromCodePoint(tokenStr.codePointAt(0)); + var lastCodePoint = this.lastCodePoint; + this.lastCodePoint = String.fromCodePoint(tokenStr.codePointAt(tokenStrCodePointCount - 1)); + var previousWasRegExp = this.previousWasRegExp; + this.previousWasRegExp = isRegExp; + + if (lastCodePoint && ((lastCodePoint === '+' || lastCodePoint === '-') && lastCodePoint === rightCodePoint || isIdentifierPartES6(lastCodePoint) && isIdentifierPartES6(rightCodePoint) || lastCodePoint === '/' && rightCodePoint === '/' || previousWasRegExp && rightCodePoint === 'i' || this.partialHtmlComment && tokenStr.startsWith('--'))) { + this.result += ' '; + } + } + + this.partialHtmlComment = this.lastTokenStr.endsWith('<') && tokenStr === '!'; + + this.result += tokenStr; + this.lastTokenStr = tokenStr; + } + }]); + + return TokenStream; +}(); +}); + +var withLocation = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + +exports.default = codeGenWithLocation; + + + + + + + +var _minimalCodegen2 = _interopRequireDefault(minimalCodegen); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +function mightHaveSemi(type) { + return (/(Import)|(Export)|(Statement)|(Directive)|(SwitchCase)|(SwitchDefault)/.test(type) + ); +} + +var TokenStreamWithLocation = function (_TokenStream) { + _inherits(TokenStreamWithLocation, _TokenStream); + + function TokenStreamWithLocation() { + _classCallCheck(this, TokenStreamWithLocation); + + var _this = _possibleConstructorReturn(this, (TokenStreamWithLocation.__proto__ || Object.getPrototypeOf(TokenStreamWithLocation)).call(this)); + + _this.line = 1; + _this.column = 0; + _this.startingNodes = []; + _this.finishingStatements = []; + _this.lastNumberNode = null; + _this.locations = new WeakMap(); + return _this; + } + + _createClass(TokenStreamWithLocation, [{ + key: 'putRaw', + value: function putRaw(tokenStr) { + var previousLength = this.result.length; + _get(TokenStreamWithLocation.prototype.__proto__ || Object.getPrototypeOf(TokenStreamWithLocation.prototype), 'putRaw', this).call(this, tokenStr); + this.startNodes(tokenStr, previousLength); + } + }, { + key: 'put', + value: function put(tokenStr, isRegExp) { + if (this.optionalSemi && tokenStr !== '}') { + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = this.finishingStatements[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var obj = _step.value; + + ++obj.end.column; + ++obj.end.offset; + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + } + this.finishingStatements = []; + + if (this.lastNumber !== null && tokenStr === '.' && (0, tokenStream.needsDoubleDot)(this.lastNumber)) { + var loc = this.locations.get(this.lastNumberNode).end; + ++loc.column; + ++loc.offset; + } + this.lastNumberNode = null; + + var previousLength = this.result.length; + _get(TokenStreamWithLocation.prototype.__proto__ || Object.getPrototypeOf(TokenStreamWithLocation.prototype), 'put', this).call(this, tokenStr, isRegExp); + this.startNodes(tokenStr, previousLength); + } + }, { + key: 'startNodes', + value: function startNodes(tokenStr, previousLength) { + var linebreakRegex = /\r\n?|[\n\u2028\u2029]/g; + var matched = false; + var match = void 0; + var startLine = this.line; + var startColumn = this.column; + while (match = linebreakRegex.exec(tokenStr)) { + ++this.line; + this.column = tokenStr.length - match.index - match[0].length; + matched = true; + } + + if (!matched) { + this.column += this.result.length - previousLength; + startColumn = this.column - tokenStr.length; // i.e., skip past any additional characters which were necessitated by, but not part of, this part + } + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = this.startingNodes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var node = _step2.value; + + this.locations.set(node, { + start: { + line: startLine, + column: startColumn, + offset: this.result.length - tokenStr.length + }, + end: null + }); + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } + + this.startingNodes = []; + } + }, { + key: 'startEmit', + value: function startEmit(node) { + this.startingNodes.push(node); + } + }, { + key: 'finishEmit', + value: function finishEmit(node) { + this.locations.get(node).end = { + line: this.line, + column: this.column, + offset: this.result.length + }; + if (mightHaveSemi(node.type)) { + this.finishingStatements.push(this.locations.get(node)); + } + } + }]); + + return TokenStreamWithLocation; +}(tokenStream.TokenStream); + +function addLocation(rep, node) { + var originalEmit = rep.emit.bind(rep); + if (node.type === 'Script' || node.type === 'Module') { + // These are handled specially: they include beginning and trailing whitespace. + rep.emit = function (ts) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + ts.locations.set(node, { + start: { + line: 1, + column: 0, + offset: 0 + }, + end: null + }); + originalEmit.apply(undefined, [ts].concat(args)); + ts.locations.get(node).end = { + line: ts.line, + column: ts.column, + offset: ts.result.length + }; + }; + } else if (node.type === 'LiteralNumericExpression') { + rep.emit = function (ts) { + for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; + } + + ts.startEmit(node); + originalEmit.apply(undefined, [ts].concat(args)); + ts.finishEmit(node); + ts.lastNumberNode = node; + }; + } else { + rep.emit = function (ts) { + for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { + args[_key3 - 1] = arguments[_key3]; + } + + ts.startEmit(node); + originalEmit.apply(undefined, [ts].concat(args)); + ts.finishEmit(node); + }; + } + return rep; +} + +function addLocationToReducer(reducer) { + var wrapped = (0, dist.adapt)(addLocation, reducer); + + var originalRegenerate = wrapped.regenerateArrowParams.bind(wrapped); + wrapped.regenerateArrowParams = function (element, original) { + var out = originalRegenerate(element, original); + if (out !== original) { + addLocation(out, element); + } + return out; + }; + + var originalDirective = wrapped.parenToAvoidBeingDirective.bind(wrapped); + wrapped.parenToAvoidBeingDirective = function (element, original) { + var out = originalDirective(element, original); + if (out !== original) { + addLocation(out, element); + } + return out; + }; + + return wrapped; +} + +function codeGenWithLocation(program) { + var generator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new _minimalCodegen2.default(); + + var ts = new TokenStreamWithLocation(); + var rep = (0, dist.reduce)(addLocationToReducer(generator), program); + rep.emit(ts); + return { source: ts.result, locations: ts.locations }; +} +}); + +var dist$1 = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.codeGenWithLocation = exports.SemiOp = exports.CommaSep = exports.Semi = exports.Seq = exports.ContainsIn = exports.NoIn = exports.Brace = exports.Bracket = exports.Paren = exports.NumberCodeRep = exports.Token = exports.Empty = exports.CodeRep = exports.escapeStringLiteral = exports.getPrecedence = exports.Precedence = exports.Sep = exports.FormattedCodeGen = exports.ExtensibleCodeGen = exports.MinimalCodeGen = undefined; +exports.default = codeGen; + + + +Object.defineProperty(exports, 'MinimalCodeGen', { + enumerable: true, + get: function get() { + return _interopRequireDefault(minimalCodegen).default; + } +}); + + + +Object.defineProperty(exports, 'ExtensibleCodeGen', { + enumerable: true, + get: function get() { + return formattedCodegen.ExtensibleCodeGen; + } +}); +Object.defineProperty(exports, 'FormattedCodeGen', { + enumerable: true, + get: function get() { + return formattedCodegen.FormattedCodeGen; + } +}); +Object.defineProperty(exports, 'Sep', { + enumerable: true, + get: function get() { + return formattedCodegen.Sep; + } +}); + + + +Object.defineProperty(exports, 'Precedence', { + enumerable: true, + get: function get() { + return coderep.Precedence; + } +}); +Object.defineProperty(exports, 'getPrecedence', { + enumerable: true, + get: function get() { + return coderep.getPrecedence; + } +}); +Object.defineProperty(exports, 'escapeStringLiteral', { + enumerable: true, + get: function get() { + return coderep.escapeStringLiteral; + } +}); +Object.defineProperty(exports, 'CodeRep', { + enumerable: true, + get: function get() { + return coderep.CodeRep; + } +}); +Object.defineProperty(exports, 'Empty', { + enumerable: true, + get: function get() { + return coderep.Empty; + } +}); +Object.defineProperty(exports, 'Token', { + enumerable: true, + get: function get() { + return coderep.Token; + } +}); +Object.defineProperty(exports, 'NumberCodeRep', { + enumerable: true, + get: function get() { + return coderep.NumberCodeRep; + } +}); +Object.defineProperty(exports, 'Paren', { + enumerable: true, + get: function get() { + return coderep.Paren; + } +}); +Object.defineProperty(exports, 'Bracket', { + enumerable: true, + get: function get() { + return coderep.Bracket; + } +}); +Object.defineProperty(exports, 'Brace', { + enumerable: true, + get: function get() { + return coderep.Brace; + } +}); +Object.defineProperty(exports, 'NoIn', { + enumerable: true, + get: function get() { + return coderep.NoIn; + } +}); +Object.defineProperty(exports, 'ContainsIn', { + enumerable: true, + get: function get() { + return coderep.ContainsIn; + } +}); +Object.defineProperty(exports, 'Seq', { + enumerable: true, + get: function get() { + return coderep.Seq; + } +}); +Object.defineProperty(exports, 'Semi', { + enumerable: true, + get: function get() { + return coderep.Semi; + } +}); +Object.defineProperty(exports, 'CommaSep', { + enumerable: true, + get: function get() { + return coderep.CommaSep; + } +}); +Object.defineProperty(exports, 'SemiOp', { + enumerable: true, + get: function get() { + return coderep.SemiOp; + } +}); + + + +Object.defineProperty(exports, 'codeGenWithLocation', { + enumerable: true, + get: function get() { + return _interopRequireDefault(withLocation).default; + } +}); + + + +var _shiftReducer2 = _interopRequireDefault(dist); + + + +var _minimalCodegen2 = _interopRequireDefault(minimalCodegen); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function codeGen(script) { + var generator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new _minimalCodegen2.default(); + + var ts = new tokenStream.TokenStream(); + var rep = (0, _shiftReducer2.default)(generator, script); + rep.emit(ts); + return ts.result; +} +}); + +var __pika_web_default_export_for_treeshaking__ = /*@__PURE__*/getDefaultExportFromCjs(dist$1); + +export default __pika_web_default_export_for_treeshaking__; diff --git a/docs/_snowpack/pkg/shift-regexp-acceptor.js b/docs/_snowpack/pkg/shift-regexp-acceptor.js new file mode 100644 index 00000000..a7c9d7b4 --- /dev/null +++ b/docs/_snowpack/pkg/shift-regexp-acceptor.js @@ -0,0 +1,1771 @@ +import { c as createCommonjsModule, g as getDefaultExportFromCjs } from './common/_commonjsHelpers-8c19dec8.js'; + +var mappings = new Map([ + ['General_Category', new Map([ + ['C', 'Other'], + ['Cc', 'Control'], + ['cntrl', 'Control'], + ['Cf', 'Format'], + ['Cn', 'Unassigned'], + ['Co', 'Private_Use'], + ['Cs', 'Surrogate'], + ['L', 'Letter'], + ['LC', 'Cased_Letter'], + ['Ll', 'Lowercase_Letter'], + ['Lm', 'Modifier_Letter'], + ['Lo', 'Other_Letter'], + ['Lt', 'Titlecase_Letter'], + ['Lu', 'Uppercase_Letter'], + ['M', 'Mark'], + ['Combining_Mark', 'Mark'], + ['Mc', 'Spacing_Mark'], + ['Me', 'Enclosing_Mark'], + ['Mn', 'Nonspacing_Mark'], + ['N', 'Number'], + ['Nd', 'Decimal_Number'], + ['digit', 'Decimal_Number'], + ['Nl', 'Letter_Number'], + ['No', 'Other_Number'], + ['P', 'Punctuation'], + ['punct', 'Punctuation'], + ['Pc', 'Connector_Punctuation'], + ['Pd', 'Dash_Punctuation'], + ['Pe', 'Close_Punctuation'], + ['Pf', 'Final_Punctuation'], + ['Pi', 'Initial_Punctuation'], + ['Po', 'Other_Punctuation'], + ['Ps', 'Open_Punctuation'], + ['S', 'Symbol'], + ['Sc', 'Currency_Symbol'], + ['Sk', 'Modifier_Symbol'], + ['Sm', 'Math_Symbol'], + ['So', 'Other_Symbol'], + ['Z', 'Separator'], + ['Zl', 'Line_Separator'], + ['Zp', 'Paragraph_Separator'], + ['Zs', 'Space_Separator'], + ['Other', 'Other'], + ['Control', 'Control'], + ['Format', 'Format'], + ['Unassigned', 'Unassigned'], + ['Private_Use', 'Private_Use'], + ['Surrogate', 'Surrogate'], + ['Letter', 'Letter'], + ['Cased_Letter', 'Cased_Letter'], + ['Lowercase_Letter', 'Lowercase_Letter'], + ['Modifier_Letter', 'Modifier_Letter'], + ['Other_Letter', 'Other_Letter'], + ['Titlecase_Letter', 'Titlecase_Letter'], + ['Uppercase_Letter', 'Uppercase_Letter'], + ['Mark', 'Mark'], + ['Spacing_Mark', 'Spacing_Mark'], + ['Enclosing_Mark', 'Enclosing_Mark'], + ['Nonspacing_Mark', 'Nonspacing_Mark'], + ['Number', 'Number'], + ['Decimal_Number', 'Decimal_Number'], + ['Letter_Number', 'Letter_Number'], + ['Other_Number', 'Other_Number'], + ['Punctuation', 'Punctuation'], + ['Connector_Punctuation', 'Connector_Punctuation'], + ['Dash_Punctuation', 'Dash_Punctuation'], + ['Close_Punctuation', 'Close_Punctuation'], + ['Final_Punctuation', 'Final_Punctuation'], + ['Initial_Punctuation', 'Initial_Punctuation'], + ['Other_Punctuation', 'Other_Punctuation'], + ['Open_Punctuation', 'Open_Punctuation'], + ['Symbol', 'Symbol'], + ['Currency_Symbol', 'Currency_Symbol'], + ['Modifier_Symbol', 'Modifier_Symbol'], + ['Math_Symbol', 'Math_Symbol'], + ['Other_Symbol', 'Other_Symbol'], + ['Separator', 'Separator'], + ['Line_Separator', 'Line_Separator'], + ['Paragraph_Separator', 'Paragraph_Separator'], + ['Space_Separator', 'Space_Separator'] + ])], + ['Script', new Map([ + ['Adlm', 'Adlam'], + ['Aghb', 'Caucasian_Albanian'], + ['Ahom', 'Ahom'], + ['Arab', 'Arabic'], + ['Armi', 'Imperial_Aramaic'], + ['Armn', 'Armenian'], + ['Avst', 'Avestan'], + ['Bali', 'Balinese'], + ['Bamu', 'Bamum'], + ['Bass', 'Bassa_Vah'], + ['Batk', 'Batak'], + ['Beng', 'Bengali'], + ['Bhks', 'Bhaiksuki'], + ['Bopo', 'Bopomofo'], + ['Brah', 'Brahmi'], + ['Brai', 'Braille'], + ['Bugi', 'Buginese'], + ['Buhd', 'Buhid'], + ['Cakm', 'Chakma'], + ['Cans', 'Canadian_Aboriginal'], + ['Cari', 'Carian'], + ['Cham', 'Cham'], + ['Cher', 'Cherokee'], + ['Copt', 'Coptic'], + ['Qaac', 'Coptic'], + ['Cprt', 'Cypriot'], + ['Cyrl', 'Cyrillic'], + ['Deva', 'Devanagari'], + ['Dogr', 'Dogra'], + ['Dsrt', 'Deseret'], + ['Dupl', 'Duployan'], + ['Egyp', 'Egyptian_Hieroglyphs'], + ['Elba', 'Elbasan'], + ['Ethi', 'Ethiopic'], + ['Geor', 'Georgian'], + ['Glag', 'Glagolitic'], + ['Gong', 'Gunjala_Gondi'], + ['Gonm', 'Masaram_Gondi'], + ['Goth', 'Gothic'], + ['Gran', 'Grantha'], + ['Grek', 'Greek'], + ['Gujr', 'Gujarati'], + ['Guru', 'Gurmukhi'], + ['Hang', 'Hangul'], + ['Hani', 'Han'], + ['Hano', 'Hanunoo'], + ['Hatr', 'Hatran'], + ['Hebr', 'Hebrew'], + ['Hira', 'Hiragana'], + ['Hluw', 'Anatolian_Hieroglyphs'], + ['Hmng', 'Pahawh_Hmong'], + ['Hrkt', 'Katakana_Or_Hiragana'], + ['Hung', 'Old_Hungarian'], + ['Ital', 'Old_Italic'], + ['Java', 'Javanese'], + ['Kali', 'Kayah_Li'], + ['Kana', 'Katakana'], + ['Khar', 'Kharoshthi'], + ['Khmr', 'Khmer'], + ['Khoj', 'Khojki'], + ['Knda', 'Kannada'], + ['Kthi', 'Kaithi'], + ['Lana', 'Tai_Tham'], + ['Laoo', 'Lao'], + ['Latn', 'Latin'], + ['Lepc', 'Lepcha'], + ['Limb', 'Limbu'], + ['Lina', 'Linear_A'], + ['Linb', 'Linear_B'], + ['Lisu', 'Lisu'], + ['Lyci', 'Lycian'], + ['Lydi', 'Lydian'], + ['Mahj', 'Mahajani'], + ['Maka', 'Makasar'], + ['Mand', 'Mandaic'], + ['Mani', 'Manichaean'], + ['Marc', 'Marchen'], + ['Medf', 'Medefaidrin'], + ['Mend', 'Mende_Kikakui'], + ['Merc', 'Meroitic_Cursive'], + ['Mero', 'Meroitic_Hieroglyphs'], + ['Mlym', 'Malayalam'], + ['Modi', 'Modi'], + ['Mong', 'Mongolian'], + ['Mroo', 'Mro'], + ['Mtei', 'Meetei_Mayek'], + ['Mult', 'Multani'], + ['Mymr', 'Myanmar'], + ['Narb', 'Old_North_Arabian'], + ['Nbat', 'Nabataean'], + ['Newa', 'Newa'], + ['Nkoo', 'Nko'], + ['Nshu', 'Nushu'], + ['Ogam', 'Ogham'], + ['Olck', 'Ol_Chiki'], + ['Orkh', 'Old_Turkic'], + ['Orya', 'Oriya'], + ['Osge', 'Osage'], + ['Osma', 'Osmanya'], + ['Palm', 'Palmyrene'], + ['Pauc', 'Pau_Cin_Hau'], + ['Perm', 'Old_Permic'], + ['Phag', 'Phags_Pa'], + ['Phli', 'Inscriptional_Pahlavi'], + ['Phlp', 'Psalter_Pahlavi'], + ['Phnx', 'Phoenician'], + ['Plrd', 'Miao'], + ['Prti', 'Inscriptional_Parthian'], + ['Rjng', 'Rejang'], + ['Rohg', 'Hanifi_Rohingya'], + ['Runr', 'Runic'], + ['Samr', 'Samaritan'], + ['Sarb', 'Old_South_Arabian'], + ['Saur', 'Saurashtra'], + ['Sgnw', 'SignWriting'], + ['Shaw', 'Shavian'], + ['Shrd', 'Sharada'], + ['Sidd', 'Siddham'], + ['Sind', 'Khudawadi'], + ['Sinh', 'Sinhala'], + ['Sogd', 'Sogdian'], + ['Sogo', 'Old_Sogdian'], + ['Sora', 'Sora_Sompeng'], + ['Soyo', 'Soyombo'], + ['Sund', 'Sundanese'], + ['Sylo', 'Syloti_Nagri'], + ['Syrc', 'Syriac'], + ['Tagb', 'Tagbanwa'], + ['Takr', 'Takri'], + ['Tale', 'Tai_Le'], + ['Talu', 'New_Tai_Lue'], + ['Taml', 'Tamil'], + ['Tang', 'Tangut'], + ['Tavt', 'Tai_Viet'], + ['Telu', 'Telugu'], + ['Tfng', 'Tifinagh'], + ['Tglg', 'Tagalog'], + ['Thaa', 'Thaana'], + ['Thai', 'Thai'], + ['Tibt', 'Tibetan'], + ['Tirh', 'Tirhuta'], + ['Ugar', 'Ugaritic'], + ['Vaii', 'Vai'], + ['Wara', 'Warang_Citi'], + ['Xpeo', 'Old_Persian'], + ['Xsux', 'Cuneiform'], + ['Yiii', 'Yi'], + ['Zanb', 'Zanabazar_Square'], + ['Zinh', 'Inherited'], + ['Qaai', 'Inherited'], + ['Zyyy', 'Common'], + ['Zzzz', 'Unknown'], + ['Adlam', 'Adlam'], + ['Caucasian_Albanian', 'Caucasian_Albanian'], + ['Arabic', 'Arabic'], + ['Imperial_Aramaic', 'Imperial_Aramaic'], + ['Armenian', 'Armenian'], + ['Avestan', 'Avestan'], + ['Balinese', 'Balinese'], + ['Bamum', 'Bamum'], + ['Bassa_Vah', 'Bassa_Vah'], + ['Batak', 'Batak'], + ['Bengali', 'Bengali'], + ['Bhaiksuki', 'Bhaiksuki'], + ['Bopomofo', 'Bopomofo'], + ['Brahmi', 'Brahmi'], + ['Braille', 'Braille'], + ['Buginese', 'Buginese'], + ['Buhid', 'Buhid'], + ['Chakma', 'Chakma'], + ['Canadian_Aboriginal', 'Canadian_Aboriginal'], + ['Carian', 'Carian'], + ['Cherokee', 'Cherokee'], + ['Coptic', 'Coptic'], + ['Cypriot', 'Cypriot'], + ['Cyrillic', 'Cyrillic'], + ['Devanagari', 'Devanagari'], + ['Dogra', 'Dogra'], + ['Deseret', 'Deseret'], + ['Duployan', 'Duployan'], + ['Egyptian_Hieroglyphs', 'Egyptian_Hieroglyphs'], + ['Elbasan', 'Elbasan'], + ['Ethiopic', 'Ethiopic'], + ['Georgian', 'Georgian'], + ['Glagolitic', 'Glagolitic'], + ['Gunjala_Gondi', 'Gunjala_Gondi'], + ['Masaram_Gondi', 'Masaram_Gondi'], + ['Gothic', 'Gothic'], + ['Grantha', 'Grantha'], + ['Greek', 'Greek'], + ['Gujarati', 'Gujarati'], + ['Gurmukhi', 'Gurmukhi'], + ['Hangul', 'Hangul'], + ['Han', 'Han'], + ['Hanunoo', 'Hanunoo'], + ['Hatran', 'Hatran'], + ['Hebrew', 'Hebrew'], + ['Hiragana', 'Hiragana'], + ['Anatolian_Hieroglyphs', 'Anatolian_Hieroglyphs'], + ['Pahawh_Hmong', 'Pahawh_Hmong'], + ['Katakana_Or_Hiragana', 'Katakana_Or_Hiragana'], + ['Old_Hungarian', 'Old_Hungarian'], + ['Old_Italic', 'Old_Italic'], + ['Javanese', 'Javanese'], + ['Kayah_Li', 'Kayah_Li'], + ['Katakana', 'Katakana'], + ['Kharoshthi', 'Kharoshthi'], + ['Khmer', 'Khmer'], + ['Khojki', 'Khojki'], + ['Kannada', 'Kannada'], + ['Kaithi', 'Kaithi'], + ['Tai_Tham', 'Tai_Tham'], + ['Lao', 'Lao'], + ['Latin', 'Latin'], + ['Lepcha', 'Lepcha'], + ['Limbu', 'Limbu'], + ['Linear_A', 'Linear_A'], + ['Linear_B', 'Linear_B'], + ['Lycian', 'Lycian'], + ['Lydian', 'Lydian'], + ['Mahajani', 'Mahajani'], + ['Makasar', 'Makasar'], + ['Mandaic', 'Mandaic'], + ['Manichaean', 'Manichaean'], + ['Marchen', 'Marchen'], + ['Medefaidrin', 'Medefaidrin'], + ['Mende_Kikakui', 'Mende_Kikakui'], + ['Meroitic_Cursive', 'Meroitic_Cursive'], + ['Meroitic_Hieroglyphs', 'Meroitic_Hieroglyphs'], + ['Malayalam', 'Malayalam'], + ['Mongolian', 'Mongolian'], + ['Mro', 'Mro'], + ['Meetei_Mayek', 'Meetei_Mayek'], + ['Multani', 'Multani'], + ['Myanmar', 'Myanmar'], + ['Old_North_Arabian', 'Old_North_Arabian'], + ['Nabataean', 'Nabataean'], + ['Nko', 'Nko'], + ['Nushu', 'Nushu'], + ['Ogham', 'Ogham'], + ['Ol_Chiki', 'Ol_Chiki'], + ['Old_Turkic', 'Old_Turkic'], + ['Oriya', 'Oriya'], + ['Osage', 'Osage'], + ['Osmanya', 'Osmanya'], + ['Palmyrene', 'Palmyrene'], + ['Pau_Cin_Hau', 'Pau_Cin_Hau'], + ['Old_Permic', 'Old_Permic'], + ['Phags_Pa', 'Phags_Pa'], + ['Inscriptional_Pahlavi', 'Inscriptional_Pahlavi'], + ['Psalter_Pahlavi', 'Psalter_Pahlavi'], + ['Phoenician', 'Phoenician'], + ['Miao', 'Miao'], + ['Inscriptional_Parthian', 'Inscriptional_Parthian'], + ['Rejang', 'Rejang'], + ['Hanifi_Rohingya', 'Hanifi_Rohingya'], + ['Runic', 'Runic'], + ['Samaritan', 'Samaritan'], + ['Old_South_Arabian', 'Old_South_Arabian'], + ['Saurashtra', 'Saurashtra'], + ['SignWriting', 'SignWriting'], + ['Shavian', 'Shavian'], + ['Sharada', 'Sharada'], + ['Siddham', 'Siddham'], + ['Khudawadi', 'Khudawadi'], + ['Sinhala', 'Sinhala'], + ['Sogdian', 'Sogdian'], + ['Old_Sogdian', 'Old_Sogdian'], + ['Sora_Sompeng', 'Sora_Sompeng'], + ['Soyombo', 'Soyombo'], + ['Sundanese', 'Sundanese'], + ['Syloti_Nagri', 'Syloti_Nagri'], + ['Syriac', 'Syriac'], + ['Tagbanwa', 'Tagbanwa'], + ['Takri', 'Takri'], + ['Tai_Le', 'Tai_Le'], + ['New_Tai_Lue', 'New_Tai_Lue'], + ['Tamil', 'Tamil'], + ['Tangut', 'Tangut'], + ['Tai_Viet', 'Tai_Viet'], + ['Telugu', 'Telugu'], + ['Tifinagh', 'Tifinagh'], + ['Tagalog', 'Tagalog'], + ['Thaana', 'Thaana'], + ['Tibetan', 'Tibetan'], + ['Tirhuta', 'Tirhuta'], + ['Ugaritic', 'Ugaritic'], + ['Vai', 'Vai'], + ['Warang_Citi', 'Warang_Citi'], + ['Old_Persian', 'Old_Persian'], + ['Cuneiform', 'Cuneiform'], + ['Yi', 'Yi'], + ['Zanabazar_Square', 'Zanabazar_Square'], + ['Inherited', 'Inherited'], + ['Common', 'Common'], + ['Unknown', 'Unknown'] + ])], + ['Script_Extensions', new Map([ + ['Adlm', 'Adlam'], + ['Aghb', 'Caucasian_Albanian'], + ['Ahom', 'Ahom'], + ['Arab', 'Arabic'], + ['Armi', 'Imperial_Aramaic'], + ['Armn', 'Armenian'], + ['Avst', 'Avestan'], + ['Bali', 'Balinese'], + ['Bamu', 'Bamum'], + ['Bass', 'Bassa_Vah'], + ['Batk', 'Batak'], + ['Beng', 'Bengali'], + ['Bhks', 'Bhaiksuki'], + ['Bopo', 'Bopomofo'], + ['Brah', 'Brahmi'], + ['Brai', 'Braille'], + ['Bugi', 'Buginese'], + ['Buhd', 'Buhid'], + ['Cakm', 'Chakma'], + ['Cans', 'Canadian_Aboriginal'], + ['Cari', 'Carian'], + ['Cham', 'Cham'], + ['Cher', 'Cherokee'], + ['Copt', 'Coptic'], + ['Qaac', 'Coptic'], + ['Cprt', 'Cypriot'], + ['Cyrl', 'Cyrillic'], + ['Deva', 'Devanagari'], + ['Dogr', 'Dogra'], + ['Dsrt', 'Deseret'], + ['Dupl', 'Duployan'], + ['Egyp', 'Egyptian_Hieroglyphs'], + ['Elba', 'Elbasan'], + ['Ethi', 'Ethiopic'], + ['Geor', 'Georgian'], + ['Glag', 'Glagolitic'], + ['Gong', 'Gunjala_Gondi'], + ['Gonm', 'Masaram_Gondi'], + ['Goth', 'Gothic'], + ['Gran', 'Grantha'], + ['Grek', 'Greek'], + ['Gujr', 'Gujarati'], + ['Guru', 'Gurmukhi'], + ['Hang', 'Hangul'], + ['Hani', 'Han'], + ['Hano', 'Hanunoo'], + ['Hatr', 'Hatran'], + ['Hebr', 'Hebrew'], + ['Hira', 'Hiragana'], + ['Hluw', 'Anatolian_Hieroglyphs'], + ['Hmng', 'Pahawh_Hmong'], + ['Hrkt', 'Katakana_Or_Hiragana'], + ['Hung', 'Old_Hungarian'], + ['Ital', 'Old_Italic'], + ['Java', 'Javanese'], + ['Kali', 'Kayah_Li'], + ['Kana', 'Katakana'], + ['Khar', 'Kharoshthi'], + ['Khmr', 'Khmer'], + ['Khoj', 'Khojki'], + ['Knda', 'Kannada'], + ['Kthi', 'Kaithi'], + ['Lana', 'Tai_Tham'], + ['Laoo', 'Lao'], + ['Latn', 'Latin'], + ['Lepc', 'Lepcha'], + ['Limb', 'Limbu'], + ['Lina', 'Linear_A'], + ['Linb', 'Linear_B'], + ['Lisu', 'Lisu'], + ['Lyci', 'Lycian'], + ['Lydi', 'Lydian'], + ['Mahj', 'Mahajani'], + ['Maka', 'Makasar'], + ['Mand', 'Mandaic'], + ['Mani', 'Manichaean'], + ['Marc', 'Marchen'], + ['Medf', 'Medefaidrin'], + ['Mend', 'Mende_Kikakui'], + ['Merc', 'Meroitic_Cursive'], + ['Mero', 'Meroitic_Hieroglyphs'], + ['Mlym', 'Malayalam'], + ['Modi', 'Modi'], + ['Mong', 'Mongolian'], + ['Mroo', 'Mro'], + ['Mtei', 'Meetei_Mayek'], + ['Mult', 'Multani'], + ['Mymr', 'Myanmar'], + ['Narb', 'Old_North_Arabian'], + ['Nbat', 'Nabataean'], + ['Newa', 'Newa'], + ['Nkoo', 'Nko'], + ['Nshu', 'Nushu'], + ['Ogam', 'Ogham'], + ['Olck', 'Ol_Chiki'], + ['Orkh', 'Old_Turkic'], + ['Orya', 'Oriya'], + ['Osge', 'Osage'], + ['Osma', 'Osmanya'], + ['Palm', 'Palmyrene'], + ['Pauc', 'Pau_Cin_Hau'], + ['Perm', 'Old_Permic'], + ['Phag', 'Phags_Pa'], + ['Phli', 'Inscriptional_Pahlavi'], + ['Phlp', 'Psalter_Pahlavi'], + ['Phnx', 'Phoenician'], + ['Plrd', 'Miao'], + ['Prti', 'Inscriptional_Parthian'], + ['Rjng', 'Rejang'], + ['Rohg', 'Hanifi_Rohingya'], + ['Runr', 'Runic'], + ['Samr', 'Samaritan'], + ['Sarb', 'Old_South_Arabian'], + ['Saur', 'Saurashtra'], + ['Sgnw', 'SignWriting'], + ['Shaw', 'Shavian'], + ['Shrd', 'Sharada'], + ['Sidd', 'Siddham'], + ['Sind', 'Khudawadi'], + ['Sinh', 'Sinhala'], + ['Sogd', 'Sogdian'], + ['Sogo', 'Old_Sogdian'], + ['Sora', 'Sora_Sompeng'], + ['Soyo', 'Soyombo'], + ['Sund', 'Sundanese'], + ['Sylo', 'Syloti_Nagri'], + ['Syrc', 'Syriac'], + ['Tagb', 'Tagbanwa'], + ['Takr', 'Takri'], + ['Tale', 'Tai_Le'], + ['Talu', 'New_Tai_Lue'], + ['Taml', 'Tamil'], + ['Tang', 'Tangut'], + ['Tavt', 'Tai_Viet'], + ['Telu', 'Telugu'], + ['Tfng', 'Tifinagh'], + ['Tglg', 'Tagalog'], + ['Thaa', 'Thaana'], + ['Thai', 'Thai'], + ['Tibt', 'Tibetan'], + ['Tirh', 'Tirhuta'], + ['Ugar', 'Ugaritic'], + ['Vaii', 'Vai'], + ['Wara', 'Warang_Citi'], + ['Xpeo', 'Old_Persian'], + ['Xsux', 'Cuneiform'], + ['Yiii', 'Yi'], + ['Zanb', 'Zanabazar_Square'], + ['Zinh', 'Inherited'], + ['Qaai', 'Inherited'], + ['Zyyy', 'Common'], + ['Zzzz', 'Unknown'], + ['Adlam', 'Adlam'], + ['Caucasian_Albanian', 'Caucasian_Albanian'], + ['Arabic', 'Arabic'], + ['Imperial_Aramaic', 'Imperial_Aramaic'], + ['Armenian', 'Armenian'], + ['Avestan', 'Avestan'], + ['Balinese', 'Balinese'], + ['Bamum', 'Bamum'], + ['Bassa_Vah', 'Bassa_Vah'], + ['Batak', 'Batak'], + ['Bengali', 'Bengali'], + ['Bhaiksuki', 'Bhaiksuki'], + ['Bopomofo', 'Bopomofo'], + ['Brahmi', 'Brahmi'], + ['Braille', 'Braille'], + ['Buginese', 'Buginese'], + ['Buhid', 'Buhid'], + ['Chakma', 'Chakma'], + ['Canadian_Aboriginal', 'Canadian_Aboriginal'], + ['Carian', 'Carian'], + ['Cherokee', 'Cherokee'], + ['Coptic', 'Coptic'], + ['Cypriot', 'Cypriot'], + ['Cyrillic', 'Cyrillic'], + ['Devanagari', 'Devanagari'], + ['Dogra', 'Dogra'], + ['Deseret', 'Deseret'], + ['Duployan', 'Duployan'], + ['Egyptian_Hieroglyphs', 'Egyptian_Hieroglyphs'], + ['Elbasan', 'Elbasan'], + ['Ethiopic', 'Ethiopic'], + ['Georgian', 'Georgian'], + ['Glagolitic', 'Glagolitic'], + ['Gunjala_Gondi', 'Gunjala_Gondi'], + ['Masaram_Gondi', 'Masaram_Gondi'], + ['Gothic', 'Gothic'], + ['Grantha', 'Grantha'], + ['Greek', 'Greek'], + ['Gujarati', 'Gujarati'], + ['Gurmukhi', 'Gurmukhi'], + ['Hangul', 'Hangul'], + ['Han', 'Han'], + ['Hanunoo', 'Hanunoo'], + ['Hatran', 'Hatran'], + ['Hebrew', 'Hebrew'], + ['Hiragana', 'Hiragana'], + ['Anatolian_Hieroglyphs', 'Anatolian_Hieroglyphs'], + ['Pahawh_Hmong', 'Pahawh_Hmong'], + ['Katakana_Or_Hiragana', 'Katakana_Or_Hiragana'], + ['Old_Hungarian', 'Old_Hungarian'], + ['Old_Italic', 'Old_Italic'], + ['Javanese', 'Javanese'], + ['Kayah_Li', 'Kayah_Li'], + ['Katakana', 'Katakana'], + ['Kharoshthi', 'Kharoshthi'], + ['Khmer', 'Khmer'], + ['Khojki', 'Khojki'], + ['Kannada', 'Kannada'], + ['Kaithi', 'Kaithi'], + ['Tai_Tham', 'Tai_Tham'], + ['Lao', 'Lao'], + ['Latin', 'Latin'], + ['Lepcha', 'Lepcha'], + ['Limbu', 'Limbu'], + ['Linear_A', 'Linear_A'], + ['Linear_B', 'Linear_B'], + ['Lycian', 'Lycian'], + ['Lydian', 'Lydian'], + ['Mahajani', 'Mahajani'], + ['Makasar', 'Makasar'], + ['Mandaic', 'Mandaic'], + ['Manichaean', 'Manichaean'], + ['Marchen', 'Marchen'], + ['Medefaidrin', 'Medefaidrin'], + ['Mende_Kikakui', 'Mende_Kikakui'], + ['Meroitic_Cursive', 'Meroitic_Cursive'], + ['Meroitic_Hieroglyphs', 'Meroitic_Hieroglyphs'], + ['Malayalam', 'Malayalam'], + ['Mongolian', 'Mongolian'], + ['Mro', 'Mro'], + ['Meetei_Mayek', 'Meetei_Mayek'], + ['Multani', 'Multani'], + ['Myanmar', 'Myanmar'], + ['Old_North_Arabian', 'Old_North_Arabian'], + ['Nabataean', 'Nabataean'], + ['Nko', 'Nko'], + ['Nushu', 'Nushu'], + ['Ogham', 'Ogham'], + ['Ol_Chiki', 'Ol_Chiki'], + ['Old_Turkic', 'Old_Turkic'], + ['Oriya', 'Oriya'], + ['Osage', 'Osage'], + ['Osmanya', 'Osmanya'], + ['Palmyrene', 'Palmyrene'], + ['Pau_Cin_Hau', 'Pau_Cin_Hau'], + ['Old_Permic', 'Old_Permic'], + ['Phags_Pa', 'Phags_Pa'], + ['Inscriptional_Pahlavi', 'Inscriptional_Pahlavi'], + ['Psalter_Pahlavi', 'Psalter_Pahlavi'], + ['Phoenician', 'Phoenician'], + ['Miao', 'Miao'], + ['Inscriptional_Parthian', 'Inscriptional_Parthian'], + ['Rejang', 'Rejang'], + ['Hanifi_Rohingya', 'Hanifi_Rohingya'], + ['Runic', 'Runic'], + ['Samaritan', 'Samaritan'], + ['Old_South_Arabian', 'Old_South_Arabian'], + ['Saurashtra', 'Saurashtra'], + ['SignWriting', 'SignWriting'], + ['Shavian', 'Shavian'], + ['Sharada', 'Sharada'], + ['Siddham', 'Siddham'], + ['Khudawadi', 'Khudawadi'], + ['Sinhala', 'Sinhala'], + ['Sogdian', 'Sogdian'], + ['Old_Sogdian', 'Old_Sogdian'], + ['Sora_Sompeng', 'Sora_Sompeng'], + ['Soyombo', 'Soyombo'], + ['Sundanese', 'Sundanese'], + ['Syloti_Nagri', 'Syloti_Nagri'], + ['Syriac', 'Syriac'], + ['Tagbanwa', 'Tagbanwa'], + ['Takri', 'Takri'], + ['Tai_Le', 'Tai_Le'], + ['New_Tai_Lue', 'New_Tai_Lue'], + ['Tamil', 'Tamil'], + ['Tangut', 'Tangut'], + ['Tai_Viet', 'Tai_Viet'], + ['Telugu', 'Telugu'], + ['Tifinagh', 'Tifinagh'], + ['Tagalog', 'Tagalog'], + ['Thaana', 'Thaana'], + ['Tibetan', 'Tibetan'], + ['Tirhuta', 'Tirhuta'], + ['Ugaritic', 'Ugaritic'], + ['Vai', 'Vai'], + ['Warang_Citi', 'Warang_Citi'], + ['Old_Persian', 'Old_Persian'], + ['Cuneiform', 'Cuneiform'], + ['Yi', 'Yi'], + ['Zanabazar_Square', 'Zanabazar_Square'], + ['Inherited', 'Inherited'], + ['Common', 'Common'], + ['Unknown', 'Unknown'] + ])] +]); + +const matchPropertyValue = function(property, value) { + const aliasToValue = mappings.get(property); + if (!aliasToValue) { + throw new Error(`Unknown property \`${ property }\`.`); + } + const canonicalValue = aliasToValue.get(value); + if (canonicalValue) { + return canonicalValue; + } + throw new Error( + `Unknown value \`${ value }\` for property \`${ property }\`.` + ); +}; + +var unicodeMatchPropertyValueEcmascript = matchPropertyValue; + +var unicodeCanonicalPropertyNamesEcmascript = new Set([ + // Non-binary properties: + 'General_Category', + 'Script', + 'Script_Extensions', + // Binary properties: + 'Alphabetic', + 'Any', + 'ASCII', + 'ASCII_Hex_Digit', + 'Assigned', + 'Bidi_Control', + 'Bidi_Mirrored', + 'Case_Ignorable', + 'Cased', + 'Changes_When_Casefolded', + 'Changes_When_Casemapped', + 'Changes_When_Lowercased', + 'Changes_When_NFKC_Casefolded', + 'Changes_When_Titlecased', + 'Changes_When_Uppercased', + 'Dash', + 'Default_Ignorable_Code_Point', + 'Deprecated', + 'Diacritic', + 'Emoji', + 'Emoji_Component', + 'Emoji_Modifier', + 'Emoji_Modifier_Base', + 'Emoji_Presentation', + 'Extended_Pictographic', + 'Extender', + 'Grapheme_Base', + 'Grapheme_Extend', + 'Hex_Digit', + 'ID_Continue', + 'ID_Start', + 'Ideographic', + 'IDS_Binary_Operator', + 'IDS_Trinary_Operator', + 'Join_Control', + 'Logical_Order_Exception', + 'Lowercase', + 'Math', + 'Noncharacter_Code_Point', + 'Pattern_Syntax', + 'Pattern_White_Space', + 'Quotation_Mark', + 'Radical', + 'Regional_Indicator', + 'Sentence_Terminal', + 'Soft_Dotted', + 'Terminal_Punctuation', + 'Unified_Ideograph', + 'Uppercase', + 'Variation_Selector', + 'White_Space', + 'XID_Continue', + 'XID_Start' +]); + +// Generated using `npm run build`. Do not edit! +var unicodePropertyAliasesEcmascript = new Map([ + ['scx', 'Script_Extensions'], + ['sc', 'Script'], + ['gc', 'General_Category'], + ['AHex', 'ASCII_Hex_Digit'], + ['Alpha', 'Alphabetic'], + ['Bidi_C', 'Bidi_Control'], + ['Bidi_M', 'Bidi_Mirrored'], + ['Cased', 'Cased'], + ['CI', 'Case_Ignorable'], + ['CWCF', 'Changes_When_Casefolded'], + ['CWCM', 'Changes_When_Casemapped'], + ['CWKCF', 'Changes_When_NFKC_Casefolded'], + ['CWL', 'Changes_When_Lowercased'], + ['CWT', 'Changes_When_Titlecased'], + ['CWU', 'Changes_When_Uppercased'], + ['Dash', 'Dash'], + ['Dep', 'Deprecated'], + ['DI', 'Default_Ignorable_Code_Point'], + ['Dia', 'Diacritic'], + ['Ext', 'Extender'], + ['Gr_Base', 'Grapheme_Base'], + ['Gr_Ext', 'Grapheme_Extend'], + ['Hex', 'Hex_Digit'], + ['IDC', 'ID_Continue'], + ['Ideo', 'Ideographic'], + ['IDS', 'ID_Start'], + ['IDSB', 'IDS_Binary_Operator'], + ['IDST', 'IDS_Trinary_Operator'], + ['Join_C', 'Join_Control'], + ['LOE', 'Logical_Order_Exception'], + ['Lower', 'Lowercase'], + ['Math', 'Math'], + ['NChar', 'Noncharacter_Code_Point'], + ['Pat_Syn', 'Pattern_Syntax'], + ['Pat_WS', 'Pattern_White_Space'], + ['QMark', 'Quotation_Mark'], + ['Radical', 'Radical'], + ['RI', 'Regional_Indicator'], + ['SD', 'Soft_Dotted'], + ['STerm', 'Sentence_Terminal'], + ['Term', 'Terminal_Punctuation'], + ['UIdeo', 'Unified_Ideograph'], + ['Upper', 'Uppercase'], + ['VS', 'Variation_Selector'], + ['WSpace', 'White_Space'], + ['space', 'White_Space'], + ['XIDC', 'XID_Continue'], + ['XIDS', 'XID_Start'] +]); + +const matchProperty = function(property) { + if (unicodeCanonicalPropertyNamesEcmascript.has(property)) { + return property; + } + if (unicodePropertyAliasesEcmascript.has(property)) { + return unicodePropertyAliasesEcmascript.get(property); + } + throw new Error(`Unknown property: ${ property }`); +}; + +var unicodeMatchPropertyEcmascript = matchProperty; + +var unicode = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); +// Generated by shift-parser-js/scripts/generate-unicode-data.js + +var whitespaceArray = exports.whitespaceArray = [5760, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8202, 8239, 8287, 12288, 65279]; +var whitespaceBool = exports.whitespaceBool = [false, false, false, false, false, false, false, false, false, true, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]; + +var idStartLargeRegex = exports.idStartLargeRegex = /^[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]$/; +var idStartBool = exports.idStartBool = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false]; + +var idContinueLargeRegex = exports.idContinueLargeRegex = /^[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]$/; +var idContinueBool = exports.idContinueBool = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false]; +}); + +var dist = createCommonjsModule(function (module, exports) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint-disable no-use-before-define */ + + + +var _unicodeMatchPropertyValueEcmascript2 = _interopRequireDefault(unicodeMatchPropertyValueEcmascript); + + + +var _mappings2 = _interopRequireDefault(mappings); + + + +var _unicodeMatchPropertyEcmascript2 = _interopRequireDefault(unicodeMatchPropertyEcmascript); + + + +var _unicodePropertyAliasesEcmascript2 = _interopRequireDefault(unicodePropertyAliasesEcmascript); + + + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var catchIsFalse = function catchIsFalse(predicate) { + try { + return !!predicate(); + } catch (e) { + return false; + } +}; + +var syntaxCharacters = '^$\\.*+?()[]{}|'.split(''); +var extendedSyntaxCharacters = '^$\\.*+?()[|'.split(''); + +var controlEscapeCharacters = 'fnrtv'.split(''); +var controlEscapeCharacterValues = { 'f': '\f'.charCodeAt(0), 'n': '\n'.charCodeAt(0), 'r': '\r'.charCodeAt(0), 't': '\t'.charCodeAt(0), 'v': '\v'.charCodeAt(0) }; + +var controlCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''); +var hexDigits = '0123456789abcdefABCDEF'.split(''); +var decimalDigits = '0123456789'.split(''); +var octalDigits = '01234567'.split(''); + +var INVALID_NAMED_BACKREFERENCE_SENTINEL = {}; + +function isIdentifierStart(ch) { + return ch < 128 ? unicode.idStartBool[ch] : unicode.idStartLargeRegex.test(String.fromCodePoint(ch)); +} + +function isIdentifierPart(ch) { + return ch < 128 ? unicode.idContinueBool[ch] : unicode.idContinueLargeRegex.test(String.fromCodePoint(ch)); +} + +var PatternAcceptorState = function () { + function PatternAcceptorState(pattern, unicode) { + _classCallCheck(this, PatternAcceptorState); + + this.pattern = pattern; + this.unicode = unicode; + this.index = 0; + this.largestBackreference = 0; + this.backreferenceNames = []; + this.groupingNames = []; + this.capturingGroups = 0; + } + + _createClass(PatternAcceptorState, [{ + key: 'empty', + value: function empty() { + return this.index >= this.pattern.length; + } + }, { + key: 'backreference', + value: function backreference(ref) { + if (ref > this.largestBackreference) { + this.largestBackreference = ref; + } + } + }, { + key: 'nextCodePoint', + value: function nextCodePoint() { + if (this.empty()) { + return null; + } + if (this.unicode) { + return String.fromCodePoint(this.pattern.codePointAt(this.index)); + } + return this.pattern.charAt(this.index); + } + }, { + key: 'skipCodePoint', + value: function skipCodePoint() { + this.index += this.nextCodePoint().length; + } + }, { + key: 'eat', + value: function eat(str) { + if (this.index + str.length > this.pattern.length || this.pattern.slice(this.index, this.index + str.length) !== str) { + return false; + } + this.index += str.length; + return true; + } + }, { + key: 'eatIdentifierCodePoint', + value: function eatIdentifierCodePoint() { + var characterValue = void 0; + var originalIndex = this.index; + var character = void 0; + if (this.match('\\u')) { + this.skipCodePoint(); + characterValue = acceptUnicodeEscape(this); + if (!characterValue.matched) { + this.index = originalIndex; + return null; + } + characterValue = characterValue.value; + character = String.fromCodePoint(characterValue); + } else { + character = this.nextCodePoint(); + if (character == null) { + this.index = originalIndex; + return null; + } + this.index += character.length; + characterValue = character.codePointAt(0); + } + return { character: character, characterValue: characterValue }; + } + }, { + key: 'eatIdentifierStart', + value: function eatIdentifierStart() { + var originalIndex = this.index; + var codePoint = this.eatIdentifierCodePoint(); + if (codePoint === null) { + this.index = originalIndex; + return null; + } + if (codePoint.character === '_' || codePoint.character === '$' || isIdentifierStart(codePoint.characterValue)) { + return codePoint.character; + } + this.index = originalIndex; + return null; + } + }, { + key: 'eatIdentifierPart', + value: function eatIdentifierPart() { + var originalIndex = this.index; + var codePoint = this.eatIdentifierCodePoint(); + if (codePoint === null) { + this.index = originalIndex; + return null; + } + // ZWNJ / ZWJ + if (codePoint.character === '\u200C' || codePoint.character === '\u200D' || codePoint.character === '$' || isIdentifierPart(codePoint.characterValue)) { + return codePoint.character; + } + this.index = originalIndex; + return null; + } + }, { + key: 'eatAny', + value: function eatAny() { + for (var _len = arguments.length, strs = Array(_len), _key = 0; _key < _len; _key++) { + strs[_key] = arguments[_key]; + } + + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = strs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var str = _step.value; + + if (this.eat(str)) { + return str; + } + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + return null; + } + }, { + key: 'match', + value: function match(str) { + return this.index + str.length <= this.pattern.length && this.pattern.slice(this.index, this.index + str.length) === str; + } + }, { + key: 'matchAny', + value: function matchAny() { + for (var _len2 = arguments.length, strs = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + strs[_key2] = arguments[_key2]; + } + + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = strs[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var str = _step2.value; + + if (this.match(str)) { + return true; + } + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } + + return false; + } + }, { + key: 'eatNaturalNumber', + value: function eatNaturalNumber() { + var _this = this; + + var characters = []; + var eatNumber = function eatNumber() { + var _iteratorNormalCompletion3 = true; + var _didIteratorError3 = false; + var _iteratorError3 = undefined; + + try { + for (var _iterator3 = decimalDigits[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { + var str = _step3.value; + + if (_this.eat(str)) { + characters.push(str); + return true; + } + } + } catch (err) { + _didIteratorError3 = true; + _iteratorError3 = err; + } finally { + try { + if (!_iteratorNormalCompletion3 && _iterator3.return) { + _iterator3.return(); + } + } finally { + if (_didIteratorError3) { + throw _iteratorError3; + } + } + } + + return false; + }; + while (eatNumber()) {} + return characters.length === 0 ? null : characters.join(''); + } + }]); + + return PatternAcceptorState; +}(); + +// acceptRegex + + +exports.default = function (pattern) { + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$unicode = _ref.unicode, + unicode = _ref$unicode === undefined ? false : _ref$unicode; + + var state = new PatternAcceptorState(pattern, unicode); + var accepted = acceptDisjunction(state); + if (accepted.matched) { + if (state.unicode) { + if (state.largestBackreference > state.capturingGroups) { + return false; + } + } + if (state.groupingNames.length > 0 || state.unicode) { + var _iteratorNormalCompletion4 = true; + var _didIteratorError4 = false; + var _iteratorError4 = undefined; + + try { + for (var _iterator4 = state.backreferenceNames[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { + var backreferenceName = _step4.value; + + if (state.groupingNames.indexOf(backreferenceName) === -1) { + return false; + } + } + } catch (err) { + _didIteratorError4 = true; + _iteratorError4 = err; + } finally { + try { + if (!_iteratorNormalCompletion4 && _iterator4.return) { + _iterator4.return(); + } + } finally { + if (_didIteratorError4) { + throw _iteratorError4; + } + } + } + } + } + return accepted.matched; +}; + +var backtrackOnFailure = function backtrackOnFailure(func) { + return function (state) { + var savedIndex = state.index; + var oldBackreference = state.largestBackreference; + var oldCapturingGroups = state.capturingGroups; + var val = func(state); + if (!val.matched) { + state.index = savedIndex; + state.largestBackreference = oldBackreference; + state.capturingGroups = oldCapturingGroups; + } + return val; + }; +}; + +var acceptUnicodeEscape = backtrackOnFailure(function (state) { + if (!state.eat('u')) { + return { matched: false }; + } + if (state.unicode && state.eat('{')) { + var _digits = []; + while (!state.eat('}')) { + var digit = state.eatAny.apply(state, _toConsumableArray(hexDigits)); + if (digit === null) { + return { matched: false }; + } + _digits.push(digit); + } + var _value = parseInt(_digits.join(''), 16); + return _value > 0x10FFFF ? { matched: false } : { matched: true, value: _value }; + } + var digits = [0, 0, 0, 0].map(function () { + return state.eatAny.apply(state, _toConsumableArray(hexDigits)); + }); + if (digits.some(function (digit) { + return digit === null; + })) { + return { matched: false }; + } + var value = parseInt(digits.join(''), 16); + if (state.unicode && value >= 0xD800 && value <= 0xDBFF) { + var surrogatePairValue = backtrackOnFailure(function (subState) { + if (!subState.eat('\\u')) { + return { matched: false }; + } + var digits2 = [0, 0, 0, 0].map(function () { + return subState.eatAny.apply(subState, _toConsumableArray(hexDigits)); + }); + if (digits2.some(function (digit) { + return digit === null; + })) { + return { matched: false }; + } + var value2 = parseInt(digits2.join(''), 16); + if (value2 < 0xDC00 || value2 >= 0xE000) { + return { matched: false }; + } + return { matched: true, value: 0x10000 + ((value & 0x03FF) << 10) + (value2 & 0x03FF) }; + })(state); + if (surrogatePairValue.matched) { + return surrogatePairValue; + } + } + return { matched: true, value: value }; +}); + +var acceptDisjunction = function acceptDisjunction(state, terminator) { + do { + if (terminator !== void 0 && state.eat(terminator)) { + return { matched: true }; + } else if (state.match('|')) { + continue; + } + if (!acceptAlternative(state, terminator).matched) { + return { matched: false }; + } + } while (state.eat('|')); + return { matched: terminator === void 0 || !!state.eat(terminator) }; +}; + +var acceptAlternative = function acceptAlternative(state, terminator) { + while (!state.match('|') && !state.empty() && (terminator === void 0 || !state.match(terminator))) { + if (!acceptTerm(state).matched) { + return { matched: false }; + } + } + return { matched: true }; +}; + +var anyOf = function anyOf() { + for (var _len3 = arguments.length, acceptors = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + acceptors[_key3] = arguments[_key3]; + } + + return function (state) { + var _iteratorNormalCompletion5 = true; + var _didIteratorError5 = false; + var _iteratorError5 = undefined; + + try { + for (var _iterator5 = acceptors[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { + var predicate = _step5.value; + + var value = predicate(state); + if (value.matched) { + return value; + } + } + } catch (err) { + _didIteratorError5 = true; + _iteratorError5 = err; + } finally { + try { + if (!_iteratorNormalCompletion5 && _iterator5.return) { + _iterator5.return(); + } + } finally { + if (_didIteratorError5) { + throw _iteratorError5; + } + } + } + + return { matched: false }; + }; +}; + +var acceptTerm = function acceptTerm(state) { + // non-quantified references are rolled into quantified accepts to improve performance significantly. + if (state.unicode) { + return anyOf(acceptAssertion, acceptQuantified(acceptAtom))(state); + } + return anyOf(acceptQuantified(acceptQuantifiableAssertion), acceptAssertion, acceptQuantified(acceptAtom))(state); +}; + +var acceptLabeledGroup = function acceptLabeledGroup(predicate) { + return backtrackOnFailure(function (state) { + if (!state.eat('(')) { + return { matched: false }; + } + if (predicate(state)) { + return acceptDisjunction(state, ')'); + } + return { matched: false }; + }); +}; + +var acceptQuantifiableAssertion = acceptLabeledGroup(function (state) { + return !!state.eatAny('?=', '?!'); +}); + +var acceptAssertion = function acceptAssertion(state) { + if (state.eatAny('^', '$', '\\b', '\\B')) { + return { matched: true }; + } + return acceptLabeledGroup(function (subState) { + return subState.unicode ? !!subState.eatAny('?=', '?!', '?<=', '? parseInt(num2)) { + return { matched: false }; + } + } + if (!subState.eat('}')) { + return { matched: false }; + } + subState.eat('?'); + return { matched: true }; + })(state); + if (!value.matched) { + return { matched: !state.unicode }; + } + return value; + } else if (state.eatAny('*', '+', '?')) { + state.eat('?'); + } + return { matched: true }; + }); +}; + +var acceptCharacterExcept = function acceptCharacterExcept(characters) { + return function (state) { + var nextCodePoint = state.nextCodePoint(); + if (nextCodePoint === null || characters.indexOf(nextCodePoint) !== -1) { + return { matched: false }; + } + state.skipCodePoint(); + return { matched: true }; + }; +}; + +var acceptPatternCharacter = acceptCharacterExcept(syntaxCharacters); + +var acceptExtendedPatternCharacter = acceptCharacterExcept(extendedSyntaxCharacters); + +var acceptInvalidBracedQuantifier = function acceptInvalidBracedQuantifier(state) { + return backtrackOnFailure(function (subState) { + return { matched: !!(subState.eat('{') && acceptDecimal(subState).matched && (!subState.eat(',') || subState.match('}') || acceptDecimal(subState).matched) && subState.eat('}')) }; + })(state); +}; + +var acceptAtom = function acceptAtom(state) { + if (state.unicode) { + return anyOf(acceptPatternCharacter, function (subState) { + return { matched: !!subState.eat('.') }; + }, backtrackOnFailure(function (subState) { + return subState.eat('\\') ? acceptAtomEscape(subState) : { matched: false }; + }), acceptCharacterClass, acceptLabeledGroup(function (subState) { + return subState.eat('?:'); + }), acceptGrouping)(state); + } + var matched = anyOf(function (subState) { + return { matched: !!subState.eat('.') }; + }, backtrackOnFailure(function (subState) { + return subState.eat('\\') ? acceptAtomEscape(subState) : { matched: false }; + }), backtrackOnFailure(function (subState) { + return { matched: subState.eat('\\') && subState.match('c') }; + }), acceptCharacterClass, acceptLabeledGroup(function (subState) { + return subState.eat('?:'); + }), acceptGrouping)(state); + if (!matched.matched && acceptInvalidBracedQuantifier(state).matched) { + return { matched: false }; + } + return matched.matched ? matched : acceptExtendedPatternCharacter(state); +}; + +var acceptGrouping = backtrackOnFailure(function (state) { + if (!state.eat('(')) { + return { matched: false }; + } + var groupName = backtrackOnFailure(function (subState) { + if (!state.eat('?')) { + return { matched: false }; + } + return acceptGroupName(subState); + })(state); + if (!acceptDisjunction(state, ')').matched) { + return { matched: false }; + } + if (groupName.matched) { + if (state.groupingNames.indexOf(groupName.data) !== -1) { + return { matched: false }; + } + state.groupingNames.push(groupName.data); + } + state.capturingGroups++; + return { matched: true }; +}); + +var acceptDecimalEscape = backtrackOnFailure(function (state) { + var firstDecimal = state.eatAny.apply(state, _toConsumableArray(decimalDigits)); + if (firstDecimal === null) { + return { matched: false }; + } + if (firstDecimal === '0') { + return { matched: true }; + } + // we also accept octal escapes here, but it is impossible to tell if it is a octal escape until all parsing is complete. + // octal escapes are handled in acceptCharacterEscape for classes + state.backreference(parseInt(firstDecimal + (state.eatNaturalNumber() || ''))); + return { matched: true }; +}); + +var acceptCharacterClassEscape = function acceptCharacterClassEscape(state) { + if (state.eatAny('d', 'D', 's', 'S', 'w', 'W')) { + return { matched: true }; + } + if (state.unicode) { + return backtrackOnFailure(function (subState) { + if (!subState.eat('p{') && !subState.eat('P{')) { + return { matched: false }; + } + if (!acceptUnicodePropertyValueExpression(subState).matched) { + return { matched: false }; + } + return { matched: !!subState.eat('}') }; + })(state); + } + return { matched: false }; +}; + +var acceptUnicodePropertyName = function acceptUnicodePropertyName(state) { + var characters = []; + var character = void 0; + while (character = state.eatAny.apply(state, _toConsumableArray(controlCharacters).concat(['_']))) { + // eslint-disable-line no-cond-assign + characters.push(character); + } + return { matched: characters.length > 0, data: characters.join('') }; +}; + +var acceptUnicodePropertyValue = function acceptUnicodePropertyValue(state) { + var characters = []; + var character = void 0; + while (character = state.eatAny.apply(state, _toConsumableArray(controlCharacters).concat(_toConsumableArray(decimalDigits), ['_']))) { + // eslint-disable-line no-cond-assign + characters.push(character); + } + return { matched: characters.length > 0, data: characters.join('') }; +}; + +// excluding nonbinary properties from mathias' list +// https://www.ecma-international.org/ecma-262/9.0/index.html#table-nonbinary-unicode-properties +var illegalLoneUnicodePropertyNames = ['General_Category', 'Script', 'Script_Extensions', 'scx', 'sc', 'gc']; + +var generalCategoryValues = _mappings2.default.get('General_Category'); + +var acceptLoneUnicodePropertyNameOrValue = function acceptLoneUnicodePropertyNameOrValue(state) { + var loneValue = acceptUnicodePropertyValue(state); + if (!loneValue.matched || illegalLoneUnicodePropertyNames.includes(loneValue.data)) { + return { matched: false }; + } + + return { matched: catchIsFalse(function () { + return (0, _unicodeMatchPropertyEcmascript2.default)(loneValue.data); + }) || generalCategoryValues.get(loneValue.data) != null }; +}; + +var acceptUnicodePropertyValueExpression = function acceptUnicodePropertyValueExpression(state) { + return anyOf(backtrackOnFailure(function (subState) { + var name = acceptUnicodePropertyName(subState); + if (!name.matched || !subState.eat('=')) { + return { matched: false }; + } + var value = acceptUnicodePropertyValue(subState); + if (!value.matched) { + return { matched: false }; + } + return { matched: catchIsFalse(function () { + return (0, _unicodeMatchPropertyValueEcmascript2.default)(_unicodePropertyAliasesEcmascript2.default.get(name.data) || name.data, value.data); + }) }; + }), backtrackOnFailure(acceptLoneUnicodePropertyNameOrValue))(state); +}; + +var acceptCharacterEscape = anyOf(function (state) { + var eaten = state.eatAny.apply(state, _toConsumableArray(controlEscapeCharacters)); + if (eaten === null) { + return { matched: false }; + } + return { matched: true, value: controlEscapeCharacterValues[eaten] }; +}, backtrackOnFailure(function (state) { + if (!state.eat('c')) { + return { matched: false }; + } + var character = state.eatAny.apply(state, _toConsumableArray(controlCharacters)); + if (character === null) { + return { matched: false }; + } + return { matched: true, value: character.charCodeAt(0) % 32 }; +}), backtrackOnFailure(function (state) { + if (!state.eat('0') || state.eatAny.apply(state, _toConsumableArray(decimalDigits))) { + return { matched: false }; + } + return { matched: true, value: 0 }; +}), backtrackOnFailure(function (state) { + if (!state.eat('x')) { + return { matched: false }; + } + var digits = [0, 0].map(function () { + return state.eatAny.apply(state, _toConsumableArray(hexDigits)); + }); + if (digits.some(function (value) { + return value === null; + })) { + return { matched: false }; + } + return { matched: true, value: parseInt(digits.join(''), 16) }; +}), acceptUnicodeEscape, backtrackOnFailure(function (state) { + if (state.unicode) { + return { matched: false }; + } + var octal1 = state.eatAny.apply(state, _toConsumableArray(octalDigits)); + if (octal1 === null) { + return { matched: false }; + } + var octal1Value = parseInt(octal1, 8); + if (octalDigits.indexOf(state.nextCodePoint()) === -1) { + return { matched: true, value: octal1Value }; + } + var octal2 = state.eatAny.apply(state, _toConsumableArray(octalDigits)); + var octal2Value = parseInt(octal2, 8); + if (octal1Value < 4) { + if (octalDigits.indexOf(state.nextCodePoint()) === -1) { + return { matched: true, value: octal1Value << 3 | octal2Value }; + } + var octal3 = state.eatAny.apply(state, _toConsumableArray(octalDigits)); + var octal3Value = parseInt(octal3, 8); + return { matched: true, value: octal1Value << 6 | octal2Value << 3 | octal3Value }; + } + return { matched: true, value: octal1Value << 3 | octal2Value }; +}), backtrackOnFailure(function (state) { + if (!state.unicode) { + return { matched: false }; + } + var value = state.eatAny.apply(state, _toConsumableArray(syntaxCharacters)); + if (value === null) { + return { matched: false }; + } + return { matched: true, value: value.charCodeAt(0) }; +}), function (state) { + if (!state.unicode || !state.eat('/')) { + return { matched: false }; + } + return { matched: true, value: '/'.charCodeAt(0) }; +}, backtrackOnFailure(function (state) { + if (state.unicode) { + return { matched: false }; + } + var next = state.nextCodePoint(); + if (next !== null && next !== 'c' && next !== 'k') { + state.skipCodePoint(); + return { matched: true, value: next.codePointAt(0) }; + } + return { matched: false }; +})); + +var acceptGroupNameBackreference = backtrackOnFailure(function (state) { + if (!state.eat('k')) { + return { matched: false }; + } + var name = acceptGroupName(state); + if (!name.matched) { + state.backreferenceNames.push(INVALID_NAMED_BACKREFERENCE_SENTINEL); + return { matched: true }; + } + state.backreferenceNames.push(name.data); + return { matched: true }; +}); + +var acceptGroupName = backtrackOnFailure(function (state) { + if (!state.eat('<')) { + return { matched: false }; + } + var characters = []; + var start = state.eatIdentifierStart(); + if (!start) { + return { matched: false }; + } + characters.push(start); + var part = void 0; + while (part = state.eatIdentifierPart()) { + // eslint-disable-line no-cond-assign + characters.push(part); + } + if (!state.eat('>')) { + return { matched: false }; + } + return { matched: characters.length > 0, data: characters.join('') }; +}); + +var acceptAtomEscape = anyOf(acceptDecimalEscape, acceptCharacterClassEscape, acceptCharacterEscape, acceptGroupNameBackreference); + +var acceptCharacterClass = backtrackOnFailure(function (state) { + if (!state.eat('[')) { + return { matched: false }; + } + state.eat('^'); + + var acceptClassEscape = anyOf(function (subState) { + return { matched: !!subState.eat('b'), value: 0x0008 }; + }, function (subState) { + return { matched: subState.unicode && !!subState.eat('-'), value: '-'.charCodeAt(0) }; + }, backtrackOnFailure(function (subState) { + if (subState.unicode || !subState.eat('c')) { + return { matched: false }; + } + var character = subState.eatAny.apply(subState, _toConsumableArray(decimalDigits).concat(['_'])); + if (character === null) { + return { matched: false }; + } + return { matched: true, value: character.charCodeAt(0) % 32 }; + }), acceptCharacterClassEscape, acceptCharacterEscape, + // We special-case `\k` because `acceptCharacterEscape` rejects `\k` unconditionally, + // deferring `\k` to acceptGroupNameBackreference, which is not called here. + // See also https://github.com/tc39/ecma262/issues/2037. This code takes the route of + // making it unconditionally legal, rather than legal only in the absence of a group name. + function (subState) { + return { matched: !subState.unicode && !!subState.eat('k'), value: 107 }; + }); + + var acceptClassAtomNoDash = function acceptClassAtomNoDash(localState) { + var nextCodePoint = localState.nextCodePoint(); + if (nextCodePoint === ']' || nextCodePoint === '-' || nextCodePoint === null) { + return { matched: false }; + } + if (nextCodePoint !== '\\') { + localState.skipCodePoint(); + return { matched: true, value: nextCodePoint.codePointAt(0) }; + } + localState.eat('\\'); + var classEscape = acceptClassEscape(localState); + if (!classEscape.matched && localState.nextCodePoint() === 'c' && !localState.unicode) { + return { matched: true, value: '\\'.charCodeAt(0) }; + } + return classEscape; + }; + + var acceptClassAtom = function acceptClassAtom(localState) { + if (localState.eat('-')) { + return { matched: true, value: '-'.charCodeAt(0) }; + } + return acceptClassAtomNoDash(localState); + }; + + var finishClassRange = function finishClassRange(localState, atom) { + var isUnvaluedPassedAtom = function isUnvaluedPassedAtom(subAtom) { + return subAtom.value === void 0 && subAtom.matched; + }; + if (localState.eat('-')) { + if (localState.match(']')) { + return { matched: true }; + } + var otherAtom = acceptClassAtom(localState); + if (!otherAtom.matched) { + return { matched: false }; + } + if (localState.unicode && (isUnvaluedPassedAtom(atom) || isUnvaluedPassedAtom(otherAtom))) { + return { matched: false }; + } else if (!(!localState.unicode && (isUnvaluedPassedAtom(atom) || isUnvaluedPassedAtom(otherAtom))) && atom.value > otherAtom.value) { + return { matched: false }; + } else if (localState.match(']')) { + return { matched: true }; + } + return acceptNonEmptyClassRanges(localState); + } + if (localState.match(']')) { + return { matched: true }; + } + return acceptNonEmptyClassRangesNoDash(localState); + }; + + var acceptNonEmptyClassRanges = function acceptNonEmptyClassRanges(localState) { + var atom = acceptClassAtom(localState); + return atom.matched ? finishClassRange(localState, atom) : { matched: false }; + }; + + var acceptNonEmptyClassRangesNoDash = function acceptNonEmptyClassRangesNoDash(localState) { + var atom = acceptClassAtomNoDash(localState); + return atom.matched ? finishClassRange(localState, atom) : { matched: false }; + }; + + if (state.eat(']')) { + return { matched: true }; + } + + var value = acceptNonEmptyClassRanges(state); + if (value.matched) { + state.eat(']'); // cannot fail, as above will not return matched if it is not seen in advance + } + + return value; +}); +}); + +var __pika_web_default_export_for_treeshaking__ = /*@__PURE__*/getDefaultExportFromCjs(dist); + +export default __pika_web_default_export_for_treeshaking__; diff --git a/docs/_snowpack/pkg/shift-spec.js b/docs/_snowpack/pkg/shift-spec.js new file mode 100644 index 00000000..67d8504c --- /dev/null +++ b/docs/_snowpack/pkg/shift-spec.js @@ -0,0 +1,876 @@ +import { g as getDefaultExportFromCjs, c as createCommonjsModule } from './common/_commonjsHelpers-8c19dec8.js'; + +var dist = createCommonjsModule(function (module, exports) { +// Generated by src/generate-spec.js. + +/** + * Copyright 2016 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Hack to make Babel6 import this as a module. +Object.defineProperty(exports, "__esModule", { + value: true +}); + +exports.default = (function() { + var SPEC = {}; + + var BOOLEAN = { typeName: "Boolean" }; + var DOUBLE = { typeName: "Number" }; + var STRING = { typeName: "String" }; + function Maybe(arg) { return { typeName: "Maybe", argument: arg }; } + function List(arg) { return { typeName: "List", argument: arg }; } + function Const(arg) { return { typeName: "Const", argument: arg }; } + function Union() { return { typeName: "Union", arguments: [].slice.call(arguments, 0) }; } + + + var TYPE_INDICATOR = { + typeName: "Enum", + values: ["ArrayAssignmentTarget", "ArrayBinding", "ArrayExpression", "ArrowExpression", "AssignmentExpression", "AssignmentTargetIdentifier", "AssignmentTargetPropertyIdentifier", "AssignmentTargetPropertyProperty", "AssignmentTargetWithDefault", "AwaitExpression", "BinaryExpression", "BindingIdentifier", "BindingPropertyIdentifier", "BindingPropertyProperty", "BindingWithDefault", "Block", "BlockStatement", "BreakStatement", "CallExpression", "CatchClause", "ClassDeclaration", "ClassElement", "ClassExpression", "CompoundAssignmentExpression", "ComputedMemberAssignmentTarget", "ComputedMemberExpression", "ComputedPropertyName", "ConditionalExpression", "ContinueStatement", "DataProperty", "DebuggerStatement", "Directive", "DoWhileStatement", "EmptyStatement", "Export", "ExportAllFrom", "ExportDefault", "ExportFrom", "ExportFromSpecifier", "ExportLocalSpecifier", "ExportLocals", "ExpressionStatement", "ForAwaitStatement", "ForInStatement", "ForOfStatement", "ForStatement", "FormalParameters", "FunctionBody", "FunctionDeclaration", "FunctionExpression", "Getter", "IdentifierExpression", "IfStatement", "Import", "ImportNamespace", "ImportSpecifier", "LabeledStatement", "LiteralBooleanExpression", "LiteralInfinityExpression", "LiteralNullExpression", "LiteralNumericExpression", "LiteralRegExpExpression", "LiteralStringExpression", "Method", "Module", "NewExpression", "NewTargetExpression", "ObjectAssignmentTarget", "ObjectBinding", "ObjectExpression", "ReturnStatement", "Script", "Setter", "ShorthandProperty", "SpreadElement", "SpreadProperty", "StaticMemberAssignmentTarget", "StaticMemberExpression", "StaticPropertyName", "Super", "SwitchCase", "SwitchDefault", "SwitchStatement", "SwitchStatementWithDefault", "TemplateElement", "TemplateExpression", "ThisExpression", "ThrowStatement", "TryCatchStatement", "TryFinallyStatement", "UnaryExpression", "UpdateExpression", "VariableDeclaration", "VariableDeclarationStatement", "VariableDeclarator", "WhileStatement", "WithStatement", "YieldExpression", "YieldGeneratorExpression"] + }; + + var BinaryOperator = { + typeName: "Enum", + values: ["==", "!=", "===", "!==", "<", "<=", ">", ">=", "in", "instanceof", "<<", ">>", ">>>", "+", "-", "*", "/", "%", "**", ",", "||", "&&", "|", "^", "&"] + }; + + var CompoundAssignmentOperator = { + typeName: "Enum", + values: ["+=", "-=", "*=", "/=", "%=", "**=", "<<=", ">>=", ">>>=", "|=", "^=", "&="] + }; + + var UnaryOperator = { + typeName: "Enum", + values: ["+", "-", "!", "~", "typeof", "void", "delete"] + }; + + var UpdateOperator = { + typeName: "Enum", + values: ["++", "--"] + }; + + var VariableDeclarationKind = { + typeName: "Enum", + values: ["var", "let", "const"] + }; + + + var ArrayAssignmentTarget = SPEC.ArrayAssignmentTarget = {}; + var ArrayBinding = SPEC.ArrayBinding = {}; + var ArrayExpression = SPEC.ArrayExpression = {}; + var ArrowExpression = SPEC.ArrowExpression = {}; + var AssignmentExpression = SPEC.AssignmentExpression = {}; + var AssignmentTargetIdentifier = SPEC.AssignmentTargetIdentifier = {}; + var AssignmentTargetPropertyIdentifier = SPEC.AssignmentTargetPropertyIdentifier = {}; + var AssignmentTargetPropertyProperty = SPEC.AssignmentTargetPropertyProperty = {}; + var AssignmentTargetWithDefault = SPEC.AssignmentTargetWithDefault = {}; + var AwaitExpression = SPEC.AwaitExpression = {}; + var BinaryExpression = SPEC.BinaryExpression = {}; + var BindingIdentifier = SPEC.BindingIdentifier = {}; + var BindingPropertyIdentifier = SPEC.BindingPropertyIdentifier = {}; + var BindingPropertyProperty = SPEC.BindingPropertyProperty = {}; + var BindingWithDefault = SPEC.BindingWithDefault = {}; + var Block = SPEC.Block = {}; + var BlockStatement = SPEC.BlockStatement = {}; + var BreakStatement = SPEC.BreakStatement = {}; + var CallExpression = SPEC.CallExpression = {}; + var CatchClause = SPEC.CatchClause = {}; + var ClassDeclaration = SPEC.ClassDeclaration = {}; + var ClassElement = SPEC.ClassElement = {}; + var ClassExpression = SPEC.ClassExpression = {}; + var CompoundAssignmentExpression = SPEC.CompoundAssignmentExpression = {}; + var ComputedMemberAssignmentTarget = SPEC.ComputedMemberAssignmentTarget = {}; + var ComputedMemberExpression = SPEC.ComputedMemberExpression = {}; + var ComputedPropertyName = SPEC.ComputedPropertyName = {}; + var ConditionalExpression = SPEC.ConditionalExpression = {}; + var ContinueStatement = SPEC.ContinueStatement = {}; + var DataProperty = SPEC.DataProperty = {}; + var DebuggerStatement = SPEC.DebuggerStatement = {}; + var Directive = SPEC.Directive = {}; + var DoWhileStatement = SPEC.DoWhileStatement = {}; + var EmptyStatement = SPEC.EmptyStatement = {}; + var Export = SPEC.Export = {}; + var ExportAllFrom = SPEC.ExportAllFrom = {}; + var ExportDefault = SPEC.ExportDefault = {}; + var ExportFrom = SPEC.ExportFrom = {}; + var ExportFromSpecifier = SPEC.ExportFromSpecifier = {}; + var ExportLocalSpecifier = SPEC.ExportLocalSpecifier = {}; + var ExportLocals = SPEC.ExportLocals = {}; + var ExpressionStatement = SPEC.ExpressionStatement = {}; + var ForAwaitStatement = SPEC.ForAwaitStatement = {}; + var ForInStatement = SPEC.ForInStatement = {}; + var ForOfStatement = SPEC.ForOfStatement = {}; + var ForStatement = SPEC.ForStatement = {}; + var FormalParameters = SPEC.FormalParameters = {}; + var FunctionBody = SPEC.FunctionBody = {}; + var FunctionDeclaration = SPEC.FunctionDeclaration = {}; + var FunctionExpression = SPEC.FunctionExpression = {}; + var Getter = SPEC.Getter = {}; + var IdentifierExpression = SPEC.IdentifierExpression = {}; + var IfStatement = SPEC.IfStatement = {}; + var Import = SPEC.Import = {}; + var ImportNamespace = SPEC.ImportNamespace = {}; + var ImportSpecifier = SPEC.ImportSpecifier = {}; + var LabeledStatement = SPEC.LabeledStatement = {}; + var LiteralBooleanExpression = SPEC.LiteralBooleanExpression = {}; + var LiteralInfinityExpression = SPEC.LiteralInfinityExpression = {}; + var LiteralNullExpression = SPEC.LiteralNullExpression = {}; + var LiteralNumericExpression = SPEC.LiteralNumericExpression = {}; + var LiteralRegExpExpression = SPEC.LiteralRegExpExpression = {}; + var LiteralStringExpression = SPEC.LiteralStringExpression = {}; + var Method = SPEC.Method = {}; + var Module = SPEC.Module = {}; + var NewExpression = SPEC.NewExpression = {}; + var NewTargetExpression = SPEC.NewTargetExpression = {}; + var ObjectAssignmentTarget = SPEC.ObjectAssignmentTarget = {}; + var ObjectBinding = SPEC.ObjectBinding = {}; + var ObjectExpression = SPEC.ObjectExpression = {}; + var ReturnStatement = SPEC.ReturnStatement = {}; + var Script = SPEC.Script = {}; + var Setter = SPEC.Setter = {}; + var ShorthandProperty = SPEC.ShorthandProperty = {}; + var SpreadElement = SPEC.SpreadElement = {}; + var SpreadProperty = SPEC.SpreadProperty = {}; + var StaticMemberAssignmentTarget = SPEC.StaticMemberAssignmentTarget = {}; + var StaticMemberExpression = SPEC.StaticMemberExpression = {}; + var StaticPropertyName = SPEC.StaticPropertyName = {}; + var Super = SPEC.Super = {}; + var SwitchCase = SPEC.SwitchCase = {}; + var SwitchDefault = SPEC.SwitchDefault = {}; + var SwitchStatement = SPEC.SwitchStatement = {}; + var SwitchStatementWithDefault = SPEC.SwitchStatementWithDefault = {}; + var TemplateElement = SPEC.TemplateElement = {}; + var TemplateExpression = SPEC.TemplateExpression = {}; + var ThisExpression = SPEC.ThisExpression = {}; + var ThrowStatement = SPEC.ThrowStatement = {}; + var TryCatchStatement = SPEC.TryCatchStatement = {}; + var TryFinallyStatement = SPEC.TryFinallyStatement = {}; + var UnaryExpression = SPEC.UnaryExpression = {}; + var UpdateExpression = SPEC.UpdateExpression = {}; + var VariableDeclaration = SPEC.VariableDeclaration = {}; + var VariableDeclarationStatement = SPEC.VariableDeclarationStatement = {}; + var VariableDeclarator = SPEC.VariableDeclarator = {}; + var WhileStatement = SPEC.WhileStatement = {}; + var WithStatement = SPEC.WithStatement = {}; + var YieldExpression = SPEC.YieldExpression = {}; + var YieldGeneratorExpression = SPEC.YieldGeneratorExpression = {}; + + var MemberExpression = Union(ComputedMemberExpression, StaticMemberExpression); + var AssignmentTargetProperty = Union(AssignmentTargetPropertyIdentifier, AssignmentTargetPropertyProperty); + var Class = Union(ClassDeclaration, ClassExpression); + var ExportDeclaration = Union(Export, ExportAllFrom, ExportDefault, ExportFrom, ExportLocals); + var PropertyName = Union(ComputedPropertyName, StaticPropertyName); + var Function = Union(FunctionDeclaration, FunctionExpression); + var ImportDeclaration = Union(Import, ImportNamespace); + var IterationStatement = Union(DoWhileStatement, ForAwaitStatement, ForInStatement, ForOfStatement, ForStatement, WhileStatement); + var MemberAssignmentTarget = Union(ComputedMemberAssignmentTarget, StaticMemberAssignmentTarget); + var BindingProperty = Union(BindingPropertyIdentifier, BindingPropertyProperty); + var MethodDefinition = Union(Getter, Method, Setter); + var Program = Union(Module, Script); + var VariableReference = Union(AssignmentTargetIdentifier, BindingIdentifier, IdentifierExpression); + var NamedObjectProperty = Union(DataProperty, MethodDefinition); + var Expression = Union(ArrayExpression, ArrowExpression, AssignmentExpression, AwaitExpression, BinaryExpression, CallExpression, ClassExpression, CompoundAssignmentExpression, ConditionalExpression, FunctionExpression, IdentifierExpression, LiteralBooleanExpression, LiteralInfinityExpression, LiteralNullExpression, LiteralNumericExpression, LiteralRegExpExpression, LiteralStringExpression, MemberExpression, NewExpression, NewTargetExpression, ObjectExpression, TemplateExpression, ThisExpression, UnaryExpression, UpdateExpression, YieldExpression, YieldGeneratorExpression); + var Statement = Union(BlockStatement, BreakStatement, ClassDeclaration, ContinueStatement, DebuggerStatement, EmptyStatement, ExpressionStatement, FunctionDeclaration, IfStatement, IterationStatement, LabeledStatement, ReturnStatement, SwitchStatement, SwitchStatementWithDefault, ThrowStatement, TryCatchStatement, TryFinallyStatement, VariableDeclarationStatement, WithStatement); + var ObjectProperty = Union(NamedObjectProperty, ShorthandProperty, SpreadProperty); + var Node = Union(ArrayAssignmentTarget, ArrayBinding, AssignmentTargetProperty, AssignmentTargetWithDefault, BindingProperty, BindingWithDefault, Block, CatchClause, ClassElement, Directive, ExportDeclaration, ExportFromSpecifier, ExportLocalSpecifier, Expression, FormalParameters, FunctionBody, ImportDeclaration, ImportSpecifier, MemberAssignmentTarget, ObjectAssignmentTarget, ObjectBinding, ObjectProperty, Program, PropertyName, SpreadElement, Statement, Super, SwitchCase, SwitchDefault, TemplateElement, VariableDeclaration, VariableDeclarator, VariableReference); + + ArrayAssignmentTarget.typeName = "ArrayAssignmentTarget"; + ArrayAssignmentTarget.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ArrayAssignmentTarget" }, + { name: "elements", type: List(Maybe(Union(AssignmentTargetWithDefault, Union(Union(ArrayAssignmentTarget, ObjectAssignmentTarget), Union(AssignmentTargetIdentifier, MemberAssignmentTarget))))) }, + { name: "rest", type: Maybe(Union(Union(ArrayAssignmentTarget, ObjectAssignmentTarget), Union(AssignmentTargetIdentifier, MemberAssignmentTarget))) } + ]; + + ArrayBinding.typeName = "ArrayBinding"; + ArrayBinding.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ArrayBinding" }, + { name: "elements", type: List(Maybe(Union(BindingWithDefault, Union(BindingIdentifier, Union(ArrayBinding, ObjectBinding))))) }, + { name: "rest", type: Maybe(Union(BindingIdentifier, Union(ArrayBinding, ObjectBinding))) } + ]; + + ArrayExpression.typeName = "ArrayExpression"; + ArrayExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ArrayExpression" }, + { name: "elements", type: List(Maybe(Union(Expression, SpreadElement))) } + ]; + + ArrowExpression.typeName = "ArrowExpression"; + ArrowExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ArrowExpression" }, + { name: "isAsync", type: BOOLEAN }, + { name: "params", type: FormalParameters }, + { name: "body", type: Union(Expression, FunctionBody) } + ]; + + AssignmentExpression.typeName = "AssignmentExpression"; + AssignmentExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "AssignmentExpression" }, + { name: "binding", type: Union(Union(ArrayAssignmentTarget, ObjectAssignmentTarget), Union(AssignmentTargetIdentifier, MemberAssignmentTarget)) }, + { name: "expression", type: Expression } + ]; + + AssignmentTargetIdentifier.typeName = "AssignmentTargetIdentifier"; + AssignmentTargetIdentifier.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "AssignmentTargetIdentifier" }, + { name: "name", type: STRING } + ]; + + AssignmentTargetPropertyIdentifier.typeName = "AssignmentTargetPropertyIdentifier"; + AssignmentTargetPropertyIdentifier.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "AssignmentTargetPropertyIdentifier" }, + { name: "binding", type: AssignmentTargetIdentifier }, + { name: "init", type: Maybe(Expression) } + ]; + + AssignmentTargetPropertyProperty.typeName = "AssignmentTargetPropertyProperty"; + AssignmentTargetPropertyProperty.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "AssignmentTargetPropertyProperty" }, + { name: "name", type: PropertyName }, + { name: "binding", type: Union(AssignmentTargetWithDefault, Union(Union(ArrayAssignmentTarget, ObjectAssignmentTarget), Union(AssignmentTargetIdentifier, MemberAssignmentTarget))) } + ]; + + AssignmentTargetWithDefault.typeName = "AssignmentTargetWithDefault"; + AssignmentTargetWithDefault.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "AssignmentTargetWithDefault" }, + { name: "binding", type: Union(Union(ArrayAssignmentTarget, ObjectAssignmentTarget), Union(AssignmentTargetIdentifier, MemberAssignmentTarget)) }, + { name: "init", type: Expression } + ]; + + AwaitExpression.typeName = "AwaitExpression"; + AwaitExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "AwaitExpression" }, + { name: "expression", type: Expression } + ]; + + BinaryExpression.typeName = "BinaryExpression"; + BinaryExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "BinaryExpression" }, + { name: "left", type: Expression }, + { name: "operator", type: BinaryOperator }, + { name: "right", type: Expression } + ]; + + BindingIdentifier.typeName = "BindingIdentifier"; + BindingIdentifier.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "BindingIdentifier" }, + { name: "name", type: STRING } + ]; + + BindingPropertyIdentifier.typeName = "BindingPropertyIdentifier"; + BindingPropertyIdentifier.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "BindingPropertyIdentifier" }, + { name: "binding", type: BindingIdentifier }, + { name: "init", type: Maybe(Expression) } + ]; + + BindingPropertyProperty.typeName = "BindingPropertyProperty"; + BindingPropertyProperty.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "BindingPropertyProperty" }, + { name: "name", type: PropertyName }, + { name: "binding", type: Union(BindingWithDefault, Union(BindingIdentifier, Union(ArrayBinding, ObjectBinding))) } + ]; + + BindingWithDefault.typeName = "BindingWithDefault"; + BindingWithDefault.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "BindingWithDefault" }, + { name: "binding", type: Union(BindingIdentifier, Union(ArrayBinding, ObjectBinding)) }, + { name: "init", type: Expression } + ]; + + Block.typeName = "Block"; + Block.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "Block" }, + { name: "statements", type: List(Statement) } + ]; + + BlockStatement.typeName = "BlockStatement"; + BlockStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "BlockStatement" }, + { name: "block", type: Block } + ]; + + BreakStatement.typeName = "BreakStatement"; + BreakStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "BreakStatement" }, + { name: "label", type: Maybe(STRING) } + ]; + + CallExpression.typeName = "CallExpression"; + CallExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "CallExpression" }, + { name: "callee", type: Union(Expression, Super) }, + { name: "arguments", type: List(Union(Expression, SpreadElement)) } + ]; + + CatchClause.typeName = "CatchClause"; + CatchClause.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "CatchClause" }, + { name: "binding", type: Union(BindingIdentifier, Union(ArrayBinding, ObjectBinding)) }, + { name: "body", type: Block } + ]; + + ClassDeclaration.typeName = "ClassDeclaration"; + ClassDeclaration.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ClassDeclaration" }, + { name: "name", type: BindingIdentifier }, + { name: "super", type: Maybe(Expression) }, + { name: "elements", type: List(ClassElement) } + ]; + + ClassElement.typeName = "ClassElement"; + ClassElement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ClassElement" }, + { name: "isStatic", type: BOOLEAN }, + { name: "method", type: MethodDefinition } + ]; + + ClassExpression.typeName = "ClassExpression"; + ClassExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ClassExpression" }, + { name: "name", type: Maybe(BindingIdentifier) }, + { name: "super", type: Maybe(Expression) }, + { name: "elements", type: List(ClassElement) } + ]; + + CompoundAssignmentExpression.typeName = "CompoundAssignmentExpression"; + CompoundAssignmentExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "CompoundAssignmentExpression" }, + { name: "binding", type: Union(AssignmentTargetIdentifier, MemberAssignmentTarget) }, + { name: "operator", type: CompoundAssignmentOperator }, + { name: "expression", type: Expression } + ]; + + ComputedMemberAssignmentTarget.typeName = "ComputedMemberAssignmentTarget"; + ComputedMemberAssignmentTarget.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ComputedMemberAssignmentTarget" }, + { name: "object", type: Union(Expression, Super) }, + { name: "expression", type: Expression } + ]; + + ComputedMemberExpression.typeName = "ComputedMemberExpression"; + ComputedMemberExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ComputedMemberExpression" }, + { name: "object", type: Union(Expression, Super) }, + { name: "expression", type: Expression } + ]; + + ComputedPropertyName.typeName = "ComputedPropertyName"; + ComputedPropertyName.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ComputedPropertyName" }, + { name: "expression", type: Expression } + ]; + + ConditionalExpression.typeName = "ConditionalExpression"; + ConditionalExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ConditionalExpression" }, + { name: "test", type: Expression }, + { name: "consequent", type: Expression }, + { name: "alternate", type: Expression } + ]; + + ContinueStatement.typeName = "ContinueStatement"; + ContinueStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ContinueStatement" }, + { name: "label", type: Maybe(STRING) } + ]; + + DataProperty.typeName = "DataProperty"; + DataProperty.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "DataProperty" }, + { name: "name", type: PropertyName }, + { name: "expression", type: Expression } + ]; + + DebuggerStatement.typeName = "DebuggerStatement"; + DebuggerStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "DebuggerStatement" } + ]; + + Directive.typeName = "Directive"; + Directive.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "Directive" }, + { name: "rawValue", type: STRING } + ]; + + DoWhileStatement.typeName = "DoWhileStatement"; + DoWhileStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "DoWhileStatement" }, + { name: "body", type: Statement }, + { name: "test", type: Expression } + ]; + + EmptyStatement.typeName = "EmptyStatement"; + EmptyStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "EmptyStatement" } + ]; + + Export.typeName = "Export"; + Export.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "Export" }, + { name: "declaration", type: Union(ClassDeclaration, FunctionDeclaration, VariableDeclaration) } + ]; + + ExportAllFrom.typeName = "ExportAllFrom"; + ExportAllFrom.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ExportAllFrom" }, + { name: "moduleSpecifier", type: STRING } + ]; + + ExportDefault.typeName = "ExportDefault"; + ExportDefault.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ExportDefault" }, + { name: "body", type: Union(ClassDeclaration, Expression, FunctionDeclaration) } + ]; + + ExportFrom.typeName = "ExportFrom"; + ExportFrom.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ExportFrom" }, + { name: "namedExports", type: List(ExportFromSpecifier) }, + { name: "moduleSpecifier", type: STRING } + ]; + + ExportFromSpecifier.typeName = "ExportFromSpecifier"; + ExportFromSpecifier.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ExportFromSpecifier" }, + { name: "name", type: STRING }, + { name: "exportedName", type: Maybe(STRING) } + ]; + + ExportLocalSpecifier.typeName = "ExportLocalSpecifier"; + ExportLocalSpecifier.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ExportLocalSpecifier" }, + { name: "name", type: IdentifierExpression }, + { name: "exportedName", type: Maybe(STRING) } + ]; + + ExportLocals.typeName = "ExportLocals"; + ExportLocals.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ExportLocals" }, + { name: "namedExports", type: List(ExportLocalSpecifier) } + ]; + + ExpressionStatement.typeName = "ExpressionStatement"; + ExpressionStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ExpressionStatement" }, + { name: "expression", type: Expression } + ]; + + ForAwaitStatement.typeName = "ForAwaitStatement"; + ForAwaitStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ForAwaitStatement" }, + { name: "left", type: Union(Union(Union(ArrayAssignmentTarget, ObjectAssignmentTarget), Union(AssignmentTargetIdentifier, MemberAssignmentTarget)), VariableDeclaration) }, + { name: "right", type: Expression }, + { name: "body", type: Statement } + ]; + + ForInStatement.typeName = "ForInStatement"; + ForInStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ForInStatement" }, + { name: "left", type: Union(Union(Union(ArrayAssignmentTarget, ObjectAssignmentTarget), Union(AssignmentTargetIdentifier, MemberAssignmentTarget)), VariableDeclaration) }, + { name: "right", type: Expression }, + { name: "body", type: Statement } + ]; + + ForOfStatement.typeName = "ForOfStatement"; + ForOfStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ForOfStatement" }, + { name: "left", type: Union(Union(Union(ArrayAssignmentTarget, ObjectAssignmentTarget), Union(AssignmentTargetIdentifier, MemberAssignmentTarget)), VariableDeclaration) }, + { name: "right", type: Expression }, + { name: "body", type: Statement } + ]; + + ForStatement.typeName = "ForStatement"; + ForStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ForStatement" }, + { name: "init", type: Maybe(Union(Expression, VariableDeclaration)) }, + { name: "test", type: Maybe(Expression) }, + { name: "update", type: Maybe(Expression) }, + { name: "body", type: Statement } + ]; + + FormalParameters.typeName = "FormalParameters"; + FormalParameters.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "FormalParameters" }, + { name: "items", type: List(Union(BindingWithDefault, Union(BindingIdentifier, Union(ArrayBinding, ObjectBinding)))) }, + { name: "rest", type: Maybe(Union(BindingIdentifier, Union(ArrayBinding, ObjectBinding))) } + ]; + + FunctionBody.typeName = "FunctionBody"; + FunctionBody.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "FunctionBody" }, + { name: "directives", type: List(Directive) }, + { name: "statements", type: List(Statement) } + ]; + + FunctionDeclaration.typeName = "FunctionDeclaration"; + FunctionDeclaration.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "FunctionDeclaration" }, + { name: "isAsync", type: BOOLEAN }, + { name: "isGenerator", type: BOOLEAN }, + { name: "name", type: BindingIdentifier }, + { name: "params", type: FormalParameters }, + { name: "body", type: FunctionBody } + ]; + + FunctionExpression.typeName = "FunctionExpression"; + FunctionExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "FunctionExpression" }, + { name: "isAsync", type: BOOLEAN }, + { name: "isGenerator", type: BOOLEAN }, + { name: "name", type: Maybe(BindingIdentifier) }, + { name: "params", type: FormalParameters }, + { name: "body", type: FunctionBody } + ]; + + Getter.typeName = "Getter"; + Getter.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "Getter" }, + { name: "name", type: PropertyName }, + { name: "body", type: FunctionBody } + ]; + + IdentifierExpression.typeName = "IdentifierExpression"; + IdentifierExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "IdentifierExpression" }, + { name: "name", type: STRING } + ]; + + IfStatement.typeName = "IfStatement"; + IfStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "IfStatement" }, + { name: "test", type: Expression }, + { name: "consequent", type: Statement }, + { name: "alternate", type: Maybe(Statement) } + ]; + + Import.typeName = "Import"; + Import.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "Import" }, + { name: "defaultBinding", type: Maybe(BindingIdentifier) }, + { name: "namedImports", type: List(ImportSpecifier) }, + { name: "moduleSpecifier", type: STRING } + ]; + + ImportNamespace.typeName = "ImportNamespace"; + ImportNamespace.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ImportNamespace" }, + { name: "defaultBinding", type: Maybe(BindingIdentifier) }, + { name: "namespaceBinding", type: BindingIdentifier }, + { name: "moduleSpecifier", type: STRING } + ]; + + ImportSpecifier.typeName = "ImportSpecifier"; + ImportSpecifier.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ImportSpecifier" }, + { name: "name", type: Maybe(STRING) }, + { name: "binding", type: BindingIdentifier } + ]; + + LabeledStatement.typeName = "LabeledStatement"; + LabeledStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "LabeledStatement" }, + { name: "label", type: STRING }, + { name: "body", type: Statement } + ]; + + LiteralBooleanExpression.typeName = "LiteralBooleanExpression"; + LiteralBooleanExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "LiteralBooleanExpression" }, + { name: "value", type: BOOLEAN } + ]; + + LiteralInfinityExpression.typeName = "LiteralInfinityExpression"; + LiteralInfinityExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "LiteralInfinityExpression" } + ]; + + LiteralNullExpression.typeName = "LiteralNullExpression"; + LiteralNullExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "LiteralNullExpression" } + ]; + + LiteralNumericExpression.typeName = "LiteralNumericExpression"; + LiteralNumericExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "LiteralNumericExpression" }, + { name: "value", type: DOUBLE } + ]; + + LiteralRegExpExpression.typeName = "LiteralRegExpExpression"; + LiteralRegExpExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "LiteralRegExpExpression" }, + { name: "pattern", type: STRING }, + { name: "global", type: BOOLEAN }, + { name: "ignoreCase", type: BOOLEAN }, + { name: "multiLine", type: BOOLEAN }, + { name: "dotAll", type: BOOLEAN }, + { name: "unicode", type: BOOLEAN }, + { name: "sticky", type: BOOLEAN } + ]; + + LiteralStringExpression.typeName = "LiteralStringExpression"; + LiteralStringExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "LiteralStringExpression" }, + { name: "value", type: STRING } + ]; + + Method.typeName = "Method"; + Method.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "Method" }, + { name: "isAsync", type: BOOLEAN }, + { name: "isGenerator", type: BOOLEAN }, + { name: "name", type: PropertyName }, + { name: "params", type: FormalParameters }, + { name: "body", type: FunctionBody } + ]; + + Module.typeName = "Module"; + Module.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "Module" }, + { name: "directives", type: List(Directive) }, + { name: "items", type: List(Union(ExportDeclaration, ImportDeclaration, Statement)) } + ]; + + NewExpression.typeName = "NewExpression"; + NewExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "NewExpression" }, + { name: "callee", type: Expression }, + { name: "arguments", type: List(Union(Expression, SpreadElement)) } + ]; + + NewTargetExpression.typeName = "NewTargetExpression"; + NewTargetExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "NewTargetExpression" } + ]; + + ObjectAssignmentTarget.typeName = "ObjectAssignmentTarget"; + ObjectAssignmentTarget.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ObjectAssignmentTarget" }, + { name: "properties", type: List(AssignmentTargetProperty) }, + { name: "rest", type: Maybe(Union(Union(ArrayAssignmentTarget, ObjectAssignmentTarget), Union(AssignmentTargetIdentifier, MemberAssignmentTarget))) } + ]; + + ObjectBinding.typeName = "ObjectBinding"; + ObjectBinding.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ObjectBinding" }, + { name: "properties", type: List(BindingProperty) }, + { name: "rest", type: Maybe(Union(BindingIdentifier, Union(ArrayBinding, ObjectBinding))) } + ]; + + ObjectExpression.typeName = "ObjectExpression"; + ObjectExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ObjectExpression" }, + { name: "properties", type: List(ObjectProperty) } + ]; + + ReturnStatement.typeName = "ReturnStatement"; + ReturnStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ReturnStatement" }, + { name: "expression", type: Maybe(Expression) } + ]; + + Script.typeName = "Script"; + Script.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "Script" }, + { name: "directives", type: List(Directive) }, + { name: "statements", type: List(Statement) } + ]; + + Setter.typeName = "Setter"; + Setter.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "Setter" }, + { name: "name", type: PropertyName }, + { name: "param", type: Union(BindingWithDefault, Union(BindingIdentifier, Union(ArrayBinding, ObjectBinding))) }, + { name: "body", type: FunctionBody } + ]; + + ShorthandProperty.typeName = "ShorthandProperty"; + ShorthandProperty.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ShorthandProperty" }, + { name: "name", type: IdentifierExpression } + ]; + + SpreadElement.typeName = "SpreadElement"; + SpreadElement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "SpreadElement" }, + { name: "expression", type: Expression } + ]; + + SpreadProperty.typeName = "SpreadProperty"; + SpreadProperty.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "SpreadProperty" }, + { name: "expression", type: Expression } + ]; + + StaticMemberAssignmentTarget.typeName = "StaticMemberAssignmentTarget"; + StaticMemberAssignmentTarget.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "StaticMemberAssignmentTarget" }, + { name: "object", type: Union(Expression, Super) }, + { name: "property", type: STRING } + ]; + + StaticMemberExpression.typeName = "StaticMemberExpression"; + StaticMemberExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "StaticMemberExpression" }, + { name: "object", type: Union(Expression, Super) }, + { name: "property", type: STRING } + ]; + + StaticPropertyName.typeName = "StaticPropertyName"; + StaticPropertyName.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "StaticPropertyName" }, + { name: "value", type: STRING } + ]; + + Super.typeName = "Super"; + Super.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "Super" } + ]; + + SwitchCase.typeName = "SwitchCase"; + SwitchCase.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "SwitchCase" }, + { name: "test", type: Expression }, + { name: "consequent", type: List(Statement) } + ]; + + SwitchDefault.typeName = "SwitchDefault"; + SwitchDefault.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "SwitchDefault" }, + { name: "consequent", type: List(Statement) } + ]; + + SwitchStatement.typeName = "SwitchStatement"; + SwitchStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "SwitchStatement" }, + { name: "discriminant", type: Expression }, + { name: "cases", type: List(SwitchCase) } + ]; + + SwitchStatementWithDefault.typeName = "SwitchStatementWithDefault"; + SwitchStatementWithDefault.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "SwitchStatementWithDefault" }, + { name: "discriminant", type: Expression }, + { name: "preDefaultCases", type: List(SwitchCase) }, + { name: "defaultCase", type: SwitchDefault }, + { name: "postDefaultCases", type: List(SwitchCase) } + ]; + + TemplateElement.typeName = "TemplateElement"; + TemplateElement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "TemplateElement" }, + { name: "rawValue", type: STRING } + ]; + + TemplateExpression.typeName = "TemplateExpression"; + TemplateExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "TemplateExpression" }, + { name: "tag", type: Maybe(Expression) }, + { name: "elements", type: List(Union(Expression, TemplateElement)) } + ]; + + ThisExpression.typeName = "ThisExpression"; + ThisExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ThisExpression" } + ]; + + ThrowStatement.typeName = "ThrowStatement"; + ThrowStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "ThrowStatement" }, + { name: "expression", type: Expression } + ]; + + TryCatchStatement.typeName = "TryCatchStatement"; + TryCatchStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "TryCatchStatement" }, + { name: "body", type: Block }, + { name: "catchClause", type: CatchClause } + ]; + + TryFinallyStatement.typeName = "TryFinallyStatement"; + TryFinallyStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "TryFinallyStatement" }, + { name: "body", type: Block }, + { name: "catchClause", type: Maybe(CatchClause) }, + { name: "finalizer", type: Block } + ]; + + UnaryExpression.typeName = "UnaryExpression"; + UnaryExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "UnaryExpression" }, + { name: "operator", type: UnaryOperator }, + { name: "operand", type: Expression } + ]; + + UpdateExpression.typeName = "UpdateExpression"; + UpdateExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "UpdateExpression" }, + { name: "isPrefix", type: BOOLEAN }, + { name: "operator", type: UpdateOperator }, + { name: "operand", type: Union(AssignmentTargetIdentifier, MemberAssignmentTarget) } + ]; + + VariableDeclaration.typeName = "VariableDeclaration"; + VariableDeclaration.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "VariableDeclaration" }, + { name: "kind", type: VariableDeclarationKind }, + { name: "declarators", type: List(VariableDeclarator) } + ]; + + VariableDeclarationStatement.typeName = "VariableDeclarationStatement"; + VariableDeclarationStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "VariableDeclarationStatement" }, + { name: "declaration", type: VariableDeclaration } + ]; + + VariableDeclarator.typeName = "VariableDeclarator"; + VariableDeclarator.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "VariableDeclarator" }, + { name: "binding", type: Union(BindingIdentifier, Union(ArrayBinding, ObjectBinding)) }, + { name: "init", type: Maybe(Expression) } + ]; + + WhileStatement.typeName = "WhileStatement"; + WhileStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "WhileStatement" }, + { name: "test", type: Expression }, + { name: "body", type: Statement } + ]; + + WithStatement.typeName = "WithStatement"; + WithStatement.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "WithStatement" }, + { name: "object", type: Expression }, + { name: "body", type: Statement } + ]; + + YieldExpression.typeName = "YieldExpression"; + YieldExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "YieldExpression" }, + { name: "expression", type: Maybe(Expression) } + ]; + + YieldGeneratorExpression.typeName = "YieldGeneratorExpression"; + YieldGeneratorExpression.fields = [ + { name: "type", type: Const(TYPE_INDICATOR), value: "YieldGeneratorExpression" }, + { name: "expression", type: Expression } + ]; + + return SPEC; +}()); +}); + +var __pika_web_default_export_for_treeshaking__ = /*@__PURE__*/getDefaultExportFromCjs(dist); + +export default __pika_web_default_export_for_treeshaking__; diff --git a/docs/dist/App.js b/docs/dist/App.js index 98d2a884..f7b2a691 100644 --- a/docs/dist/App.js +++ b/docs/dist/App.js @@ -1,18 +1,22 @@ import React, {useCallback, useEffect, useLayoutEffect, useRef, useState} from "../_snowpack/pkg/react.js"; import logo from "./logo.svg.proxy.js"; -import * as strudel from "../_snowpack/link/strudel.js"; import cx from "./cx.js"; import * as Tone from "../_snowpack/pkg/tone.js"; import useCycle from "./useCycle.js"; import * as tunes from "./tunes.js"; -import * as krill from "./parse.js"; +import * as parser from "./parse.js"; import CodeMirror from "./CodeMirror.js"; -const {tetris, tetrisMini, tetrisHaskell} = tunes; -const {sequence, pure, reify, slowcat, fastcat, cat, stack, silence} = strudel; -const {mini, h} = krill; -const parse = (code) => eval(code); -const synth = new Tone.PolySynth().toDestination(); -synth.set({ +import hot from "../hot.js"; +import {isNote} from "../_snowpack/pkg/tone.js"; +const {tetris, tetrisRev, shapeShifted} = tunes; +const {parse} = parser; +const getHotCode = async () => { + return fetch("/hot.js").then((res) => res.text()).then((src) => { + return src.split("export default").slice(-1)[0].trim(); + }); +}; +const defaultSynth = new Tone.PolySynth().toDestination(); +defaultSynth.set({ oscillator: {type: "triangle"}, envelope: { release: 0.01 @@ -20,92 +24,138 @@ synth.set({ }); function App() { const [mode, setMode] = useState("javascript"); - const [code, setCode] = useState(tetrisHaskell); + const [code, setCode] = useState(shapeShifted); const [log, setLog] = useState(""); const logBox = useRef(); const [error, setError] = useState(); const [pattern, setPattern] = useState(); + const [activePattern, setActivePattern] = useState(); + const [isHot, setIsHot] = useState(false); + const pushLog = (message) => setLog((log2) => log2 + `${log2 ? "\n\n" : ""}${message}`); const logCycle = (_events, cycle2) => { if (_events.length) { - setLog((log2) => log2 + `${log2 ? "\n\n" : ""}# cycle ${cycle2} + pushLog(`# cycle ${cycle2} ` + _events.map((e) => e.show()).join("\n")); } }; const cycle = useCycle({ onEvent: useCallback((time, event) => { - synth.triggerAttackRelease(event.value, event.duration, time); + try { + if (typeof event.value === "string") { + if (!isNote(event.value)) { + throw new Error("not a note: " + event.value); + } + defaultSynth.triggerAttackRelease(event.value, event.duration, time); + } else { + const {onTrigger} = event.value; + onTrigger(time, event); + } + } catch (err) { + console.warn(err); + err.message = "unplayable event: " + err?.message; + pushLog(err.message); + } }, []), onQuery: useCallback((span) => { try { - return pattern?.query(span) || []; + return activePattern?.query(span) || []; } catch (err) { setError(err); return []; } - }, [pattern]), - onSchedule: useCallback((_events, cycle2) => logCycle(_events, cycle2), [pattern]), - ready: !!pattern + }, [activePattern]), + onSchedule: useCallback((_events, cycle2) => logCycle(_events, cycle2), [activePattern]), + ready: !!activePattern }); - useEffect(() => { - try { - let _pattern; - try { - _pattern = h(code); - setMode("pegjs"); - } catch (err) { - setMode("javascript"); - _pattern = parse(code); - if (_pattern?.constructor?.name !== "Pattern") { - const message = `got "${typeof _pattern}" instead of pattern`; - throw new Error(message + (typeof _pattern === "function" ? "did you foget to call a function?" : "")); - } + useLayoutEffect(() => { + const handleKeyPress = (e) => { + if (e.ctrlKey && e.code === "Enter") { + setActivePattern(() => pattern); + !cycle.started && cycle.start(); } - setPattern(() => _pattern); + }; + document.addEventListener("keypress", handleKeyPress); + return () => document.removeEventListener("keypress", handleKeyPress); + }, [pattern]); + useEffect(() => { + let _code = code; + if (isHot) { + if (typeof hot !== "string") { + getHotCode().then((_code2) => { + setCode(_code2); + setMode("javascript"); + }); + setActivePattern(hot); + return; + } else { + _code = hot; + setCode(_code); + } + } + try { + const parsed = parse(_code); + setPattern(() => parsed.pattern); + if (!activePattern || isHot) { + setActivePattern(() => parsed.pattern); + } + setMode(parsed.mode); setError(void 0); } catch (err) { console.warn(err); setError(err); } - }, [code]); + }, [code, isHot]); useLayoutEffect(() => { logBox.current.scrollTop = logBox.current?.scrollHeight; }, [log]); return /* @__PURE__ */ React.createElement("div", { className: "h-screen bg-slate-900 flex flex-col" }, /* @__PURE__ */ React.createElement("header", { - className: "flex-none w-full h-16 px-2 flex items-center space-x-2 border-b border-gray-200 bg-white" + className: "flex-none w-full h-16 px-2 flex border-b border-gray-200 bg-white justify-between" + }, /* @__PURE__ */ React.createElement("div", { + className: "flex items-center space-x-2" }, /* @__PURE__ */ React.createElement("img", { src: logo, className: "Tidal-logo w-16 h-16", alt: "logo" }), /* @__PURE__ */ React.createElement("h1", { className: "text-2xl" - }, "Strudel REPL")), /* @__PURE__ */ React.createElement("section", { + }, "Strudel REPL")), window.location.href.includes("http://localhost:8080") && /* @__PURE__ */ React.createElement("button", { + onClick: () => { + if (isHot || confirm("Really switch? You might loose your current pattern..")) { + setIsHot((h) => !h); + } + } + }, isHot ? "🔥" : " ", " toggle hot mode")), /* @__PURE__ */ React.createElement("section", { className: "grow flex flex-col p-2 text-gray-100" }, /* @__PURE__ */ React.createElement("div", { className: "grow relative" }, /* @__PURE__ */ React.createElement("div", { - className: cx("h-full bg-slate-600", error ? "focus:ring-red-500" : "focus:ring-slate-800") + className: cx("h-full bg-[#2A3236]", error ? "focus:ring-red-500" : "focus:ring-slate-800") }, /* @__PURE__ */ React.createElement(CodeMirror, { value: code, + readOnly: isHot, options: { mode, theme: "material", lineNumbers: true }, onChange: (_, __, value) => { - setLog((log2) => log2 + `${log2 ? "\n\n" : ""}✏️ edit -${code} -${value}`); - setCode(value); + if (!isHot) { + setCode(value); + } } - })), error && /* @__PURE__ */ React.createElement("div", { + }), /* @__PURE__ */ React.createElement("span", { + className: "p-4 absolute bottom-0 left-0 text-xs whitespace-pre" + }, !cycle.started ? `press ctrl+enter to play +` : !isHot && activePattern !== pattern ? `ctrl+enter to update +` : "no changes\n", !isHot && /* @__PURE__ */ React.createElement(React.Fragment, null, {pegjs: "mini"}[mode] || mode, " mode"), isHot && "🔥 hot mode: go to hot.js to edit pattern, then save")), error && /* @__PURE__ */ React.createElement("div", { className: "absolute right-2 bottom-2 text-red-500" }, error?.message || "unknown error")), /* @__PURE__ */ React.createElement("button", { className: "flex-none w-full border border-gray-700 p-2 bg-slate-700 hover:bg-slate-500", onClick: () => cycle.toggle() }, cycle.started ? "pause" : "play"), /* @__PURE__ */ React.createElement("textarea", { - className: "grow bg-[#283237] border-0", + className: "grow bg-[#283237] border-0 text-xs", value: log, readOnly: true, ref: logBox, diff --git a/docs/dist/parse.js b/docs/dist/parse.js index 3329c590..0baece74 100644 --- a/docs/dist/parse.js +++ b/docs/dist/parse.js @@ -1,7 +1,11 @@ import * as krill from "../_snowpack/link/repl/krill-parser.js"; import * as strudel from "../_snowpack/link/strudel.js"; import {Scale, Note, Interval} from "../_snowpack/pkg/@tonaljs/tonal.js"; -const {sequence, stack, silence, Fraction, pure} = strudel; +import "./tone.js"; +import * as toneStuff from "./tone.js"; +import shapeshifter from "./shapeshifter.js"; +const {pure, stack, slowcat, fastcat, cat, sequence, polymeter, pm, polyrhythm, pr, silence, Fraction} = strudel; +const {autofilter, filter, gain} = toneStuff; function reify(thing) { if (thing?.constructor?.name === "Pattern") { return thing; @@ -57,7 +61,7 @@ export function patternifyAST(ast) { return step; } const octaves = Math.floor(step / intervals.length); - const mod = (n, m) => n < 0 ? mod(n + m, m) : n % m; + const mod = (n, m2) => n < 0 ? mod(n + m2, m2) : n % m2; const index = mod(step, intervals.length); const interval = Interval.add(intervals[index], Interval.fromSemitones(octaves * 12)); return Note.transpose(tonic, interval || "1P"); @@ -74,7 +78,25 @@ export const mini = (...strings) => { })); return pattern; }; +const m = mini; export const h = (string) => { const ast = krill.parse(string); return patternifyAST(ast); }; +export const parse = (code) => { + let _pattern; + let mode; + try { + _pattern = h(code); + mode = "pegjs"; + } catch (err) { + mode = "javascript"; + code = shapeshifter(code); + _pattern = eval(code); + if (_pattern?.constructor?.name !== "Pattern") { + const message = `got "${typeof _pattern}" instead of pattern`; + throw new Error(message + (typeof _pattern === "function" ? ", did you forget to call a function?" : ".")); + } + } + return {mode, pattern: _pattern}; +}; diff --git a/docs/dist/shapeshifter.js b/docs/dist/shapeshifter.js new file mode 100644 index 00000000..a37cd15d --- /dev/null +++ b/docs/dist/shapeshifter.js @@ -0,0 +1,26 @@ +import { parseScript } from './shift-parser/index.js'; // npm module does not work in the browser +import traverser from './shift-traverser/index.js'; // npm module does not work in the browser +const { replace } = traverser; +import { LiteralStringExpression, IdentifierExpression } from '../_snowpack/pkg/shift-ast.js'; +import codegen from '../_snowpack/pkg/shift-codegen.js'; + +const isNote = (name) => /^[a-gC-G][bs]?[0-9]$/.test(name); + +export default (code) => { + const ast = parseScript(code); + const shifted = replace(ast, { + enter(node, parent) { + // replace identifiers that are a note with a note string + if (node.type === 'IdentifierExpression') { + if (isNote(node.name)) { + const value = node.name[1] === 's' ? node.name.replace('s', '#') : node.name; + return new LiteralStringExpression({ value }); + } + if (node.name === 'r') { + return new IdentifierExpression({ name: 'silence' }); + } + } + }, + }); + return codegen(shifted); +}; diff --git a/docs/dist/shift-parser/early-error-state.js b/docs/dist/shift-parser/early-error-state.js new file mode 100644 index 00000000..b15f5433 --- /dev/null +++ b/docs/dist/shift-parser/early-error-state.js @@ -0,0 +1,409 @@ +/** + * Copyright 2014 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import MultiMap from '../../_snowpack/pkg/multimap.js'; + +function addEach(thisMap, ...otherMaps) { + otherMaps.forEach(otherMap => { + otherMap.forEachEntry((v, k) => { + thisMap.set.apply(thisMap, [k].concat(v)); + }); + }); + return thisMap; +} + +let identity; // initialised below EarlyErrorState + +export class EarlyErrorState { + + constructor() { + this.errors = []; + // errors that are only errors in strict mode code + this.strictErrors = []; + + // Label values used in LabeledStatement nodes; cleared at function boundaries + this.usedLabelNames = []; + + // BreakStatement nodes; cleared at iteration; switch; and function boundaries + this.freeBreakStatements = []; + // ContinueStatement nodes; cleared at + this.freeContinueStatements = []; + + // labeled BreakStatement nodes; cleared at LabeledStatement with same Label and function boundaries + this.freeLabeledBreakStatements = []; + // labeled ContinueStatement nodes; cleared at labeled iteration statement with same Label and function boundaries + this.freeLabeledContinueStatements = []; + + // NewTargetExpression nodes; cleared at function (besides arrow expression) boundaries + this.newTargetExpressions = []; + + // BindingIdentifier nodes; cleared at containing declaration node + this.boundNames = new MultiMap; + // BindingIdentifiers that were found to be in a lexical binding position + this.lexicallyDeclaredNames = new MultiMap; + // BindingIdentifiers that were the name of a FunctionDeclaration + this.functionDeclarationNames = new MultiMap; + // BindingIdentifiers that were found to be in a variable binding position + this.varDeclaredNames = new MultiMap; + // BindingIdentifiers that were found to be in a variable binding position + this.forOfVarDeclaredNames = []; + + // Names that this module exports + this.exportedNames = new MultiMap; + // Locally declared names that are referenced in export declarations + this.exportedBindings = new MultiMap; + + // CallExpressions with Super callee + this.superCallExpressions = []; + // SuperCall expressions in the context of a Method named "constructor" + this.superCallExpressionsInConstructorMethod = []; + // MemberExpressions with Super object + this.superPropertyExpressions = []; + + // YieldExpression and YieldGeneratorExpression nodes; cleared at function boundaries + this.yieldExpressions = []; + // AwaitExpression nodes; cleared at function boundaries + this.awaitExpressions = []; + } + + + addFreeBreakStatement(s) { + this.freeBreakStatements.push(s); + return this; + } + + addFreeLabeledBreakStatement(s) { + this.freeLabeledBreakStatements.push(s); + return this; + } + + clearFreeBreakStatements() { + this.freeBreakStatements = []; + return this; + } + + addFreeContinueStatement(s) { + this.freeContinueStatements.push(s); + return this; + } + + addFreeLabeledContinueStatement(s) { + this.freeLabeledContinueStatements.push(s); + return this; + } + + clearFreeContinueStatements() { + this.freeContinueStatements = []; + return this; + } + + enforceFreeBreakStatementErrors(createError) { + [].push.apply(this.errors, this.freeBreakStatements.map(createError)); + this.freeBreakStatements = []; + return this; + } + + enforceFreeLabeledBreakStatementErrors(createError) { + [].push.apply(this.errors, this.freeLabeledBreakStatements.map(createError)); + this.freeLabeledBreakStatements = []; + return this; + } + + enforceFreeContinueStatementErrors(createError) { + [].push.apply(this.errors, this.freeContinueStatements.map(createError)); + this.freeContinueStatements = []; + return this; + } + + enforceFreeLabeledContinueStatementErrors(createError) { + [].push.apply(this.errors, this.freeLabeledContinueStatements.map(createError)); + this.freeLabeledContinueStatements = []; + return this; + } + + + observeIterationLabel(label) { + this.usedLabelNames.push(label); + this.freeLabeledBreakStatements = this.freeLabeledBreakStatements.filter(s => s.label !== label); + this.freeLabeledContinueStatements = this.freeLabeledContinueStatements.filter(s => s.label !== label); + return this; + } + + observeNonIterationLabel(label) { + this.usedLabelNames.push(label); + this.freeLabeledBreakStatements = this.freeLabeledBreakStatements.filter(s => s.label !== label); + return this; + } + + clearUsedLabelNames() { + this.usedLabelNames = []; + return this; + } + + + observeSuperCallExpression(node) { + this.superCallExpressions.push(node); + return this; + } + + observeConstructorMethod() { + this.superCallExpressionsInConstructorMethod = this.superCallExpressions; + this.superCallExpressions = []; + return this; + } + + clearSuperCallExpressionsInConstructorMethod() { + this.superCallExpressionsInConstructorMethod = []; + return this; + } + + enforceSuperCallExpressions(createError) { + [].push.apply(this.errors, this.superCallExpressions.map(createError)); + [].push.apply(this.errors, this.superCallExpressionsInConstructorMethod.map(createError)); + this.superCallExpressions = []; + this.superCallExpressionsInConstructorMethod = []; + return this; + } + + enforceSuperCallExpressionsInConstructorMethod(createError) { + [].push.apply(this.errors, this.superCallExpressionsInConstructorMethod.map(createError)); + this.superCallExpressionsInConstructorMethod = []; + return this; + } + + + observeSuperPropertyExpression(node) { + this.superPropertyExpressions.push(node); + return this; + } + + clearSuperPropertyExpressions() { + this.superPropertyExpressions = []; + return this; + } + + enforceSuperPropertyExpressions(createError) { + [].push.apply(this.errors, this.superPropertyExpressions.map(createError)); + this.superPropertyExpressions = []; + return this; + } + + + observeNewTargetExpression(node) { + this.newTargetExpressions.push(node); + return this; + } + + clearNewTargetExpressions() { + this.newTargetExpressions = []; + return this; + } + + + bindName(name, node) { + this.boundNames.set(name, node); + return this; + } + + clearBoundNames() { + this.boundNames = new MultiMap; + return this; + } + + observeLexicalDeclaration() { + addEach(this.lexicallyDeclaredNames, this.boundNames); + this.boundNames = new MultiMap; + return this; + } + + observeLexicalBoundary() { + this.previousLexicallyDeclaredNames = this.lexicallyDeclaredNames; + this.lexicallyDeclaredNames = new MultiMap; + this.functionDeclarationNames = new MultiMap; + return this; + } + + enforceDuplicateLexicallyDeclaredNames(createError) { + this.lexicallyDeclaredNames.forEachEntry(nodes => { + if (nodes.length > 1) { + nodes.slice(1).forEach(dupeNode => { + this.addError(createError(dupeNode)); + }); + } + }); + return this; + } + + enforceConflictingLexicallyDeclaredNames(otherNames, createError) { + this.lexicallyDeclaredNames.forEachEntry((nodes, bindingName) => { + if (otherNames.has(bindingName)) { + nodes.forEach(conflictingNode => { + this.addError(createError(conflictingNode)); + }); + } + }); + return this; + } + + observeFunctionDeclaration() { + this.observeVarBoundary(); + addEach(this.functionDeclarationNames, this.boundNames); + this.boundNames = new MultiMap; + return this; + } + + functionDeclarationNamesAreLexical() { + addEach(this.lexicallyDeclaredNames, this.functionDeclarationNames); + this.functionDeclarationNames = new MultiMap; + return this; + } + + observeVarDeclaration() { + addEach(this.varDeclaredNames, this.boundNames); + this.boundNames = new MultiMap; + return this; + } + + recordForOfVars() { + this.varDeclaredNames.forEach(bindingIdentifier => { + this.forOfVarDeclaredNames.push(bindingIdentifier); + }); + return this; + } + + observeVarBoundary() { + this.lexicallyDeclaredNames = new MultiMap; + this.functionDeclarationNames = new MultiMap; + this.varDeclaredNames = new MultiMap; + this.forOfVarDeclaredNames = []; + return this; + } + + + exportName(name, node) { + this.exportedNames.set(name, node); + return this; + } + + exportDeclaredNames() { + addEach(this.exportedNames, this.lexicallyDeclaredNames, this.varDeclaredNames); + addEach(this.exportedBindings, this.lexicallyDeclaredNames, this.varDeclaredNames); + return this; + } + + exportBinding(name, node) { + this.exportedBindings.set(name, node); + return this; + } + + clearExportedBindings() { + this.exportedBindings = new MultiMap; + return this; + } + + + observeYieldExpression(node) { + this.yieldExpressions.push(node); + return this; + } + + clearYieldExpressions() { + this.yieldExpressions = []; + return this; + } + + observeAwaitExpression(node) { + this.awaitExpressions.push(node); + return this; + } + + clearAwaitExpressions() { + this.awaitExpressions = []; + return this; + } + + + addError(e) { + this.errors.push(e); + return this; + } + + addStrictError(e) { + this.strictErrors.push(e); + return this; + } + + enforceStrictErrors() { + [].push.apply(this.errors, this.strictErrors); + this.strictErrors = []; + return this; + } + + + // MONOID IMPLEMENTATION + + static empty() { + return identity; + } + + concat(s) { + if (this === identity) return s; + if (s === identity) return this; + [].push.apply(this.errors, s.errors); + [].push.apply(this.strictErrors, s.strictErrors); + [].push.apply(this.usedLabelNames, s.usedLabelNames); + [].push.apply(this.freeBreakStatements, s.freeBreakStatements); + [].push.apply(this.freeContinueStatements, s.freeContinueStatements); + [].push.apply(this.freeLabeledBreakStatements, s.freeLabeledBreakStatements); + [].push.apply(this.freeLabeledContinueStatements, s.freeLabeledContinueStatements); + [].push.apply(this.newTargetExpressions, s.newTargetExpressions); + addEach(this.boundNames, s.boundNames); + addEach(this.lexicallyDeclaredNames, s.lexicallyDeclaredNames); + addEach(this.functionDeclarationNames, s.functionDeclarationNames); + addEach(this.varDeclaredNames, s.varDeclaredNames); + [].push.apply(this.forOfVarDeclaredNames, s.forOfVarDeclaredNames); + addEach(this.exportedNames, s.exportedNames); + addEach(this.exportedBindings, s.exportedBindings); + [].push.apply(this.superCallExpressions, s.superCallExpressions); + [].push.apply(this.superCallExpressionsInConstructorMethod, s.superCallExpressionsInConstructorMethod); + [].push.apply(this.superPropertyExpressions, s.superPropertyExpressions); + [].push.apply(this.yieldExpressions, s.yieldExpressions); + [].push.apply(this.awaitExpressions, s.awaitExpressions); + return this; + } + +} + +identity = new EarlyErrorState; +Object.getOwnPropertyNames(EarlyErrorState.prototype).forEach(methodName => { + if (methodName === 'constructor') return; + Object.defineProperty(identity, methodName, { + value() { + return EarlyErrorState.prototype[methodName].apply(new EarlyErrorState, arguments); + }, + enumerable: false, + writable: true, + configurable: true, + }); +}); + +export class EarlyError extends Error { + constructor(node, message) { + super(message); + this.node = node; + this.message = message; + } +} diff --git a/docs/dist/shift-parser/early-errors.js b/docs/dist/shift-parser/early-errors.js new file mode 100644 index 00000000..9c230b8a --- /dev/null +++ b/docs/dist/shift-parser/early-errors.js @@ -0,0 +1,772 @@ +/** + * Copyright 2014 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import reduce, { MonoidalReducer } from '../shift-reducer/index.js'; +import { isStrictModeReservedWord } from './utils.js'; +import { ErrorMessages } from './errors.js'; + +import { EarlyErrorState, EarlyError } from './early-error-state.js'; + +function isStrictFunctionBody({ directives }) { + return directives.some(directive => directive.rawValue === 'use strict'); +} + +function isLabelledFunction(node) { + return node.type === 'LabeledStatement' && + (node.body.type === 'FunctionDeclaration' || isLabelledFunction(node.body)); +} + +function isIterationStatement(node) { + switch (node.type) { + case 'LabeledStatement': + return isIterationStatement(node.body); + case 'DoWhileStatement': + case 'ForInStatement': + case 'ForOfStatement': + case 'ForStatement': + case 'WhileStatement': + return true; + } + return false; +} + +function isSpecialMethod(methodDefinition) { + if (methodDefinition.name.type !== 'StaticPropertyName' || methodDefinition.name.value !== 'constructor') { + return false; + } + switch (methodDefinition.type) { + case 'Getter': + case 'Setter': + return true; + case 'Method': + return methodDefinition.isGenerator || methodDefinition.isAsync; + } + /* istanbul ignore next */ + throw new Error('not reached'); +} + + +function enforceDuplicateConstructorMethods(node, s) { + let ctors = node.elements.filter(e => + !e.isStatic && + e.method.type === 'Method' && + !e.method.isGenerator && + e.method.name.type === 'StaticPropertyName' && + e.method.name.value === 'constructor' + ); + if (ctors.length > 1) { + ctors.slice(1).forEach(ctor => { + s = s.addError(new EarlyError(ctor, 'Duplicate constructor method in class')); + }); + } + return s; +} + +const SUPERCALL_ERROR = node => new EarlyError(node, ErrorMessages.ILLEGAL_SUPER_CALL); +const SUPERPROPERTY_ERROR = node => new EarlyError(node, 'Member access on super must be in a method'); +const DUPLICATE_BINDING = node => new EarlyError(node, `Duplicate binding ${JSON.stringify(node.name)}`); +const FREE_CONTINUE = node => new EarlyError(node, 'Continue statement must be nested within an iteration statement'); +const UNBOUND_CONTINUE = node => new EarlyError(node, `Continue statement must be nested within an iteration statement with label ${JSON.stringify(node.label)}`); +const FREE_BREAK = node => new EarlyError(node, 'Break statement must be nested within an iteration statement or a switch statement'); +const UNBOUND_BREAK = node => new EarlyError(node, `Break statement must be nested within a statement with label ${JSON.stringify(node.label)}`); + +export class EarlyErrorChecker extends MonoidalReducer { + constructor() { + super(EarlyErrorState); + } + + reduceAssignmentExpression() { + return super.reduceAssignmentExpression(...arguments).clearBoundNames(); + } + + reduceAssignmentTargetIdentifier(node) { + let s = this.identity; + if (node.name === 'eval' || node.name === 'arguments' || isStrictModeReservedWord(node.name)) { + s = s.addStrictError(new EarlyError(node, `The identifier ${JSON.stringify(node.name)} must not be in binding position in strict mode`)); + } + return s; + } + + reduceArrowExpression(node, { params, body }) { + let isSimpleParameterList = node.params.rest == null && node.params.items.every(i => i.type === 'BindingIdentifier'); + params = params.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING); + if (node.body.type === 'FunctionBody') { + body = body.enforceConflictingLexicallyDeclaredNames(params.lexicallyDeclaredNames, DUPLICATE_BINDING); + if (isStrictFunctionBody(node.body)) { + params = params.enforceStrictErrors(); + body = body.enforceStrictErrors(); + } + } + params.yieldExpressions.forEach(n => { + params = params.addError(new EarlyError(n, 'Arrow parameters must not contain yield expressions')); + }); + params.awaitExpressions.forEach(n => { + params = params.addError(new EarlyError(n, 'Arrow parameters must not contain await expressions')); + }); + let s = super.reduceArrowExpression(node, { params, body }); + if (!isSimpleParameterList && node.body.type === 'FunctionBody' && isStrictFunctionBody(node.body)) { + s = s.addError(new EarlyError(node, 'Functions with non-simple parameter lists may not contain a "use strict" directive')); + } + s = s.clearYieldExpressions(); + s = s.clearAwaitExpressions(); + s = s.observeVarBoundary(); + return s; + } + + reduceAwaitExpression(node, { expression }) { + return expression.observeAwaitExpression(node); + } + + reduceBindingIdentifier(node) { + let s = this.identity; + if (node.name === 'eval' || node.name === 'arguments' || isStrictModeReservedWord(node.name)) { + s = s.addStrictError(new EarlyError(node, `The identifier ${JSON.stringify(node.name)} must not be in binding position in strict mode`)); + } + s = s.bindName(node.name, node); + return s; + } + + reduceBlock() { + let s = super.reduceBlock(...arguments); + s = s.functionDeclarationNamesAreLexical(); + s = s.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING); + s = s.enforceConflictingLexicallyDeclaredNames(s.varDeclaredNames, DUPLICATE_BINDING); + s = s.observeLexicalBoundary(); + return s; + } + + reduceBreakStatement(node) { + let s = super.reduceBreakStatement(...arguments); + s = node.label == null + ? s.addFreeBreakStatement(node) + : s.addFreeLabeledBreakStatement(node); + return s; + } + + reduceCallExpression(node) { + let s = super.reduceCallExpression(...arguments); + if (node.callee.type === 'Super') { + s = s.observeSuperCallExpression(node); + } + return s; + } + + reduceCatchClause(node, { binding, body }) { + binding = binding.observeLexicalDeclaration(); + binding = binding.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING); + binding = binding.enforceConflictingLexicallyDeclaredNames(body.previousLexicallyDeclaredNames, DUPLICATE_BINDING); + binding.lexicallyDeclaredNames.forEachEntry((nodes, bindingName) => { + if (body.varDeclaredNames.has(bindingName)) { + body.varDeclaredNames.get(bindingName).forEach(conflictingNode => { + if (body.forOfVarDeclaredNames.indexOf(conflictingNode) >= 0) { + binding = binding.addError(DUPLICATE_BINDING(conflictingNode)); + } + }); + } + }); + let s = super.reduceCatchClause(node, { binding, body }); + s = s.observeLexicalBoundary(); + return s; + } + + reduceClassDeclaration(node, { name, super: _super, elements }) { + let s = name.enforceStrictErrors(); + let sElements = this.append(...elements); + sElements = sElements.enforceStrictErrors(); + if (node.super != null) { + _super = _super.enforceStrictErrors(); + s = this.append(s, _super); + sElements = sElements.clearSuperCallExpressionsInConstructorMethod(); + } + s = this.append(s, sElements); + s = enforceDuplicateConstructorMethods(node, s); + s = s.observeLexicalDeclaration(); + return s; + } + + reduceClassElement(node) { + let s = super.reduceClassElement(...arguments); + if (!node.isStatic && isSpecialMethod(node.method)) { + s = s.addError(new EarlyError(node, ErrorMessages.ILLEGAL_CONSTRUCTORS)); + } + if (node.isStatic && node.method.name.type === 'StaticPropertyName' && node.method.name.value === 'prototype') { + s = s.addError(new EarlyError(node, 'Static class methods cannot be named "prototype"')); + } + return s; + } + + reduceClassExpression(node, { name, super: _super, elements }) { + let s = node.name == null ? this.identity : name.enforceStrictErrors(); + let sElements = this.append(...elements); + sElements = sElements.enforceStrictErrors(); + if (node.super != null) { + _super = _super.enforceStrictErrors(); + s = this.append(s, _super); + sElements = sElements.clearSuperCallExpressionsInConstructorMethod(); + } + s = this.append(s, sElements); + s = enforceDuplicateConstructorMethods(node, s); + s = s.clearBoundNames(); + return s; + } + + reduceCompoundAssignmentExpression() { + return super.reduceCompoundAssignmentExpression(...arguments).clearBoundNames(); + } + + reduceComputedMemberExpression(node) { + let s = super.reduceComputedMemberExpression(...arguments); + if (node.object.type === 'Super') { + s = s.observeSuperPropertyExpression(node); + } + return s; + } + + reduceContinueStatement(node) { + let s = super.reduceContinueStatement(...arguments); + s = node.label == null + ? s.addFreeContinueStatement(node) + : s.addFreeLabeledContinueStatement(node); + return s; + } + + reduceDoWhileStatement(node) { + let s = super.reduceDoWhileStatement(...arguments); + if (isLabelledFunction(node.body)) { + s = s.addError(new EarlyError(node.body, 'The body of a do-while statement must not be a labeled function declaration')); + } + s = s.clearFreeContinueStatements(); + s = s.clearFreeBreakStatements(); + return s; + } + + reduceExport() { + let s = super.reduceExport(...arguments); + s = s.functionDeclarationNamesAreLexical(); + s = s.exportDeclaredNames(); + return s; + } + + reduceExportFrom() { + let s = super.reduceExportFrom(...arguments); + s = s.clearExportedBindings(); + return s; + } + + reduceExportFromSpecifier(node) { + let s = super.reduceExportFromSpecifier(...arguments); + s = s.exportName(node.exportedName || node.name, node); + s = s.exportBinding(node.name, node); + return s; + } + + reduceExportLocalSpecifier(node) { + let s = super.reduceExportLocalSpecifier(...arguments); + s = s.exportName(node.exportedName || node.name.name, node); + s = s.exportBinding(node.name.name, node); + return s; + } + + reduceExportDefault(node) { + let s = super.reduceExportDefault(...arguments); + s = s.functionDeclarationNamesAreLexical(); + s = s.exportName('default', node); + return s; + } + + reduceFormalParameters() { + let s = super.reduceFormalParameters(...arguments); + s = s.observeLexicalDeclaration(); + return s; + } + + reduceForStatement(node, { init, test, update, body }) { + if (init != null) { + init = init.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING); + init = init.enforceConflictingLexicallyDeclaredNames(body.varDeclaredNames, DUPLICATE_BINDING); + } + let s = super.reduceForStatement(node, { init, test, update, body }); + if (node.init != null && node.init.type === 'VariableDeclaration' && node.init.kind === 'const') { + node.init.declarators.forEach(declarator => { + if (declarator.init == null) { + s = s.addError(new EarlyError(declarator, 'Constant lexical declarations must have an initialiser')); + } + }); + } + if (isLabelledFunction(node.body)) { + s = s.addError(new EarlyError(node.body, 'The body of a for statement must not be a labeled function declaration')); + } + s = s.clearFreeContinueStatements(); + s = s.clearFreeBreakStatements(); + s = s.observeLexicalBoundary(); + return s; + } + + reduceForInStatement(node, { left, right, body }) { + left = left.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING); + left = left.enforceConflictingLexicallyDeclaredNames(body.varDeclaredNames, DUPLICATE_BINDING); + let s = super.reduceForInStatement(node, { left, right, body }); + if (isLabelledFunction(node.body)) { + s = s.addError(new EarlyError(node.body, 'The body of a for-in statement must not be a labeled function declaration')); + } + s = s.clearFreeContinueStatements(); + s = s.clearFreeBreakStatements(); + s = s.observeLexicalBoundary(); + return s; + } + + reduceForOfStatement(node, { left, right, body }) { + left = left.recordForOfVars(); + left = left.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING); + left = left.enforceConflictingLexicallyDeclaredNames(body.varDeclaredNames, DUPLICATE_BINDING); + let s = super.reduceForOfStatement(node, { left, right, body }); + if (isLabelledFunction(node.body)) { + s = s.addError(new EarlyError(node.body, 'The body of a for-of statement must not be a labeled function declaration')); + } + s = s.clearFreeContinueStatements(); + s = s.clearFreeBreakStatements(); + s = s.observeLexicalBoundary(); + return s; + } + + reduceForAwaitStatement(node, { left, right, body }) { + left = left.recordForOfVars(); + left = left.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING); + left = left.enforceConflictingLexicallyDeclaredNames(body.varDeclaredNames, DUPLICATE_BINDING); + let s = super.reduceForOfStatement(node, { left, right, body }); + if (isLabelledFunction(node.body)) { + s = s.addError(new EarlyError(node.body, 'The body of a for-await statement must not be a labeled function declaration')); + } + s = s.clearFreeContinueStatements(); + s = s.clearFreeBreakStatements(); + s = s.observeLexicalBoundary(); + return s; + } + + reduceFunctionBody(node) { + let s = super.reduceFunctionBody(...arguments); + s = s.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING); + s = s.enforceConflictingLexicallyDeclaredNames(s.varDeclaredNames, DUPLICATE_BINDING); + s = s.enforceFreeContinueStatementErrors(FREE_CONTINUE); + s = s.enforceFreeLabeledContinueStatementErrors(UNBOUND_CONTINUE); + s = s.enforceFreeBreakStatementErrors(FREE_BREAK); + s = s.enforceFreeLabeledBreakStatementErrors(UNBOUND_BREAK); + s = s.clearUsedLabelNames(); + s = s.clearYieldExpressions(); + s = s.clearAwaitExpressions(); + if (isStrictFunctionBody(node)) { + s = s.enforceStrictErrors(); + } + return s; + } + + reduceFunctionDeclaration(node, { name, params, body }) { + let isSimpleParameterList = node.params.rest == null && node.params.items.every(i => i.type === 'BindingIdentifier'); + let addError = !isSimpleParameterList || node.isGenerator ? 'addError' : 'addStrictError'; + params.lexicallyDeclaredNames.forEachEntry(nodes => { + if (nodes.length > 1) { + nodes.slice(1).forEach(dupeNode => { + params = params[addError](DUPLICATE_BINDING(dupeNode)); + }); + } + }); + body = body.enforceConflictingLexicallyDeclaredNames(params.lexicallyDeclaredNames, DUPLICATE_BINDING); + body = body.enforceSuperCallExpressions(SUPERCALL_ERROR); + body = body.enforceSuperPropertyExpressions(SUPERPROPERTY_ERROR); + params = params.enforceSuperCallExpressions(SUPERCALL_ERROR); + params = params.enforceSuperPropertyExpressions(SUPERPROPERTY_ERROR); + if (node.isGenerator) { + params.yieldExpressions.forEach(n => { + params = params.addError(new EarlyError(n, 'Generator parameters must not contain yield expressions')); + }); + } + if (node.isAsync) { + params.awaitExpressions.forEach(n => { + params = params.addError(new EarlyError(n, 'Async function parameters must not contain await expressions')); + }); + } + params = params.clearNewTargetExpressions(); + body = body.clearNewTargetExpressions(); + if (isStrictFunctionBody(node.body)) { + params = params.enforceStrictErrors(); + body = body.enforceStrictErrors(); + } + let s = super.reduceFunctionDeclaration(node, { name, params, body }); + if (!isSimpleParameterList && isStrictFunctionBody(node.body)) { + s = s.addError(new EarlyError(node, 'Functions with non-simple parameter lists may not contain a "use strict" directive')); + } + s = s.clearYieldExpressions(); + s = s.clearAwaitExpressions(); + s = s.observeFunctionDeclaration(); + return s; + } + + reduceFunctionExpression(node, { name, params, body }) { + let isSimpleParameterList = node.params.rest == null && node.params.items.every(i => i.type === 'BindingIdentifier'); + let addError = !isSimpleParameterList || node.isGenerator ? 'addError' : 'addStrictError'; + params.lexicallyDeclaredNames.forEachEntry((nodes, bindingName) => { + if (nodes.length > 1) { + nodes.slice(1).forEach(dupeNode => { + params = params[addError](new EarlyError(dupeNode, `Duplicate binding ${JSON.stringify(bindingName)}`)); + }); + } + }); + body = body.enforceConflictingLexicallyDeclaredNames(params.lexicallyDeclaredNames, DUPLICATE_BINDING); + body = body.enforceSuperCallExpressions(SUPERCALL_ERROR); + body = body.enforceSuperPropertyExpressions(SUPERPROPERTY_ERROR); + params = params.enforceSuperCallExpressions(SUPERCALL_ERROR); + params = params.enforceSuperPropertyExpressions(SUPERPROPERTY_ERROR); + if (node.isGenerator) { + params.yieldExpressions.forEach(n => { + params = params.addError(new EarlyError(n, 'Generator parameters must not contain yield expressions')); + }); + } + if (node.isAsync) { + params.awaitExpressions.forEach(n => { + params = params.addError(new EarlyError(n, 'Async function parameters must not contain await expressions')); + }); + } + params = params.clearNewTargetExpressions(); + body = body.clearNewTargetExpressions(); + if (isStrictFunctionBody(node.body)) { + params = params.enforceStrictErrors(); + body = body.enforceStrictErrors(); + } + let s = super.reduceFunctionExpression(node, { name, params, body }); + if (!isSimpleParameterList && isStrictFunctionBody(node.body)) { + s = s.addError(new EarlyError(node, 'Functions with non-simple parameter lists may not contain a "use strict" directive')); + } + s = s.clearBoundNames(); + s = s.clearYieldExpressions(); + s = s.clearAwaitExpressions(); + s = s.observeVarBoundary(); + return s; + } + + reduceGetter(node, { name, body }) { + body = body.enforceSuperCallExpressions(SUPERCALL_ERROR); + body = body.clearSuperPropertyExpressions(); + body = body.clearNewTargetExpressions(); + if (isStrictFunctionBody(node.body)) { + body = body.enforceStrictErrors(); + } + let s = super.reduceGetter(node, { name, body }); + s = s.observeVarBoundary(); + return s; + } + + reduceIdentifierExpression(node) { + let s = this.identity; + if (isStrictModeReservedWord(node.name)) { + s = s.addStrictError(new EarlyError(node, `The identifier ${JSON.stringify(node.name)} must not be in expression position in strict mode`)); + } + return s; + } + + reduceIfStatement(node, { test, consequent, alternate }) { + if (isLabelledFunction(node.consequent)) { + consequent = consequent.addError(new EarlyError(node.consequent, 'The consequent of an if statement must not be a labeled function declaration')); + } + if (node.alternate != null && isLabelledFunction(node.alternate)) { + alternate = alternate.addError(new EarlyError(node.alternate, 'The alternate of an if statement must not be a labeled function declaration')); + } + if (node.consequent.type === 'FunctionDeclaration') { + consequent = consequent.addStrictError(new EarlyError(node.consequent, 'FunctionDeclarations in IfStatements are disallowed in strict mode')); + consequent = consequent.observeLexicalBoundary(); + } + if (node.alternate != null && node.alternate.type === 'FunctionDeclaration') { + alternate = alternate.addStrictError(new EarlyError(node.alternate, 'FunctionDeclarations in IfStatements are disallowed in strict mode')); + alternate = alternate.observeLexicalBoundary(); + } + return super.reduceIfStatement(node, { test, consequent, alternate }); + } + + reduceImport() { + let s = super.reduceImport(...arguments); + s = s.observeLexicalDeclaration(); + return s; + } + + reduceImportNamespace() { + let s = super.reduceImportNamespace(...arguments); + s = s.observeLexicalDeclaration(); + return s; + } + + reduceLabeledStatement(node) { + let s = super.reduceLabeledStatement(...arguments); + if (node.label === 'yield' || isStrictModeReservedWord(node.label)) { + s = s.addStrictError(new EarlyError(node, `The identifier ${JSON.stringify(node.label)} must not be in label position in strict mode`)); + } + if (s.usedLabelNames.indexOf(node.label) >= 0) { + s = s.addError(new EarlyError(node, `Label ${JSON.stringify(node.label)} has already been declared`)); + } + if (node.body.type === 'FunctionDeclaration') { + s = s.addStrictError(new EarlyError(node, 'Labeled FunctionDeclarations are disallowed in strict mode')); + } + s = isIterationStatement(node.body) + ? s.observeIterationLabel(node.label) + : s.observeNonIterationLabel(node.label); + return s; + } + + reduceLiteralRegExpExpression() { + let s = this.identity; + // NOTE: the RegExp pattern acceptor is disabled until we have more confidence in its correctness (more tests) + // if (!PatternAcceptor.test(node.pattern, node.flags.indexOf("u") >= 0)) { + // s = s.addError(new EarlyError(node, "Invalid regular expression pattern")); + // } + return s; + } + + reduceMethod(node, { name, params, body }) { + let isSimpleParameterList = node.params.rest == null && node.params.items.every(i => i.type === 'BindingIdentifier'); + params = params.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING); + body = body.enforceConflictingLexicallyDeclaredNames(params.lexicallyDeclaredNames, DUPLICATE_BINDING); + if (node.name.type === 'StaticPropertyName' && node.name.value === 'constructor') { + body = body.observeConstructorMethod(); + params = params.observeConstructorMethod(); + } else { + body = body.enforceSuperCallExpressions(SUPERCALL_ERROR); + params = params.enforceSuperCallExpressions(SUPERCALL_ERROR); + } + if (node.isGenerator) { + params.yieldExpressions.forEach(n => { + params = params.addError(new EarlyError(n, 'Generator parameters must not contain yield expressions')); + }); + } + if (node.isAsync) { + params.awaitExpressions.forEach(n => { + params = params.addError(new EarlyError(n, 'Async function parameters must not contain await expressions')); + }); + } + body = body.clearSuperPropertyExpressions(); + params = params.clearSuperPropertyExpressions(); + params = params.clearNewTargetExpressions(); + body = body.clearNewTargetExpressions(); + if (isStrictFunctionBody(node.body)) { + params = params.enforceStrictErrors(); + body = body.enforceStrictErrors(); + } + let s = super.reduceMethod(node, { name, params, body }); + if (!isSimpleParameterList && isStrictFunctionBody(node.body)) { + s = s.addError(new EarlyError(node, 'Functions with non-simple parameter lists may not contain a "use strict" directive')); + } + s = s.clearYieldExpressions(); + s = s.clearAwaitExpressions(); + s = s.observeVarBoundary(); + return s; + } + + reduceModule() { + let s = super.reduceModule(...arguments); + s = s.functionDeclarationNamesAreLexical(); + s = s.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING); + s = s.enforceConflictingLexicallyDeclaredNames(s.varDeclaredNames, DUPLICATE_BINDING); + s.exportedNames.forEachEntry((nodes, bindingName) => { + if (nodes.length > 1) { + nodes.slice(1).forEach(dupeNode => { + s = s.addError(new EarlyError(dupeNode, `Duplicate export ${JSON.stringify(bindingName)}`)); + }); + } + }); + s.exportedBindings.forEachEntry((nodes, bindingName) => { + if (!s.lexicallyDeclaredNames.has(bindingName) && !s.varDeclaredNames.has(bindingName)) { + nodes.forEach(undeclaredNode => { + s = s.addError(new EarlyError(undeclaredNode, `Exported binding ${JSON.stringify(bindingName)} is not declared`)); + }); + } + }); + s.newTargetExpressions.forEach(node => { + s = s.addError(new EarlyError(node, 'new.target must be within function (but not arrow expression) code')); + }); + s = s.enforceFreeContinueStatementErrors(FREE_CONTINUE); + s = s.enforceFreeLabeledContinueStatementErrors(UNBOUND_CONTINUE); + s = s.enforceFreeBreakStatementErrors(FREE_BREAK); + s = s.enforceFreeLabeledBreakStatementErrors(UNBOUND_BREAK); + s = s.enforceSuperCallExpressions(SUPERCALL_ERROR); + s = s.enforceSuperPropertyExpressions(SUPERPROPERTY_ERROR); + s = s.enforceStrictErrors(); + return s; + } + + reduceNewTargetExpression(node) { + return this.identity.observeNewTargetExpression(node); + } + + reduceObjectExpression(node) { + let s = super.reduceObjectExpression(...arguments); + s = s.enforceSuperCallExpressionsInConstructorMethod(SUPERCALL_ERROR); + let protos = node.properties.filter(p => p.type === 'DataProperty' && p.name.type === 'StaticPropertyName' && p.name.value === '__proto__'); + protos.slice(1).forEach(n => { + s = s.addError(new EarlyError(n, 'Duplicate __proto__ property in object literal not allowed')); + }); + return s; + } + + reduceUpdateExpression() { + let s = super.reduceUpdateExpression(...arguments); + s = s.clearBoundNames(); + return s; + } + + reduceUnaryExpression(node) { + let s = super.reduceUnaryExpression(...arguments); + if (node.operator === 'delete' && node.operand.type === 'IdentifierExpression') { + s = s.addStrictError(new EarlyError(node, 'Identifier expressions must not be deleted in strict mode')); + } + return s; + } + + reduceScript(node) { + let s = super.reduceScript(...arguments); + s = s.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING); + s = s.enforceConflictingLexicallyDeclaredNames(s.varDeclaredNames, DUPLICATE_BINDING); + s.newTargetExpressions.forEach(n => { + s = s.addError(new EarlyError(n, 'new.target must be within function (but not arrow expression) code')); + }); + s = s.enforceFreeContinueStatementErrors(FREE_CONTINUE); + s = s.enforceFreeLabeledContinueStatementErrors(UNBOUND_CONTINUE); + s = s.enforceFreeBreakStatementErrors(FREE_BREAK); + s = s.enforceFreeLabeledBreakStatementErrors(UNBOUND_BREAK); + s = s.enforceSuperCallExpressions(SUPERCALL_ERROR); + s = s.enforceSuperPropertyExpressions(SUPERPROPERTY_ERROR); + if (isStrictFunctionBody(node)) { + s = s.enforceStrictErrors(); + } + return s; + } + + reduceSetter(node, { name, param, body }) { + let isSimpleParameterList = node.param.type === 'BindingIdentifier'; + param = param.observeLexicalDeclaration(); + param = param.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING); + body = body.enforceConflictingLexicallyDeclaredNames(param.lexicallyDeclaredNames, DUPLICATE_BINDING); + param = param.enforceSuperCallExpressions(SUPERCALL_ERROR); + body = body.enforceSuperCallExpressions(SUPERCALL_ERROR); + param = param.clearSuperPropertyExpressions(); + body = body.clearSuperPropertyExpressions(); + param = param.clearNewTargetExpressions(); + body = body.clearNewTargetExpressions(); + if (isStrictFunctionBody(node.body)) { + param = param.enforceStrictErrors(); + body = body.enforceStrictErrors(); + } + let s = super.reduceSetter(node, { name, param, body }); + if (!isSimpleParameterList && isStrictFunctionBody(node.body)) { + s = s.addError(new EarlyError(node, 'Functions with non-simple parameter lists may not contain a "use strict" directive')); + } + s = s.observeVarBoundary(); + return s; + } + + reduceStaticMemberExpression(node) { + let s = super.reduceStaticMemberExpression(...arguments); + if (node.object.type === 'Super') { + s = s.observeSuperPropertyExpression(node); + } + return s; + } + + reduceSwitchStatement(node, { discriminant, cases }) { + let sCases = this.append(...cases); + sCases = sCases.functionDeclarationNamesAreLexical(); + sCases = sCases.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING); + sCases = sCases.enforceConflictingLexicallyDeclaredNames(sCases.varDeclaredNames, DUPLICATE_BINDING); + sCases = sCases.observeLexicalBoundary(); + let s = this.append(discriminant, sCases); + s = s.clearFreeBreakStatements(); + return s; + } + + reduceSwitchStatementWithDefault(node, { discriminant, preDefaultCases, defaultCase, postDefaultCases }) { + let sCases = this.append(defaultCase, ...preDefaultCases, ...postDefaultCases); + sCases = sCases.functionDeclarationNamesAreLexical(); + sCases = sCases.enforceDuplicateLexicallyDeclaredNames(DUPLICATE_BINDING); + sCases = sCases.enforceConflictingLexicallyDeclaredNames(sCases.varDeclaredNames, DUPLICATE_BINDING); + sCases = sCases.observeLexicalBoundary(); + let s = this.append(discriminant, sCases); + s = s.clearFreeBreakStatements(); + return s; + } + + reduceVariableDeclaration(node) { + let s = super.reduceVariableDeclaration(...arguments); + switch (node.kind) { + case 'const': + case 'let': { + s = s.observeLexicalDeclaration(); + if (s.lexicallyDeclaredNames.has('let')) { + s.lexicallyDeclaredNames.get('let').forEach(n => { + s = s.addError(new EarlyError(n, 'Lexical declarations must not have a binding named "let"')); + }); + } + break; + } + case 'var': + s = s.observeVarDeclaration(); + break; + } + return s; + } + + reduceVariableDeclarationStatement(node) { + let s = super.reduceVariableDeclarationStatement(...arguments); + if (node.declaration.kind === 'const') { + node.declaration.declarators.forEach(declarator => { + if (declarator.init == null) { + s = s.addError(new EarlyError(declarator, 'Constant lexical declarations must have an initialiser')); + } + }); + } + return s; + } + + reduceWhileStatement(node) { + let s = super.reduceWhileStatement(...arguments); + if (isLabelledFunction(node.body)) { + s = s.addError(new EarlyError(node.body, 'The body of a while statement must not be a labeled function declaration')); + } + s = s.clearFreeContinueStatements().clearFreeBreakStatements(); + return s; + } + + reduceWithStatement(node) { + let s = super.reduceWithStatement(...arguments); + if (isLabelledFunction(node.body)) { + s = s.addError(new EarlyError(node.body, 'The body of a with statement must not be a labeled function declaration')); + } + s = s.addStrictError(new EarlyError(node, 'Strict mode code must not include a with statement')); + return s; + } + + reduceYieldExpression(node) { + let s = super.reduceYieldExpression(...arguments); + s = s.observeYieldExpression(node); + return s; + } + + reduceYieldGeneratorExpression(node) { + let s = super.reduceYieldGeneratorExpression(...arguments); + s = s.observeYieldExpression(node); + return s; + } + + + static check(node) { + return reduce(new EarlyErrorChecker, node).errors; + } +} diff --git a/docs/dist/shift-parser/errors.js b/docs/dist/shift-parser/errors.js new file mode 100644 index 00000000..11d84b01 --- /dev/null +++ b/docs/dist/shift-parser/errors.js @@ -0,0 +1,119 @@ +/** + * Copyright 2014 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const ErrorMessages = { + UNEXPECTED_TOKEN(id) { + return `Unexpected token ${JSON.stringify(id)}`; + }, + UNEXPECTED_ILLEGAL_TOKEN(id) { + return `Unexpected ${JSON.stringify(id)}`; + }, + UNEXPECTED_ESCAPED_KEYWORD: 'Unexpected escaped keyword', + UNEXPECTED_NUMBER: 'Unexpected number', + UNEXPECTED_STRING: 'Unexpected string', + UNEXPECTED_IDENTIFIER: 'Unexpected identifier', + UNEXPECTED_RESERVED_WORD: 'Unexpected reserved word', + UNEXPECTED_TEMPLATE: 'Unexpected template', + UNEXPECTED_EOS: 'Unexpected end of input', + UNEXPECTED_LINE_TERMINATOR: 'Unexpected line terminator', + UNEXPECTED_COMMA_AFTER_REST: 'Unexpected comma after rest', + UNEXPECTED_REST_PARAMETERS_INITIALIZATION: 'Rest parameter may not have a default initializer', + NEWLINE_AFTER_THROW: 'Illegal newline after throw', + UNTERMINATED_REGEXP: 'Invalid regular expression: missing /', + INVALID_LAST_REST_PARAMETER: 'Rest parameter must be last formal parameter', + INVALID_REST_PARAMETERS_INITIALIZATION: 'Rest parameter may not have a default initializer', + INVALID_REGEXP_FLAGS: 'Invalid regular expression flags', + INVALID_REGEX: 'Invalid regular expression', + INVALID_LHS_IN_ASSIGNMENT: 'Invalid left-hand side in assignment', + INVALID_LHS_IN_BINDING: 'Invalid left-hand side in binding', // todo collapse messages? + INVALID_LHS_IN_FOR_IN: 'Invalid left-hand side in for-in', + INVALID_LHS_IN_FOR_OF: 'Invalid left-hand side in for-of', + INVALID_LHS_IN_FOR_AWAIT: 'Invalid left-hand side in for-await', + INVALID_UPDATE_OPERAND: 'Increment/decrement target must be an identifier or member expression', + INVALID_EXPONENTIATION_LHS: 'Unary expressions as the left operand of an exponentation expression ' + + 'must be disambiguated with parentheses', + MULTIPLE_DEFAULTS_IN_SWITCH: 'More than one default clause in switch statement', + NO_CATCH_OR_FINALLY: 'Missing catch or finally after try', + ILLEGAL_RETURN: 'Illegal return statement', + ILLEGAL_ARROW_FUNCTION_PARAMS: 'Illegal arrow function parameter list', + INVALID_ASYNC_PARAMS: 'Async function parameters must not contain await expressions', + INVALID_VAR_INIT_FOR_IN: 'Invalid variable declaration in for-in statement', + INVALID_VAR_INIT_FOR_OF: 'Invalid variable declaration in for-of statement', + INVALID_VAR_INIT_FOR_AWAIT: 'Invalid variable declaration in for-await statement', + UNINITIALIZED_BINDINGPATTERN_IN_FOR_INIT: 'Binding pattern appears without initializer in for statement init', + ILLEGAL_PROPERTY: 'Illegal property initializer', + INVALID_ID_BINDING_STRICT_MODE(id) { + return `The identifier ${JSON.stringify(id)} must not be in binding position in strict mode`; + }, + INVALID_ID_IN_LABEL_STRICT_MODE(id) { + return `The identifier ${JSON.stringify(id)} must not be in label position in strict mode`; + }, + INVALID_ID_IN_EXPRESSION_STRICT_MODE(id) { + return `The identifier ${JSON.stringify(id)} must not be in expression position in strict mode`; + }, + INVALID_CALL_TO_SUPER: 'Calls to super must be in the "constructor" method of a class expression ' + + 'or class declaration that has a superclass', + INVALID_DELETE_STRICT_MODE: 'Identifier expressions must not be deleted in strict mode', + DUPLICATE_BINDING(id) { + return `Duplicate binding ${JSON.stringify(id)}`; + }, + ILLEGAL_ID_IN_LEXICAL_DECLARATION(id) { + return `Lexical declarations must not have a binding named ${JSON.stringify(id)}`; + }, + UNITIALIZED_CONST: 'Constant lexical declarations must have an initialiser', + ILLEGAL_LABEL_IN_BODY(stmt) { + return `The body of a ${stmt} statement must not be a labeled function declaration`; + }, + ILLEGEAL_LABEL_IN_IF: 'The consequent of an if statement must not be a labeled function declaration', + ILLEGAL_LABEL_IN_ELSE: 'The alternate of an if statement must not be a labeled function declaration', + ILLEGAL_CONTINUE_WITHOUT_ITERATION_WITH_ID(id) { + return `Continue statement must be nested within an iteration statement with label ${JSON.stringify(id)}`; + }, + ILLEGAL_CONTINUE_WITHOUT_ITERATION: 'Continue statement must be nested within an iteration statement', + ILLEGAL_BREAK_WITHOUT_ITERATION_OR_SWITCH: + 'Break statement must be nested within an iteration statement or a switch statement', + ILLEGAL_WITH_STRICT_MODE: 'Strict mode code must not include a with statement', + ILLEGAL_ACCESS_SUPER_MEMBER: 'Member access on super must be in a method', + ILLEGAL_SUPER_CALL: 'Calls to super must be in the "constructor" method of a class expression or class declaration that has a superclass', + DUPLICATE_LABEL_DECLARATION(label) { + return `Label ${JSON.stringify(label)} has already been declared`; + }, + ILLEGAL_BREAK_WITHIN_LABEL(label) { + return `Break statement must be nested within a statement with label ${JSON.stringify(label)}`; + }, + ILLEGAL_YIELD_EXPRESSIONS(paramType) { + return `${paramType} parameters must not contain yield expressions`; + }, + ILLEGAL_YIELD_IDENTIFIER: '"yield" may not be used as an identifier in this context', + ILLEGAL_AWAIT_IDENTIFIER: '"await" may not be used as an identifier in this context', + DUPLICATE_CONSTRUCTOR: 'Duplicate constructor method in class', + ILLEGAL_CONSTRUCTORS: 'Constructors cannot be async, generators, getters or setters', + ILLEGAL_STATIC_CLASS_NAME: 'Static class methods cannot be named "prototype"', + NEW_TARGET_ERROR: 'new.target must be within function (but not arrow expression) code', + DUPLICATE_EXPORT(id) { + return `Duplicate export ${JSON.stringify(id)}`; + }, + UNDECLARED_BINDING(id) { + return `Exported binding ${JSON.stringify(id)} is not declared`; + }, + DUPLICATE_PROPTO_PROP: 'Duplicate __proto__ property in object literal not allowed', + ILLEGAL_LABEL_FUNC_DECLARATION: 'Labeled FunctionDeclarations are disallowed in strict mode', + ILLEGAL_FUNC_DECL_IF: 'FunctionDeclarations in IfStatements are disallowed in strict mode', + ILLEGAL_USE_STRICT: 'Functions with non-simple parameter lists may not contain a "use strict" directive', + ILLEGAL_EXPORTED_NAME: 'Names of variables used in an export specifier from the current module must be identifiers', + NO_OCTALS_IN_TEMPLATES: 'Template literals may not contain octal escape sequences', + NO_AWAIT_IN_ASYNC_PARAMS: 'Async arrow parameters may not contain "await"', +}; diff --git a/docs/dist/shift-parser/index.js b/docs/dist/shift-parser/index.js new file mode 100644 index 00000000..2cb39d44 --- /dev/null +++ b/docs/dist/shift-parser/index.js @@ -0,0 +1,149 @@ +/** + * Copyright 2016 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { GenericParser } from './parser.js'; +import { JsError } from './tokenizer.js'; +import { EarlyErrorChecker } from './early-errors.js'; +import { isLineTerminator } from './utils.js'; + +class ParserWithLocation extends GenericParser { + constructor(source) { + super(source); + this.locations = new WeakMap; + this.comments = []; + } + + startNode() { + return this.getLocation(); + } + + finishNode(node, start) { + if (node.type === 'Script' || node.type === 'Module') { + this.locations.set(node, { + start: { line: 1, column: 0, offset: 0 }, + end: this.getLocation(), + }); + return node; + } + if (node.type === 'TemplateExpression') { + // Adjust TemplateElements to not include surrounding backticks or braces + for (let i = 0; i < node.elements.length; i += 2) { + const endAdjustment = i < node.elements.length - 1 ? 2 : 1; // discard '${' or '`' respectively + const element = node.elements[i]; + const location = this.locations.get(element); + this.locations.set(element, { + start: { line: location.start.line, column: location.start.column + 1, offset: location.start.offset + 1 }, // discard '}' or '`' + end: { line: location.end.line, column: location.end.column - endAdjustment, offset: location.end.offset - endAdjustment }, + }); + } + } + this.locations.set(node, { + start, + end: this.getLastTokenEndLocation(), + }); + return node; + } + + copyNode(src, dest) { + this.locations.set(dest, this.locations.get(src)); // todo check undefined + return dest; + } + + skipSingleLineComment(offset) { + // We're actually extending the *tokenizer*, here. + const start = { + line: this.line + 1, + column: this.index - this.lineStart, + offset: this.index, + }; + const c = this.source[this.index]; + const type = c === '/' ? 'SingleLine' : c === '<' ? 'HTMLOpen' : 'HTMLClose'; + + super.skipSingleLineComment(offset); + + const end = { + line: this.line + 1, + column: this.index - this.lineStart, + offset: this.index, + }; + const trailingLineTerminatorCharacters = this.source[this.index - 2] === '\r' ? 2 : isLineTerminator(this.source.charCodeAt(this.index - 1)) ? 1 : 0; + const text = this.source.substring(start.offset + offset, end.offset - trailingLineTerminatorCharacters); + + this.comments.push({ text, type, start, end }); + } + + skipMultiLineComment() { + const start = { + line: this.line + 1, + column: this.index - this.lineStart, + offset: this.index, + }; + const type = 'MultiLine'; + + const retval = super.skipMultiLineComment(); + + const end = { + line: this.line + 1, + column: this.index - this.lineStart, + offset: this.index, + }; + const text = this.source.substring(start.offset + 2, end.offset - 2); + + this.comments.push({ text, type, start, end }); + + return retval; + } +} + +function generateInterface(parsingFunctionName) { + return function parse(code, { earlyErrors = true } = {}) { + let parser = new GenericParser(code); + let tree = parser[parsingFunctionName](); + if (earlyErrors) { + let errors = EarlyErrorChecker.check(tree); + // for now, just throw the first error; we will handle multiple errors later + if (errors.length > 0) { + throw new JsError(0, 1, 0, errors[0].message); + } + } + return tree; + }; +} + +function generateInterfaceWithLocation(parsingFunctionName) { + return function parse(code, { earlyErrors = true } = {}) { + let parser = new ParserWithLocation(code); + let tree = parser[parsingFunctionName](); + if (earlyErrors) { + let errors = EarlyErrorChecker.check(tree); + // for now, just throw the first error; we will handle multiple errors later + if (errors.length > 0) { + let { node, message } = errors[0]; + let { offset, line, column } = parser.locations.get(node).start; + throw new JsError(offset, line, column, message); + } + } + return { tree, locations: parser.locations, comments: parser.comments }; + }; +} + +export const parseModule = generateInterface('parseModule'); +export const parseScript = generateInterface('parseScript'); +export const parseModuleWithLocation = generateInterfaceWithLocation('parseModule'); +export const parseScriptWithLocation = generateInterfaceWithLocation('parseScript'); +export default parseScript; +export { EarlyErrorChecker, GenericParser, ParserWithLocation }; +export { default as Tokenizer, TokenClass, TokenType } from './tokenizer.js'; diff --git a/docs/dist/shift-parser/parser.js b/docs/dist/shift-parser/parser.js new file mode 100644 index 00000000..4af854d9 --- /dev/null +++ b/docs/dist/shift-parser/parser.js @@ -0,0 +1,2641 @@ +/** + * Copyright 2014 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ErrorMessages } from './errors.js'; + +import acceptRegex from '../../_snowpack/pkg/shift-regexp-acceptor.js'; + +import Tokenizer, { TokenClass, TokenType } from './tokenizer.js'; + +import * as AST from '../../_snowpack/pkg/shift-ast.js'; + +// Empty parameter list for ArrowExpression +const ARROW_EXPRESSION_PARAMS = 'CoverParenthesizedExpressionAndArrowParameterList'; +const EXPORT_UNKNOWN_SPECIFIER = 'ExportNameOfUnknownType'; + +const Precedence = { + Sequence: 0, + Yield: 1, + Assignment: 1, + Conditional: 2, + ArrowFunction: 2, + LogicalOR: 3, + LogicalAND: 4, + BitwiseOR: 5, + BitwiseXOR: 6, + BitwiseAND: 7, + Equality: 8, + Relational: 9, + BitwiseSHIFT: 10, + Additive: 11, + Multiplicative: 12, + Unary: 13, + Postfix: 14, + Call: 15, + New: 16, + TaggedTemplate: 17, + Member: 18, + Primary: 19, +}; + +const BinaryPrecedence = { + '||': Precedence.LogicalOR, + '&&': Precedence.LogicalAND, + '|': Precedence.BitwiseOR, + '^': Precedence.BitwiseXOR, + '&': Precedence.BitwiseAND, + '==': Precedence.Equality, + '!=': Precedence.Equality, + '===': Precedence.Equality, + '!==': Precedence.Equality, + '<': Precedence.Relational, + '>': Precedence.Relational, + '<=': Precedence.Relational, + '>=': Precedence.Relational, + 'in': Precedence.Relational, + 'instanceof': Precedence.Relational, + '<<': Precedence.BitwiseSHIFT, + '>>': Precedence.BitwiseSHIFT, + '>>>': Precedence.BitwiseSHIFT, + '+': Precedence.Additive, + '-': Precedence.Additive, + '*': Precedence.Multiplicative, + '%': Precedence.Multiplicative, + '/': Precedence.Multiplicative, +}; + +function isValidSimpleAssignmentTarget(node) { + if (node == null) return false; + switch (node.type) { + case 'IdentifierExpression': + case 'ComputedMemberExpression': + case 'StaticMemberExpression': + return true; + } + return false; +} + +function isPrefixOperator(token) { + switch (token.type) { + case TokenType.INC: + case TokenType.DEC: + case TokenType.ADD: + case TokenType.SUB: + case TokenType.BIT_NOT: + case TokenType.NOT: + case TokenType.DELETE: + case TokenType.VOID: + case TokenType.TYPEOF: + return true; + } + return false; +} + +function isUpdateOperator(token) { + return token.type === TokenType.INC || token.type === TokenType.DEC; +} + +export class GenericParser extends Tokenizer { + constructor(source) { + super(source); + this.allowIn = true; + this.inFunctionBody = false; + this.inParameter = false; + this.allowYieldExpression = false; + this.allowAwaitExpression = false; + this.firstAwaitLocation = null; // for forbidding `await` in async arrow params. + this.module = false; + this.moduleIsTheGoalSymbol = false; + this.strict = false; + + // Cover grammar + this.isBindingElement = true; + this.isAssignmentTarget = true; + this.firstExprError = null; + } + + match(subType) { + return this.lookahead.type === subType; + } + + matchIdentifier() { + switch (this.lookahead.type) { + case TokenType.IDENTIFIER: + case TokenType.LET: + case TokenType.YIELD: + case TokenType.ASYNC: + return true; + case TokenType.AWAIT: + if (!this.moduleIsTheGoalSymbol) { + if (this.firstAwaitLocation === null) { + this.firstAwaitLocation = this.getLocation(); + } + return true; + } + return false; + case TokenType.ESCAPED_KEYWORD: + if (this.lookahead.value === 'await' && !this.moduleIsTheGoalSymbol) { + if (this.firstAwaitLocation === null) { + this.firstAwaitLocation = this.getLocation(); + } + return true; + } + return this.lookahead.value === 'let' + || this.lookahead.value === 'yield' + || this.lookahead.value === 'async'; + } + return false; + } + + eat(tokenType) { + if (this.lookahead.type === tokenType) { + return this.lex(); + } + return null; + } + + expect(tokenType) { + if (this.lookahead.type === tokenType) { + return this.lex(); + } + throw this.createUnexpected(this.lookahead); + } + + matchContextualKeyword(keyword) { + return this.lookahead.type === TokenType.IDENTIFIER && !this.lookahead.escaped && this.lookahead.value === keyword; + } + + expectContextualKeyword(keyword) { + if (this.lookahead.type === TokenType.IDENTIFIER && !this.lookahead.escaped && this.lookahead.value === keyword) { + return this.lex(); + } + throw this.createUnexpected(this.lookahead); + } + + eatContextualKeyword(keyword) { + if (this.lookahead.type === TokenType.IDENTIFIER && !this.lookahead.escaped && this.lookahead.value === keyword) { + return this.lex(); + } + return null; + } + + consumeSemicolon() { + if (this.eat(TokenType.SEMICOLON)) return; + if (this.hasLineTerminatorBeforeNext) return; + if (!this.eof() && !this.match(TokenType.RBRACE)) { + throw this.createUnexpected(this.lookahead); + } + } + + // this is a no-op, reserved for future use + startNode(node) { + return node; + } + + copyNode(src, dest) { + return dest; + } + + finishNode(node /* , startState */) { + return node; + } + + parseModule() { + this.moduleIsTheGoalSymbol = this.module = this.strict = true; + this.lookahead = this.advance(); + + let startState = this.startNode(); + let { directives, statements } = this.parseBody(); + if (!this.match(TokenType.EOS)) { + throw this.createUnexpected(this.lookahead); + } + return this.finishNode(new AST.Module({ directives, items: statements }), startState); + } + + parseScript() { + this.lookahead = this.advance(); + + let startState = this.startNode(); + let { directives, statements } = this.parseBody(); + if (!this.match(TokenType.EOS)) { + throw this.createUnexpected(this.lookahead); + } + return this.finishNode(new AST.Script({ directives, statements }), startState); + } + + parseFunctionBody() { + let oldInFunctionBody = this.inFunctionBody; + let oldModule = this.module; + let oldStrict = this.strict; + this.inFunctionBody = true; + this.module = false; + + let startState = this.startNode(); + this.expect(TokenType.LBRACE); + let body = new AST.FunctionBody(this.parseBody()); + this.expect(TokenType.RBRACE); + body = this.finishNode(body, startState); + + this.inFunctionBody = oldInFunctionBody; + this.module = oldModule; + this.strict = oldStrict; + + return body; + } + + parseBody() { + let directives = [], statements = [], parsingDirectives = true, directiveOctal = null; + + while (true) { + if (this.eof() || this.match(TokenType.RBRACE)) break; + let token = this.lookahead; + let text = token.slice.text; + let isStringLiteral = token.type === TokenType.STRING; + let isModule = this.module; + let directiveLocation = this.getLocation(); + let directiveStartState = this.startNode(); + let stmt = isModule ? this.parseModuleItem() : this.parseStatementListItem(); + if (parsingDirectives) { + if (isStringLiteral && stmt.type === 'ExpressionStatement' && stmt.expression.type === 'LiteralStringExpression') { + if (!directiveOctal && token.octal) { + directiveOctal = this.createErrorWithLocation(directiveLocation, 'Unexpected legacy octal escape sequence: \\' + token.octal); + } + let rawValue = text.slice(1, -1); + if (rawValue === 'use strict') { + this.strict = true; + } + directives.push(this.finishNode(new AST.Directive({ rawValue }), directiveStartState)); + } else { + parsingDirectives = false; + if (directiveOctal && this.strict) { + throw directiveOctal; + } + statements.push(stmt); + } + } else { + statements.push(stmt); + } + } + if (directiveOctal && this.strict) { + throw directiveOctal; + } + + return { directives, statements }; + } + + parseImportSpecifier() { + let startState = this.startNode(), name; + if (this.matchIdentifier()) { + name = this.parseIdentifier(); + if (!this.eatContextualKeyword('as')) { + return this.finishNode(new AST.ImportSpecifier({ + name: null, + binding: this.finishNode(new AST.BindingIdentifier({ name }), startState), + }), startState); + } + } else if (this.lookahead.type.klass.isIdentifierName) { + name = this.parseIdentifierName(); + this.expectContextualKeyword('as'); + } + + return this.finishNode(new AST.ImportSpecifier({ name, binding: this.parseBindingIdentifier() }), startState); + } + + parseNameSpaceBinding() { + this.expect(TokenType.MUL); + this.expectContextualKeyword('as'); + return this.parseBindingIdentifier(); + } + + parseNamedImports() { + let result = []; + this.expect(TokenType.LBRACE); + while (!this.eat(TokenType.RBRACE)) { + result.push(this.parseImportSpecifier()); + if (!this.eat(TokenType.COMMA)) { + this.expect(TokenType.RBRACE); + break; + } + } + return result; + } + + parseFromClause() { + this.expectContextualKeyword('from'); + let value = this.expect(TokenType.STRING).str; + return value; + } + + parseImportDeclaration() { + let startState = this.startNode(), defaultBinding = null, moduleSpecifier; + this.expect(TokenType.IMPORT); + if (this.match(TokenType.STRING)) { + moduleSpecifier = this.lex().str; + this.consumeSemicolon(); + return this.finishNode(new AST.Import({ defaultBinding: null, namedImports: [], moduleSpecifier }), startState); + } + if (this.matchIdentifier()) { + defaultBinding = this.parseBindingIdentifier(); + if (!this.eat(TokenType.COMMA)) { + let decl = new AST.Import({ defaultBinding, namedImports: [], moduleSpecifier: this.parseFromClause() }); + this.consumeSemicolon(); + return this.finishNode(decl, startState); + } + } + if (this.match(TokenType.MUL)) { + let decl = new AST.ImportNamespace({ + defaultBinding, + namespaceBinding: this.parseNameSpaceBinding(), + moduleSpecifier: this.parseFromClause(), + }); + this.consumeSemicolon(); + return this.finishNode(decl, startState); + } else if (this.match(TokenType.LBRACE)) { + let decl = new AST.Import({ + defaultBinding, + namedImports: this.parseNamedImports(), + moduleSpecifier: this.parseFromClause(), + }); + this.consumeSemicolon(); + return this.finishNode(decl, startState); + } + throw this.createUnexpected(this.lookahead); + } + + parseExportSpecifier() { + let startState = this.startNode(); + let name = this.finishNode({ type: EXPORT_UNKNOWN_SPECIFIER, isIdentifier: this.matchIdentifier(), value: this.parseIdentifierName() }, startState); + if (this.eatContextualKeyword('as')) { + let exportedName = this.parseIdentifierName(); + return this.finishNode({ name, exportedName }, startState); + } + return this.finishNode({ name, exportedName: null }, startState); + } + + parseExportClause() { + this.expect(TokenType.LBRACE); + let result = []; + while (!this.eat(TokenType.RBRACE)) { + result.push(this.parseExportSpecifier()); + if (!this.eat(TokenType.COMMA)) { + this.expect(TokenType.RBRACE); + break; + } + } + return result; + } + + parseExportDeclaration() { + let startState = this.startNode(), decl; + this.expect(TokenType.EXPORT); + switch (this.lookahead.type) { + case TokenType.MUL: + this.lex(); + // export * FromClause ; + decl = new AST.ExportAllFrom({ moduleSpecifier: this.parseFromClause() }); + this.consumeSemicolon(); + break; + case TokenType.LBRACE: { + // export ExportClause FromClause ; + // export ExportClause ; + let namedExports = this.parseExportClause(); + let moduleSpecifier = null; + if (this.matchContextualKeyword('from')) { + moduleSpecifier = this.parseFromClause(); + decl = new AST.ExportFrom({ namedExports: namedExports.map(e => this.copyNode(e, new AST.ExportFromSpecifier({ name: e.name.value, exportedName: e.exportedName }))), moduleSpecifier }); + } else { + namedExports.forEach(({ name }) => { + if (!name.isIdentifier) { + throw this.createError(ErrorMessages.ILLEGAL_EXPORTED_NAME); + } + }); + decl = new AST.ExportLocals({ namedExports: namedExports.map(e => this.copyNode(e, new AST.ExportLocalSpecifier({ name: this.copyNode(e.name, new AST.IdentifierExpression({ name: e.name.value })), exportedName: e.exportedName }))) }); + } + this.consumeSemicolon(); + break; + } + case TokenType.CLASS: + // export ClassDeclaration + decl = new AST.Export({ declaration: this.parseClass({ isExpr: false, inDefault: false }) }); + break; + case TokenType.FUNCTION: + // export HoistableDeclaration + decl = new AST.Export({ declaration: this.parseFunction({ isExpr: false, inDefault: false, allowGenerator: true, isAsync: false }) }); + break; + case TokenType.ASYNC: { + let preAsyncStartState = this.startNode(); + this.lex(); + decl = new AST.Export({ declaration: this.parseFunction({ isExpr: false, inDefault: false, allowGenerator: true, isAsync: true, startState: preAsyncStartState }) }); + break; + } + case TokenType.DEFAULT: + this.lex(); + switch (this.lookahead.type) { + case TokenType.FUNCTION: + // export default HoistableDeclaration[Default] + decl = new AST.ExportDefault({ + body: this.parseFunction({ isExpr: false, inDefault: true, allowGenerator: true, isAsync: false }), + }); + break; + case TokenType.CLASS: + // export default ClassDeclaration[Default] + decl = new AST.ExportDefault({ body: this.parseClass({ isExpr: false, inDefault: true }) }); + break; + case TokenType.ASYNC: { + let preAsyncStartState = this.startNode(); + let lexerState = this.saveLexerState(); + this.lex(); + if (!this.hasLineTerminatorBeforeNext && this.match(TokenType.FUNCTION)) { + decl = new AST.ExportDefault({ + body: this.parseFunction({ isExpr: false, inDefault: true, allowGenerator: false, isAsync: true, startState: preAsyncStartState }), + }); + break; + } + this.restoreLexerState(lexerState); + } + // else fall through + default: + // export default [lookahead ∉ {function, async [no LineTerminatorHere] function, class}] AssignmentExpression[In] ; + decl = new AST.ExportDefault({ body: this.parseAssignmentExpression() }); + this.consumeSemicolon(); + break; + } + break; + case TokenType.VAR: + case TokenType.LET: + case TokenType.CONST: + // export LexicalDeclaration + decl = new AST.Export({ declaration: this.parseVariableDeclaration(true) }); + this.consumeSemicolon(); + break; + default: + throw this.createUnexpected(this.lookahead); + } + return this.finishNode(decl, startState); + } + + parseModuleItem() { + switch (this.lookahead.type) { + case TokenType.IMPORT: + return this.parseImportDeclaration(); + case TokenType.EXPORT: + return this.parseExportDeclaration(); + default: + return this.parseStatementListItem(); + } + } + + lookaheadLexicalDeclaration() { + if (this.match(TokenType.LET) || this.match(TokenType.CONST)) { + let lexerState = this.saveLexerState(); + this.lex(); + if ( + this.matchIdentifier() || + this.match(TokenType.LBRACE) || + this.match(TokenType.LBRACK) + ) { + this.restoreLexerState(lexerState); + return true; + } + this.restoreLexerState(lexerState); + } + return false; + } + + parseStatementListItem() { + if (this.eof()) throw this.createUnexpected(this.lookahead); + + switch (this.lookahead.type) { + case TokenType.FUNCTION: + return this.parseFunction({ isExpr: false, inDefault: false, allowGenerator: true, isAsync: false }); + case TokenType.CLASS: + return this.parseClass({ isExpr: false, inDefault: false }); + case TokenType.ASYNC: { + let preAsyncStartState = this.getLocation(); + let lexerState = this.saveLexerState(); + this.lex(); + if (!this.hasLineTerminatorBeforeNext && this.match(TokenType.FUNCTION)) { + return this.parseFunction({ isExpr: false, inDefault: false, allowGenerator: true, isAsync: true, startState: preAsyncStartState }); + } + this.restoreLexerState(lexerState); + return this.parseStatement(); + } + default: + if (this.lookaheadLexicalDeclaration()) { + let startState = this.startNode(); + return this.finishNode(this.parseVariableDeclarationStatement(), startState); + } + return this.parseStatement(); + } + } + + parseStatement() { + let startState = this.startNode(); + let stmt = this.isolateCoverGrammar(this.parseStatementHelper); + return this.finishNode(stmt, startState); + } + + parseStatementHelper() { + if (this.eof()) { + throw this.createUnexpected(this.lookahead); + } + + switch (this.lookahead.type) { + case TokenType.SEMICOLON: + return this.parseEmptyStatement(); + case TokenType.LBRACE: + return this.parseBlockStatement(); + case TokenType.LPAREN: + return this.parseExpressionStatement(); + case TokenType.BREAK: + return this.parseBreakStatement(); + case TokenType.CONTINUE: + return this.parseContinueStatement(); + case TokenType.DEBUGGER: + return this.parseDebuggerStatement(); + case TokenType.DO: + return this.parseDoWhileStatement(); + case TokenType.FOR: + return this.parseForStatement(); + case TokenType.IF: + return this.parseIfStatement(); + case TokenType.RETURN: + return this.parseReturnStatement(); + case TokenType.SWITCH: + return this.parseSwitchStatement(); + case TokenType.THROW: + return this.parseThrowStatement(); + case TokenType.TRY: + return this.parseTryStatement(); + case TokenType.VAR: + return this.parseVariableDeclarationStatement(); + case TokenType.WHILE: + return this.parseWhileStatement(); + case TokenType.WITH: + return this.parseWithStatement(); + case TokenType.FUNCTION: + case TokenType.CLASS: + throw this.createUnexpected(this.lookahead); + + default: { + let lexerState = this.saveLexerState(); + if (this.eat(TokenType.LET)) { + if (this.match(TokenType.LBRACK)) { + this.restoreLexerState(lexerState); + throw this.createUnexpected(this.lookahead); + } + this.restoreLexerState(lexerState); + } else if (this.eat(TokenType.ASYNC)) { + if (!this.hasLineTerminatorBeforeNext && this.match(TokenType.FUNCTION)) { + throw this.createUnexpected(this.lookahead); + } + this.restoreLexerState(lexerState); + } + let expr = this.parseExpression(); + // 12.12 Labelled Statements; + if (expr.type === 'IdentifierExpression' && this.eat(TokenType.COLON)) { + let labeledBody = this.match(TokenType.FUNCTION) + ? this.parseFunction({ isExpr: false, inDefault: false, allowGenerator: false, isAsync: false }) + : this.parseStatement(); + return new AST.LabeledStatement({ label: expr.name, body: labeledBody }); + } + this.consumeSemicolon(); + return new AST.ExpressionStatement({ expression: expr }); + } + } + } + + parseEmptyStatement() { + this.lex(); + return new AST.EmptyStatement; + } + + parseBlockStatement() { + return new AST.BlockStatement({ block: this.parseBlock() }); + } + + parseExpressionStatement() { + let expr = this.parseExpression(); + this.consumeSemicolon(); + return new AST.ExpressionStatement({ expression: expr }); + } + + parseBreakStatement() { + this.lex(); + + // Catch the very common case first: immediately a semicolon (U+003B). + if (this.eat(TokenType.SEMICOLON) || this.hasLineTerminatorBeforeNext) { + return new AST.BreakStatement({ label: null }); + } + + let label = null; + if (this.matchIdentifier()) { + label = this.parseIdentifier(); + } + + this.consumeSemicolon(); + + return new AST.BreakStatement({ label }); + } + + parseContinueStatement() { + this.lex(); + + // Catch the very common case first: immediately a semicolon (U+003B). + if (this.eat(TokenType.SEMICOLON) || this.hasLineTerminatorBeforeNext) { + return new AST.ContinueStatement({ label: null }); + } + + let label = null; + if (this.matchIdentifier()) { + label = this.parseIdentifier(); + } + + this.consumeSemicolon(); + + return new AST.ContinueStatement({ label }); + } + + + parseDebuggerStatement() { + this.lex(); + this.consumeSemicolon(); + return new AST.DebuggerStatement; + } + + parseDoWhileStatement() { + this.lex(); + let body = this.parseStatement(); + this.expect(TokenType.WHILE); + this.expect(TokenType.LPAREN); + let test = this.parseExpression(); + this.expect(TokenType.RPAREN); + this.eat(TokenType.SEMICOLON); + return new AST.DoWhileStatement({ body, test }); + } + + parseForStatement() { + this.lex(); + let isAwait = this.allowAwaitExpression && this.eat(TokenType.AWAIT); + this.expect(TokenType.LPAREN); + let test = null; + let right = null; + if (isAwait && this.match(TokenType.SEMICOLON)) { + throw this.createUnexpected(this.lookahead); + } + if (this.eat(TokenType.SEMICOLON)) { + if (!this.match(TokenType.SEMICOLON)) { + test = this.parseExpression(); + } + this.expect(TokenType.SEMICOLON); + if (!this.match(TokenType.RPAREN)) { + right = this.parseExpression(); + } + return new AST.ForStatement({ init: null, test, update: right, body: this.getIteratorStatementEpilogue() }); + } + let startsWithLet = this.match(TokenType.LET); + let isForDecl = this.lookaheadLexicalDeclaration(); + let leftStartState = this.startNode(); + if (this.match(TokenType.VAR) || isForDecl) { + let previousAllowIn = this.allowIn; + this.allowIn = false; + let init = this.parseVariableDeclaration(false); + this.allowIn = previousAllowIn; + + if (init.declarators.length === 1 && (this.match(TokenType.IN) || this.matchContextualKeyword('of'))) { + let ctor; + let decl = init.declarators[0]; + + if (this.match(TokenType.IN)) { + if (isAwait) { + throw this.createUnexpected(this.lookahead); + } + if (decl.init !== null && (this.strict || init.kind !== 'var' || decl.binding.type !== 'BindingIdentifier')) { + throw this.createError(ErrorMessages.INVALID_VAR_INIT_FOR_IN); + } + ctor = AST.ForInStatement; + this.lex(); + right = this.parseExpression(); + } else { + if (decl.init !== null) { + throw this.createError(isAwait ? ErrorMessages.INVALID_VAR_INIT_FOR_AWAIT : ErrorMessages.INVALID_VAR_INIT_FOR_OF); + } + if (isAwait) { + ctor = AST.ForAwaitStatement; + } else { + ctor = AST.ForOfStatement; + } + this.lex(); + right = this.parseAssignmentExpression(); + } + + let body = this.getIteratorStatementEpilogue(); + + return new ctor({ left: init, right, body }); + } else if (isAwait) { + throw this.createUnexpected(this.lookahead); + } + this.expect(TokenType.SEMICOLON); + if (init.declarators.some(decl => decl.binding.type !== 'BindingIdentifier' && decl.init === null)) { + throw this.createError(ErrorMessages.UNINITIALIZED_BINDINGPATTERN_IN_FOR_INIT); + } + if (!this.match(TokenType.SEMICOLON)) { + test = this.parseExpression(); + } + this.expect(TokenType.SEMICOLON); + if (!this.match(TokenType.RPAREN)) { + right = this.parseExpression(); + } + return new AST.ForStatement({ init, test, update: right, body: this.getIteratorStatementEpilogue() }); + + } + let previousAllowIn = this.allowIn; + this.allowIn = false; + let expr = this.inheritCoverGrammar(this.parseAssignmentExpressionOrTarget); + this.allowIn = previousAllowIn; + + if (this.isAssignmentTarget && expr.type !== 'AssignmentExpression' && (this.match(TokenType.IN) || this.matchContextualKeyword('of'))) { + if (expr.type === 'ObjectAssignmentTarget' || expr.type === 'ArrayAssignmentTarget') { + this.firstExprError = null; + } + if (startsWithLet && this.matchContextualKeyword('of')) { + throw this.createError(isAwait ? ErrorMessages.INVALID_LHS_IN_FOR_AWAIT : ErrorMessages.INVALID_LHS_IN_FOR_OF); + } + let ctor; + if (this.match(TokenType.IN)) { + if (isAwait) { + throw this.createUnexpected(this.lookahead); + } + ctor = AST.ForInStatement; + this.lex(); + right = this.parseExpression(); + } else { + if (isAwait) { + ctor = AST.ForAwaitStatement; + } else { + ctor = AST.ForOfStatement; + } + this.lex(); + right = this.parseAssignmentExpression(); + } + + return new ctor({ left: this.transformDestructuring(expr), right, body: this.getIteratorStatementEpilogue() }); + } else if (isAwait) { + throw this.createError(ErrorMessages.INVALID_LHS_IN_FOR_AWAIT); + } + if (this.firstExprError) { + throw this.firstExprError; + } + while (this.eat(TokenType.COMMA)) { + let rhs = this.parseAssignmentExpression(); + expr = this.finishNode(new AST.BinaryExpression({ left: expr, operator: ',', right: rhs }), leftStartState); + } + if (this.match(TokenType.IN)) { + throw this.createError(ErrorMessages.INVALID_LHS_IN_FOR_IN); + } + if (this.matchContextualKeyword('of')) { + throw this.createError(ErrorMessages.INVALID_LHS_IN_FOR_OF); + } + this.expect(TokenType.SEMICOLON); + if (!this.match(TokenType.SEMICOLON)) { + test = this.parseExpression(); + } + this.expect(TokenType.SEMICOLON); + if (!this.match(TokenType.RPAREN)) { + right = this.parseExpression(); + } + return new AST.ForStatement({ init: expr, test, update: right, body: this.getIteratorStatementEpilogue() }); + } + + getIteratorStatementEpilogue() { + this.expect(TokenType.RPAREN); + let body = this.parseStatement(); + return body; + } + + parseIfStatementChild() { + return this.match(TokenType.FUNCTION) + ? this.parseFunction({ isExpr: false, inDefault: false, allowGenerator: false, isAsync: false }) + : this.parseStatement(); + } + + parseIfStatement() { + this.lex(); + this.expect(TokenType.LPAREN); + let test = this.parseExpression(); + this.expect(TokenType.RPAREN); + let consequent = this.parseIfStatementChild(); + let alternate = null; + if (this.eat(TokenType.ELSE)) { + alternate = this.parseIfStatementChild(); + } + return new AST.IfStatement({ test, consequent, alternate }); + } + + parseReturnStatement() { + if (!this.inFunctionBody) { + throw this.createError(ErrorMessages.ILLEGAL_RETURN); + } + + this.lex(); + + // Catch the very common case first: immediately a semicolon (U+003B). + if (this.eat(TokenType.SEMICOLON) || this.hasLineTerminatorBeforeNext) { + return new AST.ReturnStatement({ expression: null }); + } + + let expression = null; + if (!this.match(TokenType.RBRACE) && !this.eof()) { + expression = this.parseExpression(); + } + + this.consumeSemicolon(); + return new AST.ReturnStatement({ expression }); + } + + parseSwitchStatement() { + this.lex(); + this.expect(TokenType.LPAREN); + let discriminant = this.parseExpression(); + this.expect(TokenType.RPAREN); + this.expect(TokenType.LBRACE); + + if (this.eat(TokenType.RBRACE)) { + return new AST.SwitchStatement({ discriminant, cases: [] }); + } + + let cases = this.parseSwitchCases(); + if (this.match(TokenType.DEFAULT)) { + let defaultCase = this.parseSwitchDefault(); + let postDefaultCases = this.parseSwitchCases(); + if (this.match(TokenType.DEFAULT)) { + throw this.createError(ErrorMessages.MULTIPLE_DEFAULTS_IN_SWITCH); + } + this.expect(TokenType.RBRACE); + return new AST.SwitchStatementWithDefault({ + discriminant, + preDefaultCases: cases, + defaultCase, + postDefaultCases, + }); + } + this.expect(TokenType.RBRACE); + return new AST.SwitchStatement({ discriminant, cases }); + } + + parseSwitchCases() { + let result = []; + while (!(this.eof() || this.match(TokenType.RBRACE) || this.match(TokenType.DEFAULT))) { + result.push(this.parseSwitchCase()); + } + return result; + } + + parseSwitchCase() { + let startState = this.startNode(); + this.expect(TokenType.CASE); + return this.finishNode(new AST.SwitchCase({ + test: this.parseExpression(), + consequent: this.parseSwitchCaseBody(), + }), startState); + } + + parseSwitchDefault() { + let startState = this.startNode(); + this.expect(TokenType.DEFAULT); + return this.finishNode(new AST.SwitchDefault({ consequent: this.parseSwitchCaseBody() }), startState); + } + + parseSwitchCaseBody() { + this.expect(TokenType.COLON); + return this.parseStatementListInSwitchCaseBody(); + } + + parseStatementListInSwitchCaseBody() { + let result = []; + while (!(this.eof() || this.match(TokenType.RBRACE) || this.match(TokenType.DEFAULT) || this.match(TokenType.CASE))) { + result.push(this.parseStatementListItem()); + } + return result; + } + + parseThrowStatement() { + let token = this.lex(); + if (this.hasLineTerminatorBeforeNext) { + throw this.createErrorWithLocation(token, ErrorMessages.NEWLINE_AFTER_THROW); + } + let expression = this.parseExpression(); + this.consumeSemicolon(); + return new AST.ThrowStatement({ expression }); + } + + parseTryStatement() { + this.lex(); + let body = this.parseBlock(); + + if (this.match(TokenType.CATCH)) { + let catchClause = this.parseCatchClause(); + if (this.eat(TokenType.FINALLY)) { + let finalizer = this.parseBlock(); + return new AST.TryFinallyStatement({ body, catchClause, finalizer }); + } + return new AST.TryCatchStatement({ body, catchClause }); + } + + if (this.eat(TokenType.FINALLY)) { + let finalizer = this.parseBlock(); + return new AST.TryFinallyStatement({ body, catchClause: null, finalizer }); + } + throw this.createError(ErrorMessages.NO_CATCH_OR_FINALLY); + } + + parseVariableDeclarationStatement() { + let declaration = this.parseVariableDeclaration(true); + this.consumeSemicolon(); + return new AST.VariableDeclarationStatement({ declaration }); + } + + parseWhileStatement() { + this.lex(); + this.expect(TokenType.LPAREN); + let test = this.parseExpression(); + let body = this.getIteratorStatementEpilogue(); + return new AST.WhileStatement({ test, body }); + } + + parseWithStatement() { + this.lex(); + this.expect(TokenType.LPAREN); + let object = this.parseExpression(); + this.expect(TokenType.RPAREN); + let body = this.parseStatement(); + return new AST.WithStatement({ object, body }); + } + + parseCatchClause() { + let startState = this.startNode(); + + this.lex(); + this.expect(TokenType.LPAREN); + if (this.match(TokenType.RPAREN) || this.match(TokenType.LPAREN)) { + throw this.createUnexpected(this.lookahead); + } + let binding = this.parseBindingTarget(); + this.expect(TokenType.RPAREN); + let body = this.parseBlock(); + + return this.finishNode(new AST.CatchClause({ binding, body }), startState); + } + + parseBlock() { + let startState = this.startNode(); + this.expect(TokenType.LBRACE); + let body = []; + while (!this.match(TokenType.RBRACE)) { + body.push(this.parseStatementListItem()); + } + this.expect(TokenType.RBRACE); + return this.finishNode(new AST.Block({ statements: body }), startState); + } + + parseVariableDeclaration(bindingPatternsMustHaveInit) { + let startState = this.startNode(); + let token = this.lex(); + + // preceded by this.match(TokenSubType.VAR) || this.match(TokenSubType.LET); + let kind = token.type === TokenType.VAR ? 'var' : token.type === TokenType.CONST ? 'const' : 'let'; + let declarators = this.parseVariableDeclaratorList(bindingPatternsMustHaveInit); + return this.finishNode(new AST.VariableDeclaration({ kind, declarators }), startState); + } + + parseVariableDeclaratorList(bindingPatternsMustHaveInit) { + let result = []; + do { + result.push(this.parseVariableDeclarator(bindingPatternsMustHaveInit)); + } while (this.eat(TokenType.COMMA)); + return result; + } + + parseVariableDeclarator(bindingPatternsMustHaveInit) { + let startState = this.startNode(); + + if (this.match(TokenType.LPAREN)) { + throw this.createUnexpected(this.lookahead); + } + + let previousAllowIn = this.allowIn; + this.allowIn = true; + let binding = this.parseBindingTarget(); + this.allowIn = previousAllowIn; + + if (bindingPatternsMustHaveInit && binding.type !== 'BindingIdentifier' && !this.match(TokenType.ASSIGN)) { + this.expect(TokenType.ASSIGN); + } + + let init = null; + if (this.eat(TokenType.ASSIGN)) { + init = this.parseAssignmentExpression(); + } + + return this.finishNode(new AST.VariableDeclarator({ binding, init }), startState); + } + + isolateCoverGrammar(parser) { + let oldIsBindingElement = this.isBindingElement, + oldIsAssignmentTarget = this.isAssignmentTarget, + oldFirstExprError = this.firstExprError, + result; + this.isBindingElement = this.isAssignmentTarget = true; + this.firstExprError = null; + result = parser.call(this); + if (this.firstExprError !== null) { + throw this.firstExprError; + } + this.isBindingElement = oldIsBindingElement; + this.isAssignmentTarget = oldIsAssignmentTarget; + this.firstExprError = oldFirstExprError; + return result; + } + + inheritCoverGrammar(parser) { + let oldIsBindingElement = this.isBindingElement, + oldIsAssignmentTarget = this.isAssignmentTarget, + oldFirstExprError = this.firstExprError, + result; + this.isBindingElement = this.isAssignmentTarget = true; + this.firstExprError = null; + result = parser.call(this); + this.isBindingElement = this.isBindingElement && oldIsBindingElement; + this.isAssignmentTarget = this.isAssignmentTarget && oldIsAssignmentTarget; + this.firstExprError = oldFirstExprError || this.firstExprError; + return result; + } + + parseExpression() { + let startState = this.startNode(); + + let left = this.parseAssignmentExpression(); + if (this.match(TokenType.COMMA)) { + while (!this.eof()) { + if (!this.match(TokenType.COMMA)) break; + this.lex(); + let right = this.parseAssignmentExpression(); + left = this.finishNode(new AST.BinaryExpression({ left, operator: ',', right }), startState); + } + } + return left; + } + + finishArrowParams(head) { + let { params = null, rest = null } = head; + if (head.type !== ARROW_EXPRESSION_PARAMS) { + if (head.type === 'IdentifierExpression') { + params = [this.targetToBinding(this.transformDestructuring(head))]; + } else { + throw this.createUnexpected(this.lookahead); + } + } + return this.copyNode(head, new AST.FormalParameters({ items: params, rest })); + } + + parseArrowExpressionTail(params, isAsync, startState) { + this.expect(TokenType.ARROW); + let previousYield = this.allowYieldExpression; + let previousAwait = this.allowAwaitExpression; + let previousAwaitLocation = this.firstAwaitLocation; + this.allowYieldExpression = false; + this.allowAwaitExpression = isAsync; + this.firstAwaitLocation = null; + let body; + if (this.match(TokenType.LBRACE)) { + let previousAllowIn = this.allowIn; + this.allowIn = true; + body = this.parseFunctionBody(); + this.allowIn = previousAllowIn; + } else { + body = this.parseAssignmentExpression(); + } + this.allowYieldExpression = previousYield; + this.allowAwaitExpression = previousAwait; + this.firstAwaitLocation = previousAwaitLocation; + return this.finishNode(new AST.ArrowExpression({ isAsync, params, body }), startState); + } + + parseAssignmentExpression() { + return this.isolateCoverGrammar(this.parseAssignmentExpressionOrTarget); + } + + parseAssignmentExpressionOrTarget() { + let startState = this.startNode(); + if (this.allowYieldExpression && this.match(TokenType.YIELD)) { + this.isBindingElement = this.isAssignmentTarget = false; + return this.parseYieldExpression(); + } + let expr = this.parseConditionalExpression(); + if (!this.hasLineTerminatorBeforeNext && this.match(TokenType.ARROW)) { + this.isBindingElement = this.isAssignmentTarget = false; + this.firstExprError = null; + let isAsync = expr.type === ARROW_EXPRESSION_PARAMS && expr.isAsync; + return this.parseArrowExpressionTail(this.finishArrowParams(expr), isAsync, startState); + } + let isAssignmentOperator = false; + let operator = this.lookahead; + switch (operator.type) { + case TokenType.ASSIGN_BIT_OR: + case TokenType.ASSIGN_BIT_XOR: + case TokenType.ASSIGN_BIT_AND: + case TokenType.ASSIGN_SHL: + case TokenType.ASSIGN_SHR: + case TokenType.ASSIGN_SHR_UNSIGNED: + case TokenType.ASSIGN_ADD: + case TokenType.ASSIGN_SUB: + case TokenType.ASSIGN_MUL: + case TokenType.ASSIGN_DIV: + case TokenType.ASSIGN_MOD: + case TokenType.ASSIGN_EXP: + isAssignmentOperator = true; + break; + } + if (isAssignmentOperator) { + if (!this.isAssignmentTarget || !isValidSimpleAssignmentTarget(expr)) { + throw this.createError(ErrorMessages.INVALID_LHS_IN_ASSIGNMENT); + } + expr = this.transformDestructuring(expr); + } else if (operator.type === TokenType.ASSIGN) { + if (!this.isAssignmentTarget) { + throw this.createError(ErrorMessages.INVALID_LHS_IN_ASSIGNMENT); + } + expr = this.transformDestructuring(expr); + } else { + return expr; + } + this.lex(); + let rhs = this.parseAssignmentExpression(); + + this.firstExprError = null; + let node; + if (operator.type === TokenType.ASSIGN) { + node = new AST.AssignmentExpression({ binding: expr, expression: rhs }); + } else { + node = new AST.CompoundAssignmentExpression({ binding: expr, operator: operator.type.name, expression: rhs }); + this.isBindingElement = this.isAssignmentTarget = false; + } + return this.finishNode(node, startState); + } + + targetToBinding(node) { + if (node === null) { + return null; + } + + switch (node.type) { + case 'AssignmentTargetIdentifier': + return this.copyNode(node, new AST.BindingIdentifier({ name: node.name })); + case 'ArrayAssignmentTarget': + return this.copyNode(node, new AST.ArrayBinding({ elements: node.elements.map(e => this.targetToBinding(e)), rest: this.targetToBinding(node.rest) })); + case 'ObjectAssignmentTarget': + return this.copyNode(node, new AST.ObjectBinding({ properties: node.properties.map(p => this.targetToBinding(p)), rest: this.targetToBinding(node.rest) })); + case 'AssignmentTargetPropertyIdentifier': + return this.copyNode(node, new AST.BindingPropertyIdentifier({ binding: this.targetToBinding(node.binding), init: node.init })); + case 'AssignmentTargetPropertyProperty': + return this.copyNode(node, new AST.BindingPropertyProperty({ name: node.name, binding: this.targetToBinding(node.binding) })); + case 'AssignmentTargetWithDefault': + return this.copyNode(node, new AST.BindingWithDefault({ binding: this.targetToBinding(node.binding), init: node.init })); + } + + // istanbul ignore next + throw new Error('Not reached'); + } + + transformDestructuring(node) { + switch (node.type) { + + case 'DataProperty': + return this.copyNode(node, new AST.AssignmentTargetPropertyProperty({ + name: node.name, + binding: this.transformDestructuringWithDefault(node.expression), + })); + case 'ShorthandProperty': + return this.copyNode(node, new AST.AssignmentTargetPropertyIdentifier({ + binding: this.copyNode(node, new AST.AssignmentTargetIdentifier({ name: node.name.name })), + init: null, + })); + + case 'ObjectExpression': { + let last = node.properties.length > 0 ? node.properties[node.properties.length - 1] : void 0; + if (last != null && last.type === 'SpreadProperty') { + return this.copyNode(node, new AST.ObjectAssignmentTarget({ + properties: node.properties.slice(0, -1).map(e => e && this.transformDestructuringWithDefault(e)), + rest: this.transformDestructuring(last.expression), + })); + } + + return this.copyNode(node, new AST.ObjectAssignmentTarget({ + properties: node.properties.map(e => e && this.transformDestructuringWithDefault(e)), + rest: null, + })); + } + case 'ArrayExpression': { + let last = node.elements[node.elements.length - 1]; + if (last != null && last.type === 'SpreadElement') { + return this.copyNode(node, new AST.ArrayAssignmentTarget({ + elements: node.elements.slice(0, -1).map(e => e && this.transformDestructuringWithDefault(e)), + rest: this.copyNode(last.expression, this.transformDestructuring(last.expression)), + })); + } + return this.copyNode(node, new AST.ArrayAssignmentTarget({ + elements: node.elements.map(e => e && this.transformDestructuringWithDefault(e)), + rest: null, + })); + } + case 'IdentifierExpression': + return this.copyNode(node, new AST.AssignmentTargetIdentifier({ name: node.name })); + + case 'StaticPropertyName': + return this.copyNode(node, new AST.AssignmentTargetIdentifier({ name: node.value })); + + case 'ComputedMemberExpression': + return this.copyNode(node, new AST.ComputedMemberAssignmentTarget({ object: node.object, expression: node.expression })); + case 'StaticMemberExpression': + return this.copyNode(node, new AST.StaticMemberAssignmentTarget({ object: node.object, property: node.property })); + + case 'ArrayAssignmentTarget': + case 'ObjectAssignmentTarget': + case 'ComputedMemberAssignmentTarget': + case 'StaticMemberAssignmentTarget': + case 'AssignmentTargetIdentifier': + case 'AssignmentTargetPropertyIdentifier': + case 'AssignmentTargetPropertyProperty': + case 'AssignmentTargetWithDefault': + return node; + } + // istanbul ignore next + throw new Error('Not reached'); + } + + transformDestructuringWithDefault(node) { + switch (node.type) { + case 'AssignmentExpression': + return this.copyNode(node, new AST.AssignmentTargetWithDefault({ + binding: this.transformDestructuring(node.binding), + init: node.expression, + })); + } + return this.transformDestructuring(node); + } + + lookaheadAssignmentExpression() { + if (this.matchIdentifier()) { + return true; + } + switch (this.lookahead.type) { + case TokenType.ADD: + case TokenType.ASSIGN_DIV: + case TokenType.BIT_NOT: + case TokenType.CLASS: + case TokenType.DEC: + case TokenType.DELETE: + case TokenType.DIV: + case TokenType.FALSE: + case TokenType.FUNCTION: + case TokenType.INC: + case TokenType.LBRACE: + case TokenType.LBRACK: + case TokenType.LPAREN: + case TokenType.NEW: + case TokenType.NOT: + case TokenType.NULL: + case TokenType.NUMBER: + case TokenType.STRING: + case TokenType.SUB: + case TokenType.SUPER: + case TokenType.THIS: + case TokenType.TRUE: + case TokenType.TYPEOF: + case TokenType.VOID: + case TokenType.TEMPLATE: + return true; + } + return false; + } + + parseYieldExpression() { + let startState = this.startNode(); + + this.lex(); + if (this.hasLineTerminatorBeforeNext) { + return this.finishNode(new AST.YieldExpression({ expression: null }), startState); + } + let isGenerator = !!this.eat(TokenType.MUL); + let expr = null; + if (isGenerator || this.lookaheadAssignmentExpression()) { + expr = this.parseAssignmentExpression(); + } + let ctor = isGenerator ? AST.YieldGeneratorExpression : AST.YieldExpression; + return this.finishNode(new ctor({ expression: expr }), startState); + } + + parseConditionalExpression() { + let startState = this.startNode(); + let test = this.parseBinaryExpression(); + if (this.firstExprError) return test; + if (this.eat(TokenType.CONDITIONAL)) { + this.isBindingElement = this.isAssignmentTarget = false; + let previousAllowIn = this.allowIn; + this.allowIn = true; + let consequent = this.isolateCoverGrammar(this.parseAssignmentExpression); + this.allowIn = previousAllowIn; + this.expect(TokenType.COLON); + let alternate = this.isolateCoverGrammar(this.parseAssignmentExpression); + return this.finishNode(new AST.ConditionalExpression({ test, consequent, alternate }), startState); + } + return test; + } + + isBinaryOperator(type) { + switch (type) { + case TokenType.OR: + case TokenType.AND: + case TokenType.BIT_OR: + case TokenType.BIT_XOR: + case TokenType.BIT_AND: + case TokenType.EQ: + case TokenType.NE: + case TokenType.EQ_STRICT: + case TokenType.NE_STRICT: + case TokenType.LT: + case TokenType.GT: + case TokenType.LTE: + case TokenType.GTE: + case TokenType.INSTANCEOF: + case TokenType.SHL: + case TokenType.SHR: + case TokenType.SHR_UNSIGNED: + case TokenType.ADD: + case TokenType.SUB: + case TokenType.MUL: + case TokenType.DIV: + case TokenType.MOD: + return true; + case TokenType.IN: + return this.allowIn; + default: + return false; + } + } + + parseBinaryExpression() { + let startState = this.startNode(); + let left = this.parseExponentiationExpression(); + if (this.firstExprError) { + return left; + } + + let operator = this.lookahead.type; + if (!this.isBinaryOperator(operator)) return left; + + this.isBindingElement = this.isAssignmentTarget = false; + + this.lex(); + let stack = []; + stack.push({ startState, left, operator, precedence: BinaryPrecedence[operator.name] }); + startState = this.startNode(); + let right = this.isolateCoverGrammar(this.parseExponentiationExpression); + operator = this.lookahead.type; + while (this.isBinaryOperator(operator)) { + let precedence = BinaryPrecedence[operator.name]; + // Reduce: make a binary expression from the three topmost entries. + while (stack.length && precedence <= stack[stack.length - 1].precedence) { + let stackItem = stack[stack.length - 1]; + let stackOperator = stackItem.operator; + left = stackItem.left; + stack.pop(); + startState = stackItem.startState; + right = this.finishNode(new AST.BinaryExpression({ left, operator: stackOperator.name, right }), startState); + } + + this.lex(); + stack.push({ startState, left: right, operator, precedence }); + + startState = this.startNode(); + right = this.isolateCoverGrammar(this.parseExponentiationExpression); + operator = this.lookahead.type; + } + + // Final reduce to clean-up the stack. + return stack.reduceRight((expr, stackItem) => + this.finishNode(new AST.BinaryExpression({ + left: stackItem.left, + operator: stackItem.operator.name, + right: expr, + }), stackItem.startState), + right); + } + + parseExponentiationExpression() { + let startState = this.startNode(); + + let leftIsParenthesized = this.lookahead.type === TokenType.LPAREN; + let left = this.parseUnaryExpression(); + if (this.lookahead.type !== TokenType.EXP) { + return left; + } + if (left.type === 'UnaryExpression' && !leftIsParenthesized) { + throw this.createError(ErrorMessages.INVALID_EXPONENTIATION_LHS); + } + this.lex(); + + this.isBindingElement = this.isAssignmentTarget = false; + + let right = this.isolateCoverGrammar(this.parseExponentiationExpression); + return this.finishNode(new AST.BinaryExpression({ left, operator: '**', right }), startState); + } + + parseUnaryExpression() { + if (this.lookahead.type.klass !== TokenClass.Punctuator && this.lookahead.type.klass !== TokenClass.Keyword) { + return this.parseUpdateExpression(); + } + + let startState = this.startNode(); + if (this.allowAwaitExpression && this.eat(TokenType.AWAIT)) { + this.isBindingElement = this.isAssignmentTarget = false; + let expression = this.isolateCoverGrammar(this.parseUnaryExpression); + return this.finishNode(new AST.AwaitExpression({ expression }), startState); + } + + let operator = this.lookahead; + if (!isPrefixOperator(operator)) { + return this.parseUpdateExpression(); + } + + this.lex(); + this.isBindingElement = this.isAssignmentTarget = false; + + let node; + if (isUpdateOperator(operator)) { + let operandStartLocation = this.getLocation(); + let operand = this.isolateCoverGrammar(this.parseUnaryExpression); + if (!isValidSimpleAssignmentTarget(operand)) { + throw this.createErrorWithLocation(operandStartLocation, ErrorMessages.INVALID_UPDATE_OPERAND); + } + operand = this.transformDestructuring(operand); + node = new AST.UpdateExpression({ isPrefix: true, operator: operator.value, operand }); + } else { + let operand = this.isolateCoverGrammar(this.parseUnaryExpression); + node = new AST.UnaryExpression({ operator: operator.value, operand }); + } + + return this.finishNode(node, startState); + } + + parseUpdateExpression() { + let startLocation = this.getLocation(); + let startState = this.startNode(); + + let operand = this.parseLeftHandSideExpression({ allowCall: true }); + if (this.firstExprError || this.hasLineTerminatorBeforeNext) return operand; + + let operator = this.lookahead; + if (!isUpdateOperator(operator)) return operand; + this.lex(); + this.isBindingElement = this.isAssignmentTarget = false; + if (!isValidSimpleAssignmentTarget(operand)) { + throw this.createErrorWithLocation(startLocation, ErrorMessages.INVALID_UPDATE_OPERAND); + } + operand = this.transformDestructuring(operand); + + return this.finishNode(new AST.UpdateExpression({ isPrefix: false, operator: operator.value, operand }), startState); + } + + parseLeftHandSideExpression({ allowCall }) { + let startState = this.startNode(); + let previousAllowIn = this.allowIn; + this.allowIn = true; + + let expr, token = this.lookahead; + + if (this.eat(TokenType.SUPER)) { + this.isBindingElement = false; + this.isAssignmentTarget = false; + expr = this.finishNode(new AST.Super, startState); + if (this.match(TokenType.LPAREN)) { + if (allowCall) { + expr = this.finishNode(new AST.CallExpression({ + callee: expr, + arguments: this.parseArgumentList().args, + }), startState); + } else { + throw this.createUnexpected(token); + } + } else if (this.match(TokenType.LBRACK)) { + expr = this.finishNode(new AST.ComputedMemberExpression({ + object: expr, + expression: this.parseComputedMember(), + }), startState); + this.isAssignmentTarget = true; + } else if (this.match(TokenType.PERIOD)) { + expr = this.finishNode(new AST.StaticMemberExpression({ + object: expr, + property: this.parseStaticMember(), + }), startState); + this.isAssignmentTarget = true; + } else { + throw this.createUnexpected(token); + } + } else if (this.match(TokenType.NEW)) { + this.isBindingElement = this.isAssignmentTarget = false; + expr = this.parseNewExpression(); + } else if (this.match(TokenType.ASYNC)) { + expr = this.parsePrimaryExpression(); + // there's only three things this could be: an identifier, an async arrow, or an async function expression. + if (expr.type === 'IdentifierExpression' && allowCall && !this.hasLineTerminatorBeforeNext) { + if (this.matchIdentifier()) { + // `async [no lineterminator here] identifier` must be an async arrow + let afterAsyncStartState = this.startNode(); + let previousAwait = this.allowAwaitExpression; + this.allowAwaitExpression = true; + let param = this.parseBindingIdentifier(); + this.allowAwaitExpression = previousAwait; + this.ensureArrow(); + return this.finishNode({ + type: ARROW_EXPRESSION_PARAMS, + params: [param], + rest: null, + isAsync: true, + }, afterAsyncStartState); + } + if (this.match(TokenType.LPAREN)) { + // the maximally obnoxious case: `async (` + let afterAsyncStartState = this.startNode(); + let previousAwaitLocation = this.firstAwaitLocation; + this.firstAwaitLocation = null; + let { args, locationFollowingFirstSpread } = this.parseArgumentList(); + if (this.isBindingElement && !this.hasLineTerminatorBeforeNext && this.match(TokenType.ARROW)) { + if (locationFollowingFirstSpread !== null) { + throw this.createErrorWithLocation(locationFollowingFirstSpread, ErrorMessages.UNEXPECTED_TOKEN(',')); + } + if (this.firstAwaitLocation !== null) { + throw this.createErrorWithLocation(this.firstAwaitLocation, ErrorMessages.NO_AWAIT_IN_ASYNC_PARAMS); + } + let rest = null; + if (args.length > 0 && args[args.length - 1].type === 'SpreadElement') { + rest = this.targetToBinding(this.transformDestructuringWithDefault(args[args.length - 1].expression)); + if (rest.init != null) { + throw this.createError(ErrorMessages.UNEXPECTED_REST_PARAMETERS_INITIALIZATION); + } + args = args.slice(0, -1); + } + let params = args.map(arg => this.targetToBinding(this.transformDestructuringWithDefault(arg))); + return this.finishNode({ + type: ARROW_EXPRESSION_PARAMS, + params, + rest, + isAsync: true, + }, afterAsyncStartState); + } + this.firstAwaitLocation = previousAwaitLocation || this.firstAwaitLocation; + // otherwise we've just taken the first iteration of the loop below + this.isBindingElement = this.isAssignmentTarget = false; + expr = this.finishNode(new AST.CallExpression({ + callee: expr, + arguments: args, + }), startState); + } + } + } else { + expr = this.parsePrimaryExpression(); + if (this.firstExprError) { + return expr; + } + } + + while (true) { + if (allowCall && this.match(TokenType.LPAREN)) { + this.isBindingElement = this.isAssignmentTarget = false; + expr = this.finishNode(new AST.CallExpression({ + callee: expr, + arguments: this.parseArgumentList().args, + }), startState); + } else if (this.match(TokenType.LBRACK)) { + this.isBindingElement = false; + this.isAssignmentTarget = true; + expr = this.finishNode(new AST.ComputedMemberExpression({ + object: expr, + expression: this.parseComputedMember(), + }), startState); + } else if (this.match(TokenType.PERIOD)) { + this.isBindingElement = false; + this.isAssignmentTarget = true; + expr = this.finishNode(new AST.StaticMemberExpression({ + object: expr, + property: this.parseStaticMember(), + }), startState); + } else if (this.match(TokenType.TEMPLATE)) { + this.isBindingElement = this.isAssignmentTarget = false; + expr = this.finishNode(new AST.TemplateExpression({ + tag: expr, + elements: this.parseTemplateElements(), + }), startState); + } else { + break; + } + } + + this.allowIn = previousAllowIn; + + return expr; + } + + parseTemplateElements() { + let startState = this.startNode(); + let token = this.lookahead; + if (token.tail) { + this.lex(); + return [this.finishNode(new AST.TemplateElement({ rawValue: token.slice.text.slice(1, -1) }), startState)]; + } + let result = [ + this.finishNode(new AST.TemplateElement({ rawValue: this.lex().slice.text.slice(1, -2) }), startState), + ]; + while (true) { + result.push(this.parseExpression()); + if (!this.match(TokenType.RBRACE)) { + throw this.createILLEGAL(); + } + this.index = this.startIndex; + this.line = this.startLine; + this.lineStart = this.startLineStart; + this.lookahead = this.scanTemplateElement(); + startState = this.startNode(); + token = this.lex(); + if (token.tail) { + result.push(this.finishNode(new AST.TemplateElement({ rawValue: token.slice.text.slice(1, -1) }), startState)); + return result; + } + result.push(this.finishNode(new AST.TemplateElement({ rawValue: token.slice.text.slice(1, -2) }), startState)); + } + } + + parseStaticMember() { + this.lex(); + if (this.lookahead.type.klass.isIdentifierName) { + return this.lex().value; + } + throw this.createUnexpected(this.lookahead); + } + + parseComputedMember() { + this.lex(); + let expr = this.parseExpression(); + this.expect(TokenType.RBRACK); + return expr; + } + + parseNewExpression() { + let startState = this.startNode(); + this.lex(); + if (this.eat(TokenType.PERIOD)) { + this.expectContextualKeyword('target'); + return this.finishNode(new AST.NewTargetExpression, startState); + } + let callee = this.isolateCoverGrammar(() => this.parseLeftHandSideExpression({ allowCall: false })); + return this.finishNode(new AST.NewExpression({ + callee, + arguments: this.match(TokenType.LPAREN) ? this.parseArgumentList().args : [], + }), startState); + } + + parseRegexFlags(flags) { + let global = false, + ignoreCase = false, + multiLine = false, + unicode = false, + sticky = false, + dotAll = false; + for (let i = 0; i < flags.length; ++i) { + let f = flags[i]; + switch (f) { + case 'g': + if (global) { + throw this.createError('Duplicate regular expression flag \'g\''); + } + global = true; + break; + case 'i': + if (ignoreCase) { + throw this.createError('Duplicate regular expression flag \'i\''); + } + ignoreCase = true; + break; + case 'm': + if (multiLine) { + throw this.createError('Duplicate regular expression flag \'m\''); + } + multiLine = true; + break; + case 'u': + if (unicode) { + throw this.createError('Duplicate regular expression flag \'u\''); + } + unicode = true; + break; + case 'y': + if (sticky) { + throw this.createError('Duplicate regular expression flag \'y\''); + } + sticky = true; + break; + case 's': + if (dotAll) { + throw this.createError('Duplicate regular expression flag \'s\''); + } + dotAll = true; + break; + default: + throw this.createError(`Invalid regular expression flag '${f}'`); + } + } + return { global, ignoreCase, multiLine, unicode, sticky, dotAll }; + } + + parsePrimaryExpression() { + if (this.match(TokenType.LPAREN)) { + return this.parseGroupExpression(); + } + + let startState = this.startNode(); + + if (this.eat(TokenType.ASYNC)) { + if (!this.hasLineTerminatorBeforeNext && this.match(TokenType.FUNCTION)) { + this.isBindingElement = this.isAssignmentTarget = false; + return this.finishNode(this.parseFunction({ isExpr: true, inDefault: false, allowGenerator: true, isAsync: true }), startState); + } + return this.finishNode(new AST.IdentifierExpression({ name: 'async' }), startState); + } + + if (this.matchIdentifier()) { + return this.finishNode(new AST.IdentifierExpression({ name: this.parseIdentifier() }), startState); + } + switch (this.lookahead.type) { + case TokenType.STRING: + this.isBindingElement = this.isAssignmentTarget = false; + return this.parseStringLiteral(); + case TokenType.NUMBER: + this.isBindingElement = this.isAssignmentTarget = false; + return this.parseNumericLiteral(); + case TokenType.THIS: + this.lex(); + this.isBindingElement = this.isAssignmentTarget = false; + return this.finishNode(new AST.ThisExpression, startState); + case TokenType.FUNCTION: + this.isBindingElement = this.isAssignmentTarget = false; + return this.finishNode(this.parseFunction({ isExpr: true, inDefault: false, allowGenerator: true, isAsync: false }), startState); + case TokenType.TRUE: + this.lex(); + this.isBindingElement = this.isAssignmentTarget = false; + return this.finishNode(new AST.LiteralBooleanExpression({ value: true }), startState); + case TokenType.FALSE: + this.lex(); + this.isBindingElement = this.isAssignmentTarget = false; + return this.finishNode(new AST.LiteralBooleanExpression({ value: false }), startState); + case TokenType.NULL: + this.lex(); + this.isBindingElement = this.isAssignmentTarget = false; + return this.finishNode(new AST.LiteralNullExpression, startState); + case TokenType.LBRACK: + return this.parseArrayExpression(); + case TokenType.LBRACE: + return this.parseObjectExpression(); + case TokenType.TEMPLATE: + this.isBindingElement = this.isAssignmentTarget = false; + return this.finishNode(new AST.TemplateExpression({ tag: null, elements: this.parseTemplateElements() }), startState); + case TokenType.DIV: + case TokenType.ASSIGN_DIV: { + this.isBindingElement = this.isAssignmentTarget = false; + this.lookahead = this.scanRegExp(this.match(TokenType.DIV) ? '/' : '/='); + let token = this.lex(); + let lastSlash = token.value.lastIndexOf('/'); + let pattern = token.value.slice(1, lastSlash); + let flags = token.value.slice(lastSlash + 1); + let ctorArgs = this.parseRegexFlags(flags); + if (!acceptRegex(pattern, ctorArgs)) { + throw this.createError(ErrorMessages.INVALID_REGEX); + } + ctorArgs.pattern = pattern; + return this.finishNode(new AST.LiteralRegExpExpression(ctorArgs), startState); + } + case TokenType.CLASS: + this.isBindingElement = this.isAssignmentTarget = false; + return this.parseClass({ isExpr: true, inDefault: false }); + default: + throw this.createUnexpected(this.lookahead); + } + } + + parseNumericLiteral() { + let startLocation = this.getLocation(); + let startState = this.startNode(); + let token = this.lex(); + if (token.octal && this.strict) { + if (token.noctal) { + throw this.createErrorWithLocation(startLocation, 'Unexpected noctal integer literal'); + } else { + throw this.createErrorWithLocation(startLocation, 'Unexpected legacy octal integer literal'); + } + } + let node = token.value === 1 / 0 + ? new AST.LiteralInfinityExpression + : new AST.LiteralNumericExpression({ value: token.value }); + return this.finishNode(node, startState); + } + + parseStringLiteral() { + let startLocation = this.getLocation(); + let startState = this.startNode(); + let token = this.lex(); + if (token.octal != null && this.strict) { + throw this.createErrorWithLocation(startLocation, 'Unexpected legacy octal escape sequence: \\' + token.octal); + } + return this.finishNode(new AST.LiteralStringExpression({ value: token.str }), startState); + } + + parseIdentifierName() { + if (this.lookahead.type.klass.isIdentifierName) { + return this.lex().value; + } + throw this.createUnexpected(this.lookahead); + } + + parseBindingIdentifier() { + let startState = this.startNode(); + return this.finishNode(new AST.BindingIdentifier({ name: this.parseIdentifier() }), startState); + } + + parseIdentifier() { + if (this.lookahead.value === 'yield' && this.allowYieldExpression) { + throw this.createError(ErrorMessages.ILLEGAL_YIELD_IDENTIFIER); + } + if (this.lookahead.value === 'await' && this.allowAwaitExpression) { + throw this.createError(ErrorMessages.ILLEGAL_AWAIT_IDENTIFIER); + } + if (this.matchIdentifier()) { + return this.lex().value; + } + throw this.createUnexpected(this.lookahead); + } + + parseArgumentList() { + this.lex(); + let args = this.parseArguments(); + this.expect(TokenType.RPAREN); + return args; + } + + parseArguments() { + let args = []; + let locationFollowingFirstSpread = null; + while (!this.match(TokenType.RPAREN)) { + let arg; + let startState = this.startNode(); + if (this.eat(TokenType.ELLIPSIS)) { + arg = this.finishNode(new AST.SpreadElement({ expression: this.inheritCoverGrammar(this.parseAssignmentExpressionOrTarget) }), startState); + if (locationFollowingFirstSpread === null) { + args.push(arg); + if (this.match(TokenType.RPAREN)) { + break; + } + locationFollowingFirstSpread = this.getLocation(); + this.expect(TokenType.COMMA); + continue; + } + } else { + arg = this.inheritCoverGrammar(this.parseAssignmentExpressionOrTarget); + } + args.push(arg); + if (this.match(TokenType.RPAREN)) { + break; + } + this.expect(TokenType.COMMA); + } + return { args, locationFollowingFirstSpread }; + } + + // 11.2 Left-Hand-Side Expressions; + + ensureArrow() { + if (this.hasLineTerminatorBeforeNext) { + throw this.createError(ErrorMessages.UNEXPECTED_LINE_TERMINATOR); + } + if (!this.match(TokenType.ARROW)) { + this.expect(TokenType.ARROW); + } + } + + parseGroupExpression() { + // At this point, we need to parse 3 things: + // 1. Group expression + // 2. Assignment target of assignment expression + // 3. Parameter list of arrow function + let rest = null; + let preParenStartState = this.startNode(); + let start = this.expect(TokenType.LPAREN); + let postParenStartState = this.startNode(); + if (this.match(TokenType.RPAREN)) { + this.lex(); + let paramsNode = this.finishNode({ + type: ARROW_EXPRESSION_PARAMS, + params: [], + rest: null, + isAsync: false, + }, preParenStartState); + this.ensureArrow(); + this.isBindingElement = this.isAssignmentTarget = false; + return paramsNode; + } else if (this.eat(TokenType.ELLIPSIS)) { + rest = this.parseBindingTarget(); + if (this.match(TokenType.ASSIGN)) { + throw this.createError(ErrorMessages.INVALID_REST_PARAMETERS_INITIALIZATION); + } + if (this.match(TokenType.COMMA)) { + throw this.createError(ErrorMessages.INVALID_LAST_REST_PARAMETER); + } + this.expect(TokenType.RPAREN); + let paramsNode = this.finishNode({ + type: ARROW_EXPRESSION_PARAMS, + params: [], + rest, + isAsync: false, + }, preParenStartState); + this.ensureArrow(); + this.isBindingElement = this.isAssignmentTarget = false; + return paramsNode; + } + let group = this.inheritCoverGrammar(this.parseAssignmentExpressionOrTarget); + + let params = this.isBindingElement ? [this.targetToBinding(this.transformDestructuringWithDefault(group))] : null; + + while (this.eat(TokenType.COMMA)) { + if (this.match(TokenType.RPAREN)) { + if (!this.isBindingElement) { + throw this.createUnexpected(this.lookahead); + } + this.firstExprError = this.firstExprError || this.createUnexpected(this.lookahead); + group = null; + break; + } + this.isAssignmentTarget = false; + if (this.match(TokenType.ELLIPSIS)) { + if (!this.isBindingElement) { + throw this.createUnexpected(this.lookahead); + } + this.lex(); + rest = this.parseBindingTarget(); + if (this.match(TokenType.ASSIGN)) { + throw this.createError(ErrorMessages.INVALID_REST_PARAMETERS_INITIALIZATION); + } + if (this.match(TokenType.COMMA)) { + throw this.createError(ErrorMessages.INVALID_LAST_REST_PARAMETER); + } + break; + } + + if (group) { + // Can be either binding element or assignment target. + let expr = this.inheritCoverGrammar(this.parseAssignmentExpressionOrTarget); + if (this.isBindingElement) { + params.push(this.targetToBinding(this.transformDestructuringWithDefault(expr))); + } else { + params = null; + } + + if (this.firstExprError) { + group = null; + } else { + group = this.finishNode(new AST.BinaryExpression({ + left: group, + operator: ',', + right: expr, + }), postParenStartState); + } + } else { + // Can be only binding elements. + let binding = this.parseBindingElement(); + params.push(binding); + } + } + this.expect(TokenType.RPAREN); + + if (!this.hasLineTerminatorBeforeNext && this.match(TokenType.ARROW)) { + if (!this.isBindingElement) { + throw this.createErrorWithLocation(start, ErrorMessages.ILLEGAL_ARROW_FUNCTION_PARAMS); + } + + this.isBindingElement = false; + return this.finishNode({ + type: ARROW_EXPRESSION_PARAMS, + params, + rest, + isAsync: false, + }, preParenStartState); + } + // Ensure assignment pattern: + if (rest) { + this.ensureArrow(); + } + this.isBindingElement = false; + if (!isValidSimpleAssignmentTarget(group)) { + this.isAssignmentTarget = false; + } + return group; + } + + parseArrayExpression() { + let startLocation = this.getLocation(); + let startState = this.startNode(); + + this.lex(); + + let exprs = []; + let rest = null; + + while (true) { + if (this.match(TokenType.RBRACK)) { + break; + } + if (this.eat(TokenType.COMMA)) { + exprs.push(null); + } else { + let elementStartState = this.startNode(); + let expr; + if (this.eat(TokenType.ELLIPSIS)) { + // Spread/Rest element + expr = this.inheritCoverGrammar(this.parseAssignmentExpressionOrTarget); + if (!this.isAssignmentTarget && this.firstExprError) { + throw this.firstExprError; + } + if (expr.type === 'ArrayAssignmentTarget' || expr.type === 'ObjectAssignmentTarget') { + rest = expr; + break; + } + if (expr.type !== 'ArrayExpression' && expr.type !== 'ObjectExpression' && !isValidSimpleAssignmentTarget(expr)) { + this.isBindingElement = this.isAssignmentTarget = false; + } + expr = this.finishNode(new AST.SpreadElement({ expression: expr }), elementStartState); + if (!this.match(TokenType.RBRACK)) { + this.isBindingElement = this.isAssignmentTarget = false; + } + } else { + expr = this.inheritCoverGrammar(this.parseAssignmentExpressionOrTarget); + if (!this.isAssignmentTarget && this.firstExprError) { + throw this.firstExprError; + } + } + exprs.push(expr); + + if (!this.match(TokenType.RBRACK)) { + this.expect(TokenType.COMMA); + } + } + } + + if (rest && this.match(TokenType.COMMA)) { + throw this.createErrorWithLocation(startLocation, ErrorMessages.UNEXPECTED_COMMA_AFTER_REST); + } + + this.expect(TokenType.RBRACK); + + if (rest) { + // No need to check isAssignmentTarget: the only way to have something we know is a rest element is if we have ...Object/ArrayAssignmentTarget, which implies we have a firstExprError; as such, if isAssignmentTarget were false, we'd've thrown above before setting rest. + return this.finishNode(new AST.ArrayAssignmentTarget({ + elements: exprs.map(e => e && this.transformDestructuringWithDefault(e)), + rest, + }), startState); + } else if (this.firstExprError) { + let last = exprs[exprs.length - 1]; + if (last != null && last.type === 'SpreadElement') { + return this.finishNode(new AST.ArrayAssignmentTarget({ + elements: exprs.slice(0, -1).map(e => e && this.transformDestructuringWithDefault(e)), + rest: this.transformDestructuring(last.expression), + }), startState); + } + return this.finishNode(new AST.ArrayAssignmentTarget({ + elements: exprs.map(e => e && this.transformDestructuringWithDefault(e)), + rest: null, + }), startState); + + } + return this.finishNode(new AST.ArrayExpression({ elements: exprs }), startState); + } + + parseObjectExpression() { + let startState = this.startNode(); + this.lex(); + let properties = []; + while (!this.match(TokenType.RBRACE)) { + let isSpreadProperty = false; + if (this.match(TokenType.ELLIPSIS)) { + isSpreadProperty = true; + let spreadPropertyOrAssignmentTarget = this.parseSpreadPropertyDefinition(); + properties.push(spreadPropertyOrAssignmentTarget); + } else { + let property = this.inheritCoverGrammar(this.parsePropertyDefinition); + properties.push(property); + } + if (!this.match(TokenType.RBRACE)) { + this.expect(TokenType.COMMA); + if (isSpreadProperty) { + this.isBindingElement = this.isAssignmentTarget = false; + } + } + } + this.expect(TokenType.RBRACE); + if (this.firstExprError) { + if (!this.isAssignmentTarget) { + throw this.createError(ErrorMessages.INVALID_LHS_IN_BINDING); + } + let last = properties[properties.length - 1]; + if (last != null && last.type === 'SpreadProperty') { + return this.finishNode(new AST.ObjectAssignmentTarget({ + properties: properties.slice(0, -1).map(p => this.transformDestructuringWithDefault(p)), + rest: this.transformDestructuring(last.expression), + }), startState); + } + return this.finishNode(new AST.ObjectAssignmentTarget({ properties: properties.map(p => this.transformDestructuringWithDefault(p)), rest: null }), startState); + } + return this.finishNode(new AST.ObjectExpression({ properties }), startState); + } + + parseSpreadPropertyDefinition() { + let startState = this.startNode(); + this.expect(TokenType.ELLIPSIS); + let expression = this.parseAssignmentExpression(); + if (!isValidSimpleAssignmentTarget(expression)) { + this.isBindingElement = this.isAssignmentTarget = false; + } else if (expression.type !== 'IdentifierExpression') { + this.isBindingElement = false; + } + return this.finishNode(new AST.SpreadProperty({ expression }), startState); + } + + parsePropertyDefinition() { + let startLocation = this.getLocation(); + let startState = this.startNode(); + let token = this.lookahead; + + let { methodOrKey, kind } = this.parseMethodDefinition(); + switch (kind) { + case 'method': + this.isBindingElement = this.isAssignmentTarget = false; + return methodOrKey; + case 'identifier': + if (token.value === 'await' && this.firstAwaitLocation == null) { + this.firstAwaitLocation = this.getLocation(); + } + if (this.eat(TokenType.ASSIGN)) { + if (this.allowYieldExpression && token.value === 'yield') { + throw this.createError(ErrorMessages.ILLEGAL_YIELD_IDENTIFIER); + } + if (this.allowAwaitExpression && token.value === 'await') { + throw this.createError(ErrorMessages.ILLEGAL_AWAIT_IDENTIFIER); + } + // CoverInitializedName + let init = this.isolateCoverGrammar(this.parseAssignmentExpression); + this.firstExprError = this.createErrorWithLocation(startLocation, ErrorMessages.ILLEGAL_PROPERTY); + return this.finishNode(new AST.AssignmentTargetPropertyIdentifier({ + binding: this.transformDestructuring(methodOrKey), + init, + }), startState); + } else if (!this.match(TokenType.COLON)) { + if (this.allowYieldExpression && token.value === 'yield') { + throw this.createError(ErrorMessages.ILLEGAL_YIELD_IDENTIFIER); + } + if (this.allowAwaitExpression && token.value === 'await') { + throw this.createError(ErrorMessages.ILLEGAL_AWAIT_IDENTIFIER); + } + if (token.type === TokenType.IDENTIFIER || token.value === 'let' || token.value === 'yield' || token.value === 'async' || token.value === 'await') { + return this.finishNode(new AST.ShorthandProperty({ name: this.finishNode(new AST.IdentifierExpression({ name: methodOrKey.value }), startState) }), startState); + } + throw this.createUnexpected(token); + } + } + + // property + this.expect(TokenType.COLON); + + let expr = this.inheritCoverGrammar(this.parseAssignmentExpressionOrTarget); + if (this.firstExprError) { + return this.finishNode(new AST.AssignmentTargetPropertyProperty({ name: methodOrKey, binding: expr }), startState); + } + return this.finishNode(new AST.DataProperty({ name: methodOrKey, expression: expr }), startState); + } + + parsePropertyName() { + // PropertyName[Yield,GeneratorParameter]: + let token = this.lookahead; + let startState = this.startNode(); + + if (this.eof()) { + throw this.createUnexpected(token); + } + + switch (token.type) { + case TokenType.STRING: + return { + name: this.finishNode(new AST.StaticPropertyName({ + value: this.parseStringLiteral().value, + }), startState), + binding: null, + }; + case TokenType.NUMBER: { + let numLiteral = this.parseNumericLiteral(); + return { + name: this.finishNode(new AST.StaticPropertyName({ + value: `${numLiteral.type === 'LiteralInfinityExpression' ? 1 / 0 : numLiteral.value}`, + }), startState), + binding: null, + }; + } + case TokenType.LBRACK: { + this.lex(); + let expr = this.parseAssignmentExpression(); + this.expect(TokenType.RBRACK); + return { name: this.finishNode(new AST.ComputedPropertyName({ expression: expr }), startState), binding: null }; + } + } + + let name = this.parseIdentifierName(); + return { + name: this.finishNode(new AST.StaticPropertyName({ value: name }), startState), + binding: this.finishNode(new AST.BindingIdentifier({ name }), startState), + }; + } + + /** + * Test if lookahead can be the beginning of a `PropertyName`. + * @returns {boolean} + */ + lookaheadPropertyName() { + switch (this.lookahead.type) { + case TokenType.NUMBER: + case TokenType.STRING: + case TokenType.LBRACK: + return true; + default: + return this.lookahead.type.klass.isIdentifierName; + } + } + + // eslint-disable-next-line valid-jsdoc + /** + * Try to parse a method definition. + * + * If it turns out to be one of: + * * `IdentifierReference` + * * `CoverInitializedName` (`IdentifierReference "=" AssignmentExpression`) + * * `PropertyName : AssignmentExpression` + * The parser will stop at the end of the leading `Identifier` or `PropertyName` and return it. + * + * @returns {{methodOrKey: (Method|PropertyName), kind: string}} + */ + parseMethodDefinition() { + let token = this.lookahead; + let startState = this.startNode(); + + let preAsyncTokenState = this.saveLexerState(); + + let isAsync = !!this.eat(TokenType.ASYNC); + if (isAsync && this.hasLineTerminatorBeforeNext) { + isAsync = false; + this.restoreLexerState(preAsyncTokenState); + } + + let isGenerator = !!this.eat(TokenType.MUL); + if (isAsync && !this.lookaheadPropertyName()) { + isAsync = false; + isGenerator = false; + this.restoreLexerState(preAsyncTokenState); + } + + let { name } = this.parsePropertyName(); + + if (!isGenerator && !isAsync) { + if (token.type === TokenType.IDENTIFIER && token.value.length === 3) { + // Property Assignment: Getter and Setter. + if (token.value === 'get' && this.lookaheadPropertyName() && !token.escaped) { + ({ name } = this.parsePropertyName()); + this.expect(TokenType.LPAREN); + this.expect(TokenType.RPAREN); + let previousYield = this.allowYieldExpression; + let previousAwait = this.allowAwaitExpression; + let previousAwaitLocation = this.firstAwaitLocation; + this.allowYieldExpression = false; + this.allowAwaitExpression = false; + this.firstAwaitLocation = null; + let body = this.parseFunctionBody(); + this.allowYieldExpression = previousYield; + this.allowAwaitExpression = previousAwait; + this.firstAwaitLocation = previousAwaitLocation; + return { + methodOrKey: this.finishNode(new AST.Getter({ name, body }), startState), + kind: 'method', + }; + } else if (token.value === 'set' && this.lookaheadPropertyName() && !token.escaped) { + ({ name } = this.parsePropertyName()); + this.expect(TokenType.LPAREN); + let previousYield = this.allowYieldExpression; + let previousAwait = this.allowAwaitExpression; + let previousAwaitLocation = this.firstAwaitLocation; + this.allowYieldExpression = false; + this.allowAwaitExpression = false; + this.firstAwaitLocation = null; + let param = this.parseBindingElement(); + this.expect(TokenType.RPAREN); + let body = this.parseFunctionBody(); + this.allowYieldExpression = previousYield; + this.allowAwaitExpression = previousAwait; + this.firstAwaitLocation = previousAwaitLocation; + return { + methodOrKey: this.finishNode(new AST.Setter({ name, param, body }), startState), + kind: 'method', + }; + } + } + } + if (isAsync) { + let previousYield = this.allowYieldExpression; + let previousAwait = this.allowAwaitExpression; + this.allowYieldExpression = isGenerator; + this.allowAwaitExpression = true; + let params = this.parseParams(); + this.allowYieldExpression = isGenerator; + this.allowAwaitExpression = true; + let body = this.parseFunctionBody(); + this.allowYieldExpression = previousYield; + this.allowAwaitExpression = previousAwait; + return { + methodOrKey: this.finishNode(new AST.Method({ isAsync, isGenerator, name, params, body }), startState), + kind: 'method', + }; + } + + if (this.match(TokenType.LPAREN)) { + let previousYield = this.allowYieldExpression; + let previousAwait = this.allowAwaitExpression; + let previousAwaitLocation = this.firstAwaitLocation; + this.allowYieldExpression = isGenerator; + this.allowAwaitExpression = false; + this.firstAwaitLocation = null; + let params = this.parseParams(); + let body = this.parseFunctionBody(); + this.allowYieldExpression = previousYield; + this.allowAwaitExpression = previousAwait; + this.firstAwaitLocation = previousAwaitLocation; + + return { + methodOrKey: this.finishNode(new AST.Method({ isAsync, isGenerator, name, params, body }), startState), + kind: 'method', + }; + } + + if (isGenerator && this.match(TokenType.COLON)) { + throw this.createUnexpected(this.lookahead); + } + + return { + methodOrKey: name, + kind: token.type.klass.isIdentifierName ? 'identifier' : 'property', + escaped: token.escaped, + }; + } + + parseClass({ isExpr, inDefault }) { + let startState = this.startNode(); + + this.lex(); + let name = null; + let heritage = null; + + if (this.matchIdentifier()) { + name = this.parseBindingIdentifier(); + } else if (!isExpr) { + if (inDefault) { + name = new AST.BindingIdentifier({ name: '*default*' }); + } else { + throw this.createUnexpected(this.lookahead); + } + } + + if (this.eat(TokenType.EXTENDS)) { + heritage = this.isolateCoverGrammar(() => this.parseLeftHandSideExpression({ allowCall: true })); + } + + this.expect(TokenType.LBRACE); + let elements = []; + while (!this.eat(TokenType.RBRACE)) { + if (this.eat(TokenType.SEMICOLON)) { + continue; + } + let isStatic = false; + let classElementStart = this.startNode(); + let { methodOrKey, kind, escaped } = this.parseMethodDefinition(); + if (kind === 'identifier' && methodOrKey.value === 'static' && !escaped) { + isStatic = true; + ({ methodOrKey, kind } = this.parseMethodDefinition()); + } + if (kind === 'method') { + elements.push(this.finishNode(new AST.ClassElement({ isStatic, method: methodOrKey }), classElementStart)); + } else { + throw this.createError('Only methods are allowed in classes'); + } + } + return this.finishNode(new (isExpr ? AST.ClassExpression : AST.ClassDeclaration)({ name, super: heritage, elements }), startState); + } + + parseFunction({ isExpr, inDefault, allowGenerator, isAsync, startState = this.startNode() }) { + this.lex(); + let name = null; + let isGenerator = allowGenerator && !!this.eat(TokenType.MUL); + + let previousYield = this.allowYieldExpression; + let previousAwait = this.allowAwaitExpression; + let previousAwaitLocation = this.firstAwaitLocation; + + if (isExpr) { + this.allowYieldExpression = isGenerator; + this.allowAwaitExpression = isAsync; + } + + if (!this.match(TokenType.LPAREN)) { + name = this.parseBindingIdentifier(); + } else if (!isExpr) { + if (inDefault) { + name = new AST.BindingIdentifier({ name: '*default*' }); + } else { + throw this.createUnexpected(this.lookahead); + } + } + this.allowYieldExpression = isGenerator; + this.allowAwaitExpression = isAsync; + this.firstAwaitLocation = null; + let params = this.parseParams(); + let body = this.parseFunctionBody(); + this.allowYieldExpression = previousYield; + this.allowAwaitExpression = previousAwait; + this.firstAwaitLocation = previousAwaitLocation; + + return this.finishNode(new (isExpr ? AST.FunctionExpression : AST.FunctionDeclaration)({ isAsync, isGenerator, name, params, body }), startState); + } + + parseArrayBinding() { + let startState = this.startNode(); + + this.expect(TokenType.LBRACK); + + let elements = [], rest = null; + + while (true) { + if (this.match(TokenType.RBRACK)) { + break; + } + let el; + + if (this.eat(TokenType.COMMA)) { + el = null; + } else { + if (this.eat(TokenType.ELLIPSIS)) { + rest = this.parseBindingTarget(); + break; + } else { + el = this.parseBindingElement(); + } + if (!this.match(TokenType.RBRACK)) { + this.expect(TokenType.COMMA); + } + } + elements.push(el); + } + + this.expect(TokenType.RBRACK); + + return this.finishNode(new AST.ArrayBinding({ elements, rest }), startState); + } + + parseBindingProperty() { + let startState = this.startNode(); + let isIdentifier = this.matchIdentifier(); + let token = this.lookahead; + let { name, binding } = this.parsePropertyName(); + if (isIdentifier && name.type === 'StaticPropertyName') { + if (!this.match(TokenType.COLON)) { + if (this.allowYieldExpression && token.value === 'yield') { + throw this.createError(ErrorMessages.ILLEGAL_YIELD_IDENTIFIER); + } + if (this.allowAwaitExpression && token.value === 'await') { + throw this.createError(ErrorMessages.ILLEGAL_AWAIT_IDENTIFIER); + } + let defaultValue = null; + if (this.eat(TokenType.ASSIGN)) { + defaultValue = this.parseAssignmentExpression(); + } + return this.finishNode(new AST.BindingPropertyIdentifier({ + binding, + init: defaultValue, + }), startState); + } + } + this.expect(TokenType.COLON); + binding = this.parseBindingElement(); + return this.finishNode(new AST.BindingPropertyProperty({ name, binding }), startState); + } + + parseObjectBinding() { + let startState = this.startNode(); + this.expect(TokenType.LBRACE); + + let properties = []; + let rest = null; + while (!this.match(TokenType.RBRACE)) { + if (this.eat(TokenType.ELLIPSIS)) { + rest = this.parseBindingIdentifier(); + break; + } + properties.push(this.parseBindingProperty()); + if (!this.match(TokenType.RBRACE)) { + this.expect(TokenType.COMMA); + } + } + + this.expect(TokenType.RBRACE); + + return this.finishNode(new AST.ObjectBinding({ properties, rest }), startState); + } + + parseBindingTarget() { + if (this.matchIdentifier()) { + return this.parseBindingIdentifier(); + } + switch (this.lookahead.type) { + case TokenType.LBRACK: + return this.parseArrayBinding(); + case TokenType.LBRACE: + return this.parseObjectBinding(); + } + throw this.createUnexpected(this.lookahead); + } + + parseBindingElement() { + let startState = this.startNode(); + let binding = this.parseBindingTarget(); + if (this.eat(TokenType.ASSIGN)) { + let init = this.parseAssignmentExpression(); + binding = this.finishNode(new AST.BindingWithDefault({ binding, init }), startState); + } + return binding; + } + + parseParam() { + let previousInParameter = this.inParameter; + this.inParameter = true; + let param = this.parseBindingElement(); + this.inParameter = previousInParameter; + return param; + } + + parseParams() { + let startState = this.startNode(); + this.expect(TokenType.LPAREN); + + let items = [], rest = null; + while (!this.match(TokenType.RPAREN)) { + if (this.eat(TokenType.ELLIPSIS)) { + rest = this.parseBindingTarget(); + if (this.lookahead.type === TokenType.ASSIGN) { + throw this.createError(ErrorMessages.UNEXPECTED_REST_PARAMETERS_INITIALIZATION); + } + if (this.match(TokenType.COMMA)) { + throw this.createError(ErrorMessages.UNEXPECTED_COMMA_AFTER_REST); + } + break; + } + items.push(this.parseParam()); + if (this.match(TokenType.RPAREN)) break; + this.expect(TokenType.COMMA); + } + + this.expect(TokenType.RPAREN); + + return this.finishNode(new AST.FormalParameters({ items, rest }), startState); + } +} diff --git a/docs/dist/shift-parser/tokenizer.js b/docs/dist/shift-parser/tokenizer.js new file mode 100644 index 00000000..f5e24611 --- /dev/null +++ b/docs/dist/shift-parser/tokenizer.js @@ -0,0 +1,1505 @@ +/** + * Copyright 2014 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +import { getHexValue, isLineTerminator, isWhiteSpace, isIdentifierStart, isIdentifierPart, isDecimalDigit } from './utils.js'; +import { ErrorMessages } from './errors.js'; + +export const TokenClass = { + Eof: { name: '' }, + Ident: { name: 'Identifier', isIdentifierName: true }, + Keyword: { name: 'Keyword', isIdentifierName: true }, + NumericLiteral: { name: 'Numeric' }, + TemplateElement: { name: 'Template' }, + Punctuator: { name: 'Punctuator' }, + StringLiteral: { name: 'String' }, + RegularExpression: { name: 'RegularExpression' }, + Illegal: { name: 'Illegal' }, +}; + +export const TokenType = { + EOS: { klass: TokenClass.Eof, name: 'EOS' }, + LPAREN: { klass: TokenClass.Punctuator, name: '(' }, + RPAREN: { klass: TokenClass.Punctuator, name: ')' }, + LBRACK: { klass: TokenClass.Punctuator, name: '[' }, + RBRACK: { klass: TokenClass.Punctuator, name: ']' }, + LBRACE: { klass: TokenClass.Punctuator, name: '{' }, + RBRACE: { klass: TokenClass.Punctuator, name: '}' }, + COLON: { klass: TokenClass.Punctuator, name: ':' }, + SEMICOLON: { klass: TokenClass.Punctuator, name: ';' }, + PERIOD: { klass: TokenClass.Punctuator, name: '.' }, + ELLIPSIS: { klass: TokenClass.Punctuator, name: '...' }, + ARROW: { klass: TokenClass.Punctuator, name: '=>' }, + CONDITIONAL: { klass: TokenClass.Punctuator, name: '?' }, + INC: { klass: TokenClass.Punctuator, name: '++' }, + DEC: { klass: TokenClass.Punctuator, name: '--' }, + ASSIGN: { klass: TokenClass.Punctuator, name: '=' }, + ASSIGN_BIT_OR: { klass: TokenClass.Punctuator, name: '|=' }, + ASSIGN_BIT_XOR: { klass: TokenClass.Punctuator, name: '^=' }, + ASSIGN_BIT_AND: { klass: TokenClass.Punctuator, name: '&=' }, + ASSIGN_SHL: { klass: TokenClass.Punctuator, name: '<<=' }, + ASSIGN_SHR: { klass: TokenClass.Punctuator, name: '>>=' }, + ASSIGN_SHR_UNSIGNED: { klass: TokenClass.Punctuator, name: '>>>=' }, + ASSIGN_ADD: { klass: TokenClass.Punctuator, name: '+=' }, + ASSIGN_SUB: { klass: TokenClass.Punctuator, name: '-=' }, + ASSIGN_MUL: { klass: TokenClass.Punctuator, name: '*=' }, + ASSIGN_DIV: { klass: TokenClass.Punctuator, name: '/=' }, + ASSIGN_MOD: { klass: TokenClass.Punctuator, name: '%=' }, + ASSIGN_EXP: { klass: TokenClass.Punctuator, name: '**=' }, + COMMA: { klass: TokenClass.Punctuator, name: ',' }, + OR: { klass: TokenClass.Punctuator, name: '||' }, + AND: { klass: TokenClass.Punctuator, name: '&&' }, + BIT_OR: { klass: TokenClass.Punctuator, name: '|' }, + BIT_XOR: { klass: TokenClass.Punctuator, name: '^' }, + BIT_AND: { klass: TokenClass.Punctuator, name: '&' }, + SHL: { klass: TokenClass.Punctuator, name: '<<' }, + SHR: { klass: TokenClass.Punctuator, name: '>>' }, + SHR_UNSIGNED: { klass: TokenClass.Punctuator, name: '>>>' }, + ADD: { klass: TokenClass.Punctuator, name: '+' }, + SUB: { klass: TokenClass.Punctuator, name: '-' }, + MUL: { klass: TokenClass.Punctuator, name: '*' }, + DIV: { klass: TokenClass.Punctuator, name: '/' }, + MOD: { klass: TokenClass.Punctuator, name: '%' }, + EXP: { klass: TokenClass.Punctuator, name: '**' }, + EQ: { klass: TokenClass.Punctuator, name: '==' }, + NE: { klass: TokenClass.Punctuator, name: '!=' }, + EQ_STRICT: { klass: TokenClass.Punctuator, name: '===' }, + NE_STRICT: { klass: TokenClass.Punctuator, name: '!==' }, + LT: { klass: TokenClass.Punctuator, name: '<' }, + GT: { klass: TokenClass.Punctuator, name: '>' }, + LTE: { klass: TokenClass.Punctuator, name: '<=' }, + GTE: { klass: TokenClass.Punctuator, name: '>=' }, + INSTANCEOF: { klass: TokenClass.Keyword, name: 'instanceof' }, + IN: { klass: TokenClass.Keyword, name: 'in' }, + NOT: { klass: TokenClass.Punctuator, name: '!' }, + BIT_NOT: { klass: TokenClass.Punctuator, name: '~' }, + ASYNC: { klass: TokenClass.Keyword, name: 'async' }, + AWAIT: { klass: TokenClass.Keyword, name: 'await' }, + ENUM: { klass: TokenClass.Keyword, name: 'enum' }, + DELETE: { klass: TokenClass.Keyword, name: 'delete' }, + TYPEOF: { klass: TokenClass.Keyword, name: 'typeof' }, + VOID: { klass: TokenClass.Keyword, name: 'void' }, + BREAK: { klass: TokenClass.Keyword, name: 'break' }, + CASE: { klass: TokenClass.Keyword, name: 'case' }, + CATCH: { klass: TokenClass.Keyword, name: 'catch' }, + CLASS: { klass: TokenClass.Keyword, name: 'class' }, + CONTINUE: { klass: TokenClass.Keyword, name: 'continue' }, + DEBUGGER: { klass: TokenClass.Keyword, name: 'debugger' }, + DEFAULT: { klass: TokenClass.Keyword, name: 'default' }, + DO: { klass: TokenClass.Keyword, name: 'do' }, + ELSE: { klass: TokenClass.Keyword, name: 'else' }, + EXPORT: { klass: TokenClass.Keyword, name: 'export' }, + EXTENDS: { klass: TokenClass.Keyword, name: 'extends' }, + FINALLY: { klass: TokenClass.Keyword, name: 'finally' }, + FOR: { klass: TokenClass.Keyword, name: 'for' }, + FUNCTION: { klass: TokenClass.Keyword, name: 'function' }, + IF: { klass: TokenClass.Keyword, name: 'if' }, + IMPORT: { klass: TokenClass.Keyword, name: 'import' }, + LET: { klass: TokenClass.Keyword, name: 'let' }, + NEW: { klass: TokenClass.Keyword, name: 'new' }, + RETURN: { klass: TokenClass.Keyword, name: 'return' }, + SUPER: { klass: TokenClass.Keyword, name: 'super' }, + SWITCH: { klass: TokenClass.Keyword, name: 'switch' }, + THIS: { klass: TokenClass.Keyword, name: 'this' }, + THROW: { klass: TokenClass.Keyword, name: 'throw' }, + TRY: { klass: TokenClass.Keyword, name: 'try' }, + VAR: { klass: TokenClass.Keyword, name: 'var' }, + WHILE: { klass: TokenClass.Keyword, name: 'while' }, + WITH: { klass: TokenClass.Keyword, name: 'with' }, + NULL: { klass: TokenClass.Keyword, name: 'null' }, + TRUE: { klass: TokenClass.Keyword, name: 'true' }, + FALSE: { klass: TokenClass.Keyword, name: 'false' }, + YIELD: { klass: TokenClass.Keyword, name: 'yield' }, + NUMBER: { klass: TokenClass.NumericLiteral, name: '' }, + STRING: { klass: TokenClass.StringLiteral, name: '' }, + REGEXP: { klass: TokenClass.RegularExpression, name: '' }, + IDENTIFIER: { klass: TokenClass.Ident, name: '' }, + CONST: { klass: TokenClass.Keyword, name: 'const' }, + TEMPLATE: { klass: TokenClass.TemplateElement, name: '' }, + ESCAPED_KEYWORD: { klass: TokenClass.Keyword, name: '' }, + ILLEGAL: { klass: TokenClass.Illegal, name: '' }, +}; + +const TT = TokenType; +const I = TT.ILLEGAL; +const F = false; +const T = true; + +const ONE_CHAR_PUNCTUATOR = [ + I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, TT.NOT, I, I, I, + TT.MOD, TT.BIT_AND, I, TT.LPAREN, TT.RPAREN, TT.MUL, TT.ADD, TT.COMMA, TT.SUB, TT.PERIOD, TT.DIV, I, I, I, I, I, I, I, + I, I, I, TT.COLON, TT.SEMICOLON, TT.LT, TT.ASSIGN, TT.GT, TT.CONDITIONAL, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, + I, I, I, I, I, I, I, I, I, I, I, I, TT.LBRACK, I, TT.RBRACK, TT.BIT_XOR, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, + I, I, I, I, I, I, I, I, I, I, I, I, I, TT.LBRACE, TT.BIT_OR, TT.RBRACE, TT.BIT_NOT, +]; + +const PUNCTUATOR_START = [ + F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, T, F, F, F, T, T, + F, T, T, T, T, T, T, F, T, F, F, F, F, F, F, F, F, F, F, T, T, T, T, T, T, F, F, F, F, F, F, F, F, F, F, F, F, F, F, + F, F, F, F, F, F, F, F, F, F, F, F, F, T, F, T, T, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, + F, F, F, F, F, F, T, T, T, T, F, +]; + +export class JsError extends Error { + constructor(index, line, column, msg) { + super(msg); + this.index = index; + // Safari defines these properties as non-writable and non-configurable on Error objects + try { + this.line = line; + this.column = column; + } catch (e) {} + // define these as well so Safari still has access to this info + this.parseErrorLine = line; + this.parseErrorColumn = column; + this.description = msg; + this.message = `[${line}:${column}]: ${msg}`; + } +} + +function fromCodePoint(cp) { + if (cp <= 0xFFFF) return String.fromCharCode(cp); + let cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800); + let cu2 = String.fromCharCode((cp - 0x10000) % 0x400 + 0xDC00); + return cu1 + cu2; +} + +function decodeUtf16(lead, trail) { + return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; +} + +export default class Tokenizer { + constructor(source) { + this.source = source; + this.index = 0; + this.line = 0; + this.lineStart = 0; + this.startIndex = 0; + this.startLine = 0; + this.startLineStart = 0; + this.lastIndex = 0; + this.lastLine = 0; + this.lastLineStart = 0; + this.hasLineTerminatorBeforeNext = false; + this.tokenIndex = 0; + } + + saveLexerState() { + return { + source: this.source, + index: this.index, + line: this.line, + lineStart: this.lineStart, + startIndex: this.startIndex, + startLine: this.startLine, + startLineStart: this.startLineStart, + lastIndex: this.lastIndex, + lastLine: this.lastLine, + lastLineStart: this.lastLineStart, + lookahead: this.lookahead, + hasLineTerminatorBeforeNext: this.hasLineTerminatorBeforeNext, + tokenIndex: this.tokenIndex, + }; + } + + restoreLexerState(state) { + this.source = state.source; + this.index = state.index; + this.line = state.line; + this.lineStart = state.lineStart; + this.startIndex = state.startIndex; + this.startLine = state.startLine; + this.startLineStart = state.startLineStart; + this.lastIndex = state.lastIndex; + this.lastLine = state.lastLine; + this.lastLineStart = state.lastLineStart; + this.lookahead = state.lookahead; + this.hasLineTerminatorBeforeNext = state.hasLineTerminatorBeforeNext; + this.tokenIndex = state.tokenIndex; + } + + createILLEGAL() { + this.startIndex = this.index; + this.startLine = this.line; + this.startLineStart = this.lineStart; + return this.index < this.source.length + ? this.createError(ErrorMessages.UNEXPECTED_ILLEGAL_TOKEN, this.source.charAt(this.index)) + : this.createError(ErrorMessages.UNEXPECTED_EOS); + } + + createUnexpected(token) { + switch (token.type.klass) { + case TokenClass.Eof: + return this.createError(ErrorMessages.UNEXPECTED_EOS); + case TokenClass.Ident: + return this.createError(ErrorMessages.UNEXPECTED_IDENTIFIER); + case TokenClass.Keyword: + if (token.type === TokenType.ESCAPED_KEYWORD) { + return this.createError(ErrorMessages.UNEXPECTED_ESCAPED_KEYWORD); + } + return this.createError(ErrorMessages.UNEXPECTED_TOKEN, token.slice.text); + case TokenClass.NumericLiteral: + return this.createError(ErrorMessages.UNEXPECTED_NUMBER); + case TokenClass.TemplateElement: + return this.createError(ErrorMessages.UNEXPECTED_TEMPLATE); + case TokenClass.Punctuator: + return this.createError(ErrorMessages.UNEXPECTED_TOKEN, token.type.name); + case TokenClass.StringLiteral: + return this.createError(ErrorMessages.UNEXPECTED_STRING); + // the other token classes are RegularExpression and Illegal, but they cannot reach here + } + // istanbul ignore next + throw new Error('Unreachable: unexpected token of class ' + token.type.klass); + } + + createError(message, ...params) { + let msg; + if (typeof message === 'function') { + msg = message(...params); + } else { + msg = message; + } + return new JsError(this.startIndex, this.startLine + 1, this.startIndex - this.startLineStart + 1, msg); + } + + createErrorWithLocation(location, message) { + /* istanbul ignore next */ + let msg = message.replace(/\{(\d+)\}/g, (_, n) => JSON.stringify(arguments[+n + 2])); + if (location.slice && location.slice.startLocation) { + location = location.slice.startLocation; + } + return new JsError(location.offset, location.line, location.column + 1, msg); + } + + static cse2(id, ch1, ch2) { + return id.charAt(1) === ch1 && id.charAt(2) === ch2; + } + + static cse3(id, ch1, ch2, ch3) { + return id.charAt(1) === ch1 && id.charAt(2) === ch2 && id.charAt(3) === ch3; + } + + static cse4(id, ch1, ch2, ch3, ch4) { + return id.charAt(1) === ch1 && id.charAt(2) === ch2 && id.charAt(3) === ch3 && id.charAt(4) === ch4; + } + + static cse5(id, ch1, ch2, ch3, ch4, ch5) { + return id.charAt(1) === ch1 && id.charAt(2) === ch2 && id.charAt(3) === ch3 && id.charAt(4) === ch4 && id.charAt(5) === ch5; + } + + static cse6(id, ch1, ch2, ch3, ch4, ch5, ch6) { + return id.charAt(1) === ch1 && id.charAt(2) === ch2 && id.charAt(3) === ch3 && id.charAt(4) === ch4 && id.charAt(5) === ch5 && id.charAt(6) === ch6; + } + + static cse7(id, ch1, ch2, ch3, ch4, ch5, ch6, ch7) { + return id.charAt(1) === ch1 && id.charAt(2) === ch2 && id.charAt(3) === ch3 && id.charAt(4) === ch4 && id.charAt(5) === ch5 && id.charAt(6) === ch6 && id.charAt(7) === ch7; + } + + getKeyword(id) { + if (id.length === 1 || id.length > 10) { + return TokenType.IDENTIFIER; + } + + /* istanbul ignore next */ + switch (id.length) { + case 2: + switch (id.charAt(0)) { + case 'i': + switch (id.charAt(1)) { + case 'f': + return TokenType.IF; + case 'n': + return TokenType.IN; + default: + break; + } + break; + case 'd': + if (id.charAt(1) === 'o') { + return TokenType.DO; + } + break; + } + break; + case 3: + switch (id.charAt(0)) { + case 'v': + if (Tokenizer.cse2(id, 'a', 'r')) { + return TokenType.VAR; + } + break; + case 'f': + if (Tokenizer.cse2(id, 'o', 'r')) { + return TokenType.FOR; + } + break; + case 'n': + if (Tokenizer.cse2(id, 'e', 'w')) { + return TokenType.NEW; + } + break; + case 't': + if (Tokenizer.cse2(id, 'r', 'y')) { + return TokenType.TRY; + } + break; + case 'l': + if (Tokenizer.cse2(id, 'e', 't')) { + return TokenType.LET; + } + break; + } + break; + case 4: + switch (id.charAt(0)) { + case 't': + if (Tokenizer.cse3(id, 'h', 'i', 's')) { + return TokenType.THIS; + } else if (Tokenizer.cse3(id, 'r', 'u', 'e')) { + return TokenType.TRUE; + } + break; + case 'n': + if (Tokenizer.cse3(id, 'u', 'l', 'l')) { + return TokenType.NULL; + } + break; + case 'e': + if (Tokenizer.cse3(id, 'l', 's', 'e')) { + return TokenType.ELSE; + } else if (Tokenizer.cse3(id, 'n', 'u', 'm')) { + return TokenType.ENUM; + } + break; + case 'c': + if (Tokenizer.cse3(id, 'a', 's', 'e')) { + return TokenType.CASE; + } + break; + case 'v': + if (Tokenizer.cse3(id, 'o', 'i', 'd')) { + return TokenType.VOID; + } + break; + case 'w': + if (Tokenizer.cse3(id, 'i', 't', 'h')) { + return TokenType.WITH; + } + break; + } + break; + case 5: + switch (id.charAt(0)) { + case 'a': + if (Tokenizer.cse4(id, 's', 'y', 'n', 'c')) { + return TokenType.ASYNC; + } + if (Tokenizer.cse4(id, 'w', 'a', 'i', 't')) { + return TokenType.AWAIT; + } + break; + case 'w': + if (Tokenizer.cse4(id, 'h', 'i', 'l', 'e')) { + return TokenType.WHILE; + } + break; + case 'b': + if (Tokenizer.cse4(id, 'r', 'e', 'a', 'k')) { + return TokenType.BREAK; + } + break; + case 'f': + if (Tokenizer.cse4(id, 'a', 'l', 's', 'e')) { + return TokenType.FALSE; + } + break; + case 'c': + if (Tokenizer.cse4(id, 'a', 't', 'c', 'h')) { + return TokenType.CATCH; + } else if (Tokenizer.cse4(id, 'o', 'n', 's', 't')) { + return TokenType.CONST; + } else if (Tokenizer.cse4(id, 'l', 'a', 's', 's')) { + return TokenType.CLASS; + } + break; + case 't': + if (Tokenizer.cse4(id, 'h', 'r', 'o', 'w')) { + return TokenType.THROW; + } + break; + case 'y': + if (Tokenizer.cse4(id, 'i', 'e', 'l', 'd')) { + return TokenType.YIELD; + } + break; + case 's': + if (Tokenizer.cse4(id, 'u', 'p', 'e', 'r')) { + return TokenType.SUPER; + } + break; + } + break; + case 6: + switch (id.charAt(0)) { + case 'r': + if (Tokenizer.cse5(id, 'e', 't', 'u', 'r', 'n')) { + return TokenType.RETURN; + } + break; + case 't': + if (Tokenizer.cse5(id, 'y', 'p', 'e', 'o', 'f')) { + return TokenType.TYPEOF; + } + break; + case 'd': + if (Tokenizer.cse5(id, 'e', 'l', 'e', 't', 'e')) { + return TokenType.DELETE; + } + break; + case 's': + if (Tokenizer.cse5(id, 'w', 'i', 't', 'c', 'h')) { + return TokenType.SWITCH; + } + break; + case 'e': + if (Tokenizer.cse5(id, 'x', 'p', 'o', 'r', 't')) { + return TokenType.EXPORT; + } + break; + case 'i': + if (Tokenizer.cse5(id, 'm', 'p', 'o', 'r', 't')) { + return TokenType.IMPORT; + } + break; + } + break; + case 7: + switch (id.charAt(0)) { + case 'd': + if (Tokenizer.cse6(id, 'e', 'f', 'a', 'u', 'l', 't')) { + return TokenType.DEFAULT; + } + break; + case 'f': + if (Tokenizer.cse6(id, 'i', 'n', 'a', 'l', 'l', 'y')) { + return TokenType.FINALLY; + } + break; + case 'e': + if (Tokenizer.cse6(id, 'x', 't', 'e', 'n', 'd', 's')) { + return TokenType.EXTENDS; + } + break; + } + break; + case 8: + switch (id.charAt(0)) { + case 'f': + if (Tokenizer.cse7(id, 'u', 'n', 'c', 't', 'i', 'o', 'n')) { + return TokenType.FUNCTION; + } + break; + case 'c': + if (Tokenizer.cse7(id, 'o', 'n', 't', 'i', 'n', 'u', 'e')) { + return TokenType.CONTINUE; + } + break; + case 'd': + if (Tokenizer.cse7(id, 'e', 'b', 'u', 'g', 'g', 'e', 'r')) { + return TokenType.DEBUGGER; + } + break; + } + break; + case 10: + if (id === 'instanceof') { + return TokenType.INSTANCEOF; + } + break; + } + return TokenType.IDENTIFIER; + } + + skipSingleLineComment(offset) { + this.index += offset; + while (this.index < this.source.length) { + /** + * @type {Number} + */ + let chCode = this.source.charCodeAt(this.index); + this.index++; + if (isLineTerminator(chCode)) { + this.hasLineTerminatorBeforeNext = true; + if (chCode === 0xD /* "\r" */ && this.source.charCodeAt(this.index) === 0xA /* "\n" */) { + this.index++; + } + this.lineStart = this.index; + this.line++; + return; + } + } + } + + skipMultiLineComment() { + this.index += 2; + const length = this.source.length; + let isLineStart = false; + while (this.index < length) { + let chCode = this.source.charCodeAt(this.index); + if (chCode < 0x80) { + switch (chCode) { + case 42: // "*" + // Block comment ends with "*/". + if (this.source.charAt(this.index + 1) === '/') { + this.index = this.index + 2; + return isLineStart; + } + this.index++; + break; + case 10: // "\n" + isLineStart = true; + this.hasLineTerminatorBeforeNext = true; + this.index++; + this.lineStart = this.index; + this.line++; + break; + case 13: // "\r": + isLineStart = true; + this.hasLineTerminatorBeforeNext = true; + if (this.source.charAt(this.index + 1) === '\n') { + this.index++; + } + this.index++; + this.lineStart = this.index; + this.line++; + break; + default: + this.index++; + } + } else if (chCode === 0x2028 || chCode === 0x2029) { + isLineStart = true; + this.hasLineTerminatorBeforeNext = true; + this.index++; + this.lineStart = this.index; + this.line++; + } else { + this.index++; + } + } + throw this.createILLEGAL(); + } + + + skipComment() { + this.hasLineTerminatorBeforeNext = false; + + let isLineStart = this.index === 0; + const length = this.source.length; + + while (this.index < length) { + let chCode = this.source.charCodeAt(this.index); + if (isWhiteSpace(chCode)) { + this.index++; + } else if (isLineTerminator(chCode)) { + this.hasLineTerminatorBeforeNext = true; + this.index++; + if (chCode === 13 /* "\r" */ && this.source.charAt(this.index) === '\n') { + this.index++; + } + this.lineStart = this.index; + this.line++; + isLineStart = true; + } else if (chCode === 47 /* "/" */) { + if (this.index + 1 >= length) { + break; + } + chCode = this.source.charCodeAt(this.index + 1); + if (chCode === 47 /* "/" */) { + this.skipSingleLineComment(2); + isLineStart = true; + } else if (chCode === 42 /* "*" */) { + isLineStart = this.skipMultiLineComment() || isLineStart; + } else { + break; + } + } else if (!this.moduleIsTheGoalSymbol && isLineStart && chCode === 45 /* "-" */) { + if (this.index + 2 >= length) { + break; + } + // U+003E is ">" + if (this.source.charAt(this.index + 1) === '-' && this.source.charAt(this.index + 2) === '>') { + // "-->" is a single-line comment + this.skipSingleLineComment(3); + } else { + break; + } + } else if (!this.moduleIsTheGoalSymbol && chCode === 60 /* "<" */) { + if (this.source.slice(this.index + 1, this.index + 4) === '!--') { + this.skipSingleLineComment(4); + isLineStart = true; + } else { + break; + } + } else { + break; + } + } + } + + scanHexEscape2() { + if (this.index + 2 > this.source.length) { + return -1; + } + let r1 = getHexValue(this.source.charAt(this.index)); + if (r1 === -1) { + return -1; + } + let r2 = getHexValue(this.source.charAt(this.index + 1)); + if (r2 === -1) { + return -1; + } + this.index += 2; + return r1 << 4 | r2; + } + + scanUnicode() { + if (this.source.charAt(this.index) === '{') { + // \u{HexDigits} + let i = this.index + 1; + let hexDigits = 0, ch; + while (i < this.source.length) { + ch = this.source.charAt(i); + let hex = getHexValue(ch); + if (hex === -1) { + break; + } + hexDigits = hexDigits << 4 | hex; + if (hexDigits > 0x10FFFF) { + throw this.createILLEGAL(); + } + i++; + } + if (ch !== '}') { + throw this.createILLEGAL(); + } + if (i === this.index + 1) { + ++this.index; // This is so that the error is 'Unexpected "}"' instead of 'Unexpected "{"'. + throw this.createILLEGAL(); + } + this.index = i + 1; + return hexDigits; + } + // \uHex4Digits + if (this.index + 4 > this.source.length) { + return -1; + } + let r1 = getHexValue(this.source.charAt(this.index)); + if (r1 === -1) { + return -1; + } + let r2 = getHexValue(this.source.charAt(this.index + 1)); + if (r2 === -1) { + return -1; + } + let r3 = getHexValue(this.source.charAt(this.index + 2)); + if (r3 === -1) { + return -1; + } + let r4 = getHexValue(this.source.charAt(this.index + 3)); + if (r4 === -1) { + return -1; + } + this.index += 4; + return r1 << 12 | r2 << 8 | r3 << 4 | r4; + } + + getEscapedIdentifier() { + let id = ''; + let check = isIdentifierStart; + + while (this.index < this.source.length) { + let ch = this.source.charAt(this.index); + let code = ch.charCodeAt(0); + let start = this.index; + ++this.index; + if (ch === '\\') { + if (this.index >= this.source.length) { + throw this.createILLEGAL(); + } + if (this.source.charAt(this.index) !== 'u') { + throw this.createILLEGAL(); + } + ++this.index; + code = this.scanUnicode(); + if (code < 0) { + throw this.createILLEGAL(); + } + ch = fromCodePoint(code); + } else if (code >= 0xD800 && code <= 0xDBFF) { + if (this.index >= this.source.length) { + throw this.createILLEGAL(); + } + let lowSurrogateCode = this.source.charCodeAt(this.index); + ++this.index; + if (!(lowSurrogateCode >= 0xDC00 && lowSurrogateCode <= 0xDFFF)) { + throw this.createILLEGAL(); + } + code = decodeUtf16(code, lowSurrogateCode); + ch = fromCodePoint(code); + } + if (!check(code)) { + if (id.length < 1) { + throw this.createILLEGAL(); + } + this.index = start; + return id; + } + check = isIdentifierPart; + id += ch; + } + return id; + } + + getIdentifier() { + let start = this.index; + let l = this.source.length; + let i = this.index; + let check = isIdentifierStart; + while (i < l) { + let ch = this.source.charAt(i); + let code = ch.charCodeAt(0); + if (ch === '\\' || code >= 0xD800 && code <= 0xDBFF) { + // Go back and try the hard one. + this.index = start; + return this.getEscapedIdentifier(); + } + if (!check(code)) { + this.index = i; + return this.source.slice(start, i); + } + ++i; + check = isIdentifierPart; + } + this.index = i; + return this.source.slice(start, i); + } + + scanIdentifier() { + let startLocation = this.getLocation(); + let start = this.index; + + // Backslash (U+005C) starts an escaped character. + let id = this.source.charAt(this.index) === '\\' ? this.getEscapedIdentifier() : this.getIdentifier(); + + let slice = this.getSlice(start, startLocation); + slice.text = id; + let hasEscape = this.index - start !== id.length; + + let type = this.getKeyword(id); + if (hasEscape && type !== TokenType.IDENTIFIER) { + type = TokenType.ESCAPED_KEYWORD; + } + return { type, value: id, slice, escaped: hasEscape }; + } + + getLocation() { + return { + line: this.startLine + 1, + column: this.startIndex - this.startLineStart, + offset: this.startIndex, + }; + } + + getLastTokenEndLocation() { + return { + line: this.lastLine + 1, + column: this.lastIndex - this.lastLineStart, + offset: this.lastIndex, + }; + } + + getSlice(start, startLocation) { + return { text: this.source.slice(start, this.index), start, startLocation, end: this.index }; + } + + scanPunctuatorHelper() { + let ch1 = this.source.charAt(this.index); + + switch (ch1) { + // Check for most common single-character punctuators. + case '.': { + let ch2 = this.source.charAt(this.index + 1); + if (ch2 !== '.') return TokenType.PERIOD; + let ch3 = this.source.charAt(this.index + 2); + if (ch3 !== '.') return TokenType.PERIOD; + return TokenType.ELLIPSIS; + } + case '(': + return TokenType.LPAREN; + case ')': + case ';': + case ',': + return ONE_CHAR_PUNCTUATOR[ch1.charCodeAt(0)]; + case '{': + return TokenType.LBRACE; + case '}': + case '[': + case ']': + case ':': + case '?': + case '~': + return ONE_CHAR_PUNCTUATOR[ch1.charCodeAt(0)]; + default: + // "=" (U+003D) marks an assignment or comparison operator. + if (this.index + 1 < this.source.length && this.source.charAt(this.index + 1) === '=') { + switch (ch1) { + case '=': + if (this.index + 2 < this.source.length && this.source.charAt(this.index + 2) === '=') { + return TokenType.EQ_STRICT; + } + return TokenType.EQ; + case '!': + if (this.index + 2 < this.source.length && this.source.charAt(this.index + 2) === '=') { + return TokenType.NE_STRICT; + } + return TokenType.NE; + case '|': + return TokenType.ASSIGN_BIT_OR; + case '+': + return TokenType.ASSIGN_ADD; + case '-': + return TokenType.ASSIGN_SUB; + case '*': + return TokenType.ASSIGN_MUL; + case '<': + return TokenType.LTE; + case '>': + return TokenType.GTE; + case '/': + return TokenType.ASSIGN_DIV; + case '%': + return TokenType.ASSIGN_MOD; + case '^': + return TokenType.ASSIGN_BIT_XOR; + case '&': + return TokenType.ASSIGN_BIT_AND; + // istanbul ignore next + default: + break; // failed + } + } + } + + if (this.index + 1 < this.source.length) { + let ch2 = this.source.charAt(this.index + 1); + if (ch1 === ch2) { + if (this.index + 2 < this.source.length) { + let ch3 = this.source.charAt(this.index + 2); + if (ch1 === '>' && ch3 === '>') { + // 4-character punctuator: >>>= + if (this.index + 3 < this.source.length && this.source.charAt(this.index + 3) === '=') { + return TokenType.ASSIGN_SHR_UNSIGNED; + } + return TokenType.SHR_UNSIGNED; + } + + if (ch1 === '<' && ch3 === '=') { + return TokenType.ASSIGN_SHL; + } + + if (ch1 === '>' && ch3 === '=') { + return TokenType.ASSIGN_SHR; + } + + if (ch1 === '*' && ch3 === '=') { + return TokenType.ASSIGN_EXP; + } + } + // Other 2-character punctuators: ++ -- << >> && || + switch (ch1) { + case '*': + return TokenType.EXP; + case '+': + return TokenType.INC; + case '-': + return TokenType.DEC; + case '<': + return TokenType.SHL; + case '>': + return TokenType.SHR; + case '&': + return TokenType.AND; + case '|': + return TokenType.OR; + // istanbul ignore next + default: + break; // failed + } + } else if (ch1 === '=' && ch2 === '>') { + return TokenType.ARROW; + } + } + + return ONE_CHAR_PUNCTUATOR[ch1.charCodeAt(0)]; + } + + // 7.7 Punctuators + scanPunctuator() { + let startLocation = this.getLocation(); + let start = this.index; + let subType = this.scanPunctuatorHelper(); + this.index += subType.name.length; + return { type: subType, value: subType.name, slice: this.getSlice(start, startLocation) }; + } + + scanHexLiteral(start, startLocation) { + let i = this.index; + while (i < this.source.length) { + let ch = this.source.charAt(i); + let hex = getHexValue(ch); + if (hex === -1) { + break; + } + i++; + } + + if (this.index === i) { + throw this.createILLEGAL(); + } + + if (i < this.source.length && isIdentifierStart(this.source.charCodeAt(i))) { + throw this.createILLEGAL(); + } + + this.index = i; + + let slice = this.getSlice(start, startLocation); + return { type: TokenType.NUMBER, value: parseInt(slice.text.substr(2), 16), slice }; + } + + scanBinaryLiteral(start, startLocation) { + let offset = this.index - start; + + while (this.index < this.source.length) { + let ch = this.source.charAt(this.index); + if (ch !== '0' && ch !== '1') { + break; + } + this.index++; + } + + if (this.index - start <= offset) { + throw this.createILLEGAL(); + } + + if (this.index < this.source.length && (isIdentifierStart(this.source.charCodeAt(this.index)) + || isDecimalDigit(this.source.charCodeAt(this.index)))) { + throw this.createILLEGAL(); + } + + return { + type: TokenType.NUMBER, + value: parseInt(this.getSlice(start, startLocation).text.substr(offset), 2), + slice: this.getSlice(start, startLocation), + octal: false, + noctal: false, + }; + } + + scanOctalLiteral(start, startLocation) { + while (this.index < this.source.length) { + let ch = this.source.charAt(this.index); + if (ch >= '0' && ch <= '7') { + this.index++; + } else if (isIdentifierPart(ch.charCodeAt(0))) { + throw this.createILLEGAL(); + } else { + break; + } + } + + if (this.index - start === 2) { + throw this.createILLEGAL(); + } + + return { + type: TokenType.NUMBER, + value: parseInt(this.getSlice(start, startLocation).text.substr(2), 8), + slice: this.getSlice(start, startLocation), + octal: false, + noctal: false, + }; + } + + scanLegacyOctalLiteral(start, startLocation) { + let isOctal = true; + + while (this.index < this.source.length) { + let ch = this.source.charAt(this.index); + if (ch >= '0' && ch <= '7') { + this.index++; + } else if (ch === '8' || ch === '9') { + isOctal = false; + this.index++; + } else if (isIdentifierPart(ch.charCodeAt(0))) { + throw this.createILLEGAL(); + } else { + break; + } + } + + let slice = this.getSlice(start, startLocation); + if (!isOctal) { + this.eatDecimalLiteralSuffix(); + return { + type: TokenType.NUMBER, + slice, + value: +slice.text, + octal: true, + noctal: !isOctal, + }; + } + + return { + type: TokenType.NUMBER, + slice, + value: parseInt(slice.text.substr(1), 8), + octal: true, + noctal: !isOctal, + }; + } + + scanNumericLiteral() { + let ch = this.source.charAt(this.index); + // assert(ch === "." || "0" <= ch && ch <= "9") + let startLocation = this.getLocation(); + let start = this.index; + + if (ch === '0') { + this.index++; + if (this.index < this.source.length) { + ch = this.source.charAt(this.index); + if (ch === 'x' || ch === 'X') { + this.index++; + return this.scanHexLiteral(start, startLocation); + } else if (ch === 'b' || ch === 'B') { + this.index++; + return this.scanBinaryLiteral(start, startLocation); + } else if (ch === 'o' || ch === 'O') { + this.index++; + return this.scanOctalLiteral(start, startLocation); + } else if (ch >= '0' && ch <= '9') { + return this.scanLegacyOctalLiteral(start, startLocation); + } + } else { + let slice = this.getSlice(start, startLocation); + return { + type: TokenType.NUMBER, + value: +slice.text, + slice, + octal: false, + noctal: false, + }; + } + } else if (ch !== '.') { + // Must be "1".."9" + ch = this.source.charAt(this.index); + while (ch >= '0' && ch <= '9') { + this.index++; + if (this.index === this.source.length) { + let slice = this.getSlice(start, startLocation); + return { + type: TokenType.NUMBER, + value: +slice.text, + slice, + octal: false, + noctal: false, + }; + } + ch = this.source.charAt(this.index); + } + } + + this.eatDecimalLiteralSuffix(); + + if (this.index !== this.source.length && isIdentifierStart(this.source.charCodeAt(this.index))) { + throw this.createILLEGAL(); + } + + let slice = this.getSlice(start, startLocation); + return { + type: TokenType.NUMBER, + value: +slice.text, + slice, + octal: false, + noctal: false, + }; + } + + eatDecimalLiteralSuffix() { + let ch = this.source.charAt(this.index); + if (ch === '.') { + this.index++; + if (this.index === this.source.length) { + return; + } + + ch = this.source.charAt(this.index); + while (ch >= '0' && ch <= '9') { + this.index++; + if (this.index === this.source.length) { + return; + } + ch = this.source.charAt(this.index); + } + } + + // EOF not reached here + if (ch === 'e' || ch === 'E') { + this.index++; + if (this.index === this.source.length) { + throw this.createILLEGAL(); + } + + ch = this.source.charAt(this.index); + if (ch === '+' || ch === '-') { + this.index++; + if (this.index === this.source.length) { + throw this.createILLEGAL(); + } + ch = this.source.charAt(this.index); + } + + if (ch >= '0' && ch <= '9') { + while (ch >= '0' && ch <= '9') { + this.index++; + if (this.index === this.source.length) { + break; + } + ch = this.source.charAt(this.index); + } + } else { + throw this.createILLEGAL(); + } + } + } + + scanStringEscape(str, octal) { + this.index++; + if (this.index === this.source.length) { + throw this.createILLEGAL(); + } + let ch = this.source.charAt(this.index); + if (isLineTerminator(ch.charCodeAt(0))) { + this.index++; + if (ch === '\r' && this.source.charAt(this.index) === '\n') { + this.index++; + } + this.lineStart = this.index; + this.line++; + } else { + switch (ch) { + case 'n': + str += '\n'; + this.index++; + break; + case 'r': + str += '\r'; + this.index++; + break; + case 't': + str += '\t'; + this.index++; + break; + case 'u': + case 'x': { + let unescaped; + this.index++; + if (this.index >= this.source.length) { + throw this.createILLEGAL(); + } + unescaped = ch === 'u' ? this.scanUnicode() : this.scanHexEscape2(); + if (unescaped < 0) { + throw this.createILLEGAL(); + } + str += fromCodePoint(unescaped); + break; + } + case 'b': + str += '\b'; + this.index++; + break; + case 'f': + str += '\f'; + this.index++; + break; + case 'v': + str += '\u000B'; + this.index++; + break; + default: + if (ch >= '0' && ch <= '7') { + let octalStart = this.index; + let octLen = 1; + // 3 digits are only allowed when string starts + // with 0, 1, 2, 3 + if (ch >= '0' && ch <= '3') { + octLen = 0; + } + let code = 0; + while (octLen < 3 && ch >= '0' && ch <= '7') { + this.index++; + if (octLen > 0 || ch !== '0') { + octal = this.source.slice(octalStart, this.index); + } + code *= 8; + code += ch - '0'; + octLen++; + if (this.index === this.source.length) { + throw this.createILLEGAL(); + } + ch = this.source.charAt(this.index); + } + if (code === 0 && octLen === 1 && (ch === '8' || ch === '9')) { + octal = this.source.slice(octalStart, this.index + 1); + } + str += String.fromCharCode(code); + } else if (ch === '8' || ch === '9') { + throw this.createILLEGAL(); + } else { + str += ch; + this.index++; + } + } + } + return [str, octal]; + } + // 7.8.4 String Literals + scanStringLiteral() { + let str = ''; + + let quote = this.source.charAt(this.index); + // assert((quote === "\"" || quote === """), "String literal must starts with a quote") + + let startLocation = this.getLocation(); + let start = this.index; + this.index++; + + let octal = null; + while (this.index < this.source.length) { + let ch = this.source.charAt(this.index); + if (ch === quote) { + this.index++; + return { type: TokenType.STRING, slice: this.getSlice(start, startLocation), str, octal }; + } else if (ch === '\\') { + [str, octal] = this.scanStringEscape(str, octal); + } else if (isLineTerminator(ch.charCodeAt(0))) { + throw this.createILLEGAL(); + } else { + str += ch; + this.index++; + } + } + + throw this.createILLEGAL(); + } + + scanTemplateElement() { + let startLocation = this.getLocation(); + let start = this.index; + this.index++; + while (this.index < this.source.length) { + let ch = this.source.charCodeAt(this.index); + switch (ch) { + case 0x60: { // ` + this.index++; + return { type: TokenType.TEMPLATE, tail: true, slice: this.getSlice(start, startLocation) }; + } + case 0x24: { // $ + if (this.source.charCodeAt(this.index + 1) === 0x7B) { // { + this.index += 2; + return { type: TokenType.TEMPLATE, tail: false, slice: this.getSlice(start, startLocation) }; + } + this.index++; + break; + } + case 0x5C: { // \\ + let octal = this.scanStringEscape('', null)[1]; + if (octal != null) { + throw this.createError(ErrorMessages.NO_OCTALS_IN_TEMPLATES); + } + break; + } + case 0x0D: { // \r + this.line++; + this.index++; + if (this.index < this.source.length && this.source.charAt(this.index) === '\n') { + this.index++; + } + this.lineStart = this.index; + break; + } + case 0x0A: // \r + case 0x2028: + case 0x2029: { + this.line++; + this.index++; + this.lineStart = this.index; + break; + } + default: + this.index++; + } + } + + throw this.createILLEGAL(); + } + + scanRegExp(str) { + let startLocation = this.getLocation(); + let start = this.index; + + let terminated = false; + let classMarker = false; + while (this.index < this.source.length) { + let ch = this.source.charAt(this.index); + if (ch === '\\') { + str += ch; + this.index++; + ch = this.source.charAt(this.index); + // ECMA-262 7.8.5 + if (isLineTerminator(ch.charCodeAt(0))) { + throw this.createError(ErrorMessages.UNTERMINATED_REGEXP); + } + str += ch; + this.index++; + } else if (isLineTerminator(ch.charCodeAt(0))) { + throw this.createError(ErrorMessages.UNTERMINATED_REGEXP); + } else { + if (classMarker) { + if (ch === ']') { + classMarker = false; + } + } else if (ch === '/') { + terminated = true; + str += ch; + this.index++; + break; + } else if (ch === '[') { + classMarker = true; + } + str += ch; + this.index++; + } + } + + if (!terminated) { + throw this.createError(ErrorMessages.UNTERMINATED_REGEXP); + } + + while (this.index < this.source.length) { + let ch = this.source.charAt(this.index); + if (ch === '\\') { + throw this.createError(ErrorMessages.INVALID_REGEXP_FLAGS); + } + if (!isIdentifierPart(ch.charCodeAt(0))) { + break; + } + this.index++; + str += ch; + } + return { type: TokenType.REGEXP, value: str, slice: this.getSlice(start, startLocation) }; + } + + advance() { + let startLocation = this.getLocation(); + + this.lastIndex = this.index; + this.lastLine = this.line; + this.lastLineStart = this.lineStart; + + this.skipComment(); + + this.startIndex = this.index; + this.startLine = this.line; + this.startLineStart = this.lineStart; + + if (this.lastIndex === 0) { + this.lastIndex = this.index; + this.lastLine = this.line; + this.lastLineStart = this.lineStart; + } + + if (this.index >= this.source.length) { + return { type: TokenType.EOS, slice: this.getSlice(this.index, startLocation) }; + } + + let charCode = this.source.charCodeAt(this.index); + + if (charCode < 0x80) { + if (PUNCTUATOR_START[charCode]) { + return this.scanPunctuator(); + } + + if (isIdentifierStart(charCode) || charCode === 0x5C /* backslash (\) */) { + return this.scanIdentifier(); + } + + // Dot (.) U+002E can also start a floating-point number, hence the need + // to check the next character. + if (charCode === 0x2E) { + if (this.index + 1 < this.source.length && isDecimalDigit(this.source.charCodeAt(this.index + 1))) { + return this.scanNumericLiteral(); + } + return this.scanPunctuator(); + } + + // String literal starts with single quote (U+0027) or double quote (U+0022). + if (charCode === 0x27 || charCode === 0x22) { + return this.scanStringLiteral(); + } + + // Template literal starts with back quote (U+0060) + if (charCode === 0x60) { + return this.scanTemplateElement(); + } + + if (charCode /* "0" */ >= 0x30 && charCode <= 0x39 /* "9" */) { + return this.scanNumericLiteral(); + } + + // Slash (/) U+002F can also start a regex. + throw this.createILLEGAL(); + } else { + if (isIdentifierStart(charCode) || charCode >= 0xD800 && charCode <= 0xDBFF) { + return this.scanIdentifier(); + } + + throw this.createILLEGAL(); + } + } + + eof() { + return this.lookahead.type === TokenType.EOS; + } + + lex() { + let prevToken = this.lookahead; + this.lookahead = this.advance(); + this.tokenIndex++; + return prevToken; + } +} diff --git a/docs/dist/shift-parser/unicode.js b/docs/dist/shift-parser/unicode.js new file mode 100644 index 00000000..27906deb --- /dev/null +++ b/docs/dist/shift-parser/unicode.js @@ -0,0 +1,11 @@ +// Generated by scripts/generate-unicode-data.js + +export const whitespaceArray = [5760, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8202, 8239, 8287, 12288, 65279]; +export const whitespaceBool = [false, false, false, false, false, false, false, false, false, true, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]; + +export const idStartLargeRegex = /^[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]$/; +export const idStartBool = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false]; + +export const idContinueLargeRegex = /^[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]$/; +export const idContinueBool = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false]; + diff --git a/docs/dist/shift-parser/utils.js b/docs/dist/shift-parser/utils.js new file mode 100644 index 00000000..a5efcb86 --- /dev/null +++ b/docs/dist/shift-parser/utils.js @@ -0,0 +1,105 @@ +/** + * Copyright 2017 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { whitespaceArray, whitespaceBool, idStartLargeRegex, idStartBool, idContinueLargeRegex, idContinueBool } from './unicode.js'; + + +const strictReservedWords = [ + 'null', + 'true', + 'false', + + 'implements', + 'interface', + 'package', + 'private', + 'protected', + 'public', + 'static', + 'let', + + 'if', + 'in', + 'do', + 'var', + 'for', + 'new', + 'try', + 'this', + 'else', + 'case', + 'void', + 'with', + 'enum', + 'while', + 'break', + 'catch', + 'throw', + 'const', + 'yield', + 'class', + 'super', + 'return', + 'typeof', + 'delete', + 'switch', + 'export', + 'import', + 'default', + 'finally', + 'extends', + 'function', + 'continue', + 'debugger', + 'instanceof', +]; + +export function isStrictModeReservedWord(id) { + return strictReservedWords.indexOf(id) !== -1; +} + +export function isWhiteSpace(ch) { + return ch < 128 ? whitespaceBool[ch] : ch === 0xA0 || ch > 0x167F && whitespaceArray.indexOf(ch) !== -1; +} + +export function isLineTerminator(ch) { + return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029; +} + +export function isIdentifierStart(ch) { + return ch < 128 ? idStartBool[ch] : idStartLargeRegex.test(String.fromCodePoint(ch)); +} + +export function isIdentifierPart(ch) { + return ch < 128 ? idContinueBool[ch] : idContinueLargeRegex.test(String.fromCodePoint(ch)); +} + +export function isDecimalDigit(ch) { + return ch >= 48 && ch <= 57; +} + +export function getHexValue(rune) { + if (rune >= '0' && rune <= '9') { + return rune.charCodeAt(0) - 48; + } + if (rune >= 'a' && rune <= 'f') { + return rune.charCodeAt(0) - 87; + } + if (rune >= 'A' && rune <= 'F') { + return rune.charCodeAt(0) - 55; + } + return -1; +} diff --git a/docs/dist/shift-reducer/adapt.js b/docs/dist/shift-reducer/adapt.js new file mode 100644 index 00000000..56653486 --- /dev/null +++ b/docs/dist/shift-reducer/adapt.js @@ -0,0 +1,418 @@ +// Generated by generate-adapt.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as Shift from '../../_snowpack/pkg/shift-ast.js'; + +export default (fn, reducer) => ({ + __proto__: reducer, + + reduceArrayAssignmentTarget(node, data) { + return fn(super.reduceArrayAssignmentTarget(node, data), node); + }, + + reduceArrayBinding(node, data) { + return fn(super.reduceArrayBinding(node, data), node); + }, + + reduceArrayExpression(node, data) { + return fn(super.reduceArrayExpression(node, data), node); + }, + + reduceArrowExpression(node, data) { + return fn(super.reduceArrowExpression(node, data), node); + }, + + reduceAssignmentExpression(node, data) { + return fn(super.reduceAssignmentExpression(node, data), node); + }, + + reduceAssignmentTargetIdentifier(node, data) { + return fn(super.reduceAssignmentTargetIdentifier(node, data), node); + }, + + reduceAssignmentTargetPropertyIdentifier(node, data) { + return fn(super.reduceAssignmentTargetPropertyIdentifier(node, data), node); + }, + + reduceAssignmentTargetPropertyProperty(node, data) { + return fn(super.reduceAssignmentTargetPropertyProperty(node, data), node); + }, + + reduceAssignmentTargetWithDefault(node, data) { + return fn(super.reduceAssignmentTargetWithDefault(node, data), node); + }, + + reduceAwaitExpression(node, data) { + return fn(super.reduceAwaitExpression(node, data), node); + }, + + reduceBinaryExpression(node, data) { + return fn(super.reduceBinaryExpression(node, data), node); + }, + + reduceBindingIdentifier(node, data) { + return fn(super.reduceBindingIdentifier(node, data), node); + }, + + reduceBindingPropertyIdentifier(node, data) { + return fn(super.reduceBindingPropertyIdentifier(node, data), node); + }, + + reduceBindingPropertyProperty(node, data) { + return fn(super.reduceBindingPropertyProperty(node, data), node); + }, + + reduceBindingWithDefault(node, data) { + return fn(super.reduceBindingWithDefault(node, data), node); + }, + + reduceBlock(node, data) { + return fn(super.reduceBlock(node, data), node); + }, + + reduceBlockStatement(node, data) { + return fn(super.reduceBlockStatement(node, data), node); + }, + + reduceBreakStatement(node, data) { + return fn(super.reduceBreakStatement(node, data), node); + }, + + reduceCallExpression(node, data) { + return fn(super.reduceCallExpression(node, data), node); + }, + + reduceCatchClause(node, data) { + return fn(super.reduceCatchClause(node, data), node); + }, + + reduceClassDeclaration(node, data) { + return fn(super.reduceClassDeclaration(node, data), node); + }, + + reduceClassElement(node, data) { + return fn(super.reduceClassElement(node, data), node); + }, + + reduceClassExpression(node, data) { + return fn(super.reduceClassExpression(node, data), node); + }, + + reduceCompoundAssignmentExpression(node, data) { + return fn(super.reduceCompoundAssignmentExpression(node, data), node); + }, + + reduceComputedMemberAssignmentTarget(node, data) { + return fn(super.reduceComputedMemberAssignmentTarget(node, data), node); + }, + + reduceComputedMemberExpression(node, data) { + return fn(super.reduceComputedMemberExpression(node, data), node); + }, + + reduceComputedPropertyName(node, data) { + return fn(super.reduceComputedPropertyName(node, data), node); + }, + + reduceConditionalExpression(node, data) { + return fn(super.reduceConditionalExpression(node, data), node); + }, + + reduceContinueStatement(node, data) { + return fn(super.reduceContinueStatement(node, data), node); + }, + + reduceDataProperty(node, data) { + return fn(super.reduceDataProperty(node, data), node); + }, + + reduceDebuggerStatement(node, data) { + return fn(super.reduceDebuggerStatement(node, data), node); + }, + + reduceDirective(node, data) { + return fn(super.reduceDirective(node, data), node); + }, + + reduceDoWhileStatement(node, data) { + return fn(super.reduceDoWhileStatement(node, data), node); + }, + + reduceEmptyStatement(node, data) { + return fn(super.reduceEmptyStatement(node, data), node); + }, + + reduceExport(node, data) { + return fn(super.reduceExport(node, data), node); + }, + + reduceExportAllFrom(node, data) { + return fn(super.reduceExportAllFrom(node, data), node); + }, + + reduceExportDefault(node, data) { + return fn(super.reduceExportDefault(node, data), node); + }, + + reduceExportFrom(node, data) { + return fn(super.reduceExportFrom(node, data), node); + }, + + reduceExportFromSpecifier(node, data) { + return fn(super.reduceExportFromSpecifier(node, data), node); + }, + + reduceExportLocalSpecifier(node, data) { + return fn(super.reduceExportLocalSpecifier(node, data), node); + }, + + reduceExportLocals(node, data) { + return fn(super.reduceExportLocals(node, data), node); + }, + + reduceExpressionStatement(node, data) { + return fn(super.reduceExpressionStatement(node, data), node); + }, + + reduceForAwaitStatement(node, data) { + return fn(super.reduceForAwaitStatement(node, data), node); + }, + + reduceForInStatement(node, data) { + return fn(super.reduceForInStatement(node, data), node); + }, + + reduceForOfStatement(node, data) { + return fn(super.reduceForOfStatement(node, data), node); + }, + + reduceForStatement(node, data) { + return fn(super.reduceForStatement(node, data), node); + }, + + reduceFormalParameters(node, data) { + return fn(super.reduceFormalParameters(node, data), node); + }, + + reduceFunctionBody(node, data) { + return fn(super.reduceFunctionBody(node, data), node); + }, + + reduceFunctionDeclaration(node, data) { + return fn(super.reduceFunctionDeclaration(node, data), node); + }, + + reduceFunctionExpression(node, data) { + return fn(super.reduceFunctionExpression(node, data), node); + }, + + reduceGetter(node, data) { + return fn(super.reduceGetter(node, data), node); + }, + + reduceIdentifierExpression(node, data) { + return fn(super.reduceIdentifierExpression(node, data), node); + }, + + reduceIfStatement(node, data) { + return fn(super.reduceIfStatement(node, data), node); + }, + + reduceImport(node, data) { + return fn(super.reduceImport(node, data), node); + }, + + reduceImportNamespace(node, data) { + return fn(super.reduceImportNamespace(node, data), node); + }, + + reduceImportSpecifier(node, data) { + return fn(super.reduceImportSpecifier(node, data), node); + }, + + reduceLabeledStatement(node, data) { + return fn(super.reduceLabeledStatement(node, data), node); + }, + + reduceLiteralBooleanExpression(node, data) { + return fn(super.reduceLiteralBooleanExpression(node, data), node); + }, + + reduceLiteralInfinityExpression(node, data) { + return fn(super.reduceLiteralInfinityExpression(node, data), node); + }, + + reduceLiteralNullExpression(node, data) { + return fn(super.reduceLiteralNullExpression(node, data), node); + }, + + reduceLiteralNumericExpression(node, data) { + return fn(super.reduceLiteralNumericExpression(node, data), node); + }, + + reduceLiteralRegExpExpression(node, data) { + return fn(super.reduceLiteralRegExpExpression(node, data), node); + }, + + reduceLiteralStringExpression(node, data) { + return fn(super.reduceLiteralStringExpression(node, data), node); + }, + + reduceMethod(node, data) { + return fn(super.reduceMethod(node, data), node); + }, + + reduceModule(node, data) { + return fn(super.reduceModule(node, data), node); + }, + + reduceNewExpression(node, data) { + return fn(super.reduceNewExpression(node, data), node); + }, + + reduceNewTargetExpression(node, data) { + return fn(super.reduceNewTargetExpression(node, data), node); + }, + + reduceObjectAssignmentTarget(node, data) { + return fn(super.reduceObjectAssignmentTarget(node, data), node); + }, + + reduceObjectBinding(node, data) { + return fn(super.reduceObjectBinding(node, data), node); + }, + + reduceObjectExpression(node, data) { + return fn(super.reduceObjectExpression(node, data), node); + }, + + reduceReturnStatement(node, data) { + return fn(super.reduceReturnStatement(node, data), node); + }, + + reduceScript(node, data) { + return fn(super.reduceScript(node, data), node); + }, + + reduceSetter(node, data) { + return fn(super.reduceSetter(node, data), node); + }, + + reduceShorthandProperty(node, data) { + return fn(super.reduceShorthandProperty(node, data), node); + }, + + reduceSpreadElement(node, data) { + return fn(super.reduceSpreadElement(node, data), node); + }, + + reduceSpreadProperty(node, data) { + return fn(super.reduceSpreadProperty(node, data), node); + }, + + reduceStaticMemberAssignmentTarget(node, data) { + return fn(super.reduceStaticMemberAssignmentTarget(node, data), node); + }, + + reduceStaticMemberExpression(node, data) { + return fn(super.reduceStaticMemberExpression(node, data), node); + }, + + reduceStaticPropertyName(node, data) { + return fn(super.reduceStaticPropertyName(node, data), node); + }, + + reduceSuper(node, data) { + return fn(super.reduceSuper(node, data), node); + }, + + reduceSwitchCase(node, data) { + return fn(super.reduceSwitchCase(node, data), node); + }, + + reduceSwitchDefault(node, data) { + return fn(super.reduceSwitchDefault(node, data), node); + }, + + reduceSwitchStatement(node, data) { + return fn(super.reduceSwitchStatement(node, data), node); + }, + + reduceSwitchStatementWithDefault(node, data) { + return fn(super.reduceSwitchStatementWithDefault(node, data), node); + }, + + reduceTemplateElement(node, data) { + return fn(super.reduceTemplateElement(node, data), node); + }, + + reduceTemplateExpression(node, data) { + return fn(super.reduceTemplateExpression(node, data), node); + }, + + reduceThisExpression(node, data) { + return fn(super.reduceThisExpression(node, data), node); + }, + + reduceThrowStatement(node, data) { + return fn(super.reduceThrowStatement(node, data), node); + }, + + reduceTryCatchStatement(node, data) { + return fn(super.reduceTryCatchStatement(node, data), node); + }, + + reduceTryFinallyStatement(node, data) { + return fn(super.reduceTryFinallyStatement(node, data), node); + }, + + reduceUnaryExpression(node, data) { + return fn(super.reduceUnaryExpression(node, data), node); + }, + + reduceUpdateExpression(node, data) { + return fn(super.reduceUpdateExpression(node, data), node); + }, + + reduceVariableDeclaration(node, data) { + return fn(super.reduceVariableDeclaration(node, data), node); + }, + + reduceVariableDeclarationStatement(node, data) { + return fn(super.reduceVariableDeclarationStatement(node, data), node); + }, + + reduceVariableDeclarator(node, data) { + return fn(super.reduceVariableDeclarator(node, data), node); + }, + + reduceWhileStatement(node, data) { + return fn(super.reduceWhileStatement(node, data), node); + }, + + reduceWithStatement(node, data) { + return fn(super.reduceWithStatement(node, data), node); + }, + + reduceYieldExpression(node, data) { + return fn(super.reduceYieldExpression(node, data), node); + }, + + reduceYieldGeneratorExpression(node, data) { + return fn(super.reduceYieldGeneratorExpression(node, data), node); + }, +}); diff --git a/docs/dist/shift-reducer/clone-reducer.js b/docs/dist/shift-reducer/clone-reducer.js new file mode 100644 index 00000000..b248ae0c --- /dev/null +++ b/docs/dist/shift-reducer/clone-reducer.js @@ -0,0 +1,416 @@ +// Generated by generate-clone-reducer.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as Shift from '../../_snowpack/pkg/shift-ast.js'; + +export default class CloneReducer { + reduceArrayAssignmentTarget(node, { elements, rest }) { + return new Shift.ArrayAssignmentTarget({ elements, rest }); + } + + reduceArrayBinding(node, { elements, rest }) { + return new Shift.ArrayBinding({ elements, rest }); + } + + reduceArrayExpression(node, { elements }) { + return new Shift.ArrayExpression({ elements }); + } + + reduceArrowExpression(node, { params, body }) { + return new Shift.ArrowExpression({ isAsync: node.isAsync, params, body }); + } + + reduceAssignmentExpression(node, { binding, expression }) { + return new Shift.AssignmentExpression({ binding, expression }); + } + + reduceAssignmentTargetIdentifier(node) { + return new Shift.AssignmentTargetIdentifier({ name: node.name }); + } + + reduceAssignmentTargetPropertyIdentifier(node, { binding, init }) { + return new Shift.AssignmentTargetPropertyIdentifier({ binding, init }); + } + + reduceAssignmentTargetPropertyProperty(node, { name, binding }) { + return new Shift.AssignmentTargetPropertyProperty({ name, binding }); + } + + reduceAssignmentTargetWithDefault(node, { binding, init }) { + return new Shift.AssignmentTargetWithDefault({ binding, init }); + } + + reduceAwaitExpression(node, { expression }) { + return new Shift.AwaitExpression({ expression }); + } + + reduceBinaryExpression(node, { left, right }) { + return new Shift.BinaryExpression({ left, operator: node.operator, right }); + } + + reduceBindingIdentifier(node) { + return new Shift.BindingIdentifier({ name: node.name }); + } + + reduceBindingPropertyIdentifier(node, { binding, init }) { + return new Shift.BindingPropertyIdentifier({ binding, init }); + } + + reduceBindingPropertyProperty(node, { name, binding }) { + return new Shift.BindingPropertyProperty({ name, binding }); + } + + reduceBindingWithDefault(node, { binding, init }) { + return new Shift.BindingWithDefault({ binding, init }); + } + + reduceBlock(node, { statements }) { + return new Shift.Block({ statements }); + } + + reduceBlockStatement(node, { block }) { + return new Shift.BlockStatement({ block }); + } + + reduceBreakStatement(node) { + return new Shift.BreakStatement({ label: node.label }); + } + + reduceCallExpression(node, { callee, arguments: _arguments }) { + return new Shift.CallExpression({ callee, arguments: _arguments }); + } + + reduceCatchClause(node, { binding, body }) { + return new Shift.CatchClause({ binding, body }); + } + + reduceClassDeclaration(node, { name, super: _super, elements }) { + return new Shift.ClassDeclaration({ name, super: _super, elements }); + } + + reduceClassElement(node, { method }) { + return new Shift.ClassElement({ isStatic: node.isStatic, method }); + } + + reduceClassExpression(node, { name, super: _super, elements }) { + return new Shift.ClassExpression({ name, super: _super, elements }); + } + + reduceCompoundAssignmentExpression(node, { binding, expression }) { + return new Shift.CompoundAssignmentExpression({ binding, operator: node.operator, expression }); + } + + reduceComputedMemberAssignmentTarget(node, { object, expression }) { + return new Shift.ComputedMemberAssignmentTarget({ object, expression }); + } + + reduceComputedMemberExpression(node, { object, expression }) { + return new Shift.ComputedMemberExpression({ object, expression }); + } + + reduceComputedPropertyName(node, { expression }) { + return new Shift.ComputedPropertyName({ expression }); + } + + reduceConditionalExpression(node, { test, consequent, alternate }) { + return new Shift.ConditionalExpression({ test, consequent, alternate }); + } + + reduceContinueStatement(node) { + return new Shift.ContinueStatement({ label: node.label }); + } + + reduceDataProperty(node, { name, expression }) { + return new Shift.DataProperty({ name, expression }); + } + + reduceDebuggerStatement(node) { + return new Shift.DebuggerStatement; + } + + reduceDirective(node) { + return new Shift.Directive({ rawValue: node.rawValue }); + } + + reduceDoWhileStatement(node, { body, test }) { + return new Shift.DoWhileStatement({ body, test }); + } + + reduceEmptyStatement(node) { + return new Shift.EmptyStatement; + } + + reduceExport(node, { declaration }) { + return new Shift.Export({ declaration }); + } + + reduceExportAllFrom(node) { + return new Shift.ExportAllFrom({ moduleSpecifier: node.moduleSpecifier }); + } + + reduceExportDefault(node, { body }) { + return new Shift.ExportDefault({ body }); + } + + reduceExportFrom(node, { namedExports }) { + return new Shift.ExportFrom({ namedExports, moduleSpecifier: node.moduleSpecifier }); + } + + reduceExportFromSpecifier(node) { + return new Shift.ExportFromSpecifier({ name: node.name, exportedName: node.exportedName }); + } + + reduceExportLocalSpecifier(node, { name }) { + return new Shift.ExportLocalSpecifier({ name, exportedName: node.exportedName }); + } + + reduceExportLocals(node, { namedExports }) { + return new Shift.ExportLocals({ namedExports }); + } + + reduceExpressionStatement(node, { expression }) { + return new Shift.ExpressionStatement({ expression }); + } + + reduceForAwaitStatement(node, { left, right, body }) { + return new Shift.ForAwaitStatement({ left, right, body }); + } + + reduceForInStatement(node, { left, right, body }) { + return new Shift.ForInStatement({ left, right, body }); + } + + reduceForOfStatement(node, { left, right, body }) { + return new Shift.ForOfStatement({ left, right, body }); + } + + reduceForStatement(node, { init, test, update, body }) { + return new Shift.ForStatement({ init, test, update, body }); + } + + reduceFormalParameters(node, { items, rest }) { + return new Shift.FormalParameters({ items, rest }); + } + + reduceFunctionBody(node, { directives, statements }) { + return new Shift.FunctionBody({ directives, statements }); + } + + reduceFunctionDeclaration(node, { name, params, body }) { + return new Shift.FunctionDeclaration({ isAsync: node.isAsync, isGenerator: node.isGenerator, name, params, body }); + } + + reduceFunctionExpression(node, { name, params, body }) { + return new Shift.FunctionExpression({ isAsync: node.isAsync, isGenerator: node.isGenerator, name, params, body }); + } + + reduceGetter(node, { name, body }) { + return new Shift.Getter({ name, body }); + } + + reduceIdentifierExpression(node) { + return new Shift.IdentifierExpression({ name: node.name }); + } + + reduceIfStatement(node, { test, consequent, alternate }) { + return new Shift.IfStatement({ test, consequent, alternate }); + } + + reduceImport(node, { defaultBinding, namedImports }) { + return new Shift.Import({ defaultBinding, namedImports, moduleSpecifier: node.moduleSpecifier }); + } + + reduceImportNamespace(node, { defaultBinding, namespaceBinding }) { + return new Shift.ImportNamespace({ defaultBinding, namespaceBinding, moduleSpecifier: node.moduleSpecifier }); + } + + reduceImportSpecifier(node, { binding }) { + return new Shift.ImportSpecifier({ name: node.name, binding }); + } + + reduceLabeledStatement(node, { body }) { + return new Shift.LabeledStatement({ label: node.label, body }); + } + + reduceLiteralBooleanExpression(node) { + return new Shift.LiteralBooleanExpression({ value: node.value }); + } + + reduceLiteralInfinityExpression(node) { + return new Shift.LiteralInfinityExpression; + } + + reduceLiteralNullExpression(node) { + return new Shift.LiteralNullExpression; + } + + reduceLiteralNumericExpression(node) { + return new Shift.LiteralNumericExpression({ value: node.value }); + } + + reduceLiteralRegExpExpression(node) { + return new Shift.LiteralRegExpExpression({ pattern: node.pattern, global: node.global, ignoreCase: node.ignoreCase, multiLine: node.multiLine, dotAll: node.dotAll, unicode: node.unicode, sticky: node.sticky }); + } + + reduceLiteralStringExpression(node) { + return new Shift.LiteralStringExpression({ value: node.value }); + } + + reduceMethod(node, { name, params, body }) { + return new Shift.Method({ isAsync: node.isAsync, isGenerator: node.isGenerator, name, params, body }); + } + + reduceModule(node, { directives, items }) { + return new Shift.Module({ directives, items }); + } + + reduceNewExpression(node, { callee, arguments: _arguments }) { + return new Shift.NewExpression({ callee, arguments: _arguments }); + } + + reduceNewTargetExpression(node) { + return new Shift.NewTargetExpression; + } + + reduceObjectAssignmentTarget(node, { properties, rest }) { + return new Shift.ObjectAssignmentTarget({ properties, rest }); + } + + reduceObjectBinding(node, { properties, rest }) { + return new Shift.ObjectBinding({ properties, rest }); + } + + reduceObjectExpression(node, { properties }) { + return new Shift.ObjectExpression({ properties }); + } + + reduceReturnStatement(node, { expression }) { + return new Shift.ReturnStatement({ expression }); + } + + reduceScript(node, { directives, statements }) { + return new Shift.Script({ directives, statements }); + } + + reduceSetter(node, { name, param, body }) { + return new Shift.Setter({ name, param, body }); + } + + reduceShorthandProperty(node, { name }) { + return new Shift.ShorthandProperty({ name }); + } + + reduceSpreadElement(node, { expression }) { + return new Shift.SpreadElement({ expression }); + } + + reduceSpreadProperty(node, { expression }) { + return new Shift.SpreadProperty({ expression }); + } + + reduceStaticMemberAssignmentTarget(node, { object }) { + return new Shift.StaticMemberAssignmentTarget({ object, property: node.property }); + } + + reduceStaticMemberExpression(node, { object }) { + return new Shift.StaticMemberExpression({ object, property: node.property }); + } + + reduceStaticPropertyName(node) { + return new Shift.StaticPropertyName({ value: node.value }); + } + + reduceSuper(node) { + return new Shift.Super; + } + + reduceSwitchCase(node, { test, consequent }) { + return new Shift.SwitchCase({ test, consequent }); + } + + reduceSwitchDefault(node, { consequent }) { + return new Shift.SwitchDefault({ consequent }); + } + + reduceSwitchStatement(node, { discriminant, cases }) { + return new Shift.SwitchStatement({ discriminant, cases }); + } + + reduceSwitchStatementWithDefault(node, { discriminant, preDefaultCases, defaultCase, postDefaultCases }) { + return new Shift.SwitchStatementWithDefault({ discriminant, preDefaultCases, defaultCase, postDefaultCases }); + } + + reduceTemplateElement(node) { + return new Shift.TemplateElement({ rawValue: node.rawValue }); + } + + reduceTemplateExpression(node, { tag, elements }) { + return new Shift.TemplateExpression({ tag, elements }); + } + + reduceThisExpression(node) { + return new Shift.ThisExpression; + } + + reduceThrowStatement(node, { expression }) { + return new Shift.ThrowStatement({ expression }); + } + + reduceTryCatchStatement(node, { body, catchClause }) { + return new Shift.TryCatchStatement({ body, catchClause }); + } + + reduceTryFinallyStatement(node, { body, catchClause, finalizer }) { + return new Shift.TryFinallyStatement({ body, catchClause, finalizer }); + } + + reduceUnaryExpression(node, { operand }) { + return new Shift.UnaryExpression({ operator: node.operator, operand }); + } + + reduceUpdateExpression(node, { operand }) { + return new Shift.UpdateExpression({ isPrefix: node.isPrefix, operator: node.operator, operand }); + } + + reduceVariableDeclaration(node, { declarators }) { + return new Shift.VariableDeclaration({ kind: node.kind, declarators }); + } + + reduceVariableDeclarationStatement(node, { declaration }) { + return new Shift.VariableDeclarationStatement({ declaration }); + } + + reduceVariableDeclarator(node, { binding, init }) { + return new Shift.VariableDeclarator({ binding, init }); + } + + reduceWhileStatement(node, { test, body }) { + return new Shift.WhileStatement({ test, body }); + } + + reduceWithStatement(node, { object, body }) { + return new Shift.WithStatement({ object, body }); + } + + reduceYieldExpression(node, { expression }) { + return new Shift.YieldExpression({ expression }); + } + + reduceYieldGeneratorExpression(node, { expression }) { + return new Shift.YieldGeneratorExpression({ expression }); + } +} diff --git a/docs/dist/shift-reducer/director.js b/docs/dist/shift-reducer/director.js new file mode 100644 index 00000000..c9e4b038 --- /dev/null +++ b/docs/dist/shift-reducer/director.js @@ -0,0 +1,418 @@ +// Generated by generate-director.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const director = { + ArrayAssignmentTarget(reducer, node) { + return reducer.reduceArrayAssignmentTarget(node, { elements: node.elements.map(v => v && this[v.type](reducer, v)), rest: node.rest && this[node.rest.type](reducer, node.rest) }); + }, + + ArrayBinding(reducer, node) { + return reducer.reduceArrayBinding(node, { elements: node.elements.map(v => v && this[v.type](reducer, v)), rest: node.rest && this[node.rest.type](reducer, node.rest) }); + }, + + ArrayExpression(reducer, node) { + return reducer.reduceArrayExpression(node, { elements: node.elements.map(v => v && this[v.type](reducer, v)) }); + }, + + ArrowExpression(reducer, node) { + return reducer.reduceArrowExpression(node, { params: this.FormalParameters(reducer, node.params), body: this[node.body.type](reducer, node.body) }); + }, + + AssignmentExpression(reducer, node) { + return reducer.reduceAssignmentExpression(node, { binding: this[node.binding.type](reducer, node.binding), expression: this[node.expression.type](reducer, node.expression) }); + }, + + AssignmentTargetIdentifier(reducer, node) { + return reducer.reduceAssignmentTargetIdentifier(node); + }, + + AssignmentTargetPropertyIdentifier(reducer, node) { + return reducer.reduceAssignmentTargetPropertyIdentifier(node, { binding: this.AssignmentTargetIdentifier(reducer, node.binding), init: node.init && this[node.init.type](reducer, node.init) }); + }, + + AssignmentTargetPropertyProperty(reducer, node) { + return reducer.reduceAssignmentTargetPropertyProperty(node, { name: this[node.name.type](reducer, node.name), binding: this[node.binding.type](reducer, node.binding) }); + }, + + AssignmentTargetWithDefault(reducer, node) { + return reducer.reduceAssignmentTargetWithDefault(node, { binding: this[node.binding.type](reducer, node.binding), init: this[node.init.type](reducer, node.init) }); + }, + + AwaitExpression(reducer, node) { + return reducer.reduceAwaitExpression(node, { expression: this[node.expression.type](reducer, node.expression) }); + }, + + BinaryExpression(reducer, node) { + return reducer.reduceBinaryExpression(node, { left: this[node.left.type](reducer, node.left), right: this[node.right.type](reducer, node.right) }); + }, + + BindingIdentifier(reducer, node) { + return reducer.reduceBindingIdentifier(node); + }, + + BindingPropertyIdentifier(reducer, node) { + return reducer.reduceBindingPropertyIdentifier(node, { binding: this.BindingIdentifier(reducer, node.binding), init: node.init && this[node.init.type](reducer, node.init) }); + }, + + BindingPropertyProperty(reducer, node) { + return reducer.reduceBindingPropertyProperty(node, { name: this[node.name.type](reducer, node.name), binding: this[node.binding.type](reducer, node.binding) }); + }, + + BindingWithDefault(reducer, node) { + return reducer.reduceBindingWithDefault(node, { binding: this[node.binding.type](reducer, node.binding), init: this[node.init.type](reducer, node.init) }); + }, + + Block(reducer, node) { + return reducer.reduceBlock(node, { statements: node.statements.map(v => this[v.type](reducer, v)) }); + }, + + BlockStatement(reducer, node) { + return reducer.reduceBlockStatement(node, { block: this.Block(reducer, node.block) }); + }, + + BreakStatement(reducer, node) { + return reducer.reduceBreakStatement(node); + }, + + CallExpression(reducer, node) { + return reducer.reduceCallExpression(node, { callee: this[node.callee.type](reducer, node.callee), arguments: node.arguments.map(v => this[v.type](reducer, v)) }); + }, + + CatchClause(reducer, node) { + return reducer.reduceCatchClause(node, { binding: this[node.binding.type](reducer, node.binding), body: this.Block(reducer, node.body) }); + }, + + ClassDeclaration(reducer, node) { + return reducer.reduceClassDeclaration(node, { name: this.BindingIdentifier(reducer, node.name), super: node.super && this[node.super.type](reducer, node.super), elements: node.elements.map(v => this.ClassElement(reducer, v)) }); + }, + + ClassElement(reducer, node) { + return reducer.reduceClassElement(node, { method: this[node.method.type](reducer, node.method) }); + }, + + ClassExpression(reducer, node) { + return reducer.reduceClassExpression(node, { name: node.name && this.BindingIdentifier(reducer, node.name), super: node.super && this[node.super.type](reducer, node.super), elements: node.elements.map(v => this.ClassElement(reducer, v)) }); + }, + + CompoundAssignmentExpression(reducer, node) { + return reducer.reduceCompoundAssignmentExpression(node, { binding: this[node.binding.type](reducer, node.binding), expression: this[node.expression.type](reducer, node.expression) }); + }, + + ComputedMemberAssignmentTarget(reducer, node) { + return reducer.reduceComputedMemberAssignmentTarget(node, { object: this[node.object.type](reducer, node.object), expression: this[node.expression.type](reducer, node.expression) }); + }, + + ComputedMemberExpression(reducer, node) { + return reducer.reduceComputedMemberExpression(node, { object: this[node.object.type](reducer, node.object), expression: this[node.expression.type](reducer, node.expression) }); + }, + + ComputedPropertyName(reducer, node) { + return reducer.reduceComputedPropertyName(node, { expression: this[node.expression.type](reducer, node.expression) }); + }, + + ConditionalExpression(reducer, node) { + return reducer.reduceConditionalExpression(node, { test: this[node.test.type](reducer, node.test), consequent: this[node.consequent.type](reducer, node.consequent), alternate: this[node.alternate.type](reducer, node.alternate) }); + }, + + ContinueStatement(reducer, node) { + return reducer.reduceContinueStatement(node); + }, + + DataProperty(reducer, node) { + return reducer.reduceDataProperty(node, { name: this[node.name.type](reducer, node.name), expression: this[node.expression.type](reducer, node.expression) }); + }, + + DebuggerStatement(reducer, node) { + return reducer.reduceDebuggerStatement(node); + }, + + Directive(reducer, node) { + return reducer.reduceDirective(node); + }, + + DoWhileStatement(reducer, node) { + return reducer.reduceDoWhileStatement(node, { body: this[node.body.type](reducer, node.body), test: this[node.test.type](reducer, node.test) }); + }, + + EmptyStatement(reducer, node) { + return reducer.reduceEmptyStatement(node); + }, + + Export(reducer, node) { + return reducer.reduceExport(node, { declaration: this[node.declaration.type](reducer, node.declaration) }); + }, + + ExportAllFrom(reducer, node) { + return reducer.reduceExportAllFrom(node); + }, + + ExportDefault(reducer, node) { + return reducer.reduceExportDefault(node, { body: this[node.body.type](reducer, node.body) }); + }, + + ExportFrom(reducer, node) { + return reducer.reduceExportFrom(node, { namedExports: node.namedExports.map(v => this.ExportFromSpecifier(reducer, v)) }); + }, + + ExportFromSpecifier(reducer, node) { + return reducer.reduceExportFromSpecifier(node); + }, + + ExportLocalSpecifier(reducer, node) { + return reducer.reduceExportLocalSpecifier(node, { name: this.IdentifierExpression(reducer, node.name) }); + }, + + ExportLocals(reducer, node) { + return reducer.reduceExportLocals(node, { namedExports: node.namedExports.map(v => this.ExportLocalSpecifier(reducer, v)) }); + }, + + ExpressionStatement(reducer, node) { + return reducer.reduceExpressionStatement(node, { expression: this[node.expression.type](reducer, node.expression) }); + }, + + ForAwaitStatement(reducer, node) { + return reducer.reduceForAwaitStatement(node, { left: this[node.left.type](reducer, node.left), right: this[node.right.type](reducer, node.right), body: this[node.body.type](reducer, node.body) }); + }, + + ForInStatement(reducer, node) { + return reducer.reduceForInStatement(node, { left: this[node.left.type](reducer, node.left), right: this[node.right.type](reducer, node.right), body: this[node.body.type](reducer, node.body) }); + }, + + ForOfStatement(reducer, node) { + return reducer.reduceForOfStatement(node, { left: this[node.left.type](reducer, node.left), right: this[node.right.type](reducer, node.right), body: this[node.body.type](reducer, node.body) }); + }, + + ForStatement(reducer, node) { + return reducer.reduceForStatement(node, { init: node.init && this[node.init.type](reducer, node.init), test: node.test && this[node.test.type](reducer, node.test), update: node.update && this[node.update.type](reducer, node.update), body: this[node.body.type](reducer, node.body) }); + }, + + FormalParameters(reducer, node) { + return reducer.reduceFormalParameters(node, { items: node.items.map(v => this[v.type](reducer, v)), rest: node.rest && this[node.rest.type](reducer, node.rest) }); + }, + + FunctionBody(reducer, node) { + return reducer.reduceFunctionBody(node, { directives: node.directives.map(v => this.Directive(reducer, v)), statements: node.statements.map(v => this[v.type](reducer, v)) }); + }, + + FunctionDeclaration(reducer, node) { + return reducer.reduceFunctionDeclaration(node, { name: this.BindingIdentifier(reducer, node.name), params: this.FormalParameters(reducer, node.params), body: this.FunctionBody(reducer, node.body) }); + }, + + FunctionExpression(reducer, node) { + return reducer.reduceFunctionExpression(node, { name: node.name && this.BindingIdentifier(reducer, node.name), params: this.FormalParameters(reducer, node.params), body: this.FunctionBody(reducer, node.body) }); + }, + + Getter(reducer, node) { + return reducer.reduceGetter(node, { name: this[node.name.type](reducer, node.name), body: this.FunctionBody(reducer, node.body) }); + }, + + IdentifierExpression(reducer, node) { + return reducer.reduceIdentifierExpression(node); + }, + + IfStatement(reducer, node) { + return reducer.reduceIfStatement(node, { test: this[node.test.type](reducer, node.test), consequent: this[node.consequent.type](reducer, node.consequent), alternate: node.alternate && this[node.alternate.type](reducer, node.alternate) }); + }, + + Import(reducer, node) { + return reducer.reduceImport(node, { defaultBinding: node.defaultBinding && this.BindingIdentifier(reducer, node.defaultBinding), namedImports: node.namedImports.map(v => this.ImportSpecifier(reducer, v)) }); + }, + + ImportNamespace(reducer, node) { + return reducer.reduceImportNamespace(node, { defaultBinding: node.defaultBinding && this.BindingIdentifier(reducer, node.defaultBinding), namespaceBinding: this.BindingIdentifier(reducer, node.namespaceBinding) }); + }, + + ImportSpecifier(reducer, node) { + return reducer.reduceImportSpecifier(node, { binding: this.BindingIdentifier(reducer, node.binding) }); + }, + + LabeledStatement(reducer, node) { + return reducer.reduceLabeledStatement(node, { body: this[node.body.type](reducer, node.body) }); + }, + + LiteralBooleanExpression(reducer, node) { + return reducer.reduceLiteralBooleanExpression(node); + }, + + LiteralInfinityExpression(reducer, node) { + return reducer.reduceLiteralInfinityExpression(node); + }, + + LiteralNullExpression(reducer, node) { + return reducer.reduceLiteralNullExpression(node); + }, + + LiteralNumericExpression(reducer, node) { + return reducer.reduceLiteralNumericExpression(node); + }, + + LiteralRegExpExpression(reducer, node) { + return reducer.reduceLiteralRegExpExpression(node); + }, + + LiteralStringExpression(reducer, node) { + return reducer.reduceLiteralStringExpression(node); + }, + + Method(reducer, node) { + return reducer.reduceMethod(node, { name: this[node.name.type](reducer, node.name), params: this.FormalParameters(reducer, node.params), body: this.FunctionBody(reducer, node.body) }); + }, + + Module(reducer, node) { + return reducer.reduceModule(node, { directives: node.directives.map(v => this.Directive(reducer, v)), items: node.items.map(v => this[v.type](reducer, v)) }); + }, + + NewExpression(reducer, node) { + return reducer.reduceNewExpression(node, { callee: this[node.callee.type](reducer, node.callee), arguments: node.arguments.map(v => this[v.type](reducer, v)) }); + }, + + NewTargetExpression(reducer, node) { + return reducer.reduceNewTargetExpression(node); + }, + + ObjectAssignmentTarget(reducer, node) { + return reducer.reduceObjectAssignmentTarget(node, { properties: node.properties.map(v => this[v.type](reducer, v)), rest: node.rest && this[node.rest.type](reducer, node.rest) }); + }, + + ObjectBinding(reducer, node) { + return reducer.reduceObjectBinding(node, { properties: node.properties.map(v => this[v.type](reducer, v)), rest: node.rest && this[node.rest.type](reducer, node.rest) }); + }, + + ObjectExpression(reducer, node) { + return reducer.reduceObjectExpression(node, { properties: node.properties.map(v => this[v.type](reducer, v)) }); + }, + + ReturnStatement(reducer, node) { + return reducer.reduceReturnStatement(node, { expression: node.expression && this[node.expression.type](reducer, node.expression) }); + }, + + Script(reducer, node) { + return reducer.reduceScript(node, { directives: node.directives.map(v => this.Directive(reducer, v)), statements: node.statements.map(v => this[v.type](reducer, v)) }); + }, + + Setter(reducer, node) { + return reducer.reduceSetter(node, { name: this[node.name.type](reducer, node.name), param: this[node.param.type](reducer, node.param), body: this.FunctionBody(reducer, node.body) }); + }, + + ShorthandProperty(reducer, node) { + return reducer.reduceShorthandProperty(node, { name: this.IdentifierExpression(reducer, node.name) }); + }, + + SpreadElement(reducer, node) { + return reducer.reduceSpreadElement(node, { expression: this[node.expression.type](reducer, node.expression) }); + }, + + SpreadProperty(reducer, node) { + return reducer.reduceSpreadProperty(node, { expression: this[node.expression.type](reducer, node.expression) }); + }, + + StaticMemberAssignmentTarget(reducer, node) { + return reducer.reduceStaticMemberAssignmentTarget(node, { object: this[node.object.type](reducer, node.object) }); + }, + + StaticMemberExpression(reducer, node) { + return reducer.reduceStaticMemberExpression(node, { object: this[node.object.type](reducer, node.object) }); + }, + + StaticPropertyName(reducer, node) { + return reducer.reduceStaticPropertyName(node); + }, + + Super(reducer, node) { + return reducer.reduceSuper(node); + }, + + SwitchCase(reducer, node) { + return reducer.reduceSwitchCase(node, { test: this[node.test.type](reducer, node.test), consequent: node.consequent.map(v => this[v.type](reducer, v)) }); + }, + + SwitchDefault(reducer, node) { + return reducer.reduceSwitchDefault(node, { consequent: node.consequent.map(v => this[v.type](reducer, v)) }); + }, + + SwitchStatement(reducer, node) { + return reducer.reduceSwitchStatement(node, { discriminant: this[node.discriminant.type](reducer, node.discriminant), cases: node.cases.map(v => this.SwitchCase(reducer, v)) }); + }, + + SwitchStatementWithDefault(reducer, node) { + return reducer.reduceSwitchStatementWithDefault(node, { discriminant: this[node.discriminant.type](reducer, node.discriminant), preDefaultCases: node.preDefaultCases.map(v => this.SwitchCase(reducer, v)), defaultCase: this.SwitchDefault(reducer, node.defaultCase), postDefaultCases: node.postDefaultCases.map(v => this.SwitchCase(reducer, v)) }); + }, + + TemplateElement(reducer, node) { + return reducer.reduceTemplateElement(node); + }, + + TemplateExpression(reducer, node) { + return reducer.reduceTemplateExpression(node, { tag: node.tag && this[node.tag.type](reducer, node.tag), elements: node.elements.map(v => this[v.type](reducer, v)) }); + }, + + ThisExpression(reducer, node) { + return reducer.reduceThisExpression(node); + }, + + ThrowStatement(reducer, node) { + return reducer.reduceThrowStatement(node, { expression: this[node.expression.type](reducer, node.expression) }); + }, + + TryCatchStatement(reducer, node) { + return reducer.reduceTryCatchStatement(node, { body: this.Block(reducer, node.body), catchClause: this.CatchClause(reducer, node.catchClause) }); + }, + + TryFinallyStatement(reducer, node) { + return reducer.reduceTryFinallyStatement(node, { body: this.Block(reducer, node.body), catchClause: node.catchClause && this.CatchClause(reducer, node.catchClause), finalizer: this.Block(reducer, node.finalizer) }); + }, + + UnaryExpression(reducer, node) { + return reducer.reduceUnaryExpression(node, { operand: this[node.operand.type](reducer, node.operand) }); + }, + + UpdateExpression(reducer, node) { + return reducer.reduceUpdateExpression(node, { operand: this[node.operand.type](reducer, node.operand) }); + }, + + VariableDeclaration(reducer, node) { + return reducer.reduceVariableDeclaration(node, { declarators: node.declarators.map(v => this.VariableDeclarator(reducer, v)) }); + }, + + VariableDeclarationStatement(reducer, node) { + return reducer.reduceVariableDeclarationStatement(node, { declaration: this.VariableDeclaration(reducer, node.declaration) }); + }, + + VariableDeclarator(reducer, node) { + return reducer.reduceVariableDeclarator(node, { binding: this[node.binding.type](reducer, node.binding), init: node.init && this[node.init.type](reducer, node.init) }); + }, + + WhileStatement(reducer, node) { + return reducer.reduceWhileStatement(node, { test: this[node.test.type](reducer, node.test), body: this[node.body.type](reducer, node.body) }); + }, + + WithStatement(reducer, node) { + return reducer.reduceWithStatement(node, { object: this[node.object.type](reducer, node.object), body: this[node.body.type](reducer, node.body) }); + }, + + YieldExpression(reducer, node) { + return reducer.reduceYieldExpression(node, { expression: node.expression && this[node.expression.type](reducer, node.expression) }); + }, + + YieldGeneratorExpression(reducer, node) { + return reducer.reduceYieldGeneratorExpression(node, { expression: this[node.expression.type](reducer, node.expression) }); + }, +}; + +export function reduce(reducer, node) { + return director[node.type](reducer, node); +} diff --git a/docs/dist/shift-reducer/index.js b/docs/dist/shift-reducer/index.js new file mode 100644 index 00000000..2a97b980 --- /dev/null +++ b/docs/dist/shift-reducer/index.js @@ -0,0 +1,27 @@ +/* + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { reduce, reduce as default } from './director.js'; +export { thunkedReduce } from './thunked-director.js'; +export { default as thunkify } from './thunkify.js'; +export { default as thunkifyClass } from './thunkify-class.js'; +export { default as memoize } from './memoize.js'; +export { default as CloneReducer } from './clone-reducer.js'; +export { default as LazyCloneReducer } from './lazy-clone-reducer.js'; +export { default as MonoidalReducer } from './monoidal-reducer.js'; +export { default as ThunkedMonoidalReducer } from './thunked-monoidal-reducer.js'; +export { default as adapt } from './adapt.js'; +export { PlusReducer, ThunkedPlusReducer, ConcatReducer, ThunkedConcatReducer, AndReducer, ThunkedAndReducer, OrReducer, ThunkedOrReducer } from './reducers.js'; diff --git a/docs/dist/shift-reducer/lazy-clone-reducer.js b/docs/dist/shift-reducer/lazy-clone-reducer.js new file mode 100644 index 00000000..1014b347 --- /dev/null +++ b/docs/dist/shift-reducer/lazy-clone-reducer.js @@ -0,0 +1,650 @@ +// Generated by generate-lazy-clone-reducer.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as Shift from '../../_snowpack/pkg/shift-ast.js'; + +export default class LazyCloneReducer { + reduceArrayAssignmentTarget(node, { elements, rest }) { + if ((node.elements.length === elements.length && node.elements.every((v, i) => v === elements[i])) && node.rest === rest) { + return node; + } + return new Shift.ArrayAssignmentTarget({ elements, rest }); + } + + reduceArrayBinding(node, { elements, rest }) { + if ((node.elements.length === elements.length && node.elements.every((v, i) => v === elements[i])) && node.rest === rest) { + return node; + } + return new Shift.ArrayBinding({ elements, rest }); + } + + reduceArrayExpression(node, { elements }) { + if ((node.elements.length === elements.length && node.elements.every((v, i) => v === elements[i]))) { + return node; + } + return new Shift.ArrayExpression({ elements }); + } + + reduceArrowExpression(node, { params, body }) { + if (node.params === params && node.body === body) { + return node; + } + return new Shift.ArrowExpression({ isAsync: node.isAsync, params, body }); + } + + reduceAssignmentExpression(node, { binding, expression }) { + if (node.binding === binding && node.expression === expression) { + return node; + } + return new Shift.AssignmentExpression({ binding, expression }); + } + + reduceAssignmentTargetIdentifier(node) { + return node; + } + + reduceAssignmentTargetPropertyIdentifier(node, { binding, init }) { + if (node.binding === binding && node.init === init) { + return node; + } + return new Shift.AssignmentTargetPropertyIdentifier({ binding, init }); + } + + reduceAssignmentTargetPropertyProperty(node, { name, binding }) { + if (node.name === name && node.binding === binding) { + return node; + } + return new Shift.AssignmentTargetPropertyProperty({ name, binding }); + } + + reduceAssignmentTargetWithDefault(node, { binding, init }) { + if (node.binding === binding && node.init === init) { + return node; + } + return new Shift.AssignmentTargetWithDefault({ binding, init }); + } + + reduceAwaitExpression(node, { expression }) { + if (node.expression === expression) { + return node; + } + return new Shift.AwaitExpression({ expression }); + } + + reduceBinaryExpression(node, { left, right }) { + if (node.left === left && node.right === right) { + return node; + } + return new Shift.BinaryExpression({ left, operator: node.operator, right }); + } + + reduceBindingIdentifier(node) { + return node; + } + + reduceBindingPropertyIdentifier(node, { binding, init }) { + if (node.binding === binding && node.init === init) { + return node; + } + return new Shift.BindingPropertyIdentifier({ binding, init }); + } + + reduceBindingPropertyProperty(node, { name, binding }) { + if (node.name === name && node.binding === binding) { + return node; + } + return new Shift.BindingPropertyProperty({ name, binding }); + } + + reduceBindingWithDefault(node, { binding, init }) { + if (node.binding === binding && node.init === init) { + return node; + } + return new Shift.BindingWithDefault({ binding, init }); + } + + reduceBlock(node, { statements }) { + if ((node.statements.length === statements.length && node.statements.every((v, i) => v === statements[i]))) { + return node; + } + return new Shift.Block({ statements }); + } + + reduceBlockStatement(node, { block }) { + if (node.block === block) { + return node; + } + return new Shift.BlockStatement({ block }); + } + + reduceBreakStatement(node) { + return node; + } + + reduceCallExpression(node, { callee, arguments: _arguments }) { + if (node.callee === callee && (node.arguments.length === _arguments.length && node.arguments.every((v, i) => v === _arguments[i]))) { + return node; + } + return new Shift.CallExpression({ callee, arguments: _arguments }); + } + + reduceCatchClause(node, { binding, body }) { + if (node.binding === binding && node.body === body) { + return node; + } + return new Shift.CatchClause({ binding, body }); + } + + reduceClassDeclaration(node, { name, super: _super, elements }) { + if (node.name === name && node.super === _super && (node.elements.length === elements.length && node.elements.every((v, i) => v === elements[i]))) { + return node; + } + return new Shift.ClassDeclaration({ name, super: _super, elements }); + } + + reduceClassElement(node, { method }) { + if (node.method === method) { + return node; + } + return new Shift.ClassElement({ isStatic: node.isStatic, method }); + } + + reduceClassExpression(node, { name, super: _super, elements }) { + if (node.name === name && node.super === _super && (node.elements.length === elements.length && node.elements.every((v, i) => v === elements[i]))) { + return node; + } + return new Shift.ClassExpression({ name, super: _super, elements }); + } + + reduceCompoundAssignmentExpression(node, { binding, expression }) { + if (node.binding === binding && node.expression === expression) { + return node; + } + return new Shift.CompoundAssignmentExpression({ binding, operator: node.operator, expression }); + } + + reduceComputedMemberAssignmentTarget(node, { object, expression }) { + if (node.object === object && node.expression === expression) { + return node; + } + return new Shift.ComputedMemberAssignmentTarget({ object, expression }); + } + + reduceComputedMemberExpression(node, { object, expression }) { + if (node.object === object && node.expression === expression) { + return node; + } + return new Shift.ComputedMemberExpression({ object, expression }); + } + + reduceComputedPropertyName(node, { expression }) { + if (node.expression === expression) { + return node; + } + return new Shift.ComputedPropertyName({ expression }); + } + + reduceConditionalExpression(node, { test, consequent, alternate }) { + if (node.test === test && node.consequent === consequent && node.alternate === alternate) { + return node; + } + return new Shift.ConditionalExpression({ test, consequent, alternate }); + } + + reduceContinueStatement(node) { + return node; + } + + reduceDataProperty(node, { name, expression }) { + if (node.name === name && node.expression === expression) { + return node; + } + return new Shift.DataProperty({ name, expression }); + } + + reduceDebuggerStatement(node) { + return node; + } + + reduceDirective(node) { + return node; + } + + reduceDoWhileStatement(node, { body, test }) { + if (node.body === body && node.test === test) { + return node; + } + return new Shift.DoWhileStatement({ body, test }); + } + + reduceEmptyStatement(node) { + return node; + } + + reduceExport(node, { declaration }) { + if (node.declaration === declaration) { + return node; + } + return new Shift.Export({ declaration }); + } + + reduceExportAllFrom(node) { + return node; + } + + reduceExportDefault(node, { body }) { + if (node.body === body) { + return node; + } + return new Shift.ExportDefault({ body }); + } + + reduceExportFrom(node, { namedExports }) { + if ((node.namedExports.length === namedExports.length && node.namedExports.every((v, i) => v === namedExports[i]))) { + return node; + } + return new Shift.ExportFrom({ namedExports, moduleSpecifier: node.moduleSpecifier }); + } + + reduceExportFromSpecifier(node) { + return node; + } + + reduceExportLocalSpecifier(node, { name }) { + if (node.name === name) { + return node; + } + return new Shift.ExportLocalSpecifier({ name, exportedName: node.exportedName }); + } + + reduceExportLocals(node, { namedExports }) { + if ((node.namedExports.length === namedExports.length && node.namedExports.every((v, i) => v === namedExports[i]))) { + return node; + } + return new Shift.ExportLocals({ namedExports }); + } + + reduceExpressionStatement(node, { expression }) { + if (node.expression === expression) { + return node; + } + return new Shift.ExpressionStatement({ expression }); + } + + reduceForAwaitStatement(node, { left, right, body }) { + if (node.left === left && node.right === right && node.body === body) { + return node; + } + return new Shift.ForAwaitStatement({ left, right, body }); + } + + reduceForInStatement(node, { left, right, body }) { + if (node.left === left && node.right === right && node.body === body) { + return node; + } + return new Shift.ForInStatement({ left, right, body }); + } + + reduceForOfStatement(node, { left, right, body }) { + if (node.left === left && node.right === right && node.body === body) { + return node; + } + return new Shift.ForOfStatement({ left, right, body }); + } + + reduceForStatement(node, { init, test, update, body }) { + if (node.init === init && node.test === test && node.update === update && node.body === body) { + return node; + } + return new Shift.ForStatement({ init, test, update, body }); + } + + reduceFormalParameters(node, { items, rest }) { + if ((node.items.length === items.length && node.items.every((v, i) => v === items[i])) && node.rest === rest) { + return node; + } + return new Shift.FormalParameters({ items, rest }); + } + + reduceFunctionBody(node, { directives, statements }) { + if ((node.directives.length === directives.length && node.directives.every((v, i) => v === directives[i])) && (node.statements.length === statements.length && node.statements.every((v, i) => v === statements[i]))) { + return node; + } + return new Shift.FunctionBody({ directives, statements }); + } + + reduceFunctionDeclaration(node, { name, params, body }) { + if (node.name === name && node.params === params && node.body === body) { + return node; + } + return new Shift.FunctionDeclaration({ isAsync: node.isAsync, isGenerator: node.isGenerator, name, params, body }); + } + + reduceFunctionExpression(node, { name, params, body }) { + if (node.name === name && node.params === params && node.body === body) { + return node; + } + return new Shift.FunctionExpression({ isAsync: node.isAsync, isGenerator: node.isGenerator, name, params, body }); + } + + reduceGetter(node, { name, body }) { + if (node.name === name && node.body === body) { + return node; + } + return new Shift.Getter({ name, body }); + } + + reduceIdentifierExpression(node) { + return node; + } + + reduceIfStatement(node, { test, consequent, alternate }) { + if (node.test === test && node.consequent === consequent && node.alternate === alternate) { + return node; + } + return new Shift.IfStatement({ test, consequent, alternate }); + } + + reduceImport(node, { defaultBinding, namedImports }) { + if (node.defaultBinding === defaultBinding && (node.namedImports.length === namedImports.length && node.namedImports.every((v, i) => v === namedImports[i]))) { + return node; + } + return new Shift.Import({ defaultBinding, namedImports, moduleSpecifier: node.moduleSpecifier }); + } + + reduceImportNamespace(node, { defaultBinding, namespaceBinding }) { + if (node.defaultBinding === defaultBinding && node.namespaceBinding === namespaceBinding) { + return node; + } + return new Shift.ImportNamespace({ defaultBinding, namespaceBinding, moduleSpecifier: node.moduleSpecifier }); + } + + reduceImportSpecifier(node, { binding }) { + if (node.binding === binding) { + return node; + } + return new Shift.ImportSpecifier({ name: node.name, binding }); + } + + reduceLabeledStatement(node, { body }) { + if (node.body === body) { + return node; + } + return new Shift.LabeledStatement({ label: node.label, body }); + } + + reduceLiteralBooleanExpression(node) { + return node; + } + + reduceLiteralInfinityExpression(node) { + return node; + } + + reduceLiteralNullExpression(node) { + return node; + } + + reduceLiteralNumericExpression(node) { + return node; + } + + reduceLiteralRegExpExpression(node) { + return node; + } + + reduceLiteralStringExpression(node) { + return node; + } + + reduceMethod(node, { name, params, body }) { + if (node.name === name && node.params === params && node.body === body) { + return node; + } + return new Shift.Method({ isAsync: node.isAsync, isGenerator: node.isGenerator, name, params, body }); + } + + reduceModule(node, { directives, items }) { + if ((node.directives.length === directives.length && node.directives.every((v, i) => v === directives[i])) && (node.items.length === items.length && node.items.every((v, i) => v === items[i]))) { + return node; + } + return new Shift.Module({ directives, items }); + } + + reduceNewExpression(node, { callee, arguments: _arguments }) { + if (node.callee === callee && (node.arguments.length === _arguments.length && node.arguments.every((v, i) => v === _arguments[i]))) { + return node; + } + return new Shift.NewExpression({ callee, arguments: _arguments }); + } + + reduceNewTargetExpression(node) { + return node; + } + + reduceObjectAssignmentTarget(node, { properties, rest }) { + if ((node.properties.length === properties.length && node.properties.every((v, i) => v === properties[i])) && node.rest === rest) { + return node; + } + return new Shift.ObjectAssignmentTarget({ properties, rest }); + } + + reduceObjectBinding(node, { properties, rest }) { + if ((node.properties.length === properties.length && node.properties.every((v, i) => v === properties[i])) && node.rest === rest) { + return node; + } + return new Shift.ObjectBinding({ properties, rest }); + } + + reduceObjectExpression(node, { properties }) { + if ((node.properties.length === properties.length && node.properties.every((v, i) => v === properties[i]))) { + return node; + } + return new Shift.ObjectExpression({ properties }); + } + + reduceReturnStatement(node, { expression }) { + if (node.expression === expression) { + return node; + } + return new Shift.ReturnStatement({ expression }); + } + + reduceScript(node, { directives, statements }) { + if ((node.directives.length === directives.length && node.directives.every((v, i) => v === directives[i])) && (node.statements.length === statements.length && node.statements.every((v, i) => v === statements[i]))) { + return node; + } + return new Shift.Script({ directives, statements }); + } + + reduceSetter(node, { name, param, body }) { + if (node.name === name && node.param === param && node.body === body) { + return node; + } + return new Shift.Setter({ name, param, body }); + } + + reduceShorthandProperty(node, { name }) { + if (node.name === name) { + return node; + } + return new Shift.ShorthandProperty({ name }); + } + + reduceSpreadElement(node, { expression }) { + if (node.expression === expression) { + return node; + } + return new Shift.SpreadElement({ expression }); + } + + reduceSpreadProperty(node, { expression }) { + if (node.expression === expression) { + return node; + } + return new Shift.SpreadProperty({ expression }); + } + + reduceStaticMemberAssignmentTarget(node, { object }) { + if (node.object === object) { + return node; + } + return new Shift.StaticMemberAssignmentTarget({ object, property: node.property }); + } + + reduceStaticMemberExpression(node, { object }) { + if (node.object === object) { + return node; + } + return new Shift.StaticMemberExpression({ object, property: node.property }); + } + + reduceStaticPropertyName(node) { + return node; + } + + reduceSuper(node) { + return node; + } + + reduceSwitchCase(node, { test, consequent }) { + if (node.test === test && (node.consequent.length === consequent.length && node.consequent.every((v, i) => v === consequent[i]))) { + return node; + } + return new Shift.SwitchCase({ test, consequent }); + } + + reduceSwitchDefault(node, { consequent }) { + if ((node.consequent.length === consequent.length && node.consequent.every((v, i) => v === consequent[i]))) { + return node; + } + return new Shift.SwitchDefault({ consequent }); + } + + reduceSwitchStatement(node, { discriminant, cases }) { + if (node.discriminant === discriminant && (node.cases.length === cases.length && node.cases.every((v, i) => v === cases[i]))) { + return node; + } + return new Shift.SwitchStatement({ discriminant, cases }); + } + + reduceSwitchStatementWithDefault(node, { discriminant, preDefaultCases, defaultCase, postDefaultCases }) { + if (node.discriminant === discriminant && (node.preDefaultCases.length === preDefaultCases.length && node.preDefaultCases.every((v, i) => v === preDefaultCases[i])) && node.defaultCase === defaultCase && (node.postDefaultCases.length === postDefaultCases.length && node.postDefaultCases.every((v, i) => v === postDefaultCases[i]))) { + return node; + } + return new Shift.SwitchStatementWithDefault({ discriminant, preDefaultCases, defaultCase, postDefaultCases }); + } + + reduceTemplateElement(node) { + return node; + } + + reduceTemplateExpression(node, { tag, elements }) { + if (node.tag === tag && (node.elements.length === elements.length && node.elements.every((v, i) => v === elements[i]))) { + return node; + } + return new Shift.TemplateExpression({ tag, elements }); + } + + reduceThisExpression(node) { + return node; + } + + reduceThrowStatement(node, { expression }) { + if (node.expression === expression) { + return node; + } + return new Shift.ThrowStatement({ expression }); + } + + reduceTryCatchStatement(node, { body, catchClause }) { + if (node.body === body && node.catchClause === catchClause) { + return node; + } + return new Shift.TryCatchStatement({ body, catchClause }); + } + + reduceTryFinallyStatement(node, { body, catchClause, finalizer }) { + if (node.body === body && node.catchClause === catchClause && node.finalizer === finalizer) { + return node; + } + return new Shift.TryFinallyStatement({ body, catchClause, finalizer }); + } + + reduceUnaryExpression(node, { operand }) { + if (node.operand === operand) { + return node; + } + return new Shift.UnaryExpression({ operator: node.operator, operand }); + } + + reduceUpdateExpression(node, { operand }) { + if (node.operand === operand) { + return node; + } + return new Shift.UpdateExpression({ isPrefix: node.isPrefix, operator: node.operator, operand }); + } + + reduceVariableDeclaration(node, { declarators }) { + if ((node.declarators.length === declarators.length && node.declarators.every((v, i) => v === declarators[i]))) { + return node; + } + return new Shift.VariableDeclaration({ kind: node.kind, declarators }); + } + + reduceVariableDeclarationStatement(node, { declaration }) { + if (node.declaration === declaration) { + return node; + } + return new Shift.VariableDeclarationStatement({ declaration }); + } + + reduceVariableDeclarator(node, { binding, init }) { + if (node.binding === binding && node.init === init) { + return node; + } + return new Shift.VariableDeclarator({ binding, init }); + } + + reduceWhileStatement(node, { test, body }) { + if (node.test === test && node.body === body) { + return node; + } + return new Shift.WhileStatement({ test, body }); + } + + reduceWithStatement(node, { object, body }) { + if (node.object === object && node.body === body) { + return node; + } + return new Shift.WithStatement({ object, body }); + } + + reduceYieldExpression(node, { expression }) { + if (node.expression === expression) { + return node; + } + return new Shift.YieldExpression({ expression }); + } + + reduceYieldGeneratorExpression(node, { expression }) { + if (node.expression === expression) { + return node; + } + return new Shift.YieldGeneratorExpression({ expression }); + } +} diff --git a/docs/dist/shift-reducer/memoize.js b/docs/dist/shift-reducer/memoize.js new file mode 100644 index 00000000..947f7b72 --- /dev/null +++ b/docs/dist/shift-reducer/memoize.js @@ -0,0 +1,914 @@ +// Generated by generate-memoize.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as Shift from '../../_snowpack/pkg/shift-ast.js'; + +export default function memoize(reducer) { + const cache = new WeakMap; + return { + reduceArrayAssignmentTarget(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceArrayAssignmentTarget(node, arg); + cache.set(node, res); + return res; + }, + + reduceArrayBinding(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceArrayBinding(node, arg); + cache.set(node, res); + return res; + }, + + reduceArrayExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceArrayExpression(node, arg); + cache.set(node, res); + return res; + }, + + reduceArrowExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceArrowExpression(node, arg); + cache.set(node, res); + return res; + }, + + reduceAssignmentExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceAssignmentExpression(node, arg); + cache.set(node, res); + return res; + }, + + reduceAssignmentTargetIdentifier(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceAssignmentTargetIdentifier(node); + cache.set(node, res); + return res; + }, + + reduceAssignmentTargetPropertyIdentifier(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceAssignmentTargetPropertyIdentifier(node, arg); + cache.set(node, res); + return res; + }, + + reduceAssignmentTargetPropertyProperty(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceAssignmentTargetPropertyProperty(node, arg); + cache.set(node, res); + return res; + }, + + reduceAssignmentTargetWithDefault(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceAssignmentTargetWithDefault(node, arg); + cache.set(node, res); + return res; + }, + + reduceAwaitExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceAwaitExpression(node, arg); + cache.set(node, res); + return res; + }, + + reduceBinaryExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceBinaryExpression(node, arg); + cache.set(node, res); + return res; + }, + + reduceBindingIdentifier(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceBindingIdentifier(node); + cache.set(node, res); + return res; + }, + + reduceBindingPropertyIdentifier(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceBindingPropertyIdentifier(node, arg); + cache.set(node, res); + return res; + }, + + reduceBindingPropertyProperty(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceBindingPropertyProperty(node, arg); + cache.set(node, res); + return res; + }, + + reduceBindingWithDefault(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceBindingWithDefault(node, arg); + cache.set(node, res); + return res; + }, + + reduceBlock(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceBlock(node, arg); + cache.set(node, res); + return res; + }, + + reduceBlockStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceBlockStatement(node, arg); + cache.set(node, res); + return res; + }, + + reduceBreakStatement(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceBreakStatement(node); + cache.set(node, res); + return res; + }, + + reduceCallExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceCallExpression(node, arg); + cache.set(node, res); + return res; + }, + + reduceCatchClause(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceCatchClause(node, arg); + cache.set(node, res); + return res; + }, + + reduceClassDeclaration(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceClassDeclaration(node, arg); + cache.set(node, res); + return res; + }, + + reduceClassElement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceClassElement(node, arg); + cache.set(node, res); + return res; + }, + + reduceClassExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceClassExpression(node, arg); + cache.set(node, res); + return res; + }, + + reduceCompoundAssignmentExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceCompoundAssignmentExpression(node, arg); + cache.set(node, res); + return res; + }, + + reduceComputedMemberAssignmentTarget(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceComputedMemberAssignmentTarget(node, arg); + cache.set(node, res); + return res; + }, + + reduceComputedMemberExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceComputedMemberExpression(node, arg); + cache.set(node, res); + return res; + }, + + reduceComputedPropertyName(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceComputedPropertyName(node, arg); + cache.set(node, res); + return res; + }, + + reduceConditionalExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceConditionalExpression(node, arg); + cache.set(node, res); + return res; + }, + + reduceContinueStatement(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceContinueStatement(node); + cache.set(node, res); + return res; + }, + + reduceDataProperty(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceDataProperty(node, arg); + cache.set(node, res); + return res; + }, + + reduceDebuggerStatement(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceDebuggerStatement(node); + cache.set(node, res); + return res; + }, + + reduceDirective(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceDirective(node); + cache.set(node, res); + return res; + }, + + reduceDoWhileStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceDoWhileStatement(node, arg); + cache.set(node, res); + return res; + }, + + reduceEmptyStatement(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceEmptyStatement(node); + cache.set(node, res); + return res; + }, + + reduceExport(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceExport(node, arg); + cache.set(node, res); + return res; + }, + + reduceExportAllFrom(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceExportAllFrom(node); + cache.set(node, res); + return res; + }, + + reduceExportDefault(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceExportDefault(node, arg); + cache.set(node, res); + return res; + }, + + reduceExportFrom(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceExportFrom(node, arg); + cache.set(node, res); + return res; + }, + + reduceExportFromSpecifier(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceExportFromSpecifier(node); + cache.set(node, res); + return res; + }, + + reduceExportLocalSpecifier(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceExportLocalSpecifier(node, arg); + cache.set(node, res); + return res; + }, + + reduceExportLocals(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceExportLocals(node, arg); + cache.set(node, res); + return res; + }, + + reduceExpressionStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceExpressionStatement(node, arg); + cache.set(node, res); + return res; + }, + + reduceForAwaitStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceForAwaitStatement(node, arg); + cache.set(node, res); + return res; + }, + + reduceForInStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceForInStatement(node, arg); + cache.set(node, res); + return res; + }, + + reduceForOfStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceForOfStatement(node, arg); + cache.set(node, res); + return res; + }, + + reduceForStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceForStatement(node, arg); + cache.set(node, res); + return res; + }, + + reduceFormalParameters(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceFormalParameters(node, arg); + cache.set(node, res); + return res; + }, + + reduceFunctionBody(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceFunctionBody(node, arg); + cache.set(node, res); + return res; + }, + + reduceFunctionDeclaration(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceFunctionDeclaration(node, arg); + cache.set(node, res); + return res; + }, + + reduceFunctionExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceFunctionExpression(node, arg); + cache.set(node, res); + return res; + }, + + reduceGetter(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceGetter(node, arg); + cache.set(node, res); + return res; + }, + + reduceIdentifierExpression(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceIdentifierExpression(node); + cache.set(node, res); + return res; + }, + + reduceIfStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceIfStatement(node, arg); + cache.set(node, res); + return res; + }, + + reduceImport(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceImport(node, arg); + cache.set(node, res); + return res; + }, + + reduceImportNamespace(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceImportNamespace(node, arg); + cache.set(node, res); + return res; + }, + + reduceImportSpecifier(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceImportSpecifier(node, arg); + cache.set(node, res); + return res; + }, + + reduceLabeledStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceLabeledStatement(node, arg); + cache.set(node, res); + return res; + }, + + reduceLiteralBooleanExpression(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceLiteralBooleanExpression(node); + cache.set(node, res); + return res; + }, + + reduceLiteralInfinityExpression(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceLiteralInfinityExpression(node); + cache.set(node, res); + return res; + }, + + reduceLiteralNullExpression(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceLiteralNullExpression(node); + cache.set(node, res); + return res; + }, + + reduceLiteralNumericExpression(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceLiteralNumericExpression(node); + cache.set(node, res); + return res; + }, + + reduceLiteralRegExpExpression(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceLiteralRegExpExpression(node); + cache.set(node, res); + return res; + }, + + reduceLiteralStringExpression(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceLiteralStringExpression(node); + cache.set(node, res); + return res; + }, + + reduceMethod(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceMethod(node, arg); + cache.set(node, res); + return res; + }, + + reduceModule(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceModule(node, arg); + cache.set(node, res); + return res; + }, + + reduceNewExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceNewExpression(node, arg); + cache.set(node, res); + return res; + }, + + reduceNewTargetExpression(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceNewTargetExpression(node); + cache.set(node, res); + return res; + }, + + reduceObjectAssignmentTarget(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceObjectAssignmentTarget(node, arg); + cache.set(node, res); + return res; + }, + + reduceObjectBinding(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceObjectBinding(node, arg); + cache.set(node, res); + return res; + }, + + reduceObjectExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceObjectExpression(node, arg); + cache.set(node, res); + return res; + }, + + reduceReturnStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceReturnStatement(node, arg); + cache.set(node, res); + return res; + }, + + reduceScript(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceScript(node, arg); + cache.set(node, res); + return res; + }, + + reduceSetter(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceSetter(node, arg); + cache.set(node, res); + return res; + }, + + reduceShorthandProperty(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceShorthandProperty(node, arg); + cache.set(node, res); + return res; + }, + + reduceSpreadElement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceSpreadElement(node, arg); + cache.set(node, res); + return res; + }, + + reduceSpreadProperty(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceSpreadProperty(node, arg); + cache.set(node, res); + return res; + }, + + reduceStaticMemberAssignmentTarget(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceStaticMemberAssignmentTarget(node, arg); + cache.set(node, res); + return res; + }, + + reduceStaticMemberExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceStaticMemberExpression(node, arg); + cache.set(node, res); + return res; + }, + + reduceStaticPropertyName(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceStaticPropertyName(node); + cache.set(node, res); + return res; + }, + + reduceSuper(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceSuper(node); + cache.set(node, res); + return res; + }, + + reduceSwitchCase(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceSwitchCase(node, arg); + cache.set(node, res); + return res; + }, + + reduceSwitchDefault(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceSwitchDefault(node, arg); + cache.set(node, res); + return res; + }, + + reduceSwitchStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceSwitchStatement(node, arg); + cache.set(node, res); + return res; + }, + + reduceSwitchStatementWithDefault(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceSwitchStatementWithDefault(node, arg); + cache.set(node, res); + return res; + }, + + reduceTemplateElement(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceTemplateElement(node); + cache.set(node, res); + return res; + }, + + reduceTemplateExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceTemplateExpression(node, arg); + cache.set(node, res); + return res; + }, + + reduceThisExpression(node) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceThisExpression(node); + cache.set(node, res); + return res; + }, + + reduceThrowStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceThrowStatement(node, arg); + cache.set(node, res); + return res; + }, + + reduceTryCatchStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceTryCatchStatement(node, arg); + cache.set(node, res); + return res; + }, + + reduceTryFinallyStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceTryFinallyStatement(node, arg); + cache.set(node, res); + return res; + }, + + reduceUnaryExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceUnaryExpression(node, arg); + cache.set(node, res); + return res; + }, + + reduceUpdateExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceUpdateExpression(node, arg); + cache.set(node, res); + return res; + }, + + reduceVariableDeclaration(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceVariableDeclaration(node, arg); + cache.set(node, res); + return res; + }, + + reduceVariableDeclarationStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceVariableDeclarationStatement(node, arg); + cache.set(node, res); + return res; + }, + + reduceVariableDeclarator(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceVariableDeclarator(node, arg); + cache.set(node, res); + return res; + }, + + reduceWhileStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceWhileStatement(node, arg); + cache.set(node, res); + return res; + }, + + reduceWithStatement(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceWithStatement(node, arg); + cache.set(node, res); + return res; + }, + + reduceYieldExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceYieldExpression(node, arg); + cache.set(node, res); + return res; + }, + + reduceYieldGeneratorExpression(node, arg) { + if (cache.has(node)) { + return cache.get(node); + } + const res = reducer.reduceYieldGeneratorExpression(node, arg); + cache.set(node, res); + return res; + }, + }; +} diff --git a/docs/dist/shift-reducer/monoidal-reducer.js b/docs/dist/shift-reducer/monoidal-reducer.js new file mode 100644 index 00000000..304dcd63 --- /dev/null +++ b/docs/dist/shift-reducer/monoidal-reducer.js @@ -0,0 +1,430 @@ +// Generated by generate-monoidal-reducer.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Shift from '../../_snowpack/pkg/shift-ast.js'; + +export default class MonoidalReducer { + constructor(monoid) { + let identity = monoid.empty(); + this.identity = identity; + let concat; + if (monoid.prototype && typeof monoid.prototype.concat === 'function') { + concat = Function.prototype.call.bind(monoid.prototype.concat); + } else if (typeof monoid.concat === 'function') { + concat = monoid.concat; + } else { + throw new TypeError('Monoid must provide a `concat` method'); + } + this.append = (...args) => args.reduce(concat, identity); + } + + reduceArrayAssignmentTarget(node, { elements, rest }) { + return this.append(...elements.filter(n => n != null), rest == null ? this.identity : rest); + } + + reduceArrayBinding(node, { elements, rest }) { + return this.append(...elements.filter(n => n != null), rest == null ? this.identity : rest); + } + + reduceArrayExpression(node, { elements }) { + return this.append(...elements.filter(n => n != null)); + } + + reduceArrowExpression(node, { params, body }) { + return this.append(params, body); + } + + reduceAssignmentExpression(node, { binding, expression }) { + return this.append(binding, expression); + } + + reduceAssignmentTargetIdentifier(node) { + return this.identity; + } + + reduceAssignmentTargetPropertyIdentifier(node, { binding, init }) { + return this.append(binding, init == null ? this.identity : init); + } + + reduceAssignmentTargetPropertyProperty(node, { name, binding }) { + return this.append(name, binding); + } + + reduceAssignmentTargetWithDefault(node, { binding, init }) { + return this.append(binding, init); + } + + reduceAwaitExpression(node, { expression }) { + return expression; + } + + reduceBinaryExpression(node, { left, right }) { + return this.append(left, right); + } + + reduceBindingIdentifier(node) { + return this.identity; + } + + reduceBindingPropertyIdentifier(node, { binding, init }) { + return this.append(binding, init == null ? this.identity : init); + } + + reduceBindingPropertyProperty(node, { name, binding }) { + return this.append(name, binding); + } + + reduceBindingWithDefault(node, { binding, init }) { + return this.append(binding, init); + } + + reduceBlock(node, { statements }) { + return this.append(...statements); + } + + reduceBlockStatement(node, { block }) { + return block; + } + + reduceBreakStatement(node) { + return this.identity; + } + + reduceCallExpression(node, { callee, arguments: _arguments }) { + return this.append(callee, ..._arguments); + } + + reduceCatchClause(node, { binding, body }) { + return this.append(binding, body); + } + + reduceClassDeclaration(node, { name, super: _super, elements }) { + return this.append(name, _super == null ? this.identity : _super, ...elements); + } + + reduceClassElement(node, { method }) { + return method; + } + + reduceClassExpression(node, { name, super: _super, elements }) { + return this.append(name == null ? this.identity : name, _super == null ? this.identity : _super, ...elements); + } + + reduceCompoundAssignmentExpression(node, { binding, expression }) { + return this.append(binding, expression); + } + + reduceComputedMemberAssignmentTarget(node, { object, expression }) { + return this.append(object, expression); + } + + reduceComputedMemberExpression(node, { object, expression }) { + return this.append(object, expression); + } + + reduceComputedPropertyName(node, { expression }) { + return expression; + } + + reduceConditionalExpression(node, { test, consequent, alternate }) { + return this.append(test, consequent, alternate); + } + + reduceContinueStatement(node) { + return this.identity; + } + + reduceDataProperty(node, { name, expression }) { + return this.append(name, expression); + } + + reduceDebuggerStatement(node) { + return this.identity; + } + + reduceDirective(node) { + return this.identity; + } + + reduceDoWhileStatement(node, { body, test }) { + return this.append(body, test); + } + + reduceEmptyStatement(node) { + return this.identity; + } + + reduceExport(node, { declaration }) { + return declaration; + } + + reduceExportAllFrom(node) { + return this.identity; + } + + reduceExportDefault(node, { body }) { + return body; + } + + reduceExportFrom(node, { namedExports }) { + return this.append(...namedExports); + } + + reduceExportFromSpecifier(node) { + return this.identity; + } + + reduceExportLocalSpecifier(node, { name }) { + return name; + } + + reduceExportLocals(node, { namedExports }) { + return this.append(...namedExports); + } + + reduceExpressionStatement(node, { expression }) { + return expression; + } + + reduceForAwaitStatement(node, { left, right, body }) { + return this.append(left, right, body); + } + + reduceForInStatement(node, { left, right, body }) { + return this.append(left, right, body); + } + + reduceForOfStatement(node, { left, right, body }) { + return this.append(left, right, body); + } + + reduceForStatement(node, { init, test, update, body }) { + return this.append(init == null ? this.identity : init, test == null ? this.identity : test, update == null ? this.identity : update, body); + } + + reduceFormalParameters(node, { items, rest }) { + return this.append(...items, rest == null ? this.identity : rest); + } + + reduceFunctionBody(node, { directives, statements }) { + return this.append(...directives, ...statements); + } + + reduceFunctionDeclaration(node, { name, params, body }) { + return this.append(name, params, body); + } + + reduceFunctionExpression(node, { name, params, body }) { + return this.append(name == null ? this.identity : name, params, body); + } + + reduceGetter(node, { name, body }) { + return this.append(name, body); + } + + reduceIdentifierExpression(node) { + return this.identity; + } + + reduceIfStatement(node, { test, consequent, alternate }) { + return this.append(test, consequent, alternate == null ? this.identity : alternate); + } + + reduceImport(node, { defaultBinding, namedImports }) { + return this.append(defaultBinding == null ? this.identity : defaultBinding, ...namedImports); + } + + reduceImportNamespace(node, { defaultBinding, namespaceBinding }) { + return this.append(defaultBinding == null ? this.identity : defaultBinding, namespaceBinding); + } + + reduceImportSpecifier(node, { binding }) { + return binding; + } + + reduceLabeledStatement(node, { body }) { + return body; + } + + reduceLiteralBooleanExpression(node) { + return this.identity; + } + + reduceLiteralInfinityExpression(node) { + return this.identity; + } + + reduceLiteralNullExpression(node) { + return this.identity; + } + + reduceLiteralNumericExpression(node) { + return this.identity; + } + + reduceLiteralRegExpExpression(node) { + return this.identity; + } + + reduceLiteralStringExpression(node) { + return this.identity; + } + + reduceMethod(node, { name, params, body }) { + return this.append(name, params, body); + } + + reduceModule(node, { directives, items }) { + return this.append(...directives, ...items); + } + + reduceNewExpression(node, { callee, arguments: _arguments }) { + return this.append(callee, ..._arguments); + } + + reduceNewTargetExpression(node) { + return this.identity; + } + + reduceObjectAssignmentTarget(node, { properties, rest }) { + return this.append(...properties, rest == null ? this.identity : rest); + } + + reduceObjectBinding(node, { properties, rest }) { + return this.append(...properties, rest == null ? this.identity : rest); + } + + reduceObjectExpression(node, { properties }) { + return this.append(...properties); + } + + reduceReturnStatement(node, { expression }) { + return expression == null ? this.identity : expression; + } + + reduceScript(node, { directives, statements }) { + return this.append(...directives, ...statements); + } + + reduceSetter(node, { name, param, body }) { + return this.append(name, param, body); + } + + reduceShorthandProperty(node, { name }) { + return name; + } + + reduceSpreadElement(node, { expression }) { + return expression; + } + + reduceSpreadProperty(node, { expression }) { + return expression; + } + + reduceStaticMemberAssignmentTarget(node, { object }) { + return object; + } + + reduceStaticMemberExpression(node, { object }) { + return object; + } + + reduceStaticPropertyName(node) { + return this.identity; + } + + reduceSuper(node) { + return this.identity; + } + + reduceSwitchCase(node, { test, consequent }) { + return this.append(test, ...consequent); + } + + reduceSwitchDefault(node, { consequent }) { + return this.append(...consequent); + } + + reduceSwitchStatement(node, { discriminant, cases }) { + return this.append(discriminant, ...cases); + } + + reduceSwitchStatementWithDefault(node, { discriminant, preDefaultCases, defaultCase, postDefaultCases }) { + return this.append(discriminant, ...preDefaultCases, defaultCase, ...postDefaultCases); + } + + reduceTemplateElement(node) { + return this.identity; + } + + reduceTemplateExpression(node, { tag, elements }) { + return this.append(tag == null ? this.identity : tag, ...elements); + } + + reduceThisExpression(node) { + return this.identity; + } + + reduceThrowStatement(node, { expression }) { + return expression; + } + + reduceTryCatchStatement(node, { body, catchClause }) { + return this.append(body, catchClause); + } + + reduceTryFinallyStatement(node, { body, catchClause, finalizer }) { + return this.append(body, catchClause == null ? this.identity : catchClause, finalizer); + } + + reduceUnaryExpression(node, { operand }) { + return operand; + } + + reduceUpdateExpression(node, { operand }) { + return operand; + } + + reduceVariableDeclaration(node, { declarators }) { + return this.append(...declarators); + } + + reduceVariableDeclarationStatement(node, { declaration }) { + return declaration; + } + + reduceVariableDeclarator(node, { binding, init }) { + return this.append(binding, init == null ? this.identity : init); + } + + reduceWhileStatement(node, { test, body }) { + return this.append(test, body); + } + + reduceWithStatement(node, { object, body }) { + return this.append(object, body); + } + + reduceYieldExpression(node, { expression }) { + return expression == null ? this.identity : expression; + } + + reduceYieldGeneratorExpression(node, { expression }) { + return expression; + } +} diff --git a/docs/dist/shift-reducer/reducers.js b/docs/dist/shift-reducer/reducers.js new file mode 100644 index 00000000..ed7a43cb --- /dev/null +++ b/docs/dist/shift-reducer/reducers.js @@ -0,0 +1,91 @@ +/* + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +import MonoidalReducer from './monoidal-reducer.js'; +import ThunkedMonoidalReducer from './thunked-monoidal-reducer.js'; + +const PlusMonoid = { + empty: () => 0, + concat: (a, b) => a + b, +}; + +const ConcatMonoid = { + empty: () => [], + concat: (a, b) => a.concat(b), +}; + +const AndMonoid = { + empty: () => true, + concat: (a, b) => a && b, + concatThunk: (a, b) => a && b(), +}; + +const OrMonoid = { + empty: () => false, + concat: (a, b) => a || b, + concatThunk: (a, b) => a || b(), +}; + + +export class PlusReducer extends MonoidalReducer { + constructor() { + super(PlusMonoid); + } +} + +export class ThunkedPlusReducer extends ThunkedMonoidalReducer { + constructor() { + super(PlusMonoid); + } +} + +export class ConcatReducer extends MonoidalReducer { + constructor() { + super(ConcatMonoid); + } +} + +export class ThunkedConcatReducer extends ThunkedMonoidalReducer { + constructor() { + super(ConcatMonoid); + } +} + +export class AndReducer extends MonoidalReducer { + constructor() { + super(AndMonoid); + } +} + +export class ThunkedAndReducer extends ThunkedMonoidalReducer { + constructor() { + super(AndMonoid); + } +} + +export class OrReducer extends MonoidalReducer { + constructor() { + super(OrMonoid); + } +} + +export class ThunkedOrReducer extends ThunkedMonoidalReducer { + constructor() { + super(OrMonoid); + } +} diff --git a/docs/dist/shift-reducer/thunked-director.js b/docs/dist/shift-reducer/thunked-director.js new file mode 100644 index 00000000..01fd3d3f --- /dev/null +++ b/docs/dist/shift-reducer/thunked-director.js @@ -0,0 +1,418 @@ +// Generated by generate-director.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const director = { + ArrayAssignmentTarget(reducer, node) { + return reducer.reduceArrayAssignmentTarget(node, { elements: node.elements.map(v => v && (() => this[v.type](reducer, v))), rest: node.rest && (() => this[node.rest.type](reducer, node.rest)) }); + }, + + ArrayBinding(reducer, node) { + return reducer.reduceArrayBinding(node, { elements: node.elements.map(v => v && (() => this[v.type](reducer, v))), rest: node.rest && (() => this[node.rest.type](reducer, node.rest)) }); + }, + + ArrayExpression(reducer, node) { + return reducer.reduceArrayExpression(node, { elements: node.elements.map(v => v && (() => this[v.type](reducer, v))) }); + }, + + ArrowExpression(reducer, node) { + return reducer.reduceArrowExpression(node, { params: (() => this.FormalParameters(reducer, node.params)), body: (() => this[node.body.type](reducer, node.body)) }); + }, + + AssignmentExpression(reducer, node) { + return reducer.reduceAssignmentExpression(node, { binding: (() => this[node.binding.type](reducer, node.binding)), expression: (() => this[node.expression.type](reducer, node.expression)) }); + }, + + AssignmentTargetIdentifier(reducer, node) { + return reducer.reduceAssignmentTargetIdentifier(node); + }, + + AssignmentTargetPropertyIdentifier(reducer, node) { + return reducer.reduceAssignmentTargetPropertyIdentifier(node, { binding: (() => this.AssignmentTargetIdentifier(reducer, node.binding)), init: node.init && (() => this[node.init.type](reducer, node.init)) }); + }, + + AssignmentTargetPropertyProperty(reducer, node) { + return reducer.reduceAssignmentTargetPropertyProperty(node, { name: (() => this[node.name.type](reducer, node.name)), binding: (() => this[node.binding.type](reducer, node.binding)) }); + }, + + AssignmentTargetWithDefault(reducer, node) { + return reducer.reduceAssignmentTargetWithDefault(node, { binding: (() => this[node.binding.type](reducer, node.binding)), init: (() => this[node.init.type](reducer, node.init)) }); + }, + + AwaitExpression(reducer, node) { + return reducer.reduceAwaitExpression(node, { expression: (() => this[node.expression.type](reducer, node.expression)) }); + }, + + BinaryExpression(reducer, node) { + return reducer.reduceBinaryExpression(node, { left: (() => this[node.left.type](reducer, node.left)), right: (() => this[node.right.type](reducer, node.right)) }); + }, + + BindingIdentifier(reducer, node) { + return reducer.reduceBindingIdentifier(node); + }, + + BindingPropertyIdentifier(reducer, node) { + return reducer.reduceBindingPropertyIdentifier(node, { binding: (() => this.BindingIdentifier(reducer, node.binding)), init: node.init && (() => this[node.init.type](reducer, node.init)) }); + }, + + BindingPropertyProperty(reducer, node) { + return reducer.reduceBindingPropertyProperty(node, { name: (() => this[node.name.type](reducer, node.name)), binding: (() => this[node.binding.type](reducer, node.binding)) }); + }, + + BindingWithDefault(reducer, node) { + return reducer.reduceBindingWithDefault(node, { binding: (() => this[node.binding.type](reducer, node.binding)), init: (() => this[node.init.type](reducer, node.init)) }); + }, + + Block(reducer, node) { + return reducer.reduceBlock(node, { statements: node.statements.map(v => (() => this[v.type](reducer, v))) }); + }, + + BlockStatement(reducer, node) { + return reducer.reduceBlockStatement(node, { block: (() => this.Block(reducer, node.block)) }); + }, + + BreakStatement(reducer, node) { + return reducer.reduceBreakStatement(node); + }, + + CallExpression(reducer, node) { + return reducer.reduceCallExpression(node, { callee: (() => this[node.callee.type](reducer, node.callee)), arguments: node.arguments.map(v => (() => this[v.type](reducer, v))) }); + }, + + CatchClause(reducer, node) { + return reducer.reduceCatchClause(node, { binding: (() => this[node.binding.type](reducer, node.binding)), body: (() => this.Block(reducer, node.body)) }); + }, + + ClassDeclaration(reducer, node) { + return reducer.reduceClassDeclaration(node, { name: (() => this.BindingIdentifier(reducer, node.name)), super: node.super && (() => this[node.super.type](reducer, node.super)), elements: node.elements.map(v => (() => this.ClassElement(reducer, v))) }); + }, + + ClassElement(reducer, node) { + return reducer.reduceClassElement(node, { method: (() => this[node.method.type](reducer, node.method)) }); + }, + + ClassExpression(reducer, node) { + return reducer.reduceClassExpression(node, { name: node.name && (() => this.BindingIdentifier(reducer, node.name)), super: node.super && (() => this[node.super.type](reducer, node.super)), elements: node.elements.map(v => (() => this.ClassElement(reducer, v))) }); + }, + + CompoundAssignmentExpression(reducer, node) { + return reducer.reduceCompoundAssignmentExpression(node, { binding: (() => this[node.binding.type](reducer, node.binding)), expression: (() => this[node.expression.type](reducer, node.expression)) }); + }, + + ComputedMemberAssignmentTarget(reducer, node) { + return reducer.reduceComputedMemberAssignmentTarget(node, { object: (() => this[node.object.type](reducer, node.object)), expression: (() => this[node.expression.type](reducer, node.expression)) }); + }, + + ComputedMemberExpression(reducer, node) { + return reducer.reduceComputedMemberExpression(node, { object: (() => this[node.object.type](reducer, node.object)), expression: (() => this[node.expression.type](reducer, node.expression)) }); + }, + + ComputedPropertyName(reducer, node) { + return reducer.reduceComputedPropertyName(node, { expression: (() => this[node.expression.type](reducer, node.expression)) }); + }, + + ConditionalExpression(reducer, node) { + return reducer.reduceConditionalExpression(node, { test: (() => this[node.test.type](reducer, node.test)), consequent: (() => this[node.consequent.type](reducer, node.consequent)), alternate: (() => this[node.alternate.type](reducer, node.alternate)) }); + }, + + ContinueStatement(reducer, node) { + return reducer.reduceContinueStatement(node); + }, + + DataProperty(reducer, node) { + return reducer.reduceDataProperty(node, { name: (() => this[node.name.type](reducer, node.name)), expression: (() => this[node.expression.type](reducer, node.expression)) }); + }, + + DebuggerStatement(reducer, node) { + return reducer.reduceDebuggerStatement(node); + }, + + Directive(reducer, node) { + return reducer.reduceDirective(node); + }, + + DoWhileStatement(reducer, node) { + return reducer.reduceDoWhileStatement(node, { body: (() => this[node.body.type](reducer, node.body)), test: (() => this[node.test.type](reducer, node.test)) }); + }, + + EmptyStatement(reducer, node) { + return reducer.reduceEmptyStatement(node); + }, + + Export(reducer, node) { + return reducer.reduceExport(node, { declaration: (() => this[node.declaration.type](reducer, node.declaration)) }); + }, + + ExportAllFrom(reducer, node) { + return reducer.reduceExportAllFrom(node); + }, + + ExportDefault(reducer, node) { + return reducer.reduceExportDefault(node, { body: (() => this[node.body.type](reducer, node.body)) }); + }, + + ExportFrom(reducer, node) { + return reducer.reduceExportFrom(node, { namedExports: node.namedExports.map(v => (() => this.ExportFromSpecifier(reducer, v))) }); + }, + + ExportFromSpecifier(reducer, node) { + return reducer.reduceExportFromSpecifier(node); + }, + + ExportLocalSpecifier(reducer, node) { + return reducer.reduceExportLocalSpecifier(node, { name: (() => this.IdentifierExpression(reducer, node.name)) }); + }, + + ExportLocals(reducer, node) { + return reducer.reduceExportLocals(node, { namedExports: node.namedExports.map(v => (() => this.ExportLocalSpecifier(reducer, v))) }); + }, + + ExpressionStatement(reducer, node) { + return reducer.reduceExpressionStatement(node, { expression: (() => this[node.expression.type](reducer, node.expression)) }); + }, + + ForAwaitStatement(reducer, node) { + return reducer.reduceForAwaitStatement(node, { left: (() => this[node.left.type](reducer, node.left)), right: (() => this[node.right.type](reducer, node.right)), body: (() => this[node.body.type](reducer, node.body)) }); + }, + + ForInStatement(reducer, node) { + return reducer.reduceForInStatement(node, { left: (() => this[node.left.type](reducer, node.left)), right: (() => this[node.right.type](reducer, node.right)), body: (() => this[node.body.type](reducer, node.body)) }); + }, + + ForOfStatement(reducer, node) { + return reducer.reduceForOfStatement(node, { left: (() => this[node.left.type](reducer, node.left)), right: (() => this[node.right.type](reducer, node.right)), body: (() => this[node.body.type](reducer, node.body)) }); + }, + + ForStatement(reducer, node) { + return reducer.reduceForStatement(node, { init: node.init && (() => this[node.init.type](reducer, node.init)), test: node.test && (() => this[node.test.type](reducer, node.test)), update: node.update && (() => this[node.update.type](reducer, node.update)), body: (() => this[node.body.type](reducer, node.body)) }); + }, + + FormalParameters(reducer, node) { + return reducer.reduceFormalParameters(node, { items: node.items.map(v => (() => this[v.type](reducer, v))), rest: node.rest && (() => this[node.rest.type](reducer, node.rest)) }); + }, + + FunctionBody(reducer, node) { + return reducer.reduceFunctionBody(node, { directives: node.directives.map(v => (() => this.Directive(reducer, v))), statements: node.statements.map(v => (() => this[v.type](reducer, v))) }); + }, + + FunctionDeclaration(reducer, node) { + return reducer.reduceFunctionDeclaration(node, { name: (() => this.BindingIdentifier(reducer, node.name)), params: (() => this.FormalParameters(reducer, node.params)), body: (() => this.FunctionBody(reducer, node.body)) }); + }, + + FunctionExpression(reducer, node) { + return reducer.reduceFunctionExpression(node, { name: node.name && (() => this.BindingIdentifier(reducer, node.name)), params: (() => this.FormalParameters(reducer, node.params)), body: (() => this.FunctionBody(reducer, node.body)) }); + }, + + Getter(reducer, node) { + return reducer.reduceGetter(node, { name: (() => this[node.name.type](reducer, node.name)), body: (() => this.FunctionBody(reducer, node.body)) }); + }, + + IdentifierExpression(reducer, node) { + return reducer.reduceIdentifierExpression(node); + }, + + IfStatement(reducer, node) { + return reducer.reduceIfStatement(node, { test: (() => this[node.test.type](reducer, node.test)), consequent: (() => this[node.consequent.type](reducer, node.consequent)), alternate: node.alternate && (() => this[node.alternate.type](reducer, node.alternate)) }); + }, + + Import(reducer, node) { + return reducer.reduceImport(node, { defaultBinding: node.defaultBinding && (() => this.BindingIdentifier(reducer, node.defaultBinding)), namedImports: node.namedImports.map(v => (() => this.ImportSpecifier(reducer, v))) }); + }, + + ImportNamespace(reducer, node) { + return reducer.reduceImportNamespace(node, { defaultBinding: node.defaultBinding && (() => this.BindingIdentifier(reducer, node.defaultBinding)), namespaceBinding: (() => this.BindingIdentifier(reducer, node.namespaceBinding)) }); + }, + + ImportSpecifier(reducer, node) { + return reducer.reduceImportSpecifier(node, { binding: (() => this.BindingIdentifier(reducer, node.binding)) }); + }, + + LabeledStatement(reducer, node) { + return reducer.reduceLabeledStatement(node, { body: (() => this[node.body.type](reducer, node.body)) }); + }, + + LiteralBooleanExpression(reducer, node) { + return reducer.reduceLiteralBooleanExpression(node); + }, + + LiteralInfinityExpression(reducer, node) { + return reducer.reduceLiteralInfinityExpression(node); + }, + + LiteralNullExpression(reducer, node) { + return reducer.reduceLiteralNullExpression(node); + }, + + LiteralNumericExpression(reducer, node) { + return reducer.reduceLiteralNumericExpression(node); + }, + + LiteralRegExpExpression(reducer, node) { + return reducer.reduceLiteralRegExpExpression(node); + }, + + LiteralStringExpression(reducer, node) { + return reducer.reduceLiteralStringExpression(node); + }, + + Method(reducer, node) { + return reducer.reduceMethod(node, { name: (() => this[node.name.type](reducer, node.name)), params: (() => this.FormalParameters(reducer, node.params)), body: (() => this.FunctionBody(reducer, node.body)) }); + }, + + Module(reducer, node) { + return reducer.reduceModule(node, { directives: node.directives.map(v => (() => this.Directive(reducer, v))), items: node.items.map(v => (() => this[v.type](reducer, v))) }); + }, + + NewExpression(reducer, node) { + return reducer.reduceNewExpression(node, { callee: (() => this[node.callee.type](reducer, node.callee)), arguments: node.arguments.map(v => (() => this[v.type](reducer, v))) }); + }, + + NewTargetExpression(reducer, node) { + return reducer.reduceNewTargetExpression(node); + }, + + ObjectAssignmentTarget(reducer, node) { + return reducer.reduceObjectAssignmentTarget(node, { properties: node.properties.map(v => (() => this[v.type](reducer, v))), rest: node.rest && (() => this[node.rest.type](reducer, node.rest)) }); + }, + + ObjectBinding(reducer, node) { + return reducer.reduceObjectBinding(node, { properties: node.properties.map(v => (() => this[v.type](reducer, v))), rest: node.rest && (() => this[node.rest.type](reducer, node.rest)) }); + }, + + ObjectExpression(reducer, node) { + return reducer.reduceObjectExpression(node, { properties: node.properties.map(v => (() => this[v.type](reducer, v))) }); + }, + + ReturnStatement(reducer, node) { + return reducer.reduceReturnStatement(node, { expression: node.expression && (() => this[node.expression.type](reducer, node.expression)) }); + }, + + Script(reducer, node) { + return reducer.reduceScript(node, { directives: node.directives.map(v => (() => this.Directive(reducer, v))), statements: node.statements.map(v => (() => this[v.type](reducer, v))) }); + }, + + Setter(reducer, node) { + return reducer.reduceSetter(node, { name: (() => this[node.name.type](reducer, node.name)), param: (() => this[node.param.type](reducer, node.param)), body: (() => this.FunctionBody(reducer, node.body)) }); + }, + + ShorthandProperty(reducer, node) { + return reducer.reduceShorthandProperty(node, { name: (() => this.IdentifierExpression(reducer, node.name)) }); + }, + + SpreadElement(reducer, node) { + return reducer.reduceSpreadElement(node, { expression: (() => this[node.expression.type](reducer, node.expression)) }); + }, + + SpreadProperty(reducer, node) { + return reducer.reduceSpreadProperty(node, { expression: (() => this[node.expression.type](reducer, node.expression)) }); + }, + + StaticMemberAssignmentTarget(reducer, node) { + return reducer.reduceStaticMemberAssignmentTarget(node, { object: (() => this[node.object.type](reducer, node.object)) }); + }, + + StaticMemberExpression(reducer, node) { + return reducer.reduceStaticMemberExpression(node, { object: (() => this[node.object.type](reducer, node.object)) }); + }, + + StaticPropertyName(reducer, node) { + return reducer.reduceStaticPropertyName(node); + }, + + Super(reducer, node) { + return reducer.reduceSuper(node); + }, + + SwitchCase(reducer, node) { + return reducer.reduceSwitchCase(node, { test: (() => this[node.test.type](reducer, node.test)), consequent: node.consequent.map(v => (() => this[v.type](reducer, v))) }); + }, + + SwitchDefault(reducer, node) { + return reducer.reduceSwitchDefault(node, { consequent: node.consequent.map(v => (() => this[v.type](reducer, v))) }); + }, + + SwitchStatement(reducer, node) { + return reducer.reduceSwitchStatement(node, { discriminant: (() => this[node.discriminant.type](reducer, node.discriminant)), cases: node.cases.map(v => (() => this.SwitchCase(reducer, v))) }); + }, + + SwitchStatementWithDefault(reducer, node) { + return reducer.reduceSwitchStatementWithDefault(node, { discriminant: (() => this[node.discriminant.type](reducer, node.discriminant)), preDefaultCases: node.preDefaultCases.map(v => (() => this.SwitchCase(reducer, v))), defaultCase: (() => this.SwitchDefault(reducer, node.defaultCase)), postDefaultCases: node.postDefaultCases.map(v => (() => this.SwitchCase(reducer, v))) }); + }, + + TemplateElement(reducer, node) { + return reducer.reduceTemplateElement(node); + }, + + TemplateExpression(reducer, node) { + return reducer.reduceTemplateExpression(node, { tag: node.tag && (() => this[node.tag.type](reducer, node.tag)), elements: node.elements.map(v => (() => this[v.type](reducer, v))) }); + }, + + ThisExpression(reducer, node) { + return reducer.reduceThisExpression(node); + }, + + ThrowStatement(reducer, node) { + return reducer.reduceThrowStatement(node, { expression: (() => this[node.expression.type](reducer, node.expression)) }); + }, + + TryCatchStatement(reducer, node) { + return reducer.reduceTryCatchStatement(node, { body: (() => this.Block(reducer, node.body)), catchClause: (() => this.CatchClause(reducer, node.catchClause)) }); + }, + + TryFinallyStatement(reducer, node) { + return reducer.reduceTryFinallyStatement(node, { body: (() => this.Block(reducer, node.body)), catchClause: node.catchClause && (() => this.CatchClause(reducer, node.catchClause)), finalizer: (() => this.Block(reducer, node.finalizer)) }); + }, + + UnaryExpression(reducer, node) { + return reducer.reduceUnaryExpression(node, { operand: (() => this[node.operand.type](reducer, node.operand)) }); + }, + + UpdateExpression(reducer, node) { + return reducer.reduceUpdateExpression(node, { operand: (() => this[node.operand.type](reducer, node.operand)) }); + }, + + VariableDeclaration(reducer, node) { + return reducer.reduceVariableDeclaration(node, { declarators: node.declarators.map(v => (() => this.VariableDeclarator(reducer, v))) }); + }, + + VariableDeclarationStatement(reducer, node) { + return reducer.reduceVariableDeclarationStatement(node, { declaration: (() => this.VariableDeclaration(reducer, node.declaration)) }); + }, + + VariableDeclarator(reducer, node) { + return reducer.reduceVariableDeclarator(node, { binding: (() => this[node.binding.type](reducer, node.binding)), init: node.init && (() => this[node.init.type](reducer, node.init)) }); + }, + + WhileStatement(reducer, node) { + return reducer.reduceWhileStatement(node, { test: (() => this[node.test.type](reducer, node.test)), body: (() => this[node.body.type](reducer, node.body)) }); + }, + + WithStatement(reducer, node) { + return reducer.reduceWithStatement(node, { object: (() => this[node.object.type](reducer, node.object)), body: (() => this[node.body.type](reducer, node.body)) }); + }, + + YieldExpression(reducer, node) { + return reducer.reduceYieldExpression(node, { expression: node.expression && (() => this[node.expression.type](reducer, node.expression)) }); + }, + + YieldGeneratorExpression(reducer, node) { + return reducer.reduceYieldGeneratorExpression(node, { expression: (() => this[node.expression.type](reducer, node.expression)) }); + }, +}; + +export function thunkedReduce(reducer, node) { + return director[node.type](reducer, node); +} diff --git a/docs/dist/shift-reducer/thunked-monoidal-reducer.js b/docs/dist/shift-reducer/thunked-monoidal-reducer.js new file mode 100644 index 00000000..721b5c18 --- /dev/null +++ b/docs/dist/shift-reducer/thunked-monoidal-reducer.js @@ -0,0 +1,444 @@ +// Generated by generate-monoidal-reducer.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Shift from '../../_snowpack/pkg/shift-ast.js'; + +export default class MonoidalReducer { + constructor(monoid) { + let identity = monoid.empty(); + this.identity = identity; + + let concatThunk; + if (monoid.prototype && typeof monoid.prototype.concatThunk === 'function') { + concatThunk = Function.prototype.call.bind(monoid.prototype.concatThunk); + } else if (typeof monoid.concatThunk === 'function') { + concatThunk = monoid.concatThunk; + } else { + let concat; + if (monoid.prototype && typeof monoid.prototype.concat === 'function') { + concat = Function.prototype.call.bind(monoid.prototype.concat); + } else if (typeof monoid.concat === 'function') { + concat = monoid.concat; + } else { + throw new TypeError('Monoid must provide a `concatThunk` or `concat` method'); + } + if (typeof monoid.isAbsorbing === 'function') { + let isAbsorbing = monoid.isAbsorbing; + concatThunk = (a, b) => isAbsorbing(a) ? a : concat(a, b()); + } else { + concatThunk = (a, b) => concat(a, b()); + } + } + this.append = (...args) => args.reduce(concatThunk, identity); + } + + reduceArrayAssignmentTarget(node, { elements, rest }) { + return this.append(...elements.filter(n => n != null), rest == null ? () => this.identity : rest); + } + + reduceArrayBinding(node, { elements, rest }) { + return this.append(...elements.filter(n => n != null), rest == null ? () => this.identity : rest); + } + + reduceArrayExpression(node, { elements }) { + return this.append(...elements.filter(n => n != null)); + } + + reduceArrowExpression(node, { params, body }) { + return this.append(params, body); + } + + reduceAssignmentExpression(node, { binding, expression }) { + return this.append(binding, expression); + } + + reduceAssignmentTargetIdentifier(node) { + return this.identity; + } + + reduceAssignmentTargetPropertyIdentifier(node, { binding, init }) { + return this.append(binding, init == null ? () => this.identity : init); + } + + reduceAssignmentTargetPropertyProperty(node, { name, binding }) { + return this.append(name, binding); + } + + reduceAssignmentTargetWithDefault(node, { binding, init }) { + return this.append(binding, init); + } + + reduceAwaitExpression(node, { expression }) { + return expression(); + } + + reduceBinaryExpression(node, { left, right }) { + return this.append(left, right); + } + + reduceBindingIdentifier(node) { + return this.identity; + } + + reduceBindingPropertyIdentifier(node, { binding, init }) { + return this.append(binding, init == null ? () => this.identity : init); + } + + reduceBindingPropertyProperty(node, { name, binding }) { + return this.append(name, binding); + } + + reduceBindingWithDefault(node, { binding, init }) { + return this.append(binding, init); + } + + reduceBlock(node, { statements }) { + return this.append(...statements); + } + + reduceBlockStatement(node, { block }) { + return block(); + } + + reduceBreakStatement(node) { + return this.identity; + } + + reduceCallExpression(node, { callee, arguments: _arguments }) { + return this.append(callee, ..._arguments); + } + + reduceCatchClause(node, { binding, body }) { + return this.append(binding, body); + } + + reduceClassDeclaration(node, { name, super: _super, elements }) { + return this.append(name, _super == null ? () => this.identity : _super, ...elements); + } + + reduceClassElement(node, { method }) { + return method(); + } + + reduceClassExpression(node, { name, super: _super, elements }) { + return this.append(name == null ? () => this.identity : name, _super == null ? () => this.identity : _super, ...elements); + } + + reduceCompoundAssignmentExpression(node, { binding, expression }) { + return this.append(binding, expression); + } + + reduceComputedMemberAssignmentTarget(node, { object, expression }) { + return this.append(object, expression); + } + + reduceComputedMemberExpression(node, { object, expression }) { + return this.append(object, expression); + } + + reduceComputedPropertyName(node, { expression }) { + return expression(); + } + + reduceConditionalExpression(node, { test, consequent, alternate }) { + return this.append(test, consequent, alternate); + } + + reduceContinueStatement(node) { + return this.identity; + } + + reduceDataProperty(node, { name, expression }) { + return this.append(name, expression); + } + + reduceDebuggerStatement(node) { + return this.identity; + } + + reduceDirective(node) { + return this.identity; + } + + reduceDoWhileStatement(node, { body, test }) { + return this.append(body, test); + } + + reduceEmptyStatement(node) { + return this.identity; + } + + reduceExport(node, { declaration }) { + return declaration(); + } + + reduceExportAllFrom(node) { + return this.identity; + } + + reduceExportDefault(node, { body }) { + return body(); + } + + reduceExportFrom(node, { namedExports }) { + return this.append(...namedExports); + } + + reduceExportFromSpecifier(node) { + return this.identity; + } + + reduceExportLocalSpecifier(node, { name }) { + return name(); + } + + reduceExportLocals(node, { namedExports }) { + return this.append(...namedExports); + } + + reduceExpressionStatement(node, { expression }) { + return expression(); + } + + reduceForAwaitStatement(node, { left, right, body }) { + return this.append(left, right, body); + } + + reduceForInStatement(node, { left, right, body }) { + return this.append(left, right, body); + } + + reduceForOfStatement(node, { left, right, body }) { + return this.append(left, right, body); + } + + reduceForStatement(node, { init, test, update, body }) { + return this.append(init == null ? () => this.identity : init, test == null ? () => this.identity : test, update == null ? () => this.identity : update, body); + } + + reduceFormalParameters(node, { items, rest }) { + return this.append(...items, rest == null ? () => this.identity : rest); + } + + reduceFunctionBody(node, { directives, statements }) { + return this.append(...directives, ...statements); + } + + reduceFunctionDeclaration(node, { name, params, body }) { + return this.append(name, params, body); + } + + reduceFunctionExpression(node, { name, params, body }) { + return this.append(name == null ? () => this.identity : name, params, body); + } + + reduceGetter(node, { name, body }) { + return this.append(name, body); + } + + reduceIdentifierExpression(node) { + return this.identity; + } + + reduceIfStatement(node, { test, consequent, alternate }) { + return this.append(test, consequent, alternate == null ? () => this.identity : alternate); + } + + reduceImport(node, { defaultBinding, namedImports }) { + return this.append(defaultBinding == null ? () => this.identity : defaultBinding, ...namedImports); + } + + reduceImportNamespace(node, { defaultBinding, namespaceBinding }) { + return this.append(defaultBinding == null ? () => this.identity : defaultBinding, namespaceBinding); + } + + reduceImportSpecifier(node, { binding }) { + return binding(); + } + + reduceLabeledStatement(node, { body }) { + return body(); + } + + reduceLiteralBooleanExpression(node) { + return this.identity; + } + + reduceLiteralInfinityExpression(node) { + return this.identity; + } + + reduceLiteralNullExpression(node) { + return this.identity; + } + + reduceLiteralNumericExpression(node) { + return this.identity; + } + + reduceLiteralRegExpExpression(node) { + return this.identity; + } + + reduceLiteralStringExpression(node) { + return this.identity; + } + + reduceMethod(node, { name, params, body }) { + return this.append(name, params, body); + } + + reduceModule(node, { directives, items }) { + return this.append(...directives, ...items); + } + + reduceNewExpression(node, { callee, arguments: _arguments }) { + return this.append(callee, ..._arguments); + } + + reduceNewTargetExpression(node) { + return this.identity; + } + + reduceObjectAssignmentTarget(node, { properties, rest }) { + return this.append(...properties, rest == null ? () => this.identity : rest); + } + + reduceObjectBinding(node, { properties, rest }) { + return this.append(...properties, rest == null ? () => this.identity : rest); + } + + reduceObjectExpression(node, { properties }) { + return this.append(...properties); + } + + reduceReturnStatement(node, { expression }) { + return expression == null ? this.identity : expression(); + } + + reduceScript(node, { directives, statements }) { + return this.append(...directives, ...statements); + } + + reduceSetter(node, { name, param, body }) { + return this.append(name, param, body); + } + + reduceShorthandProperty(node, { name }) { + return name(); + } + + reduceSpreadElement(node, { expression }) { + return expression(); + } + + reduceSpreadProperty(node, { expression }) { + return expression(); + } + + reduceStaticMemberAssignmentTarget(node, { object }) { + return object(); + } + + reduceStaticMemberExpression(node, { object }) { + return object(); + } + + reduceStaticPropertyName(node) { + return this.identity; + } + + reduceSuper(node) { + return this.identity; + } + + reduceSwitchCase(node, { test, consequent }) { + return this.append(test, ...consequent); + } + + reduceSwitchDefault(node, { consequent }) { + return this.append(...consequent); + } + + reduceSwitchStatement(node, { discriminant, cases }) { + return this.append(discriminant, ...cases); + } + + reduceSwitchStatementWithDefault(node, { discriminant, preDefaultCases, defaultCase, postDefaultCases }) { + return this.append(discriminant, ...preDefaultCases, defaultCase, ...postDefaultCases); + } + + reduceTemplateElement(node) { + return this.identity; + } + + reduceTemplateExpression(node, { tag, elements }) { + return this.append(tag == null ? () => this.identity : tag, ...elements); + } + + reduceThisExpression(node) { + return this.identity; + } + + reduceThrowStatement(node, { expression }) { + return expression(); + } + + reduceTryCatchStatement(node, { body, catchClause }) { + return this.append(body, catchClause); + } + + reduceTryFinallyStatement(node, { body, catchClause, finalizer }) { + return this.append(body, catchClause == null ? () => this.identity : catchClause, finalizer); + } + + reduceUnaryExpression(node, { operand }) { + return operand(); + } + + reduceUpdateExpression(node, { operand }) { + return operand(); + } + + reduceVariableDeclaration(node, { declarators }) { + return this.append(...declarators); + } + + reduceVariableDeclarationStatement(node, { declaration }) { + return declaration(); + } + + reduceVariableDeclarator(node, { binding, init }) { + return this.append(binding, init == null ? () => this.identity : init); + } + + reduceWhileStatement(node, { test, body }) { + return this.append(test, body); + } + + reduceWithStatement(node, { object, body }) { + return this.append(object, body); + } + + reduceYieldExpression(node, { expression }) { + return expression == null ? this.identity : expression(); + } + + reduceYieldGeneratorExpression(node, { expression }) { + return expression(); + } +} diff --git a/docs/dist/shift-reducer/thunkify-class.js b/docs/dist/shift-reducer/thunkify-class.js new file mode 100644 index 00000000..4d091f21 --- /dev/null +++ b/docs/dist/shift-reducer/thunkify-class.js @@ -0,0 +1,416 @@ +// Generated by generate-thunkify.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default function thunkifyClass(reducerClass) { + return class extends reducerClass { + reduceArrayAssignmentTarget(node, { elements, rest }) { + return super.reduceArrayAssignmentTarget(node, { elements: elements.map(n => n == null ? null : n()), rest: rest == null ? null : rest() }); + } + + reduceArrayBinding(node, { elements, rest }) { + return super.reduceArrayBinding(node, { elements: elements.map(n => n == null ? null : n()), rest: rest == null ? null : rest() }); + } + + reduceArrayExpression(node, { elements }) { + return super.reduceArrayExpression(node, { elements: elements.map(n => n == null ? null : n()) }); + } + + reduceArrowExpression(node, { params, body }) { + return super.reduceArrowExpression(node, { params: params(), body: body() }); + } + + reduceAssignmentExpression(node, { binding, expression }) { + return super.reduceAssignmentExpression(node, { binding: binding(), expression: expression() }); + } + + reduceAssignmentTargetIdentifier(node) { + return super.reduceAssignmentTargetIdentifier(node); + } + + reduceAssignmentTargetPropertyIdentifier(node, { binding, init }) { + return super.reduceAssignmentTargetPropertyIdentifier(node, { binding: binding(), init: init == null ? null : init() }); + } + + reduceAssignmentTargetPropertyProperty(node, { name, binding }) { + return super.reduceAssignmentTargetPropertyProperty(node, { name: name(), binding: binding() }); + } + + reduceAssignmentTargetWithDefault(node, { binding, init }) { + return super.reduceAssignmentTargetWithDefault(node, { binding: binding(), init: init() }); + } + + reduceAwaitExpression(node, { expression }) { + return super.reduceAwaitExpression(node, { expression: expression() }); + } + + reduceBinaryExpression(node, { left, right }) { + return super.reduceBinaryExpression(node, { left: left(), right: right() }); + } + + reduceBindingIdentifier(node) { + return super.reduceBindingIdentifier(node); + } + + reduceBindingPropertyIdentifier(node, { binding, init }) { + return super.reduceBindingPropertyIdentifier(node, { binding: binding(), init: init == null ? null : init() }); + } + + reduceBindingPropertyProperty(node, { name, binding }) { + return super.reduceBindingPropertyProperty(node, { name: name(), binding: binding() }); + } + + reduceBindingWithDefault(node, { binding, init }) { + return super.reduceBindingWithDefault(node, { binding: binding(), init: init() }); + } + + reduceBlock(node, { statements }) { + return super.reduceBlock(node, { statements: statements.map(n => n()) }); + } + + reduceBlockStatement(node, { block }) { + return super.reduceBlockStatement(node, { block: block() }); + } + + reduceBreakStatement(node) { + return super.reduceBreakStatement(node); + } + + reduceCallExpression(node, { callee, arguments: _arguments }) { + return super.reduceCallExpression(node, { callee: callee(), arguments: _arguments.map(n => n()) }); + } + + reduceCatchClause(node, { binding, body }) { + return super.reduceCatchClause(node, { binding: binding(), body: body() }); + } + + reduceClassDeclaration(node, { name, super: _super, elements }) { + return super.reduceClassDeclaration(node, { name: name(), super: _super == null ? null : _super(), elements: elements.map(n => n()) }); + } + + reduceClassElement(node, { method }) { + return super.reduceClassElement(node, { method: method() }); + } + + reduceClassExpression(node, { name, super: _super, elements }) { + return super.reduceClassExpression(node, { name: name == null ? null : name(), super: _super == null ? null : _super(), elements: elements.map(n => n()) }); + } + + reduceCompoundAssignmentExpression(node, { binding, expression }) { + return super.reduceCompoundAssignmentExpression(node, { binding: binding(), expression: expression() }); + } + + reduceComputedMemberAssignmentTarget(node, { object, expression }) { + return super.reduceComputedMemberAssignmentTarget(node, { object: object(), expression: expression() }); + } + + reduceComputedMemberExpression(node, { object, expression }) { + return super.reduceComputedMemberExpression(node, { object: object(), expression: expression() }); + } + + reduceComputedPropertyName(node, { expression }) { + return super.reduceComputedPropertyName(node, { expression: expression() }); + } + + reduceConditionalExpression(node, { test, consequent, alternate }) { + return super.reduceConditionalExpression(node, { test: test(), consequent: consequent(), alternate: alternate() }); + } + + reduceContinueStatement(node) { + return super.reduceContinueStatement(node); + } + + reduceDataProperty(node, { name, expression }) { + return super.reduceDataProperty(node, { name: name(), expression: expression() }); + } + + reduceDebuggerStatement(node) { + return super.reduceDebuggerStatement(node); + } + + reduceDirective(node) { + return super.reduceDirective(node); + } + + reduceDoWhileStatement(node, { body, test }) { + return super.reduceDoWhileStatement(node, { body: body(), test: test() }); + } + + reduceEmptyStatement(node) { + return super.reduceEmptyStatement(node); + } + + reduceExport(node, { declaration }) { + return super.reduceExport(node, { declaration: declaration() }); + } + + reduceExportAllFrom(node) { + return super.reduceExportAllFrom(node); + } + + reduceExportDefault(node, { body }) { + return super.reduceExportDefault(node, { body: body() }); + } + + reduceExportFrom(node, { namedExports }) { + return super.reduceExportFrom(node, { namedExports: namedExports.map(n => n()) }); + } + + reduceExportFromSpecifier(node) { + return super.reduceExportFromSpecifier(node); + } + + reduceExportLocalSpecifier(node, { name }) { + return super.reduceExportLocalSpecifier(node, { name: name() }); + } + + reduceExportLocals(node, { namedExports }) { + return super.reduceExportLocals(node, { namedExports: namedExports.map(n => n()) }); + } + + reduceExpressionStatement(node, { expression }) { + return super.reduceExpressionStatement(node, { expression: expression() }); + } + + reduceForAwaitStatement(node, { left, right, body }) { + return super.reduceForAwaitStatement(node, { left: left(), right: right(), body: body() }); + } + + reduceForInStatement(node, { left, right, body }) { + return super.reduceForInStatement(node, { left: left(), right: right(), body: body() }); + } + + reduceForOfStatement(node, { left, right, body }) { + return super.reduceForOfStatement(node, { left: left(), right: right(), body: body() }); + } + + reduceForStatement(node, { init, test, update, body }) { + return super.reduceForStatement(node, { init: init == null ? null : init(), test: test == null ? null : test(), update: update == null ? null : update(), body: body() }); + } + + reduceFormalParameters(node, { items, rest }) { + return super.reduceFormalParameters(node, { items: items.map(n => n()), rest: rest == null ? null : rest() }); + } + + reduceFunctionBody(node, { directives, statements }) { + return super.reduceFunctionBody(node, { directives: directives.map(n => n()), statements: statements.map(n => n()) }); + } + + reduceFunctionDeclaration(node, { name, params, body }) { + return super.reduceFunctionDeclaration(node, { name: name(), params: params(), body: body() }); + } + + reduceFunctionExpression(node, { name, params, body }) { + return super.reduceFunctionExpression(node, { name: name == null ? null : name(), params: params(), body: body() }); + } + + reduceGetter(node, { name, body }) { + return super.reduceGetter(node, { name: name(), body: body() }); + } + + reduceIdentifierExpression(node) { + return super.reduceIdentifierExpression(node); + } + + reduceIfStatement(node, { test, consequent, alternate }) { + return super.reduceIfStatement(node, { test: test(), consequent: consequent(), alternate: alternate == null ? null : alternate() }); + } + + reduceImport(node, { defaultBinding, namedImports }) { + return super.reduceImport(node, { defaultBinding: defaultBinding == null ? null : defaultBinding(), namedImports: namedImports.map(n => n()) }); + } + + reduceImportNamespace(node, { defaultBinding, namespaceBinding }) { + return super.reduceImportNamespace(node, { defaultBinding: defaultBinding == null ? null : defaultBinding(), namespaceBinding: namespaceBinding() }); + } + + reduceImportSpecifier(node, { binding }) { + return super.reduceImportSpecifier(node, { binding: binding() }); + } + + reduceLabeledStatement(node, { body }) { + return super.reduceLabeledStatement(node, { body: body() }); + } + + reduceLiteralBooleanExpression(node) { + return super.reduceLiteralBooleanExpression(node); + } + + reduceLiteralInfinityExpression(node) { + return super.reduceLiteralInfinityExpression(node); + } + + reduceLiteralNullExpression(node) { + return super.reduceLiteralNullExpression(node); + } + + reduceLiteralNumericExpression(node) { + return super.reduceLiteralNumericExpression(node); + } + + reduceLiteralRegExpExpression(node) { + return super.reduceLiteralRegExpExpression(node); + } + + reduceLiteralStringExpression(node) { + return super.reduceLiteralStringExpression(node); + } + + reduceMethod(node, { name, params, body }) { + return super.reduceMethod(node, { name: name(), params: params(), body: body() }); + } + + reduceModule(node, { directives, items }) { + return super.reduceModule(node, { directives: directives.map(n => n()), items: items.map(n => n()) }); + } + + reduceNewExpression(node, { callee, arguments: _arguments }) { + return super.reduceNewExpression(node, { callee: callee(), arguments: _arguments.map(n => n()) }); + } + + reduceNewTargetExpression(node) { + return super.reduceNewTargetExpression(node); + } + + reduceObjectAssignmentTarget(node, { properties, rest }) { + return super.reduceObjectAssignmentTarget(node, { properties: properties.map(n => n()), rest: rest == null ? null : rest() }); + } + + reduceObjectBinding(node, { properties, rest }) { + return super.reduceObjectBinding(node, { properties: properties.map(n => n()), rest: rest == null ? null : rest() }); + } + + reduceObjectExpression(node, { properties }) { + return super.reduceObjectExpression(node, { properties: properties.map(n => n()) }); + } + + reduceReturnStatement(node, { expression }) { + return super.reduceReturnStatement(node, { expression: expression == null ? null : expression() }); + } + + reduceScript(node, { directives, statements }) { + return super.reduceScript(node, { directives: directives.map(n => n()), statements: statements.map(n => n()) }); + } + + reduceSetter(node, { name, param, body }) { + return super.reduceSetter(node, { name: name(), param: param(), body: body() }); + } + + reduceShorthandProperty(node, { name }) { + return super.reduceShorthandProperty(node, { name: name() }); + } + + reduceSpreadElement(node, { expression }) { + return super.reduceSpreadElement(node, { expression: expression() }); + } + + reduceSpreadProperty(node, { expression }) { + return super.reduceSpreadProperty(node, { expression: expression() }); + } + + reduceStaticMemberAssignmentTarget(node, { object }) { + return super.reduceStaticMemberAssignmentTarget(node, { object: object() }); + } + + reduceStaticMemberExpression(node, { object }) { + return super.reduceStaticMemberExpression(node, { object: object() }); + } + + reduceStaticPropertyName(node) { + return super.reduceStaticPropertyName(node); + } + + reduceSuper(node) { + return super.reduceSuper(node); + } + + reduceSwitchCase(node, { test, consequent }) { + return super.reduceSwitchCase(node, { test: test(), consequent: consequent.map(n => n()) }); + } + + reduceSwitchDefault(node, { consequent }) { + return super.reduceSwitchDefault(node, { consequent: consequent.map(n => n()) }); + } + + reduceSwitchStatement(node, { discriminant, cases }) { + return super.reduceSwitchStatement(node, { discriminant: discriminant(), cases: cases.map(n => n()) }); + } + + reduceSwitchStatementWithDefault(node, { discriminant, preDefaultCases, defaultCase, postDefaultCases }) { + return super.reduceSwitchStatementWithDefault(node, { discriminant: discriminant(), preDefaultCases: preDefaultCases.map(n => n()), defaultCase: defaultCase(), postDefaultCases: postDefaultCases.map(n => n()) }); + } + + reduceTemplateElement(node) { + return super.reduceTemplateElement(node); + } + + reduceTemplateExpression(node, { tag, elements }) { + return super.reduceTemplateExpression(node, { tag: tag == null ? null : tag(), elements: elements.map(n => n()) }); + } + + reduceThisExpression(node) { + return super.reduceThisExpression(node); + } + + reduceThrowStatement(node, { expression }) { + return super.reduceThrowStatement(node, { expression: expression() }); + } + + reduceTryCatchStatement(node, { body, catchClause }) { + return super.reduceTryCatchStatement(node, { body: body(), catchClause: catchClause() }); + } + + reduceTryFinallyStatement(node, { body, catchClause, finalizer }) { + return super.reduceTryFinallyStatement(node, { body: body(), catchClause: catchClause == null ? null : catchClause(), finalizer: finalizer() }); + } + + reduceUnaryExpression(node, { operand }) { + return super.reduceUnaryExpression(node, { operand: operand() }); + } + + reduceUpdateExpression(node, { operand }) { + return super.reduceUpdateExpression(node, { operand: operand() }); + } + + reduceVariableDeclaration(node, { declarators }) { + return super.reduceVariableDeclaration(node, { declarators: declarators.map(n => n()) }); + } + + reduceVariableDeclarationStatement(node, { declaration }) { + return super.reduceVariableDeclarationStatement(node, { declaration: declaration() }); + } + + reduceVariableDeclarator(node, { binding, init }) { + return super.reduceVariableDeclarator(node, { binding: binding(), init: init == null ? null : init() }); + } + + reduceWhileStatement(node, { test, body }) { + return super.reduceWhileStatement(node, { test: test(), body: body() }); + } + + reduceWithStatement(node, { object, body }) { + return super.reduceWithStatement(node, { object: object(), body: body() }); + } + + reduceYieldExpression(node, { expression }) { + return super.reduceYieldExpression(node, { expression: expression == null ? null : expression() }); + } + + reduceYieldGeneratorExpression(node, { expression }) { + return super.reduceYieldGeneratorExpression(node, { expression: expression() }); + } + }; +} diff --git a/docs/dist/shift-reducer/thunkify.js b/docs/dist/shift-reducer/thunkify.js new file mode 100644 index 00000000..80620d64 --- /dev/null +++ b/docs/dist/shift-reducer/thunkify.js @@ -0,0 +1,416 @@ +// Generated by generate-thunkify.js +/** + * Copyright 2018 Shape Security, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default function thunkify(reducer) { + return { + reduceArrayAssignmentTarget(node, { elements, rest }) { + return reducer.reduceArrayAssignmentTarget(node, { elements: elements.map(n => n == null ? null : n()), rest: rest == null ? null : rest() }); + }, + + reduceArrayBinding(node, { elements, rest }) { + return reducer.reduceArrayBinding(node, { elements: elements.map(n => n == null ? null : n()), rest: rest == null ? null : rest() }); + }, + + reduceArrayExpression(node, { elements }) { + return reducer.reduceArrayExpression(node, { elements: elements.map(n => n == null ? null : n()) }); + }, + + reduceArrowExpression(node, { params, body }) { + return reducer.reduceArrowExpression(node, { params: params(), body: body() }); + }, + + reduceAssignmentExpression(node, { binding, expression }) { + return reducer.reduceAssignmentExpression(node, { binding: binding(), expression: expression() }); + }, + + reduceAssignmentTargetIdentifier(node) { + return reducer.reduceAssignmentTargetIdentifier(node); + }, + + reduceAssignmentTargetPropertyIdentifier(node, { binding, init }) { + return reducer.reduceAssignmentTargetPropertyIdentifier(node, { binding: binding(), init: init == null ? null : init() }); + }, + + reduceAssignmentTargetPropertyProperty(node, { name, binding }) { + return reducer.reduceAssignmentTargetPropertyProperty(node, { name: name(), binding: binding() }); + }, + + reduceAssignmentTargetWithDefault(node, { binding, init }) { + return reducer.reduceAssignmentTargetWithDefault(node, { binding: binding(), init: init() }); + }, + + reduceAwaitExpression(node, { expression }) { + return reducer.reduceAwaitExpression(node, { expression: expression() }); + }, + + reduceBinaryExpression(node, { left, right }) { + return reducer.reduceBinaryExpression(node, { left: left(), right: right() }); + }, + + reduceBindingIdentifier(node) { + return reducer.reduceBindingIdentifier(node); + }, + + reduceBindingPropertyIdentifier(node, { binding, init }) { + return reducer.reduceBindingPropertyIdentifier(node, { binding: binding(), init: init == null ? null : init() }); + }, + + reduceBindingPropertyProperty(node, { name, binding }) { + return reducer.reduceBindingPropertyProperty(node, { name: name(), binding: binding() }); + }, + + reduceBindingWithDefault(node, { binding, init }) { + return reducer.reduceBindingWithDefault(node, { binding: binding(), init: init() }); + }, + + reduceBlock(node, { statements }) { + return reducer.reduceBlock(node, { statements: statements.map(n => n()) }); + }, + + reduceBlockStatement(node, { block }) { + return reducer.reduceBlockStatement(node, { block: block() }); + }, + + reduceBreakStatement(node) { + return reducer.reduceBreakStatement(node); + }, + + reduceCallExpression(node, { callee, arguments: _arguments }) { + return reducer.reduceCallExpression(node, { callee: callee(), arguments: _arguments.map(n => n()) }); + }, + + reduceCatchClause(node, { binding, body }) { + return reducer.reduceCatchClause(node, { binding: binding(), body: body() }); + }, + + reduceClassDeclaration(node, { name, super: _super, elements }) { + return reducer.reduceClassDeclaration(node, { name: name(), super: _super == null ? null : _super(), elements: elements.map(n => n()) }); + }, + + reduceClassElement(node, { method }) { + return reducer.reduceClassElement(node, { method: method() }); + }, + + reduceClassExpression(node, { name, super: _super, elements }) { + return reducer.reduceClassExpression(node, { name: name == null ? null : name(), super: _super == null ? null : _super(), elements: elements.map(n => n()) }); + }, + + reduceCompoundAssignmentExpression(node, { binding, expression }) { + return reducer.reduceCompoundAssignmentExpression(node, { binding: binding(), expression: expression() }); + }, + + reduceComputedMemberAssignmentTarget(node, { object, expression }) { + return reducer.reduceComputedMemberAssignmentTarget(node, { object: object(), expression: expression() }); + }, + + reduceComputedMemberExpression(node, { object, expression }) { + return reducer.reduceComputedMemberExpression(node, { object: object(), expression: expression() }); + }, + + reduceComputedPropertyName(node, { expression }) { + return reducer.reduceComputedPropertyName(node, { expression: expression() }); + }, + + reduceConditionalExpression(node, { test, consequent, alternate }) { + return reducer.reduceConditionalExpression(node, { test: test(), consequent: consequent(), alternate: alternate() }); + }, + + reduceContinueStatement(node) { + return reducer.reduceContinueStatement(node); + }, + + reduceDataProperty(node, { name, expression }) { + return reducer.reduceDataProperty(node, { name: name(), expression: expression() }); + }, + + reduceDebuggerStatement(node) { + return reducer.reduceDebuggerStatement(node); + }, + + reduceDirective(node) { + return reducer.reduceDirective(node); + }, + + reduceDoWhileStatement(node, { body, test }) { + return reducer.reduceDoWhileStatement(node, { body: body(), test: test() }); + }, + + reduceEmptyStatement(node) { + return reducer.reduceEmptyStatement(node); + }, + + reduceExport(node, { declaration }) { + return reducer.reduceExport(node, { declaration: declaration() }); + }, + + reduceExportAllFrom(node) { + return reducer.reduceExportAllFrom(node); + }, + + reduceExportDefault(node, { body }) { + return reducer.reduceExportDefault(node, { body: body() }); + }, + + reduceExportFrom(node, { namedExports }) { + return reducer.reduceExportFrom(node, { namedExports: namedExports.map(n => n()) }); + }, + + reduceExportFromSpecifier(node) { + return reducer.reduceExportFromSpecifier(node); + }, + + reduceExportLocalSpecifier(node, { name }) { + return reducer.reduceExportLocalSpecifier(node, { name: name() }); + }, + + reduceExportLocals(node, { namedExports }) { + return reducer.reduceExportLocals(node, { namedExports: namedExports.map(n => n()) }); + }, + + reduceExpressionStatement(node, { expression }) { + return reducer.reduceExpressionStatement(node, { expression: expression() }); + }, + + reduceForAwaitStatement(node, { left, right, body }) { + return reducer.reduceForAwaitStatement(node, { left: left(), right: right(), body: body() }); + }, + + reduceForInStatement(node, { left, right, body }) { + return reducer.reduceForInStatement(node, { left: left(), right: right(), body: body() }); + }, + + reduceForOfStatement(node, { left, right, body }) { + return reducer.reduceForOfStatement(node, { left: left(), right: right(), body: body() }); + }, + + reduceForStatement(node, { init, test, update, body }) { + return reducer.reduceForStatement(node, { init: init == null ? null : init(), test: test == null ? null : test(), update: update == null ? null : update(), body: body() }); + }, + + reduceFormalParameters(node, { items, rest }) { + return reducer.reduceFormalParameters(node, { items: items.map(n => n()), rest: rest == null ? null : rest() }); + }, + + reduceFunctionBody(node, { directives, statements }) { + return reducer.reduceFunctionBody(node, { directives: directives.map(n => n()), statements: statements.map(n => n()) }); + }, + + reduceFunctionDeclaration(node, { name, params, body }) { + return reducer.reduceFunctionDeclaration(node, { name: name(), params: params(), body: body() }); + }, + + reduceFunctionExpression(node, { name, params, body }) { + return reducer.reduceFunctionExpression(node, { name: name == null ? null : name(), params: params(), body: body() }); + }, + + reduceGetter(node, { name, body }) { + return reducer.reduceGetter(node, { name: name(), body: body() }); + }, + + reduceIdentifierExpression(node) { + return reducer.reduceIdentifierExpression(node); + }, + + reduceIfStatement(node, { test, consequent, alternate }) { + return reducer.reduceIfStatement(node, { test: test(), consequent: consequent(), alternate: alternate == null ? null : alternate() }); + }, + + reduceImport(node, { defaultBinding, namedImports }) { + return reducer.reduceImport(node, { defaultBinding: defaultBinding == null ? null : defaultBinding(), namedImports: namedImports.map(n => n()) }); + }, + + reduceImportNamespace(node, { defaultBinding, namespaceBinding }) { + return reducer.reduceImportNamespace(node, { defaultBinding: defaultBinding == null ? null : defaultBinding(), namespaceBinding: namespaceBinding() }); + }, + + reduceImportSpecifier(node, { binding }) { + return reducer.reduceImportSpecifier(node, { binding: binding() }); + }, + + reduceLabeledStatement(node, { body }) { + return reducer.reduceLabeledStatement(node, { body: body() }); + }, + + reduceLiteralBooleanExpression(node) { + return reducer.reduceLiteralBooleanExpression(node); + }, + + reduceLiteralInfinityExpression(node) { + return reducer.reduceLiteralInfinityExpression(node); + }, + + reduceLiteralNullExpression(node) { + return reducer.reduceLiteralNullExpression(node); + }, + + reduceLiteralNumericExpression(node) { + return reducer.reduceLiteralNumericExpression(node); + }, + + reduceLiteralRegExpExpression(node) { + return reducer.reduceLiteralRegExpExpression(node); + }, + + reduceLiteralStringExpression(node) { + return reducer.reduceLiteralStringExpression(node); + }, + + reduceMethod(node, { name, params, body }) { + return reducer.reduceMethod(node, { name: name(), params: params(), body: body() }); + }, + + reduceModule(node, { directives, items }) { + return reducer.reduceModule(node, { directives: directives.map(n => n()), items: items.map(n => n()) }); + }, + + reduceNewExpression(node, { callee, arguments: _arguments }) { + return reducer.reduceNewExpression(node, { callee: callee(), arguments: _arguments.map(n => n()) }); + }, + + reduceNewTargetExpression(node) { + return reducer.reduceNewTargetExpression(node); + }, + + reduceObjectAssignmentTarget(node, { properties, rest }) { + return reducer.reduceObjectAssignmentTarget(node, { properties: properties.map(n => n()), rest: rest == null ? null : rest() }); + }, + + reduceObjectBinding(node, { properties, rest }) { + return reducer.reduceObjectBinding(node, { properties: properties.map(n => n()), rest: rest == null ? null : rest() }); + }, + + reduceObjectExpression(node, { properties }) { + return reducer.reduceObjectExpression(node, { properties: properties.map(n => n()) }); + }, + + reduceReturnStatement(node, { expression }) { + return reducer.reduceReturnStatement(node, { expression: expression == null ? null : expression() }); + }, + + reduceScript(node, { directives, statements }) { + return reducer.reduceScript(node, { directives: directives.map(n => n()), statements: statements.map(n => n()) }); + }, + + reduceSetter(node, { name, param, body }) { + return reducer.reduceSetter(node, { name: name(), param: param(), body: body() }); + }, + + reduceShorthandProperty(node, { name }) { + return reducer.reduceShorthandProperty(node, { name: name() }); + }, + + reduceSpreadElement(node, { expression }) { + return reducer.reduceSpreadElement(node, { expression: expression() }); + }, + + reduceSpreadProperty(node, { expression }) { + return reducer.reduceSpreadProperty(node, { expression: expression() }); + }, + + reduceStaticMemberAssignmentTarget(node, { object }) { + return reducer.reduceStaticMemberAssignmentTarget(node, { object: object() }); + }, + + reduceStaticMemberExpression(node, { object }) { + return reducer.reduceStaticMemberExpression(node, { object: object() }); + }, + + reduceStaticPropertyName(node) { + return reducer.reduceStaticPropertyName(node); + }, + + reduceSuper(node) { + return reducer.reduceSuper(node); + }, + + reduceSwitchCase(node, { test, consequent }) { + return reducer.reduceSwitchCase(node, { test: test(), consequent: consequent.map(n => n()) }); + }, + + reduceSwitchDefault(node, { consequent }) { + return reducer.reduceSwitchDefault(node, { consequent: consequent.map(n => n()) }); + }, + + reduceSwitchStatement(node, { discriminant, cases }) { + return reducer.reduceSwitchStatement(node, { discriminant: discriminant(), cases: cases.map(n => n()) }); + }, + + reduceSwitchStatementWithDefault(node, { discriminant, preDefaultCases, defaultCase, postDefaultCases }) { + return reducer.reduceSwitchStatementWithDefault(node, { discriminant: discriminant(), preDefaultCases: preDefaultCases.map(n => n()), defaultCase: defaultCase(), postDefaultCases: postDefaultCases.map(n => n()) }); + }, + + reduceTemplateElement(node) { + return reducer.reduceTemplateElement(node); + }, + + reduceTemplateExpression(node, { tag, elements }) { + return reducer.reduceTemplateExpression(node, { tag: tag == null ? null : tag(), elements: elements.map(n => n()) }); + }, + + reduceThisExpression(node) { + return reducer.reduceThisExpression(node); + }, + + reduceThrowStatement(node, { expression }) { + return reducer.reduceThrowStatement(node, { expression: expression() }); + }, + + reduceTryCatchStatement(node, { body, catchClause }) { + return reducer.reduceTryCatchStatement(node, { body: body(), catchClause: catchClause() }); + }, + + reduceTryFinallyStatement(node, { body, catchClause, finalizer }) { + return reducer.reduceTryFinallyStatement(node, { body: body(), catchClause: catchClause == null ? null : catchClause(), finalizer: finalizer() }); + }, + + reduceUnaryExpression(node, { operand }) { + return reducer.reduceUnaryExpression(node, { operand: operand() }); + }, + + reduceUpdateExpression(node, { operand }) { + return reducer.reduceUpdateExpression(node, { operand: operand() }); + }, + + reduceVariableDeclaration(node, { declarators }) { + return reducer.reduceVariableDeclaration(node, { declarators: declarators.map(n => n()) }); + }, + + reduceVariableDeclarationStatement(node, { declaration }) { + return reducer.reduceVariableDeclarationStatement(node, { declaration: declaration() }); + }, + + reduceVariableDeclarator(node, { binding, init }) { + return reducer.reduceVariableDeclarator(node, { binding: binding(), init: init == null ? null : init() }); + }, + + reduceWhileStatement(node, { test, body }) { + return reducer.reduceWhileStatement(node, { test: test(), body: body() }); + }, + + reduceWithStatement(node, { object, body }) { + return reducer.reduceWithStatement(node, { object: object(), body: body() }); + }, + + reduceYieldExpression(node, { expression }) { + return reducer.reduceYieldExpression(node, { expression: expression == null ? null : expression() }); + }, + + reduceYieldGeneratorExpression(node, { expression }) { + return reducer.reduceYieldGeneratorExpression(node, { expression: expression() }); + }, + }; +} diff --git a/docs/dist/shift-traverser/index.js b/docs/dist/shift-traverser/index.js new file mode 100644 index 00000000..d04494f1 --- /dev/null +++ b/docs/dist/shift-traverser/index.js @@ -0,0 +1,61 @@ +/* + Copyright (C) 2014 Yusuke Suzuki + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +import Spec from '../../_snowpack/pkg/shift-spec.js'; +// import { version } from '../package.json' + +// Loading uncached estraverse for changing estraverse.Syntax. +import _estraverse from '../../_snowpack/pkg/estraverse.js'; + +const estraverse = _estraverse.cloneEnvironment(); + +// Adjust estraverse members. + +Object.keys(estraverse.Syntax) + .filter((key) => key !== 'Property') + .forEach((key) => { + delete estraverse.Syntax[key]; + delete estraverse.VisitorKeys[key]; + }); + +Object.assign( + estraverse.Syntax, + Object.keys(Spec).reduce((result, key) => { + result[key] = key; + return result; + }, {}) +); + +Object.assign( + estraverse.VisitorKeys, + Object.keys(Spec).reduce((result, key) => { + result[key] = Spec[key].fields.map((field) => field.name); + return result; + }, {}) +); + +// estraverse.version = version; +export default estraverse; + +/* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/docs/dist/tone.js b/docs/dist/tone.js new file mode 100644 index 00000000..7bdd9560 --- /dev/null +++ b/docs/dist/tone.js @@ -0,0 +1,79 @@ +import {Pattern as _Pattern} from "../_snowpack/link/strudel.js"; +import {AutoFilter, Destination, Filter, Gain, isNote, Synth} from "../_snowpack/pkg/tone.js"; +const Pattern = _Pattern; +const getTrigger = (getChain, value) => (time, event) => { + const chain = getChain(); + if (!isNote(value)) { + throw new Error("not a note: " + value); + } + chain.triggerAttackRelease(value, event.duration, time); + setTimeout(() => { + chain.dispose(); + }, event.duration * 2e3); +}; +Pattern.prototype._synth = function(type = "triangle") { + return this.fmap((value) => { + value = typeof value !== "object" && !Array.isArray(value) ? {value} : value; + const instrumentConfig = { + oscillator: {type}, + envelope: {attack: 0.01, decay: 0.01, sustain: 0.6, release: 0.01} + }; + const getInstrument = () => { + const instrument = new Synth(); + instrument.set(instrumentConfig); + return instrument; + }; + const onTrigger = getTrigger(() => getInstrument().toDestination(), value.value); + return {...value, getInstrument, instrumentConfig, onTrigger}; + }); +}; +Pattern.prototype.synth = function(type = "triangle") { + return this._patternify(Pattern.prototype._synth)(type); +}; +Pattern.prototype.adsr = function(attack = 0.01, decay = 0.01, sustain = 0.6, release = 0.01) { + return this.fmap((value) => { + if (!value?.getInstrument) { + throw new Error("cannot chain adsr: need instrument first (like synth)"); + } + const instrumentConfig = {...value.instrumentConfig, envelope: {attack, decay, sustain, release}}; + const getInstrument = () => { + const instrument = value.getInstrument(); + instrument.set(instrumentConfig); + return instrument; + }; + const onTrigger = getTrigger(() => getInstrument().toDestination(), value.value); + return {...value, getInstrument, instrumentConfig, onTrigger}; + }); +}; +Pattern.prototype.chain = function(...effectGetters) { + return this.fmap((value) => { + if (!value?.getInstrument) { + throw new Error("cannot chain: need instrument first (like synth)"); + } + const chain = (value.chain || []).concat(effectGetters); + const getChain = () => { + const effects = chain.map((getEffect) => getEffect()); + return value.getInstrument().chain(...effects, Destination); + }; + const onTrigger = getTrigger(getChain, value.value); + return {...value, getChain, onTrigger, chain}; + }); +}; +export const autofilter = (freq = 1) => () => new AutoFilter(freq).start(); +export const filter = (freq = 1, q = 1, type = "lowpass") => () => new Filter(freq, type); +export const gain = (gain2 = 0.9) => () => new Gain(gain2); +Pattern.prototype._gain = function(g) { + return this.chain(gain(g)); +}; +Pattern.prototype.gain = function(g) { + return this._patternify(Pattern.prototype._gain)(g); +}; +Pattern.prototype._filter = function(freq, q, type = "lowpass") { + return this.chain(filter(freq, q, type)); +}; +Pattern.prototype.filter = function(freq) { + return this._patternify(Pattern.prototype._filter)(freq); +}; +Pattern.prototype.autofilter = function(g) { + return this.chain(autofilter(g)); +}; diff --git a/docs/dist/tunes.js b/docs/dist/tunes.js index 6ce65d8c..39332caa 100644 --- a/docs/dist/tunes.js +++ b/docs/dist/tunes.js @@ -1,3 +1,25 @@ +export const shapeShifted = `stack( + sequence( + e5, [b4, c5], d5, [c5, b4], + a4, [a4, c5], e5, [d5, c5], + b4, [r, c5], d5, e5, + c5, a4, a4, r, + [r, d5], [r, f5], a5, [g5, f5], + e5, [r, c5], e5, [d5, c5], + b4, [b4, c5], d5, e5, + c5, a4, a4, r, + ).rev(), + sequence( + e2, e3, e2, e3, e2, e3, e2, e3, + a2, a3, a2, a3, a2, a3, a2, a3, + gs2, gs3, gs2, gs3, e2, e3, e2, e3, + a2, a3, a2, a3, a2, a3, b1, c2, + d2, d3, d2, d3, d2, d3, d2, d3, + c2, c3, c2, c3, c2, c3, c2, c3, + b1, b2, b1, b2, e2, e3, e2, e3, + a1, a2, a1, a2, a1, a2, a1, a2, + ).rev() +).slow(16).rev()`; export const tetrisWithFunctions = `stack(sequence( 'e5', sequence('b4', 'c5'), 'd5', sequence('c5', 'b4'), 'a4', sequence('a4', 'c5'), 'e5', sequence('d5', 'c5'), @@ -43,9 +65,37 @@ export const tetris = `stack( 'a1 a2 a1 a2 a1 a2 a1 a2' ) ) -)._slow(16);`; -export const tetrisMini1 = `mini('[[e5 [b4 c5] d5 [c5 b4]] [a4 [a4 c5] e5 [d5 c5]] [b4 [~ c5] d5 e5] [c5 a4 a4 ~] [[~ d5] [~ f5] a5 [g5 f5]] [e5 [~ c5] e5 [d5 c5]] [b4 [b4 c5] d5 e5] [c5 a4 a4 ~]],[[e2 e3 e2 e3 e2 e3 e2 e3] [a2 a3 a2 a3 a2 a3 a2 a3] [g#2 g#3 g#2 g#3 e2 e3 e2 e3] [a2 a3 a2 a3 a2 a3 b1 c2] [d2 d3 d2 d3 d2 d3 d2 d3] [c2 c3 c2 c3 c2 c3 c2 c3] [b1 b2 b1 b2 e2 e3 e2 e3] [a1 a2 a1 a2 a1 a2 a1 a2]]')._slow(16);`; -export const tetrisMini = `mini(\`[[e5 [b4 c5] d5 [c5 b4]] +).slow(16).synth({ + oscillator: {type: 'sawtooth'} +})`; +export const tetrisRev = `stack( + sequence( + mini( + 'e5 [b4 c5] d5 [c5 b4]', + 'a4 [a4 c5] e5 [d5 c5]', + 'b4 [~ c5] d5 e5', + 'c5 a4 a4 ~', + '[~ d5] [~ f5] a5 [g5 f5]', + 'e5 [~ c5] e5 [d5 c5]', + 'b4 [b4 c5] d5 e5', + 'c5 a4 a4 ~' + ).rev() + ), + sequence( + mini( + 'e2 e3 e2 e3 e2 e3 e2 e3', + 'a2 a3 a2 a3 a2 a3 a2 a3', + 'g#2 g#3 g#2 g#3 e2 e3 e2 e3', + 'a2 a3 a2 a3 a2 a3 b1 c2', + 'd2 d3 d2 d3 d2 d3 d2 d3', + 'c2 c3 c2 c3 c2 c3 c2 c3', + 'b1 b2 b1 b2 e2 e3 e2 e3', + 'a1 a2 a1 a2 a1 a2 a1 a2' + ).rev() + ) +).slow(16).synth('sawtooth').filter(1000).gain(0.6)`; +export const tetrisMini1 = `m\`[[e5 [b4 c5] d5 [c5 b4]] [a4 [a4 c5] e5 [d5 c5]] [b4 [~ c5] d5 e5] [c5 a4 a4 ~] [[~ d5] [~ f5] a5 [g5 f5]] [e5 [~ c5] e5 [d5 c5]] [b4 [b4 c5] d5 e5] [c5 a4 a4 ~]],[[e2 e3 e2 e3 e2 e3 e2 e3] [a2 a3 a2 a3 a2 a3 a2 a3] [g#2 g#3 g#2 g#3 e2 e3 e2 e3] [a2 a3 a2 a3 a2 a3 b1 c2] [d2 d3 d2 d3 d2 d3 d2 d3] [c2 c3 c2 c3 c2 c3 c2 c3] [b1 b2 b1 b2 e2 e3 e2 e3] [a1 a2 a1 a2 a1 a2 a1 a2]]')._slow(16)\``; +export const tetrisMini = `m\`[[e5 [b4 c5] d5 [c5 b4]] [a4 [a4 c5] e5 [d5 c5]] [b4 [~ c5] d5 e5] [c5 a4 a4 ~] @@ -60,7 +110,7 @@ export const tetrisMini = `mini(\`[[e5 [b4 c5] d5 [c5 b4]] [[d2 d3]*4] [[c2 c3]*4] [[b1 b2]*2 [e2 e3]*2] -[[a1 a2]*4]\`)._slow(16); +[[a1 a2]*4]\`._slow(16); `; export const tetrisHaskellH = `h(\`slow 16 $ "[[e5 [b4 c5] d5 [c5 b4]] [a4 [a4 c5] e5 [d5 c5]] @@ -102,3 +152,8 @@ export const spanish = `slowcat( stack('ab3','c4','eb4'), stack('g3','b3','d4') )`; +export const whirlyStrudel = `mini("[e4 [b2 b3] c4]") + .every(4, x => x.fast(2)) + .every(3, x => x.slow(1.5)) + .fast(slowcat(1.25,1,1.5)) + .every(2, _ => mini("e4 ~ e3 d4 ~"))`; diff --git a/docs/global.css b/docs/global.css index bd469464..dd9fb0ca 100644 --- a/docs/global.css +++ b/docs/global.css @@ -590,18 +590,34 @@ select { --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; } +.static { + position: static; +} .absolute { position: absolute; } .relative { position: relative; } +.sticky { + position: -webkit-sticky; + position: sticky; +} +.bottom-0 { + bottom: 0px; +} +.left-0 { + left: 0px; +} .right-2 { right: 0.5rem; } .bottom-2 { bottom: 0.5rem; } +.block { + display: block; +} .flex { display: flex; } @@ -614,9 +630,6 @@ select { .h-full { height: 100%; } -.h-64 { - height: 16rem; -} .w-full { width: 100%; } @@ -635,11 +648,17 @@ select { .items-center { align-items: center; } +.justify-between { + justify-content: space-between; +} .space-x-2 > :not([hidden]) ~ :not([hidden]) { --tw-space-x-reverse: 0; margin-right: calc(0.5rem * var(--tw-space-x-reverse)); margin-left: calc(0.5rem * calc(1 - var(--tw-space-x-reverse))); } +.whitespace-pre { + white-space: pre; +} .border { border-width: 1px; } @@ -665,9 +684,9 @@ select { --tw-bg-opacity: 1; background-color: rgb(255 255 255 / var(--tw-bg-opacity)); } -.bg-slate-600 { +.bg-\[\#2A3236\] { --tw-bg-opacity: 1; - background-color: rgb(71 85 105 / var(--tw-bg-opacity)); + background-color: rgb(42 50 54 / var(--tw-bg-opacity)); } .bg-slate-700 { --tw-bg-opacity: 1; @@ -680,6 +699,9 @@ select { .p-2 { padding: 0.5rem; } +.p-4 { + padding: 1rem; +} .px-2 { padding-left: 0.5rem; padding-right: 0.5rem; @@ -688,6 +710,10 @@ select { font-size: 1.5rem; line-height: 2rem; } +.text-xs { + font-size: 0.75rem; + line-height: 1rem; +} .text-gray-100 { --tw-text-opacity: 1; color: rgb(243 244 246 / var(--tw-text-opacity)); diff --git a/docs/hot.js b/docs/hot.js new file mode 100644 index 00000000..7ba68d64 --- /dev/null +++ b/docs/hot.js @@ -0,0 +1,45 @@ +// this file can be used to livecode from the comfort of your editor. +// just export a pattern from export default +// enable hot mode by pressing "toggle hot mode" on the top right of the repl + +import { mini, h } from './dist/parse.js'; +import { sequence, pure, reify, slowcat, fastcat, cat, stack, silence } from './_snowpack/link/strudel.js'; +import { gain, filter } from './dist/tone.js'; + +export default stack( + sequence( + mini( + 'e5 [b4 c5] d5 [c5 b4]', + 'a4 [a4 c5] e5 [d5 c5]', + 'b4 [~ c5] d5 e5', + 'c5 a4 a4 ~', + '[~ d5] [~ f5] a5 [g5 f5]', + 'e5 [~ c5] e5 [d5 c5]', + 'b4 [b4 c5] d5 e5', + 'c5 a4 a4 ~' + ) + .synth({ + oscillator: { type: 'sine' }, + envelope: { attack: 0.1 }, + }) + .rev() + ), + sequence( + mini( + 'e2 e3 e2 e3 e2 e3 e2 e3', + 'a2 a3 a2 a3 a2 a3 a2 a3', + 'g#2 g#3 g#2 g#3 e2 e3 e2 e3', + 'a2 a3 a2 a3 a2 a3 b1 c2', + 'd2 d3 d2 d3 d2 d3 d2 d3', + 'c2 c3 c2 c3 c2 c3 c2 c3', + 'b1 b2 b1 b2 e2 e3 e2 e3', + 'a1 a2 a1 a2 a1 a2 a1 a2' + ) + .synth({ + oscillator: { type: 'sawtooth' }, + envelope: { attack: 0.1 }, + }) + .chain(gain(0.7), filter(2000)) + .rev() + ) +).slow(16); diff --git a/repl/package.json b/repl/package.json index 29dc4b58..b55e1139 100644 --- a/repl/package.json +++ b/repl/package.json @@ -2,6 +2,7 @@ "scripts": { "start": "snowpack dev", "build": "snowpack build && cp ./public/.nojekyll ../docs", + "static": "npx serve ../docs", "test": "web-test-runner \"src/**/*.test.tsx\"", "format": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"", "lint": "prettier --check \"src/**/*.{js,jsx,ts,tsx}\"",