tokenizeAs

inline fun <T : Token> tokenizeAs(input: CharSequence, discardEnabled: Boolean = true): List<T>

Transforms the given input into a list of tokens of type T.

This method behaves like tokenize but additionally verifies that all resulting tokens conform to the specified type T.

Return

A list of tokens of type T

Parameters

T

The expected token supertype

input

The character sequence to tokenize

discardEnabled

Whether to exclude discardable tokens from the result

Throws

if the input cannot be fully tokenized

if any token is not of type T