react / wstein / node_modules / browserify / node_modules / module-deps / node_modules / detective / node_modules / acorn / dist / acorn.js
80559 views(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.acorn = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){123// The main exported interface (under `self.acorn` when in the4// browser) is a `parse` function that takes a code string and5// returns an abstract syntax tree as specified by [Mozilla parser6// API][api].7//8// [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API910"use strict";1112exports.parse = parse;1314// This function tries to parse a single expression at a given15// offset in a string. Useful for parsing mixed-language formats16// that embed JavaScript expressions.1718exports.parseExpressionAt = parseExpressionAt;1920// Acorn is organized as a tokenizer and a recursive-descent parser.21// The `tokenize` export provides an interface to the tokenizer.2223exports.tokenizer = tokenizer;24exports.__esModule = true;25// Acorn is a tiny, fast JavaScript parser written in JavaScript.26//27// Acorn was written by Marijn Haverbeke, Ingvar Stepanyan, and28// various contributors and released under an MIT license.29//30// Git repositories for Acorn are available at31//32// http://marijnhaverbeke.nl/git/acorn33// https://github.com/marijnh/acorn.git34//35// Please use the [github bug tracker][ghbt] to report issues.36//37// [ghbt]: https://github.com/marijnh/acorn/issues38//39// This file defines the main parser interface. The library also comes40// with a [error-tolerant parser][dammit] and an41// [abstract syntax tree walker][walk], defined in other files.42//43// [dammit]: acorn_loose.js44// [walk]: util/walk.js4546var _state = _dereq_("./state");4748var Parser = _state.Parser;4950var _options = _dereq_("./options");5152var getOptions = _options.getOptions;5354_dereq_("./parseutil");5556_dereq_("./statement");5758_dereq_("./lval");5960_dereq_("./expression");6162exports.Parser = _state.Parser;63exports.plugins = _state.plugins;64exports.defaultOptions = _options.defaultOptions;6566var _location = _dereq_("./location");6768exports.SourceLocation = _location.SourceLocation;69exports.getLineInfo = _location.getLineInfo;70exports.Node = _dereq_("./node").Node;7172var _tokentype = _dereq_("./tokentype");7374exports.TokenType = _tokentype.TokenType;75exports.tokTypes = _tokentype.types;7677var _tokencontext = _dereq_("./tokencontext");7879exports.TokContext = _tokencontext.TokContext;80exports.tokContexts = _tokencontext.types;8182var _identifier = _dereq_("./identifier");8384exports.isIdentifierChar = _identifier.isIdentifierChar;85exports.isIdentifierStart = _identifier.isIdentifierStart;86exports.Token = _dereq_("./tokenize").Token;8788var _whitespace = _dereq_("./whitespace");8990exports.isNewLine = _whitespace.isNewLine;91exports.lineBreak = _whitespace.lineBreak;92exports.lineBreakG = _whitespace.lineBreakG;93var version = "1.2.2";exports.version = version;9495function parse(input, options) {96var p = parser(options, input);97var startPos = p.pos,98startLoc = p.options.locations && p.curPosition();99p.nextToken();100return p.parseTopLevel(p.options.program || p.startNodeAt(startPos, startLoc));101}102103function parseExpressionAt(input, pos, options) {104var p = parser(options, input, pos);105p.nextToken();106return p.parseExpression();107}108109function tokenizer(input, options) {110return parser(options, input);111}112113function parser(options, input) {114return new Parser(getOptions(options), String(input));115}116117},{"./expression":6,"./identifier":7,"./location":8,"./lval":9,"./node":10,"./options":11,"./parseutil":12,"./state":13,"./statement":14,"./tokencontext":15,"./tokenize":16,"./tokentype":17,"./whitespace":19}],2:[function(_dereq_,module,exports){118if (typeof Object.create === 'function') {119// implementation from standard node.js 'util' module120module.exports = function inherits(ctor, superCtor) {121ctor.super_ = superCtor122ctor.prototype = Object.create(superCtor.prototype, {123constructor: {124value: ctor,125enumerable: false,126writable: true,127configurable: true128}129});130};131} else {132// old school shim for old browsers133module.exports = function inherits(ctor, superCtor) {134ctor.super_ = superCtor135var TempCtor = function () {}136TempCtor.prototype = superCtor.prototype137ctor.prototype = new TempCtor()138ctor.prototype.constructor = ctor139}140}141142},{}],3:[function(_dereq_,module,exports){143// shim for using process in browser144145var process = module.exports = {};146var queue = [];147var draining = false;148149function drainQueue() {150if (draining) {151return;152}153draining = true;154var currentQueue;155var len = queue.length;156while(len) {157currentQueue = queue;158queue = [];159var i = -1;160while (++i < len) {161currentQueue[i]();162}163len = queue.length;164}165draining = false;166}167process.nextTick = function (fun) {168queue.push(fun);169if (!draining) {170setTimeout(drainQueue, 0);171}172};173174process.title = 'browser';175process.browser = true;176process.env = {};177process.argv = [];178process.version = ''; // empty string to avoid regexp issues179process.versions = {};180181function noop() {}182183process.on = noop;184process.addListener = noop;185process.once = noop;186process.off = noop;187process.removeListener = noop;188process.removeAllListeners = noop;189process.emit = noop;190191process.binding = function (name) {192throw new Error('process.binding is not supported');193};194195// TODO(shtylman)196process.cwd = function () { return '/' };197process.chdir = function (dir) {198throw new Error('process.chdir is not supported');199};200process.umask = function() { return 0; };201202},{}],4:[function(_dereq_,module,exports){203module.exports = function isBuffer(arg) {204return arg && typeof arg === 'object'205&& typeof arg.copy === 'function'206&& typeof arg.fill === 'function'207&& typeof arg.readUInt8 === 'function';208}209},{}],5:[function(_dereq_,module,exports){210(function (process,global){211// Copyright Joyent, Inc. and other Node contributors.212//213// Permission is hereby granted, free of charge, to any person obtaining a214// copy of this software and associated documentation files (the215// "Software"), to deal in the Software without restriction, including216// without limitation the rights to use, copy, modify, merge, publish,217// distribute, sublicense, and/or sell copies of the Software, and to permit218// persons to whom the Software is furnished to do so, subject to the219// following conditions:220//221// The above copyright notice and this permission notice shall be included222// in all copies or substantial portions of the Software.223//224// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS225// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF226// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN227// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,228// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR229// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE230// USE OR OTHER DEALINGS IN THE SOFTWARE.231232var formatRegExp = /%[sdj%]/g;233exports.format = function(f) {234if (!isString(f)) {235var objects = [];236for (var i = 0; i < arguments.length; i++) {237objects.push(inspect(arguments[i]));238}239return objects.join(' ');240}241242var i = 1;243var args = arguments;244var len = args.length;245var str = String(f).replace(formatRegExp, function(x) {246if (x === '%%') return '%';247if (i >= len) return x;248switch (x) {249case '%s': return String(args[i++]);250case '%d': return Number(args[i++]);251case '%j':252try {253return JSON.stringify(args[i++]);254} catch (_) {255return '[Circular]';256}257default:258return x;259}260});261for (var x = args[i]; i < len; x = args[++i]) {262if (isNull(x) || !isObject(x)) {263str += ' ' + x;264} else {265str += ' ' + inspect(x);266}267}268return str;269};270271272// Mark that a method should not be used.273// Returns a modified function which warns once by default.274// If --no-deprecation is set, then it is a no-op.275exports.deprecate = function(fn, msg) {276// Allow for deprecating things in the process of starting up.277if (isUndefined(global.process)) {278return function() {279return exports.deprecate(fn, msg).apply(this, arguments);280};281}282283if (process.noDeprecation === true) {284return fn;285}286287var warned = false;288function deprecated() {289if (!warned) {290if (process.throwDeprecation) {291throw new Error(msg);292} else if (process.traceDeprecation) {293console.trace(msg);294} else {295console.error(msg);296}297warned = true;298}299return fn.apply(this, arguments);300}301302return deprecated;303};304305306var debugs = {};307var debugEnviron;308exports.debuglog = function(set) {309if (isUndefined(debugEnviron))310debugEnviron = process.env.NODE_DEBUG || '';311set = set.toUpperCase();312if (!debugs[set]) {313if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {314var pid = process.pid;315debugs[set] = function() {316var msg = exports.format.apply(exports, arguments);317console.error('%s %d: %s', set, pid, msg);318};319} else {320debugs[set] = function() {};321}322}323return debugs[set];324};325326327/**328* Echos the value of a value. Trys to print the value out329* in the best way possible given the different types.330*331* @param {Object} obj The object to print out.332* @param {Object} opts Optional options object that alters the output.333*/334/* legacy: obj, showHidden, depth, colors*/335function inspect(obj, opts) {336// default options337var ctx = {338seen: [],339stylize: stylizeNoColor340};341// legacy...342if (arguments.length >= 3) ctx.depth = arguments[2];343if (arguments.length >= 4) ctx.colors = arguments[3];344if (isBoolean(opts)) {345// legacy...346ctx.showHidden = opts;347} else if (opts) {348// got an "options" object349exports._extend(ctx, opts);350}351// set default options352if (isUndefined(ctx.showHidden)) ctx.showHidden = false;353if (isUndefined(ctx.depth)) ctx.depth = 2;354if (isUndefined(ctx.colors)) ctx.colors = false;355if (isUndefined(ctx.customInspect)) ctx.customInspect = true;356if (ctx.colors) ctx.stylize = stylizeWithColor;357return formatValue(ctx, obj, ctx.depth);358}359exports.inspect = inspect;360361362// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics363inspect.colors = {364'bold' : [1, 22],365'italic' : [3, 23],366'underline' : [4, 24],367'inverse' : [7, 27],368'white' : [37, 39],369'grey' : [90, 39],370'black' : [30, 39],371'blue' : [34, 39],372'cyan' : [36, 39],373'green' : [32, 39],374'magenta' : [35, 39],375'red' : [31, 39],376'yellow' : [33, 39]377};378379// Don't use 'blue' not visible on cmd.exe380inspect.styles = {381'special': 'cyan',382'number': 'yellow',383'boolean': 'yellow',384'undefined': 'grey',385'null': 'bold',386'string': 'green',387'date': 'magenta',388// "name": intentionally not styling389'regexp': 'red'390};391392393function stylizeWithColor(str, styleType) {394var style = inspect.styles[styleType];395396if (style) {397return '\u001b[' + inspect.colors[style][0] + 'm' + str +398'\u001b[' + inspect.colors[style][1] + 'm';399} else {400return str;401}402}403404405function stylizeNoColor(str, styleType) {406return str;407}408409410function arrayToHash(array) {411var hash = {};412413array.forEach(function(val, idx) {414hash[val] = true;415});416417return hash;418}419420421function formatValue(ctx, value, recurseTimes) {422// Provide a hook for user-specified inspect functions.423// Check that value is an object with an inspect function on it424if (ctx.customInspect &&425value &&426isFunction(value.inspect) &&427// Filter out the util module, it's inspect function is special428value.inspect !== exports.inspect &&429// Also filter out any prototype objects using the circular check.430!(value.constructor && value.constructor.prototype === value)) {431var ret = value.inspect(recurseTimes, ctx);432if (!isString(ret)) {433ret = formatValue(ctx, ret, recurseTimes);434}435return ret;436}437438// Primitive types cannot have properties439var primitive = formatPrimitive(ctx, value);440if (primitive) {441return primitive;442}443444// Look up the keys of the object.445var keys = Object.keys(value);446var visibleKeys = arrayToHash(keys);447448if (ctx.showHidden) {449keys = Object.getOwnPropertyNames(value);450}451452// IE doesn't make error fields non-enumerable453// http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx454if (isError(value)455&& (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {456return formatError(value);457}458459// Some type of object without properties can be shortcutted.460if (keys.length === 0) {461if (isFunction(value)) {462var name = value.name ? ': ' + value.name : '';463return ctx.stylize('[Function' + name + ']', 'special');464}465if (isRegExp(value)) {466return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');467}468if (isDate(value)) {469return ctx.stylize(Date.prototype.toString.call(value), 'date');470}471if (isError(value)) {472return formatError(value);473}474}475476var base = '', array = false, braces = ['{', '}'];477478// Make Array say that they are Array479if (isArray(value)) {480array = true;481braces = ['[', ']'];482}483484// Make functions say that they are functions485if (isFunction(value)) {486var n = value.name ? ': ' + value.name : '';487base = ' [Function' + n + ']';488}489490// Make RegExps say that they are RegExps491if (isRegExp(value)) {492base = ' ' + RegExp.prototype.toString.call(value);493}494495// Make dates with properties first say the date496if (isDate(value)) {497base = ' ' + Date.prototype.toUTCString.call(value);498}499500// Make error with message first say the error501if (isError(value)) {502base = ' ' + formatError(value);503}504505if (keys.length === 0 && (!array || value.length == 0)) {506return braces[0] + base + braces[1];507}508509if (recurseTimes < 0) {510if (isRegExp(value)) {511return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');512} else {513return ctx.stylize('[Object]', 'special');514}515}516517ctx.seen.push(value);518519var output;520if (array) {521output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);522} else {523output = keys.map(function(key) {524return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);525});526}527528ctx.seen.pop();529530return reduceToSingleString(output, base, braces);531}532533534function formatPrimitive(ctx, value) {535if (isUndefined(value))536return ctx.stylize('undefined', 'undefined');537if (isString(value)) {538var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')539.replace(/'/g, "\\'")540.replace(/\\"/g, '"') + '\'';541return ctx.stylize(simple, 'string');542}543if (isNumber(value))544return ctx.stylize('' + value, 'number');545if (isBoolean(value))546return ctx.stylize('' + value, 'boolean');547// For some reason typeof null is "object", so special case here.548if (isNull(value))549return ctx.stylize('null', 'null');550}551552553function formatError(value) {554return '[' + Error.prototype.toString.call(value) + ']';555}556557558function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {559var output = [];560for (var i = 0, l = value.length; i < l; ++i) {561if (hasOwnProperty(value, String(i))) {562output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,563String(i), true));564} else {565output.push('');566}567}568keys.forEach(function(key) {569if (!key.match(/^\d+$/)) {570output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,571key, true));572}573});574return output;575}576577578function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {579var name, str, desc;580desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };581if (desc.get) {582if (desc.set) {583str = ctx.stylize('[Getter/Setter]', 'special');584} else {585str = ctx.stylize('[Getter]', 'special');586}587} else {588if (desc.set) {589str = ctx.stylize('[Setter]', 'special');590}591}592if (!hasOwnProperty(visibleKeys, key)) {593name = '[' + key + ']';594}595if (!str) {596if (ctx.seen.indexOf(desc.value) < 0) {597if (isNull(recurseTimes)) {598str = formatValue(ctx, desc.value, null);599} else {600str = formatValue(ctx, desc.value, recurseTimes - 1);601}602if (str.indexOf('\n') > -1) {603if (array) {604str = str.split('\n').map(function(line) {605return ' ' + line;606}).join('\n').substr(2);607} else {608str = '\n' + str.split('\n').map(function(line) {609return ' ' + line;610}).join('\n');611}612}613} else {614str = ctx.stylize('[Circular]', 'special');615}616}617if (isUndefined(name)) {618if (array && key.match(/^\d+$/)) {619return str;620}621name = JSON.stringify('' + key);622if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {623name = name.substr(1, name.length - 2);624name = ctx.stylize(name, 'name');625} else {626name = name.replace(/'/g, "\\'")627.replace(/\\"/g, '"')628.replace(/(^"|"$)/g, "'");629name = ctx.stylize(name, 'string');630}631}632633return name + ': ' + str;634}635636637function reduceToSingleString(output, base, braces) {638var numLinesEst = 0;639var length = output.reduce(function(prev, cur) {640numLinesEst++;641if (cur.indexOf('\n') >= 0) numLinesEst++;642return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;643}, 0);644645if (length > 60) {646return braces[0] +647(base === '' ? '' : base + '\n ') +648' ' +649output.join(',\n ') +650' ' +651braces[1];652}653654return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];655}656657658// NOTE: These type checking functions intentionally don't use `instanceof`659// because it is fragile and can be easily faked with `Object.create()`.660function isArray(ar) {661return Array.isArray(ar);662}663exports.isArray = isArray;664665function isBoolean(arg) {666return typeof arg === 'boolean';667}668exports.isBoolean = isBoolean;669670function isNull(arg) {671return arg === null;672}673exports.isNull = isNull;674675function isNullOrUndefined(arg) {676return arg == null;677}678exports.isNullOrUndefined = isNullOrUndefined;679680function isNumber(arg) {681return typeof arg === 'number';682}683exports.isNumber = isNumber;684685function isString(arg) {686return typeof arg === 'string';687}688exports.isString = isString;689690function isSymbol(arg) {691return typeof arg === 'symbol';692}693exports.isSymbol = isSymbol;694695function isUndefined(arg) {696return arg === void 0;697}698exports.isUndefined = isUndefined;699700function isRegExp(re) {701return isObject(re) && objectToString(re) === '[object RegExp]';702}703exports.isRegExp = isRegExp;704705function isObject(arg) {706return typeof arg === 'object' && arg !== null;707}708exports.isObject = isObject;709710function isDate(d) {711return isObject(d) && objectToString(d) === '[object Date]';712}713exports.isDate = isDate;714715function isError(e) {716return isObject(e) &&717(objectToString(e) === '[object Error]' || e instanceof Error);718}719exports.isError = isError;720721function isFunction(arg) {722return typeof arg === 'function';723}724exports.isFunction = isFunction;725726function isPrimitive(arg) {727return arg === null ||728typeof arg === 'boolean' ||729typeof arg === 'number' ||730typeof arg === 'string' ||731typeof arg === 'symbol' || // ES6 symbol732typeof arg === 'undefined';733}734exports.isPrimitive = isPrimitive;735736exports.isBuffer = _dereq_('./support/isBuffer');737738function objectToString(o) {739return Object.prototype.toString.call(o);740}741742743function pad(n) {744return n < 10 ? '0' + n.toString(10) : n.toString(10);745}746747748var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',749'Oct', 'Nov', 'Dec'];750751// 26 Feb 16:19:34752function timestamp() {753var d = new Date();754var time = [pad(d.getHours()),755pad(d.getMinutes()),756pad(d.getSeconds())].join(':');757return [d.getDate(), months[d.getMonth()], time].join(' ');758}759760761// log is just a thin wrapper to console.log that prepends a timestamp762exports.log = function() {763console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));764};765766767/**768* Inherit the prototype methods from one constructor into another.769*770* The Function.prototype.inherits from lang.js rewritten as a standalone771* function (not on Function.prototype). NOTE: If this file is to be loaded772* during bootstrapping this function needs to be rewritten using some native773* functions as prototype setup using normal JavaScript does not work as774* expected during bootstrapping (see mirror.js in r114903).775*776* @param {function} ctor Constructor function which needs to inherit the777* prototype.778* @param {function} superCtor Constructor function to inherit prototype from.779*/780exports.inherits = _dereq_('inherits');781782exports._extend = function(origin, add) {783// Don't do anything if add isn't an object784if (!add || !isObject(add)) return origin;785786var keys = Object.keys(add);787var i = keys.length;788while (i--) {789origin[keys[i]] = add[keys[i]];790}791return origin;792};793794function hasOwnProperty(obj, prop) {795return Object.prototype.hasOwnProperty.call(obj, prop);796}797798}).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})799},{"./support/isBuffer":4,"_process":3,"inherits":2}],6:[function(_dereq_,module,exports){800// A recursive descent parser operates by defining functions for all801// syntactic elements, and recursively calling those, each function802// advancing the input stream and returning an AST node. Precedence803// of constructs (for example, the fact that `!x[1]` means `!(x[1])`804// instead of `(!x)[1]` is handled by the fact that the parser805// function that parses unary prefix operators is called first, and806// in turn calls the function that parses `[]` subscripts — that807// way, it'll receive the node for `x[1]` already parsed, and wraps808// *that* in the unary operator node.809//810// Acorn uses an [operator precedence parser][opp] to handle binary811// operator precedence, because it is much more compact than using812// the technique outlined above, which uses different, nesting813// functions to specify precedence, for all of the ten binary814// precedence levels that JavaScript defines.815//816// [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser817818"use strict";819820var tt = _dereq_("./tokentype").types;821822var Parser = _dereq_("./state").Parser;823824var reservedWords = _dereq_("./identifier").reservedWords;825826var has = _dereq_("./util").has;827828var pp = Parser.prototype;829830// Check if property name clashes with already added.831// Object/class getters and setters are not allowed to clash —832// either with each other or with an init property — and in833// strict mode, init properties are also not allowed to be repeated.834835pp.checkPropClash = function (prop, propHash) {836if (this.options.ecmaVersion >= 6) return;837var key = prop.key,838name = undefined;839switch (key.type) {840case "Identifier":841name = key.name;break;842case "Literal":843name = String(key.value);break;844default:845return;846}847var kind = prop.kind || "init",848other = undefined;849if (has(propHash, name)) {850other = propHash[name];851var isGetSet = kind !== "init";852if ((this.strict || isGetSet) && other[kind] || !(isGetSet ^ other.init)) this.raise(key.start, "Redefinition of property");853} else {854other = propHash[name] = {855init: false,856get: false,857set: false858};859}860other[kind] = true;861};862863// ### Expression parsing864865// These nest, from the most general expression type at the top to866// 'atomic', nondivisible expression types at the bottom. Most of867// the functions will simply let the function(s) below them parse,868// and, *if* the syntactic construct they handle is present, wrap869// the AST node that the inner parser gave them in another node.870871// Parse a full expression. The optional arguments are used to872// forbid the `in` operator (in for loops initalization expressions)873// and provide reference for storing '=' operator inside shorthand874// property assignment in contexts where both object expression875// and object pattern might appear (so it's possible to raise876// delayed syntax error at correct position).877878pp.parseExpression = function (noIn, refShorthandDefaultPos) {879var startPos = this.start,880startLoc = this.startLoc;881var expr = this.parseMaybeAssign(noIn, refShorthandDefaultPos);882if (this.type === tt.comma) {883var node = this.startNodeAt(startPos, startLoc);884node.expressions = [expr];885while (this.eat(tt.comma)) node.expressions.push(this.parseMaybeAssign(noIn, refShorthandDefaultPos));886return this.finishNode(node, "SequenceExpression");887}888return expr;889};890891// Parse an assignment expression. This includes applications of892// operators like `+=`.893894pp.parseMaybeAssign = function (noIn, refShorthandDefaultPos, afterLeftParse) {895if (this.type == tt._yield && this.inGenerator) return this.parseYield();896897var failOnShorthandAssign = undefined;898if (!refShorthandDefaultPos) {899refShorthandDefaultPos = { start: 0 };900failOnShorthandAssign = true;901} else {902failOnShorthandAssign = false;903}904var startPos = this.start,905startLoc = this.startLoc;906if (this.type == tt.parenL || this.type == tt.name) this.potentialArrowAt = this.start;907var left = this.parseMaybeConditional(noIn, refShorthandDefaultPos);908if (afterLeftParse) left = afterLeftParse.call(this, left, startPos, startLoc);909if (this.type.isAssign) {910var node = this.startNodeAt(startPos, startLoc);911node.operator = this.value;912node.left = this.type === tt.eq ? this.toAssignable(left) : left;913refShorthandDefaultPos.start = 0; // reset because shorthand default was used correctly914this.checkLVal(left);915this.next();916node.right = this.parseMaybeAssign(noIn);917return this.finishNode(node, "AssignmentExpression");918} else if (failOnShorthandAssign && refShorthandDefaultPos.start) {919this.unexpected(refShorthandDefaultPos.start);920}921return left;922};923924// Parse a ternary conditional (`?:`) operator.925926pp.parseMaybeConditional = function (noIn, refShorthandDefaultPos) {927var startPos = this.start,928startLoc = this.startLoc;929var expr = this.parseExprOps(noIn, refShorthandDefaultPos);930if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;931if (this.eat(tt.question)) {932var node = this.startNodeAt(startPos, startLoc);933node.test = expr;934node.consequent = this.parseMaybeAssign();935this.expect(tt.colon);936node.alternate = this.parseMaybeAssign(noIn);937return this.finishNode(node, "ConditionalExpression");938}939return expr;940};941942// Start the precedence parser.943944pp.parseExprOps = function (noIn, refShorthandDefaultPos) {945var startPos = this.start,946startLoc = this.startLoc;947var expr = this.parseMaybeUnary(refShorthandDefaultPos);948if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;949return this.parseExprOp(expr, startPos, startLoc, -1, noIn);950};951952// Parse binary operators with the operator precedence parsing953// algorithm. `left` is the left-hand side of the operator.954// `minPrec` provides context that allows the function to stop and955// defer further parser to one of its callers when it encounters an956// operator that has a lower precedence than the set it is parsing.957958pp.parseExprOp = function (left, leftStartPos, leftStartLoc, minPrec, noIn) {959var prec = this.type.binop;960if (Array.isArray(leftStartPos)) {961if (this.options.locations && noIn === undefined) {962// shift arguments to left by one963noIn = minPrec;964minPrec = leftStartLoc;965// flatten leftStartPos966leftStartLoc = leftStartPos[1];967leftStartPos = leftStartPos[0];968}969}970if (prec != null && (!noIn || this.type !== tt._in)) {971if (prec > minPrec) {972var node = this.startNodeAt(leftStartPos, leftStartLoc);973node.left = left;974node.operator = this.value;975var op = this.type;976this.next();977var startPos = this.start,978startLoc = this.startLoc;979node.right = this.parseExprOp(this.parseMaybeUnary(), startPos, startLoc, prec, noIn);980this.finishNode(node, op === tt.logicalOR || op === tt.logicalAND ? "LogicalExpression" : "BinaryExpression");981return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn);982}983}984return left;985};986987// Parse unary operators, both prefix and postfix.988989pp.parseMaybeUnary = function (refShorthandDefaultPos) {990if (this.type.prefix) {991var node = this.startNode(),992update = this.type === tt.incDec;993node.operator = this.value;994node.prefix = true;995this.next();996node.argument = this.parseMaybeUnary();997if (refShorthandDefaultPos && refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start);998if (update) this.checkLVal(node.argument);else if (this.strict && node.operator === "delete" && node.argument.type === "Identifier") this.raise(node.start, "Deleting local variable in strict mode");999return this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");1000}1001var startPos = this.start,1002startLoc = this.startLoc;1003var expr = this.parseExprSubscripts(refShorthandDefaultPos);1004if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;1005while (this.type.postfix && !this.canInsertSemicolon()) {1006var node = this.startNodeAt(startPos, startLoc);1007node.operator = this.value;1008node.prefix = false;1009node.argument = expr;1010this.checkLVal(expr);1011this.next();1012expr = this.finishNode(node, "UpdateExpression");1013}1014return expr;1015};10161017// Parse call, dot, and `[]`-subscript expressions.10181019pp.parseExprSubscripts = function (refShorthandDefaultPos) {1020var startPos = this.start,1021startLoc = this.startLoc;1022var expr = this.parseExprAtom(refShorthandDefaultPos);1023if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;1024return this.parseSubscripts(expr, startPos, startLoc);1025};10261027pp.parseSubscripts = function (base, startPos, startLoc, noCalls) {1028if (Array.isArray(startPos)) {1029if (this.options.locations && noCalls === undefined) {1030// shift arguments to left by one1031noCalls = startLoc;1032// flatten startPos1033startLoc = startPos[1];1034startPos = startPos[0];1035}1036}1037for (;;) {1038if (this.eat(tt.dot)) {1039var node = this.startNodeAt(startPos, startLoc);1040node.object = base;1041node.property = this.parseIdent(true);1042node.computed = false;1043base = this.finishNode(node, "MemberExpression");1044} else if (this.eat(tt.bracketL)) {1045var node = this.startNodeAt(startPos, startLoc);1046node.object = base;1047node.property = this.parseExpression();1048node.computed = true;1049this.expect(tt.bracketR);1050base = this.finishNode(node, "MemberExpression");1051} else if (!noCalls && this.eat(tt.parenL)) {1052var node = this.startNodeAt(startPos, startLoc);1053node.callee = base;1054node.arguments = this.parseExprList(tt.parenR, false);1055base = this.finishNode(node, "CallExpression");1056} else if (this.type === tt.backQuote) {1057var node = this.startNodeAt(startPos, startLoc);1058node.tag = base;1059node.quasi = this.parseTemplate();1060base = this.finishNode(node, "TaggedTemplateExpression");1061} else {1062return base;1063}1064}1065};10661067// Parse an atomic expression — either a single token that is an1068// expression, an expression started by a keyword like `function` or1069// `new`, or an expression wrapped in punctuation like `()`, `[]`,1070// or `{}`.10711072pp.parseExprAtom = function (refShorthandDefaultPos) {1073var node = undefined,1074canBeArrow = this.potentialArrowAt == this.start;1075switch (this.type) {1076case tt._this:1077case tt._super:1078var type = this.type === tt._this ? "ThisExpression" : "Super";1079node = this.startNode();1080this.next();1081return this.finishNode(node, type);10821083case tt._yield:1084if (this.inGenerator) this.unexpected();10851086case tt.name:1087var startPos = this.start,1088startLoc = this.startLoc;1089var id = this.parseIdent(this.type !== tt.name);1090if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id]);1091return id;10921093case tt.regexp:1094var value = this.value;1095node = this.parseLiteral(value.value);1096node.regex = { pattern: value.pattern, flags: value.flags };1097return node;10981099case tt.num:case tt.string:1100return this.parseLiteral(this.value);11011102case tt._null:case tt._true:case tt._false:1103node = this.startNode();1104node.value = this.type === tt._null ? null : this.type === tt._true;1105node.raw = this.type.keyword;1106this.next();1107return this.finishNode(node, "Literal");11081109case tt.parenL:1110return this.parseParenAndDistinguishExpression(canBeArrow);11111112case tt.bracketL:1113node = this.startNode();1114this.next();1115// check whether this is array comprehension or regular array1116if (this.options.ecmaVersion >= 7 && this.type === tt._for) {1117return this.parseComprehension(node, false);1118}1119node.elements = this.parseExprList(tt.bracketR, true, true, refShorthandDefaultPos);1120return this.finishNode(node, "ArrayExpression");11211122case tt.braceL:1123return this.parseObj(false, refShorthandDefaultPos);11241125case tt._function:1126node = this.startNode();1127this.next();1128return this.parseFunction(node, false);11291130case tt._class:1131return this.parseClass(this.startNode(), false);11321133case tt._new:1134return this.parseNew();11351136case tt.backQuote:1137return this.parseTemplate();11381139default:1140this.unexpected();1141}1142};11431144pp.parseLiteral = function (value) {1145var node = this.startNode();1146node.value = value;1147node.raw = this.input.slice(this.start, this.end);1148this.next();1149return this.finishNode(node, "Literal");1150};11511152pp.parseParenExpression = function () {1153this.expect(tt.parenL);1154var val = this.parseExpression();1155this.expect(tt.parenR);1156return val;1157};11581159pp.parseParenAndDistinguishExpression = function (canBeArrow) {1160var startPos = this.start,1161startLoc = this.startLoc,1162val = undefined;1163if (this.options.ecmaVersion >= 6) {1164this.next();11651166if (this.options.ecmaVersion >= 7 && this.type === tt._for) {1167return this.parseComprehension(this.startNodeAt(startPos, startLoc), true);1168}11691170var innerStartPos = this.start,1171innerStartLoc = this.startLoc;1172var exprList = [],1173first = true;1174var refShorthandDefaultPos = { start: 0 },1175spreadStart = undefined,1176innerParenStart = undefined;1177while (this.type !== tt.parenR) {1178first ? first = false : this.expect(tt.comma);1179if (this.type === tt.ellipsis) {1180spreadStart = this.start;1181exprList.push(this.parseParenItem(this.parseRest()));1182break;1183} else {1184if (this.type === tt.parenL && !innerParenStart) {1185innerParenStart = this.start;1186}1187exprList.push(this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem));1188}1189}1190var innerEndPos = this.start,1191innerEndLoc = this.startLoc;1192this.expect(tt.parenR);11931194if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) {1195if (innerParenStart) this.unexpected(innerParenStart);1196return this.parseParenArrowList(startPos, startLoc, exprList);1197}11981199if (!exprList.length) this.unexpected(this.lastTokStart);1200if (spreadStart) this.unexpected(spreadStart);1201if (refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start);12021203if (exprList.length > 1) {1204val = this.startNodeAt(innerStartPos, innerStartLoc);1205val.expressions = exprList;1206this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);1207} else {1208val = exprList[0];1209}1210} else {1211val = this.parseParenExpression();1212}12131214if (this.options.preserveParens) {1215var par = this.startNodeAt(startPos, startLoc);1216par.expression = val;1217return this.finishNode(par, "ParenthesizedExpression");1218} else {1219return val;1220}1221};12221223pp.parseParenItem = function (item) {1224return item;1225};12261227pp.parseParenArrowList = function (startPos, startLoc, exprList) {1228return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList);1229};12301231// New's precedence is slightly tricky. It must allow its argument1232// to be a `[]` or dot subscript expression, but not a call — at1233// least, not without wrapping it in parentheses. Thus, it uses the12341235var empty = [];12361237pp.parseNew = function () {1238var node = this.startNode();1239var meta = this.parseIdent(true);1240if (this.options.ecmaVersion >= 6 && this.eat(tt.dot)) {1241node.meta = meta;1242node.property = this.parseIdent(true);1243if (node.property.name !== "target") this.raise(node.property.start, "The only valid meta property for new is new.target");1244return this.finishNode(node, "MetaProperty");1245}1246var startPos = this.start,1247startLoc = this.startLoc;1248node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true);1249if (this.eat(tt.parenL)) node.arguments = this.parseExprList(tt.parenR, false);else node.arguments = empty;1250return this.finishNode(node, "NewExpression");1251};12521253// Parse template expression.12541255pp.parseTemplateElement = function () {1256var elem = this.startNode();1257elem.value = {1258raw: this.input.slice(this.start, this.end),1259cooked: this.value1260};1261this.next();1262elem.tail = this.type === tt.backQuote;1263return this.finishNode(elem, "TemplateElement");1264};12651266pp.parseTemplate = function () {1267var node = this.startNode();1268this.next();1269node.expressions = [];1270var curElt = this.parseTemplateElement();1271node.quasis = [curElt];1272while (!curElt.tail) {1273this.expect(tt.dollarBraceL);1274node.expressions.push(this.parseExpression());1275this.expect(tt.braceR);1276node.quasis.push(curElt = this.parseTemplateElement());1277}1278this.next();1279return this.finishNode(node, "TemplateLiteral");1280};12811282// Parse an object literal or binding pattern.12831284pp.parseObj = function (isPattern, refShorthandDefaultPos) {1285var node = this.startNode(),1286first = true,1287propHash = {};1288node.properties = [];1289this.next();1290while (!this.eat(tt.braceR)) {1291if (!first) {1292this.expect(tt.comma);1293if (this.afterTrailingComma(tt.braceR)) break;1294} else first = false;12951296var prop = this.startNode(),1297isGenerator = undefined,1298startPos = undefined,1299startLoc = undefined;1300if (this.options.ecmaVersion >= 6) {1301prop.method = false;1302prop.shorthand = false;1303if (isPattern || refShorthandDefaultPos) {1304startPos = this.start;1305startLoc = this.startLoc;1306}1307if (!isPattern) isGenerator = this.eat(tt.star);1308}1309this.parsePropertyName(prop);1310this.parsePropertyValue(prop, isPattern, isGenerator, startPos, startLoc, refShorthandDefaultPos);1311this.checkPropClash(prop, propHash);1312node.properties.push(this.finishNode(prop, "Property"));1313}1314return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression");1315};13161317pp.parsePropertyValue = function (prop, isPattern, isGenerator, startPos, startLoc, refShorthandDefaultPos) {1318if (this.eat(tt.colon)) {1319prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refShorthandDefaultPos);1320prop.kind = "init";1321} else if (this.options.ecmaVersion >= 6 && this.type === tt.parenL) {1322if (isPattern) this.unexpected();1323prop.kind = "init";1324prop.method = true;1325prop.value = this.parseMethod(isGenerator);1326} else if (this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && (this.type != tt.comma && this.type != tt.braceR)) {1327if (isGenerator || isPattern) this.unexpected();1328prop.kind = prop.key.name;1329this.parsePropertyName(prop);1330prop.value = this.parseMethod(false);1331} else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {1332prop.kind = "init";1333if (isPattern) {1334if (this.isKeyword(prop.key.name) || this.strict && (reservedWords.strictBind(prop.key.name) || reservedWords.strict(prop.key.name)) || !this.options.allowReserved && this.isReservedWord(prop.key.name)) this.raise(prop.key.start, "Binding " + prop.key.name);1335prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);1336} else if (this.type === tt.eq && refShorthandDefaultPos) {1337if (!refShorthandDefaultPos.start) refShorthandDefaultPos.start = this.start;1338prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);1339} else {1340prop.value = prop.key;1341}1342prop.shorthand = true;1343} else this.unexpected();1344};13451346pp.parsePropertyName = function (prop) {1347if (this.options.ecmaVersion >= 6) {1348if (this.eat(tt.bracketL)) {1349prop.computed = true;1350prop.key = this.parseMaybeAssign();1351this.expect(tt.bracketR);1352return prop.key;1353} else {1354prop.computed = false;1355}1356}1357return prop.key = this.type === tt.num || this.type === tt.string ? this.parseExprAtom() : this.parseIdent(true);1358};13591360// Initialize empty function node.13611362pp.initFunction = function (node) {1363node.id = null;1364if (this.options.ecmaVersion >= 6) {1365node.generator = false;1366node.expression = false;1367}1368};13691370// Parse object or class method.13711372pp.parseMethod = function (isGenerator) {1373var node = this.startNode();1374this.initFunction(node);1375this.expect(tt.parenL);1376node.params = this.parseBindingList(tt.parenR, false, false);1377var allowExpressionBody = undefined;1378if (this.options.ecmaVersion >= 6) {1379node.generator = isGenerator;1380allowExpressionBody = true;1381} else {1382allowExpressionBody = false;1383}1384this.parseFunctionBody(node, allowExpressionBody);1385return this.finishNode(node, "FunctionExpression");1386};13871388// Parse arrow function expression with given parameters.13891390pp.parseArrowExpression = function (node, params) {1391this.initFunction(node);1392node.params = this.toAssignableList(params, true);1393this.parseFunctionBody(node, true);1394return this.finishNode(node, "ArrowFunctionExpression");1395};13961397// Parse function body and check parameters.13981399pp.parseFunctionBody = function (node, allowExpression) {1400var isExpression = allowExpression && this.type !== tt.braceL;14011402if (isExpression) {1403node.body = this.parseMaybeAssign();1404node.expression = true;1405} else {1406// Start a new scope with regard to labels and the `inFunction`1407// flag (restore them to their old value afterwards).1408var oldInFunc = this.inFunction,1409oldInGen = this.inGenerator,1410oldLabels = this.labels;1411this.inFunction = true;this.inGenerator = node.generator;this.labels = [];1412node.body = this.parseBlock(true);1413node.expression = false;1414this.inFunction = oldInFunc;this.inGenerator = oldInGen;this.labels = oldLabels;1415}14161417// If this is a strict mode function, verify that argument names1418// are not repeated, and it does not try to bind the words `eval`1419// or `arguments`.1420if (this.strict || !isExpression && node.body.body.length && this.isUseStrict(node.body.body[0])) {1421var nameHash = {},1422oldStrict = this.strict;1423this.strict = true;1424if (node.id) this.checkLVal(node.id, true);1425for (var i = 0; i < node.params.length; i++) {1426this.checkLVal(node.params[i], true, nameHash);1427}this.strict = oldStrict;1428}1429};14301431// Parses a comma-separated list of expressions, and returns them as1432// an array. `close` is the token type that ends the list, and1433// `allowEmpty` can be turned on to allow subsequent commas with1434// nothing in between them to be parsed as `null` (which is needed1435// for array literals).14361437pp.parseExprList = function (close, allowTrailingComma, allowEmpty, refShorthandDefaultPos) {1438var elts = [],1439first = true;1440while (!this.eat(close)) {1441if (!first) {1442this.expect(tt.comma);1443if (allowTrailingComma && this.afterTrailingComma(close)) break;1444} else first = false;14451446if (allowEmpty && this.type === tt.comma) {1447elts.push(null);1448} else {1449if (this.type === tt.ellipsis) elts.push(this.parseSpread(refShorthandDefaultPos));else elts.push(this.parseMaybeAssign(false, refShorthandDefaultPos));1450}1451}1452return elts;1453};14541455// Parse the next token as an identifier. If `liberal` is true (used1456// when parsing properties), it will also convert keywords into1457// identifiers.14581459pp.parseIdent = function (liberal) {1460var node = this.startNode();1461if (liberal && this.options.allowReserved == "never") liberal = false;1462if (this.type === tt.name) {1463if (!liberal && (!this.options.allowReserved && this.isReservedWord(this.value) || this.strict && reservedWords.strict(this.value) && (this.options.ecmaVersion >= 6 || this.input.slice(this.start, this.end).indexOf("\\") == -1))) this.raise(this.start, "The keyword '" + this.value + "' is reserved");1464node.name = this.value;1465} else if (liberal && this.type.keyword) {1466node.name = this.type.keyword;1467} else {1468this.unexpected();1469}1470this.next();1471return this.finishNode(node, "Identifier");1472};14731474// Parses yield expression inside generator.14751476pp.parseYield = function () {1477var node = this.startNode();1478this.next();1479if (this.type == tt.semi || this.canInsertSemicolon() || this.type != tt.star && !this.type.startsExpr) {1480node.delegate = false;1481node.argument = null;1482} else {1483node.delegate = this.eat(tt.star);1484node.argument = this.parseMaybeAssign();1485}1486return this.finishNode(node, "YieldExpression");1487};14881489// Parses array and generator comprehensions.14901491pp.parseComprehension = function (node, isGenerator) {1492node.blocks = [];1493while (this.type === tt._for) {1494var block = this.startNode();1495this.next();1496this.expect(tt.parenL);1497block.left = this.parseBindingAtom();1498this.checkLVal(block.left, true);1499this.expectContextual("of");1500block.right = this.parseExpression();1501this.expect(tt.parenR);1502node.blocks.push(this.finishNode(block, "ComprehensionBlock"));1503}1504node.filter = this.eat(tt._if) ? this.parseParenExpression() : null;1505node.body = this.parseExpression();1506this.expect(isGenerator ? tt.parenR : tt.bracketR);1507node.generator = isGenerator;1508return this.finishNode(node, "ComprehensionExpression");1509};15101511},{"./identifier":7,"./state":13,"./tokentype":17,"./util":18}],7:[function(_dereq_,module,exports){151215131514// Test whether a given character code starts an identifier.15151516"use strict";15171518exports.isIdentifierStart = isIdentifierStart;15191520// Test whether a given character is part of an identifier.15211522exports.isIdentifierChar = isIdentifierChar;1523exports.__esModule = true;1524// This is a trick taken from Esprima. It turns out that, on1525// non-Chrome browsers, to check whether a string is in a set, a1526// predicate containing a big ugly `switch` statement is faster than1527// a regular expression, and on Chrome the two are about on par.1528// This function uses `eval` (non-lexical) to produce such a1529// predicate from a space-separated string of words.1530//1531// It starts by sorting the words by length.15321533function makePredicate(words) {1534words = words.split(" ");1535var f = "",1536cats = [];1537out: for (var i = 0; i < words.length; ++i) {1538for (var j = 0; j < cats.length; ++j) {1539if (cats[j][0].length == words[i].length) {1540cats[j].push(words[i]);1541continue out;1542}1543}cats.push([words[i]]);1544}1545function compareTo(arr) {1546if (arr.length == 1) {1547return f += "return str === " + JSON.stringify(arr[0]) + ";";1548}f += "switch(str){";1549for (var i = 0; i < arr.length; ++i) {1550f += "case " + JSON.stringify(arr[i]) + ":";1551}f += "return true}return false;";1552}15531554// When there are more than three length categories, an outer1555// switch first dispatches on the lengths, to save on comparisons.15561557if (cats.length > 3) {1558cats.sort(function (a, b) {1559return b.length - a.length;1560});1561f += "switch(str.length){";1562for (var i = 0; i < cats.length; ++i) {1563var cat = cats[i];1564f += "case " + cat[0].length + ":";1565compareTo(cat);1566}1567f += "}"15681569// Otherwise, simply generate a flat `switch` statement.15701571;1572} else {1573compareTo(words);1574}1575return new Function("str", f);1576}15771578// Reserved word lists for various dialects of the language15791580var reservedWords = {15813: makePredicate("abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile"),15825: makePredicate("class enum extends super const export import"),15836: makePredicate("enum await"),1584strict: makePredicate("implements interface let package private protected public static yield"),1585strictBind: makePredicate("eval arguments")1586};15871588exports.reservedWords = reservedWords;1589// And the keywords15901591var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this";15921593var keywords = {15945: makePredicate(ecma5AndLessKeywords),15956: makePredicate(ecma5AndLessKeywords + " let const class extends export import yield super")1596};15971598exports.keywords = keywords;1599// ## Character categories16001601// Big ugly regular expressions that match characters in the1602// whitespace, identifier, and identifier-start categories. These1603// are only applied when a character is found to actually have a1604// code point above 128.1605// Generated by `tools/generate-identifier-regex.js`.16061607var nonASCIIidentifierStartChars = "ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠ-ࢲऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞭꞰꞱꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭟꭤꭥꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ";1608var nonASCIIidentifierChars = "·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣤ-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఃా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഁ-ഃാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏ᦰ-ᧀᧈᧉ᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳸᳹᷀-᷵᷼-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-꣄꣐-꣙꣠-꣱꤀-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︭︳︴﹍-﹏0-9_";16091610var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");1611var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");16121613nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;16141615// These are a run-length and offset encoded representation of the1616// >0xffff code points that are a valid part of identifiers. The1617// offset starts at 0x10000, and each pair of numbers represents an1618// offset to the next range, and then a size of the range. They were1619// generated by tools/generate-identifier-regex.js1620var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 17, 26, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 99, 39, 9, 51, 157, 310, 10, 21, 11, 7, 153, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 98, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 26, 45, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 955, 52, 76, 44, 33, 24, 27, 35, 42, 34, 4, 0, 13, 47, 15, 3, 22, 0, 38, 17, 2, 24, 133, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 32, 4, 287, 47, 21, 1, 2, 0, 185, 46, 82, 47, 21, 0, 60, 42, 502, 63, 32, 0, 449, 56, 1288, 920, 104, 110, 2962, 1070, 13266, 568, 8, 30, 114, 29, 19, 47, 17, 3, 32, 20, 6, 18, 881, 68, 12, 0, 67, 12, 16481, 1, 3071, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 4149, 196, 1340, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42710, 42, 4148, 12, 221, 16355, 541];1621var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 1306, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 52, 0, 13, 2, 49, 13, 16, 9, 83, 11, 168, 11, 6, 9, 8, 2, 57, 0, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 316, 19, 13, 9, 214, 6, 3, 8, 112, 16, 16, 9, 82, 12, 9, 9, 535, 9, 20855, 9, 135, 4, 60, 6, 26, 9, 1016, 45, 17, 3, 19723, 1, 5319, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 4305, 6, 792618, 239];16221623// This has a complexity linear to the value of the code. The1624// assumption is that looking up astral identifier characters is1625// rare.1626function isInAstralSet(code, set) {1627var pos = 65536;1628for (var i = 0; i < set.length; i += 2) {1629pos += set[i];1630if (pos > code) {1631return false;1632}pos += set[i + 1];1633if (pos >= code) {1634return true;1635}1636}1637}1638function isIdentifierStart(code, astral) {1639if (code < 65) {1640return code === 36;1641}if (code < 91) {1642return true;1643}if (code < 97) {1644return code === 95;1645}if (code < 123) {1646return true;1647}if (code <= 65535) {1648return code >= 170 && nonASCIIidentifierStart.test(String.fromCharCode(code));1649}if (astral === false) {1650return false;1651}return isInAstralSet(code, astralIdentifierStartCodes);1652}16531654function isIdentifierChar(code, astral) {1655if (code < 48) {1656return code === 36;1657}if (code < 58) {1658return true;1659}if (code < 65) {1660return false;1661}if (code < 91) {1662return true;1663}if (code < 97) {1664return code === 95;1665}if (code < 123) {1666return true;1667}if (code <= 65535) {1668return code >= 170 && nonASCIIidentifier.test(String.fromCharCode(code));1669}if (astral === false) {1670return false;1671}return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);1672}16731674},{}],8:[function(_dereq_,module,exports){1675"use strict";16761677var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };16781679// The `getLineInfo` function is mostly useful when the1680// `locations` option is off (for performance reasons) and you1681// want to find the line/column position for a given character1682// offset. `input` should be the code string that the offset refers1683// into.16841685exports.getLineInfo = getLineInfo;1686exports.__esModule = true;16871688var Parser = _dereq_("./state").Parser;16891690var lineBreakG = _dereq_("./whitespace").lineBreakG;16911692var deprecate = _dereq_("util").deprecate;16931694// These are used when `options.locations` is on, for the1695// `startLoc` and `endLoc` properties.16961697var Position = exports.Position = (function () {1698function Position(line, col) {1699_classCallCheck(this, Position);17001701this.line = line;1702this.column = col;1703}17041705Position.prototype.offset = function offset(n) {1706return new Position(this.line, this.column + n);1707};17081709return Position;1710})();17111712var SourceLocation = exports.SourceLocation = function SourceLocation(p, start, end) {1713_classCallCheck(this, SourceLocation);17141715this.start = start;1716this.end = end;1717if (p.sourceFile !== null) this.source = p.sourceFile;1718};17191720function getLineInfo(input, offset) {1721for (var line = 1, cur = 0;;) {1722lineBreakG.lastIndex = cur;1723var match = lineBreakG.exec(input);1724if (match && match.index < offset) {1725++line;1726cur = match.index + match[0].length;1727} else {1728return new Position(line, offset - cur);1729}1730}1731}17321733var pp = Parser.prototype;17341735// This function is used to raise exceptions on parse errors. It1736// takes an offset integer (into the current `input`) to indicate1737// the location of the error, attaches the position to the end1738// of the error message, and then raises a `SyntaxError` with that1739// message.17401741pp.raise = function (pos, message) {1742var loc = getLineInfo(this.input, pos);1743message += " (" + loc.line + ":" + loc.column + ")";1744var err = new SyntaxError(message);1745err.pos = pos;err.loc = loc;err.raisedAt = this.pos;1746throw err;1747};17481749pp.curPosition = function () {1750return new Position(this.curLine, this.pos - this.lineStart);1751};17521753pp.markPosition = function () {1754return this.options.locations ? [this.start, this.startLoc] : this.start;1755};17561757},{"./state":13,"./whitespace":19,"util":5}],9:[function(_dereq_,module,exports){1758"use strict";17591760var tt = _dereq_("./tokentype").types;17611762var Parser = _dereq_("./state").Parser;17631764var reservedWords = _dereq_("./identifier").reservedWords;17651766var has = _dereq_("./util").has;17671768var pp = Parser.prototype;17691770// Convert existing expression atom to assignable pattern1771// if possible.17721773pp.toAssignable = function (node, isBinding) {1774if (this.options.ecmaVersion >= 6 && node) {1775switch (node.type) {1776case "Identifier":1777case "ObjectPattern":1778case "ArrayPattern":1779case "AssignmentPattern":1780break;17811782case "ObjectExpression":1783node.type = "ObjectPattern";1784for (var i = 0; i < node.properties.length; i++) {1785var prop = node.properties[i];1786if (prop.kind !== "init") this.raise(prop.key.start, "Object pattern can't contain getter or setter");1787this.toAssignable(prop.value, isBinding);1788}1789break;17901791case "ArrayExpression":1792node.type = "ArrayPattern";1793this.toAssignableList(node.elements, isBinding);1794break;17951796case "AssignmentExpression":1797if (node.operator === "=") {1798node.type = "AssignmentPattern";1799} else {1800this.raise(node.left.end, "Only '=' operator can be used for specifying default value.");1801}1802break;18031804case "ParenthesizedExpression":1805node.expression = this.toAssignable(node.expression, isBinding);1806break;18071808case "MemberExpression":1809if (!isBinding) break;18101811default:1812this.raise(node.start, "Assigning to rvalue");1813}1814}1815return node;1816};18171818// Convert list of expression atoms to binding list.18191820pp.toAssignableList = function (exprList, isBinding) {1821var end = exprList.length;1822if (end) {1823var last = exprList[end - 1];1824if (last && last.type == "RestElement") {1825--end;1826} else if (last && last.type == "SpreadElement") {1827last.type = "RestElement";1828var arg = last.argument;1829this.toAssignable(arg, isBinding);1830if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern") this.unexpected(arg.start);1831--end;1832}1833}1834for (var i = 0; i < end; i++) {1835var elt = exprList[i];1836if (elt) this.toAssignable(elt, isBinding);1837}1838return exprList;1839};18401841// Parses spread element.18421843pp.parseSpread = function (refShorthandDefaultPos) {1844var node = this.startNode();1845this.next();1846node.argument = this.parseMaybeAssign(refShorthandDefaultPos);1847return this.finishNode(node, "SpreadElement");1848};18491850pp.parseRest = function () {1851var node = this.startNode();1852this.next();1853node.argument = this.type === tt.name || this.type === tt.bracketL ? this.parseBindingAtom() : this.unexpected();1854return this.finishNode(node, "RestElement");1855};18561857// Parses lvalue (assignable) atom.18581859pp.parseBindingAtom = function () {1860if (this.options.ecmaVersion < 6) return this.parseIdent();1861switch (this.type) {1862case tt.name:1863return this.parseIdent();18641865case tt.bracketL:1866var node = this.startNode();1867this.next();1868node.elements = this.parseBindingList(tt.bracketR, true, true);1869return this.finishNode(node, "ArrayPattern");18701871case tt.braceL:1872return this.parseObj(true);18731874default:1875this.unexpected();1876}1877};18781879pp.parseBindingList = function (close, allowEmpty, allowTrailingComma) {1880var elts = [],1881first = true;1882while (!this.eat(close)) {1883if (first) first = false;else this.expect(tt.comma);1884if (allowEmpty && this.type === tt.comma) {1885elts.push(null);1886} else if (allowTrailingComma && this.afterTrailingComma(close)) {1887break;1888} else if (this.type === tt.ellipsis) {1889var rest = this.parseRest();1890this.parseBindingListItem(rest);1891elts.push(rest);1892this.expect(close);1893break;1894} else {1895var elem = this.parseMaybeDefault(this.start, this.startLoc);1896this.parseBindingListItem(elem);1897elts.push(elem);1898}1899}1900return elts;1901};19021903pp.parseBindingListItem = function (param) {1904return param;1905};19061907// Parses assignment pattern around given atom if possible.19081909pp.parseMaybeDefault = function (startPos, startLoc, left) {1910if (Array.isArray(startPos)) {1911if (this.options.locations && noCalls === undefined) {1912// shift arguments to left by one1913left = startLoc;1914// flatten startPos1915startLoc = startPos[1];1916startPos = startPos[0];1917}1918}1919left = left || this.parseBindingAtom();1920if (!this.eat(tt.eq)) return left;1921var node = this.startNodeAt(startPos, startLoc);1922node.operator = "=";1923node.left = left;1924node.right = this.parseMaybeAssign();1925return this.finishNode(node, "AssignmentPattern");1926};19271928// Verify that a node is an lval — something that can be assigned1929// to.19301931pp.checkLVal = function (expr, isBinding, checkClashes) {1932switch (expr.type) {1933case "Identifier":1934if (this.strict && (reservedWords.strictBind(expr.name) || reservedWords.strict(expr.name))) this.raise(expr.start, (isBinding ? "Binding " : "Assigning to ") + expr.name + " in strict mode");1935if (checkClashes) {1936if (has(checkClashes, expr.name)) this.raise(expr.start, "Argument name clash in strict mode");1937checkClashes[expr.name] = true;1938}1939break;19401941case "MemberExpression":1942if (isBinding) this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " member expression");1943break;19441945case "ObjectPattern":1946for (var i = 0; i < expr.properties.length; i++) {1947this.checkLVal(expr.properties[i].value, isBinding, checkClashes);1948}break;19491950case "ArrayPattern":1951for (var i = 0; i < expr.elements.length; i++) {1952var elem = expr.elements[i];1953if (elem) this.checkLVal(elem, isBinding, checkClashes);1954}1955break;19561957case "AssignmentPattern":1958this.checkLVal(expr.left, isBinding, checkClashes);1959break;19601961case "RestElement":1962this.checkLVal(expr.argument, isBinding, checkClashes);1963break;19641965case "ParenthesizedExpression":1966this.checkLVal(expr.expression, isBinding, checkClashes);1967break;19681969default:1970this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " rvalue");1971}1972};19731974},{"./identifier":7,"./state":13,"./tokentype":17,"./util":18}],10:[function(_dereq_,module,exports){1975"use strict";19761977var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };19781979exports.__esModule = true;19801981var Parser = _dereq_("./state").Parser;19821983var SourceLocation = _dereq_("./location").SourceLocation;19841985// Start an AST node, attaching a start offset.19861987var pp = Parser.prototype;19881989var Node = exports.Node = function Node() {1990_classCallCheck(this, Node);1991};19921993pp.startNode = function () {1994var node = new Node();1995node.start = this.start;1996if (this.options.locations) node.loc = new SourceLocation(this, this.startLoc);1997if (this.options.directSourceFile) node.sourceFile = this.options.directSourceFile;1998if (this.options.ranges) node.range = [this.start, 0];1999return node;2000};20012002pp.startNodeAt = function (pos, loc) {2003var node = new Node();2004if (Array.isArray(pos)) {2005if (this.options.locations && loc === undefined) {2006// flatten pos2007loc = pos[1];2008pos = pos[0];2009}2010}2011node.start = pos;2012if (this.options.locations) node.loc = new SourceLocation(this, loc);2013if (this.options.directSourceFile) node.sourceFile = this.options.directSourceFile;2014if (this.options.ranges) node.range = [pos, 0];2015return node;2016};20172018// Finish an AST node, adding `type` and `end` properties.20192020pp.finishNode = function (node, type) {2021node.type = type;2022node.end = this.lastTokEnd;2023if (this.options.locations) node.loc.end = this.lastTokEndLoc;2024if (this.options.ranges) node.range[1] = this.lastTokEnd;2025return node;2026};20272028// Finish node at given position20292030pp.finishNodeAt = function (node, type, pos, loc) {2031node.type = type;2032if (Array.isArray(pos)) {2033if (this.options.locations && loc === undefined) {2034// flatten pos2035loc = pos[1];2036pos = pos[0];2037}2038}2039node.end = pos;2040if (this.options.locations) node.loc.end = loc;2041if (this.options.ranges) node.range[1] = pos;2042return node;2043};20442045},{"./location":8,"./state":13}],11:[function(_dereq_,module,exports){204620472048// Interpret and default an options object20492050"use strict";20512052exports.getOptions = getOptions;2053exports.__esModule = true;20542055var _util = _dereq_("./util");20562057var has = _util.has;2058var isArray = _util.isArray;20592060var SourceLocation = _dereq_("./location").SourceLocation;20612062// A second optional argument can be given to further configure2063// the parser process. These options are recognized:20642065var defaultOptions = {2066// `ecmaVersion` indicates the ECMAScript version to parse. Must2067// be either 3, or 5, or 6. This influences support for strict2068// mode, the set of reserved words, support for getters and2069// setters and other features.2070ecmaVersion: 5,2071// Source type ("script" or "module") for different semantics2072sourceType: "script",2073// `onInsertedSemicolon` can be a callback that will be called2074// when a semicolon is automatically inserted. It will be passed2075// th position of the comma as an offset, and if `locations` is2076// enabled, it is given the location as a `{line, column}` object2077// as second argument.2078onInsertedSemicolon: null,2079// `onTrailingComma` is similar to `onInsertedSemicolon`, but for2080// trailing commas.2081onTrailingComma: null,2082// By default, reserved words are not enforced. Disable2083// `allowReserved` to enforce them. When this option has the2084// value "never", reserved words and keywords can also not be2085// used as property names.2086allowReserved: true,2087// When enabled, a return at the top level is not considered an2088// error.2089allowReturnOutsideFunction: false,2090// When enabled, import/export statements are not constrained to2091// appearing at the top of the program.2092allowImportExportEverywhere: false,2093// When enabled, hashbang directive in the beginning of file2094// is allowed and treated as a line comment.2095allowHashBang: false,2096// When `locations` is on, `loc` properties holding objects with2097// `start` and `end` properties in `{line, column}` form (with2098// line being 1-based and column 0-based) will be attached to the2099// nodes.2100locations: false,2101// A function can be passed as `onToken` option, which will2102// cause Acorn to call that function with object in the same2103// format as tokenize() returns. Note that you are not2104// allowed to call the parser from the callback—that will2105// corrupt its internal state.2106onToken: null,2107// A function can be passed as `onComment` option, which will2108// cause Acorn to call that function with `(block, text, start,2109// end)` parameters whenever a comment is skipped. `block` is a2110// boolean indicating whether this is a block (`/* */`) comment,2111// `text` is the content of the comment, and `start` and `end` are2112// character offsets that denote the start and end of the comment.2113// When the `locations` option is on, two more parameters are2114// passed, the full `{line, column}` locations of the start and2115// end of the comments. Note that you are not allowed to call the2116// parser from the callback—that will corrupt its internal state.2117onComment: null,2118// Nodes have their start and end characters offsets recorded in2119// `start` and `end` properties (directly on the node, rather than2120// the `loc` object, which holds line/column data. To also add a2121// [semi-standardized][range] `range` property holding a `[start,2122// end]` array with the same numbers, set the `ranges` option to2123// `true`.2124//2125// [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=7456782126ranges: false,2127// It is possible to parse multiple files into a single AST by2128// passing the tree produced by parsing the first file as2129// `program` option in subsequent parses. This will add the2130// toplevel forms of the parsed file to the `Program` (top) node2131// of an existing parse tree.2132program: null,2133// When `locations` is on, you can pass this to record the source2134// file in every node's `loc` object.2135sourceFile: null,2136// This value, if given, is stored in every node, whether2137// `locations` is on or off.2138directSourceFile: null,2139// When enabled, parenthesized expressions are represented by2140// (non-standard) ParenthesizedExpression nodes2141preserveParens: false,2142plugins: {}2143};exports.defaultOptions = defaultOptions;21442145function getOptions(opts) {2146var options = {};2147for (var opt in defaultOptions) {2148options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt];2149}if (isArray(options.onToken)) {2150(function () {2151var tokens = options.onToken;2152options.onToken = function (token) {2153return tokens.push(token);2154};2155})();2156}2157if (isArray(options.onComment)) options.onComment = pushComment(options, options.onComment);21582159return options;2160}21612162function pushComment(options, array) {2163return function (block, text, start, end, startLoc, endLoc) {2164var comment = {2165type: block ? "Block" : "Line",2166value: text,2167start: start,2168end: end2169};2170if (options.locations) comment.loc = new SourceLocation(this, startLoc, endLoc);2171if (options.ranges) comment.range = [start, end];2172array.push(comment);2173};2174}21752176},{"./location":8,"./util":18}],12:[function(_dereq_,module,exports){2177"use strict";21782179var tt = _dereq_("./tokentype").types;21802181var Parser = _dereq_("./state").Parser;21822183var lineBreak = _dereq_("./whitespace").lineBreak;21842185var pp = Parser.prototype;21862187// ## Parser utilities21882189// Test whether a statement node is the string literal `"use strict"`.21902191pp.isUseStrict = function (stmt) {2192return this.options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && stmt.expression.value === "use strict";2193};21942195// Predicate that tests whether the next token is of the given2196// type, and if yes, consumes it as a side effect.21972198pp.eat = function (type) {2199if (this.type === type) {2200this.next();2201return true;2202} else {2203return false;2204}2205};22062207// Tests whether parsed token is a contextual keyword.22082209pp.isContextual = function (name) {2210return this.type === tt.name && this.value === name;2211};22122213// Consumes contextual keyword if possible.22142215pp.eatContextual = function (name) {2216return this.value === name && this.eat(tt.name);2217};22182219// Asserts that following token is given contextual keyword.22202221pp.expectContextual = function (name) {2222if (!this.eatContextual(name)) this.unexpected();2223};22242225// Test whether a semicolon can be inserted at the current position.22262227pp.canInsertSemicolon = function () {2228return this.type === tt.eof || this.type === tt.braceR || lineBreak.test(this.input.slice(this.lastTokEnd, this.start));2229};22302231pp.insertSemicolon = function () {2232if (this.canInsertSemicolon()) {2233if (this.options.onInsertedSemicolon) this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc);2234return true;2235}2236};22372238// Consume a semicolon, or, failing that, see if we are allowed to2239// pretend that there is a semicolon at this position.22402241pp.semicolon = function () {2242if (!this.eat(tt.semi) && !this.insertSemicolon()) this.unexpected();2243};22442245pp.afterTrailingComma = function (tokType) {2246if (this.type == tokType) {2247if (this.options.onTrailingComma) this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc);2248this.next();2249return true;2250}2251};22522253// Expect a token of a given type. If found, consume it, otherwise,2254// raise an unexpected token error.22552256pp.expect = function (type) {2257this.eat(type) || this.unexpected();2258};22592260// Raise an unexpected token error.22612262pp.unexpected = function (pos) {2263this.raise(pos != null ? pos : this.start, "Unexpected token");2264};22652266},{"./state":13,"./tokentype":17,"./whitespace":19}],13:[function(_dereq_,module,exports){2267"use strict";22682269exports.Parser = Parser;2270exports.__esModule = true;22712272var _identifier = _dereq_("./identifier");22732274var reservedWords = _identifier.reservedWords;2275var keywords = _identifier.keywords;22762277var tt = _dereq_("./tokentype").types;22782279var lineBreak = _dereq_("./whitespace").lineBreak;22802281function Parser(options, input, startPos) {2282this.options = options;2283this.sourceFile = this.options.sourceFile || null;2284this.isKeyword = keywords[this.options.ecmaVersion >= 6 ? 6 : 5];2285this.isReservedWord = reservedWords[this.options.ecmaVersion];2286this.input = input;22872288// Load plugins2289this.loadPlugins(this.options.plugins);22902291// Set up token state22922293// The current position of the tokenizer in the input.2294if (startPos) {2295this.pos = startPos;2296this.lineStart = Math.max(0, this.input.lastIndexOf("\n", startPos));2297this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;2298} else {2299this.pos = this.lineStart = 0;2300this.curLine = 1;2301}23022303// Properties of the current token:2304// Its type2305this.type = tt.eof;2306// For tokens that include more information than their type, the value2307this.value = null;2308// Its start and end offset2309this.start = this.end = this.pos;2310// And, if locations are used, the {line, column} object2311// corresponding to those offsets2312this.startLoc = this.endLoc = null;23132314// Position information for the previous token2315this.lastTokEndLoc = this.lastTokStartLoc = null;2316this.lastTokStart = this.lastTokEnd = this.pos;23172318// The context stack is used to superficially track syntactic2319// context to predict whether a regular expression is allowed in a2320// given position.2321this.context = this.initialContext();2322this.exprAllowed = true;23232324// Figure out if it's a module code.2325this.strict = this.inModule = this.options.sourceType === "module";23262327// Used to signify the start of a potential arrow function2328this.potentialArrowAt = -1;23292330// Flags to track whether we are in a function, a generator.2331this.inFunction = this.inGenerator = false;2332// Labels in scope.2333this.labels = [];23342335// If enabled, skip leading hashbang line.2336if (this.pos === 0 && this.options.allowHashBang && this.input.slice(0, 2) === "#!") this.skipLineComment(2);2337}23382339Parser.prototype.extend = function (name, f) {2340this[name] = f(this[name]);2341};23422343// Registered plugins23442345var plugins = {};23462347exports.plugins = plugins;2348Parser.prototype.loadPlugins = function (plugins) {2349for (var _name in plugins) {2350var plugin = exports.plugins[_name];2351if (!plugin) throw new Error("Plugin '" + _name + "' not found");2352plugin(this, plugins[_name]);2353}2354};23552356},{"./identifier":7,"./tokentype":17,"./whitespace":19}],14:[function(_dereq_,module,exports){2357"use strict";23582359var tt = _dereq_("./tokentype").types;23602361var Parser = _dereq_("./state").Parser;23622363var lineBreak = _dereq_("./whitespace").lineBreak;23642365var pp = Parser.prototype;23662367// ### Statement parsing23682369// Parse a program. Initializes the parser, reads any number of2370// statements, and wraps them in a Program node. Optionally takes a2371// `program` argument. If present, the statements will be appended2372// to its body instead of creating a new node.23732374pp.parseTopLevel = function (node) {2375var first = true;2376if (!node.body) node.body = [];2377while (this.type !== tt.eof) {2378var stmt = this.parseStatement(true, true);2379node.body.push(stmt);2380if (first && this.isUseStrict(stmt)) this.setStrict(true);2381first = false;2382}2383this.next();2384if (this.options.ecmaVersion >= 6) {2385node.sourceType = this.options.sourceType;2386}2387return this.finishNode(node, "Program");2388};23892390var loopLabel = { kind: "loop" },2391switchLabel = { kind: "switch" };23922393// Parse a single statement.2394//2395// If expecting a statement and finding a slash operator, parse a2396// regular expression literal. This is to handle cases like2397// `if (foo) /blah/.exec(foo)`, where looking at the previous token2398// does not help.23992400pp.parseStatement = function (declaration, topLevel) {2401var starttype = this.type,2402node = this.startNode();24032404// Most types of statements are recognized by the keyword they2405// start with. Many are trivial to parse, some require a bit of2406// complexity.24072408switch (starttype) {2409case tt._break:case tt._continue:2410return this.parseBreakContinueStatement(node, starttype.keyword);2411case tt._debugger:2412return this.parseDebuggerStatement(node);2413case tt._do:2414return this.parseDoStatement(node);2415case tt._for:2416return this.parseForStatement(node);2417case tt._function:2418if (!declaration && this.options.ecmaVersion >= 6) this.unexpected();2419return this.parseFunctionStatement(node);2420case tt._class:2421if (!declaration) this.unexpected();2422return this.parseClass(node, true);2423case tt._if:2424return this.parseIfStatement(node);2425case tt._return:2426return this.parseReturnStatement(node);2427case tt._switch:2428return this.parseSwitchStatement(node);2429case tt._throw:2430return this.parseThrowStatement(node);2431case tt._try:2432return this.parseTryStatement(node);2433case tt._let:case tt._const:2434if (!declaration) this.unexpected(); // NOTE: falls through to _var2435case tt._var:2436return this.parseVarStatement(node, starttype);2437case tt._while:2438return this.parseWhileStatement(node);2439case tt._with:2440return this.parseWithStatement(node);2441case tt.braceL:2442return this.parseBlock();2443case tt.semi:2444return this.parseEmptyStatement(node);2445case tt._export:2446case tt._import:2447if (!this.options.allowImportExportEverywhere) {2448if (!topLevel) this.raise(this.start, "'import' and 'export' may only appear at the top level");2449if (!this.inModule) this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");2450}2451return starttype === tt._import ? this.parseImport(node) : this.parseExport(node);24522453// If the statement does not start with a statement keyword or a2454// brace, it's an ExpressionStatement or LabeledStatement. We2455// simply start parsing an expression, and afterwards, if the2456// next token is a colon and the expression was a simple2457// Identifier node, we switch to interpreting it as a label.2458default:2459var maybeName = this.value,2460expr = this.parseExpression();2461if (starttype === tt.name && expr.type === "Identifier" && this.eat(tt.colon)) return this.parseLabeledStatement(node, maybeName, expr);else return this.parseExpressionStatement(node, expr);2462}2463};24642465pp.parseBreakContinueStatement = function (node, keyword) {2466var isBreak = keyword == "break";2467this.next();2468if (this.eat(tt.semi) || this.insertSemicolon()) node.label = null;else if (this.type !== tt.name) this.unexpected();else {2469node.label = this.parseIdent();2470this.semicolon();2471}24722473// Verify that there is an actual destination to break or2474// continue to.2475for (var i = 0; i < this.labels.length; ++i) {2476var lab = this.labels[i];2477if (node.label == null || lab.name === node.label.name) {2478if (lab.kind != null && (isBreak || lab.kind === "loop")) break;2479if (node.label && isBreak) break;2480}2481}2482if (i === this.labels.length) this.raise(node.start, "Unsyntactic " + keyword);2483return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");2484};24852486pp.parseDebuggerStatement = function (node) {2487this.next();2488this.semicolon();2489return this.finishNode(node, "DebuggerStatement");2490};24912492pp.parseDoStatement = function (node) {2493this.next();2494this.labels.push(loopLabel);2495node.body = this.parseStatement(false);2496this.labels.pop();2497this.expect(tt._while);2498node.test = this.parseParenExpression();2499if (this.options.ecmaVersion >= 6) this.eat(tt.semi);else this.semicolon();2500return this.finishNode(node, "DoWhileStatement");2501};25022503// Disambiguating between a `for` and a `for`/`in` or `for`/`of`2504// loop is non-trivial. Basically, we have to parse the init `var`2505// statement or expression, disallowing the `in` operator (see2506// the second parameter to `parseExpression`), and then check2507// whether the next token is `in` or `of`. When there is no init2508// part (semicolon immediately after the opening parenthesis), it2509// is a regular `for` loop.25102511pp.parseForStatement = function (node) {2512this.next();2513this.labels.push(loopLabel);2514this.expect(tt.parenL);2515if (this.type === tt.semi) return this.parseFor(node, null);2516if (this.type === tt._var || this.type === tt._let || this.type === tt._const) {2517var _init = this.startNode(),2518varKind = this.type;2519this.next();2520this.parseVar(_init, true, varKind);2521this.finishNode(_init, "VariableDeclaration");2522if ((this.type === tt._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) && _init.declarations.length === 1 && !(varKind !== tt._var && _init.declarations[0].init)) return this.parseForIn(node, _init);2523return this.parseFor(node, _init);2524}2525var refShorthandDefaultPos = { start: 0 };2526var init = this.parseExpression(true, refShorthandDefaultPos);2527if (this.type === tt._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) {2528this.toAssignable(init);2529this.checkLVal(init);2530return this.parseForIn(node, init);2531} else if (refShorthandDefaultPos.start) {2532this.unexpected(refShorthandDefaultPos.start);2533}2534return this.parseFor(node, init);2535};25362537pp.parseFunctionStatement = function (node) {2538this.next();2539return this.parseFunction(node, true);2540};25412542pp.parseIfStatement = function (node) {2543this.next();2544node.test = this.parseParenExpression();2545node.consequent = this.parseStatement(false);2546node.alternate = this.eat(tt._else) ? this.parseStatement(false) : null;2547return this.finishNode(node, "IfStatement");2548};25492550pp.parseReturnStatement = function (node) {2551if (!this.inFunction && !this.options.allowReturnOutsideFunction) this.raise(this.start, "'return' outside of function");2552this.next();25532554// In `return` (and `break`/`continue`), the keywords with2555// optional arguments, we eagerly look for a semicolon or the2556// possibility to insert one.25572558if (this.eat(tt.semi) || this.insertSemicolon()) node.argument = null;else {2559node.argument = this.parseExpression();this.semicolon();2560}2561return this.finishNode(node, "ReturnStatement");2562};25632564pp.parseSwitchStatement = function (node) {2565this.next();2566node.discriminant = this.parseParenExpression();2567node.cases = [];2568this.expect(tt.braceL);2569this.labels.push(switchLabel);25702571// Statements under must be grouped (by label) in SwitchCase2572// nodes. `cur` is used to keep the node that we are currently2573// adding statements to.25742575for (var cur, sawDefault; this.type != tt.braceR;) {2576if (this.type === tt._case || this.type === tt._default) {2577var isCase = this.type === tt._case;2578if (cur) this.finishNode(cur, "SwitchCase");2579node.cases.push(cur = this.startNode());2580cur.consequent = [];2581this.next();2582if (isCase) {2583cur.test = this.parseExpression();2584} else {2585if (sawDefault) this.raise(this.lastTokStart, "Multiple default clauses");2586sawDefault = true;2587cur.test = null;2588}2589this.expect(tt.colon);2590} else {2591if (!cur) this.unexpected();2592cur.consequent.push(this.parseStatement(true));2593}2594}2595if (cur) this.finishNode(cur, "SwitchCase");2596this.next(); // Closing brace2597this.labels.pop();2598return this.finishNode(node, "SwitchStatement");2599};26002601pp.parseThrowStatement = function (node) {2602this.next();2603if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) this.raise(this.lastTokEnd, "Illegal newline after throw");2604node.argument = this.parseExpression();2605this.semicolon();2606return this.finishNode(node, "ThrowStatement");2607};26082609// Reused empty array added for node fields that are always empty.26102611var empty = [];26122613pp.parseTryStatement = function (node) {2614this.next();2615node.block = this.parseBlock();2616node.handler = null;2617if (this.type === tt._catch) {2618var clause = this.startNode();2619this.next();2620this.expect(tt.parenL);2621clause.param = this.parseBindingAtom();2622this.checkLVal(clause.param, true);2623this.expect(tt.parenR);2624clause.guard = null;2625clause.body = this.parseBlock();2626node.handler = this.finishNode(clause, "CatchClause");2627}2628node.guardedHandlers = empty;2629node.finalizer = this.eat(tt._finally) ? this.parseBlock() : null;2630if (!node.handler && !node.finalizer) this.raise(node.start, "Missing catch or finally clause");2631return this.finishNode(node, "TryStatement");2632};26332634pp.parseVarStatement = function (node, kind) {2635this.next();2636this.parseVar(node, false, kind);2637this.semicolon();2638return this.finishNode(node, "VariableDeclaration");2639};26402641pp.parseWhileStatement = function (node) {2642this.next();2643node.test = this.parseParenExpression();2644this.labels.push(loopLabel);2645node.body = this.parseStatement(false);2646this.labels.pop();2647return this.finishNode(node, "WhileStatement");2648};26492650pp.parseWithStatement = function (node) {2651if (this.strict) this.raise(this.start, "'with' in strict mode");2652this.next();2653node.object = this.parseParenExpression();2654node.body = this.parseStatement(false);2655return this.finishNode(node, "WithStatement");2656};26572658pp.parseEmptyStatement = function (node) {2659this.next();2660return this.finishNode(node, "EmptyStatement");2661};26622663pp.parseLabeledStatement = function (node, maybeName, expr) {2664for (var i = 0; i < this.labels.length; ++i) {2665if (this.labels[i].name === maybeName) this.raise(expr.start, "Label '" + maybeName + "' is already declared");2666}var kind = this.type.isLoop ? "loop" : this.type === tt._switch ? "switch" : null;2667this.labels.push({ name: maybeName, kind: kind });2668node.body = this.parseStatement(true);2669this.labels.pop();2670node.label = expr;2671return this.finishNode(node, "LabeledStatement");2672};26732674pp.parseExpressionStatement = function (node, expr) {2675node.expression = expr;2676this.semicolon();2677return this.finishNode(node, "ExpressionStatement");2678};26792680// Parse a semicolon-enclosed block of statements, handling `"use2681// strict"` declarations when `allowStrict` is true (used for2682// function bodies).26832684pp.parseBlock = function (allowStrict) {2685var node = this.startNode(),2686first = true,2687oldStrict = undefined;2688node.body = [];2689this.expect(tt.braceL);2690while (!this.eat(tt.braceR)) {2691var stmt = this.parseStatement(true);2692node.body.push(stmt);2693if (first && allowStrict && this.isUseStrict(stmt)) {2694oldStrict = this.strict;2695this.setStrict(this.strict = true);2696}2697first = false;2698}2699if (oldStrict === false) this.setStrict(false);2700return this.finishNode(node, "BlockStatement");2701};27022703// Parse a regular `for` loop. The disambiguation code in2704// `parseStatement` will already have parsed the init statement or2705// expression.27062707pp.parseFor = function (node, init) {2708node.init = init;2709this.expect(tt.semi);2710node.test = this.type === tt.semi ? null : this.parseExpression();2711this.expect(tt.semi);2712node.update = this.type === tt.parenR ? null : this.parseExpression();2713this.expect(tt.parenR);2714node.body = this.parseStatement(false);2715this.labels.pop();2716return this.finishNode(node, "ForStatement");2717};27182719// Parse a `for`/`in` and `for`/`of` loop, which are almost2720// same from parser's perspective.27212722pp.parseForIn = function (node, init) {2723var type = this.type === tt._in ? "ForInStatement" : "ForOfStatement";2724this.next();2725node.left = init;2726node.right = this.parseExpression();2727this.expect(tt.parenR);2728node.body = this.parseStatement(false);2729this.labels.pop();2730return this.finishNode(node, type);2731};27322733// Parse a list of variable declarations.27342735pp.parseVar = function (node, isFor, kind) {2736node.declarations = [];2737node.kind = kind.keyword;2738for (;;) {2739var decl = this.startNode();2740this.parseVarId(decl);2741if (this.eat(tt.eq)) {2742decl.init = this.parseMaybeAssign(isFor);2743} else if (kind === tt._const && !(this.type === tt._in || this.options.ecmaVersion >= 6 && this.isContextual("of"))) {2744this.unexpected();2745} else if (decl.id.type != "Identifier" && !(isFor && (this.type === tt._in || this.isContextual("of")))) {2746this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");2747} else {2748decl.init = null;2749}2750node.declarations.push(this.finishNode(decl, "VariableDeclarator"));2751if (!this.eat(tt.comma)) break;2752}2753return node;2754};27552756pp.parseVarId = function (decl) {2757decl.id = this.parseBindingAtom();2758this.checkLVal(decl.id, true);2759};27602761// Parse a function declaration or literal (depending on the2762// `isStatement` parameter).27632764pp.parseFunction = function (node, isStatement, allowExpressionBody) {2765this.initFunction(node);2766if (this.options.ecmaVersion >= 6) node.generator = this.eat(tt.star);2767if (isStatement || this.type === tt.name) node.id = this.parseIdent();2768this.parseFunctionParams(node);2769this.parseFunctionBody(node, allowExpressionBody);2770return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");2771};27722773pp.parseFunctionParams = function (node) {2774this.expect(tt.parenL);2775node.params = this.parseBindingList(tt.parenR, false, false);2776};27772778// Parse a class declaration or literal (depending on the2779// `isStatement` parameter).27802781pp.parseClass = function (node, isStatement) {2782this.next();2783this.parseClassId(node, isStatement);2784this.parseClassSuper(node);2785var classBody = this.startNode();2786var hadConstructor = false;2787classBody.body = [];2788this.expect(tt.braceL);2789while (!this.eat(tt.braceR)) {2790if (this.eat(tt.semi)) continue;2791var method = this.startNode();2792var isGenerator = this.eat(tt.star);2793var isMaybeStatic = this.type === tt.name && this.value === "static";2794this.parsePropertyName(method);2795method["static"] = isMaybeStatic && this.type !== tt.parenL;2796if (method["static"]) {2797if (isGenerator) this.unexpected();2798isGenerator = this.eat(tt.star);2799this.parsePropertyName(method);2800}2801method.kind = "method";2802if (!method.computed) {2803var key = method.key;28042805var isGetSet = false;2806if (!isGenerator && key.type === "Identifier" && this.type !== tt.parenL && (key.name === "get" || key.name === "set")) {2807isGetSet = true;2808method.kind = key.name;2809key = this.parsePropertyName(method);2810}2811if (!method["static"] && (key.type === "Identifier" && key.name === "constructor" || key.type === "Literal" && key.value === "constructor")) {2812if (hadConstructor) this.raise(key.start, "Duplicate constructor in the same class");2813if (isGetSet) this.raise(key.start, "Constructor can't have get/set modifier");2814if (isGenerator) this.raise(key.start, "Constructor can't be a generator");2815method.kind = "constructor";2816hadConstructor = true;2817}2818}2819this.parseClassMethod(classBody, method, isGenerator);2820}2821node.body = this.finishNode(classBody, "ClassBody");2822return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");2823};28242825pp.parseClassMethod = function (classBody, method, isGenerator) {2826method.value = this.parseMethod(isGenerator);2827classBody.body.push(this.finishNode(method, "MethodDefinition"));2828};28292830pp.parseClassId = function (node, isStatement) {2831node.id = this.type === tt.name ? this.parseIdent() : isStatement ? this.unexpected() : null;2832};28332834pp.parseClassSuper = function (node) {2835node.superClass = this.eat(tt._extends) ? this.parseExprSubscripts() : null;2836};28372838// Parses module export declaration.28392840pp.parseExport = function (node) {2841this.next();2842// export * from '...'2843if (this.eat(tt.star)) {2844this.expectContextual("from");2845node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();2846this.semicolon();2847return this.finishNode(node, "ExportAllDeclaration");2848}2849if (this.eat(tt._default)) {2850// export default ...2851var expr = this.parseMaybeAssign();2852var needsSemi = true;2853if (expr.type == "FunctionExpression" || expr.type == "ClassExpression") {2854needsSemi = false;2855if (expr.id) {2856expr.type = expr.type == "FunctionExpression" ? "FunctionDeclaration" : "ClassDeclaration";2857}2858}2859node.declaration = expr;2860if (needsSemi) this.semicolon();2861return this.finishNode(node, "ExportDefaultDeclaration");2862}2863// export var|const|let|function|class ...2864if (this.shouldParseExportStatement()) {2865node.declaration = this.parseStatement(true);2866node.specifiers = [];2867node.source = null;2868} else {2869// export { x, y as z } [from '...']2870node.declaration = null;2871node.specifiers = this.parseExportSpecifiers();2872if (this.eatContextual("from")) {2873node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();2874} else {2875node.source = null;2876}2877this.semicolon();2878}2879return this.finishNode(node, "ExportNamedDeclaration");2880};28812882pp.shouldParseExportStatement = function () {2883return this.type.keyword;2884};28852886// Parses a comma-separated list of module exports.28872888pp.parseExportSpecifiers = function () {2889var nodes = [],2890first = true;2891// export { x, y as z } [from '...']2892this.expect(tt.braceL);2893while (!this.eat(tt.braceR)) {2894if (!first) {2895this.expect(tt.comma);2896if (this.afterTrailingComma(tt.braceR)) break;2897} else first = false;28982899var node = this.startNode();2900node.local = this.parseIdent(this.type === tt._default);2901node.exported = this.eatContextual("as") ? this.parseIdent(true) : node.local;2902nodes.push(this.finishNode(node, "ExportSpecifier"));2903}2904return nodes;2905};29062907// Parses import declaration.29082909pp.parseImport = function (node) {2910this.next();2911// import '...'2912if (this.type === tt.string) {2913node.specifiers = empty;2914node.source = this.parseExprAtom();2915node.kind = "";2916} else {2917node.specifiers = this.parseImportSpecifiers();2918this.expectContextual("from");2919node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();2920}2921this.semicolon();2922return this.finishNode(node, "ImportDeclaration");2923};29242925// Parses a comma-separated list of module imports.29262927pp.parseImportSpecifiers = function () {2928var nodes = [],2929first = true;2930if (this.type === tt.name) {2931// import defaultObj, { x, y as z } from '...'2932var node = this.startNode();2933node.local = this.parseIdent();2934this.checkLVal(node.local, true);2935nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));2936if (!this.eat(tt.comma)) return nodes;2937}2938if (this.type === tt.star) {2939var node = this.startNode();2940this.next();2941this.expectContextual("as");2942node.local = this.parseIdent();2943this.checkLVal(node.local, true);2944nodes.push(this.finishNode(node, "ImportNamespaceSpecifier"));2945return nodes;2946}2947this.expect(tt.braceL);2948while (!this.eat(tt.braceR)) {2949if (!first) {2950this.expect(tt.comma);2951if (this.afterTrailingComma(tt.braceR)) break;2952} else first = false;29532954var node = this.startNode();2955node.imported = this.parseIdent(true);2956node.local = this.eatContextual("as") ? this.parseIdent() : node.imported;2957this.checkLVal(node.local, true);2958nodes.push(this.finishNode(node, "ImportSpecifier"));2959}2960return nodes;2961};29622963},{"./state":13,"./tokentype":17,"./whitespace":19}],15:[function(_dereq_,module,exports){2964"use strict";29652966var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };29672968exports.__esModule = true;2969// The algorithm used to determine whether a regexp can appear at a2970// given point in the program is loosely based on sweet.js' approach.2971// See https://github.com/mozilla/sweet.js/wiki/design29722973var Parser = _dereq_("./state").Parser;29742975var tt = _dereq_("./tokentype").types;29762977var lineBreak = _dereq_("./whitespace").lineBreak;29782979var TokContext = exports.TokContext = function TokContext(token, isExpr, preserveSpace, override) {2980_classCallCheck(this, TokContext);29812982this.token = token;2983this.isExpr = isExpr;2984this.preserveSpace = preserveSpace;2985this.override = override;2986};29872988var types = {2989b_stat: new TokContext("{", false),2990b_expr: new TokContext("{", true),2991b_tmpl: new TokContext("${", true),2992p_stat: new TokContext("(", false),2993p_expr: new TokContext("(", true),2994q_tmpl: new TokContext("`", true, true, function (p) {2995return p.readTmplToken();2996}),2997f_expr: new TokContext("function", true)2998};29993000exports.types = types;3001var pp = Parser.prototype;30023003pp.initialContext = function () {3004return [types.b_stat];3005};30063007pp.braceIsBlock = function (prevType) {3008var parent = undefined;3009if (prevType === tt.colon && (parent = this.curContext()).token == "{") return !parent.isExpr;3010if (prevType === tt._return) return lineBreak.test(this.input.slice(this.lastTokEnd, this.start));3011if (prevType === tt._else || prevType === tt.semi || prevType === tt.eof) return true;3012if (prevType == tt.braceL) return this.curContext() === types.b_stat;3013return !this.exprAllowed;3014};30153016pp.updateContext = function (prevType) {3017var update = undefined,3018type = this.type;3019if (type.keyword && prevType == tt.dot) this.exprAllowed = false;else if (update = type.updateContext) update.call(this, prevType);else this.exprAllowed = type.beforeExpr;3020};30213022// Token-specific context update code30233024tt.parenR.updateContext = tt.braceR.updateContext = function () {3025if (this.context.length == 1) {3026this.exprAllowed = true;3027return;3028}3029var out = this.context.pop();3030if (out === types.b_stat && this.curContext() === types.f_expr) {3031this.context.pop();3032this.exprAllowed = false;3033} else if (out === types.b_tmpl) {3034this.exprAllowed = true;3035} else {3036this.exprAllowed = !out.isExpr;3037}3038};30393040tt.braceL.updateContext = function (prevType) {3041this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr);3042this.exprAllowed = true;3043};30443045tt.dollarBraceL.updateContext = function () {3046this.context.push(types.b_tmpl);3047this.exprAllowed = true;3048};30493050tt.parenL.updateContext = function (prevType) {3051var statementParens = prevType === tt._if || prevType === tt._for || prevType === tt._with || prevType === tt._while;3052this.context.push(statementParens ? types.p_stat : types.p_expr);3053this.exprAllowed = true;3054};30553056tt.incDec.updateContext = function () {};30573058tt._function.updateContext = function () {3059if (this.curContext() !== types.b_stat) this.context.push(types.f_expr);3060this.exprAllowed = false;3061};30623063tt.backQuote.updateContext = function () {3064if (this.curContext() === types.q_tmpl) this.context.pop();else this.context.push(types.q_tmpl);3065this.exprAllowed = false;3066};30673068// tokExprAllowed stays unchanged30693070},{"./state":13,"./tokentype":17,"./whitespace":19}],16:[function(_dereq_,module,exports){3071"use strict";30723073var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };30743075exports.__esModule = true;30763077var _identifier = _dereq_("./identifier");30783079var isIdentifierStart = _identifier.isIdentifierStart;3080var isIdentifierChar = _identifier.isIdentifierChar;30813082var _tokentype = _dereq_("./tokentype");30833084var tt = _tokentype.types;3085var keywordTypes = _tokentype.keywords;30863087var Parser = _dereq_("./state").Parser;30883089var SourceLocation = _dereq_("./location").SourceLocation;30903091var _whitespace = _dereq_("./whitespace");30923093var lineBreak = _whitespace.lineBreak;3094var lineBreakG = _whitespace.lineBreakG;3095var isNewLine = _whitespace.isNewLine;3096var nonASCIIwhitespace = _whitespace.nonASCIIwhitespace;30973098// Object type used to represent tokens. Note that normally, tokens3099// simply exist as properties on the parser object. This is only3100// used for the onToken callback and the external tokenizer.31013102var Token = exports.Token = function Token(p) {3103_classCallCheck(this, Token);31043105this.type = p.type;3106this.value = p.value;3107this.start = p.start;3108this.end = p.end;3109if (p.options.locations) this.loc = new SourceLocation(p, p.startLoc, p.endLoc);3110if (p.options.ranges) this.range = [p.start, p.end];3111};31123113// ## Tokenizer31143115var pp = Parser.prototype;31163117// Are we running under Rhino?3118var isRhino = typeof Packages !== "undefined";31193120// Move to the next token31213122pp.next = function () {3123if (this.options.onToken) this.options.onToken(new Token(this));31243125this.lastTokEnd = this.end;3126this.lastTokStart = this.start;3127this.lastTokEndLoc = this.endLoc;3128this.lastTokStartLoc = this.startLoc;3129this.nextToken();3130};31313132pp.getToken = function () {3133this.next();3134return new Token(this);3135};31363137// If we're in an ES6 environment, make parsers iterable3138if (typeof Symbol !== "undefined") pp[Symbol.iterator] = function () {3139var self = this;3140return { next: function next() {3141var token = self.getToken();3142return {3143done: token.type === tt.eof,3144value: token3145};3146} };3147};31483149// Toggle strict mode. Re-reads the next number or string to please3150// pedantic tests (`"use strict"; 010;` should fail).31513152pp.setStrict = function (strict) {3153this.strict = strict;3154if (this.type !== tt.num && this.type !== tt.string) return;3155this.pos = this.start;3156if (this.options.locations) {3157while (this.pos < this.lineStart) {3158this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1;3159--this.curLine;3160}3161}3162this.nextToken();3163};31643165pp.curContext = function () {3166return this.context[this.context.length - 1];3167};31683169// Read a single token, updating the parser object's token-related3170// properties.31713172pp.nextToken = function () {3173var curContext = this.curContext();3174if (!curContext || !curContext.preserveSpace) this.skipSpace();31753176this.start = this.pos;3177if (this.options.locations) this.startLoc = this.curPosition();3178if (this.pos >= this.input.length) return this.finishToken(tt.eof);31793180if (curContext.override) return curContext.override(this);else this.readToken(this.fullCharCodeAtPos());3181};31823183pp.readToken = function (code) {3184// Identifier or keyword. '\uXXXX' sequences are allowed in3185// identifiers, so '\' also dispatches to that.3186if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */) return this.readWord();31873188return this.getTokenFromCode(code);3189};31903191pp.fullCharCodeAtPos = function () {3192var code = this.input.charCodeAt(this.pos);3193if (code <= 55295 || code >= 57344) return code;3194var next = this.input.charCodeAt(this.pos + 1);3195return (code << 10) + next - 56613888;3196};31973198pp.skipBlockComment = function () {3199var startLoc = this.options.onComment && this.options.locations && this.curPosition();3200var start = this.pos,3201end = this.input.indexOf("*/", this.pos += 2);3202if (end === -1) this.raise(this.pos - 2, "Unterminated comment");3203this.pos = end + 2;3204if (this.options.locations) {3205lineBreakG.lastIndex = start;3206var match = undefined;3207while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {3208++this.curLine;3209this.lineStart = match.index + match[0].length;3210}3211}3212if (this.options.onComment) this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos, startLoc, this.options.locations && this.curPosition());3213};32143215pp.skipLineComment = function (startSkip) {3216var start = this.pos;3217var startLoc = this.options.onComment && this.options.locations && this.curPosition();3218var ch = this.input.charCodeAt(this.pos += startSkip);3219while (this.pos < this.input.length && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) {3220++this.pos;3221ch = this.input.charCodeAt(this.pos);3222}3223if (this.options.onComment) this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos, startLoc, this.options.locations && this.curPosition());3224};32253226// Called at the start of the parse and after every token. Skips3227// whitespace and comments, and.32283229pp.skipSpace = function () {3230while (this.pos < this.input.length) {3231var ch = this.input.charCodeAt(this.pos);3232if (ch === 32) {3233// ' '3234++this.pos;3235} else if (ch === 13) {3236++this.pos;3237var next = this.input.charCodeAt(this.pos);3238if (next === 10) {3239++this.pos;3240}3241if (this.options.locations) {3242++this.curLine;3243this.lineStart = this.pos;3244}3245} else if (ch === 10 || ch === 8232 || ch === 8233) {3246++this.pos;3247if (this.options.locations) {3248++this.curLine;3249this.lineStart = this.pos;3250}3251} else if (ch > 8 && ch < 14) {3252++this.pos;3253} else if (ch === 47) {3254// '/'3255var next = this.input.charCodeAt(this.pos + 1);3256if (next === 42) {3257// '*'3258this.skipBlockComment();3259} else if (next === 47) {3260// '/'3261this.skipLineComment(2);3262} else break;3263} else if (ch === 160) {3264// '\xa0'3265++this.pos;3266} else if (ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {3267++this.pos;3268} else {3269break;3270}3271}3272};32733274// Called at the end of every token. Sets `end`, `val`, and3275// maintains `context` and `exprAllowed`, and skips the space after3276// the token, so that the next one's `start` will point at the3277// right position.32783279pp.finishToken = function (type, val) {3280this.end = this.pos;3281if (this.options.locations) this.endLoc = this.curPosition();3282var prevType = this.type;3283this.type = type;3284this.value = val;32853286this.updateContext(prevType);3287};32883289// ### Token reading32903291// This is the function that is called to fetch the next token. It3292// is somewhat obscure, because it works in character codes rather3293// than characters, and because operator parsing has been inlined3294// into it.3295//3296// All in the name of speed.3297//3298pp.readToken_dot = function () {3299var next = this.input.charCodeAt(this.pos + 1);3300if (next >= 48 && next <= 57) return this.readNumber(true);3301var next2 = this.input.charCodeAt(this.pos + 2);3302if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) {3303// 46 = dot '.'3304this.pos += 3;3305return this.finishToken(tt.ellipsis);3306} else {3307++this.pos;3308return this.finishToken(tt.dot);3309}3310};33113312pp.readToken_slash = function () {3313// '/'3314var next = this.input.charCodeAt(this.pos + 1);3315if (this.exprAllowed) {3316++this.pos;return this.readRegexp();3317}3318if (next === 61) return this.finishOp(tt.assign, 2);3319return this.finishOp(tt.slash, 1);3320};33213322pp.readToken_mult_modulo = function (code) {3323// '%*'3324var next = this.input.charCodeAt(this.pos + 1);3325if (next === 61) return this.finishOp(tt.assign, 2);3326return this.finishOp(code === 42 ? tt.star : tt.modulo, 1);3327};33283329pp.readToken_pipe_amp = function (code) {3330// '|&'3331var next = this.input.charCodeAt(this.pos + 1);3332if (next === code) return this.finishOp(code === 124 ? tt.logicalOR : tt.logicalAND, 2);3333if (next === 61) return this.finishOp(tt.assign, 2);3334return this.finishOp(code === 124 ? tt.bitwiseOR : tt.bitwiseAND, 1);3335};33363337pp.readToken_caret = function () {3338// '^'3339var next = this.input.charCodeAt(this.pos + 1);3340if (next === 61) return this.finishOp(tt.assign, 2);3341return this.finishOp(tt.bitwiseXOR, 1);3342};33433344pp.readToken_plus_min = function (code) {3345// '+-'3346var next = this.input.charCodeAt(this.pos + 1);3347if (next === code) {3348if (next == 45 && this.input.charCodeAt(this.pos + 2) == 62 && lineBreak.test(this.input.slice(this.lastTokEnd, this.pos))) {3349// A `-->` line comment3350this.skipLineComment(3);3351this.skipSpace();3352return this.nextToken();3353}3354return this.finishOp(tt.incDec, 2);3355}3356if (next === 61) return this.finishOp(tt.assign, 2);3357return this.finishOp(tt.plusMin, 1);3358};33593360pp.readToken_lt_gt = function (code) {3361// '<>'3362var next = this.input.charCodeAt(this.pos + 1);3363var size = 1;3364if (next === code) {3365size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;3366if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1);3367return this.finishOp(tt.bitShift, size);3368}3369if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 && this.input.charCodeAt(this.pos + 3) == 45) {3370if (this.inModule) this.unexpected();3371// `<!--`, an XML-style comment that should be interpreted as a line comment3372this.skipLineComment(4);3373this.skipSpace();3374return this.nextToken();3375}3376if (next === 61) size = this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2;3377return this.finishOp(tt.relational, size);3378};33793380pp.readToken_eq_excl = function (code) {3381// '=!'3382var next = this.input.charCodeAt(this.pos + 1);3383if (next === 61) return this.finishOp(tt.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2);3384if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) {3385// '=>'3386this.pos += 2;3387return this.finishToken(tt.arrow);3388}3389return this.finishOp(code === 61 ? tt.eq : tt.prefix, 1);3390};33913392pp.getTokenFromCode = function (code) {3393switch (code) {3394// The interpretation of a dot depends on whether it is followed3395// by a digit or another two dots.3396case 46:3397// '.'3398return this.readToken_dot();33993400// Punctuation tokens.3401case 40:3402++this.pos;return this.finishToken(tt.parenL);3403case 41:3404++this.pos;return this.finishToken(tt.parenR);3405case 59:3406++this.pos;return this.finishToken(tt.semi);3407case 44:3408++this.pos;return this.finishToken(tt.comma);3409case 91:3410++this.pos;return this.finishToken(tt.bracketL);3411case 93:3412++this.pos;return this.finishToken(tt.bracketR);3413case 123:3414++this.pos;return this.finishToken(tt.braceL);3415case 125:3416++this.pos;return this.finishToken(tt.braceR);3417case 58:3418++this.pos;return this.finishToken(tt.colon);3419case 63:3420++this.pos;return this.finishToken(tt.question);34213422case 96:3423// '`'3424if (this.options.ecmaVersion < 6) break;3425++this.pos;3426return this.finishToken(tt.backQuote);34273428case 48:3429// '0'3430var next = this.input.charCodeAt(this.pos + 1);3431if (next === 120 || next === 88) return this.readRadixNumber(16); // '0x', '0X' - hex number3432if (this.options.ecmaVersion >= 6) {3433if (next === 111 || next === 79) return this.readRadixNumber(8); // '0o', '0O' - octal number3434if (next === 98 || next === 66) return this.readRadixNumber(2); // '0b', '0B' - binary number3435}3436// Anything else beginning with a digit is an integer, octal3437// number, or float.3438case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:3439// 1-93440return this.readNumber(false);34413442// Quotes produce strings.3443case 34:case 39:3444// '"', "'"3445return this.readString(code);34463447// Operators are parsed inline in tiny state machines. '=' (61) is3448// often referred to. `finishOp` simply skips the amount of3449// characters it is given as second argument, and returns a token3450// of the type given by its first argument.34513452case 47:3453// '/'3454return this.readToken_slash();34553456case 37:case 42:3457// '%*'3458return this.readToken_mult_modulo(code);34593460case 124:case 38:3461// '|&'3462return this.readToken_pipe_amp(code);34633464case 94:3465// '^'3466return this.readToken_caret();34673468case 43:case 45:3469// '+-'3470return this.readToken_plus_min(code);34713472case 60:case 62:3473// '<>'3474return this.readToken_lt_gt(code);34753476case 61:case 33:3477// '=!'3478return this.readToken_eq_excl(code);34793480case 126:3481// '~'3482return this.finishOp(tt.prefix, 1);3483}34843485this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");3486};34873488pp.finishOp = function (type, size) {3489var str = this.input.slice(this.pos, this.pos + size);3490this.pos += size;3491return this.finishToken(type, str);3492};34933494var regexpUnicodeSupport = false;3495try {3496new RegExp("", "u");regexpUnicodeSupport = true;3497} catch (e) {}34983499// Parse a regular expression. Some context-awareness is necessary,3500// since a '/' inside a '[]' set does not end the expression.35013502pp.readRegexp = function () {3503var escaped = undefined,3504inClass = undefined,3505start = this.pos;3506for (;;) {3507if (this.pos >= this.input.length) this.raise(start, "Unterminated regular expression");3508var ch = this.input.charAt(this.pos);3509if (lineBreak.test(ch)) this.raise(start, "Unterminated regular expression");3510if (!escaped) {3511if (ch === "[") inClass = true;else if (ch === "]" && inClass) inClass = false;else if (ch === "/" && !inClass) break;3512escaped = ch === "\\";3513} else escaped = false;3514++this.pos;3515}3516var content = this.input.slice(start, this.pos);3517++this.pos;3518// Need to use `readWord1` because '\uXXXX' sequences are allowed3519// here (don't ask).3520var mods = this.readWord1();3521var tmp = content;3522if (mods) {3523var validFlags = /^[gmsiy]*$/;3524if (this.options.ecmaVersion >= 6) validFlags = /^[gmsiyu]*$/;3525if (!validFlags.test(mods)) this.raise(start, "Invalid regular expression flag");3526if (mods.indexOf("u") >= 0 && !regexpUnicodeSupport) {3527// Replace each astral symbol and every Unicode escape sequence that3528// possibly represents an astral symbol or a paired surrogate with a3529// single ASCII symbol to avoid throwing on regular expressions that3530// are only valid in combination with the `/u` flag.3531// Note: replacing with the ASCII symbol `x` might cause false3532// negatives in unlikely scenarios. For example, `[\u{61}-b]` is a3533// perfectly valid pattern that is equivalent to `[a-b]`, but it would3534// be replaced by `[x-b]` which throws an error.3535tmp = tmp.replace(/\\u([a-fA-F0-9]{4})|\\u\{([0-9a-fA-F]+)\}|[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "x");3536}3537}3538// Detect invalid regular expressions.3539var value = null;3540// Rhino's regular expression parser is flaky and throws uncatchable exceptions,3541// so don't do detection if we are running under Rhino3542if (!isRhino) {3543try {3544new RegExp(tmp);3545} catch (e) {3546if (e instanceof SyntaxError) this.raise(start, "Error parsing regular expression: " + e.message);3547this.raise(e);3548}3549// Get a regular expression object for this pattern-flag pair, or `null` in3550// case the current environment doesn't support the flags it uses.3551try {3552value = new RegExp(content, mods);3553} catch (err) {}3554}3555return this.finishToken(tt.regexp, { pattern: content, flags: mods, value: value });3556};35573558// Read an integer in the given radix. Return null if zero digits3559// were read, the integer value otherwise. When `len` is given, this3560// will return `null` unless the integer has exactly `len` digits.35613562pp.readInt = function (radix, len) {3563var start = this.pos,3564total = 0;3565for (var i = 0, e = len == null ? Infinity : len; i < e; ++i) {3566var code = this.input.charCodeAt(this.pos),3567val = undefined;3568if (code >= 97) val = code - 97 + 10; // a3569else if (code >= 65) val = code - 65 + 10; // A3570else if (code >= 48 && code <= 57) val = code - 48; // 0-93571else val = Infinity;3572if (val >= radix) break;3573++this.pos;3574total = total * radix + val;3575}3576if (this.pos === start || len != null && this.pos - start !== len) return null;35773578return total;3579};35803581pp.readRadixNumber = function (radix) {3582this.pos += 2; // 0x3583var val = this.readInt(radix);3584if (val == null) this.raise(this.start + 2, "Expected number in radix " + radix);3585if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number");3586return this.finishToken(tt.num, val);3587};35883589// Read an integer, octal integer, or floating-point number.35903591pp.readNumber = function (startsWithDot) {3592var start = this.pos,3593isFloat = false,3594octal = this.input.charCodeAt(this.pos) === 48;3595if (!startsWithDot && this.readInt(10) === null) this.raise(start, "Invalid number");3596if (this.input.charCodeAt(this.pos) === 46) {3597++this.pos;3598this.readInt(10);3599isFloat = true;3600}3601var next = this.input.charCodeAt(this.pos);3602if (next === 69 || next === 101) {3603// 'eE'3604next = this.input.charCodeAt(++this.pos);3605if (next === 43 || next === 45) ++this.pos; // '+-'3606if (this.readInt(10) === null) this.raise(start, "Invalid number");3607isFloat = true;3608}3609if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number");36103611var str = this.input.slice(start, this.pos),3612val = undefined;3613if (isFloat) val = parseFloat(str);else if (!octal || str.length === 1) val = parseInt(str, 10);else if (/[89]/.test(str) || this.strict) this.raise(start, "Invalid number");else val = parseInt(str, 8);3614return this.finishToken(tt.num, val);3615};36163617// Read a string value, interpreting backslash-escapes.36183619pp.readCodePoint = function () {3620var ch = this.input.charCodeAt(this.pos),3621code = undefined;36223623if (ch === 123) {3624if (this.options.ecmaVersion < 6) this.unexpected();3625++this.pos;3626code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);3627++this.pos;3628if (code > 1114111) this.unexpected();3629} else {3630code = this.readHexChar(4);3631}3632return code;3633};36343635function codePointToString(code) {3636// UTF-16 Decoding3637if (code <= 65535) {3638return String.fromCharCode(code);3639}return String.fromCharCode((code - 65536 >> 10) + 55296, (code - 65536 & 1023) + 56320);3640}36413642pp.readString = function (quote) {3643var out = "",3644chunkStart = ++this.pos;3645for (;;) {3646if (this.pos >= this.input.length) this.raise(this.start, "Unterminated string constant");3647var ch = this.input.charCodeAt(this.pos);3648if (ch === quote) break;3649if (ch === 92) {3650// '\'3651out += this.input.slice(chunkStart, this.pos);3652out += this.readEscapedChar();3653chunkStart = this.pos;3654} else {3655if (isNewLine(ch)) this.raise(this.start, "Unterminated string constant");3656++this.pos;3657}3658}3659out += this.input.slice(chunkStart, this.pos++);3660return this.finishToken(tt.string, out);3661};36623663// Reads template string tokens.36643665pp.readTmplToken = function () {3666var out = "",3667chunkStart = this.pos;3668for (;;) {3669if (this.pos >= this.input.length) this.raise(this.start, "Unterminated template");3670var ch = this.input.charCodeAt(this.pos);3671if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) {3672// '`', '${'3673if (this.pos === this.start && this.type === tt.template) {3674if (ch === 36) {3675this.pos += 2;3676return this.finishToken(tt.dollarBraceL);3677} else {3678++this.pos;3679return this.finishToken(tt.backQuote);3680}3681}3682out += this.input.slice(chunkStart, this.pos);3683return this.finishToken(tt.template, out);3684}3685if (ch === 92) {3686// '\'3687out += this.input.slice(chunkStart, this.pos);3688out += this.readEscapedChar();3689chunkStart = this.pos;3690} else if (isNewLine(ch)) {3691out += this.input.slice(chunkStart, this.pos);3692++this.pos;3693if (ch === 13 && this.input.charCodeAt(this.pos) === 10) {3694++this.pos;3695out += "\n";3696} else {3697out += String.fromCharCode(ch);3698}3699if (this.options.locations) {3700++this.curLine;3701this.lineStart = this.pos;3702}3703chunkStart = this.pos;3704} else {3705++this.pos;3706}3707}3708};37093710// Used to read escaped characters37113712pp.readEscapedChar = function () {3713var ch = this.input.charCodeAt(++this.pos);3714var octal = /^[0-7]+/.exec(this.input.slice(this.pos, this.pos + 3));3715if (octal) octal = octal[0];3716while (octal && parseInt(octal, 8) > 255) octal = octal.slice(0, -1);3717if (octal === "0") octal = null;3718++this.pos;3719if (octal) {3720if (this.strict) this.raise(this.pos - 2, "Octal literal in strict mode");3721this.pos += octal.length - 1;3722return String.fromCharCode(parseInt(octal, 8));3723} else {3724switch (ch) {3725case 110:3726return "\n"; // 'n' -> '\n'3727case 114:3728return "\r"; // 'r' -> '\r'3729case 120:3730return String.fromCharCode(this.readHexChar(2)); // 'x'3731case 117:3732return codePointToString(this.readCodePoint()); // 'u'3733case 116:3734return "\t"; // 't' -> '\t'3735case 98:3736return "\b"; // 'b' -> '\b'3737case 118:3738return "\u000b"; // 'v' -> '\u000b'3739case 102:3740return "\f"; // 'f' -> '\f'3741case 48:3742return "\u0000"; // 0 -> '\0'3743case 13:3744if (this.input.charCodeAt(this.pos) === 10) ++this.pos; // '\r\n'3745case 10:3746// ' \n'3747if (this.options.locations) {3748this.lineStart = this.pos;++this.curLine;3749}3750return "";3751default:3752return String.fromCharCode(ch);3753}3754}3755};37563757// Used to read character escape sequences ('\x', '\u', '\U').37583759pp.readHexChar = function (len) {3760var n = this.readInt(16, len);3761if (n === null) this.raise(this.start, "Bad character escape sequence");3762return n;3763};37643765// Used to signal to callers of `readWord1` whether the word3766// contained any escape sequences. This is needed because words with3767// escape sequences must not be interpreted as keywords.37683769var containsEsc;37703771// Read an identifier, and return it as a string. Sets `containsEsc`3772// to whether the word contained a '\u' escape.3773//3774// Incrementally adds only escaped chars, adding other chunks as-is3775// as a micro-optimization.37763777pp.readWord1 = function () {3778containsEsc = false;3779var word = "",3780first = true,3781chunkStart = this.pos;3782var astral = this.options.ecmaVersion >= 6;3783while (this.pos < this.input.length) {3784var ch = this.fullCharCodeAtPos();3785if (isIdentifierChar(ch, astral)) {3786this.pos += ch <= 65535 ? 1 : 2;3787} else if (ch === 92) {3788// "\"3789containsEsc = true;3790word += this.input.slice(chunkStart, this.pos);3791var escStart = this.pos;3792if (this.input.charCodeAt(++this.pos) != 117) // "u"3793this.raise(this.pos, "Expecting Unicode escape sequence \\uXXXX");3794++this.pos;3795var esc = this.readCodePoint();3796if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral)) this.raise(escStart, "Invalid Unicode escape");3797word += codePointToString(esc);3798chunkStart = this.pos;3799} else {3800break;3801}3802first = false;3803}3804return word + this.input.slice(chunkStart, this.pos);3805};38063807// Read an identifier or keyword token. Will check for reserved3808// words when necessary.38093810pp.readWord = function () {3811var word = this.readWord1();3812var type = tt.name;3813if ((this.options.ecmaVersion >= 6 || !containsEsc) && this.isKeyword(word)) type = keywordTypes[word];3814return this.finishToken(type, word);3815};38163817},{"./identifier":7,"./location":8,"./state":13,"./tokentype":17,"./whitespace":19}],17:[function(_dereq_,module,exports){3818"use strict";38193820var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };38213822exports.__esModule = true;3823// ## Token types38243825// The assignment of fine-grained, information-carrying type objects3826// allows the tokenizer to store the information it has about a3827// token in a way that is very cheap for the parser to look up.38283829// All token type variables start with an underscore, to make them3830// easy to recognize.38313832// The `beforeExpr` property is used to disambiguate between regular3833// expressions and divisions. It is set on all token types that can3834// be followed by an expression (thus, a slash after them would be a3835// regular expression).3836//3837// `isLoop` marks a keyword as starting a loop, which is important3838// to know when parsing a label, in order to allow or disallow3839// continue jumps to that label.38403841var TokenType = exports.TokenType = function TokenType(label) {3842var conf = arguments[1] === undefined ? {} : arguments[1];38433844_classCallCheck(this, TokenType);38453846this.label = label;3847this.keyword = conf.keyword;3848this.beforeExpr = !!conf.beforeExpr;3849this.startsExpr = !!conf.startsExpr;3850this.isLoop = !!conf.isLoop;3851this.isAssign = !!conf.isAssign;3852this.prefix = !!conf.prefix;3853this.postfix = !!conf.postfix;3854this.binop = conf.binop || null;3855this.updateContext = null;3856};38573858function binop(name, prec) {3859return new TokenType(name, { beforeExpr: true, binop: prec });3860}3861var beforeExpr = { beforeExpr: true },3862startsExpr = { startsExpr: true };38633864var types = {3865num: new TokenType("num", startsExpr),3866regexp: new TokenType("regexp", startsExpr),3867string: new TokenType("string", startsExpr),3868name: new TokenType("name", startsExpr),3869eof: new TokenType("eof"),38703871// Punctuation token types.3872bracketL: new TokenType("[", { beforeExpr: true, startsExpr: true }),3873bracketR: new TokenType("]"),3874braceL: new TokenType("{", { beforeExpr: true, startsExpr: true }),3875braceR: new TokenType("}"),3876parenL: new TokenType("(", { beforeExpr: true, startsExpr: true }),3877parenR: new TokenType(")"),3878comma: new TokenType(",", beforeExpr),3879semi: new TokenType(";", beforeExpr),3880colon: new TokenType(":", beforeExpr),3881dot: new TokenType("."),3882question: new TokenType("?", beforeExpr),3883arrow: new TokenType("=>", beforeExpr),3884template: new TokenType("template"),3885ellipsis: new TokenType("...", beforeExpr),3886backQuote: new TokenType("`", startsExpr),3887dollarBraceL: new TokenType("${", { beforeExpr: true, startsExpr: true }),38883889// Operators. These carry several kinds of properties to help the3890// parser use them properly (the presence of these properties is3891// what categorizes them as operators).3892//3893// `binop`, when present, specifies that this operator is a binary3894// operator, and will refer to its precedence.3895//3896// `prefix` and `postfix` mark the operator as a prefix or postfix3897// unary operator.3898//3899// `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as3900// binary operators with a very low precedence, that should result3901// in AssignmentExpression nodes.39023903eq: new TokenType("=", { beforeExpr: true, isAssign: true }),3904assign: new TokenType("_=", { beforeExpr: true, isAssign: true }),3905incDec: new TokenType("++/--", { prefix: true, postfix: true, startsExpr: true }),3906prefix: new TokenType("prefix", { beforeExpr: true, prefix: true, startsExpr: true }),3907logicalOR: binop("||", 1),3908logicalAND: binop("&&", 2),3909bitwiseOR: binop("|", 3),3910bitwiseXOR: binop("^", 4),3911bitwiseAND: binop("&", 5),3912equality: binop("==/!=", 6),3913relational: binop("</>", 7),3914bitShift: binop("<</>>", 8),3915plusMin: new TokenType("+/-", { beforeExpr: true, binop: 9, prefix: true, startsExpr: true }),3916modulo: binop("%", 10),3917star: binop("*", 10),3918slash: binop("/", 10)3919};39203921exports.types = types;3922// Map keyword names to token types.39233924var keywords = {};39253926exports.keywords = keywords;3927// Succinct definitions of keyword token types3928function kw(name) {3929var options = arguments[1] === undefined ? {} : arguments[1];39303931options.keyword = name;3932keywords[name] = types["_" + name] = new TokenType(name, options);3933}39343935kw("break");3936kw("case", beforeExpr);3937kw("catch");3938kw("continue");3939kw("debugger");3940kw("default");3941kw("do", { isLoop: true });3942kw("else", beforeExpr);3943kw("finally");3944kw("for", { isLoop: true });3945kw("function", startsExpr);3946kw("if");3947kw("return", beforeExpr);3948kw("switch");3949kw("throw", beforeExpr);3950kw("try");3951kw("var");3952kw("let");3953kw("const");3954kw("while", { isLoop: true });3955kw("with");3956kw("new", { beforeExpr: true, startsExpr: true });3957kw("this", startsExpr);3958kw("super", startsExpr);3959kw("class");3960kw("extends", beforeExpr);3961kw("export");3962kw("import");3963kw("yield", { beforeExpr: true, startsExpr: true });3964kw("null", startsExpr);3965kw("true", startsExpr);3966kw("false", startsExpr);3967kw("in", { beforeExpr: true, binop: 7 });3968kw("instanceof", { beforeExpr: true, binop: 7 });3969kw("typeof", { beforeExpr: true, prefix: true, startsExpr: true });3970kw("void", { beforeExpr: true, prefix: true, startsExpr: true });3971kw("delete", { beforeExpr: true, prefix: true, startsExpr: true });39723973},{}],18:[function(_dereq_,module,exports){3974"use strict";39753976exports.isArray = isArray;39773978// Checks if an object has a property.39793980exports.has = has;3981exports.__esModule = true;39823983function isArray(obj) {3984return Object.prototype.toString.call(obj) === "[object Array]";3985}39863987function has(obj, propName) {3988return Object.prototype.hasOwnProperty.call(obj, propName);3989}39903991},{}],19:[function(_dereq_,module,exports){3992"use strict";39933994exports.isNewLine = isNewLine;3995exports.__esModule = true;3996// Matches a whole line break (where CRLF is considered a single3997// line break). Used to count lines.39983999var lineBreak = /\r\n?|\n|\u2028|\u2029/;4000exports.lineBreak = lineBreak;4001var lineBreakG = new RegExp(lineBreak.source, "g");40024003exports.lineBreakG = lineBreakG;40044005function isNewLine(code) {4006return code === 10 || code === 13 || code === 8232 || code == 8233;4007}40084009var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/;4010exports.nonASCIIwhitespace = nonASCIIwhitespace;40114012},{}]},{},[1])(1)4013});40144015