/* Manages state for parsing operations outside of a Parser. * * The state is immutable; all update operations return a new state. * * Since #x is covariant, any ParseState can convert to ParseState, and * ParseState can convert to all other ParseState. */ concrete ParseState<|#x> { @category new (String) -> (ParseState) @value run<#y> (Parser<#y>) -> (ParseState<#y>) @value runAndGet<#y> (Parser<#y>) -> (ParseState,ErrorOr<#y>) @value atEof () -> (Bool) @value hasAnyError () -> (Bool) @value getError () -> (Formatted) } /* A self-contained parser operation. * * Since #x is covariant, any Parser can convert to Parser, and Parser * can convert to all other Parser. */ @value interface Parser<|#x> { run (ParseContext) -> (ParseState<#x>) } /* Parser context available when running a Parser. * * Since #x is covariant, any ParseContext can convert to ParseContext, and * ParseContext can convert to all other ParseContext. */ @value interface ParseContext<|#x> { run<#y> (Parser<#y>) -> (ParseContext<#y>) runAndGet<#y> (Parser<#y>) -> (ParseContext,ErrorOr<#y>) convertError<#y> () -> (ParseState<#y>) getValue () -> (ErrorOr<#x>) setValue<#y> (ErrorOr<#y>) -> (ParseState<#y>) setBrokenInput (Formatted) -> (ParseState) toState () -> (ParseState<#x>) getPosition () -> (String) atEof () -> (Bool) hasAnyError () -> (Bool) hasBrokenInput () -> (Bool) current () -> (Char) advance () -> (ParseContext<#x>) }