Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which is the best counterpart to ANTLR to create parsers in ruby?

I've used antlr and javacc/freecc for a while. Now I need to write a bunch of parsers using antlr grammars but such parsers need to be written in ruby lang.

I googled but nothing found. Is there any ruby parser generator that takes antlr grammars and create a parser? If there are many, which is the best one in your opinion?

TIA Paolo

like image 423
Paolo Perego Avatar asked Jun 15 '10 07:06

Paolo Perego


3 Answers

  1. You might get away easy by using JRuby and keeping your ANTLR parsers in java.
  2. If PEGs are enough for your job, treetop and the newer citrus are common tools used by rubyists.
  3. Other parsers I dug while researching for a project are: peggy, Kanocc, Racc.

For my project I chosed treetop (citrus was not born yet).

like image 199
clyfe Avatar answered Nov 07 '22 09:11

clyfe


Why not to use ANTLR Ruby: http://www.antlr.org/wiki/display/ANTLR3/Antlr3RubyTarget (http://split-s.blogspot.com/2005/12/antlr-for-ruby.html)

There is also some beta here: http://rubyforge.org/projects/antlr3/

like image 37
Vladislav Rastrusny Avatar answered Nov 07 '22 08:11

Vladislav Rastrusny


You could also generate the parser with ANTLR for Java or C and call it from your Ruby program with JRuby or FFI.

This should also give you a performance boost which might be a big advantage if you have a lot of input to parse.

like image 39
ahe Avatar answered Nov 07 '22 09:11

ahe