fix(moo): Add missing Lexer methods (#43477)

This commit is contained in:
Evan Purkhiser 2020-03-30 15:54:10 -07:00 committed by GitHub
parent 41315ef7af
commit 1ed6fe521f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

13
types/moo/index.d.ts vendored
View File

@ -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<Token>;
}

View File

@ -55,6 +55,11 @@ lexer = moo.states({
},
});
lexer.pushState('lit');
lexer.popState();
lexer.setState('lit');
lexer.popState();
moo.compile({
myError: moo.error
});