Type Alias Chain<T, E>

Chain<T, E>: {
    done: Rule<E, T>;
    push<R>(rule: Rule<E, R>): Chain<readonly [T, R], E>;
    skip<R>(rule: Rule<E, R>): Chain<T, E>;
}

The Chain type represents a composable chain of parser rules, allowing for step-by-step construction of parsing logic with flexibility for handling results.

Type Parameters

  • T extends readonly unknown[]
  • E

Type declaration

  • done: Rule<E, T>

    A final parser that combines all the rules in the chain and produces a result of type T.

  • push:function
    • Adds a new parsing rule to the chain. The result of the rule (R) is appended to the tuple T, maintaining a record of all accumulated results.

      Type Parameters

      • R

      Parameters

      Returns Chain<readonly [T, R], E>

  • skip:function
    • Adds a parsing rule to the chain but ignores its result. The tuple T remains unchanged.

      Type Parameters

      • R

      Parameters

      Returns Chain<T, E>