UNPKG

parjs

Version:

A parser-combinator library for JavaScript.

57 lines (56 loc) 2.75 kB
/** * @module parjs/combinators */ /** */ import { ParjsCombinator } from "../.."; import { ImplicitParjser } from "../scalar-converter"; /** * Applies the source parser. If it fails softly, will try to apply the * given parsers in sequential order. If all fail, parsing will fail with the * error of the last parser. * This combinator cannot recover from Hard or Fatal failures. If any parser * fails in that way, the returned parser will fail with that info and will not * try other parsers. * * @param alt1 The first alternative parser to apply. */ export declare function or<T1, T2>(alt1: ImplicitParjser<T2>): ParjsCombinator<T1, T1 | T2>; /** * Applies the source parser. If it fails softly, will try to apply the * given parsers in sequential order. If all fail, parsing will fail with the * error of the last parser. * This combinator cannot recover from Hard or Fatal failures. If any parser * fails in that way, the returned parser will fail with that info and will not * try other parsers. * * @param alt1 The first alternative parser to apply. * @param alt2 The second alternative parser to apply. */ export declare function or<T1, T2, T3>(alt1: ImplicitParjser<T2>, alt2: ImplicitParjser<T3>): ParjsCombinator<T1, T1 | T2 | T3>; /** * Applies the source parser. If it fails softly, will try to apply the * given parsers in sequential order. If all fail, parsing will fail with the * error of the last parser. * This combinator cannot recover from Hard or Fatal failures. If any parser * fails in that way, the returned parser will fail with that info and will not * try other parsers. * * @param alt1 The first alternative parser to apply. * @param alt2 The second alternative parser to apply. * @param alt3 The third alternative parser to apply. */ export declare function or<T1, T2, T3, T4>(alt1: ImplicitParjser<T2>, alt2: ImplicitParjser<T3>, alt3: ImplicitParjser<T4>): ParjsCombinator<T1, T1 | T2 | T3 | T4>; /** * Applies the source parser. If it fails softly, will try to apply the * given parsers in sequential order. If all fail, parsing will fail with the * error of the last parser. * This combinator cannot recover from Hard or Fatal failures. If any parser * fails in that way, the returned parser will fail with that info and will not * try other parsers. * * @param alt1 The first alternative parser to apply. * @param alt2 The second alternative parser to apply. * @param alt3 The third alternative parser to apply. * @param alt4 The fourth alternative parser to apply. */ export declare function or<T1, T2, T3, T4, T5>(alt1: ImplicitParjser<T2>, alt2: ImplicitParjser<T3>, alt3: ImplicitParjser<T4>, alt4: ImplicitParjser<T5>): ParjsCombinator<T1, T1 | T2 | T3 | T4 | T5>;