January 27th, 2008


What are the best options to create language parsers?

Interesting article on Reddit.

There's the standard "use lex/flex and yacc/bison" advice, naturally. A few people advocating writing your own recursive descent parsers. Some people saying "use ML or OCAML". But there were also a couple of newer and much more interesting options as well:

http://www.antlr.org/ - A recursive descent parser generator that will output in several popular languages.

http://treetop.rubyforge.org/ - A PEG library for Ruby.

There's even the interesting revelation that Perl's extended regular expression can match balanced sets of parens, so you could in theory write your parser in perl too - i.e..

For the purists, BNF Converter looks like a nice meta-tool.