How to use the acorn.tokTypes.braceL function in acorn

To help you get started, we’ve selected a few acorn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github acornjs / acorn / acorn-loose / src / statement.js View on Github external
lp.parseExportSpecifierList = function() {
  let elts = []
  let indent = this.curIndent, line = this.curLineStart, continuedLine = this.nextLineStart
  this.pushCx()
  this.eat(tt.braceL)
  if (this.curLineStart > continuedLine) continuedLine = this.curLineStart
  while (!this.closes(tt.braceR, indent + (this.curLineStart <= continuedLine ? 1 : 0), line)) {
    if (this.isContextual("from")) break
    let elt = this.startNode()
    elt.local = this.parseIdent()
    if (isDummy(elt.local)) break
    elt.exported = this.eatContextual("as") ? this.parseIdent() : elt.local
    this.finishNode(elt, "ExportSpecifier")
    elts.push(elt)
    this.eat(tt.comma)
  }
  this.eat(tt.braceR)
  this.popCx()
  return elts
}
github acornjs / acorn / acorn-loose / src / expression.js View on Github external
lp.parseArrowExpression = function(node, params, isAsync) {
  let oldInAsync = this.inAsync, oldInFunction = this.inFunction
  this.initFunction(node)
  if (this.options.ecmaVersion >= 8)
    node.async = !!isAsync
  this.inAsync = node.async
  this.inFunction = true
  node.params = this.toAssignableList(params, true)
  node.expression = this.tok.type !== tt.braceL
  if (node.expression) {
    node.body = this.parseMaybeAssign()
  } else {
    node.body = this.parseBlock()
    this.toks.adaptDirectivePrologue(node.body.body)
  }
  this.inAsync = oldInAsync
  this.inFunction = oldInFunction
  return this.finishNode(node, "ArrowFunctionExpression")
}
github acornjs / acorn / acorn-loose / src / statement.js View on Github external
lp.parseClass = function(isStatement) {
  let node = this.startNode()
  this.next()
  if (this.tok.type === tt.name) node.id = this.parseIdent()
  else if (isStatement === true) node.id = this.dummyIdent()
  else node.id = null
  node.superClass = this.eat(tt._extends) ? this.parseExpression() : null
  node.body = this.startNode()
  node.body.body = []
  this.pushCx()
  let indent = this.curIndent + 1, line = this.curLineStart
  this.eat(tt.braceL)
  if (this.curIndent + 1 < indent) { indent = this.curIndent; line = this.curLineStart }
  while (!this.closes(tt.braceR, indent, line)) {
    if (this.semicolon()) continue
    let method = this.startNode(), isGenerator, isAsync
    if (this.options.ecmaVersion >= 6) {
      method.static = false
      isGenerator = this.eat(tt.star)
    }
    this.parsePropertyName(method)
    if (isDummy(method.key)) { if (isDummy(this.parseMaybeAssign())) this.next(); this.eat(tt.comma); continue }
    if (method.key.type === "Identifier" && !method.computed && method.key.name === "static" &&
        (this.tok.type !== tt.parenL && this.tok.type !== tt.braceL)) {
      method.static = true
      isGenerator = this.eat(tt.star)
      this.parsePropertyName(method)
    } else {
github observablehq / parser / src / parse.js View on Github external
parseImportSpecifiers() {
    const nodes = [];
    let first = true;
    this.expect(tt.braceL);
    while (!this.eat(tt.braceR)) {
      if (first) {
        first = false;
      } else {
        this.expect(tt.comma);
        if (this.afterTrailingComma(tt.braceR)) break;
      }
      const node = this.startNode();
      node.view = this.eatContextual("viewof");
      if (!node.view) node.mutable = this.eatContextual("mutable");
      node.imported = this.parseIdent();
      if (this.eatContextual("as")) {
        node.local = this.parseIdent();
      } else {
        this.checkUnreserved(node.imported);
        node.local = node.imported;
github wrleskovec / react-week-scheduler / node_modules / acorn / src / loose / expression.js View on Github external
if (this.eat(tt.arrow)) {
      return this.parseArrowExpression(this.startNodeAt(parenStart), inner.expressions || (isDummy(inner) ? [] : [inner]))
    }
    if (this.options.preserveParens) {
      let par = this.startNodeAt(parenStart)
      par.expression = inner
      inner = this.finishNode(par, "ParenthesizedExpression")
    }
    return inner

  case tt.bracketL:
    node = this.startNode()
    node.elements = this.parseExprList(tt.bracketR, true)
    return this.finishNode(node, "ArrayExpression")

  case tt.braceL:
    return this.parseObj()

  case tt._class:
    return this.parseClass()

  case tt._function:
    node = this.startNode()
    this.next()
    return this.parseFunction(node, false)

  case tt._new:
    return this.parseNew()

  case tt.backQuote:
    return this.parseTemplate()
github wrleskovec / react-week-scheduler / node_modules / acorn / src / loose / statement.js View on Github external
lp.parseClass = function(isStatement) {
  let node = this.startNode()
  this.next()
  if (this.tok.type === tt.name) node.id = this.parseIdent()
  else if (isStatement) node.id = this.dummyIdent()
  else node.id = null
  node.superClass = this.eat(tt._extends) ? this.parseExpression() : null
  node.body = this.startNode()
  node.body.body = []
  this.pushCx()
  let indent = this.curIndent + 1, line = this.curLineStart
  this.eat(tt.braceL)
  if (this.curIndent + 1 < indent) { indent = this.curIndent; line = this.curLineStart }
  while (!this.closes(tt.braceR, indent, line)) {
    if (this.semicolon()) continue
    let method = this.startNode(), isGenerator
    if (this.options.ecmaVersion >= 6) {
      method.static = false
      isGenerator = this.eat(tt.star)
    }
    this.parsePropertyName(method)
    if (isDummy(method.key)) { if (isDummy(this.parseMaybeAssign())) this.next(); this.eat(tt.comma); continue }
    if (method.key.type === "Identifier" && !method.computed && method.key.name === "static" &&
        (this.tok.type != tt.parenL && this.tok.type != tt.braceL)) {
      method.static = true
      isGenerator = this.eat(tt.star)
      this.parsePropertyName(method)
    } else {