Functional token parser for JavaScript