type-alias / @typed/router/Parser

Parser.ManyInternal

Recursively repeats a Parser while it succeeds and consumes input.

Package version
1.0.0-beta.7
Category
Parser repetition
Since
1.0.0
Member of
Parser

Import

import { Parser } from "@typed/router/Parser";

Access Parser.ManyInternal through the imported Parser export. Its declaration below describes the member.

Signatures

type ManyInternal<P extends Any, Input extends string, Acc extends ReadonlyArray<unknown> = readonly [
]> = Apply<P, Input> extends infer R ? [
    R
] extends [
    never
] ? readonly [
    Acc,
    Input
] : R extends readonly [
    infer Value,
    infer Rest extends string
] ? IsNoProgress<Input, Rest> extends true ? never : ManyInternal<P, Rest, readonly [
    ...Acc,
    Value
]> : never : never;

Why

The no-progress check prevents non-terminating type instantiation for parsers that retain input.

Ownership and lifetime

ManyInternal accumulates values and remaining input only in compiler state. The no-progress branch terminates type evaluation without creating a runtime loop.

Source