parjs
Version:
A parser-combinator library for JavaScript.
34 lines (33 loc) • 909 B
JavaScript
;
/**
* @module parjs
*/
/** */
Object.defineProperty(exports, "__esModule", { value: true });
const result_1 = require("../result");
const parser_1 = require("../parser");
/**
* Returns a parser that succeeds if there is no more input.
* @param result Optionally, the result the parser will yield. Defaults to
* undefined.
*/
function eof(result) {
return new class Eof extends parser_1.ParjserBase {
constructor() {
super(...arguments);
this.type = "eof";
this.expecting = "expecting end of input";
}
_apply(ps) {
if (ps.position === ps.input.length) {
ps.kind = result_1.ResultKind.Ok;
ps.value = result;
}
else {
ps.kind = result_1.ResultKind.SoftFail;
}
}
}();
}
exports.eof = eof;
//# sourceMappingURL=eof.js.map