PEG in Go

Jul 28, 2011 at 7:15PM
Caleb Doxsey

I've been working on a PEG parser in Go. PEG parsers are very similar to traditional CFG parsers but unambiguous and (generally) easier to write.

The library can be found here. I put together a basic example which parses simple mathematical expressions and evaluates them. It's crude but it does work:

There are two things I'd like to get working next:

  1. Add a .compile method which will let you parse PEG syntax instead of having to specify all the rules as Go calls
  2. Come up with a way to make processing expression trees easier
But I may not get to all that.