Acorn is a JavaScript parser written in JavaScript. See the Github page for the code and documentation.