diff --git a/types/moo/index.d.ts b/types/moo/index.d.ts index 1a8e9f18d4..c2baf55a29 100644 --- a/types/moo/index.d.ts +++ b/types/moo/index.d.ts @@ -96,6 +96,19 @@ export interface Lexer { * to reset() to explicitly control the internal state of the lexer. */ save(): LexerState; + /** + * Transitions to the provided state and pushes the state onto the state + * stack. + */ + pushState(state: string): void; + /** + * Returns back to the previous state in the stack. + */ + popState(): void; + /** + * Transitiosn to the provided state. Does not push onto the state stack. + */ + setState(state: string): void; [Symbol.iterator](): Iterator; } diff --git a/types/moo/moo-tests.ts b/types/moo/moo-tests.ts index 9de53e87ee..30beb0c39a 100644 --- a/types/moo/moo-tests.ts +++ b/types/moo/moo-tests.ts @@ -55,6 +55,11 @@ lexer = moo.states({ }, }); +lexer.pushState('lit'); +lexer.popState(); +lexer.setState('lit'); +lexer.popState(); + moo.compile({ myError: moo.error });