ParseState
public final class ParseState<Token>
Represents the state of the parser. Stores the generator from which the subsequent symbols to parse are obtained.
-
Construct a
ParseState
from a forkable sequence. Provided as an optimization.Declaration
Swift
public convenience init<Sequence: SequenceType where Sequence.Generator: ForkableGeneratorType, Sequence.Generator.Element == Token>(_ sequence: Sequence)
-
Returns the next token from the generator, otherwise throws a
ParseError
if no more tokens are availible.Declaration
Swift
public func read() throws -> Token
-
Save the current
ParseState
for later restoration.Declaration
Swift
@warn_unused_result public func checkpoint() -> ParseStateCheckpoint<Token>
-
Restore the
ParseState
to what is was whencheckpoint
was created.Declaration
Swift
public func restore(checkpoint: ParseStateCheckpoint<Token>)