BVB Source Codes

reactide Show acorn_loose.es.js Source code

Return Download reactide: download acorn_loose.es.js Source code - Download reactide Source code - Type:.js
  1. import acorn, { SourceLocation, tokTypes, tokenizer, Node, lineBreak, isNewLine, getLineInfo, Token, lineBreakG } from './acorn.js';
  2.  
  3. // Registered plugins
  4. var pluginsLoose = {}
  5.  
  6. var LooseParser = function LooseParser(input, options) {
  7.   if ( options === void 0 ) options = {};
  8.  
  9.   this.toks = tokenizer(input, options)
  10.   this.options = this.toks.options
  11.   this.input = this.toks.input
  12.   this.tok = this.last = {type: tokTypes.eof, start: 0, end: 0}
  13.   if (this.options.locations) {
  14.     var here = this.toks.curPosition()
  15.     this.tok.loc = new SourceLocation(this.toks, here, here)
  16.   }
  17.   this.ahead = [] // Tokens ahead
  18.   this.context = [] // Indentation contexted
  19.   this.curIndent = 0
  20.   this.curLineStart = 0
  21.   this.nextLineStart = this.lineEnd(this.curLineStart) + 1
  22.   // Load plugins
  23.   this.options.pluginsLoose = options.pluginsLoose || {}
  24.   this.loadPlugins(this.options.pluginsLoose)
  25. };
  26.  
  27. LooseParser.prototype.startNode = function startNode () {
  28.   return new Node(this.toks, this.tok.start, this.options.locations ? this.tok.loc.start : null)
  29. };
  30.  
  31. LooseParser.prototype.storeCurrentPos = function storeCurrentPos () {
  32.   return this.options.locations ? [this.tok.start, this.tok.loc.start] : this.tok.start
  33. };
  34.  
  35. LooseParser.prototype.startNodeAt = function startNodeAt (pos) {
  36.   if (this.options.locations) {
  37.     return new Node(this.toks, pos[0], pos[1])
  38.   } else {
  39.     return new Node(this.toks, pos)
  40.   }
  41. };
  42.  
  43. LooseParser.prototype.finishNode = function finishNode (node, type) {
  44.   node.type = type
  45.   node.end = this.last.end
  46.   if (this.options.locations)
  47.     node.loc.end = this.last.loc.end
  48.   if (this.options.ranges)
  49.     node.range[1] = this.last.end
  50.   return node
  51. };
  52.  
  53. LooseParser.prototype.dummyNode = function dummyNode (type) {
  54.   var dummy = this.startNode()
  55.   dummy.type = type
  56.   dummy.end = dummy.start
  57.   if (this.options.locations)
  58.     dummy.loc.end = dummy.loc.start
  59.   if (this.options.ranges)
  60.     dummy.range[1] = dummy.start
  61.   this.last = {type: tokTypes.name, start: dummy.start, end: dummy.start, loc: dummy.loc}
  62.   return dummy
  63. };
  64.  
  65. LooseParser.prototype.dummyIdent = function dummyIdent () {
  66.   var dummy = this.dummyNode("Identifier")
  67.   dummy.name = "鉁?
  68.  return dummy
  69. };
  70.  
  71. LooseParser.prototype.dummyString = function dummyString () {
  72.  var dummy = this.dummyNode("Literal")
  73.  dummy.value = dummy.raw = "?
  74.   return dummy
  75. };
  76.  
  77. LooseParser.prototype.eat = function eat (type) {
  78.   if (this.tok.type === type) {
  79.     this.next()
  80.     return true
  81.   } else {
  82.     return false
  83.   }
  84. };
  85.  
  86. LooseParser.prototype.isContextual = function isContextual (name) {
  87.   return this.tok.type === tokTypes.name && this.tok.value === name
  88. };
  89.  
  90. LooseParser.prototype.eatContextual = function eatContextual (name) {
  91.   return this.tok.value === name && this.eat(tokTypes.name)
  92. };
  93.  
  94. LooseParser.prototype.canInsertSemicolon = function canInsertSemicolon () {
  95.   return this.tok.type === tokTypes.eof || this.tok.type === tokTypes.braceR ||
  96.     lineBreak.test(this.input.slice(this.last.end, this.tok.start))
  97. };
  98.  
  99. LooseParser.prototype.semicolon = function semicolon () {
  100.   return this.eat(tokTypes.semi)
  101. };
  102.  
  103. LooseParser.prototype.expect = function expect (type) {
  104.     var this$1 = this;
  105.  
  106.   if (this.eat(type)) return true
  107.   for (var i = 1; i <= 2; i++) {
  108.     if (this$1.lookAhead(i).type == type) {
  109.       for (var j = 0; j < i; j++) this$1.next()
  110.       return true
  111.     }
  112.   }
  113. };
  114.  
  115. LooseParser.prototype.pushCx = function pushCx () {
  116.   this.context.push(this.curIndent)
  117. };
  118.  
  119. LooseParser.prototype.popCx = function popCx () {
  120.   this.curIndent = this.context.pop()
  121. };
  122.  
  123. LooseParser.prototype.lineEnd = function lineEnd (pos) {
  124.   while (pos < this.input.length && !isNewLine(this.input.charCodeAt(pos))) ++pos
  125.   return pos
  126. };
  127.  
  128. LooseParser.prototype.indentationAfter = function indentationAfter (pos) {
  129.     var this$1 = this;
  130.  
  131.   for (var count = 0;; ++pos) {
  132.     var ch = this$1.input.charCodeAt(pos)
  133.     if (ch === 32) ++count
  134.     else if (ch === 9) count += this$1.options.tabSize
  135.     else return count
  136.   }
  137. };
  138.  
  139. LooseParser.prototype.closes = function closes (closeTok, indent, line, blockHeuristic) {
  140.   if (this.tok.type === closeTok || this.tok.type === tokTypes.eof) return true
  141.   return line != this.curLineStart && this.curIndent < indent && this.tokenStartsLine() &&
  142.     (!blockHeuristic || this.nextLineStart >= this.input.length ||
  143.      this.indentationAfter(this.nextLineStart) < indent)
  144. };
  145.  
  146. LooseParser.prototype.tokenStartsLine = function tokenStartsLine () {
  147.     var this$1 = this;
  148.  
  149.   for (var p = this.tok.start - 1; p >= this.curLineStart; --p) {
  150.     var ch = this$1.input.charCodeAt(p)
  151.     if (ch !== 9 && ch !== 32) return false
  152.   }
  153.   return true
  154. };
  155.  
  156. LooseParser.prototype.extend = function extend (name, f) {
  157.   this[name] = f(this[name])
  158. };
  159.  
  160. LooseParser.prototype.loadPlugins = function loadPlugins (pluginConfigs) {
  161.     var this$1 = this;
  162.  
  163.   for (var name in pluginConfigs) {
  164.     var plugin = pluginsLoose[name]
  165.     if (!plugin) throw new Error("Plugin '" + name + "' not found")
  166.     plugin(this$1, pluginConfigs[name])
  167.   }
  168. };
  169.  
  170. var lp = LooseParser.prototype
  171.  
  172. function isSpace(ch) {
  173.   return (ch < 14 && ch > 8) || ch === 32 || ch === 160 || isNewLine(ch)
  174. }
  175.  
  176. lp.next = function() {
  177.   var this$1 = this;
  178.  
  179.   this.last = this.tok
  180.   if (this.ahead.length)
  181.     this.tok = this.ahead.shift()
  182.   else
  183.     this.tok = this.readToken()
  184.  
  185.   if (this.tok.start >= this.nextLineStart) {
  186.     while (this.tok.start >= this.nextLineStart) {
  187.       this$1.curLineStart = this$1.nextLineStart
  188.       this$1.nextLineStart = this$1.lineEnd(this$1.curLineStart) + 1
  189.     }
  190.     this.curIndent = this.indentationAfter(this.curLineStart)
  191.   }
  192. }
  193.  
  194. lp.readToken = function() {
  195.   var this$1 = this;
  196.  
  197.   for (;;) {
  198.     try {
  199.       this$1.toks.next()
  200.       if (this$1.toks.type === tokTypes.dot &&
  201.           this$1.input.substr(this$1.toks.end, 1) === "." &&
  202.           this$1.options.ecmaVersion >= 6) {
  203.         this$1.toks.end++
  204.         this$1.toks.type = tokTypes.ellipsis
  205.       }
  206.       return new Token(this$1.toks)
  207.     } catch(e) {
  208.       if (!(e instanceof SyntaxError)) throw e
  209.  
  210.       // Try to skip some text, based on the error message, and then continue
  211.       var msg = e.message, pos = e.raisedAt, replace = true
  212.       if (/unterminated/i.test(msg)) {
  213.         pos = this$1.lineEnd(e.pos + 1)
  214.         if (/string/.test(msg)) {
  215.           replace = {start: e.pos, end: pos, type: tokTypes.string, value: this$1.input.slice(e.pos + 1, pos)}
  216.         } else if (/regular expr/i.test(msg)) {
  217.           var re = this$1.input.slice(e.pos, pos)
  218.           try { re = new RegExp(re) } catch(e) {}
  219.           replace = {start: e.pos, end: pos, type: tokTypes.regexp, value: re}
  220.         } else if (/template/.test(msg)) {
  221.           replace = {start: e.pos, end: pos,
  222.                      type: tokTypes.template,
  223.                      value: this$1.input.slice(e.pos, pos)}
  224.         } else {
  225.           replace = false
  226.         }
  227.       } else if (/invalid (unicode|regexp|number)|expecting unicode|octal literal|is reserved|directly after number|expected number in radix/i.test(msg)) {
  228.         while (pos < this.input.length && !isSpace(this.input.charCodeAt(pos))) ++pos
  229.       } else if (/character escape|expected hexadecimal/i.test(msg)) {
  230.         while (pos < this.input.length) {
  231.           var ch = this$1.input.charCodeAt(pos++)
  232.           if (ch === 34 || ch === 39 || isNewLine(ch)) break
  233.         }
  234.       } else if (/unexpected character/i.test(msg)) {
  235.         pos++
  236.         replace = false
  237.       } else if (/regular expression/i.test(msg)) {
  238.         replace = true
  239.       } else {
  240.         throw e
  241.       }
  242.       this$1.resetTo(pos)
  243.       if (replace === true) replace = {start: pos, end: pos, type: tokTypes.name, value: "鉁?}
  244.      if (replace) {
  245.        if (this$1.options.locations)
  246.          replace.loc = new SourceLocation(
  247.            this$1.toks,
  248.            getLineInfo(this$1.input, replace.start),
  249.            getLineInfo(this$1.input, replace.end))
  250.        return replace
  251.      }
  252.    }
  253.  }
  254. }
  255.  
  256. lp.resetTo = function(pos) {
  257.  var this$1 = this;
  258.  
  259.  this.toks.pos = pos
  260.  var ch = this.input.charAt(pos - 1)
  261.  this.toks.exprAllowed = !ch || /[\[\{\(,;:?\/*=+\-~!|&%^<>]/.test(ch) ||
  262.    /[enwfd]/.test(ch) &&
  263.    /\b(keywords|case|else|return|throw|new|in|(instance|type)of|delete|void)$/.test(this.input.slice(pos - 10, pos))
  264.  
  265.  if (this.options.locations) {
  266.    this.toks.curLine = 1
  267.    this.toks.lineStart = lineBreakG.lastIndex = 0
  268.    var match
  269.    while ((match = lineBreakG.exec(this.input)) && match.index < pos) {
  270.      ++this$1.toks.curLine
  271.      this$1.toks.lineStart = match.index + match[0].length
  272.    }
  273.  }
  274. }
  275.  
  276. lp.lookAhead = function(n) {
  277.  var this$1 = this;
  278.  
  279.  while (n > this.ahead.length)
  280.    this$1.ahead.push(this$1.readToken())
  281.  return this.ahead[n - 1]
  282. }
  283.  
  284. function isDummy(node) { return node.name == "? }
  285.  
  286. var lp$1 = LooseParser.prototype
  287.  
  288. lp$1.parseTopLevel = function() {
  289.   var this$1 = this;
  290.  
  291.   var node = this.startNodeAt(this.options.locations ? [0, getLineInfo(this.input, 0)] : 0)
  292.   node.body = []
  293.   while (this.tok.type !== tokTypes.eof) node.body.push(this$1.parseStatement())
  294.   this.last = this.tok
  295.   if (this.options.ecmaVersion >= 6) {
  296.     node.sourceType = this.options.sourceType
  297.   }
  298.   return this.finishNode(node, "Program")
  299. }
  300.  
  301. lp$1.parseStatement = function() {
  302.   var this$1 = this;
  303.  
  304.   var starttype = this.tok.type, node = this.startNode(), kind
  305.  
  306.   if (this.toks.isLet()) {
  307.     starttype = tokTypes._var
  308.     kind = "let"
  309.   }
  310.  
  311.   switch (starttype) {
  312.   case tokTypes._break: case tokTypes._continue:
  313.     this.next()
  314.     var isBreak = starttype === tokTypes._break
  315.     if (this.semicolon() || this.canInsertSemicolon()) {
  316.       node.label = null
  317.     } else {
  318.       node.label = this.tok.type === tokTypes.name ? this.parseIdent() : null
  319.       this.semicolon()
  320.     }
  321.     return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement")
  322.  
  323.   case tokTypes._debugger:
  324.     this.next()
  325.     this.semicolon()
  326.     return this.finishNode(node, "DebuggerStatement")
  327.  
  328.   case tokTypes._do:
  329.     this.next()
  330.     node.body = this.parseStatement()
  331.     node.test = this.eat(tokTypes._while) ? this.parseParenExpression() : this.dummyIdent()
  332.     this.semicolon()
  333.     return this.finishNode(node, "DoWhileStatement")
  334.  
  335.   case tokTypes._for:
  336.     this.next()
  337.     this.pushCx()
  338.     this.expect(tokTypes.parenL)
  339.     if (this.tok.type === tokTypes.semi) return this.parseFor(node, null)
  340.     var isLet = this.toks.isLet()
  341.     if (isLet || this.tok.type === tokTypes._var || this.tok.type === tokTypes._const) {
  342.       var init$1 = this.parseVar(true, isLet ? "let" : this.tok.value)
  343.       if (init$1.declarations.length === 1 && (this.tok.type === tokTypes._in || this.isContextual("of"))) {
  344.         return this.parseForIn(node, init$1)
  345.       }
  346.       return this.parseFor(node, init$1)
  347.     }
  348.     var init = this.parseExpression(true)
  349.     if (this.tok.type === tokTypes._in || this.isContextual("of"))
  350.       return this.parseForIn(node, this.toAssignable(init))
  351.     return this.parseFor(node, init)
  352.  
  353.   case tokTypes._function:
  354.     this.next()
  355.     return this.parseFunction(node, true)
  356.  
  357.   case tokTypes._if:
  358.     this.next()
  359.     node.test = this.parseParenExpression()
  360.     node.consequent = this.parseStatement()
  361.     node.alternate = this.eat(tokTypes._else) ? this.parseStatement() : null
  362.     return this.finishNode(node, "IfStatement")
  363.  
  364.   case tokTypes._return:
  365.     this.next()
  366.     if (this.eat(tokTypes.semi) || this.canInsertSemicolon()) node.argument = null
  367.     else { node.argument = this.parseExpression(); this.semicolon() }
  368.     return this.finishNode(node, "ReturnStatement")
  369.  
  370.   case tokTypes._switch:
  371.     var blockIndent = this.curIndent, line = this.curLineStart
  372.     this.next()
  373.     node.discriminant = this.parseParenExpression()
  374.     node.cases = []
  375.     this.pushCx()
  376.     this.expect(tokTypes.braceL)
  377.  
  378.     var cur
  379.     while (!this.closes(tokTypes.braceR, blockIndent, line, true)) {
  380.       if (this$1.tok.type === tokTypes._case || this$1.tok.type === tokTypes._default) {
  381.         var isCase = this$1.tok.type === tokTypes._case
  382.         if (cur) this$1.finishNode(cur, "SwitchCase")
  383.         node.cases.push(cur = this$1.startNode())
  384.         cur.consequent = []
  385.         this$1.next()
  386.         if (isCase) cur.test = this$1.parseExpression()
  387.         else cur.test = null
  388.         this$1.expect(tokTypes.colon)
  389.       } else {
  390.         if (!cur) {
  391.           node.cases.push(cur = this$1.startNode())
  392.           cur.consequent = []
  393.           cur.test = null
  394.         }
  395.         cur.consequent.push(this$1.parseStatement())
  396.       }
  397.     }
  398.     if (cur) this.finishNode(cur, "SwitchCase")
  399.     this.popCx()
  400.     this.eat(tokTypes.braceR)
  401.     return this.finishNode(node, "SwitchStatement")
  402.  
  403.   case tokTypes._throw:
  404.     this.next()
  405.     node.argument = this.parseExpression()
  406.     this.semicolon()
  407.     return this.finishNode(node, "ThrowStatement")
  408.  
  409.   case tokTypes._try:
  410.     this.next()
  411.     node.block = this.parseBlock()
  412.     node.handler = null
  413.     if (this.tok.type === tokTypes._catch) {
  414.       var clause = this.startNode()
  415.       this.next()
  416.       this.expect(tokTypes.parenL)
  417.       clause.param = this.toAssignable(this.parseExprAtom(), true)
  418.       this.expect(tokTypes.parenR)
  419.       clause.body = this.parseBlock()
  420.       node.handler = this.finishNode(clause, "CatchClause")
  421.     }
  422.     node.finalizer = this.eat(tokTypes._finally) ? this.parseBlock() : null
  423.     if (!node.handler && !node.finalizer) return node.block
  424.     return this.finishNode(node, "TryStatement")
  425.  
  426.   case tokTypes._var:
  427.   case tokTypes._const:
  428.     return this.parseVar(false, kind || this.tok.value)
  429.  
  430.   case tokTypes._while:
  431.     this.next()
  432.     node.test = this.parseParenExpression()
  433.     node.body = this.parseStatement()
  434.     return this.finishNode(node, "WhileStatement")
  435.  
  436.   case tokTypes._with:
  437.     this.next()
  438.     node.object = this.parseParenExpression()
  439.     node.body = this.parseStatement()
  440.     return this.finishNode(node, "WithStatement")
  441.  
  442.   case tokTypes.braceL:
  443.     return this.parseBlock()
  444.  
  445.   case tokTypes.semi:
  446.     this.next()
  447.     return this.finishNode(node, "EmptyStatement")
  448.  
  449.   case tokTypes._class:
  450.     return this.parseClass(true)
  451.  
  452.   case tokTypes._import:
  453.     return this.parseImport()
  454.  
  455.   case tokTypes._export:
  456.     return this.parseExport()
  457.  
  458.   default:
  459.     var expr = this.parseExpression()
  460.     if (isDummy(expr)) {
  461.       this.next()
  462.       if (this.tok.type === tokTypes.eof) return this.finishNode(node, "EmptyStatement")
  463.       return this.parseStatement()
  464.     } else if (starttype === tokTypes.name && expr.type === "Identifier" && this.eat(tokTypes.colon)) {
  465.       node.body = this.parseStatement()
  466.       node.label = expr
  467.       return this.finishNode(node, "LabeledStatement")
  468.     } else {
  469.       node.expression = expr
  470.       this.semicolon()
  471.       return this.finishNode(node, "ExpressionStatement")
  472.     }
  473.   }
  474. }
  475.  
  476. lp$1.parseBlock = function() {
  477.   var this$1 = this;
  478.  
  479.   var node = this.startNode()
  480.   this.pushCx()
  481.   this.expect(tokTypes.braceL)
  482.   var blockIndent = this.curIndent, line = this.curLineStart
  483.   node.body = []
  484.   while (!this.closes(tokTypes.braceR, blockIndent, line, true))
  485.     node.body.push(this$1.parseStatement())
  486.   this.popCx()
  487.   this.eat(tokTypes.braceR)
  488.   return this.finishNode(node, "BlockStatement")
  489. }
  490.  
  491. lp$1.parseFor = function(node, init) {
  492.   node.init = init
  493.   node.test = node.update = null
  494.   if (this.eat(tokTypes.semi) && this.tok.type !== tokTypes.semi) node.test = this.parseExpression()
  495.   if (this.eat(tokTypes.semi) && this.tok.type !== tokTypes.parenR) node.update = this.parseExpression()
  496.   this.popCx()
  497.   this.expect(tokTypes.parenR)
  498.   node.body = this.parseStatement()
  499.   return this.finishNode(node, "ForStatement")
  500. }
  501.  
  502. lp$1.parseForIn = function(node, init) {
  503.   var type = this.tok.type === tokTypes._in ? "ForInStatement" : "ForOfStatement"
  504.   this.next()
  505.   node.left = init
  506.   node.right = this.parseExpression()
  507.   this.popCx()
  508.   this.expect(tokTypes.parenR)
  509.   node.body = this.parseStatement()
  510.   return this.finishNode(node, type)
  511. }
  512.  
  513. lp$1.parseVar = function(noIn, kind) {
  514.   var this$1 = this;
  515.  
  516.   var node = this.startNode()
  517.   node.kind = kind
  518.   this.next()
  519.   node.declarations = []
  520.   do {
  521.     var decl = this$1.startNode()
  522.     decl.id = this$1.options.ecmaVersion >= 6 ? this$1.toAssignable(this$1.parseExprAtom(), true) : this$1.parseIdent()
  523.     decl.init = this$1.eat(tokTypes.eq) ? this$1.parseMaybeAssign(noIn) : null
  524.     node.declarations.push(this$1.finishNode(decl, "VariableDeclarator"))
  525.   } while (this.eat(tokTypes.comma))
  526.   if (!node.declarations.length) {
  527.     var decl$1 = this.startNode()
  528.     decl$1.id = this.dummyIdent()
  529.     node.declarations.push(this.finishNode(decl$1, "VariableDeclarator"))
  530.   }
  531.   if (!noIn) this.semicolon()
  532.   return this.finishNode(node, "VariableDeclaration")
  533. }
  534.  
  535. lp$1.parseClass = function(isStatement) {
  536.   var this$1 = this;
  537.  
  538.   var node = this.startNode()
  539.   this.next()
  540.   if (this.tok.type === tokTypes.name) node.id = this.parseIdent()
  541.   else if (isStatement) node.id = this.dummyIdent()
  542.   else node.id = null
  543.   node.superClass = this.eat(tokTypes._extends) ? this.parseExpression() : null
  544.   node.body = this.startNode()
  545.   node.body.body = []
  546.   this.pushCx()
  547.   var indent = this.curIndent + 1, line = this.curLineStart
  548.   this.eat(tokTypes.braceL)
  549.   if (this.curIndent + 1 < indent) { indent = this.curIndent; line = this.curLineStart }
  550.   while (!this.closes(tokTypes.braceR, indent, line)) {
  551.     if (this$1.semicolon()) continue
  552.     var method = this$1.startNode(), isGenerator
  553.     if (this$1.options.ecmaVersion >= 6) {
  554.       method.static = false
  555.       isGenerator = this$1.eat(tokTypes.star)
  556.     }
  557.     this$1.parsePropertyName(method)
  558.     if (isDummy(method.key)) { if (isDummy(this$1.parseMaybeAssign())) this$1.next(); this$1.eat(tokTypes.comma); continue }
  559.     if (method.key.type === "Identifier" && !method.computed && method.key.name === "static" &&
  560.         (this$1.tok.type != tokTypes.parenL && this$1.tok.type != tokTypes.braceL)) {
  561.       method.static = true
  562.       isGenerator = this$1.eat(tokTypes.star)
  563.       this$1.parsePropertyName(method)
  564.     } else {
  565.       method.static = false
  566.     }
  567.     if (this$1.options.ecmaVersion >= 5 && method.key.type === "Identifier" &&
  568.         !method.computed && (method.key.name === "get" || method.key.name === "set") &&
  569.         this$1.tok.type !== tokTypes.parenL && this$1.tok.type !== tokTypes.braceL) {
  570.       method.kind = method.key.name
  571.       this$1.parsePropertyName(method)
  572.       method.value = this$1.parseMethod(false)
  573.     } else {
  574.       if (!method.computed && !method.static && !isGenerator && (
  575.         method.key.type === "Identifier" && method.key.name === "constructor" ||
  576.           method.key.type === "Literal" && method.key.value === "constructor")) {
  577.         method.kind = "constructor"
  578.       } else {
  579.         method.kind =  "method"
  580.       }
  581.       method.value = this$1.parseMethod(isGenerator)
  582.     }
  583.     node.body.body.push(this$1.finishNode(method, "MethodDefinition"))
  584.   }
  585.   this.popCx()
  586.   if (!this.eat(tokTypes.braceR)) {
  587.     // If there is no closing brace, make the node span to the start
  588.     // of the next token (this is useful for Tern)
  589.     this.last.end = this.tok.start
  590.     if (this.options.locations) this.last.loc.end = this.tok.loc.start
  591.   }
  592.   this.semicolon()
  593.   this.finishNode(node.body, "ClassBody")
  594.   return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression")
  595. }
  596.  
  597. lp$1.parseFunction = function(node, isStatement) {
  598.   this.initFunction(node)
  599.   if (this.options.ecmaVersion >= 6) {
  600.     node.generator = this.eat(tokTypes.star)
  601.   }
  602.   if (this.tok.type === tokTypes.name) node.id = this.parseIdent()
  603.   else if (isStatement) node.id = this.dummyIdent()
  604.   node.params = this.parseFunctionParams()
  605.   node.body = this.parseBlock()
  606.   return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression")
  607. }
  608.  
  609. lp$1.parseExport = function() {
  610.   var node = this.startNode()
  611.   this.next()
  612.   if (this.eat(tokTypes.star)) {
  613.     node.source = this.eatContextual("from") ? this.parseExprAtom() : this.dummyString()
  614.     return this.finishNode(node, "ExportAllDeclaration")
  615.   }
  616.   if (this.eat(tokTypes._default)) {
  617.     var expr = this.parseMaybeAssign()
  618.     if (expr.id) {
  619.       switch (expr.type) {
  620.       case "FunctionExpression": expr.type = "FunctionDeclaration"; break
  621.       case "ClassExpression": expr.type = "ClassDeclaration"; break
  622.       }
  623.     }
  624.     node.declaration = expr
  625.     this.semicolon()
  626.     return this.finishNode(node, "ExportDefaultDeclaration")
  627.   }
  628.   if (this.tok.type.keyword || this.toks.isLet()) {
  629.     node.declaration = this.parseStatement()
  630.     node.specifiers = []
  631.     node.source = null
  632.   } else {
  633.     node.declaration = null
  634.     node.specifiers = this.parseExportSpecifierList()
  635.     node.source = this.eatContextual("from") ? this.parseExprAtom() : null
  636.     this.semicolon()
  637.   }
  638.   return this.finishNode(node, "ExportNamedDeclaration")
  639. }
  640.  
  641. lp$1.parseImport = function() {
  642.   var node = this.startNode()
  643.   this.next()
  644.   if (this.tok.type === tokTypes.string) {
  645.     node.specifiers = []
  646.     node.source = this.parseExprAtom()
  647.     node.kind = ''
  648.   } else {
  649.     var elt
  650.     if (this.tok.type === tokTypes.name && this.tok.value !== "from") {
  651.       elt = this.startNode()
  652.       elt.local = this.parseIdent()
  653.       this.finishNode(elt, "ImportDefaultSpecifier")
  654.       this.eat(tokTypes.comma)
  655.     }
  656.     node.specifiers = this.parseImportSpecifierList()
  657.     node.source = this.eatContextual("from") && this.tok.type == tokTypes.string ? this.parseExprAtom() : this.dummyString()
  658.     if (elt) node.specifiers.unshift(elt)
  659.   }
  660.   this.semicolon()
  661.   return this.finishNode(node, "ImportDeclaration")
  662. }
  663.  
  664. lp$1.parseImportSpecifierList = function() {
  665.   var this$1 = this;
  666.  
  667.   var elts = []
  668.   if (this.tok.type === tokTypes.star) {
  669.     var elt = this.startNode()
  670.     this.next()
  671.     elt.local = this.eatContextual("as") ? this.parseIdent() : this.dummyIdent()
  672.     elts.push(this.finishNode(elt, "ImportNamespaceSpecifier"))
  673.   } else {
  674.     var indent = this.curIndent, line = this.curLineStart, continuedLine = this.nextLineStart
  675.     this.pushCx()
  676.     this.eat(tokTypes.braceL)
  677.     if (this.curLineStart > continuedLine) continuedLine = this.curLineStart
  678.     while (!this.closes(tokTypes.braceR, indent + (this.curLineStart <= continuedLine ? 1 : 0), line)) {
  679.       var elt$1 = this$1.startNode()
  680.       if (this$1.eat(tokTypes.star)) {
  681.         elt$1.local = this$1.eatContextual("as") ? this$1.parseIdent() : this$1.dummyIdent()
  682.         this$1.finishNode(elt$1, "ImportNamespaceSpecifier")
  683.       } else {
  684.         if (this$1.isContextual("from")) break
  685.         elt$1.imported = this$1.parseIdent()
  686.         if (isDummy(elt$1.imported)) break
  687.         elt$1.local = this$1.eatContextual("as") ? this$1.parseIdent() : elt$1.imported
  688.         this$1.finishNode(elt$1, "ImportSpecifier")
  689.       }
  690.       elts.push(elt$1)
  691.       this$1.eat(tokTypes.comma)
  692.     }
  693.     this.eat(tokTypes.braceR)
  694.     this.popCx()
  695.   }
  696.   return elts
  697. }
  698.  
  699. lp$1.parseExportSpecifierList = function() {
  700.   var this$1 = this;
  701.  
  702.   var elts = []
  703.   var indent = this.curIndent, line = this.curLineStart, continuedLine = this.nextLineStart
  704.   this.pushCx()
  705.   this.eat(tokTypes.braceL)
  706.   if (this.curLineStart > continuedLine) continuedLine = this.curLineStart
  707.   while (!this.closes(tokTypes.braceR, indent + (this.curLineStart <= continuedLine ? 1 : 0), line)) {
  708.     if (this$1.isContextual("from")) break
  709.     var elt = this$1.startNode()
  710.     elt.local = this$1.parseIdent()
  711.     if (isDummy(elt.local)) break
  712.     elt.exported = this$1.eatContextual("as") ? this$1.parseIdent() : elt.local
  713.     this$1.finishNode(elt, "ExportSpecifier")
  714.     elts.push(elt)
  715.     this$1.eat(tokTypes.comma)
  716.   }
  717.   this.eat(tokTypes.braceR)
  718.   this.popCx()
  719.   return elts
  720. }
  721.  
  722. var lp$2 = LooseParser.prototype
  723.  
  724. lp$2.checkLVal = function(expr) {
  725.   if (!expr) return expr
  726.   switch (expr.type) {
  727.   case "Identifier":
  728.   case "MemberExpression":
  729.     return expr
  730.  
  731.   case "ParenthesizedExpression":
  732.     expr.expression = this.checkLVal(expr.expression)
  733.     return expr
  734.  
  735.   default:
  736.     return this.dummyIdent()
  737.   }
  738. }
  739.  
  740. lp$2.parseExpression = function(noIn) {
  741.   var this$1 = this;
  742.  
  743.   var start = this.storeCurrentPos()
  744.   var expr = this.parseMaybeAssign(noIn)
  745.   if (this.tok.type === tokTypes.comma) {
  746.     var node = this.startNodeAt(start)
  747.     node.expressions = [expr]
  748.     while (this.eat(tokTypes.comma)) node.expressions.push(this$1.parseMaybeAssign(noIn))
  749.     return this.finishNode(node, "SequenceExpression")
  750.   }
  751.   return expr
  752. }
  753.  
  754. lp$2.parseParenExpression = function() {
  755.   this.pushCx()
  756.   this.expect(tokTypes.parenL)
  757.   var val = this.parseExpression()
  758.   this.popCx()
  759.   this.expect(tokTypes.parenR)
  760.   return val
  761. }
  762.  
  763. lp$2.parseMaybeAssign = function(noIn) {
  764.   if (this.toks.isContextual("yield")) {
  765.     var node = this.startNode()
  766.     this.next()
  767.     if (this.semicolon() || this.canInsertSemicolon() || (this.tok.type != tokTypes.star && !this.tok.type.startsExpr)) {
  768.       node.delegate = false
  769.       node.argument = null
  770.     } else {
  771.       node.delegate = this.eat(tokTypes.star)
  772.       node.argument = this.parseMaybeAssign()
  773.     }
  774.     return this.finishNode(node, "YieldExpression")
  775.   }
  776.  
  777.   var start = this.storeCurrentPos()
  778.   var left = this.parseMaybeConditional(noIn)
  779.   if (this.tok.type.isAssign) {
  780.     var node$1 = this.startNodeAt(start)
  781.     node$1.operator = this.tok.value
  782.     node$1.left = this.tok.type === tokTypes.eq ? this.toAssignable(left) : this.checkLVal(left)
  783.     this.next()
  784.     node$1.right = this.parseMaybeAssign(noIn)
  785.     return this.finishNode(node$1, "AssignmentExpression")
  786.   }
  787.   return left
  788. }
  789.  
  790. lp$2.parseMaybeConditional = function(noIn) {
  791.   var start = this.storeCurrentPos()
  792.   var expr = this.parseExprOps(noIn)
  793.   if (this.eat(tokTypes.question)) {
  794.     var node = this.startNodeAt(start)
  795.     node.test = expr
  796.     node.consequent = this.parseMaybeAssign()
  797.     node.alternate = this.expect(tokTypes.colon) ? this.parseMaybeAssign(noIn) : this.dummyIdent()
  798.     return this.finishNode(node, "ConditionalExpression")
  799.   }
  800.   return expr
  801. }
  802.  
  803. lp$2.parseExprOps = function(noIn) {
  804.   var start = this.storeCurrentPos()
  805.   var indent = this.curIndent, line = this.curLineStart
  806.   return this.parseExprOp(this.parseMaybeUnary(false), start, -1, noIn, indent, line)
  807. }
  808.  
  809. lp$2.parseExprOp = function(left, start, minPrec, noIn, indent, line) {
  810.   if (this.curLineStart != line && this.curIndent < indent && this.tokenStartsLine()) return left
  811.   var prec = this.tok.type.binop
  812.   if (prec != null && (!noIn || this.tok.type !== tokTypes._in)) {
  813.     if (prec > minPrec) {
  814.       var node = this.startNodeAt(start)
  815.       node.left = left
  816.       node.operator = this.tok.value
  817.       this.next()
  818.       if (this.curLineStart != line && this.curIndent < indent && this.tokenStartsLine()) {
  819.         node.right = this.dummyIdent()
  820.       } else {
  821.         var rightStart = this.storeCurrentPos()
  822.         node.right = this.parseExprOp(this.parseMaybeUnary(false), rightStart, prec, noIn, indent, line)
  823.       }
  824.       this.finishNode(node, /&&|\|\|/.test(node.operator) ? "LogicalExpression" : "BinaryExpression")
  825.       return this.parseExprOp(node, start, minPrec, noIn, indent, line)
  826.     }
  827.   }
  828.   return left
  829. }
  830.  
  831. lp$2.parseMaybeUnary = function(sawUnary) {
  832.   var this$1 = this;
  833.  
  834.   var start = this.storeCurrentPos(), expr
  835.   if (this.tok.type.prefix) {
  836.     var node = this.startNode(), update = this.tok.type === tokTypes.incDec
  837.     if (!update) sawUnary = true
  838.     node.operator = this.tok.value
  839.     node.prefix = true
  840.     this.next()
  841.     node.argument = this.parseMaybeUnary(true)
  842.     if (update) node.argument = this.checkLVal(node.argument)
  843.     expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression")
  844.   } else if (this.tok.type === tokTypes.ellipsis) {
  845.     var node$1 = this.startNode()
  846.     this.next()
  847.     node$1.argument = this.parseMaybeUnary(sawUnary)
  848.     expr = this.finishNode(node$1, "SpreadElement")
  849.   } else {
  850.     expr = this.parseExprSubscripts()
  851.     while (this.tok.type.postfix && !this.canInsertSemicolon()) {
  852.       var node$2 = this$1.startNodeAt(start)
  853.       node$2.operator = this$1.tok.value
  854.       node$2.prefix = false
  855.       node$2.argument = this$1.checkLVal(expr)
  856.       this$1.next()
  857.       expr = this$1.finishNode(node$2, "UpdateExpression")
  858.     }
  859.   }
  860.  
  861.   if (!sawUnary && this.eat(tokTypes.starstar)) {
  862.     var node$3 = this.startNodeAt(start)
  863.     node$3.operator = "**"
  864.     node$3.left = expr
  865.     node$3.right = this.parseMaybeUnary(false)
  866.     return this.finishNode(node$3, "BinaryExpression")
  867.   }
  868.  
  869.   return expr
  870. }
  871.  
  872. lp$2.parseExprSubscripts = function() {
  873.   var start = this.storeCurrentPos()
  874.   return this.parseSubscripts(this.parseExprAtom(), start, false, this.curIndent, this.curLineStart)
  875. }
  876.  
  877. lp$2.parseSubscripts = function(base, start, noCalls, startIndent, line) {
  878.   var this$1 = this;
  879.  
  880.   for (;;) {
  881.     if (this$1.curLineStart != line && this$1.curIndent <= startIndent && this$1.tokenStartsLine()) {
  882.       if (this$1.tok.type == tokTypes.dot && this$1.curIndent == startIndent)
  883.         --startIndent
  884.       else
  885.         return base
  886.     }
  887.  
  888.     if (this$1.eat(tokTypes.dot)) {
  889.       var node = this$1.startNodeAt(start)
  890.       node.object = base
  891.       if (this$1.curLineStart != line && this$1.curIndent <= startIndent && this$1.tokenStartsLine())
  892.         node.property = this$1.dummyIdent()
  893.       else
  894.         node.property = this$1.parsePropertyAccessor() || this$1.dummyIdent()
  895.       node.computed = false
  896.       base = this$1.finishNode(node, "MemberExpression")
  897.     } else if (this$1.tok.type == tokTypes.bracketL) {
  898.       this$1.pushCx()
  899.       this$1.next()
  900.       var node$1 = this$1.startNodeAt(start)
  901.       node$1.object = base
  902.       node$1.property = this$1.parseExpression()
  903.       node$1.computed = true
  904.       this$1.popCx()
  905.       this$1.expect(tokTypes.bracketR)
  906.       base = this$1.finishNode(node$1, "MemberExpression")
  907.     } else if (!noCalls && this$1.tok.type == tokTypes.parenL) {
  908.       var node$2 = this$1.startNodeAt(start)
  909.       node$2.callee = base
  910.       node$2.arguments = this$1.parseExprList(tokTypes.parenR)
  911.       base = this$1.finishNode(node$2, "CallExpression")
  912.     } else if (this$1.tok.type == tokTypes.backQuote) {
  913.       var node$3 = this$1.startNodeAt(start)
  914.       node$3.tag = base
  915.       node$3.quasi = this$1.parseTemplate()
  916.       base = this$1.finishNode(node$3, "TaggedTemplateExpression")
  917.     } else {
  918.       return base
  919.     }
  920.   }
  921. }
  922.  
  923. lp$2.parseExprAtom = function() {
  924.   var node
  925.   switch (this.tok.type) {
  926.   case tokTypes._this:
  927.   case tokTypes._super:
  928.     var type = this.tok.type === tokTypes._this ? "ThisExpression" : "Super"
  929.     node = this.startNode()
  930.     this.next()
  931.     return this.finishNode(node, type)
  932.  
  933.   case tokTypes.name:
  934.     var start = this.storeCurrentPos()
  935.     var id = this.parseIdent()
  936.     return this.eat(tokTypes.arrow) ? this.parseArrowExpression(this.startNodeAt(start), [id]) : id
  937.  
  938.   case tokTypes.regexp:
  939.     node = this.startNode()
  940.     var val = this.tok.value
  941.     node.regex = {pattern: val.pattern, flags: val.flags}
  942.     node.value = val.value
  943.     node.raw = this.input.slice(this.tok.start, this.tok.end)
  944.     this.next()
  945.     return this.finishNode(node, "Literal")
  946.  
  947.   case tokTypes.num: case tokTypes.string:
  948.     node = this.startNode()
  949.     node.value = this.tok.value
  950.     node.raw = this.input.slice(this.tok.start, this.tok.end)
  951.     this.next()
  952.     return this.finishNode(node, "Literal")
  953.  
  954.   case tokTypes._null: case tokTypes._true: case tokTypes._false:
  955.     node = this.startNode()
  956.     node.value = this.tok.type === tokTypes._null ? null : this.tok.type === tokTypes._true
  957.     node.raw = this.tok.type.keyword
  958.     this.next()
  959.     return this.finishNode(node, "Literal")
  960.  
  961.   case tokTypes.parenL:
  962.     var parenStart = this.storeCurrentPos()
  963.     this.next()
  964.     var inner = this.parseExpression()
  965.     this.expect(tokTypes.parenR)
  966.     if (this.eat(tokTypes.arrow)) {
  967.       return this.parseArrowExpression(this.startNodeAt(parenStart), inner.expressions || (isDummy(inner) ? [] : [inner]))
  968.     }
  969.     if (this.options.preserveParens) {
  970.       var par = this.startNodeAt(parenStart)
  971.       par.expression = inner
  972.       inner = this.finishNode(par, "ParenthesizedExpression")
  973.     }
  974.     return inner
  975.  
  976.   case tokTypes.bracketL:
  977.     node = this.startNode()
  978.     node.elements = this.parseExprList(tokTypes.bracketR, true)
  979.     return this.finishNode(node, "ArrayExpression")
  980.  
  981.   case tokTypes.braceL:
  982.     return this.parseObj()
  983.  
  984.   case tokTypes._class:
  985.     return this.parseClass()
  986.  
  987.   case tokTypes._function:
  988.     node = this.startNode()
  989.     this.next()
  990.     return this.parseFunction(node, false)
  991.  
  992.   case tokTypes._new:
  993.     return this.parseNew()
  994.  
  995.   case tokTypes.backQuote:
  996.     return this.parseTemplate()
  997.  
  998.   default:
  999.     return this.dummyIdent()
  1000.   }
  1001. }
  1002.  
  1003. lp$2.parseNew = function() {
  1004.   var node = this.startNode(), startIndent = this.curIndent, line = this.curLineStart
  1005.   var meta = this.parseIdent(true)
  1006.   if (this.options.ecmaVersion >= 6 && this.eat(tokTypes.dot)) {
  1007.     node.meta = meta
  1008.     node.property = this.parseIdent(true)
  1009.     return this.finishNode(node, "MetaProperty")
  1010.   }
  1011.   var start = this.storeCurrentPos()
  1012.   node.callee = this.parseSubscripts(this.parseExprAtom(), start, true, startIndent, line)
  1013.   if (this.tok.type == tokTypes.parenL) {
  1014.     node.arguments = this.parseExprList(tokTypes.parenR)
  1015.   } else {
  1016.     node.arguments = []
  1017.   }
  1018.   return this.finishNode(node, "NewExpression")
  1019. }
  1020.  
  1021. lp$2.parseTemplateElement = function() {
  1022.   var elem = this.startNode()
  1023.   elem.value = {
  1024.     raw: this.input.slice(this.tok.start, this.tok.end).replace(/\r\n?/g, '\n'),
  1025.     cooked: this.tok.value
  1026.   }
  1027.   this.next()
  1028.   elem.tail = this.tok.type === tokTypes.backQuote
  1029.   return this.finishNode(elem, "TemplateElement")
  1030. }
  1031.  
  1032. lp$2.parseTemplate = function() {
  1033.   var this$1 = this;
  1034.  
  1035.   var node = this.startNode()
  1036.   this.next()
  1037.   node.expressions = []
  1038.   var curElt = this.parseTemplateElement()
  1039.   node.quasis = [curElt]
  1040.   while (!curElt.tail) {
  1041.     this$1.next()
  1042.     node.expressions.push(this$1.parseExpression())
  1043.     if (this$1.expect(tokTypes.braceR)) {
  1044.       curElt = this$1.parseTemplateElement()
  1045.     } else {
  1046.       curElt = this$1.startNode()
  1047.       curElt.value = {cooked: '', raw: ''}
  1048.       curElt.tail = true
  1049.       this$1.finishNode(curElt, "TemplateElement")
  1050.     }
  1051.     node.quasis.push(curElt)
  1052.   }
  1053.   this.expect(tokTypes.backQuote)
  1054.   return this.finishNode(node, "TemplateLiteral")
  1055. }
  1056.  
  1057. lp$2.parseObj = function() {
  1058.   var this$1 = this;
  1059.  
  1060.   var node = this.startNode()
  1061.   node.properties = []
  1062.   this.pushCx()
  1063.   var indent = this.curIndent + 1, line = this.curLineStart
  1064.   this.eat(tokTypes.braceL)
  1065.   if (this.curIndent + 1 < indent) { indent = this.curIndent; line = this.curLineStart }
  1066.   while (!this.closes(tokTypes.braceR, indent, line)) {
  1067.     var prop = this$1.startNode(), isGenerator, start
  1068.     if (this$1.options.ecmaVersion >= 6) {
  1069.       start = this$1.storeCurrentPos()
  1070.       prop.method = false
  1071.       prop.shorthand = false
  1072.       isGenerator = this$1.eat(tokTypes.star)
  1073.     }
  1074.     this$1.parsePropertyName(prop)
  1075.     if (isDummy(prop.key)) { if (isDummy(this$1.parseMaybeAssign())) this$1.next(); this$1.eat(tokTypes.comma); continue }
  1076.     if (this$1.eat(tokTypes.colon)) {
  1077.       prop.kind = "init"
  1078.       prop.value = this$1.parseMaybeAssign()
  1079.     } else if (this$1.options.ecmaVersion >= 6 && (this$1.tok.type === tokTypes.parenL || this$1.tok.type === tokTypes.braceL)) {
  1080.       prop.kind = "init"
  1081.       prop.method = true
  1082.       prop.value = this$1.parseMethod(isGenerator)
  1083.     } else if (this$1.options.ecmaVersion >= 5 && prop.key.type === "Identifier" &&
  1084.                !prop.computed && (prop.key.name === "get" || prop.key.name === "set") &&
  1085.                (this$1.tok.type != tokTypes.comma && this$1.tok.type != tokTypes.braceR)) {
  1086.       prop.kind = prop.key.name
  1087.       this$1.parsePropertyName(prop)
  1088.       prop.value = this$1.parseMethod(false)
  1089.     } else {
  1090.       prop.kind = "init"
  1091.       if (this$1.options.ecmaVersion >= 6) {
  1092.         if (this$1.eat(tokTypes.eq)) {
  1093.           var assign = this$1.startNodeAt(start)
  1094.           assign.operator = "="
  1095.           assign.left = prop.key
  1096.           assign.right = this$1.parseMaybeAssign()
  1097.           prop.value = this$1.finishNode(assign, "AssignmentExpression")
  1098.         } else {
  1099.           prop.value = prop.key
  1100.         }
  1101.       } else {
  1102.         prop.value = this$1.dummyIdent()
  1103.       }
  1104.       prop.shorthand = true
  1105.     }
  1106.     node.properties.push(this$1.finishNode(prop, "Property"))
  1107.     this$1.eat(tokTypes.comma)
  1108.   }
  1109.   this.popCx()
  1110.   if (!this.eat(tokTypes.braceR)) {
  1111.     // If there is no closing brace, make the node span to the start
  1112.     // of the next token (this is useful for Tern)
  1113.     this.last.end = this.tok.start
  1114.     if (this.options.locations) this.last.loc.end = this.tok.loc.start
  1115.   }
  1116.   return this.finishNode(node, "ObjectExpression")
  1117. }
  1118.  
  1119. lp$2.parsePropertyName = function(prop) {
  1120.   if (this.options.ecmaVersion >= 6) {
  1121.     if (this.eat(tokTypes.bracketL)) {
  1122.       prop.computed = true
  1123.       prop.key = this.parseExpression()
  1124.       this.expect(tokTypes.bracketR)
  1125.       return
  1126.     } else {
  1127.       prop.computed = false
  1128.     }
  1129.   }
  1130.   var key = (this.tok.type === tokTypes.num || this.tok.type === tokTypes.string) ? this.parseExprAtom() : this.parseIdent()
  1131.   prop.key = key || this.dummyIdent()
  1132. }
  1133.  
  1134. lp$2.parsePropertyAccessor = function() {
  1135.   if (this.tok.type === tokTypes.name || this.tok.type.keyword) return this.parseIdent()
  1136. }
  1137.  
  1138. lp$2.parseIdent = function() {
  1139.   var name = this.tok.type === tokTypes.name ? this.tok.value : this.tok.type.keyword
  1140.   if (!name) return this.dummyIdent()
  1141.   var node = this.startNode()
  1142.   this.next()
  1143.   node.name = name
  1144.   return this.finishNode(node, "Identifier")
  1145. }
  1146.  
  1147. lp$2.initFunction = function(node) {
  1148.   node.id = null
  1149.   node.params = []
  1150.   if (this.options.ecmaVersion >= 6) {
  1151.     node.generator = false
  1152.     node.expression = false
  1153.   }
  1154. }
  1155.  
  1156. // Convert existing expression atom to assignable pattern
  1157. // if possible.
  1158.  
  1159. lp$2.toAssignable = function(node, binding) {
  1160.   var this$1 = this;
  1161.  
  1162.   if (!node || node.type == "Identifier" || (node.type == "MemberExpression" && !binding)) {
  1163.     // Okay
  1164.   } else if (node.type == "ParenthesizedExpression") {
  1165.     node.expression = this.toAssignable(node.expression, binding)
  1166.   } else if (this.options.ecmaVersion < 6) {
  1167.     return this.dummyIdent()
  1168.   } else if (node.type == "ObjectExpression") {
  1169.     node.type = "ObjectPattern"
  1170.     var props = node.properties
  1171.     for (var i = 0; i < props.length; i++)
  1172.       props[i].value = this$1.toAssignable(props[i].value, binding)
  1173.   } else if (node.type == "ArrayExpression") {
  1174.     node.type = "ArrayPattern"
  1175.     this.toAssignableList(node.elements, binding)
  1176.   } else if (node.type == "SpreadElement") {
  1177.     node.type = "RestElement"
  1178.     node.argument = this.toAssignable(node.argument, binding)
  1179.   } else if (node.type == "AssignmentExpression") {
  1180.     node.type = "AssignmentPattern"
  1181.     delete node.operator
  1182.   } else {
  1183.     return this.dummyIdent()
  1184.   }
  1185.   return node
  1186. }
  1187.  
  1188. lp$2.toAssignableList = function(exprList, binding) {
  1189.   var this$1 = this;
  1190.  
  1191.   for (var i = 0; i < exprList.length; i++)
  1192.     exprList[i] = this$1.toAssignable(exprList[i], binding)
  1193.   return exprList
  1194. }
  1195.  
  1196. lp$2.parseFunctionParams = function(params) {
  1197.   params = this.parseExprList(tokTypes.parenR)
  1198.   return this.toAssignableList(params, true)
  1199. }
  1200.  
  1201. lp$2.parseMethod = function(isGenerator) {
  1202.   var node = this.startNode()
  1203.   this.initFunction(node)
  1204.   node.params = this.parseFunctionParams()
  1205.   node.generator = isGenerator || false
  1206.   node.expression = this.options.ecmaVersion >= 6 && this.tok.type !== tokTypes.braceL
  1207.   node.body = node.expression ? this.parseMaybeAssign() : this.parseBlock()
  1208.   return this.finishNode(node, "FunctionExpression")
  1209. }
  1210.  
  1211. lp$2.parseArrowExpression = function(node, params) {
  1212.   this.initFunction(node)
  1213.   node.params = this.toAssignableList(params, true)
  1214.   node.expression = this.tok.type !== tokTypes.braceL
  1215.   node.body = node.expression ? this.parseMaybeAssign() : this.parseBlock()
  1216.   return this.finishNode(node, "ArrowFunctionExpression")
  1217. }
  1218.  
  1219. lp$2.parseExprList = function(close, allowEmpty) {
  1220.   var this$1 = this;
  1221.  
  1222.   this.pushCx()
  1223.   var indent = this.curIndent, line = this.curLineStart, elts = []
  1224.   this.next() // Opening bracket
  1225.   while (!this.closes(close, indent + 1, line)) {
  1226.     if (this$1.eat(tokTypes.comma)) {
  1227.       elts.push(allowEmpty ? null : this$1.dummyIdent())
  1228.       continue
  1229.     }
  1230.     var elt = this$1.parseMaybeAssign()
  1231.     if (isDummy(elt)) {
  1232.       if (this$1.closes(close, indent, line)) break
  1233.       this$1.next()
  1234.     } else {
  1235.       elts.push(elt)
  1236.     }
  1237.     this$1.eat(tokTypes.comma)
  1238.   }
  1239.   this.popCx()
  1240.   if (!this.eat(close)) {
  1241.     // If there is no closing brace, make the node span to the start
  1242.     // of the next token (this is useful for Tern)
  1243.     this.last.end = this.tok.start
  1244.     if (this.options.locations) this.last.loc.end = this.tok.loc.start
  1245.   }
  1246.   return elts
  1247. }
  1248.  
  1249. acorn.defaultOptions.tabSize = 4
  1250.  
  1251. function parse_dammit(input, options) {
  1252.   var p = new LooseParser(input, options)
  1253.   p.next()
  1254.   return p.parseTopLevel()
  1255. }
  1256.  
  1257. acorn.parse_dammit = parse_dammit
  1258. acorn.LooseParser = LooseParser
  1259. acorn.pluginsLoose = pluginsLoose
  1260.  
  1261. export { parse_dammit, LooseParser, pluginsLoose };
downloadacorn_loose.es.js Source code - Download reactide Source code
Related Source Codes/Software:
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
postal - 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top