On 09/06/2010 06:49 AM, Attila Szegedi wrote:
parsing is hard (well, unless your language is LISP). You'll end up wasting lot 
of time on debugging your parser. Worse, if later you'll want to extend your 
grammar, you'll likely realize that too is hard in a handwritten parser as 
you'll have to modify a lot of it. Parser generators exist for a reason; they 
do a tremendous amount of mundane work instead of you. I would never write a 
lexer/parser by hand, unless the goal is to amuse myself with exactly that.

As an old curmudgeon, I still prefer a hard-written recursive-descent
parser.  It's simple, efficient, and much easier to debug.  You can set
a breakpoint in the parser and inspect the parser state.  You don't have
IDEs getting confused.  Yes, some parser-generators have debugging tools
and IDE interfaces, but that's more stuff you need to install and understand.

(For typical arithmetic with infix operators, one uses an operator
precedence sub-parser.)

Error recovery is a mixed issue: It is easier and more flexible to add
recovery in a hand-written parser, but this is where a generator could pay
off - but note that (for example) learning how to use ANTLR's error
recovery features is another learning hump.

More appealing seems to be a parser library (or language feature), as in
Perl 6 or Scala, but I don't experience with those.
--
        --Per Bothner
[email protected]   http://per.bothner.com/

--
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en.

Reply via email to