Skip to main content
Module

x/pazza/mod.ts>prefix

Parser combinators library designed for Deno, but also works on browsers and Node.js.
Go to Latest
function prefix
import { prefix } from "https://deno.land/x/pazza@v0.3.0/mod.ts";

Execute the "prefix" parse first. If it succeeds, discard its result and execute the following normal parser.

If any of both parsers fails, the whole parser will fail.

const parser = prefix(char("<"), digit());
parser("<5").output === "5";
parser("[5").ok === false;
parser("<a").ok === false;

Type Parameters

T
ET
EP
I extends Input
CtxIn
CtxOut

Parameters

prefix: IParser<unknown, EP, I, CtxIn, CtxOut>

parser to parse prefix

parser: IParser<T, ET, I, CtxIn, CtxOut>

parser to parse normal stuff