The following changes were made in an effort to make the API closer to other popular parsing libraries, such as babel and acorn.
lexer.loc.columnwas changed from a 1-index number to a 0-index number
.currentis now a property set by the
.handle()method. The value of
lexer.currentis whatever is returned by a handler.
.prev()now returns the previously lexed token
lexer.options.modeis set to
lexer.advance()will consume and return a single character each time it's called, instead of iterating over the handlers.
token.matcharray is now decorated with a
.consumedproperty, which is the value of
lexer.consumedbefore the match was created.
lexer.stackfor tracking opening/closing structures
lexer.stashfor storing an array of strings (in addition to
lexer.tokens, which stores objects)