react / react-0.13.3 / examples / basic-commonjs / node_modules / browserify / node_modules / syntax-error / node_modules / acorn / dist / acorn.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.831832function makePredicate(words) {833words = words.split(" ");834var f = "",835cats = [];836out: for (var i = 0; i < words.length; ++i) {837for (var j = 0; j < cats.length; ++j) {838if (cats[j][0].length == words[i].length) {839cats[j].push(words[i]);840continue out;841}842}cats.push([words[i]]);843}844function compareTo(arr) {845if (arr.length == 1) {846return f += "return str === " + JSON.stringify(arr[0]) + ";";847}f += "switch(str){";848for (var i = 0; i < arr.length; ++i) {849f += "case " + JSON.stringify(arr[i]) + ":";850}f += "return true}return false;";851}852853// When there are more than three length categories, an outer854// switch first dispatches on the lengths, to save on comparisons.855856if (cats.length > 3) {857cats.sort(function (a, b) {858return b.length - a.length;859});860f += "switch(str.length){";861for (var i = 0; i < cats.length; ++i) {862var cat = cats[i];863f += "case " + cat[0].length + ":";864compareTo(cat);865}866f += "}"867868// Otherwise, simply generate a flat `switch` statement.869870;871} else {872compareTo(words);873}874return new Function("str", f);875}876877// Reserved word lists for various dialects of the language878879var reservedWords = {8803: makePredicate("abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile"),8815: makePredicate("class enum extends super const export import"),8826: makePredicate("enum await"),883strict: makePredicate("implements interface let package private protected public static yield"),884strictBind: makePredicate("eval arguments")885};886887exports.reservedWords = reservedWords;888// And the keywords889890var 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";891892var keywords = {8935: makePredicate(ecma5AndLessKeywords),8946: makePredicate(ecma5AndLessKeywords + " let const class extends export import yield super")895};896897exports.keywords = keywords;898// ## Character categories899900// Big ugly regular expressions that match characters in the901// whitespace, identifier, and identifier-start categories. These902// are only applied when a character is found to actually have a903// code point above 128.904// Generated by `tools/generate-identifier-regex.js`.905906var nonASCIIidentifierStartChars = "ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠ-ࢲऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞭꞰꞱꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭟꭤꭥꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ";907var nonASCIIidentifierChars = "·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣤ-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఃా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഁ-ഃാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏ᦰ-ᧀᧈᧉ᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳸᳹᷀-᷵᷼-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-꣄꣐-꣙꣠-꣱꤀-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︭︳︴﹍-﹏0-9_";908909var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");910var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");911912nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;913914// These are a run-length and offset encoded representation of the915// >0xffff code points that are a valid part of identifiers. The916// offset starts at 0x10000, and each pair of numbers represents an917// offset to the next range, and then a size of the range. They were918// generated by tools/generate-identifier-regex.js919var 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];920var 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];921922// This has a complexity linear to the value of the code. The923// assumption is that looking up astral identifier characters is924// rare.925function isInAstralSet(code, set) {926var pos = 65536;927for (var i = 0; i < set.length; i += 2) {928pos += set[i];929if (pos > code) {930return false;931}pos += set[i + 1];932if (pos >= code) {933return true;934}935}936}937function isIdentifierStart(code, astral) {938if (code < 65) {939return code === 36;940}if (code < 91) {941return true;942}if (code < 97) {943return code === 95;944}if (code < 123) {945return true;946}if (code <= 65535) {947return code >= 170 && nonASCIIidentifierStart.test(String.fromCharCode(code));948}if (astral === false) {949return false;950}return isInAstralSet(code, astralIdentifierStartCodes);951}952953function isIdentifierChar(code, astral) {954if (code < 48) {955return code === 36;956}if (code < 58) {957return true;958}if (code < 65) {959return false;960}if (code < 91) {961return true;962}if (code < 97) {963return code === 95;964}if (code < 123) {965return true;966}if (code <= 65535) {967return code >= 170 && nonASCIIidentifier.test(String.fromCharCode(code));968}if (astral === false) {969return false;970}return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);971}972973},{}],4:[function(_dereq_,module,exports){974"use strict";975976var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };977978// The `getLineInfo` function is mostly useful when the979// `locations` option is off (for performance reasons) and you980// want to find the line/column position for a given character981// offset. `input` should be the code string that the offset refers982// into.983984exports.getLineInfo = getLineInfo;985exports.__esModule = true;986987var Parser = _dereq_("./state").Parser;988989var lineBreakG = _dereq_("./whitespace").lineBreakG;990991// These are used when `options.locations` is on, for the992// `startLoc` and `endLoc` properties.993994var Position = exports.Position = (function () {995function Position(line, col) {996_classCallCheck(this, Position);997998this.line = line;999this.column = col;1000}10011002Position.prototype.offset = function offset(n) {1003return new Position(this.line, this.column + n);1004};10051006return Position;1007})();10081009var SourceLocation = exports.SourceLocation = function SourceLocation(p, start, end) {1010_classCallCheck(this, SourceLocation);10111012this.start = start;1013this.end = end;1014if (p.sourceFile !== null) this.source = p.sourceFile;1015};10161017function getLineInfo(input, offset) {1018for (var line = 1, cur = 0;;) {1019lineBreakG.lastIndex = cur;1020var match = lineBreakG.exec(input);1021if (match && match.index < offset) {1022++line;1023cur = match.index + match[0].length;1024} else {1025return new Position(line, offset - cur);1026}1027}1028}10291030var pp = Parser.prototype;10311032// This function is used to raise exceptions on parse errors. It1033// takes an offset integer (into the current `input`) to indicate1034// the location of the error, attaches the position to the end1035// of the error message, and then raises a `SyntaxError` with that1036// message.10371038pp.raise = function (pos, message) {1039var loc = getLineInfo(this.input, pos);1040message += " (" + loc.line + ":" + loc.column + ")";1041var err = new SyntaxError(message);1042err.pos = pos;err.loc = loc;err.raisedAt = this.pos;1043throw err;1044};10451046pp.curPosition = function () {1047return new Position(this.curLine, this.pos - this.lineStart);1048};10491050},{"./state":9,"./whitespace":15}],5:[function(_dereq_,module,exports){1051"use strict";10521053var tt = _dereq_("./tokentype").types;10541055var Parser = _dereq_("./state").Parser;10561057var reservedWords = _dereq_("./identifier").reservedWords;10581059var has = _dereq_("./util").has;10601061var pp = Parser.prototype;10621063// Convert existing expression atom to assignable pattern1064// if possible.10651066pp.toAssignable = function (node, isBinding) {1067if (this.options.ecmaVersion >= 6 && node) {1068switch (node.type) {1069case "Identifier":1070case "ObjectPattern":1071case "ArrayPattern":1072case "AssignmentPattern":1073break;10741075case "ObjectExpression":1076node.type = "ObjectPattern";1077for (var i = 0; i < node.properties.length; i++) {1078var prop = node.properties[i];1079if (prop.kind !== "init") this.raise(prop.key.start, "Object pattern can't contain getter or setter");1080this.toAssignable(prop.value, isBinding);1081}1082break;10831084case "ArrayExpression":1085node.type = "ArrayPattern";1086this.toAssignableList(node.elements, isBinding);1087break;10881089case "AssignmentExpression":1090if (node.operator === "=") {1091node.type = "AssignmentPattern";1092} else {1093this.raise(node.left.end, "Only '=' operator can be used for specifying default value.");1094}1095break;10961097case "ParenthesizedExpression":1098node.expression = this.toAssignable(node.expression, isBinding);1099break;11001101case "MemberExpression":1102if (!isBinding) break;11031104default:1105this.raise(node.start, "Assigning to rvalue");1106}1107}1108return node;1109};11101111// Convert list of expression atoms to binding list.11121113pp.toAssignableList = function (exprList, isBinding) {1114var end = exprList.length;1115if (end) {1116var last = exprList[end - 1];1117if (last && last.type == "RestElement") {1118--end;1119} else if (last && last.type == "SpreadElement") {1120last.type = "RestElement";1121var arg = last.argument;1122this.toAssignable(arg, isBinding);1123if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern") this.unexpected(arg.start);1124--end;1125}1126}1127for (var i = 0; i < end; i++) {1128var elt = exprList[i];1129if (elt) this.toAssignable(elt, isBinding);1130}1131return exprList;1132};11331134// Parses spread element.11351136pp.parseSpread = function (refShorthandDefaultPos) {1137var node = this.startNode();1138this.next();1139node.argument = this.parseMaybeAssign(refShorthandDefaultPos);1140return this.finishNode(node, "SpreadElement");1141};11421143pp.parseRest = function () {1144var node = this.startNode();1145this.next();1146node.argument = this.type === tt.name || this.type === tt.bracketL ? this.parseBindingAtom() : this.unexpected();1147return this.finishNode(node, "RestElement");1148};11491150// Parses lvalue (assignable) atom.11511152pp.parseBindingAtom = function () {1153if (this.options.ecmaVersion < 6) return this.parseIdent();1154switch (this.type) {1155case tt.name:1156return this.parseIdent();11571158case tt.bracketL:1159var node = this.startNode();1160this.next();1161node.elements = this.parseBindingList(tt.bracketR, true, true);1162return this.finishNode(node, "ArrayPattern");11631164case tt.braceL:1165return this.parseObj(true);11661167default:1168this.unexpected();1169}1170};11711172pp.parseBindingList = function (close, allowEmpty, allowTrailingComma) {1173var elts = [],1174first = true;1175while (!this.eat(close)) {1176if (first) first = false;else this.expect(tt.comma);1177if (allowEmpty && this.type === tt.comma) {1178elts.push(null);1179} else if (allowTrailingComma && this.afterTrailingComma(close)) {1180break;1181} else if (this.type === tt.ellipsis) {1182var rest = this.parseRest();1183this.parseBindingListItem(rest);1184elts.push(rest);1185this.expect(close);1186break;1187} else {1188var elem = this.parseMaybeDefault(this.start, this.startLoc);1189this.parseBindingListItem(elem);1190elts.push(elem);1191}1192}1193return elts;1194};11951196pp.parseBindingListItem = function (param) {1197return param;1198};11991200// Parses assignment pattern around given atom if possible.12011202pp.parseMaybeDefault = function (startPos, startLoc, left) {1203left = left || this.parseBindingAtom();1204if (!this.eat(tt.eq)) return left;1205var node = this.startNodeAt(startPos, startLoc);1206node.operator = "=";1207node.left = left;1208node.right = this.parseMaybeAssign();1209return this.finishNode(node, "AssignmentPattern");1210};12111212// Verify that a node is an lval — something that can be assigned1213// to.12141215pp.checkLVal = function (expr, isBinding, checkClashes) {1216switch (expr.type) {1217case "Identifier":1218if (this.strict && (reservedWords.strictBind(expr.name) || reservedWords.strict(expr.name))) this.raise(expr.start, (isBinding ? "Binding " : "Assigning to ") + expr.name + " in strict mode");1219if (checkClashes) {1220if (has(checkClashes, expr.name)) this.raise(expr.start, "Argument name clash in strict mode");1221checkClashes[expr.name] = true;1222}1223break;12241225case "MemberExpression":1226if (isBinding) this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " member expression");1227break;12281229case "ObjectPattern":1230for (var i = 0; i < expr.properties.length; i++) {1231this.checkLVal(expr.properties[i].value, isBinding, checkClashes);1232}break;12331234case "ArrayPattern":1235for (var i = 0; i < expr.elements.length; i++) {1236var elem = expr.elements[i];1237if (elem) this.checkLVal(elem, isBinding, checkClashes);1238}1239break;12401241case "AssignmentPattern":1242this.checkLVal(expr.left, isBinding, checkClashes);1243break;12441245case "RestElement":1246this.checkLVal(expr.argument, isBinding, checkClashes);1247break;12481249case "ParenthesizedExpression":1250this.checkLVal(expr.expression, isBinding, checkClashes);1251break;12521253default:1254this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " rvalue");1255}1256};12571258},{"./identifier":3,"./state":9,"./tokentype":13,"./util":14}],6:[function(_dereq_,module,exports){1259"use strict";12601261var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };12621263exports.__esModule = true;12641265var Parser = _dereq_("./state").Parser;12661267var SourceLocation = _dereq_("./location").SourceLocation;12681269// Start an AST node, attaching a start offset.12701271var pp = Parser.prototype;12721273var Node = exports.Node = function Node() {1274_classCallCheck(this, Node);1275};12761277pp.startNode = function () {1278var node = new Node();1279node.start = this.start;1280if (this.options.locations) node.loc = new SourceLocation(this, this.startLoc);1281if (this.options.directSourceFile) node.sourceFile = this.options.directSourceFile;1282if (this.options.ranges) node.range = [this.start, 0];1283return node;1284};12851286pp.startNodeAt = function (pos, loc) {1287var node = new Node();1288node.start = pos;1289if (this.options.locations) node.loc = new SourceLocation(this, loc);1290if (this.options.directSourceFile) node.sourceFile = this.options.directSourceFile;1291if (this.options.ranges) node.range = [pos, 0];1292return node;1293};12941295// Finish an AST node, adding `type` and `end` properties.12961297pp.finishNode = function (node, type) {1298node.type = type;1299node.end = this.lastTokEnd;1300if (this.options.locations) node.loc.end = this.lastTokEndLoc;1301if (this.options.ranges) node.range[1] = this.lastTokEnd;1302return node;1303};13041305// Finish node at given position13061307pp.finishNodeAt = function (node, type, pos, loc) {1308node.type = type;1309node.end = pos;1310if (this.options.locations) node.loc.end = loc;1311if (this.options.ranges) node.range[1] = pos;1312return node;1313};13141315},{"./location":4,"./state":9}],7:[function(_dereq_,module,exports){131613171318// Interpret and default an options object13191320"use strict";13211322exports.getOptions = getOptions;1323exports.__esModule = true;13241325var _util = _dereq_("./util");13261327var has = _util.has;1328var isArray = _util.isArray;13291330var SourceLocation = _dereq_("./location").SourceLocation;13311332// A second optional argument can be given to further configure1333// the parser process. These options are recognized:13341335var defaultOptions = {1336// `ecmaVersion` indicates the ECMAScript version to parse. Must1337// be either 3, or 5, or 6. This influences support for strict1338// mode, the set of reserved words, support for getters and1339// setters and other features.1340ecmaVersion: 5,1341// Source type ("script" or "module") for different semantics1342sourceType: "script",1343// `onInsertedSemicolon` can be a callback that will be called1344// when a semicolon is automatically inserted. It will be passed1345// th position of the comma as an offset, and if `locations` is1346// enabled, it is given the location as a `{line, column}` object1347// as second argument.1348onInsertedSemicolon: null,1349// `onTrailingComma` is similar to `onInsertedSemicolon`, but for1350// trailing commas.1351onTrailingComma: null,1352// By default, reserved words are not enforced. Disable1353// `allowReserved` to enforce them. When this option has the1354// value "never", reserved words and keywords can also not be1355// used as property names.1356allowReserved: true,1357// When enabled, a return at the top level is not considered an1358// error.1359allowReturnOutsideFunction: false,1360// When enabled, import/export statements are not constrained to1361// appearing at the top of the program.1362allowImportExportEverywhere: false,1363// When enabled, hashbang directive in the beginning of file1364// is allowed and treated as a line comment.1365allowHashBang: false,1366// When `locations` is on, `loc` properties holding objects with1367// `start` and `end` properties in `{line, column}` form (with1368// line being 1-based and column 0-based) will be attached to the1369// nodes.1370locations: false,1371// A function can be passed as `onToken` option, which will1372// cause Acorn to call that function with object in the same1373// format as tokenize() returns. Note that you are not1374// allowed to call the parser from the callback—that will1375// corrupt its internal state.1376onToken: null,1377// A function can be passed as `onComment` option, which will1378// cause Acorn to call that function with `(block, text, start,1379// end)` parameters whenever a comment is skipped. `block` is a1380// boolean indicating whether this is a block (`/* */`) comment,1381// `text` is the content of the comment, and `start` and `end` are1382// character offsets that denote the start and end of the comment.1383// When the `locations` option is on, two more parameters are1384// passed, the full `{line, column}` locations of the start and1385// end of the comments. Note that you are not allowed to call the1386// parser from the callback—that will corrupt its internal state.1387onComment: null,1388// Nodes have their start and end characters offsets recorded in1389// `start` and `end` properties (directly on the node, rather than1390// the `loc` object, which holds line/column data. To also add a1391// [semi-standardized][range] `range` property holding a `[start,1392// end]` array with the same numbers, set the `ranges` option to1393// `true`.1394//1395// [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=7456781396ranges: false,1397// It is possible to parse multiple files into a single AST by1398// passing the tree produced by parsing the first file as1399// `program` option in subsequent parses. This will add the1400// toplevel forms of the parsed file to the `Program` (top) node1401// of an existing parse tree.1402program: null,1403// When `locations` is on, you can pass this to record the source1404// file in every node's `loc` object.1405sourceFile: null,1406// This value, if given, is stored in every node, whether1407// `locations` is on or off.1408directSourceFile: null,1409// When enabled, parenthesized expressions are represented by1410// (non-standard) ParenthesizedExpression nodes1411preserveParens: false,1412plugins: {}1413};exports.defaultOptions = defaultOptions;14141415function getOptions(opts) {1416var options = {};1417for (var opt in defaultOptions) {1418options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt];1419}if (isArray(options.onToken)) {1420(function () {1421var tokens = options.onToken;1422options.onToken = function (token) {1423return tokens.push(token);1424};1425})();1426}1427if (isArray(options.onComment)) options.onComment = pushComment(options, options.onComment);14281429return options;1430}14311432function pushComment(options, array) {1433return function (block, text, start, end, startLoc, endLoc) {1434var comment = {1435type: block ? "Block" : "Line",1436value: text,1437start: start,1438end: end1439};1440if (options.locations) comment.loc = new SourceLocation(this, startLoc, endLoc);1441if (options.ranges) comment.range = [start, end];1442array.push(comment);1443};1444}14451446},{"./location":4,"./util":14}],8:[function(_dereq_,module,exports){1447"use strict";14481449var tt = _dereq_("./tokentype").types;14501451var Parser = _dereq_("./state").Parser;14521453var lineBreak = _dereq_("./whitespace").lineBreak;14541455var pp = Parser.prototype;14561457// ## Parser utilities14581459// Test whether a statement node is the string literal `"use strict"`.14601461pp.isUseStrict = function (stmt) {1462return this.options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && stmt.expression.value === "use strict";1463};14641465// Predicate that tests whether the next token is of the given1466// type, and if yes, consumes it as a side effect.14671468pp.eat = function (type) {1469if (this.type === type) {1470this.next();1471return true;1472} else {1473return false;1474}1475};14761477// Tests whether parsed token is a contextual keyword.14781479pp.isContextual = function (name) {1480return this.type === tt.name && this.value === name;1481};14821483// Consumes contextual keyword if possible.14841485pp.eatContextual = function (name) {1486return this.value === name && this.eat(tt.name);1487};14881489// Asserts that following token is given contextual keyword.14901491pp.expectContextual = function (name) {1492if (!this.eatContextual(name)) this.unexpected();1493};14941495// Test whether a semicolon can be inserted at the current position.14961497pp.canInsertSemicolon = function () {1498return this.type === tt.eof || this.type === tt.braceR || lineBreak.test(this.input.slice(this.lastTokEnd, this.start));1499};15001501pp.insertSemicolon = function () {1502if (this.canInsertSemicolon()) {1503if (this.options.onInsertedSemicolon) this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc);1504return true;1505}1506};15071508// Consume a semicolon, or, failing that, see if we are allowed to1509// pretend that there is a semicolon at this position.15101511pp.semicolon = function () {1512if (!this.eat(tt.semi) && !this.insertSemicolon()) this.unexpected();1513};15141515pp.afterTrailingComma = function (tokType) {1516if (this.type == tokType) {1517if (this.options.onTrailingComma) this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc);1518this.next();1519return true;1520}1521};15221523// Expect a token of a given type. If found, consume it, otherwise,1524// raise an unexpected token error.15251526pp.expect = function (type) {1527this.eat(type) || this.unexpected();1528};15291530// Raise an unexpected token error.15311532pp.unexpected = function (pos) {1533this.raise(pos != null ? pos : this.start, "Unexpected token");1534};15351536},{"./state":9,"./tokentype":13,"./whitespace":15}],9:[function(_dereq_,module,exports){1537"use strict";15381539exports.Parser = Parser;1540exports.__esModule = true;15411542var _identifier = _dereq_("./identifier");15431544var reservedWords = _identifier.reservedWords;1545var keywords = _identifier.keywords;15461547var tt = _dereq_("./tokentype").types;15481549var lineBreak = _dereq_("./whitespace").lineBreak;15501551function Parser(options, input, startPos) {1552this.options = options;1553this.sourceFile = this.options.sourceFile || null;1554this.isKeyword = keywords[this.options.ecmaVersion >= 6 ? 6 : 5];1555this.isReservedWord = reservedWords[this.options.ecmaVersion];1556this.input = input;15571558// Load plugins1559this.loadPlugins(this.options.plugins);15601561// Set up token state15621563// The current position of the tokenizer in the input.1564if (startPos) {1565this.pos = startPos;1566this.lineStart = Math.max(0, this.input.lastIndexOf("\n", startPos));1567this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;1568} else {1569this.pos = this.lineStart = 0;1570this.curLine = 1;1571}15721573// Properties of the current token:1574// Its type1575this.type = tt.eof;1576// For tokens that include more information than their type, the value1577this.value = null;1578// Its start and end offset1579this.start = this.end = this.pos;1580// And, if locations are used, the {line, column} object1581// corresponding to those offsets1582this.startLoc = this.endLoc = null;15831584// Position information for the previous token1585this.lastTokEndLoc = this.lastTokStartLoc = null;1586this.lastTokStart = this.lastTokEnd = this.pos;15871588// The context stack is used to superficially track syntactic1589// context to predict whether a regular expression is allowed in a1590// given position.1591this.context = this.initialContext();1592this.exprAllowed = true;15931594// Figure out if it's a module code.1595this.strict = this.inModule = this.options.sourceType === "module";15961597// Used to signify the start of a potential arrow function1598this.potentialArrowAt = -1;15991600// Flags to track whether we are in a function, a generator.1601this.inFunction = this.inGenerator = false;1602// Labels in scope.1603this.labels = [];16041605// If enabled, skip leading hashbang line.1606if (this.pos === 0 && this.options.allowHashBang && this.input.slice(0, 2) === "#!") this.skipLineComment(2);1607}16081609Parser.prototype.extend = function (name, f) {1610this[name] = f(this[name]);1611};16121613// Registered plugins16141615var plugins = {};16161617exports.plugins = plugins;1618Parser.prototype.loadPlugins = function (plugins) {1619for (var _name in plugins) {1620var plugin = exports.plugins[_name];1621if (!plugin) throw new Error("Plugin '" + _name + "' not found");1622plugin(this, plugins[_name]);1623}1624};16251626},{"./identifier":3,"./tokentype":13,"./whitespace":15}],10:[function(_dereq_,module,exports){1627"use strict";16281629var tt = _dereq_("./tokentype").types;16301631var Parser = _dereq_("./state").Parser;16321633var lineBreak = _dereq_("./whitespace").lineBreak;16341635var pp = Parser.prototype;16361637// ### Statement parsing16381639// Parse a program. Initializes the parser, reads any number of1640// statements, and wraps them in a Program node. Optionally takes a1641// `program` argument. If present, the statements will be appended1642// to its body instead of creating a new node.16431644pp.parseTopLevel = function (node) {1645var first = true;1646if (!node.body) node.body = [];1647while (this.type !== tt.eof) {1648var stmt = this.parseStatement(true, true);1649node.body.push(stmt);1650if (first && this.isUseStrict(stmt)) this.setStrict(true);1651first = false;1652}1653this.next();1654if (this.options.ecmaVersion >= 6) {1655node.sourceType = this.options.sourceType;1656}1657return this.finishNode(node, "Program");1658};16591660var loopLabel = { kind: "loop" },1661switchLabel = { kind: "switch" };16621663// Parse a single statement.1664//1665// If expecting a statement and finding a slash operator, parse a1666// regular expression literal. This is to handle cases like1667// `if (foo) /blah/.exec(foo)`, where looking at the previous token1668// does not help.16691670pp.parseStatement = function (declaration, topLevel) {1671var starttype = this.type,1672node = this.startNode();16731674// Most types of statements are recognized by the keyword they1675// start with. Many are trivial to parse, some require a bit of1676// complexity.16771678switch (starttype) {1679case tt._break:case tt._continue:1680return this.parseBreakContinueStatement(node, starttype.keyword);1681case tt._debugger:1682return this.parseDebuggerStatement(node);1683case tt._do:1684return this.parseDoStatement(node);1685case tt._for:1686return this.parseForStatement(node);1687case tt._function:1688if (!declaration && this.options.ecmaVersion >= 6) this.unexpected();1689return this.parseFunctionStatement(node);1690case tt._class:1691if (!declaration) this.unexpected();1692return this.parseClass(node, true);1693case tt._if:1694return this.parseIfStatement(node);1695case tt._return:1696return this.parseReturnStatement(node);1697case tt._switch:1698return this.parseSwitchStatement(node);1699case tt._throw:1700return this.parseThrowStatement(node);1701case tt._try:1702return this.parseTryStatement(node);1703case tt._let:case tt._const:1704if (!declaration) this.unexpected(); // NOTE: falls through to _var1705case tt._var:1706return this.parseVarStatement(node, starttype);1707case tt._while:1708return this.parseWhileStatement(node);1709case tt._with:1710return this.parseWithStatement(node);1711case tt.braceL:1712return this.parseBlock();1713case tt.semi:1714return this.parseEmptyStatement(node);1715case tt._export:1716case tt._import:1717if (!this.options.allowImportExportEverywhere) {1718if (!topLevel) this.raise(this.start, "'import' and 'export' may only appear at the top level");1719if (!this.inModule) this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");1720}1721return starttype === tt._import ? this.parseImport(node) : this.parseExport(node);17221723// If the statement does not start with a statement keyword or a1724// brace, it's an ExpressionStatement or LabeledStatement. We1725// simply start parsing an expression, and afterwards, if the1726// next token is a colon and the expression was a simple1727// Identifier node, we switch to interpreting it as a label.1728default:1729var maybeName = this.value,1730expr = this.parseExpression();1731if (starttype === tt.name && expr.type === "Identifier" && this.eat(tt.colon)) return this.parseLabeledStatement(node, maybeName, expr);else return this.parseExpressionStatement(node, expr);1732}1733};17341735pp.parseBreakContinueStatement = function (node, keyword) {1736var isBreak = keyword == "break";1737this.next();1738if (this.eat(tt.semi) || this.insertSemicolon()) node.label = null;else if (this.type !== tt.name) this.unexpected();else {1739node.label = this.parseIdent();1740this.semicolon();1741}17421743// Verify that there is an actual destination to break or1744// continue to.1745for (var i = 0; i < this.labels.length; ++i) {1746var lab = this.labels[i];1747if (node.label == null || lab.name === node.label.name) {1748if (lab.kind != null && (isBreak || lab.kind === "loop")) break;1749if (node.label && isBreak) break;1750}1751}1752if (i === this.labels.length) this.raise(node.start, "Unsyntactic " + keyword);1753return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");1754};17551756pp.parseDebuggerStatement = function (node) {1757this.next();1758this.semicolon();1759return this.finishNode(node, "DebuggerStatement");1760};17611762pp.parseDoStatement = function (node) {1763this.next();1764this.labels.push(loopLabel);1765node.body = this.parseStatement(false);1766this.labels.pop();1767this.expect(tt._while);1768node.test = this.parseParenExpression();1769if (this.options.ecmaVersion >= 6) this.eat(tt.semi);else this.semicolon();1770return this.finishNode(node, "DoWhileStatement");1771};17721773// Disambiguating between a `for` and a `for`/`in` or `for`/`of`1774// loop is non-trivial. Basically, we have to parse the init `var`1775// statement or expression, disallowing the `in` operator (see1776// the second parameter to `parseExpression`), and then check1777// whether the next token is `in` or `of`. When there is no init1778// part (semicolon immediately after the opening parenthesis), it1779// is a regular `for` loop.17801781pp.parseForStatement = function (node) {1782this.next();1783this.labels.push(loopLabel);1784this.expect(tt.parenL);1785if (this.type === tt.semi) return this.parseFor(node, null);1786if (this.type === tt._var || this.type === tt._let || this.type === tt._const) {1787var _init = this.startNode(),1788varKind = this.type;1789this.next();1790this.parseVar(_init, true, varKind);1791this.finishNode(_init, "VariableDeclaration");1792if ((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);1793return this.parseFor(node, _init);1794}1795var refShorthandDefaultPos = { start: 0 };1796var init = this.parseExpression(true, refShorthandDefaultPos);1797if (this.type === tt._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) {1798this.toAssignable(init);1799this.checkLVal(init);1800return this.parseForIn(node, init);1801} else if (refShorthandDefaultPos.start) {1802this.unexpected(refShorthandDefaultPos.start);1803}1804return this.parseFor(node, init);1805};18061807pp.parseFunctionStatement = function (node) {1808this.next();1809return this.parseFunction(node, true);1810};18111812pp.parseIfStatement = function (node) {1813this.next();1814node.test = this.parseParenExpression();1815node.consequent = this.parseStatement(false);1816node.alternate = this.eat(tt._else) ? this.parseStatement(false) : null;1817return this.finishNode(node, "IfStatement");1818};18191820pp.parseReturnStatement = function (node) {1821if (!this.inFunction && !this.options.allowReturnOutsideFunction) this.raise(this.start, "'return' outside of function");1822this.next();18231824// In `return` (and `break`/`continue`), the keywords with1825// optional arguments, we eagerly look for a semicolon or the1826// possibility to insert one.18271828if (this.eat(tt.semi) || this.insertSemicolon()) node.argument = null;else {1829node.argument = this.parseExpression();this.semicolon();1830}1831return this.finishNode(node, "ReturnStatement");1832};18331834pp.parseSwitchStatement = function (node) {1835this.next();1836node.discriminant = this.parseParenExpression();1837node.cases = [];1838this.expect(tt.braceL);1839this.labels.push(switchLabel);18401841// Statements under must be grouped (by label) in SwitchCase1842// nodes. `cur` is used to keep the node that we are currently1843// adding statements to.18441845for (var cur, sawDefault; this.type != tt.braceR;) {1846if (this.type === tt._case || this.type === tt._default) {1847var isCase = this.type === tt._case;1848if (cur) this.finishNode(cur, "SwitchCase");1849node.cases.push(cur = this.startNode());1850cur.consequent = [];1851this.next();1852if (isCase) {1853cur.test = this.parseExpression();1854} else {1855if (sawDefault) this.raise(this.lastTokStart, "Multiple default clauses");1856sawDefault = true;1857cur.test = null;1858}1859this.expect(tt.colon);1860} else {1861if (!cur) this.unexpected();1862cur.consequent.push(this.parseStatement(true));1863}1864}1865if (cur) this.finishNode(cur, "SwitchCase");1866this.next(); // Closing brace1867this.labels.pop();1868return this.finishNode(node, "SwitchStatement");1869};18701871pp.parseThrowStatement = function (node) {1872this.next();1873if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) this.raise(this.lastTokEnd, "Illegal newline after throw");1874node.argument = this.parseExpression();1875this.semicolon();1876return this.finishNode(node, "ThrowStatement");1877};18781879// Reused empty array added for node fields that are always empty.18801881var empty = [];18821883pp.parseTryStatement = function (node) {1884this.next();1885node.block = this.parseBlock();1886node.handler = null;1887if (this.type === tt._catch) {1888var clause = this.startNode();1889this.next();1890this.expect(tt.parenL);1891clause.param = this.parseBindingAtom();1892this.checkLVal(clause.param, true);1893this.expect(tt.parenR);1894clause.guard = null;1895clause.body = this.parseBlock();1896node.handler = this.finishNode(clause, "CatchClause");1897}1898node.guardedHandlers = empty;1899node.finalizer = this.eat(tt._finally) ? this.parseBlock() : null;1900if (!node.handler && !node.finalizer) this.raise(node.start, "Missing catch or finally clause");1901return this.finishNode(node, "TryStatement");1902};19031904pp.parseVarStatement = function (node, kind) {1905this.next();1906this.parseVar(node, false, kind);1907this.semicolon();1908return this.finishNode(node, "VariableDeclaration");1909};19101911pp.parseWhileStatement = function (node) {1912this.next();1913node.test = this.parseParenExpression();1914this.labels.push(loopLabel);1915node.body = this.parseStatement(false);1916this.labels.pop();1917return this.finishNode(node, "WhileStatement");1918};19191920pp.parseWithStatement = function (node) {1921if (this.strict) this.raise(this.start, "'with' in strict mode");1922this.next();1923node.object = this.parseParenExpression();1924node.body = this.parseStatement(false);1925return this.finishNode(node, "WithStatement");1926};19271928pp.parseEmptyStatement = function (node) {1929this.next();1930return this.finishNode(node, "EmptyStatement");1931};19321933pp.parseLabeledStatement = function (node, maybeName, expr) {1934for (var i = 0; i < this.labels.length; ++i) {1935if (this.labels[i].name === maybeName) this.raise(expr.start, "Label '" + maybeName + "' is already declared");1936}var kind = this.type.isLoop ? "loop" : this.type === tt._switch ? "switch" : null;1937this.labels.push({ name: maybeName, kind: kind });1938node.body = this.parseStatement(true);1939this.labels.pop();1940node.label = expr;1941return this.finishNode(node, "LabeledStatement");1942};19431944pp.parseExpressionStatement = function (node, expr) {1945node.expression = expr;1946this.semicolon();1947return this.finishNode(node, "ExpressionStatement");1948};19491950// Parse a semicolon-enclosed block of statements, handling `"use1951// strict"` declarations when `allowStrict` is true (used for1952// function bodies).19531954pp.parseBlock = function (allowStrict) {1955var node = this.startNode(),1956first = true,1957oldStrict = undefined;1958node.body = [];1959this.expect(tt.braceL);1960while (!this.eat(tt.braceR)) {1961var stmt = this.parseStatement(true);1962node.body.push(stmt);1963if (first && allowStrict && this.isUseStrict(stmt)) {1964oldStrict = this.strict;1965this.setStrict(this.strict = true);1966}1967first = false;1968}1969if (oldStrict === false) this.setStrict(false);1970return this.finishNode(node, "BlockStatement");1971};19721973// Parse a regular `for` loop. The disambiguation code in1974// `parseStatement` will already have parsed the init statement or1975// expression.19761977pp.parseFor = function (node, init) {1978node.init = init;1979this.expect(tt.semi);1980node.test = this.type === tt.semi ? null : this.parseExpression();1981this.expect(tt.semi);1982node.update = this.type === tt.parenR ? null : this.parseExpression();1983this.expect(tt.parenR);1984node.body = this.parseStatement(false);1985this.labels.pop();1986return this.finishNode(node, "ForStatement");1987};19881989// Parse a `for`/`in` and `for`/`of` loop, which are almost1990// same from parser's perspective.19911992pp.parseForIn = function (node, init) {1993var type = this.type === tt._in ? "ForInStatement" : "ForOfStatement";1994this.next();1995node.left = init;1996node.right = this.parseExpression();1997this.expect(tt.parenR);1998node.body = this.parseStatement(false);1999this.labels.pop();2000return this.finishNode(node, type);2001};20022003// Parse a list of variable declarations.20042005pp.parseVar = function (node, isFor, kind) {2006node.declarations = [];2007node.kind = kind.keyword;2008for (;;) {2009var decl = this.startNode();2010this.parseVarId(decl);2011if (this.eat(tt.eq)) {2012decl.init = this.parseMaybeAssign(isFor);2013} else if (kind === tt._const && !(this.type === tt._in || this.options.ecmaVersion >= 6 && this.isContextual("of"))) {2014this.unexpected();2015} else if (decl.id.type != "Identifier" && !(isFor && (this.type === tt._in || this.isContextual("of")))) {2016this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");2017} else {2018decl.init = null;2019}2020node.declarations.push(this.finishNode(decl, "VariableDeclarator"));2021if (!this.eat(tt.comma)) break;2022}2023return node;2024};20252026pp.parseVarId = function (decl) {2027decl.id = this.parseBindingAtom();2028this.checkLVal(decl.id, true);2029};20302031// Parse a function declaration or literal (depending on the2032// `isStatement` parameter).20332034pp.parseFunction = function (node, isStatement, allowExpressionBody) {2035this.initFunction(node);2036if (this.options.ecmaVersion >= 6) node.generator = this.eat(tt.star);2037if (isStatement || this.type === tt.name) node.id = this.parseIdent();2038this.parseFunctionParams(node);2039this.parseFunctionBody(node, allowExpressionBody);2040return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");2041};20422043pp.parseFunctionParams = function (node) {2044this.expect(tt.parenL);2045node.params = this.parseBindingList(tt.parenR, false, false);2046};20472048// Parse a class declaration or literal (depending on the2049// `isStatement` parameter).20502051pp.parseClass = function (node, isStatement) {2052this.next();2053this.parseClassId(node, isStatement);2054this.parseClassSuper(node);2055var classBody = this.startNode();2056var hadConstructor = false;2057classBody.body = [];2058this.expect(tt.braceL);2059while (!this.eat(tt.braceR)) {2060if (this.eat(tt.semi)) continue;2061var method = this.startNode();2062var isGenerator = this.eat(tt.star);2063var isMaybeStatic = this.type === tt.name && this.value === "static";2064this.parsePropertyName(method);2065method["static"] = isMaybeStatic && this.type !== tt.parenL;2066if (method["static"]) {2067if (isGenerator) this.unexpected();2068isGenerator = this.eat(tt.star);2069this.parsePropertyName(method);2070}2071method.kind = "method";2072if (!method.computed) {2073var key = method.key;20742075var isGetSet = false;2076if (!isGenerator && key.type === "Identifier" && this.type !== tt.parenL && (key.name === "get" || key.name === "set")) {2077isGetSet = true;2078method.kind = key.name;2079key = this.parsePropertyName(method);2080}2081if (!method["static"] && (key.type === "Identifier" && key.name === "constructor" || key.type === "Literal" && key.value === "constructor")) {2082if (hadConstructor) this.raise(key.start, "Duplicate constructor in the same class");2083if (isGetSet) this.raise(key.start, "Constructor can't have get/set modifier");2084if (isGenerator) this.raise(key.start, "Constructor can't be a generator");2085method.kind = "constructor";2086hadConstructor = true;2087}2088}2089this.parseClassMethod(classBody, method, isGenerator);2090}2091node.body = this.finishNode(classBody, "ClassBody");2092return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");2093};20942095pp.parseClassMethod = function (classBody, method, isGenerator) {2096method.value = this.parseMethod(isGenerator);2097classBody.body.push(this.finishNode(method, "MethodDefinition"));2098};20992100pp.parseClassId = function (node, isStatement) {2101node.id = this.type === tt.name ? this.parseIdent() : isStatement ? this.unexpected() : null;2102};21032104pp.parseClassSuper = function (node) {2105node.superClass = this.eat(tt._extends) ? this.parseExprSubscripts() : null;2106};21072108// Parses module export declaration.21092110pp.parseExport = function (node) {2111this.next();2112// export * from '...'2113if (this.eat(tt.star)) {2114this.expectContextual("from");2115node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();2116this.semicolon();2117return this.finishNode(node, "ExportAllDeclaration");2118}2119if (this.eat(tt._default)) {2120// export default ...2121var expr = this.parseMaybeAssign();2122var needsSemi = true;2123if (expr.type == "FunctionExpression" || expr.type == "ClassExpression") {2124needsSemi = false;2125if (expr.id) {2126expr.type = expr.type == "FunctionExpression" ? "FunctionDeclaration" : "ClassDeclaration";2127}2128}2129node.declaration = expr;2130if (needsSemi) this.semicolon();2131return this.finishNode(node, "ExportDefaultDeclaration");2132}2133// export var|const|let|function|class ...2134if (this.shouldParseExportStatement()) {2135node.declaration = this.parseStatement(true);2136node.specifiers = [];2137node.source = null;2138} else {2139// export { x, y as z } [from '...']2140node.declaration = null;2141node.specifiers = this.parseExportSpecifiers();2142if (this.eatContextual("from")) {2143node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();2144} else {2145node.source = null;2146}2147this.semicolon();2148}2149return this.finishNode(node, "ExportNamedDeclaration");2150};21512152pp.shouldParseExportStatement = function () {2153return this.type.keyword;2154};21552156// Parses a comma-separated list of module exports.21572158pp.parseExportSpecifiers = function () {2159var nodes = [],2160first = true;2161// export { x, y as z } [from '...']2162this.expect(tt.braceL);2163while (!this.eat(tt.braceR)) {2164if (!first) {2165this.expect(tt.comma);2166if (this.afterTrailingComma(tt.braceR)) break;2167} else first = false;21682169var node = this.startNode();2170node.local = this.parseIdent(this.type === tt._default);2171node.exported = this.eatContextual("as") ? this.parseIdent(true) : node.local;2172nodes.push(this.finishNode(node, "ExportSpecifier"));2173}2174return nodes;2175};21762177// Parses import declaration.21782179pp.parseImport = function (node) {2180this.next();2181// import '...'2182if (this.type === tt.string) {2183node.specifiers = empty;2184node.source = this.parseExprAtom();2185node.kind = "";2186} else {2187node.specifiers = this.parseImportSpecifiers();2188this.expectContextual("from");2189node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();2190}2191this.semicolon();2192return this.finishNode(node, "ImportDeclaration");2193};21942195// Parses a comma-separated list of module imports.21962197pp.parseImportSpecifiers = function () {2198var nodes = [],2199first = true;2200if (this.type === tt.name) {2201// import defaultObj, { x, y as z } from '...'2202var node = this.startNode();2203node.local = this.parseIdent();2204this.checkLVal(node.local, true);2205nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));2206if (!this.eat(tt.comma)) return nodes;2207}2208if (this.type === tt.star) {2209var node = this.startNode();2210this.next();2211this.expectContextual("as");2212node.local = this.parseIdent();2213this.checkLVal(node.local, true);2214nodes.push(this.finishNode(node, "ImportNamespaceSpecifier"));2215return nodes;2216}2217this.expect(tt.braceL);2218while (!this.eat(tt.braceR)) {2219if (!first) {2220this.expect(tt.comma);2221if (this.afterTrailingComma(tt.braceR)) break;2222} else first = false;22232224var node = this.startNode();2225node.imported = this.parseIdent(true);2226node.local = this.eatContextual("as") ? this.parseIdent() : node.imported;2227this.checkLVal(node.local, true);2228nodes.push(this.finishNode(node, "ImportSpecifier"));2229}2230return nodes;2231};22322233},{"./state":9,"./tokentype":13,"./whitespace":15}],11:[function(_dereq_,module,exports){2234"use strict";22352236var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };22372238exports.__esModule = true;2239// The algorithm used to determine whether a regexp can appear at a2240// given point in the program is loosely based on sweet.js' approach.2241// See https://github.com/mozilla/sweet.js/wiki/design22422243var Parser = _dereq_("./state").Parser;22442245var tt = _dereq_("./tokentype").types;22462247var lineBreak = _dereq_("./whitespace").lineBreak;22482249var TokContext = exports.TokContext = function TokContext(token, isExpr, preserveSpace, override) {2250_classCallCheck(this, TokContext);22512252this.token = token;2253this.isExpr = isExpr;2254this.preserveSpace = preserveSpace;2255this.override = override;2256};22572258var types = {2259b_stat: new TokContext("{", false),2260b_expr: new TokContext("{", true),2261b_tmpl: new TokContext("${", true),2262p_stat: new TokContext("(", false),2263p_expr: new TokContext("(", true),2264q_tmpl: new TokContext("`", true, true, function (p) {2265return p.readTmplToken();2266}),2267f_expr: new TokContext("function", true)2268};22692270exports.types = types;2271var pp = Parser.prototype;22722273pp.initialContext = function () {2274return [types.b_stat];2275};22762277pp.braceIsBlock = function (prevType) {2278var parent = undefined;2279if (prevType === tt.colon && (parent = this.curContext()).token == "{") return !parent.isExpr;2280if (prevType === tt._return) return lineBreak.test(this.input.slice(this.lastTokEnd, this.start));2281if (prevType === tt._else || prevType === tt.semi || prevType === tt.eof) return true;2282if (prevType == tt.braceL) return this.curContext() === types.b_stat;2283return !this.exprAllowed;2284};22852286pp.updateContext = function (prevType) {2287var update = undefined,2288type = this.type;2289if (type.keyword && prevType == tt.dot) this.exprAllowed = false;else if (update = type.updateContext) update.call(this, prevType);else this.exprAllowed = type.beforeExpr;2290};22912292// Token-specific context update code22932294tt.parenR.updateContext = tt.braceR.updateContext = function () {2295if (this.context.length == 1) {2296this.exprAllowed = true;2297return;2298}2299var out = this.context.pop();2300if (out === types.b_stat && this.curContext() === types.f_expr) {2301this.context.pop();2302this.exprAllowed = false;2303} else if (out === types.b_tmpl) {2304this.exprAllowed = true;2305} else {2306this.exprAllowed = !out.isExpr;2307}2308};23092310tt.braceL.updateContext = function (prevType) {2311this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr);2312this.exprAllowed = true;2313};23142315tt.dollarBraceL.updateContext = function () {2316this.context.push(types.b_tmpl);2317this.exprAllowed = true;2318};23192320tt.parenL.updateContext = function (prevType) {2321var statementParens = prevType === tt._if || prevType === tt._for || prevType === tt._with || prevType === tt._while;2322this.context.push(statementParens ? types.p_stat : types.p_expr);2323this.exprAllowed = true;2324};23252326tt.incDec.updateContext = function () {};23272328tt._function.updateContext = function () {2329if (this.curContext() !== types.b_stat) this.context.push(types.f_expr);2330this.exprAllowed = false;2331};23322333tt.backQuote.updateContext = function () {2334if (this.curContext() === types.q_tmpl) this.context.pop();else this.context.push(types.q_tmpl);2335this.exprAllowed = false;2336};23372338// tokExprAllowed stays unchanged23392340},{"./state":9,"./tokentype":13,"./whitespace":15}],12:[function(_dereq_,module,exports){2341"use strict";23422343var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };23442345exports.__esModule = true;23462347var _identifier = _dereq_("./identifier");23482349var isIdentifierStart = _identifier.isIdentifierStart;2350var isIdentifierChar = _identifier.isIdentifierChar;23512352var _tokentype = _dereq_("./tokentype");23532354var tt = _tokentype.types;2355var keywordTypes = _tokentype.keywords;23562357var Parser = _dereq_("./state").Parser;23582359var SourceLocation = _dereq_("./location").SourceLocation;23602361var _whitespace = _dereq_("./whitespace");23622363var lineBreak = _whitespace.lineBreak;2364var lineBreakG = _whitespace.lineBreakG;2365var isNewLine = _whitespace.isNewLine;2366var nonASCIIwhitespace = _whitespace.nonASCIIwhitespace;23672368// Object type used to represent tokens. Note that normally, tokens2369// simply exist as properties on the parser object. This is only2370// used for the onToken callback and the external tokenizer.23712372var Token = exports.Token = function Token(p) {2373_classCallCheck(this, Token);23742375this.type = p.type;2376this.value = p.value;2377this.start = p.start;2378this.end = p.end;2379if (p.options.locations) this.loc = new SourceLocation(p, p.startLoc, p.endLoc);2380if (p.options.ranges) this.range = [p.start, p.end];2381};23822383// ## Tokenizer23842385var pp = Parser.prototype;23862387// Are we running under Rhino?2388var isRhino = typeof Packages !== "undefined";23892390// Move to the next token23912392pp.next = function () {2393if (this.options.onToken) this.options.onToken(new Token(this));23942395this.lastTokEnd = this.end;2396this.lastTokStart = this.start;2397this.lastTokEndLoc = this.endLoc;2398this.lastTokStartLoc = this.startLoc;2399this.nextToken();2400};24012402pp.getToken = function () {2403this.next();2404return new Token(this);2405};24062407// If we're in an ES6 environment, make parsers iterable2408if (typeof Symbol !== "undefined") pp[Symbol.iterator] = function () {2409var self = this;2410return { next: function next() {2411var token = self.getToken();2412return {2413done: token.type === tt.eof,2414value: token2415};2416} };2417};24182419// Toggle strict mode. Re-reads the next number or string to please2420// pedantic tests (`"use strict"; 010;` should fail).24212422pp.setStrict = function (strict) {2423this.strict = strict;2424if (this.type !== tt.num && this.type !== tt.string) return;2425this.pos = this.start;2426if (this.options.locations) {2427while (this.pos < this.lineStart) {2428this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1;2429--this.curLine;2430}2431}2432this.nextToken();2433};24342435pp.curContext = function () {2436return this.context[this.context.length - 1];2437};24382439// Read a single token, updating the parser object's token-related2440// properties.24412442pp.nextToken = function () {2443var curContext = this.curContext();2444if (!curContext || !curContext.preserveSpace) this.skipSpace();24452446this.start = this.pos;2447if (this.options.locations) this.startLoc = this.curPosition();2448if (this.pos >= this.input.length) return this.finishToken(tt.eof);24492450if (curContext.override) return curContext.override(this);else this.readToken(this.fullCharCodeAtPos());2451};24522453pp.readToken = function (code) {2454// Identifier or keyword. '\uXXXX' sequences are allowed in2455// identifiers, so '\' also dispatches to that.2456if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */) return this.readWord();24572458return this.getTokenFromCode(code);2459};24602461pp.fullCharCodeAtPos = function () {2462var code = this.input.charCodeAt(this.pos);2463if (code <= 55295 || code >= 57344) return code;2464var next = this.input.charCodeAt(this.pos + 1);2465return (code << 10) + next - 56613888;2466};24672468pp.skipBlockComment = function () {2469var startLoc = this.options.onComment && this.options.locations && this.curPosition();2470var start = this.pos,2471end = this.input.indexOf("*/", this.pos += 2);2472if (end === -1) this.raise(this.pos - 2, "Unterminated comment");2473this.pos = end + 2;2474if (this.options.locations) {2475lineBreakG.lastIndex = start;2476var match = undefined;2477while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {2478++this.curLine;2479this.lineStart = match.index + match[0].length;2480}2481}2482if (this.options.onComment) this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos, startLoc, this.options.locations && this.curPosition());2483};24842485pp.skipLineComment = function (startSkip) {2486var start = this.pos;2487var startLoc = this.options.onComment && this.options.locations && this.curPosition();2488var ch = this.input.charCodeAt(this.pos += startSkip);2489while (this.pos < this.input.length && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) {2490++this.pos;2491ch = this.input.charCodeAt(this.pos);2492}2493if (this.options.onComment) this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos, startLoc, this.options.locations && this.curPosition());2494};24952496// Called at the start of the parse and after every token. Skips2497// whitespace and comments, and.24982499pp.skipSpace = function () {2500while (this.pos < this.input.length) {2501var ch = this.input.charCodeAt(this.pos);2502if (ch === 32) {2503// ' '2504++this.pos;2505} else if (ch === 13) {2506++this.pos;2507var next = this.input.charCodeAt(this.pos);2508if (next === 10) {2509++this.pos;2510}2511if (this.options.locations) {2512++this.curLine;2513this.lineStart = this.pos;2514}2515} else if (ch === 10 || ch === 8232 || ch === 8233) {2516++this.pos;2517if (this.options.locations) {2518++this.curLine;2519this.lineStart = this.pos;2520}2521} else if (ch > 8 && ch < 14) {2522++this.pos;2523} else if (ch === 47) {2524// '/'2525var next = this.input.charCodeAt(this.pos + 1);2526if (next === 42) {2527// '*'2528this.skipBlockComment();2529} else if (next === 47) {2530// '/'2531this.skipLineComment(2);2532} else break;2533} else if (ch === 160) {2534// '\xa0'2535++this.pos;2536} else if (ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {2537++this.pos;2538} else {2539break;2540}2541}2542};25432544// Called at the end of every token. Sets `end`, `val`, and2545// maintains `context` and `exprAllowed`, and skips the space after2546// the token, so that the next one's `start` will point at the2547// right position.25482549pp.finishToken = function (type, val) {2550this.end = this.pos;2551if (this.options.locations) this.endLoc = this.curPosition();2552var prevType = this.type;2553this.type = type;2554this.value = val;25552556this.updateContext(prevType);2557};25582559// ### Token reading25602561// This is the function that is called to fetch the next token. It2562// is somewhat obscure, because it works in character codes rather2563// than characters, and because operator parsing has been inlined2564// into it.2565//2566// All in the name of speed.2567//2568pp.readToken_dot = function () {2569var next = this.input.charCodeAt(this.pos + 1);2570if (next >= 48 && next <= 57) return this.readNumber(true);2571var next2 = this.input.charCodeAt(this.pos + 2);2572if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) {2573// 46 = dot '.'2574this.pos += 3;2575return this.finishToken(tt.ellipsis);2576} else {2577++this.pos;2578return this.finishToken(tt.dot);2579}2580};25812582pp.readToken_slash = function () {2583// '/'2584var next = this.input.charCodeAt(this.pos + 1);2585if (this.exprAllowed) {2586++this.pos;return this.readRegexp();2587}2588if (next === 61) return this.finishOp(tt.assign, 2);2589return this.finishOp(tt.slash, 1);2590};25912592pp.readToken_mult_modulo = function (code) {2593// '%*'2594var next = this.input.charCodeAt(this.pos + 1);2595if (next === 61) return this.finishOp(tt.assign, 2);2596return this.finishOp(code === 42 ? tt.star : tt.modulo, 1);2597};25982599pp.readToken_pipe_amp = function (code) {2600// '|&'2601var next = this.input.charCodeAt(this.pos + 1);2602if (next === code) return this.finishOp(code === 124 ? tt.logicalOR : tt.logicalAND, 2);2603if (next === 61) return this.finishOp(tt.assign, 2);2604return this.finishOp(code === 124 ? tt.bitwiseOR : tt.bitwiseAND, 1);2605};26062607pp.readToken_caret = function () {2608// '^'2609var next = this.input.charCodeAt(this.pos + 1);2610if (next === 61) return this.finishOp(tt.assign, 2);2611return this.finishOp(tt.bitwiseXOR, 1);2612};26132614pp.readToken_plus_min = function (code) {2615// '+-'2616var next = this.input.charCodeAt(this.pos + 1);2617if (next === code) {2618if (next == 45 && this.input.charCodeAt(this.pos + 2) == 62 && lineBreak.test(this.input.slice(this.lastTokEnd, this.pos))) {2619// A `-->` line comment2620this.skipLineComment(3);2621this.skipSpace();2622return this.nextToken();2623}2624return this.finishOp(tt.incDec, 2);2625}2626if (next === 61) return this.finishOp(tt.assign, 2);2627return this.finishOp(tt.plusMin, 1);2628};26292630pp.readToken_lt_gt = function (code) {2631// '<>'2632var next = this.input.charCodeAt(this.pos + 1);2633var size = 1;2634if (next === code) {2635size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;2636if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1);2637return this.finishOp(tt.bitShift, size);2638}2639if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 && this.input.charCodeAt(this.pos + 3) == 45) {2640if (this.inModule) this.unexpected();2641// `<!--`, an XML-style comment that should be interpreted as a line comment2642this.skipLineComment(4);2643this.skipSpace();2644return this.nextToken();2645}2646if (next === 61) size = this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2;2647return this.finishOp(tt.relational, size);2648};26492650pp.readToken_eq_excl = function (code) {2651// '=!'2652var next = this.input.charCodeAt(this.pos + 1);2653if (next === 61) return this.finishOp(tt.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2);2654if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) {2655// '=>'2656this.pos += 2;2657return this.finishToken(tt.arrow);2658}2659return this.finishOp(code === 61 ? tt.eq : tt.prefix, 1);2660};26612662pp.getTokenFromCode = function (code) {2663switch (code) {2664// The interpretation of a dot depends on whether it is followed2665// by a digit or another two dots.2666case 46:2667// '.'2668return this.readToken_dot();26692670// Punctuation tokens.2671case 40:2672++this.pos;return this.finishToken(tt.parenL);2673case 41:2674++this.pos;return this.finishToken(tt.parenR);2675case 59:2676++this.pos;return this.finishToken(tt.semi);2677case 44:2678++this.pos;return this.finishToken(tt.comma);2679case 91:2680++this.pos;return this.finishToken(tt.bracketL);2681case 93:2682++this.pos;return this.finishToken(tt.bracketR);2683case 123:2684++this.pos;return this.finishToken(tt.braceL);2685case 125:2686++this.pos;return this.finishToken(tt.braceR);2687case 58:2688++this.pos;return this.finishToken(tt.colon);2689case 63:2690++this.pos;return this.finishToken(tt.question);26912692case 96:2693// '`'2694if (this.options.ecmaVersion < 6) break;2695++this.pos;2696return this.finishToken(tt.backQuote);26972698case 48:2699// '0'2700var next = this.input.charCodeAt(this.pos + 1);2701if (next === 120 || next === 88) return this.readRadixNumber(16); // '0x', '0X' - hex number2702if (this.options.ecmaVersion >= 6) {2703if (next === 111 || next === 79) return this.readRadixNumber(8); // '0o', '0O' - octal number2704if (next === 98 || next === 66) return this.readRadixNumber(2); // '0b', '0B' - binary number2705}2706// Anything else beginning with a digit is an integer, octal2707// number, or float.2708case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:2709// 1-92710return this.readNumber(false);27112712// Quotes produce strings.2713case 34:case 39:2714// '"', "'"2715return this.readString(code);27162717// Operators are parsed inline in tiny state machines. '=' (61) is2718// often referred to. `finishOp` simply skips the amount of2719// characters it is given as second argument, and returns a token2720// of the type given by its first argument.27212722case 47:2723// '/'2724return this.readToken_slash();27252726case 37:case 42:2727// '%*'2728return this.readToken_mult_modulo(code);27292730case 124:case 38:2731// '|&'2732return this.readToken_pipe_amp(code);27332734case 94:2735// '^'2736return this.readToken_caret();27372738case 43:case 45:2739// '+-'2740return this.readToken_plus_min(code);27412742case 60:case 62:2743// '<>'2744return this.readToken_lt_gt(code);27452746case 61:case 33:2747// '=!'2748return this.readToken_eq_excl(code);27492750case 126:2751// '~'2752return this.finishOp(tt.prefix, 1);2753}27542755this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");2756};27572758pp.finishOp = function (type, size) {2759var str = this.input.slice(this.pos, this.pos + size);2760this.pos += size;2761return this.finishToken(type, str);2762};27632764var regexpUnicodeSupport = false;2765try {2766new RegExp("", "u");regexpUnicodeSupport = true;2767} catch (e) {}27682769// Parse a regular expression. Some context-awareness is necessary,2770// since a '/' inside a '[]' set does not end the expression.27712772pp.readRegexp = function () {2773var escaped = undefined,2774inClass = undefined,2775start = this.pos;2776for (;;) {2777if (this.pos >= this.input.length) this.raise(start, "Unterminated regular expression");2778var ch = this.input.charAt(this.pos);2779if (lineBreak.test(ch)) this.raise(start, "Unterminated regular expression");2780if (!escaped) {2781if (ch === "[") inClass = true;else if (ch === "]" && inClass) inClass = false;else if (ch === "/" && !inClass) break;2782escaped = ch === "\\";2783} else escaped = false;2784++this.pos;2785}2786var content = this.input.slice(start, this.pos);2787++this.pos;2788// Need to use `readWord1` because '\uXXXX' sequences are allowed2789// here (don't ask).2790var mods = this.readWord1();2791var tmp = content;2792if (mods) {2793var validFlags = /^[gmsiy]*$/;2794if (this.options.ecmaVersion >= 6) validFlags = /^[gmsiyu]*$/;2795if (!validFlags.test(mods)) this.raise(start, "Invalid regular expression flag");2796if (mods.indexOf("u") >= 0 && !regexpUnicodeSupport) {2797// Replace each astral symbol and every Unicode escape sequence that2798// possibly represents an astral symbol or a paired surrogate with a2799// single ASCII symbol to avoid throwing on regular expressions that2800// are only valid in combination with the `/u` flag.2801// Note: replacing with the ASCII symbol `x` might cause false2802// negatives in unlikely scenarios. For example, `[\u{61}-b]` is a2803// perfectly valid pattern that is equivalent to `[a-b]`, but it would2804// be replaced by `[x-b]` which throws an error.2805tmp = tmp.replace(/\\u([a-fA-F0-9]{4})|\\u\{([0-9a-fA-F]+)\}|[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "x");2806}2807}2808// Detect invalid regular expressions.2809var value = null;2810// Rhino's regular expression parser is flaky and throws uncatchable exceptions,2811// so don't do detection if we are running under Rhino2812if (!isRhino) {2813try {2814new RegExp(tmp);2815} catch (e) {2816if (e instanceof SyntaxError) this.raise(start, "Error parsing regular expression: " + e.message);2817this.raise(e);2818}2819// Get a regular expression object for this pattern-flag pair, or `null` in2820// case the current environment doesn't support the flags it uses.2821try {2822value = new RegExp(content, mods);2823} catch (err) {}2824}2825return this.finishToken(tt.regexp, { pattern: content, flags: mods, value: value });2826};28272828// Read an integer in the given radix. Return null if zero digits2829// were read, the integer value otherwise. When `len` is given, this2830// will return `null` unless the integer has exactly `len` digits.28312832pp.readInt = function (radix, len) {2833var start = this.pos,2834total = 0;2835for (var i = 0, e = len == null ? Infinity : len; i < e; ++i) {2836var code = this.input.charCodeAt(this.pos),2837val = undefined;2838if (code >= 97) val = code - 97 + 10; // a2839else if (code >= 65) val = code - 65 + 10; // A2840else if (code >= 48 && code <= 57) val = code - 48; // 0-92841else val = Infinity;2842if (val >= radix) break;2843++this.pos;2844total = total * radix + val;2845}2846if (this.pos === start || len != null && this.pos - start !== len) return null;28472848return total;2849};28502851pp.readRadixNumber = function (radix) {2852this.pos += 2; // 0x2853var val = this.readInt(radix);2854if (val == null) this.raise(this.start + 2, "Expected number in radix " + radix);2855if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number");2856return this.finishToken(tt.num, val);2857};28582859// Read an integer, octal integer, or floating-point number.28602861pp.readNumber = function (startsWithDot) {2862var start = this.pos,2863isFloat = false,2864octal = this.input.charCodeAt(this.pos) === 48;2865if (!startsWithDot && this.readInt(10) === null) this.raise(start, "Invalid number");2866if (this.input.charCodeAt(this.pos) === 46) {2867++this.pos;2868this.readInt(10);2869isFloat = true;2870}2871var next = this.input.charCodeAt(this.pos);2872if (next === 69 || next === 101) {2873// 'eE'2874next = this.input.charCodeAt(++this.pos);2875if (next === 43 || next === 45) ++this.pos; // '+-'2876if (this.readInt(10) === null) this.raise(start, "Invalid number");2877isFloat = true;2878}2879if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number");28802881var str = this.input.slice(start, this.pos),2882val = undefined;2883if (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);2884return this.finishToken(tt.num, val);2885};28862887// Read a string value, interpreting backslash-escapes.28882889pp.readCodePoint = function () {2890var ch = this.input.charCodeAt(this.pos),2891code = undefined;28922893if (ch === 123) {2894if (this.options.ecmaVersion < 6) this.unexpected();2895++this.pos;2896code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);2897++this.pos;2898if (code > 1114111) this.unexpected();2899} else {2900code = this.readHexChar(4);2901}2902return code;2903};29042905function codePointToString(code) {2906// UTF-16 Decoding2907if (code <= 65535) {2908return String.fromCharCode(code);2909}return String.fromCharCode((code - 65536 >> 10) + 55296, (code - 65536 & 1023) + 56320);2910}29112912pp.readString = function (quote) {2913var out = "",2914chunkStart = ++this.pos;2915for (;;) {2916if (this.pos >= this.input.length) this.raise(this.start, "Unterminated string constant");2917var ch = this.input.charCodeAt(this.pos);2918if (ch === quote) break;2919if (ch === 92) {2920// '\'2921out += this.input.slice(chunkStart, this.pos);2922out += this.readEscapedChar();2923chunkStart = this.pos;2924} else {2925if (isNewLine(ch)) this.raise(this.start, "Unterminated string constant");2926++this.pos;2927}2928}2929out += this.input.slice(chunkStart, this.pos++);2930return this.finishToken(tt.string, out);2931};29322933// Reads template string tokens.29342935pp.readTmplToken = function () {2936var out = "",2937chunkStart = this.pos;2938for (;;) {2939if (this.pos >= this.input.length) this.raise(this.start, "Unterminated template");2940var ch = this.input.charCodeAt(this.pos);2941if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) {2942// '`', '${'2943if (this.pos === this.start && this.type === tt.template) {2944if (ch === 36) {2945this.pos += 2;2946return this.finishToken(tt.dollarBraceL);2947} else {2948++this.pos;2949return this.finishToken(tt.backQuote);2950}2951}2952out += this.input.slice(chunkStart, this.pos);2953return this.finishToken(tt.template, out);2954}2955if (ch === 92) {2956// '\'2957out += this.input.slice(chunkStart, this.pos);2958out += this.readEscapedChar();2959chunkStart = this.pos;2960} else if (isNewLine(ch)) {2961out += this.input.slice(chunkStart, this.pos);2962++this.pos;2963if (ch === 13 && this.input.charCodeAt(this.pos) === 10) {2964++this.pos;2965out += "\n";2966} else {2967out += String.fromCharCode(ch);2968}2969if (this.options.locations) {2970++this.curLine;2971this.lineStart = this.pos;2972}2973chunkStart = this.pos;2974} else {2975++this.pos;2976}2977}2978};29792980// Used to read escaped characters29812982pp.readEscapedChar = function () {2983var ch = this.input.charCodeAt(++this.pos);2984var octal = /^[0-7]+/.exec(this.input.slice(this.pos, this.pos + 3));2985if (octal) octal = octal[0];2986while (octal && parseInt(octal, 8) > 255) octal = octal.slice(0, -1);2987if (octal === "0") octal = null;2988++this.pos;2989if (octal) {2990if (this.strict) this.raise(this.pos - 2, "Octal literal in strict mode");2991this.pos += octal.length - 1;2992return String.fromCharCode(parseInt(octal, 8));2993} else {2994switch (ch) {2995case 110:2996return "\n"; // 'n' -> '\n'2997case 114:2998return "\r"; // 'r' -> '\r'2999case 120:3000return String.fromCharCode(this.readHexChar(2)); // 'x'3001case 117:3002return codePointToString(this.readCodePoint()); // 'u'3003case 116:3004return "\t"; // 't' -> '\t'3005case 98:3006return "\b"; // 'b' -> '\b'3007case 118:3008return "\u000b"; // 'v' -> '\u000b'3009case 102:3010return "\f"; // 'f' -> '\f'3011case 48:3012return "\u0000"; // 0 -> '\0'3013case 13:3014if (this.input.charCodeAt(this.pos) === 10) ++this.pos; // '\r\n'3015case 10:3016// ' \n'3017if (this.options.locations) {3018this.lineStart = this.pos;++this.curLine;3019}3020return "";3021default:3022return String.fromCharCode(ch);3023}3024}3025};30263027// Used to read character escape sequences ('\x', '\u', '\U').30283029pp.readHexChar = function (len) {3030var n = this.readInt(16, len);3031if (n === null) this.raise(this.start, "Bad character escape sequence");3032return n;3033};30343035// Used to signal to callers of `readWord1` whether the word3036// contained any escape sequences. This is needed because words with3037// escape sequences must not be interpreted as keywords.30383039var containsEsc;30403041// Read an identifier, and return it as a string. Sets `containsEsc`3042// to whether the word contained a '\u' escape.3043//3044// Incrementally adds only escaped chars, adding other chunks as-is3045// as a micro-optimization.30463047pp.readWord1 = function () {3048containsEsc = false;3049var word = "",3050first = true,3051chunkStart = this.pos;3052var astral = this.options.ecmaVersion >= 6;3053while (this.pos < this.input.length) {3054var ch = this.fullCharCodeAtPos();3055if (isIdentifierChar(ch, astral)) {3056this.pos += ch <= 65535 ? 1 : 2;3057} else if (ch === 92) {3058// "\"3059containsEsc = true;3060word += this.input.slice(chunkStart, this.pos);3061var escStart = this.pos;3062if (this.input.charCodeAt(++this.pos) != 117) // "u"3063this.raise(this.pos, "Expecting Unicode escape sequence \\uXXXX");3064++this.pos;3065var esc = this.readCodePoint();3066if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral)) this.raise(escStart, "Invalid Unicode escape");3067word += codePointToString(esc);3068chunkStart = this.pos;3069} else {3070break;3071}3072first = false;3073}3074return word + this.input.slice(chunkStart, this.pos);3075};30763077// Read an identifier or keyword token. Will check for reserved3078// words when necessary.30793080pp.readWord = function () {3081var word = this.readWord1();3082var type = tt.name;3083if ((this.options.ecmaVersion >= 6 || !containsEsc) && this.isKeyword(word)) type = keywordTypes[word];3084return this.finishToken(type, word);3085};30863087},{"./identifier":3,"./location":4,"./state":9,"./tokentype":13,"./whitespace":15}],13:[function(_dereq_,module,exports){3088"use strict";30893090var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };30913092exports.__esModule = true;3093// ## Token types30943095// The assignment of fine-grained, information-carrying type objects3096// allows the tokenizer to store the information it has about a3097// token in a way that is very cheap for the parser to look up.30983099// All token type variables start with an underscore, to make them3100// easy to recognize.31013102// The `beforeExpr` property is used to disambiguate between regular3103// expressions and divisions. It is set on all token types that can3104// be followed by an expression (thus, a slash after them would be a3105// regular expression).3106//3107// `isLoop` marks a keyword as starting a loop, which is important3108// to know when parsing a label, in order to allow or disallow3109// continue jumps to that label.31103111var TokenType = exports.TokenType = function TokenType(label) {3112var conf = arguments[1] === undefined ? {} : arguments[1];31133114_classCallCheck(this, TokenType);31153116this.label = label;3117this.keyword = conf.keyword;3118this.beforeExpr = !!conf.beforeExpr;3119this.startsExpr = !!conf.startsExpr;3120this.isLoop = !!conf.isLoop;3121this.isAssign = !!conf.isAssign;3122this.prefix = !!conf.prefix;3123this.postfix = !!conf.postfix;3124this.binop = conf.binop || null;3125this.updateContext = null;3126};31273128function binop(name, prec) {3129return new TokenType(name, { beforeExpr: true, binop: prec });3130}3131var beforeExpr = { beforeExpr: true },3132startsExpr = { startsExpr: true };31333134var types = {3135num: new TokenType("num", startsExpr),3136regexp: new TokenType("regexp", startsExpr),3137string: new TokenType("string", startsExpr),3138name: new TokenType("name", startsExpr),3139eof: new TokenType("eof"),31403141// Punctuation token types.3142bracketL: new TokenType("[", { beforeExpr: true, startsExpr: true }),3143bracketR: new TokenType("]"),3144braceL: new TokenType("{", { beforeExpr: true, startsExpr: true }),3145braceR: new TokenType("}"),3146parenL: new TokenType("(", { beforeExpr: true, startsExpr: true }),3147parenR: new TokenType(")"),3148comma: new TokenType(",", beforeExpr),3149semi: new TokenType(";", beforeExpr),3150colon: new TokenType(":", beforeExpr),3151dot: new TokenType("."),3152question: new TokenType("?", beforeExpr),3153arrow: new TokenType("=>", beforeExpr),3154template: new TokenType("template"),3155ellipsis: new TokenType("...", beforeExpr),3156backQuote: new TokenType("`", startsExpr),3157dollarBraceL: new TokenType("${", { beforeExpr: true, startsExpr: true }),31583159// Operators. These carry several kinds of properties to help the3160// parser use them properly (the presence of these properties is3161// what categorizes them as operators).3162//3163// `binop`, when present, specifies that this operator is a binary3164// operator, and will refer to its precedence.3165//3166// `prefix` and `postfix` mark the operator as a prefix or postfix3167// unary operator.3168//3169// `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as3170// binary operators with a very low precedence, that should result3171// in AssignmentExpression nodes.31723173eq: new TokenType("=", { beforeExpr: true, isAssign: true }),3174assign: new TokenType("_=", { beforeExpr: true, isAssign: true }),3175incDec: new TokenType("++/--", { prefix: true, postfix: true, startsExpr: true }),3176prefix: new TokenType("prefix", { beforeExpr: true, prefix: true, startsExpr: true }),3177logicalOR: binop("||", 1),3178logicalAND: binop("&&", 2),3179bitwiseOR: binop("|", 3),3180bitwiseXOR: binop("^", 4),3181bitwiseAND: binop("&", 5),3182equality: binop("==/!=", 6),3183relational: binop("</>", 7),3184bitShift: binop("<</>>", 8),3185plusMin: new TokenType("+/-", { beforeExpr: true, binop: 9, prefix: true, startsExpr: true }),3186modulo: binop("%", 10),3187star: binop("*", 10),3188slash: binop("/", 10)3189};31903191exports.types = types;3192// Map keyword names to token types.31933194var keywords = {};31953196exports.keywords = keywords;3197// Succinct definitions of keyword token types3198function kw(name) {3199var options = arguments[1] === undefined ? {} : arguments[1];32003201options.keyword = name;3202keywords[name] = types["_" + name] = new TokenType(name, options);3203}32043205kw("break");3206kw("case", beforeExpr);3207kw("catch");3208kw("continue");3209kw("debugger");3210kw("default");3211kw("do", { isLoop: true });3212kw("else", beforeExpr);3213kw("finally");3214kw("for", { isLoop: true });3215kw("function", startsExpr);3216kw("if");3217kw("return", beforeExpr);3218kw("switch");3219kw("throw", beforeExpr);3220kw("try");3221kw("var");3222kw("let");3223kw("const");3224kw("while", { isLoop: true });3225kw("with");3226kw("new", { beforeExpr: true, startsExpr: true });3227kw("this", startsExpr);3228kw("super", startsExpr);3229kw("class");3230kw("extends", beforeExpr);3231kw("export");3232kw("import");3233kw("yield", { beforeExpr: true, startsExpr: true });3234kw("null", startsExpr);3235kw("true", startsExpr);3236kw("false", startsExpr);3237kw("in", { beforeExpr: true, binop: 7 });3238kw("instanceof", { beforeExpr: true, binop: 7 });3239kw("typeof", { beforeExpr: true, prefix: true, startsExpr: true });3240kw("void", { beforeExpr: true, prefix: true, startsExpr: true });3241kw("delete", { beforeExpr: true, prefix: true, startsExpr: true });32423243},{}],14:[function(_dereq_,module,exports){3244"use strict";32453246exports.isArray = isArray;32473248// Checks if an object has a property.32493250exports.has = has;3251exports.__esModule = true;32523253function isArray(obj) {3254return Object.prototype.toString.call(obj) === "[object Array]";3255}32563257function has(obj, propName) {3258return Object.prototype.hasOwnProperty.call(obj, propName);3259}32603261},{}],15:[function(_dereq_,module,exports){3262"use strict";32633264exports.isNewLine = isNewLine;3265exports.__esModule = true;3266// Matches a whole line break (where CRLF is considered a single3267// line break). Used to count lines.32683269var lineBreak = /\r\n?|\n|\u2028|\u2029/;3270exports.lineBreak = lineBreak;3271var lineBreakG = new RegExp(lineBreak.source, "g");32723273exports.lineBreakG = lineBreakG;32743275function isNewLine(code) {3276return code === 10 || code === 13 || code === 8232 || code == 8233;3277}32783279var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/;3280exports.nonASCIIwhitespace = nonASCIIwhitespace;32813282},{}]},{},[1])(1)3283});32843285