export type ParseResult = { value: T; restInput: string; }; export declare class ParseError extends Error { readonly restInput: string; name: string; constructor(message: string, restInput: string); } export declare class Parser { readonly run: (input: string) => ParseResult; constructor(run: (input: string) => ParseResult); andThen(restParser: (result: T) => Parser): Parser; map(fn: (value: T) => U): Parser; } export declare function failure(message: string): Parser; export declare function sequence(parsers: { [K in keyof Ts]: Parser; }): Parser; export declare function pure(value: T): Parser; export declare function string(str: string): Parser; export declare function char(char: string): Parser; export declare function between(open: Parser, close: Parser, middle: Parser): Parser; export declare function choice(parserOptions: Parser[]): Parser; export declare function many(parser: Parser): Parser; export declare function some(parser: Parser): Parser<[T, ...T[]]>; export declare function count(n: number, parser: Parser): Parser; export declare function optional(parser: Parser): Parser; export declare function satisfy(predicate: (char: string) => boolean): Parser; export declare const digitChar: Parser; export declare const hexChar: Parser; export declare const anyChar: Parser; export declare const decimal: Parser; export declare function lazy(createParser: () => Parser): Parser; export declare function tryElseBacktrack(parser: Parser): Parser; export declare namespace Expr { type UnaryOperator = Parser<(inner: T) => T>; type BinaryOperator = Parser<(left: T, right: T) => R>; function infixOpLeftAssoc(left: T, operatorParser: BinaryOperator, rightParser: Parser): Parser; function infixOpRightAssoc(left: T, operatorParser: BinaryOperator, rightParser: Parser): Parser; function infixOpLeftAssocOptional(left: T | undefined, operatorParser: BinaryOperator, rightParser: Parser): Parser; function infixOpRightAssocOptional(left: T | undefined, operatorParser: BinaryOperator, rightParser: Parser): Parser; type Operator = Readonly<{ type: 'prefix'; op: Expr.UnaryOperator; } | { type: 'postfix'; op: Expr.UnaryOperator; } | { type: 'infixLeft'; op: Expr.BinaryOperator; } | { type: 'infixRight'; op: Expr.BinaryOperator; } | { type: 'infixLeftOptional'; op: Expr.BinaryOperator; } | { type: 'infixRightOptional'; op: Expr.BinaryOperator; }>; function makeExprParser(termParser: Parser, operators: Operator[]): Parser; }