UNPKG

sucrase

Version:

Super-fast alternative to Babel for when you can target modern JS runtimes

37 lines (27 loc) 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _location = require("../util/location"); var _comments = _interopRequireDefault(require("./comments")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // This function is used to raise exceptions on parse errors. It // takes an offset integer (into the current `input`) to indicate // the location of the error, attaches the position to the end // of the error message, and then raises a `SyntaxError` with that // message. class LocationParser extends _comments.default { raise(pos, message, missingPluginNames) { const loc = (0, _location.getLineInfo)(this.input, pos); message += ` (${loc.line}:${loc.column})`; // $FlowIgnore const err = new SyntaxError(message); err.pos = pos; err.loc = loc; if (missingPluginNames) { err.missingPlugin = missingPluginNames; } throw err; } } exports.default = LocationParser;