UNPKG

parseit.js

Version:

Customizable parsing library for converting a list of tokens into an AST tree

26 lines 877 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.error = exports.ParseErrorType = void 0; var ParseErrorType; (function (ParseErrorType) { ParseErrorType[ParseErrorType["UNEXP_TOKEN"] = 0] = "UNEXP_TOKEN"; })(ParseErrorType = exports.ParseErrorType || (exports.ParseErrorType = {})); class ParseError { type = ParseErrorType.UNEXP_TOKEN; position = { index: -1, token: null }; constructor(index, token, type) { this.position.index = index; this.position.token = token; this.type = type || this.type; } toString = () => `ParseError: Unexpected token ${this.position.token} at index ${this.position.index}`; } exports.default = ParseError; function error(index, token) { return new ParseError(index, token); } exports.error = error; //# sourceMappingURL=ParseError.js.map