TokenIterator
An iterator wrapper for a sequence of tokens that explicitly uses reference semantics.
class TokenIterator<T>
An iterator wrapper for a sequence of tokens that explicitly uses reference semantics.
class TokenIterator<T>
import Utils
protocol IteratorProtocol<Element>
A type that supplies the values of a sequence one at a time.
init(_ array: [T])
var current: T? { get }
func contains(where predicate: (T) -> Bool) -> Bool
func first(where predicate: (T) -> Bool) -> T?
Finds the first matching token in the rest of the array without advancing the iteration. This allows users to essentially do ‘infinite lookahead’. Note that this will also extend the internal lookahead buffer.
@discardableResult func next() -> T?
func peek(_ k: Int = 1) -> T?
Peeks the kth token (if it exists).