UNPKG

@thi.ng/parse

Version:

Purely functional parser combinators & AST generation for generic inputs

12 lines (11 loc) 243 B
import { always } from "../prims/always.js"; const not = (parser, fail = always()) => (ctx) => { if (ctx.done) return false; ctx.start(""); const res = parser(ctx); ctx.discard(); return res ? false : fail(ctx); }; export { not };