UNPKG

parjs

Version:

Library for building parsers using combinators.

32 lines 877 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.eof = void 0; const parser_1 = require("../parser"); const result_1 = require("../result"); class Eof extends parser_1.ParjserBase { constructor(result) { super(); this.result = result; 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 = this.result; } else { ps.kind = result_1.ResultKind.SoftFail; } } } /** * 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 Eof(result); } exports.eof = eof; //# sourceMappingURL=eof.js.map