/** * # Parser Result * * The result of a parser function is a discriminated union that * represents either success or failure. In both cases need the * `position` field to indicate where in the input stream we are. * This is field is defined in the base interface. */ interface Position { position: number; } /** * When parsing succeeds we return the the `Ok` object. It contains * the `result` returned by the parser. Type parameter `T` indicates * its type. */ interface Ok extends Position { kind: "ok"; result: T; } /** * When parsing fails we return the `Fail` object. It does not have a * result, but information about the input `found` and input `expected`. */ interface Fail extends Position { kind: "fail"; found: string; expected: string[]; } /** * The actual result type is a discriminated union of the `Ok` and * `Fail` objects. */ export type ParseResult = Ok | Fail; /** * ## Helper Functions * * The `joinExpected` function concatenates the list of expected * inputs from the `other` failed parse result into the `expected` * array of the first one. */ export declare function joinExpected(result: Fail, other: Fail): void; /** * This function formats the array of expected inputs as a string for * printing. */ export declare function expectedAsCsv(result: Fail): string; /** * ## Constructor Functions * * The following function is used to construct an `Ok` result. */ export declare function succeeded(pos: number, res: T): ParseResult; /** * The next one constructs a `Fail` result. */ export declare function failed(pos: number, fnd: string, exp?: string[]): ParseResult; export {};