Home > Archive > Compilers > September 2007 > Comparison of ANTLR and javacc
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Comparison of ANTLR and javacc
|
|
| axsmth@gmail.com 2007-08-28, 7:17 pm |
| Hi,
Can anyone point me to a recent comparison of ANTLR and javacc? What
are each of them more/less useful for?
Thanks
| |
| Tom Copeland 2007-08-29, 10:10 pm |
| On Tue, 2007-08-28 at 18:59 +0000, axsmth@gmail.com wrote:
> Can anyone point me to a recent comparison of ANTLR and javacc? What
> are each of them more/less useful for?
ANTLR has an edge over JavaCC in that it can produce parser source
code in various languages, whereas JavaCC is limited to producing
parsers in Java.
That said, JavaCC+JJTree provides a fine solution for projects that
can use a parser in Java, and there are lots of example JavaCC
grammars out there to learn from.
Yours,
Tom
http://generatingparserswithjavacc.com/
| |
|
| One major advantage that JavaCC has is no runtime component. It
generates the files needed, and your parser is completely self
contained. ANTLR build parsers can run into problems if you have two
libraries which both use ANTLR. This is more common than you might
think.
For example, I help maintain a copy paste detector which uses ANTLR
(same-code-duplication-detector). It can be run from Ant, but it may
fail if you also use CheckStyle. If the runtime component was binary
compatible, this wouldn't be so much of an issue, but unfortunately,
it changes between point releases. The solution in the above case is
to put my tool into a separate classloader, which makes using it more
complicated.
If your app has multiple parsers, and they're all built off from
whatever version on ANTLR you have, then you're probably going to be
OK, and may even be smaller than multiple JavaCC parsers. But, if you
take someone else's jar file, and they have an ANTLR dependency, then
your project can become quite complicated.
ANTLR v3 has a lot of great features, like being able to target other
languages. But, I think some of these features make it a bit harder
to learn.
I would check to see if there is a existing grammar available for what
you want to parse, and start with the tool that you can find the
grammar for.
-Brian
|
|
|
|
|