Re: parser



On Sep 11, 2:14 pm, "Remo D." <rd> wrote:
cr88192 ha scritto:

so, here is a mystery:
why do so many people prefer/promote parser generators over just writing out
a recursive descent parser?...

Probably because not all grammars can be parsed with a recursive descent
parser.

But not all parser generators can handle all grammars, and in some
cases their output is ugly.

Efficiency is another reason I can think of.

"Efficiency" is a vague term with the appearance of precision. This
appearance induces confusion in the mind of the reader, because once
something is labeled "efficient" it gains glamor (conversely for
"inefficient"). But long ago, Gerald Weinberg (in THE PSYCHOLOGY OF
COMPUTER PROGRAMMING) pointed out that there are at least two,
mutually irreducible forms of "efficiency": efficiency in the use of
computer resources (which had already been divided into CPU time
versus memory, and these two measures had already been found to be
inversely correlated) and people efficiency.

In most demotic programming circles, in fact, the word "efficiency"
means "it's my favorite solution. I understand it. I don't want to
think. Shut up. Mom!"

Lastly, writing a complex grammar can be a complex task in itself, it
would be nice if one hadn't to translate it in a programming language
and could rely on a parser generator to do the job.

Why? The translation (to a reasonably clean high level language) is a
valuable additional pass through the grammar and unless you are
skilled at mindless coding it can alert you to problems. I like
writing recursive descent parsers with a function for each production,
and I label the function with the production. Most productions are so
easy to code that I wonder why anybody ever bothered with yacc in the
first place save for a basic managerial hostility to programming and
programmers as such.

The Original Sin of computerdom was to label thinking as inefficient
and somehow the waste of scarce resources. It led, quickly enough, to
a profound anti-intellectualism shading to Fascism in the 1970s once
programmers misread the structured programming gospel as meaning that
"simplicity" meant "I don't have to think at all". It led to
widespread layoffs of women in computing, in my direct experience at
Bell Northern Research, in the 1980s when those women insisted that
the men under them had to take time to think, and could not
metaphorize their sedentary, subaltern, soft and passive roles as some
sort of Men's Adventure tale, in which without thinking they were able
to get things done like noble savages.

By the 1990s and as a result, many American programming shops were
fantasy worlds in which most of the programmers spent their time
playing games, surfing the Web, installing overpriced ERP solutions,
evaluating the valueless, trashing their coworkers like jealous maiden
aunts, and breaking working data bases and software for shits and
giggles.


R.D.

.