UNPKG

sucrase

Version:

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

26 lines (25 loc) 933 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const location_1 = require("../util/location"); const base_1 = require("./base"); // 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 base_1.default { raise(pos, message, missingPluginNames) { const loc = location_1.getLineInfo(this.input, pos); message += ` (${loc.line}:${loc.column})`; // @ts-ignore const err = new SyntaxError(message); err.pos = pos; err.loc = loc; if (missingPluginNames) { // @ts-ignore err.missingPlugin = missingPluginNames; } throw err; } } exports.default = LocationParser;