react / react-0.13.3 / examples / basic-commonjs / node_modules / browserify / node_modules / syntax-error / node_modules / acorn / dist / acorn_csp.js
80744 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.1";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":2,"./identifier":3,"./location":4,"./lval":5,"./node":6,"./options":7,"./parseutil":8,"./state":9,"./statement":10,"./tokencontext":11,"./tokenize":12,"./tokentype":13,"./whitespace":15}],2:[function(_dereq_,module,exports){118// A recursive descent parser operates by defining functions for all119// syntactic elements, and recursively calling those, each function120// advancing the input stream and returning an AST node. Precedence121// of constructs (for example, the fact that `!x[1]` means `!(x[1])`122// instead of `(!x)[1]` is handled by the fact that the parser123// function that parses unary prefix operators is called first, and124// in turn calls the function that parses `[]` subscripts — that125// way, it'll receive the node for `x[1]` already parsed, and wraps126// *that* in the unary operator node.127//128// Acorn uses an [operator precedence parser][opp] to handle binary129// operator precedence, because it is much more compact than using130// the technique outlined above, which uses different, nesting131// functions to specify precedence, for all of the ten binary132// precedence levels that JavaScript defines.133//134// [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser135136"use strict";137138var tt = _dereq_("./tokentype").types;139140var Parser = _dereq_("./state").Parser;141142var reservedWords = _dereq_("./identifier").reservedWords;143144var has = _dereq_("./util").has;145146var pp = Parser.prototype;147148// Check if property name clashes with already added.149// Object/class getters and setters are not allowed to clash —150// either with each other or with an init property — and in151// strict mode, init properties are also not allowed to be repeated.152153pp.checkPropClash = function (prop, propHash) {154if (this.options.ecmaVersion >= 6) return;155var key = prop.key,156name = undefined;157switch (key.type) {158case "Identifier":159name = key.name;break;160case "Literal":161name = String(key.value);break;162default:163return;164}165var kind = prop.kind || "init",166other = undefined;167if (has(propHash, name)) {168other = propHash[name];169var isGetSet = kind !== "init";170if ((this.strict || isGetSet) && other[kind] || !(isGetSet ^ other.init)) this.raise(key.start, "Redefinition of property");171} else {172other = propHash[name] = {173init: false,174get: false,175set: false176};177}178other[kind] = true;179};180181// ### Expression parsing182183// These nest, from the most general expression type at the top to184// 'atomic', nondivisible expression types at the bottom. Most of185// the functions will simply let the function(s) below them parse,186// and, *if* the syntactic construct they handle is present, wrap187// the AST node that the inner parser gave them in another node.188189// Parse a full expression. The optional arguments are used to190// forbid the `in` operator (in for loops initalization expressions)191// and provide reference for storing '=' operator inside shorthand192// property assignment in contexts where both object expression193// and object pattern might appear (so it's possible to raise194// delayed syntax error at correct position).195196pp.parseExpression = function (noIn, refShorthandDefaultPos) {197var startPos = this.start,198startLoc = this.startLoc;199var expr = this.parseMaybeAssign(noIn, refShorthandDefaultPos);200if (this.type === tt.comma) {201var node = this.startNodeAt(startPos, startLoc);202node.expressions = [expr];203while (this.eat(tt.comma)) node.expressions.push(this.parseMaybeAssign(noIn, refShorthandDefaultPos));204return this.finishNode(node, "SequenceExpression");205}206return expr;207};208209// Parse an assignment expression. This includes applications of210// operators like `+=`.211212pp.parseMaybeAssign = function (noIn, refShorthandDefaultPos, afterLeftParse) {213if (this.type == tt._yield && this.inGenerator) return this.parseYield();214215var failOnShorthandAssign = undefined;216if (!refShorthandDefaultPos) {217refShorthandDefaultPos = { start: 0 };218failOnShorthandAssign = true;219} else {220failOnShorthandAssign = false;221}222var startPos = this.start,223startLoc = this.startLoc;224if (this.type == tt.parenL || this.type == tt.name) this.potentialArrowAt = this.start;225var left = this.parseMaybeConditional(noIn, refShorthandDefaultPos);226if (afterLeftParse) left = afterLeftParse.call(this, left, startPos, startLoc);227if (this.type.isAssign) {228var node = this.startNodeAt(startPos, startLoc);229node.operator = this.value;230node.left = this.type === tt.eq ? this.toAssignable(left) : left;231refShorthandDefaultPos.start = 0; // reset because shorthand default was used correctly232this.checkLVal(left);233this.next();234node.right = this.parseMaybeAssign(noIn);235return this.finishNode(node, "AssignmentExpression");236} else if (failOnShorthandAssign && refShorthandDefaultPos.start) {237this.unexpected(refShorthandDefaultPos.start);238}239return left;240};241242// Parse a ternary conditional (`?:`) operator.243244pp.parseMaybeConditional = function (noIn, refShorthandDefaultPos) {245var startPos = this.start,246startLoc = this.startLoc;247var expr = this.parseExprOps(noIn, refShorthandDefaultPos);248if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;249if (this.eat(tt.question)) {250var node = this.startNodeAt(startPos, startLoc);251node.test = expr;252node.consequent = this.parseMaybeAssign();253this.expect(tt.colon);254node.alternate = this.parseMaybeAssign(noIn);255return this.finishNode(node, "ConditionalExpression");256}257return expr;258};259260// Start the precedence parser.261262pp.parseExprOps = function (noIn, refShorthandDefaultPos) {263var startPos = this.start,264startLoc = this.startLoc;265var expr = this.parseMaybeUnary(refShorthandDefaultPos);266if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;267return this.parseExprOp(expr, startPos, startLoc, -1, noIn);268};269270// Parse binary operators with the operator precedence parsing271// algorithm. `left` is the left-hand side of the operator.272// `minPrec` provides context that allows the function to stop and273// defer further parser to one of its callers when it encounters an274// operator that has a lower precedence than the set it is parsing.275276pp.parseExprOp = function (left, leftStartPos, leftStartLoc, minPrec, noIn) {277var prec = this.type.binop;278if (prec != null && (!noIn || this.type !== tt._in)) {279if (prec > minPrec) {280var node = this.startNodeAt(leftStartPos, leftStartLoc);281node.left = left;282node.operator = this.value;283var op = this.type;284this.next();285var startPos = this.start,286startLoc = this.startLoc;287node.right = this.parseExprOp(this.parseMaybeUnary(), startPos, startLoc, prec, noIn);288this.finishNode(node, op === tt.logicalOR || op === tt.logicalAND ? "LogicalExpression" : "BinaryExpression");289return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn);290}291}292return left;293};294295// Parse unary operators, both prefix and postfix.296297pp.parseMaybeUnary = function (refShorthandDefaultPos) {298if (this.type.prefix) {299var node = this.startNode(),300update = this.type === tt.incDec;301node.operator = this.value;302node.prefix = true;303this.next();304node.argument = this.parseMaybeUnary();305if (refShorthandDefaultPos && refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start);306if (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");307return this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");308}309var startPos = this.start,310startLoc = this.startLoc;311var expr = this.parseExprSubscripts(refShorthandDefaultPos);312if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;313while (this.type.postfix && !this.canInsertSemicolon()) {314var node = this.startNodeAt(startPos, startLoc);315node.operator = this.value;316node.prefix = false;317node.argument = expr;318this.checkLVal(expr);319this.next();320expr = this.finishNode(node, "UpdateExpression");321}322return expr;323};324325// Parse call, dot, and `[]`-subscript expressions.326327pp.parseExprSubscripts = function (refShorthandDefaultPos) {328var startPos = this.start,329startLoc = this.startLoc;330var expr = this.parseExprAtom(refShorthandDefaultPos);331if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr;332return this.parseSubscripts(expr, startPos, startLoc);333};334335pp.parseSubscripts = function (base, startPos, startLoc, noCalls) {336for (;;) {337if (this.eat(tt.dot)) {338var node = this.startNodeAt(startPos, startLoc);339node.object = base;340node.property = this.parseIdent(true);341node.computed = false;342base = this.finishNode(node, "MemberExpression");343} else if (this.eat(tt.bracketL)) {344var node = this.startNodeAt(startPos, startLoc);345node.object = base;346node.property = this.parseExpression();347node.computed = true;348this.expect(tt.bracketR);349base = this.finishNode(node, "MemberExpression");350} else if (!noCalls && this.eat(tt.parenL)) {351var node = this.startNodeAt(startPos, startLoc);352node.callee = base;353node.arguments = this.parseExprList(tt.parenR, false);354base = this.finishNode(node, "CallExpression");355} else if (this.type === tt.backQuote) {356var node = this.startNodeAt(startPos, startLoc);357node.tag = base;358node.quasi = this.parseTemplate();359base = this.finishNode(node, "TaggedTemplateExpression");360} else {361return base;362}363}364};365366// Parse an atomic expression — either a single token that is an367// expression, an expression started by a keyword like `function` or368// `new`, or an expression wrapped in punctuation like `()`, `[]`,369// or `{}`.370371pp.parseExprAtom = function (refShorthandDefaultPos) {372var node = undefined,373canBeArrow = this.potentialArrowAt == this.start;374switch (this.type) {375case tt._this:376case tt._super:377var type = this.type === tt._this ? "ThisExpression" : "Super";378node = this.startNode();379this.next();380return this.finishNode(node, type);381382case tt._yield:383if (this.inGenerator) this.unexpected();384385case tt.name:386var startPos = this.start,387startLoc = this.startLoc;388var id = this.parseIdent(this.type !== tt.name);389if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id]);390return id;391392case tt.regexp:393var value = this.value;394node = this.parseLiteral(value.value);395node.regex = { pattern: value.pattern, flags: value.flags };396return node;397398case tt.num:case tt.string:399return this.parseLiteral(this.value);400401case tt._null:case tt._true:case tt._false:402node = this.startNode();403node.value = this.type === tt._null ? null : this.type === tt._true;404node.raw = this.type.keyword;405this.next();406return this.finishNode(node, "Literal");407408case tt.parenL:409return this.parseParenAndDistinguishExpression(canBeArrow);410411case tt.bracketL:412node = this.startNode();413this.next();414// check whether this is array comprehension or regular array415if (this.options.ecmaVersion >= 7 && this.type === tt._for) {416return this.parseComprehension(node, false);417}418node.elements = this.parseExprList(tt.bracketR, true, true, refShorthandDefaultPos);419return this.finishNode(node, "ArrayExpression");420421case tt.braceL:422return this.parseObj(false, refShorthandDefaultPos);423424case tt._function:425node = this.startNode();426this.next();427return this.parseFunction(node, false);428429case tt._class:430return this.parseClass(this.startNode(), false);431432case tt._new:433return this.parseNew();434435case tt.backQuote:436return this.parseTemplate();437438default:439this.unexpected();440}441};442443pp.parseLiteral = function (value) {444var node = this.startNode();445node.value = value;446node.raw = this.input.slice(this.start, this.end);447this.next();448return this.finishNode(node, "Literal");449};450451pp.parseParenExpression = function () {452this.expect(tt.parenL);453var val = this.parseExpression();454this.expect(tt.parenR);455return val;456};457458pp.parseParenAndDistinguishExpression = function (canBeArrow) {459var startPos = this.start,460startLoc = this.startLoc,461val = undefined;462if (this.options.ecmaVersion >= 6) {463this.next();464465if (this.options.ecmaVersion >= 7 && this.type === tt._for) {466return this.parseComprehension(this.startNodeAt(startPos, startLoc), true);467}468469var innerStartPos = this.start,470innerStartLoc = this.startLoc;471var exprList = [],472first = true;473var refShorthandDefaultPos = { start: 0 },474spreadStart = undefined,475innerParenStart = undefined;476while (this.type !== tt.parenR) {477first ? first = false : this.expect(tt.comma);478if (this.type === tt.ellipsis) {479spreadStart = this.start;480exprList.push(this.parseParenItem(this.parseRest()));481break;482} else {483if (this.type === tt.parenL && !innerParenStart) {484innerParenStart = this.start;485}486exprList.push(this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem));487}488}489var innerEndPos = this.start,490innerEndLoc = this.startLoc;491this.expect(tt.parenR);492493if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) {494if (innerParenStart) this.unexpected(innerParenStart);495return this.parseParenArrowList(startPos, startLoc, exprList);496}497498if (!exprList.length) this.unexpected(this.lastTokStart);499if (spreadStart) this.unexpected(spreadStart);500if (refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start);501502if (exprList.length > 1) {503val = this.startNodeAt(innerStartPos, innerStartLoc);504val.expressions = exprList;505this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);506} else {507val = exprList[0];508}509} else {510val = this.parseParenExpression();511}512513if (this.options.preserveParens) {514var par = this.startNodeAt(startPos, startLoc);515par.expression = val;516return this.finishNode(par, "ParenthesizedExpression");517} else {518return val;519}520};521522pp.parseParenItem = function (item) {523return item;524};525526pp.parseParenArrowList = function (startPos, startLoc, exprList) {527return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList);528};529530// New's precedence is slightly tricky. It must allow its argument531// to be a `[]` or dot subscript expression, but not a call — at532// least, not without wrapping it in parentheses. Thus, it uses the533534var empty = [];535536pp.parseNew = function () {537var node = this.startNode();538var meta = this.parseIdent(true);539if (this.options.ecmaVersion >= 6 && this.eat(tt.dot)) {540node.meta = meta;541node.property = this.parseIdent(true);542if (node.property.name !== "target") this.raise(node.property.start, "The only valid meta property for new is new.target");543return this.finishNode(node, "MetaProperty");544}545var startPos = this.start,546startLoc = this.startLoc;547node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true);548if (this.eat(tt.parenL)) node.arguments = this.parseExprList(tt.parenR, false);else node.arguments = empty;549return this.finishNode(node, "NewExpression");550};551552// Parse template expression.553554pp.parseTemplateElement = function () {555var elem = this.startNode();556elem.value = {557raw: this.input.slice(this.start, this.end),558cooked: this.value559};560this.next();561elem.tail = this.type === tt.backQuote;562return this.finishNode(elem, "TemplateElement");563};564565pp.parseTemplate = function () {566var node = this.startNode();567this.next();568node.expressions = [];569var curElt = this.parseTemplateElement();570node.quasis = [curElt];571while (!curElt.tail) {572this.expect(tt.dollarBraceL);573node.expressions.push(this.parseExpression());574this.expect(tt.braceR);575node.quasis.push(curElt = this.parseTemplateElement());576}577this.next();578return this.finishNode(node, "TemplateLiteral");579};580581// Parse an object literal or binding pattern.582583pp.parseObj = function (isPattern, refShorthandDefaultPos) {584var node = this.startNode(),585first = true,586propHash = {};587node.properties = [];588this.next();589while (!this.eat(tt.braceR)) {590if (!first) {591this.expect(tt.comma);592if (this.afterTrailingComma(tt.braceR)) break;593} else first = false;594595var prop = this.startNode(),596isGenerator = undefined,597startPos = undefined,598startLoc = undefined;599if (this.options.ecmaVersion >= 6) {600prop.method = false;601prop.shorthand = false;602if (isPattern || refShorthandDefaultPos) {603startPos = this.start;604startLoc = this.startLoc;605}606if (!isPattern) isGenerator = this.eat(tt.star);607}608this.parsePropertyName(prop);609this.parsePropertyValue(prop, isPattern, isGenerator, startPos, startLoc, refShorthandDefaultPos);610this.checkPropClash(prop, propHash);611node.properties.push(this.finishNode(prop, "Property"));612}613return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression");614};615616pp.parsePropertyValue = function (prop, isPattern, isGenerator, startPos, startLoc, refShorthandDefaultPos) {617if (this.eat(tt.colon)) {618prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refShorthandDefaultPos);619prop.kind = "init";620} else if (this.options.ecmaVersion >= 6 && this.type === tt.parenL) {621if (isPattern) this.unexpected();622prop.kind = "init";623prop.method = true;624prop.value = this.parseMethod(isGenerator);625} 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)) {626if (isGenerator || isPattern) this.unexpected();627prop.kind = prop.key.name;628this.parsePropertyName(prop);629prop.value = this.parseMethod(false);630} else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {631prop.kind = "init";632if (isPattern) {633if (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);634prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);635} else if (this.type === tt.eq && refShorthandDefaultPos) {636if (!refShorthandDefaultPos.start) refShorthandDefaultPos.start = this.start;637prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);638} else {639prop.value = prop.key;640}641prop.shorthand = true;642} else this.unexpected();643};644645pp.parsePropertyName = function (prop) {646if (this.options.ecmaVersion >= 6) {647if (this.eat(tt.bracketL)) {648prop.computed = true;649prop.key = this.parseMaybeAssign();650this.expect(tt.bracketR);651return prop.key;652} else {653prop.computed = false;654}655}656return prop.key = this.type === tt.num || this.type === tt.string ? this.parseExprAtom() : this.parseIdent(true);657};658659// Initialize empty function node.660661pp.initFunction = function (node) {662node.id = null;663if (this.options.ecmaVersion >= 6) {664node.generator = false;665node.expression = false;666}667};668669// Parse object or class method.670671pp.parseMethod = function (isGenerator) {672var node = this.startNode();673this.initFunction(node);674this.expect(tt.parenL);675node.params = this.parseBindingList(tt.parenR, false, false);676var allowExpressionBody = undefined;677if (this.options.ecmaVersion >= 6) {678node.generator = isGenerator;679allowExpressionBody = true;680} else {681allowExpressionBody = false;682}683this.parseFunctionBody(node, allowExpressionBody);684return this.finishNode(node, "FunctionExpression");685};686687// Parse arrow function expression with given parameters.688689pp.parseArrowExpression = function (node, params) {690this.initFunction(node);691node.params = this.toAssignableList(params, true);692this.parseFunctionBody(node, true);693return this.finishNode(node, "ArrowFunctionExpression");694};695696// Parse function body and check parameters.697698pp.parseFunctionBody = function (node, allowExpression) {699var isExpression = allowExpression && this.type !== tt.braceL;700701if (isExpression) {702node.body = this.parseMaybeAssign();703node.expression = true;704} else {705// Start a new scope with regard to labels and the `inFunction`706// flag (restore them to their old value afterwards).707var oldInFunc = this.inFunction,708oldInGen = this.inGenerator,709oldLabels = this.labels;710this.inFunction = true;this.inGenerator = node.generator;this.labels = [];711node.body = this.parseBlock(true);712node.expression = false;713this.inFunction = oldInFunc;this.inGenerator = oldInGen;this.labels = oldLabels;714}715716// If this is a strict mode function, verify that argument names717// are not repeated, and it does not try to bind the words `eval`718// or `arguments`.719if (this.strict || !isExpression && node.body.body.length && this.isUseStrict(node.body.body[0])) {720var nameHash = {},721oldStrict = this.strict;722this.strict = true;723if (node.id) this.checkLVal(node.id, true);724for (var i = 0; i < node.params.length; i++) {725this.checkLVal(node.params[i], true, nameHash);726}this.strict = oldStrict;727}728};729730// Parses a comma-separated list of expressions, and returns them as731// an array. `close` is the token type that ends the list, and732// `allowEmpty` can be turned on to allow subsequent commas with733// nothing in between them to be parsed as `null` (which is needed734// for array literals).735736pp.parseExprList = function (close, allowTrailingComma, allowEmpty, refShorthandDefaultPos) {737var elts = [],738first = true;739while (!this.eat(close)) {740if (!first) {741this.expect(tt.comma);742if (allowTrailingComma && this.afterTrailingComma(close)) break;743} else first = false;744745if (allowEmpty && this.type === tt.comma) {746elts.push(null);747} else {748if (this.type === tt.ellipsis) elts.push(this.parseSpread(refShorthandDefaultPos));else elts.push(this.parseMaybeAssign(false, refShorthandDefaultPos));749}750}751return elts;752};753754// Parse the next token as an identifier. If `liberal` is true (used755// when parsing properties), it will also convert keywords into756// identifiers.757758pp.parseIdent = function (liberal) {759var node = this.startNode();760if (liberal && this.options.allowReserved == "never") liberal = false;761if (this.type === tt.name) {762if (!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");763node.name = this.value;764} else if (liberal && this.type.keyword) {765node.name = this.type.keyword;766} else {767this.unexpected();768}769this.next();770return this.finishNode(node, "Identifier");771};772773// Parses yield expression inside generator.774775pp.parseYield = function () {776var node = this.startNode();777this.next();778if (this.type == tt.semi || this.canInsertSemicolon() || this.type != tt.star && !this.type.startsExpr) {779node.delegate = false;780node.argument = null;781} else {782node.delegate = this.eat(tt.star);783node.argument = this.parseMaybeAssign();784}785return this.finishNode(node, "YieldExpression");786};787788// Parses array and generator comprehensions.789790pp.parseComprehension = function (node, isGenerator) {791node.blocks = [];792while (this.type === tt._for) {793var block = this.startNode();794this.next();795this.expect(tt.parenL);796block.left = this.parseBindingAtom();797this.checkLVal(block.left, true);798this.expectContextual("of");799block.right = this.parseExpression();800this.expect(tt.parenR);801node.blocks.push(this.finishNode(block, "ComprehensionBlock"));802}803node.filter = this.eat(tt._if) ? this.parseParenExpression() : null;804node.body = this.parseExpression();805this.expect(isGenerator ? tt.parenR : tt.bracketR);806node.generator = isGenerator;807return this.finishNode(node, "ComprehensionExpression");808};809810},{"./identifier":3,"./state":9,"./tokentype":13,"./util":14}],3:[function(_dereq_,module,exports){811812813// Test whether a given character code starts an identifier.814815"use strict";816817exports.isIdentifierStart = isIdentifierStart;818819// Test whether a given character is part of an identifier.820821exports.isIdentifierChar = isIdentifierChar;822exports.__esModule = true;823// This is a trick taken from Esprima. It turns out that, on824// non-Chrome browsers, to check whether a string is in a set, a825// predicate containing a big ugly `switch` statement is faster than826// a regular expression, and on Chrome the two are about on par.827// This function uses `eval` (non-lexical) to produce such a828// predicate from a space-separated string of words.829//830// It starts by sorting the words by length.831832// Removed to create an eval-free library833834// Reserved word lists for various dialects of the language835836var reservedWords = {8373: function anonymous(str) {838switch(str.length){case 6:switch(str){case "double":case "export":case "import":case "native":case "public":case "static":case "throws":return true}return false;case 4:switch(str){case "byte":case "char":case "enum":case "goto":case "long":return true}return false;case 5:switch(str){case "class":case "final":case "float":case "short":case "super":return true}return false;case 7:switch(str){case "boolean":case "extends":case "package":case "private":return true}return false;case 9:switch(str){case "interface":case "protected":case "transient":return true}return false;case 8:switch(str){case "abstract":case "volatile":return true}return false;case 10:return str === "implements";case 3:return str === "int";case 12:return str === "synchronized";}839},8405: function anonymous(str) {841switch(str.length){case 5:switch(str){case "class":case "super":case "const":return true}return false;case 6:switch(str){case "export":case "import":return true}return false;case 4:return str === "enum";case 7:return str === "extends";}842},8436: function anonymous(str) {844switch(str){case "enum":case "await":return true}return false;845},846strict: function anonymous(str) {847switch(str.length){case 9:switch(str){case "interface":case "protected":return true}return false;case 7:switch(str){case "package":case "private":return true}return false;case 6:switch(str){case "public":case "static":return true}return false;case 10:return str === "implements";case 3:return str === "let";case 5:return str === "yield";}848},849strictBind: function anonymous(str) {850switch(str){case "eval":case "arguments":return true}return false;851}852};853854exports.reservedWords = reservedWords;855// And the keywords856857var 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";858859var keywords = {8605: function anonymous(str) {861switch(str.length){case 4:switch(str){case "case":case "else":case "with":case "null":case "true":case "void":case "this":return true}return false;case 5:switch(str){case "break":case "catch":case "throw":case "while":case "false":return true}return false;case 3:switch(str){case "for":case "try":case "var":case "new":return true}return false;case 6:switch(str){case "return":case "switch":case "typeof":case "delete":return true}return false;case 8:switch(str){case "continue":case "debugger":case "function":return true}return false;case 2:switch(str){case "do":case "if":case "in":return true}return false;case 7:switch(str){case "default":case "finally":return true}return false;case 10:return str === "instanceof";}862},8636: function anonymous(str) {864switch(str.length){case 5:switch(str){case "break":case "catch":case "throw":case "while":case "false":case "const":case "class":case "yield":case "super":return true}return false;case 4:switch(str){case "case":case "else":case "with":case "null":case "true":case "void":case "this":return true}return false;case 6:switch(str){case "return":case "switch":case "typeof":case "delete":case "export":case "import":return true}return false;case 3:switch(str){case "for":case "try":case "var":case "new":case "let":return true}return false;case 8:switch(str){case "continue":case "debugger":case "function":return true}return false;case 7:switch(str){case "default":case "finally":case "extends":return true}return false;case 2:switch(str){case "do":case "if":case "in":return true}return false;case 10:return str === "instanceof";}865}866};867868exports.keywords = keywords;869// ## Character categories870871// Big ugly regular expressions that match characters in the872// whitespace, identifier, and identifier-start categories. These873// are only applied when a character is found to actually have a874// code point above 128.875// Generated by `tools/generate-identifier-regex.js`.876877var nonASCIIidentifierStartChars = "ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠ-ࢲऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞭꞰꞱꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭟꭤꭥꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ";878var nonASCIIidentifierChars = "·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣤ-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఃా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഁ-ഃാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏ᦰ-ᧀᧈᧉ᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳸᳹᷀-᷵᷼-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-꣄꣐-꣙꣠-꣱꤀-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︭︳︴﹍-﹏0-9_";879880var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");881var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");882883nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;884885// These are a run-length and offset encoded representation of the886// >0xffff code points that are a valid part of identifiers. The887// offset starts at 0x10000, and each pair of numbers represents an888// offset to the next range, and then a size of the range. They were889// generated by tools/generate-identifier-regex.js890var 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];891var 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];892893// This has a complexity linear to the value of the code. The894// assumption is that looking up astral identifier characters is895// rare.896function isInAstralSet(code, set) {897var pos = 65536;898for (var i = 0; i < set.length; i += 2) {899pos += set[i];900if (pos > code) {901return false;902}pos += set[i + 1];903if (pos >= code) {904return true;905}906}907}908function isIdentifierStart(code, astral) {909if (code < 65) {910return code === 36;911}if (code < 91) {912return true;913}if (code < 97) {914return code === 95;915}if (code < 123) {916return true;917}if (code <= 65535) {918return code >= 170 && nonASCIIidentifierStart.test(String.fromCharCode(code));919}if (astral === false) {920return false;921}return isInAstralSet(code, astralIdentifierStartCodes);922}923924function isIdentifierChar(code, astral) {925if (code < 48) {926return code === 36;927}if (code < 58) {928return true;929}if (code < 65) {930return false;931}if (code < 91) {932return true;933}if (code < 97) {934return code === 95;935}if (code < 123) {936return true;937}if (code <= 65535) {938return code >= 170 && nonASCIIidentifier.test(String.fromCharCode(code));939}if (astral === false) {940return false;941}return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);942}943944},{}],4:[function(_dereq_,module,exports){945"use strict";946947var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };948949// The `getLineInfo` function is mostly useful when the950// `locations` option is off (for performance reasons) and you951// want to find the line/column position for a given character952// offset. `input` should be the code string that the offset refers953// into.954955exports.getLineInfo = getLineInfo;956exports.__esModule = true;957958var Parser = _dereq_("./state").Parser;959960var lineBreakG = _dereq_("./whitespace").lineBreakG;961962// These are used when `options.locations` is on, for the963// `startLoc` and `endLoc` properties.964965var Position = exports.Position = (function () {966function Position(line, col) {967_classCallCheck(this, Position);968969this.line = line;970this.column = col;971}972973Position.prototype.offset = function offset(n) {974return new Position(this.line, this.column + n);975};976977return Position;978})();979980var SourceLocation = exports.SourceLocation = function SourceLocation(p, start, end) {981_classCallCheck(this, SourceLocation);982983this.start = start;984this.end = end;985if (p.sourceFile !== null) this.source = p.sourceFile;986};987988function getLineInfo(input, offset) {989for (var line = 1, cur = 0;;) {990lineBreakG.lastIndex = cur;991var match = lineBreakG.exec(input);992if (match && match.index < offset) {993++line;994cur = match.index + match[0].length;995} else {996return new Position(line, offset - cur);997}998}999}10001001var pp = Parser.prototype;10021003// This function is used to raise exceptions on parse errors. It1004// takes an offset integer (into the current `input`) to indicate1005// the location of the error, attaches the position to the end1006// of the error message, and then raises a `SyntaxError` with that1007// message.10081009pp.raise = function (pos, message) {1010var loc = getLineInfo(this.input, pos);1011message += " (" + loc.line + ":" + loc.column + ")";1012var err = new SyntaxError(message);1013err.pos = pos;err.loc = loc;err.raisedAt = this.pos;1014throw err;1015};10161017pp.curPosition = function () {1018return new Position(this.curLine, this.pos - this.lineStart);1019};10201021},{"./state":9,"./whitespace":15}],5:[function(_dereq_,module,exports){1022"use strict";10231024var tt = _dereq_("./tokentype").types;10251026var Parser = _dereq_("./state").Parser;10271028var reservedWords = _dereq_("./identifier").reservedWords;10291030var has = _dereq_("./util").has;10311032var pp = Parser.prototype;10331034// Convert existing expression atom to assignable pattern1035// if possible.10361037pp.toAssignable = function (node, isBinding) {1038if (this.options.ecmaVersion >= 6 && node) {1039switch (node.type) {1040case "Identifier":1041case "ObjectPattern":1042case "ArrayPattern":1043case "AssignmentPattern":1044break;10451046case "ObjectExpression":1047node.type = "ObjectPattern";1048for (var i = 0; i < node.properties.length; i++) {1049var prop = node.properties[i];1050if (prop.kind !== "init") this.raise(prop.key.start, "Object pattern can't contain getter or setter");1051this.toAssignable(prop.value, isBinding);1052}1053break;10541055case "ArrayExpression":1056node.type = "ArrayPattern";1057this.toAssignableList(node.elements, isBinding);1058break;10591060case "AssignmentExpression":1061if (node.operator === "=") {1062node.type = "AssignmentPattern";1063} else {1064this.raise(node.left.end, "Only '=' operator can be used for specifying default value.");1065}1066break;10671068case "ParenthesizedExpression":1069node.expression = this.toAssignable(node.expression, isBinding);1070break;10711072case "MemberExpression":1073if (!isBinding) break;10741075default:1076this.raise(node.start, "Assigning to rvalue");1077}1078}1079return node;1080};10811082// Convert list of expression atoms to binding list.10831084pp.toAssignableList = function (exprList, isBinding) {1085var end = exprList.length;1086if (end) {1087var last = exprList[end - 1];1088if (last && last.type == "RestElement") {1089--end;1090} else if (last && last.type == "SpreadElement") {1091last.type = "RestElement";1092var arg = last.argument;1093this.toAssignable(arg, isBinding);1094if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern") this.unexpected(arg.start);1095--end;1096}1097}1098for (var i = 0; i < end; i++) {1099var elt = exprList[i];1100if (elt) this.toAssignable(elt, isBinding);1101}1102return exprList;1103};11041105// Parses spread element.11061107pp.parseSpread = function (refShorthandDefaultPos) {1108var node = this.startNode();1109this.next();1110node.argument = this.parseMaybeAssign(refShorthandDefaultPos);1111return this.finishNode(node, "SpreadElement");1112};11131114pp.parseRest = function () {1115var node = this.startNode();1116this.next();1117node.argument = this.type === tt.name || this.type === tt.bracketL ? this.parseBindingAtom() : this.unexpected();1118return this.finishNode(node, "RestElement");1119};11201121// Parses lvalue (assignable) atom.11221123pp.parseBindingAtom = function () {1124if (this.options.ecmaVersion < 6) return this.parseIdent();1125switch (this.type) {1126case tt.name:1127return this.parseIdent();11281129case tt.bracketL:1130var node = this.startNode();1131this.next();1132node.elements = this.parseBindingList(tt.bracketR, true, true);1133return this.finishNode(node, "ArrayPattern");11341135case tt.braceL:1136return this.parseObj(true);11371138default:1139this.unexpected();1140}1141};11421143pp.parseBindingList = function (close, allowEmpty, allowTrailingComma) {1144var elts = [],1145first = true;1146while (!this.eat(close)) {1147if (first) first = false;else this.expect(tt.comma);1148if (allowEmpty && this.type === tt.comma) {1149elts.push(null);1150} else if (allowTrailingComma && this.afterTrailingComma(close)) {1151break;1152} else if (this.type === tt.ellipsis) {1153var rest = this.parseRest();1154this.parseBindingListItem(rest);1155elts.push(rest);1156this.expect(close);1157break;1158} else {1159var elem = this.parseMaybeDefault(this.start, this.startLoc);1160this.parseBindingListItem(elem);1161elts.push(elem);1162}1163}1164return elts;1165};11661167pp.parseBindingListItem = function (param) {1168return param;1169};11701171// Parses assignment pattern around given atom if possible.11721173pp.parseMaybeDefault = function (startPos, startLoc, left) {1174left = left || this.parseBindingAtom();1175if (!this.eat(tt.eq)) return left;1176var node = this.startNodeAt(startPos, startLoc);1177node.operator = "=";1178node.left = left;1179node.right = this.parseMaybeAssign();1180return this.finishNode(node, "AssignmentPattern");1181};11821183// Verify that a node is an lval — something that can be assigned1184// to.11851186pp.checkLVal = function (expr, isBinding, checkClashes) {1187switch (expr.type) {1188case "Identifier":1189if (this.strict && (reservedWords.strictBind(expr.name) || reservedWords.strict(expr.name))) this.raise(expr.start, (isBinding ? "Binding " : "Assigning to ") + expr.name + " in strict mode");1190if (checkClashes) {1191if (has(checkClashes, expr.name)) this.raise(expr.start, "Argument name clash in strict mode");1192checkClashes[expr.name] = true;1193}1194break;11951196case "MemberExpression":1197if (isBinding) this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " member expression");1198break;11991200case "ObjectPattern":1201for (var i = 0; i < expr.properties.length; i++) {1202this.checkLVal(expr.properties[i].value, isBinding, checkClashes);1203}break;12041205case "ArrayPattern":1206for (var i = 0; i < expr.elements.length; i++) {1207var elem = expr.elements[i];1208if (elem) this.checkLVal(elem, isBinding, checkClashes);1209}1210break;12111212case "AssignmentPattern":1213this.checkLVal(expr.left, isBinding, checkClashes);1214break;12151216case "RestElement":1217this.checkLVal(expr.argument, isBinding, checkClashes);1218break;12191220case "ParenthesizedExpression":1221this.checkLVal(expr.expression, isBinding, checkClashes);1222break;12231224default:1225this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " rvalue");1226}1227};12281229},{"./identifier":3,"./state":9,"./tokentype":13,"./util":14}],6:[function(_dereq_,module,exports){1230"use strict";12311232var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };12331234exports.__esModule = true;12351236var Parser = _dereq_("./state").Parser;12371238var SourceLocation = _dereq_("./location").SourceLocation;12391240// Start an AST node, attaching a start offset.12411242var pp = Parser.prototype;12431244var Node = exports.Node = function Node() {1245_classCallCheck(this, Node);1246};12471248pp.startNode = function () {1249var node = new Node();1250node.start = this.start;1251if (this.options.locations) node.loc = new SourceLocation(this, this.startLoc);1252if (this.options.directSourceFile) node.sourceFile = this.options.directSourceFile;1253if (this.options.ranges) node.range = [this.start, 0];1254return node;1255};12561257pp.startNodeAt = function (pos, loc) {1258var node = new Node();1259node.start = pos;1260if (this.options.locations) node.loc = new SourceLocation(this, loc);1261if (this.options.directSourceFile) node.sourceFile = this.options.directSourceFile;1262if (this.options.ranges) node.range = [pos, 0];1263return node;1264};12651266// Finish an AST node, adding `type` and `end` properties.12671268pp.finishNode = function (node, type) {1269node.type = type;1270node.end = this.lastTokEnd;1271if (this.options.locations) node.loc.end = this.lastTokEndLoc;1272if (this.options.ranges) node.range[1] = this.lastTokEnd;1273return node;1274};12751276// Finish node at given position12771278pp.finishNodeAt = function (node, type, pos, loc) {1279node.type = type;1280node.end = pos;1281if (this.options.locations) node.loc.end = loc;1282if (this.options.ranges) node.range[1] = pos;1283return node;1284};12851286},{"./location":4,"./state":9}],7:[function(_dereq_,module,exports){128712881289// Interpret and default an options object12901291"use strict";12921293exports.getOptions = getOptions;1294exports.__esModule = true;12951296var _util = _dereq_("./util");12971298var has = _util.has;1299var isArray = _util.isArray;13001301var SourceLocation = _dereq_("./location").SourceLocation;13021303// A second optional argument can be given to further configure1304// the parser process. These options are recognized:13051306var defaultOptions = {1307// `ecmaVersion` indicates the ECMAScript version to parse. Must1308// be either 3, or 5, or 6. This influences support for strict1309// mode, the set of reserved words, support for getters and1310// setters and other features.1311ecmaVersion: 5,1312// Source type ("script" or "module") for different semantics1313sourceType: "script",1314// `onInsertedSemicolon` can be a callback that will be called1315// when a semicolon is automatically inserted. It will be passed1316// th position of the comma as an offset, and if `locations` is1317// enabled, it is given the location as a `{line, column}` object1318// as second argument.1319onInsertedSemicolon: null,1320// `onTrailingComma` is similar to `onInsertedSemicolon`, but for1321// trailing commas.1322onTrailingComma: null,1323// By default, reserved words are not enforced. Disable1324// `allowReserved` to enforce them. When this option has the1325// value "never", reserved words and keywords can also not be1326// used as property names.1327allowReserved: true,1328// When enabled, a return at the top level is not considered an1329// error.1330allowReturnOutsideFunction: false,1331// When enabled, import/export statements are not constrained to1332// appearing at the top of the program.1333allowImportExportEverywhere: false,1334// When enabled, hashbang directive in the beginning of file1335// is allowed and treated as a line comment.1336allowHashBang: false,1337// When `locations` is on, `loc` properties holding objects with1338// `start` and `end` properties in `{line, column}` form (with1339// line being 1-based and column 0-based) will be attached to the1340// nodes.1341locations: false,1342// A function can be passed as `onToken` option, which will1343// cause Acorn to call that function with object in the same1344// format as tokenize() returns. Note that you are not1345// allowed to call the parser from the callback—that will1346// corrupt its internal state.1347onToken: null,1348// A function can be passed as `onComment` option, which will1349// cause Acorn to call that function with `(block, text, start,1350// end)` parameters whenever a comment is skipped. `block` is a1351// boolean indicating whether this is a block (`/* */`) comment,1352// `text` is the content of the comment, and `start` and `end` are1353// character offsets that denote the start and end of the comment.1354// When the `locations` option is on, two more parameters are1355// passed, the full `{line, column}` locations of the start and1356// end of the comments. Note that you are not allowed to call the1357// parser from the callback—that will corrupt its internal state.1358onComment: null,1359// Nodes have their start and end characters offsets recorded in1360// `start` and `end` properties (directly on the node, rather than1361// the `loc` object, which holds line/column data. To also add a1362// [semi-standardized][range] `range` property holding a `[start,1363// end]` array with the same numbers, set the `ranges` option to1364// `true`.1365//1366// [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=7456781367ranges: false,1368// It is possible to parse multiple files into a single AST by1369// passing the tree produced by parsing the first file as1370// `program` option in subsequent parses. This will add the1371// toplevel forms of the parsed file to the `Program` (top) node1372// of an existing parse tree.1373program: null,1374// When `locations` is on, you can pass this to record the source1375// file in every node's `loc` object.1376sourceFile: null,1377// This value, if given, is stored in every node, whether1378// `locations` is on or off.1379directSourceFile: null,1380// When enabled, parenthesized expressions are represented by1381// (non-standard) ParenthesizedExpression nodes1382preserveParens: false,1383plugins: {}1384};exports.defaultOptions = defaultOptions;13851386function getOptions(opts) {1387var options = {};1388for (var opt in defaultOptions) {1389options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt];1390}if (isArray(options.onToken)) {1391(function () {1392var tokens = options.onToken;1393options.onToken = function (token) {1394return tokens.push(token);1395};1396})();1397}1398if (isArray(options.onComment)) options.onComment = pushComment(options, options.onComment);13991400return options;1401}14021403function pushComment(options, array) {1404return function (block, text, start, end, startLoc, endLoc) {1405var comment = {1406type: block ? "Block" : "Line",1407value: text,1408start: start,1409end: end1410};1411if (options.locations) comment.loc = new SourceLocation(this, startLoc, endLoc);1412if (options.ranges) comment.range = [start, end];1413array.push(comment);1414};1415}14161417},{"./location":4,"./util":14}],8:[function(_dereq_,module,exports){1418"use strict";14191420var tt = _dereq_("./tokentype").types;14211422var Parser = _dereq_("./state").Parser;14231424var lineBreak = _dereq_("./whitespace").lineBreak;14251426var pp = Parser.prototype;14271428// ## Parser utilities14291430// Test whether a statement node is the string literal `"use strict"`.14311432pp.isUseStrict = function (stmt) {1433return this.options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && stmt.expression.value === "use strict";1434};14351436// Predicate that tests whether the next token is of the given1437// type, and if yes, consumes it as a side effect.14381439pp.eat = function (type) {1440if (this.type === type) {1441this.next();1442return true;1443} else {1444return false;1445}1446};14471448// Tests whether parsed token is a contextual keyword.14491450pp.isContextual = function (name) {1451return this.type === tt.name && this.value === name;1452};14531454// Consumes contextual keyword if possible.14551456pp.eatContextual = function (name) {1457return this.value === name && this.eat(tt.name);1458};14591460// Asserts that following token is given contextual keyword.14611462pp.expectContextual = function (name) {1463if (!this.eatContextual(name)) this.unexpected();1464};14651466// Test whether a semicolon can be inserted at the current position.14671468pp.canInsertSemicolon = function () {1469return this.type === tt.eof || this.type === tt.braceR || lineBreak.test(this.input.slice(this.lastTokEnd, this.start));1470};14711472pp.insertSemicolon = function () {1473if (this.canInsertSemicolon()) {1474if (this.options.onInsertedSemicolon) this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc);1475return true;1476}1477};14781479// Consume a semicolon, or, failing that, see if we are allowed to1480// pretend that there is a semicolon at this position.14811482pp.semicolon = function () {1483if (!this.eat(tt.semi) && !this.insertSemicolon()) this.unexpected();1484};14851486pp.afterTrailingComma = function (tokType) {1487if (this.type == tokType) {1488if (this.options.onTrailingComma) this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc);1489this.next();1490return true;1491}1492};14931494// Expect a token of a given type. If found, consume it, otherwise,1495// raise an unexpected token error.14961497pp.expect = function (type) {1498this.eat(type) || this.unexpected();1499};15001501// Raise an unexpected token error.15021503pp.unexpected = function (pos) {1504this.raise(pos != null ? pos : this.start, "Unexpected token");1505};15061507},{"./state":9,"./tokentype":13,"./whitespace":15}],9:[function(_dereq_,module,exports){1508"use strict";15091510exports.Parser = Parser;1511exports.__esModule = true;15121513var _identifier = _dereq_("./identifier");15141515var reservedWords = _identifier.reservedWords;1516var keywords = _identifier.keywords;15171518var tt = _dereq_("./tokentype").types;15191520var lineBreak = _dereq_("./whitespace").lineBreak;15211522function Parser(options, input, startPos) {1523this.options = options;1524this.sourceFile = this.options.sourceFile || null;1525this.isKeyword = keywords[this.options.ecmaVersion >= 6 ? 6 : 5];1526this.isReservedWord = reservedWords[this.options.ecmaVersion];1527this.input = input;15281529// Load plugins1530this.loadPlugins(this.options.plugins);15311532// Set up token state15331534// The current position of the tokenizer in the input.1535if (startPos) {1536this.pos = startPos;1537this.lineStart = Math.max(0, this.input.lastIndexOf("\n", startPos));1538this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;1539} else {1540this.pos = this.lineStart = 0;1541this.curLine = 1;1542}15431544// Properties of the current token:1545// Its type1546this.type = tt.eof;1547// For tokens that include more information than their type, the value1548this.value = null;1549// Its start and end offset1550this.start = this.end = this.pos;1551// And, if locations are used, the {line, column} object1552// corresponding to those offsets1553this.startLoc = this.endLoc = null;15541555// Position information for the previous token1556this.lastTokEndLoc = this.lastTokStartLoc = null;1557this.lastTokStart = this.lastTokEnd = this.pos;15581559// The context stack is used to superficially track syntactic1560// context to predict whether a regular expression is allowed in a1561// given position.1562this.context = this.initialContext();1563this.exprAllowed = true;15641565// Figure out if it's a module code.1566this.strict = this.inModule = this.options.sourceType === "module";15671568// Used to signify the start of a potential arrow function1569this.potentialArrowAt = -1;15701571// Flags to track whether we are in a function, a generator.1572this.inFunction = this.inGenerator = false;1573// Labels in scope.1574this.labels = [];15751576// If enabled, skip leading hashbang line.1577if (this.pos === 0 && this.options.allowHashBang && this.input.slice(0, 2) === "#!") this.skipLineComment(2);1578}15791580Parser.prototype.extend = function (name, f) {1581this[name] = f(this[name]);1582};15831584// Registered plugins15851586var plugins = {};15871588exports.plugins = plugins;1589Parser.prototype.loadPlugins = function (plugins) {1590for (var _name in plugins) {1591var plugin = exports.plugins[_name];1592if (!plugin) throw new Error("Plugin '" + _name + "' not found");1593plugin(this, plugins[_name]);1594}1595};15961597},{"./identifier":3,"./tokentype":13,"./whitespace":15}],10:[function(_dereq_,module,exports){1598"use strict";15991600var tt = _dereq_("./tokentype").types;16011602var Parser = _dereq_("./state").Parser;16031604var lineBreak = _dereq_("./whitespace").lineBreak;16051606var pp = Parser.prototype;16071608// ### Statement parsing16091610// Parse a program. Initializes the parser, reads any number of1611// statements, and wraps them in a Program node. Optionally takes a1612// `program` argument. If present, the statements will be appended1613// to its body instead of creating a new node.16141615pp.parseTopLevel = function (node) {1616var first = true;1617if (!node.body) node.body = [];1618while (this.type !== tt.eof) {1619var stmt = this.parseStatement(true, true);1620node.body.push(stmt);1621if (first && this.isUseStrict(stmt)) this.setStrict(true);1622first = false;1623}1624this.next();1625if (this.options.ecmaVersion >= 6) {1626node.sourceType = this.options.sourceType;1627}1628return this.finishNode(node, "Program");1629};16301631var loopLabel = { kind: "loop" },1632switchLabel = { kind: "switch" };16331634// Parse a single statement.1635//1636// If expecting a statement and finding a slash operator, parse a1637// regular expression literal. This is to handle cases like1638// `if (foo) /blah/.exec(foo)`, where looking at the previous token1639// does not help.16401641pp.parseStatement = function (declaration, topLevel) {1642var starttype = this.type,1643node = this.startNode();16441645// Most types of statements are recognized by the keyword they1646// start with. Many are trivial to parse, some require a bit of1647// complexity.16481649switch (starttype) {1650case tt._break:case tt._continue:1651return this.parseBreakContinueStatement(node, starttype.keyword);1652case tt._debugger:1653return this.parseDebuggerStatement(node);1654case tt._do:1655return this.parseDoStatement(node);1656case tt._for:1657return this.parseForStatement(node);1658case tt._function:1659if (!declaration && this.options.ecmaVersion >= 6) this.unexpected();1660return this.parseFunctionStatement(node);1661case tt._class:1662if (!declaration) this.unexpected();1663return this.parseClass(node, true);1664case tt._if:1665return this.parseIfStatement(node);1666case tt._return:1667return this.parseReturnStatement(node);1668case tt._switch:1669return this.parseSwitchStatement(node);1670case tt._throw:1671return this.parseThrowStatement(node);1672case tt._try:1673return this.parseTryStatement(node);1674case tt._let:case tt._const:1675if (!declaration) this.unexpected(); // NOTE: falls through to _var1676case tt._var:1677return this.parseVarStatement(node, starttype);1678case tt._while:1679return this.parseWhileStatement(node);1680case tt._with:1681return this.parseWithStatement(node);1682case tt.braceL:1683return this.parseBlock();1684case tt.semi:1685return this.parseEmptyStatement(node);1686case tt._export:1687case tt._import:1688if (!this.options.allowImportExportEverywhere) {1689if (!topLevel) this.raise(this.start, "'import' and 'export' may only appear at the top level");1690if (!this.inModule) this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");1691}1692return starttype === tt._import ? this.parseImport(node) : this.parseExport(node);16931694// If the statement does not start with a statement keyword or a1695// brace, it's an ExpressionStatement or LabeledStatement. We1696// simply start parsing an expression, and afterwards, if the1697// next token is a colon and the expression was a simple1698// Identifier node, we switch to interpreting it as a label.1699default:1700var maybeName = this.value,1701expr = this.parseExpression();1702if (starttype === tt.name && expr.type === "Identifier" && this.eat(tt.colon)) return this.parseLabeledStatement(node, maybeName, expr);else return this.parseExpressionStatement(node, expr);1703}1704};17051706pp.parseBreakContinueStatement = function (node, keyword) {1707var isBreak = keyword == "break";1708this.next();1709if (this.eat(tt.semi) || this.insertSemicolon()) node.label = null;else if (this.type !== tt.name) this.unexpected();else {1710node.label = this.parseIdent();1711this.semicolon();1712}17131714// Verify that there is an actual destination to break or1715// continue to.1716for (var i = 0; i < this.labels.length; ++i) {1717var lab = this.labels[i];1718if (node.label == null || lab.name === node.label.name) {1719if (lab.kind != null && (isBreak || lab.kind === "loop")) break;1720if (node.label && isBreak) break;1721}1722}1723if (i === this.labels.length) this.raise(node.start, "Unsyntactic " + keyword);1724return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");1725};17261727pp.parseDebuggerStatement = function (node) {1728this.next();1729this.semicolon();1730return this.finishNode(node, "DebuggerStatement");1731};17321733pp.parseDoStatement = function (node) {1734this.next();1735this.labels.push(loopLabel);1736node.body = this.parseStatement(false);1737this.labels.pop();1738this.expect(tt._while);1739node.test = this.parseParenExpression();1740if (this.options.ecmaVersion >= 6) this.eat(tt.semi);else this.semicolon();1741return this.finishNode(node, "DoWhileStatement");1742};17431744// Disambiguating between a `for` and a `for`/`in` or `for`/`of`1745// loop is non-trivial. Basically, we have to parse the init `var`1746// statement or expression, disallowing the `in` operator (see1747// the second parameter to `parseExpression`), and then check1748// whether the next token is `in` or `of`. When there is no init1749// part (semicolon immediately after the opening parenthesis), it1750// is a regular `for` loop.17511752pp.parseForStatement = function (node) {1753this.next();1754this.labels.push(loopLabel);1755this.expect(tt.parenL);1756if (this.type === tt.semi) return this.parseFor(node, null);1757if (this.type === tt._var || this.type === tt._let || this.type === tt._const) {1758var _init = this.startNode(),1759varKind = this.type;1760this.next();1761this.parseVar(_init, true, varKind);1762this.finishNode(_init, "VariableDeclaration");1763if ((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);1764return this.parseFor(node, _init);1765}1766var refShorthandDefaultPos = { start: 0 };1767var init = this.parseExpression(true, refShorthandDefaultPos);1768if (this.type === tt._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) {1769this.toAssignable(init);1770this.checkLVal(init);1771return this.parseForIn(node, init);1772} else if (refShorthandDefaultPos.start) {1773this.unexpected(refShorthandDefaultPos.start);1774}1775return this.parseFor(node, init);1776};17771778pp.parseFunctionStatement = function (node) {1779this.next();1780return this.parseFunction(node, true);1781};17821783pp.parseIfStatement = function (node) {1784this.next();1785node.test = this.parseParenExpression();1786node.consequent = this.parseStatement(false);1787node.alternate = this.eat(tt._else) ? this.parseStatement(false) : null;1788return this.finishNode(node, "IfStatement");1789};17901791pp.parseReturnStatement = function (node) {1792if (!this.inFunction && !this.options.allowReturnOutsideFunction) this.raise(this.start, "'return' outside of function");1793this.next();17941795// In `return` (and `break`/`continue`), the keywords with1796// optional arguments, we eagerly look for a semicolon or the1797// possibility to insert one.17981799if (this.eat(tt.semi) || this.insertSemicolon()) node.argument = null;else {1800node.argument = this.parseExpression();this.semicolon();1801}1802return this.finishNode(node, "ReturnStatement");1803};18041805pp.parseSwitchStatement = function (node) {1806this.next();1807node.discriminant = this.parseParenExpression();1808node.cases = [];1809this.expect(tt.braceL);1810this.labels.push(switchLabel);18111812// Statements under must be grouped (by label) in SwitchCase1813// nodes. `cur` is used to keep the node that we are currently1814// adding statements to.18151816for (var cur, sawDefault; this.type != tt.braceR;) {1817if (this.type === tt._case || this.type === tt._default) {1818var isCase = this.type === tt._case;1819if (cur) this.finishNode(cur, "SwitchCase");1820node.cases.push(cur = this.startNode());1821cur.consequent = [];1822this.next();1823if (isCase) {1824cur.test = this.parseExpression();1825} else {1826if (sawDefault) this.raise(this.lastTokStart, "Multiple default clauses");1827sawDefault = true;1828cur.test = null;1829}1830this.expect(tt.colon);1831} else {1832if (!cur) this.unexpected();1833cur.consequent.push(this.parseStatement(true));1834}1835}1836if (cur) this.finishNode(cur, "SwitchCase");1837this.next(); // Closing brace1838this.labels.pop();1839return this.finishNode(node, "SwitchStatement");1840};18411842pp.parseThrowStatement = function (node) {1843this.next();1844if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) this.raise(this.lastTokEnd, "Illegal newline after throw");1845node.argument = this.parseExpression();1846this.semicolon();1847return this.finishNode(node, "ThrowStatement");1848};18491850// Reused empty array added for node fields that are always empty.18511852var empty = [];18531854pp.parseTryStatement = function (node) {1855this.next();1856node.block = this.parseBlock();1857node.handler = null;1858if (this.type === tt._catch) {1859var clause = this.startNode();1860this.next();1861this.expect(tt.parenL);1862clause.param = this.parseBindingAtom();1863this.checkLVal(clause.param, true);1864this.expect(tt.parenR);1865clause.guard = null;1866clause.body = this.parseBlock();1867node.handler = this.finishNode(clause, "CatchClause");1868}1869node.guardedHandlers = empty;1870node.finalizer = this.eat(tt._finally) ? this.parseBlock() : null;1871if (!node.handler && !node.finalizer) this.raise(node.start, "Missing catch or finally clause");1872return this.finishNode(node, "TryStatement");1873};18741875pp.parseVarStatement = function (node, kind) {1876this.next();1877this.parseVar(node, false, kind);1878this.semicolon();1879return this.finishNode(node, "VariableDeclaration");1880};18811882pp.parseWhileStatement = function (node) {1883this.next();1884node.test = this.parseParenExpression();1885this.labels.push(loopLabel);1886node.body = this.parseStatement(false);1887this.labels.pop();1888return this.finishNode(node, "WhileStatement");1889};18901891pp.parseWithStatement = function (node) {1892if (this.strict) this.raise(this.start, "'with' in strict mode");1893this.next();1894node.object = this.parseParenExpression();1895node.body = this.parseStatement(false);1896return this.finishNode(node, "WithStatement");1897};18981899pp.parseEmptyStatement = function (node) {1900this.next();1901return this.finishNode(node, "EmptyStatement");1902};19031904pp.parseLabeledStatement = function (node, maybeName, expr) {1905for (var i = 0; i < this.labels.length; ++i) {1906if (this.labels[i].name === maybeName) this.raise(expr.start, "Label '" + maybeName + "' is already declared");1907}var kind = this.type.isLoop ? "loop" : this.type === tt._switch ? "switch" : null;1908this.labels.push({ name: maybeName, kind: kind });1909node.body = this.parseStatement(true);1910this.labels.pop();1911node.label = expr;1912return this.finishNode(node, "LabeledStatement");1913};19141915pp.parseExpressionStatement = function (node, expr) {1916node.expression = expr;1917this.semicolon();1918return this.finishNode(node, "ExpressionStatement");1919};19201921// Parse a semicolon-enclosed block of statements, handling `"use1922// strict"` declarations when `allowStrict` is true (used for1923// function bodies).19241925pp.parseBlock = function (allowStrict) {1926var node = this.startNode(),1927first = true,1928oldStrict = undefined;1929node.body = [];1930this.expect(tt.braceL);1931while (!this.eat(tt.braceR)) {1932var stmt = this.parseStatement(true);1933node.body.push(stmt);1934if (first && allowStrict && this.isUseStrict(stmt)) {1935oldStrict = this.strict;1936this.setStrict(this.strict = true);1937}1938first = false;1939}1940if (oldStrict === false) this.setStrict(false);1941return this.finishNode(node, "BlockStatement");1942};19431944// Parse a regular `for` loop. The disambiguation code in1945// `parseStatement` will already have parsed the init statement or1946// expression.19471948pp.parseFor = function (node, init) {1949node.init = init;1950this.expect(tt.semi);1951node.test = this.type === tt.semi ? null : this.parseExpression();1952this.expect(tt.semi);1953node.update = this.type === tt.parenR ? null : this.parseExpression();1954this.expect(tt.parenR);1955node.body = this.parseStatement(false);1956this.labels.pop();1957return this.finishNode(node, "ForStatement");1958};19591960// Parse a `for`/`in` and `for`/`of` loop, which are almost1961// same from parser's perspective.19621963pp.parseForIn = function (node, init) {1964var type = this.type === tt._in ? "ForInStatement" : "ForOfStatement";1965this.next();1966node.left = init;1967node.right = this.parseExpression();1968this.expect(tt.parenR);1969node.body = this.parseStatement(false);1970this.labels.pop();1971return this.finishNode(node, type);1972};19731974// Parse a list of variable declarations.19751976pp.parseVar = function (node, isFor, kind) {1977node.declarations = [];1978node.kind = kind.keyword;1979for (;;) {1980var decl = this.startNode();1981this.parseVarId(decl);1982if (this.eat(tt.eq)) {1983decl.init = this.parseMaybeAssign(isFor);1984} else if (kind === tt._const && !(this.type === tt._in || this.options.ecmaVersion >= 6 && this.isContextual("of"))) {1985this.unexpected();1986} else if (decl.id.type != "Identifier" && !(isFor && (this.type === tt._in || this.isContextual("of")))) {1987this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");1988} else {1989decl.init = null;1990}1991node.declarations.push(this.finishNode(decl, "VariableDeclarator"));1992if (!this.eat(tt.comma)) break;1993}1994return node;1995};19961997pp.parseVarId = function (decl) {1998decl.id = this.parseBindingAtom();1999this.checkLVal(decl.id, true);2000};20012002// Parse a function declaration or literal (depending on the2003// `isStatement` parameter).20042005pp.parseFunction = function (node, isStatement, allowExpressionBody) {2006this.initFunction(node);2007if (this.options.ecmaVersion >= 6) node.generator = this.eat(tt.star);2008if (isStatement || this.type === tt.name) node.id = this.parseIdent();2009this.parseFunctionParams(node);2010this.parseFunctionBody(node, allowExpressionBody);2011return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");2012};20132014pp.parseFunctionParams = function (node) {2015this.expect(tt.parenL);2016node.params = this.parseBindingList(tt.parenR, false, false);2017};20182019// Parse a class declaration or literal (depending on the2020// `isStatement` parameter).20212022pp.parseClass = function (node, isStatement) {2023this.next();2024this.parseClassId(node, isStatement);2025this.parseClassSuper(node);2026var classBody = this.startNode();2027var hadConstructor = false;2028classBody.body = [];2029this.expect(tt.braceL);2030while (!this.eat(tt.braceR)) {2031if (this.eat(tt.semi)) continue;2032var method = this.startNode();2033var isGenerator = this.eat(tt.star);2034var isMaybeStatic = this.type === tt.name && this.value === "static";2035this.parsePropertyName(method);2036method["static"] = isMaybeStatic && this.type !== tt.parenL;2037if (method["static"]) {2038if (isGenerator) this.unexpected();2039isGenerator = this.eat(tt.star);2040this.parsePropertyName(method);2041}2042method.kind = "method";2043if (!method.computed) {2044var key = method.key;20452046var isGetSet = false;2047if (!isGenerator && key.type === "Identifier" && this.type !== tt.parenL && (key.name === "get" || key.name === "set")) {2048isGetSet = true;2049method.kind = key.name;2050key = this.parsePropertyName(method);2051}2052if (!method["static"] && (key.type === "Identifier" && key.name === "constructor" || key.type === "Literal" && key.value === "constructor")) {2053if (hadConstructor) this.raise(key.start, "Duplicate constructor in the same class");2054if (isGetSet) this.raise(key.start, "Constructor can't have get/set modifier");2055if (isGenerator) this.raise(key.start, "Constructor can't be a generator");2056method.kind = "constructor";2057hadConstructor = true;2058}2059}2060this.parseClassMethod(classBody, method, isGenerator);2061}2062node.body = this.finishNode(classBody, "ClassBody");2063return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");2064};20652066pp.parseClassMethod = function (classBody, method, isGenerator) {2067method.value = this.parseMethod(isGenerator);2068classBody.body.push(this.finishNode(method, "MethodDefinition"));2069};20702071pp.parseClassId = function (node, isStatement) {2072node.id = this.type === tt.name ? this.parseIdent() : isStatement ? this.unexpected() : null;2073};20742075pp.parseClassSuper = function (node) {2076node.superClass = this.eat(tt._extends) ? this.parseExprSubscripts() : null;2077};20782079// Parses module export declaration.20802081pp.parseExport = function (node) {2082this.next();2083// export * from '...'2084if (this.eat(tt.star)) {2085this.expectContextual("from");2086node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();2087this.semicolon();2088return this.finishNode(node, "ExportAllDeclaration");2089}2090if (this.eat(tt._default)) {2091// export default ...2092var expr = this.parseMaybeAssign();2093var needsSemi = true;2094if (expr.type == "FunctionExpression" || expr.type == "ClassExpression") {2095needsSemi = false;2096if (expr.id) {2097expr.type = expr.type == "FunctionExpression" ? "FunctionDeclaration" : "ClassDeclaration";2098}2099}2100node.declaration = expr;2101if (needsSemi) this.semicolon();2102return this.finishNode(node, "ExportDefaultDeclaration");2103}2104// export var|const|let|function|class ...2105if (this.shouldParseExportStatement()) {2106node.declaration = this.parseStatement(true);2107node.specifiers = [];2108node.source = null;2109} else {2110// export { x, y as z } [from '...']2111node.declaration = null;2112node.specifiers = this.parseExportSpecifiers();2113if (this.eatContextual("from")) {2114node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();2115} else {2116node.source = null;2117}2118this.semicolon();2119}2120return this.finishNode(node, "ExportNamedDeclaration");2121};21222123pp.shouldParseExportStatement = function () {2124return this.type.keyword;2125};21262127// Parses a comma-separated list of module exports.21282129pp.parseExportSpecifiers = function () {2130var nodes = [],2131first = true;2132// export { x, y as z } [from '...']2133this.expect(tt.braceL);2134while (!this.eat(tt.braceR)) {2135if (!first) {2136this.expect(tt.comma);2137if (this.afterTrailingComma(tt.braceR)) break;2138} else first = false;21392140var node = this.startNode();2141node.local = this.parseIdent(this.type === tt._default);2142node.exported = this.eatContextual("as") ? this.parseIdent(true) : node.local;2143nodes.push(this.finishNode(node, "ExportSpecifier"));2144}2145return nodes;2146};21472148// Parses import declaration.21492150pp.parseImport = function (node) {2151this.next();2152// import '...'2153if (this.type === tt.string) {2154node.specifiers = empty;2155node.source = this.parseExprAtom();2156node.kind = "";2157} else {2158node.specifiers = this.parseImportSpecifiers();2159this.expectContextual("from");2160node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();2161}2162this.semicolon();2163return this.finishNode(node, "ImportDeclaration");2164};21652166// Parses a comma-separated list of module imports.21672168pp.parseImportSpecifiers = function () {2169var nodes = [],2170first = true;2171if (this.type === tt.name) {2172// import defaultObj, { x, y as z } from '...'2173var node = this.startNode();2174node.local = this.parseIdent();2175this.checkLVal(node.local, true);2176nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));2177if (!this.eat(tt.comma)) return nodes;2178}2179if (this.type === tt.star) {2180var node = this.startNode();2181this.next();2182this.expectContextual("as");2183node.local = this.parseIdent();2184this.checkLVal(node.local, true);2185nodes.push(this.finishNode(node, "ImportNamespaceSpecifier"));2186return nodes;2187}2188this.expect(tt.braceL);2189while (!this.eat(tt.braceR)) {2190if (!first) {2191this.expect(tt.comma);2192if (this.afterTrailingComma(tt.braceR)) break;2193} else first = false;21942195var node = this.startNode();2196node.imported = this.parseIdent(true);2197node.local = this.eatContextual("as") ? this.parseIdent() : node.imported;2198this.checkLVal(node.local, true);2199nodes.push(this.finishNode(node, "ImportSpecifier"));2200}2201return nodes;2202};22032204},{"./state":9,"./tokentype":13,"./whitespace":15}],11:[function(_dereq_,module,exports){2205"use strict";22062207var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };22082209exports.__esModule = true;2210// The algorithm used to determine whether a regexp can appear at a2211// given point in the program is loosely based on sweet.js' approach.2212// See https://github.com/mozilla/sweet.js/wiki/design22132214var Parser = _dereq_("./state").Parser;22152216var tt = _dereq_("./tokentype").types;22172218var lineBreak = _dereq_("./whitespace").lineBreak;22192220var TokContext = exports.TokContext = function TokContext(token, isExpr, preserveSpace, override) {2221_classCallCheck(this, TokContext);22222223this.token = token;2224this.isExpr = isExpr;2225this.preserveSpace = preserveSpace;2226this.override = override;2227};22282229var types = {2230b_stat: new TokContext("{", false),2231b_expr: new TokContext("{", true),2232b_tmpl: new TokContext("${", true),2233p_stat: new TokContext("(", false),2234p_expr: new TokContext("(", true),2235q_tmpl: new TokContext("`", true, true, function (p) {2236return p.readTmplToken();2237}),2238f_expr: new TokContext("function", true)2239};22402241exports.types = types;2242var pp = Parser.prototype;22432244pp.initialContext = function () {2245return [types.b_stat];2246};22472248pp.braceIsBlock = function (prevType) {2249var parent = undefined;2250if (prevType === tt.colon && (parent = this.curContext()).token == "{") return !parent.isExpr;2251if (prevType === tt._return) return lineBreak.test(this.input.slice(this.lastTokEnd, this.start));2252if (prevType === tt._else || prevType === tt.semi || prevType === tt.eof) return true;2253if (prevType == tt.braceL) return this.curContext() === types.b_stat;2254return !this.exprAllowed;2255};22562257pp.updateContext = function (prevType) {2258var update = undefined,2259type = this.type;2260if (type.keyword && prevType == tt.dot) this.exprAllowed = false;else if (update = type.updateContext) update.call(this, prevType);else this.exprAllowed = type.beforeExpr;2261};22622263// Token-specific context update code22642265tt.parenR.updateContext = tt.braceR.updateContext = function () {2266if (this.context.length == 1) {2267this.exprAllowed = true;2268return;2269}2270var out = this.context.pop();2271if (out === types.b_stat && this.curContext() === types.f_expr) {2272this.context.pop();2273this.exprAllowed = false;2274} else if (out === types.b_tmpl) {2275this.exprAllowed = true;2276} else {2277this.exprAllowed = !out.isExpr;2278}2279};22802281tt.braceL.updateContext = function (prevType) {2282this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr);2283this.exprAllowed = true;2284};22852286tt.dollarBraceL.updateContext = function () {2287this.context.push(types.b_tmpl);2288this.exprAllowed = true;2289};22902291tt.parenL.updateContext = function (prevType) {2292var statementParens = prevType === tt._if || prevType === tt._for || prevType === tt._with || prevType === tt._while;2293this.context.push(statementParens ? types.p_stat : types.p_expr);2294this.exprAllowed = true;2295};22962297tt.incDec.updateContext = function () {};22982299tt._function.updateContext = function () {2300if (this.curContext() !== types.b_stat) this.context.push(types.f_expr);2301this.exprAllowed = false;2302};23032304tt.backQuote.updateContext = function () {2305if (this.curContext() === types.q_tmpl) this.context.pop();else this.context.push(types.q_tmpl);2306this.exprAllowed = false;2307};23082309// tokExprAllowed stays unchanged23102311},{"./state":9,"./tokentype":13,"./whitespace":15}],12:[function(_dereq_,module,exports){2312"use strict";23132314var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };23152316exports.__esModule = true;23172318var _identifier = _dereq_("./identifier");23192320var isIdentifierStart = _identifier.isIdentifierStart;2321var isIdentifierChar = _identifier.isIdentifierChar;23222323var _tokentype = _dereq_("./tokentype");23242325var tt = _tokentype.types;2326var keywordTypes = _tokentype.keywords;23272328var Parser = _dereq_("./state").Parser;23292330var SourceLocation = _dereq_("./location").SourceLocation;23312332var _whitespace = _dereq_("./whitespace");23332334var lineBreak = _whitespace.lineBreak;2335var lineBreakG = _whitespace.lineBreakG;2336var isNewLine = _whitespace.isNewLine;2337var nonASCIIwhitespace = _whitespace.nonASCIIwhitespace;23382339// Object type used to represent tokens. Note that normally, tokens2340// simply exist as properties on the parser object. This is only2341// used for the onToken callback and the external tokenizer.23422343var Token = exports.Token = function Token(p) {2344_classCallCheck(this, Token);23452346this.type = p.type;2347this.value = p.value;2348this.start = p.start;2349this.end = p.end;2350if (p.options.locations) this.loc = new SourceLocation(p, p.startLoc, p.endLoc);2351if (p.options.ranges) this.range = [p.start, p.end];2352};23532354// ## Tokenizer23552356var pp = Parser.prototype;23572358// Are we running under Rhino?2359var isRhino = typeof Packages !== "undefined";23602361// Move to the next token23622363pp.next = function () {2364if (this.options.onToken) this.options.onToken(new Token(this));23652366this.lastTokEnd = this.end;2367this.lastTokStart = this.start;2368this.lastTokEndLoc = this.endLoc;2369this.lastTokStartLoc = this.startLoc;2370this.nextToken();2371};23722373pp.getToken = function () {2374this.next();2375return new Token(this);2376};23772378// If we're in an ES6 environment, make parsers iterable2379if (typeof Symbol !== "undefined") pp[Symbol.iterator] = function () {2380var self = this;2381return { next: function next() {2382var token = self.getToken();2383return {2384done: token.type === tt.eof,2385value: token2386};2387} };2388};23892390// Toggle strict mode. Re-reads the next number or string to please2391// pedantic tests (`"use strict"; 010;` should fail).23922393pp.setStrict = function (strict) {2394this.strict = strict;2395if (this.type !== tt.num && this.type !== tt.string) return;2396this.pos = this.start;2397if (this.options.locations) {2398while (this.pos < this.lineStart) {2399this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1;2400--this.curLine;2401}2402}2403this.nextToken();2404};24052406pp.curContext = function () {2407return this.context[this.context.length - 1];2408};24092410// Read a single token, updating the parser object's token-related2411// properties.24122413pp.nextToken = function () {2414var curContext = this.curContext();2415if (!curContext || !curContext.preserveSpace) this.skipSpace();24162417this.start = this.pos;2418if (this.options.locations) this.startLoc = this.curPosition();2419if (this.pos >= this.input.length) return this.finishToken(tt.eof);24202421if (curContext.override) return curContext.override(this);else this.readToken(this.fullCharCodeAtPos());2422};24232424pp.readToken = function (code) {2425// Identifier or keyword. '\uXXXX' sequences are allowed in2426// identifiers, so '\' also dispatches to that.2427if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */) return this.readWord();24282429return this.getTokenFromCode(code);2430};24312432pp.fullCharCodeAtPos = function () {2433var code = this.input.charCodeAt(this.pos);2434if (code <= 55295 || code >= 57344) return code;2435var next = this.input.charCodeAt(this.pos + 1);2436return (code << 10) + next - 56613888;2437};24382439pp.skipBlockComment = function () {2440var startLoc = this.options.onComment && this.options.locations && this.curPosition();2441var start = this.pos,2442end = this.input.indexOf("*/", this.pos += 2);2443if (end === -1) this.raise(this.pos - 2, "Unterminated comment");2444this.pos = end + 2;2445if (this.options.locations) {2446lineBreakG.lastIndex = start;2447var match = undefined;2448while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {2449++this.curLine;2450this.lineStart = match.index + match[0].length;2451}2452}2453if (this.options.onComment) this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos, startLoc, this.options.locations && this.curPosition());2454};24552456pp.skipLineComment = function (startSkip) {2457var start = this.pos;2458var startLoc = this.options.onComment && this.options.locations && this.curPosition();2459var ch = this.input.charCodeAt(this.pos += startSkip);2460while (this.pos < this.input.length && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) {2461++this.pos;2462ch = this.input.charCodeAt(this.pos);2463}2464if (this.options.onComment) this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos, startLoc, this.options.locations && this.curPosition());2465};24662467// Called at the start of the parse and after every token. Skips2468// whitespace and comments, and.24692470pp.skipSpace = function () {2471while (this.pos < this.input.length) {2472var ch = this.input.charCodeAt(this.pos);2473if (ch === 32) {2474// ' '2475++this.pos;2476} else if (ch === 13) {2477++this.pos;2478var next = this.input.charCodeAt(this.pos);2479if (next === 10) {2480++this.pos;2481}2482if (this.options.locations) {2483++this.curLine;2484this.lineStart = this.pos;2485}2486} else if (ch === 10 || ch === 8232 || ch === 8233) {2487++this.pos;2488if (this.options.locations) {2489++this.curLine;2490this.lineStart = this.pos;2491}2492} else if (ch > 8 && ch < 14) {2493++this.pos;2494} else if (ch === 47) {2495// '/'2496var next = this.input.charCodeAt(this.pos + 1);2497if (next === 42) {2498// '*'2499this.skipBlockComment();2500} else if (next === 47) {2501// '/'2502this.skipLineComment(2);2503} else break;2504} else if (ch === 160) {2505// '\xa0'2506++this.pos;2507} else if (ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {2508++this.pos;2509} else {2510break;2511}2512}2513};25142515// Called at the end of every token. Sets `end`, `val`, and2516// maintains `context` and `exprAllowed`, and skips the space after2517// the token, so that the next one's `start` will point at the2518// right position.25192520pp.finishToken = function (type, val) {2521this.end = this.pos;2522if (this.options.locations) this.endLoc = this.curPosition();2523var prevType = this.type;2524this.type = type;2525this.value = val;25262527this.updateContext(prevType);2528};25292530// ### Token reading25312532// This is the function that is called to fetch the next token. It2533// is somewhat obscure, because it works in character codes rather2534// than characters, and because operator parsing has been inlined2535// into it.2536//2537// All in the name of speed.2538//2539pp.readToken_dot = function () {2540var next = this.input.charCodeAt(this.pos + 1);2541if (next >= 48 && next <= 57) return this.readNumber(true);2542var next2 = this.input.charCodeAt(this.pos + 2);2543if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) {2544// 46 = dot '.'2545this.pos += 3;2546return this.finishToken(tt.ellipsis);2547} else {2548++this.pos;2549return this.finishToken(tt.dot);2550}2551};25522553pp.readToken_slash = function () {2554// '/'2555var next = this.input.charCodeAt(this.pos + 1);2556if (this.exprAllowed) {2557++this.pos;return this.readRegexp();2558}2559if (next === 61) return this.finishOp(tt.assign, 2);2560return this.finishOp(tt.slash, 1);2561};25622563pp.readToken_mult_modulo = function (code) {2564// '%*'2565var next = this.input.charCodeAt(this.pos + 1);2566if (next === 61) return this.finishOp(tt.assign, 2);2567return this.finishOp(code === 42 ? tt.star : tt.modulo, 1);2568};25692570pp.readToken_pipe_amp = function (code) {2571// '|&'2572var next = this.input.charCodeAt(this.pos + 1);2573if (next === code) return this.finishOp(code === 124 ? tt.logicalOR : tt.logicalAND, 2);2574if (next === 61) return this.finishOp(tt.assign, 2);2575return this.finishOp(code === 124 ? tt.bitwiseOR : tt.bitwiseAND, 1);2576};25772578pp.readToken_caret = function () {2579// '^'2580var next = this.input.charCodeAt(this.pos + 1);2581if (next === 61) return this.finishOp(tt.assign, 2);2582return this.finishOp(tt.bitwiseXOR, 1);2583};25842585pp.readToken_plus_min = function (code) {2586// '+-'2587var next = this.input.charCodeAt(this.pos + 1);2588if (next === code) {2589if (next == 45 && this.input.charCodeAt(this.pos + 2) == 62 && lineBreak.test(this.input.slice(this.lastTokEnd, this.pos))) {2590// A `-->` line comment2591this.skipLineComment(3);2592this.skipSpace();2593return this.nextToken();2594}2595return this.finishOp(tt.incDec, 2);2596}2597if (next === 61) return this.finishOp(tt.assign, 2);2598return this.finishOp(tt.plusMin, 1);2599};26002601pp.readToken_lt_gt = function (code) {2602// '<>'2603var next = this.input.charCodeAt(this.pos + 1);2604var size = 1;2605if (next === code) {2606size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;2607if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1);2608return this.finishOp(tt.bitShift, size);2609}2610if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 && this.input.charCodeAt(this.pos + 3) == 45) {2611if (this.inModule) this.unexpected();2612// `<!--`, an XML-style comment that should be interpreted as a line comment2613this.skipLineComment(4);2614this.skipSpace();2615return this.nextToken();2616}2617if (next === 61) size = this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2;2618return this.finishOp(tt.relational, size);2619};26202621pp.readToken_eq_excl = function (code) {2622// '=!'2623var next = this.input.charCodeAt(this.pos + 1);2624if (next === 61) return this.finishOp(tt.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2);2625if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) {2626// '=>'2627this.pos += 2;2628return this.finishToken(tt.arrow);2629}2630return this.finishOp(code === 61 ? tt.eq : tt.prefix, 1);2631};26322633pp.getTokenFromCode = function (code) {2634switch (code) {2635// The interpretation of a dot depends on whether it is followed2636// by a digit or another two dots.2637case 46:2638// '.'2639return this.readToken_dot();26402641// Punctuation tokens.2642case 40:2643++this.pos;return this.finishToken(tt.parenL);2644case 41:2645++this.pos;return this.finishToken(tt.parenR);2646case 59:2647++this.pos;return this.finishToken(tt.semi);2648case 44:2649++this.pos;return this.finishToken(tt.comma);2650case 91:2651++this.pos;return this.finishToken(tt.bracketL);2652case 93:2653++this.pos;return this.finishToken(tt.bracketR);2654case 123:2655++this.pos;return this.finishToken(tt.braceL);2656case 125:2657++this.pos;return this.finishToken(tt.braceR);2658case 58:2659++this.pos;return this.finishToken(tt.colon);2660case 63:2661++this.pos;return this.finishToken(tt.question);26622663case 96:2664// '`'2665if (this.options.ecmaVersion < 6) break;2666++this.pos;2667return this.finishToken(tt.backQuote);26682669case 48:2670// '0'2671var next = this.input.charCodeAt(this.pos + 1);2672if (next === 120 || next === 88) return this.readRadixNumber(16); // '0x', '0X' - hex number2673if (this.options.ecmaVersion >= 6) {2674if (next === 111 || next === 79) return this.readRadixNumber(8); // '0o', '0O' - octal number2675if (next === 98 || next === 66) return this.readRadixNumber(2); // '0b', '0B' - binary number2676}2677// Anything else beginning with a digit is an integer, octal2678// number, or float.2679case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:2680// 1-92681return this.readNumber(false);26822683// Quotes produce strings.2684case 34:case 39:2685// '"', "'"2686return this.readString(code);26872688// Operators are parsed inline in tiny state machines. '=' (61) is2689// often referred to. `finishOp` simply skips the amount of2690// characters it is given as second argument, and returns a token2691// of the type given by its first argument.26922693case 47:2694// '/'2695return this.readToken_slash();26962697case 37:case 42:2698// '%*'2699return this.readToken_mult_modulo(code);27002701case 124:case 38:2702// '|&'2703return this.readToken_pipe_amp(code);27042705case 94:2706// '^'2707return this.readToken_caret();27082709case 43:case 45:2710// '+-'2711return this.readToken_plus_min(code);27122713case 60:case 62:2714// '<>'2715return this.readToken_lt_gt(code);27162717case 61:case 33:2718// '=!'2719return this.readToken_eq_excl(code);27202721case 126:2722// '~'2723return this.finishOp(tt.prefix, 1);2724}27252726this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");2727};27282729pp.finishOp = function (type, size) {2730var str = this.input.slice(this.pos, this.pos + size);2731this.pos += size;2732return this.finishToken(type, str);2733};27342735var regexpUnicodeSupport = false;2736try {2737new RegExp("", "u");regexpUnicodeSupport = true;2738} catch (e) {}27392740// Parse a regular expression. Some context-awareness is necessary,2741// since a '/' inside a '[]' set does not end the expression.27422743pp.readRegexp = function () {2744var escaped = undefined,2745inClass = undefined,2746start = this.pos;2747for (;;) {2748if (this.pos >= this.input.length) this.raise(start, "Unterminated regular expression");2749var ch = this.input.charAt(this.pos);2750if (lineBreak.test(ch)) this.raise(start, "Unterminated regular expression");2751if (!escaped) {2752if (ch === "[") inClass = true;else if (ch === "]" && inClass) inClass = false;else if (ch === "/" && !inClass) break;2753escaped = ch === "\\";2754} else escaped = false;2755++this.pos;2756}2757var content = this.input.slice(start, this.pos);2758++this.pos;2759// Need to use `readWord1` because '\uXXXX' sequences are allowed2760// here (don't ask).2761var mods = this.readWord1();2762var tmp = content;2763if (mods) {2764var validFlags = /^[gmsiy]*$/;2765if (this.options.ecmaVersion >= 6) validFlags = /^[gmsiyu]*$/;2766if (!validFlags.test(mods)) this.raise(start, "Invalid regular expression flag");2767if (mods.indexOf("u") >= 0 && !regexpUnicodeSupport) {2768// Replace each astral symbol and every Unicode escape sequence that2769// possibly represents an astral symbol or a paired surrogate with a2770// single ASCII symbol to avoid throwing on regular expressions that2771// are only valid in combination with the `/u` flag.2772// Note: replacing with the ASCII symbol `x` might cause false2773// negatives in unlikely scenarios. For example, `[\u{61}-b]` is a2774// perfectly valid pattern that is equivalent to `[a-b]`, but it would2775// be replaced by `[x-b]` which throws an error.2776tmp = tmp.replace(/\\u([a-fA-F0-9]{4})|\\u\{([0-9a-fA-F]+)\}|[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "x");2777}2778}2779// Detect invalid regular expressions.2780var value = null;2781// Rhino's regular expression parser is flaky and throws uncatchable exceptions,2782// so don't do detection if we are running under Rhino2783if (!isRhino) {2784try {2785new RegExp(tmp);2786} catch (e) {2787if (e instanceof SyntaxError) this.raise(start, "Error parsing regular expression: " + e.message);2788this.raise(e);2789}2790// Get a regular expression object for this pattern-flag pair, or `null` in2791// case the current environment doesn't support the flags it uses.2792try {2793value = new RegExp(content, mods);2794} catch (err) {}2795}2796return this.finishToken(tt.regexp, { pattern: content, flags: mods, value: value });2797};27982799// Read an integer in the given radix. Return null if zero digits2800// were read, the integer value otherwise. When `len` is given, this2801// will return `null` unless the integer has exactly `len` digits.28022803pp.readInt = function (radix, len) {2804var start = this.pos,2805total = 0;2806for (var i = 0, e = len == null ? Infinity : len; i < e; ++i) {2807var code = this.input.charCodeAt(this.pos),2808val = undefined;2809if (code >= 97) val = code - 97 + 10; // a2810else if (code >= 65) val = code - 65 + 10; // A2811else if (code >= 48 && code <= 57) val = code - 48; // 0-92812else val = Infinity;2813if (val >= radix) break;2814++this.pos;2815total = total * radix + val;2816}2817if (this.pos === start || len != null && this.pos - start !== len) return null;28182819return total;2820};28212822pp.readRadixNumber = function (radix) {2823this.pos += 2; // 0x2824var val = this.readInt(radix);2825if (val == null) this.raise(this.start + 2, "Expected number in radix " + radix);2826if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number");2827return this.finishToken(tt.num, val);2828};28292830// Read an integer, octal integer, or floating-point number.28312832pp.readNumber = function (startsWithDot) {2833var start = this.pos,2834isFloat = false,2835octal = this.input.charCodeAt(this.pos) === 48;2836if (!startsWithDot && this.readInt(10) === null) this.raise(start, "Invalid number");2837if (this.input.charCodeAt(this.pos) === 46) {2838++this.pos;2839this.readInt(10);2840isFloat = true;2841}2842var next = this.input.charCodeAt(this.pos);2843if (next === 69 || next === 101) {2844// 'eE'2845next = this.input.charCodeAt(++this.pos);2846if (next === 43 || next === 45) ++this.pos; // '+-'2847if (this.readInt(10) === null) this.raise(start, "Invalid number");2848isFloat = true;2849}2850if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number");28512852var str = this.input.slice(start, this.pos),2853val = undefined;2854if (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);2855return this.finishToken(tt.num, val);2856};28572858// Read a string value, interpreting backslash-escapes.28592860pp.readCodePoint = function () {2861var ch = this.input.charCodeAt(this.pos),2862code = undefined;28632864if (ch === 123) {2865if (this.options.ecmaVersion < 6) this.unexpected();2866++this.pos;2867code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);2868++this.pos;2869if (code > 1114111) this.unexpected();2870} else {2871code = this.readHexChar(4);2872}2873return code;2874};28752876function codePointToString(code) {2877// UTF-16 Decoding2878if (code <= 65535) {2879return String.fromCharCode(code);2880}return String.fromCharCode((code - 65536 >> 10) + 55296, (code - 65536 & 1023) + 56320);2881}28822883pp.readString = function (quote) {2884var out = "",2885chunkStart = ++this.pos;2886for (;;) {2887if (this.pos >= this.input.length) this.raise(this.start, "Unterminated string constant");2888var ch = this.input.charCodeAt(this.pos);2889if (ch === quote) break;2890if (ch === 92) {2891// '\'2892out += this.input.slice(chunkStart, this.pos);2893out += this.readEscapedChar();2894chunkStart = this.pos;2895} else {2896if (isNewLine(ch)) this.raise(this.start, "Unterminated string constant");2897++this.pos;2898}2899}2900out += this.input.slice(chunkStart, this.pos++);2901return this.finishToken(tt.string, out);2902};29032904// Reads template string tokens.29052906pp.readTmplToken = function () {2907var out = "",2908chunkStart = this.pos;2909for (;;) {2910if (this.pos >= this.input.length) this.raise(this.start, "Unterminated template");2911var ch = this.input.charCodeAt(this.pos);2912if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) {2913// '`', '${'2914if (this.pos === this.start && this.type === tt.template) {2915if (ch === 36) {2916this.pos += 2;2917return this.finishToken(tt.dollarBraceL);2918} else {2919++this.pos;2920return this.finishToken(tt.backQuote);2921}2922}2923out += this.input.slice(chunkStart, this.pos);2924return this.finishToken(tt.template, out);2925}2926if (ch === 92) {2927// '\'2928out += this.input.slice(chunkStart, this.pos);2929out += this.readEscapedChar();2930chunkStart = this.pos;2931} else if (isNewLine(ch)) {2932out += this.input.slice(chunkStart, this.pos);2933++this.pos;2934if (ch === 13 && this.input.charCodeAt(this.pos) === 10) {2935++this.pos;2936out += "\n";2937} else {2938out += String.fromCharCode(ch);2939}2940if (this.options.locations) {2941++this.curLine;2942this.lineStart = this.pos;2943}2944chunkStart = this.pos;2945} else {2946++this.pos;2947}2948}2949};29502951// Used to read escaped characters29522953pp.readEscapedChar = function () {2954var ch = this.input.charCodeAt(++this.pos);2955var octal = /^[0-7]+/.exec(this.input.slice(this.pos, this.pos + 3));2956if (octal) octal = octal[0];2957while (octal && parseInt(octal, 8) > 255) octal = octal.slice(0, -1);2958if (octal === "0") octal = null;2959++this.pos;2960if (octal) {2961if (this.strict) this.raise(this.pos - 2, "Octal literal in strict mode");2962this.pos += octal.length - 1;2963return String.fromCharCode(parseInt(octal, 8));2964} else {2965switch (ch) {2966case 110:2967return "\n"; // 'n' -> '\n'2968case 114:2969return "\r"; // 'r' -> '\r'2970case 120:2971return String.fromCharCode(this.readHexChar(2)); // 'x'2972case 117:2973return codePointToString(this.readCodePoint()); // 'u'2974case 116:2975return "\t"; // 't' -> '\t'2976case 98:2977return "\b"; // 'b' -> '\b'2978case 118:2979return "\u000b"; // 'v' -> '\u000b'2980case 102:2981return "\f"; // 'f' -> '\f'2982case 48:2983return "\u0000"; // 0 -> '\0'2984case 13:2985if (this.input.charCodeAt(this.pos) === 10) ++this.pos; // '\r\n'2986case 10:2987// ' \n'2988if (this.options.locations) {2989this.lineStart = this.pos;++this.curLine;2990}2991return "";2992default:2993return String.fromCharCode(ch);2994}2995}2996};29972998// Used to read character escape sequences ('\x', '\u', '\U').29993000pp.readHexChar = function (len) {3001var n = this.readInt(16, len);3002if (n === null) this.raise(this.start, "Bad character escape sequence");3003return n;3004};30053006// Used to signal to callers of `readWord1` whether the word3007// contained any escape sequences. This is needed because words with3008// escape sequences must not be interpreted as keywords.30093010var containsEsc;30113012// Read an identifier, and return it as a string. Sets `containsEsc`3013// to whether the word contained a '\u' escape.3014//3015// Incrementally adds only escaped chars, adding other chunks as-is3016// as a micro-optimization.30173018pp.readWord1 = function () {3019containsEsc = false;3020var word = "",3021first = true,3022chunkStart = this.pos;3023var astral = this.options.ecmaVersion >= 6;3024while (this.pos < this.input.length) {3025var ch = this.fullCharCodeAtPos();3026if (isIdentifierChar(ch, astral)) {3027this.pos += ch <= 65535 ? 1 : 2;3028} else if (ch === 92) {3029// "\"3030containsEsc = true;3031word += this.input.slice(chunkStart, this.pos);3032var escStart = this.pos;3033if (this.input.charCodeAt(++this.pos) != 117) // "u"3034this.raise(this.pos, "Expecting Unicode escape sequence \\uXXXX");3035++this.pos;3036var esc = this.readCodePoint();3037if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral)) this.raise(escStart, "Invalid Unicode escape");3038word += codePointToString(esc);3039chunkStart = this.pos;3040} else {3041break;3042}3043first = false;3044}3045return word + this.input.slice(chunkStart, this.pos);3046};30473048// Read an identifier or keyword token. Will check for reserved3049// words when necessary.30503051pp.readWord = function () {3052var word = this.readWord1();3053var type = tt.name;3054if ((this.options.ecmaVersion >= 6 || !containsEsc) && this.isKeyword(word)) type = keywordTypes[word];3055return this.finishToken(type, word);3056};30573058},{"./identifier":3,"./location":4,"./state":9,"./tokentype":13,"./whitespace":15}],13:[function(_dereq_,module,exports){3059"use strict";30603061var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };30623063exports.__esModule = true;3064// ## Token types30653066// The assignment of fine-grained, information-carrying type objects3067// allows the tokenizer to store the information it has about a3068// token in a way that is very cheap for the parser to look up.30693070// All token type variables start with an underscore, to make them3071// easy to recognize.30723073// The `beforeExpr` property is used to disambiguate between regular3074// expressions and divisions. It is set on all token types that can3075// be followed by an expression (thus, a slash after them would be a3076// regular expression).3077//3078// `isLoop` marks a keyword as starting a loop, which is important3079// to know when parsing a label, in order to allow or disallow3080// continue jumps to that label.30813082var TokenType = exports.TokenType = function TokenType(label) {3083var conf = arguments[1] === undefined ? {} : arguments[1];30843085_classCallCheck(this, TokenType);30863087this.label = label;3088this.keyword = conf.keyword;3089this.beforeExpr = !!conf.beforeExpr;3090this.startsExpr = !!conf.startsExpr;3091this.isLoop = !!conf.isLoop;3092this.isAssign = !!conf.isAssign;3093this.prefix = !!conf.prefix;3094this.postfix = !!conf.postfix;3095this.binop = conf.binop || null;3096this.updateContext = null;3097};30983099function binop(name, prec) {3100return new TokenType(name, { beforeExpr: true, binop: prec });3101}3102var beforeExpr = { beforeExpr: true },3103startsExpr = { startsExpr: true };31043105var types = {3106num: new TokenType("num", startsExpr),3107regexp: new TokenType("regexp", startsExpr),3108string: new TokenType("string", startsExpr),3109name: new TokenType("name", startsExpr),3110eof: new TokenType("eof"),31113112// Punctuation token types.3113bracketL: new TokenType("[", { beforeExpr: true, startsExpr: true }),3114bracketR: new TokenType("]"),3115braceL: new TokenType("{", { beforeExpr: true, startsExpr: true }),3116braceR: new TokenType("}"),3117parenL: new TokenType("(", { beforeExpr: true, startsExpr: true }),3118parenR: new TokenType(")"),3119comma: new TokenType(",", beforeExpr),3120semi: new TokenType(";", beforeExpr),3121colon: new TokenType(":", beforeExpr),3122dot: new TokenType("."),3123question: new TokenType("?", beforeExpr),3124arrow: new TokenType("=>", beforeExpr),3125template: new TokenType("template"),3126ellipsis: new TokenType("...", beforeExpr),3127backQuote: new TokenType("`", startsExpr),3128dollarBraceL: new TokenType("${", { beforeExpr: true, startsExpr: true }),31293130// Operators. These carry several kinds of properties to help the3131// parser use them properly (the presence of these properties is3132// what categorizes them as operators).3133//3134// `binop`, when present, specifies that this operator is a binary3135// operator, and will refer to its precedence.3136//3137// `prefix` and `postfix` mark the operator as a prefix or postfix3138// unary operator.3139//3140// `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as3141// binary operators with a very low precedence, that should result3142// in AssignmentExpression nodes.31433144eq: new TokenType("=", { beforeExpr: true, isAssign: true }),3145assign: new TokenType("_=", { beforeExpr: true, isAssign: true }),3146incDec: new TokenType("++/--", { prefix: true, postfix: true, startsExpr: true }),3147prefix: new TokenType("prefix", { beforeExpr: true, prefix: true, startsExpr: true }),3148logicalOR: binop("||", 1),3149logicalAND: binop("&&", 2),3150bitwiseOR: binop("|", 3),3151bitwiseXOR: binop("^", 4),3152bitwiseAND: binop("&", 5),3153equality: binop("==/!=", 6),3154relational: binop("</>", 7),3155bitShift: binop("<</>>", 8),3156plusMin: new TokenType("+/-", { beforeExpr: true, binop: 9, prefix: true, startsExpr: true }),3157modulo: binop("%", 10),3158star: binop("*", 10),3159slash: binop("/", 10)3160};31613162exports.types = types;3163// Map keyword names to token types.31643165var keywords = {};31663167exports.keywords = keywords;3168// Succinct definitions of keyword token types3169function kw(name) {3170var options = arguments[1] === undefined ? {} : arguments[1];31713172options.keyword = name;3173keywords[name] = types["_" + name] = new TokenType(name, options);3174}31753176kw("break");3177kw("case", beforeExpr);3178kw("catch");3179kw("continue");3180kw("debugger");3181kw("default");3182kw("do", { isLoop: true });3183kw("else", beforeExpr);3184kw("finally");3185kw("for", { isLoop: true });3186kw("function", startsExpr);3187kw("if");3188kw("return", beforeExpr);3189kw("switch");3190kw("throw", beforeExpr);3191kw("try");3192kw("var");3193kw("let");3194kw("const");3195kw("while", { isLoop: true });3196kw("with");3197kw("new", { beforeExpr: true, startsExpr: true });3198kw("this", startsExpr);3199kw("super", startsExpr);3200kw("class");3201kw("extends", beforeExpr);3202kw("export");3203kw("import");3204kw("yield", { beforeExpr: true, startsExpr: true });3205kw("null", startsExpr);3206kw("true", startsExpr);3207kw("false", startsExpr);3208kw("in", { beforeExpr: true, binop: 7 });3209kw("instanceof", { beforeExpr: true, binop: 7 });3210kw("typeof", { beforeExpr: true, prefix: true, startsExpr: true });3211kw("void", { beforeExpr: true, prefix: true, startsExpr: true });3212kw("delete", { beforeExpr: true, prefix: true, startsExpr: true });32133214},{}],14:[function(_dereq_,module,exports){3215"use strict";32163217exports.isArray = isArray;32183219// Checks if an object has a property.32203221exports.has = has;3222exports.__esModule = true;32233224function isArray(obj) {3225return Object.prototype.toString.call(obj) === "[object Array]";3226}32273228function has(obj, propName) {3229return Object.prototype.hasOwnProperty.call(obj, propName);3230}32313232},{}],15:[function(_dereq_,module,exports){3233"use strict";32343235exports.isNewLine = isNewLine;3236exports.__esModule = true;3237// Matches a whole line break (where CRLF is considered a single3238// line break). Used to count lines.32393240var lineBreak = /\r\n?|\n|\u2028|\u2029/;3241exports.lineBreak = lineBreak;3242var lineBreakG = new RegExp(lineBreak.source, "g");32433244exports.lineBreakG = lineBreakG;32453246function isNewLine(code) {3247return code === 10 || code === 13 || code === 8232 || code == 8233;3248}32493250var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/;3251exports.nonASCIIwhitespace = nonASCIIwhitespace;32523253},{}]},{},[1])(1)3254});32553256