Re: Parser Generated vs. Hand Written Parsers

Scott Nicol <snicol@apk.net>
26 Sep 2006 01:07:28 -0400

          From comp.compilers

Related articles
Parser Generated vs. Hand Written Parsers samhng@gmail.com (=?iso-8859-1?B?bW9vcJk=?=) (2006-09-25)
Re: Parser Generated vs. Hand Written Parsers DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-09-26)
Re: Parser Generated vs. Hand Written Parsers snicol@apk.net (Scott Nicol) (2006-09-26)
Re: Parser Generated vs. Hand Written Parsers DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-09-26)
Re: Parser Generated vs. Hand Written Parsers tom@infoether.com (Tom Copeland) (2006-09-28)
Re: Parser Generated vs. Hand Written Parsers napi@axiomsol.com (napi) (2006-09-28)
Re: Parser Generated vs. Hand Written Parsers rmathew@gmail.com (Ranjit Mathew) (2006-09-28)
Re: Parser Generated vs. Hand Written Parsers martin_filteau@yahoo.ca (Martin Filteau) (2006-09-28)
Re: Parser Generated vs. Hand Written Parsers spamers.sollen.sterben@cablenet.de (VergissMeinNicht) (2006-09-28)
| List of all articles for this month |
From: Scott Nicol <snicol@apk.net>
Newsgroups: comp.compilers
Date: 26 Sep 2006 01:07:28 -0400
Organization: Compilers Central
References: 06-09-138
Keywords: parse, comment
Posted-Date: 26 Sep 2006 01:07:28 EDT

moop wrote:
> PGs have a great convenince over hand written parsers, but they also
> slow in speed and hard to read the generated code.


Most parser generators generate quite tight code. If a parser
generator produces bad code, fix it and you've sped up all parsers
written for this generator. Hand written parsers are all over the
map, but often on the slow end.


Ungenerated PG code is incredibly easy to read, you don't usually need
to bother to look at the generated code. But even the generated code
is usually much cleaner than hand written parsers.


In addition, you don't have to guess the grammar of PG code -- it is
staring you in the face. PGs also help in detecting ambiguities in a
grammar.


> I wonder besides these two obvious factors, what else hand written
> parsers are better than PGs? Thank you!


These two obvious factors tend to support PG parsers, not hand written.
    Advantages of hand written parsers are hard to come by.
--
Scott Nicol
snicol@apk.net
[The best thing about a generated parser is that you actually know
what grammar it parses. You have to be very disciplined to write a
parser by hand that only accepts the language in the grammar you
started from, and it's way too easy to goof and fail to catch some
erroneous inputs. -John]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.