BVB Source Codes

reactide Show acorn_loose.js Source code

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