UNPKG

@thi.ng/parse

Version:

Purely functional parser combinators & AST generation for generic inputs

10 lines (9 loc) 233 B
import { parseError } from "../error.js"; import { xform } from "./xform.js"; const check = (parser, pred, msg = "check failed") => xform( parser, (scope, ctx) => pred(scope) ? scope : parseError(ctx, msg) ); export { check };