|
|
Comparse – Coffeescript Monadic Parser
|
|
|
======================================
|
|
|
Comparse – Monadic Parsing Library
|
|
|
==================================
|
|
|
|
|
|
We've been all taught that creating a parser boils down to writing a context free grammar and then using some library like [Bison](http://www.gnu.org/software/bison/ "Bison"). By the way, such a library exists for JavaScript, too, it is called [Jison](http://zaach.github.io/jison/ "Jison"), and CoffeeScript uses it for parsing the source code.
|
|
|
|
... | ... | @@ -11,5 +11,4 @@ So I was wondering whether a decent monadic parser could be written in CoffeeScr |
|
|
|
|
|
The implementation takes into account the lack of tail recursion optimization in JavaScript, so recursive functions are mostly rewritten using loops. Also, since JavaScript is _not_ a pure functional language, side effects and non-local variables are used in a few places for improving efficiency.
|
|
|
|
|
|
The Comparse library was written as Literate CoffeeScript. This means that both this formatted text and the CoffeeScript source were generated from the same file.
|
|
|
|
|
|
* [Annotated source code][comparse] |