Skip to content

Latest commit

 

History

History
17 lines (11 loc) · 412 Bytes

tok.md

File metadata and controls

17 lines (11 loc) · 412 Bytes

Parser Combinator: tok

tok(x) consumes a token, if the kind property of the token is exactly x. It fails if it doesn't match the kind property.

For example, for passing TypeScript's export statement:

export default Something;

We could write

seq(str('export'), str('default'), tok(TokenKind.Identifier), str(';'))

The meaning of the code is very obvious to us.