Re: Parser Generated vs. Hand Written Parsers

Hans-Peter Diettrich <DrDiettrich1@aol.com>
26 Sep 2006 10:02:03 -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: Hans-Peter Diettrich <DrDiettrich1@aol.com>
Newsgroups: comp.compilers
Date: 26 Sep 2006 10:02:03 -0400
Organization: Compilers Central
References: 06-09-138 06-09-141
Keywords: parse
Posted-Date: 26 Sep 2006 10:02:03 EDT

Scott Nicol wrote:


> [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]


Obviously you assume that a language and an according grammar already
exist. IMO these are two assumptions too much, in most real-life cases ;-)


Provided that a binding grammar is given, I can imagine *no* excuses for
*not* using an parser generator. But in all other cases...


When a language is not already specified in a valid formal grammar, it's
usually easier to handcraft an according parser, instead of writing a
formal grammar, that usually doesn't cover all semantical details of the
language. In the handcrafted parser many ambiguities can be solved in an
ad-hoc manner, easier and cleaner than by bloating a formal grammar
until the parser generator is happy with it - what does not necessarily
mean that the generated parser *really* reflects the language specification!


OTOH many modern languages IMO suffer from a poor design, resulting from
a formal grammar that was *not* checked by a parser generator. If it's
necessary to write an new parser generator, in order to produce an valid
parser for a formal grammar, the language most probably is crap. IMO it
were easier, in most cases, to start by writing an parser for a new
language, including the most important semantical actions, so that it's
known that the implied syntax matches all semantical requirements. Then
one can decide to either use an existing parser generator, that matches
the requirements of parsing the language, or to stay with the
preliminary parser, leaving it to somebody else to invent a new grammar
formalism and according parser generator, as a work of love <gd&r>


DoDi
[One of the most common reasons to use a hand-written parser is to
match the behavior of some prior parser that doesn't implement any
sort of formally describable grammar. -John]



Post a followup to this message

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