pAny

fun <I : Any, U : Any> pAny(): Parser<I, I, U>

Returns a Parser that consumes and returns any single token, failing only when the input is exhausted.

pAny is the unconditional token consumer — it never rejects a token on its own, only failing at end of input. Use it as a wildcard in situations where you need to skip or collect tokens regardless of their value.

Behaviour

ConditionResult
Input is exhaustedFailure — "Unexpected end of input"
Token availableSuccess with that token; index advances by 1

Type parameters

  • I — the token type.

  • U — the user context type threaded through unchanged.

Example

val input = ParserInput.of("ab".toList(), Unit)
val result = pAny<Char, Unit>()(input) // Success('a', nextIndex=1, ...)

Return

a Parser that succeeds with the next token or fails at end of input.

See also