JS implementation of Parser 3