[antlr-interest] ANTLR vs lex/yacc

Mike Bresnahan mike at fruitioninc.com
Sun Jan 9 19:49:13 PST 2005

I have seen many people comment on how they dislike yacc/lex vs ANTLR.  I'm
curious why people think this.  My limited experience hasn't been so black
and white.  I first learned yacc/lex about 9 years ago and I haven't used
them since.  At the time I found them wonderful tools.  I bought the
O'Reilly nutshell book and within a very short period of time I could whip
out a simple parser in one day.  I found the tools very intiutive.

Speed forward to today.  I first started using ANTLR a few months ago.  I
chose it because it generates C# and that is what I needed.  My experience
with ANTLR has been much different than my experience with yacc/lex.  I have
found it extremely difficult to get my head around the tool.  I don't think
the problem is the tool per se, but rather LL(k) grammers.  I don't find
them to be intuitive.  The grammers are harder for me to read and write.

One very hard concept is that I cannot use left recursion, however "middle
recursion" and "right recursion" are just fine.  Why is left recursion
treated differently?  It just seems asymeteric and ad-hoc to me.

So either I've gotten stupider over the years, my brain is more in tune with
LALR grammers, or LL(k) grammers are simply harder to understand than LALR
grammers.  Why is it that people like ANTLR more than yacc/lex?  Why have I
had a different experience?

Background note: I've never studied the theory of compilers nor do I have a
degree in computer science.  However, I have been programming for 20 years
or so; 10 professionally.

More information about the antlr-interest mailing list