From: Benedikt Huber Date: 2012-01-31T21:05:04+09:00 Subject: Re: Which library to write a parser Hello again, I found one combinator-based parser library which seems to provide quite decent performance: rsec-ext (http://rsec.heroku.com/) Here is the code implementing parslet's MiniP parser: require 'rubygems' require "rsec" include Rsec::Helpers id = /[a-z]+/.r.fail 'id' int = /[0-9]+/.r.fail 'int' op = one_of_('+') comma = /\s*,\s*/.r sum = seq(int, op, lazy{expr}) arglist= '('.r >> lazy{expr}.join(comma).even << ')' funcall= seq_(id, arglist) expr = funcall | sum | int parser = expr.eof File.readlines(ARGV.first).each { |line| parser.parse!(line) } I do not claim that the parsers are equivalent (different datastructures for the result), and so the comparison is a little bit unfair and only shows a trend. I'd like to share it anyway: Parsing 10000 lines, each containing puts(3 + 2 + 61235 + 24 + 51, 252 + 235 + 23532 + 11, 2, 3, 5, 7, 11, 19) the parsers need: parslet / ruby 1.8: 162.8s parslet / ruby 1.9: 49.5s rsec-ext / ruby 1.9: 0.7s Kind Regards, Benedikt -- Posted via http://www.ruby-forum.com/.