parjs
Version:
Library for building parsers using combinators.
28 lines • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParserDefinitionError = exports.ParjsParsingFailure = exports.ParjsError = void 0;
/** A parent class for all errors thrown by Parjs. */
class ParjsError extends Error {
constructor() {
super(...arguments);
this.name = this.constructor.name;
}
}
exports.ParjsError = ParjsError;
/** An error that is thrown when it is assumed a parser will succeed, but it fails. */
class ParjsParsingFailure extends ParjsError {
constructor(failure) {
super(`Expected parsing to succeed, but it failed. Reason: ${failure.trace.reason}`);
this.failure = failure;
}
}
exports.ParjsParsingFailure = ParjsParsingFailure;
/** An error thrown to indicate that a parser has been constructed inappropriately. */
class ParserDefinitionError extends ParjsError {
constructor(parserName, message) {
super(`${parserName}: ${message}`);
this.parserName = parserName;
}
}
exports.ParserDefinitionError = ParserDefinitionError;
//# sourceMappingURL=errors.js.map