Skip to content

ParserState

ParserState

This is almost the core type of Rudus. Every parser and combinator takes a ParserState as an input and returns a new ParserState.

Type declaration

type ParserState = {
offset: number;
input: string;
result: ParserStateResult | null;
isError: boolean;
errorMessage?: string;
};
PropertyExplanation
offsetCurrent index at where the input is being parsed at
inputComplete string that is to be parsed
resultCurrent results inclusive previous results
isErrorWhether the ParserState is faulty or not
errorMessageOnly set when isError is true otherwise it’s undefined