How to use the acorn.tokTypes 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 publiclab / leaflet-environmental-layers / node_modules / acorn-node / lib / dynamic-import / index.js View on Github external
exports['default'] = dynamicImport;

var _acorn = require('acorn');

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) { Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } } /* eslint-disable no-underscore-dangle */


var DynamicImportKey = exports.DynamicImportKey = 'Import';

// NOTE: This allows `yield import()` to parse correctly.
_acorn.tokTypes._import.startsExpr = true;

function parseDynamicImport() {
  var node = this.startNode();
  this.next();
  if (this.type !== _acorn.tokTypes.parenL) {
    this.unexpected();
  }
  return this.finishNode(node, DynamicImportKey);
}

function parenAfter() {
  return (/^(\s|\/\/.*|\/\*[^]*?\*\/)*\(/.test(this.input.slice(this.pos))
  );
}

function dynamicImport(Parser) {
github publiclab / leaflet-environmental-layers / node_modules / acorn-node / lib / bigint / index.js View on Github external
/* Generated by `npm run build`, do not edit! */

"use strict"

var acorn = require("acorn")
var tt = acorn.tokTypes
var isIdentifierStart = acorn.isIdentifierStart

module.exports = function(Parser) {
  return /*@__PURE__*/(function (Parser) {
    function anonymous () {
      Parser.apply(this, arguments);
    }

    if ( Parser ) anonymous.__proto__ = Parser;
    anonymous.prototype = Object.create( Parser && Parser.prototype );
    anonymous.prototype.constructor = anonymous;

    anonymous.prototype.parseLiteral = function parseLiteral (value) {
      var node = Parser.prototype.parseLiteral.call(this, value)
      if (node.raw.charCodeAt(node.raw.length - 1) == 110) { node.bigint = this.getNumberInput(node.start, node.end) }
      return node
github standard-things / esm / lib / parser.js View on Github external
var acorn = require("acorn");
var Token = acorn.Token;
var eofTokenType = acorn.tokTypes.eof;
var importTokenType = acorn.tokTypes._import;
var exportTokenType = acorn.tokTypes._export;
var importExportPattern = /\b(import|export)\b/g;
var assign = require("./utils.js").assign;
var Parser = acorn.Parser;
var parserOptions = {
  ecmaVersion: 7,
  sourceType: "module",
  allowImportExportEverywhere: true,
  allowReturnOutsideFunction: true,
  allowHashBang: true
};

// TODO Could this be cached in memory?
exports.parse = function (code) {
  var nodes = [];
  var match;
  var lastMatchIndex = -1;
github wrleskovec / react-week-scheduler / node_modules / acorn / src / bin / acorn.js View on Github external
function run(code) {
  let result
  if (!tokenize) {
    try { result = acorn.parse(code, options) }
    catch(e) { console.error(e.message); process.exit(1) }
  } else {
    result = []
    let tokenizer = acorn.tokenizer(code, options), token
    while (true) {
      try { token = tokenizer.getToken() }
      catch(e) { console.error(e.message); process.exit(1) }
      result.push(token)
      if (token.type == acorn.tokTypes.eof) break
    }
  }
  if (!silent) console.log(JSON.stringify(result, null, compact ? null : 2))
}
github sx1989827 / DOClever / Desktop / node_modules / acorn-dynamic-import / node_modules / acorn / src / bin / acorn.js View on Github external
function run(code) {
  let result
  if (!tokenize) {
    try { result = acorn.parse(code, options) }
    catch(e) { console.error(e.message); process.exit(1) }
  } else {
    result = []
    let tokenizer = acorn.tokenizer(code, options), token
    while (true) {
      try { token = tokenizer.getToken() }
      catch(e) { console.error(e.message); process.exit(1) }
      result.push(token)
      if (token.type == acorn.tokTypes.eof) break
    }
  }
  if (!silent) console.log(JSON.stringify(result, null, compact ? null : 2))
}
github hertzscript / VirtualMachine / src / AcornPlugin.js View on Github external
const acorn = require("acorn");
const tt = acorn.tokTypes;
const isIdentifierChar = acorn.isIdentifierChar;
const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
const lineBreak = /\r\n?|\n|\u2028|\u2029/;
module.exports = function HzParserFactory(Parser) {
	return class HzSpawnParser extends Parser {
		parseMaybeAssign(noIn, refDestructuringErrors) {
			return this.parseMaybeSpawn(noIn, refDestructuringErrors);
		}
		parseMaybeSpawn(noIn, refDestructuringErrors) {
			skipWhiteSpace.lastIndex = this.pos;
			const next = this.pos + skipWhiteSpace.exec(this.input)[0].length;
			if (
				!this.isContextual("spawn")
				|| lineBreak.test(this.input.slice(this.pos, next))
				|| this.input.slice(next, next + 1) === "="
				|| !isIdentifierChar(this.input[next].charCodeAt(0))
github graalvm / graaljs / tools / node_modules / eslint / node_modules / acorn-jsx / index.js View on Github external
'use strict';

const XHTMLEntities = require('./xhtml');

const hexNumber = /^[\da-fA-F]+$/;
const decimalNumber = /^\d+$/;

const acorn = require("acorn");
const tt = acorn.tokTypes;
const TokContext = acorn.TokContext;
const tokContexts = acorn.tokContexts;
const TokenType = acorn.TokenType;
const isNewLine = acorn.isNewLine;
const isIdentifierStart = acorn.isIdentifierStart;
const isIdentifierChar = acorn.isIdentifierChar;

const tc_oTag = new TokContext('...', true, true);

const tok = {
  jsxName: new TokenType('jsxName'),
  jsxText: new TokenType('jsxText', {beforeExpr: true}),
  jsxTagStart: new TokenType('jsxTagStart'),
  jsxTagEnd: new TokenType('jsxTagEnd')
github kristianoye / kmud / src / compiler / SecurityModifiers.js View on Github external
/*
 * Written by Kris Oye 
 * Copyright (C) 2017.  All rights reserved.
 * Date: October 1, 2017
 * 
 * Eventually this might allow for access modifier keywords
 * like 'public', 'private', and 'protected'.
 */
const acorn = require('acorn');

const
    tt = acorn.tokTypes,
    TokContext = acorn.TokContext,
    TokenType = acorn.TokenType;

const
    kmcCallOther = new TokContext('->', false);

const
    tokenTypes = {
        kmudCallOther: new TokenType('KMUDCallOther')
    };

function plugin(options, Parser) {
    return class extends Parser {
        parseClassElement(constructorAllowsSuper) {
            if (this.eat(tt.semi)) return null;
github aMarCruz / rollup-plugin-cleanup / dist / rollup-plugin-cleanup.js View on Github external
const onToken = ({ start, end, type }) => {
    if (pos !== start) {
      squashRegion(pos, start, pos === 0, type === acorn.tokTypes.eof);
    }
    pos = end;
  };
github cloudflare / ipfs-ext / node_modules / acorn-dynamic-import / lib / index.js View on Github external
function parseDynamicImport() {
  var node = this.startNode();
  this.next();
  if (this.type !== _acorn.tokTypes.parenL) {
    this.unexpected();
  }
  return this.finishNode(node, DynamicImportKey);
}