# Which library to write a parser

**URL:** <https://www.ruby-forum.com/t/which-library-to-write-a-parser/215786>\
**Category:** Ruby\
**Created:** [January 16, 2012, 8:48am UTC](https://www.ruby-forum.com/t/which-library-to-write-a-parser/215786 "2012-01-16T08:48:56Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![tamc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f1d935/32.png) [@tamc](https://www.ruby-forum.com/u/tamc)\
**Post date:** [January 30, 2012, 11:58pm UTC](https://www.ruby-forum.com/t/which-library-to-write-a-parser/215786/11 "2012-01-30T23:58:26Z")

</div>

Kaspar S. wrote in post #1042425:

> On 18.01.12 05:07, Ryan D. wrote:
> 
> > Write your own by hand. It’ll be faster
> 
> And for another definition of faster (faster to code): parslet.
> 
> greetings,  
> k  
> Hello,

I tried out parslet today, and I really appreciate its design (i.e.,  
what parsers look like) as well as the beautiful webpage you built.

I could not use it for my current project, however, as it was way to  
slow. I need to be able to parse millions of constraint specifications,  
each based on a fairly simple grammar (20 rules or so). I found my  
original implementation (regular expression matching and scanning) to  
be ugly, inefficient (scanning a string a few times) and rather  
slow (~15K constraints per second). The goal was to get both more  
beautiful and faster by using a parser framework. It got more beautiful,  
but too slow to be useful to me.

If I had benchmarked the MiniP parser posted on the homepage of parslet,  
it would have been obvious that parslet is too slow for my purposes: On  
my machine, it parses 180 lines / second, given the test string  
“puts(3 + 2 + 61235 + 24 + 51, 252 + 235 + 11, 2, 3, 5, 7, 11,19)”  
So while I appreciate the neat interface of those fancy new parsers,  
people should know that they are slow.

But, I think it would be awesome to have a beautiful parser lib that is  
fast, and given that the performance of the regular expression engine is  
quite decent, it should be feasible to build such a parser.  
a) Do you think there is any chance to get a faster (say, factor 100)  
implementation for parslet with the same (or a similar) interface?  
b) If not, is there any maintained ruby parsing library or parser  
generator (no need to be in pure ruby) which is fast enough? How fast is  
antlr for ruby?

Kind Regards,  
Benedikt

---

_[View the full topic](https://www.ruby-forum.com/t/which-library-to-write-a-parser/215786)._
