Sha256: 80cb81bb2a73be56e91e5ae82ff233758d99df71a94f866301c5fca6a3324920

Contents?: true

Size: 1.52 KB

Versions: 6

Compression:

Stored size: 1.52 KB

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _options = require("../options");

var _statement = _interopRequireDefault(require("./statement"));

var _scopeflags = require("../util/scopeflags");

var _scope = _interopRequireDefault(require("../util/scope"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

class Parser extends _statement.default {
  constructor(options, input) {
    options = (0, _options.getOptions)(options);
    super(options, input);
    const ScopeHandler = this.getScopeHandler();
    this.options = options;
    this.inModule = this.options.sourceType === "module";
    this.scope = new ScopeHandler(this.raise.bind(this), this.inModule);
    this.plugins = pluginsMap(this.options.plugins);
    this.filename = options.sourceFilename;
  }

  getScopeHandler() {
    return _scope.default;
  }

  parse() {
    this.scope.enter(_scopeflags.SCOPE_PROGRAM);
    const file = this.startNode();
    const program = this.startNode();
    this.nextToken();
    file.errors = null;
    this.parseTopLevel(file, program);
    file.errors = this.state.errors;
    return file;
  }

}

exports.default = Parser;

function pluginsMap(plugins) {
  const pluginMap = new Map();

  for (let _i = 0; _i < plugins.length; _i++) {
    const plugin = plugins[_i];
    const [name, options] = Array.isArray(plugin) ? plugin : [plugin, {}];
    if (!pluginMap.has(name)) pluginMap.set(name, options || {});
  }

  return pluginMap;
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
condenser-0.2 lib/condenser/processors/node_modules/@babel/parser/lib/parser/index.js
condenser-0.1 lib/condenser/processors/node_modules/@babel/parser/lib/parser/index.js
condenser-0.0.12 lib/condenser/processors/node_modules/@babel/parser/lib/parser/index.js
condenser-0.0.11 lib/condenser/processors/node_modules/@babel/parser/lib/parser/index.js
condenser-0.0.10 lib/condenser/processors/node_modules/@babel/parser/lib/parser/index.js
condenser-0.0.9 lib/condenser/processors/node_modules/@babel/parser/lib/parser/index.js