> I don't know how to make my parser faster since I already use 'infix > expression'. I observed that after removing some small matches, the time cost > dropped from ~20 to ~10 seconds, so my best guess is that the slowness is > mainly caused by the frequent object construction and deconstruction, or > deeply the behavior of PEG? Any suggestion?
You say you need to parse thousands of lines of code fast: I wonder whether a parser in Ruby is the best choice of implementation. Treetop would be about 3x faster than parslet (probably), but that only gets you down to around 2 seconds for your tests. Most programming languages eventually write their parser in a language like C. These languages have a 50-100x speed advantage over Ruby. That might be the way to go if you want to see real improvement. parslet is already heavily optimized; I still have some ideas left to implement, but all things considered I might only manage to close the gap to Treetop and other simpler parser combinators. I certainly wont be able to provide the speed a parser written in C provides - not unless I compile parsers down to C. That sounds interesting, but I would not hold my breath for it, I also run a company on the side. my 2 cents.. kaspar
