Interface ParsingState

Maintains progress for parsing a single input.

interface ParsingState {
    initialUserState: undefined | UserState;
    input: string;
    isFatal: boolean;
    isHard: boolean;
    isOk: boolean;
    isSoft: boolean;
    kind: ResultKind;
    position: number;
    reason: undefined | string;
    stack: {
        expecting: string;
        type: string;
    }[];
    userState: UserState;
    value: unknown;
    atLeast(kind): undefined | boolean;
    atMost(kind): undefined | boolean;
}

Properties

initialUserState: undefined | UserState

Initial user state.

input: string

The original string input on which parsing is performed. Should not be mutated while parsing.

isFatal: boolean

Shorthand for this.result == FatalFailure

isHard: boolean

Shorthand for this.result == HardFailure

isOk: boolean

Shorthand for this.result == Okay

isSoft: boolean

Shorthand for this.result == SoftFailure

The result of the last parser action: OK, SoftFailure, HardFailure, FatalFailure.

position: number

The next character waiting to be parsed.

reason: undefined | string

If the result is a failure, this field will indicate the reason for the failure. If the result is OK, this must be undefined.

stack: {
    expecting: string;
    type: string;
}[]

A stack that indicates entered parsers. Should not be modified by user code.

Type declaration

  • expecting: string
  • type: string
userState: UserState

Additional state data.

value: unknown

The value from the last parser action performed on this state.

Methods