UNPKG

807 BJavaScriptView Raw
1/* @flow */
2
3"use strict";
4
5var _interopRequireDefault = require("babel-runtime/helpers/interop-require-default")["default"];
6
7var _utilLocation = require("../util/location");
8
9var _index = require("./index");
10
11var _index2 = _interopRequireDefault(_index);
12
13var pp = _index2["default"].prototype;
14
15// This function is used to raise exceptions on parse errors. It
16// takes an offset integer (into the current `input`) to indicate
17// the location of the error, attaches the position to the end
18// of the error message, and then raises a `SyntaxError` with that
19// message.
20
21pp.raise = function (pos, message) {
22 var loc = _utilLocation.getLineInfo(this.input, pos);
23 message += " (" + loc.line + ":" + loc.column + ")";
24 var err = new SyntaxError(message);
25 err.pos = pos;
26 err.loc = loc;
27 throw err;
28};
\No newline at end of file