How to use the acorn.tokTypes.parenR 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 / expression.js View on Github external
if (this.tok.type === tt.num && node.raw.charCodeAt(node.raw.length - 1) === 110) node.bigint = node.raw.slice(0, -1)
    this.next()
    return this.finishNode(node, "Literal")

  case tt._null: case tt._true: case tt._false:
    node = this.startNode()
    node.value = this.tok.type === tt._null ? null : this.tok.type === tt._true
    node.raw = this.tok.type.keyword
    this.next()
    return this.finishNode(node, "Literal")

  case tt.parenL:
    let parenStart = this.storeCurrentPos()
    this.next()
    let inner = this.parseExpression()
    this.expect(tt.parenR)
    if (this.eat(tt.arrow)) {
      // (a,)=>a // SequenceExpression makes dummy in the last hole. Drop the dummy.
      let params = inner.expressions || [inner]
      if (params.length && isDummy(params[params.length - 1]))
        params.pop()
      return this.parseArrowExpression(this.startNodeAt(parenStart), params)
    }
    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()
github wrleskovec / react-week-scheduler / node_modules / acorn / src / loose / statement.js View on Github external
lp.parseFor = function(node, init) {
  node.init = init
  node.test = node.update = null
  if (this.eat(tt.semi) && this.tok.type !== tt.semi) node.test = this.parseExpression()
  if (this.eat(tt.semi) && this.tok.type !== tt.parenR) node.update = this.parseExpression()
  this.popCx()
  this.expect(tt.parenR)
  node.body = this.parseStatement()
  return this.finishNode(node, "ForStatement")
}
github acornjs / acorn / acorn-loose / src / statement.js View on Github external
lp.parseForIn = function(node, init) {
  let type = this.tok.type === tt._in ? "ForInStatement" : "ForOfStatement"
  this.next()
  node.left = init
  node.right = this.parseExpression()
  this.popCx()
  this.expect(tt.parenR)
  node.body = this.parseStatement()
  return this.finishNode(node, type)
}
github acornjs / acorn / acorn-loose / src / expression.js View on Github external
lp.parseDynamicImport = function(node) {
  node.source = this.parseExprList(tt.parenR)[0] || this.dummyString()
  return this.finishNode(node, "ImportExpression")
}
github observablehq / parser / src / dynamic-import.js View on Github external
function parseImportCall(parser) {
  const node = parser.startNode();
  const {start} = parser;
  const callExpr = parser.startNode();
  const callee = parser.parseExprAtom();
  parser.expect(tt.parenL);
  callExpr.arguments = [parser.parseMaybeAssign()];
  callExpr.callee = callee;
  parser.finishNode(callExpr, "CallExpression");
  parser.expect(tt.parenR);
  const expr = parser.parseSubscripts(callExpr, start);
  return parser.parseExpressionStatement(node, expr);
}
github acornjs / acorn / acorn-loose / src / statement.js View on Github external
lp.parseFor = function(node, init) {
  node.init = init
  node.test = node.update = null
  if (this.eat(tt.semi) && this.tok.type !== tt.semi) node.test = this.parseExpression()
  if (this.eat(tt.semi) && this.tok.type !== tt.parenR) node.update = this.parseExpression()
  this.popCx()
  this.expect(tt.parenR)
  node.body = this.parseStatement()
  return this.finishNode(node, "ForStatement")
}
github wrleskovec / react-week-scheduler / node_modules / acorn / src / loose / statement.js View on Github external
lp.parseFor = function(node, init) {
  node.init = init
  node.test = node.update = null
  if (this.eat(tt.semi) && this.tok.type !== tt.semi) node.test = this.parseExpression()
  if (this.eat(tt.semi) && this.tok.type !== tt.parenR) node.update = this.parseExpression()
  this.popCx()
  this.expect(tt.parenR)
  node.body = this.parseStatement()
  return this.finishNode(node, "ForStatement")
}
github wrleskovec / react-week-scheduler / node_modules / acorn / src / loose / expression.js View on Github external
lp.parseParenExpression = function() {
  this.pushCx()
  this.expect(tt.parenL)
  let val = this.parseExpression()
  this.popCx()
  this.expect(tt.parenR)
  return val
}