Today, Parboiled is mainly scala-tool. So, if you are using scala it may be better solution for most cases.
Ease of use
ANTLR should be much easier for beginners. It's easier to start with.
- There's the book about ANTLR. It's also well described in DSLs in action. And it has better documentation in general.
- There are ANTLR plugins for different IDEs. They will allow you to see the AST and give you some other support.
Parboiled is a scala library. You will have syntax highlights and type check out of the box. Parboiled1 works fine in most IDEs. Parbiled2 doesn't (will be fixed soon in Idea). The library uses macro-expressions and the most IDEs are not comfortable with it. That's why you will have everything red.
But both are pretty easy to start with.
- You can try ANTLR from console (please correct me if I'm wrong).
- You can install sbt add parboiled as a dependency and play in scala console.
Scalability
In my opinion Parboiled is more scalable. Because you are writing scala code. You can decompose your parser to multiple scala traits and mix them one with another. You may create DateTime parser, and mix it to LogEvent parser or $PROTOCOL_NAME parser. And reuse them easily.
For parboiled1 you can do some naughty things in runtime. Well, it gives you power. For some cases you can construct parsers on a fly. For example you have datetime format, defined as string. You can read the format string and generate the appropriate parser for it. It is possible even for Parboiled2 (which does lot's of stuff during compile time). I don't know whether it's possible for ANTLR.
AST
I like the Parboiled approach to AST. It expects you to define ADT.
So in ideal case you will have an immutable tree of case classes.
you may add some 'dsl-like' stuff to your tree nodes. For example you may define "\" method to your node, which returns a child with specified name.
case class Node(value: String) {
....
def \ (childName: String): Option[Node] =
this.children.find(child => child.name == childName)
}
And Then use it:
city \ "3rd street" \ "23"
This makes work with AST much easier.
I hope it helps.
Using in production
- If you are using parboiled you have do add it to your dependency list. That's all. You will have everything working right out the box.
- If you are using ANTLR, you have to generate *.java files first. And regenerate every time you change the grammar. For the most cases grammar is not changed very often. But In my experience I had situations where we've changed grammar every 2days. You may not thing that it's a problem though.