comp.lang.ada
 help / color / mirror / Atom feed
From: Cesar Rabak <csrabak@uol.com.br>
Subject: Re: Ada 95 grammar for aflex?
Date: Sat, 20 Jan 2001 14:19:27 -0200
Date: 2001-01-20T14:19:27-02:00	[thread overview]
Message-ID: <3A69BA8F.A26A531E@uol.com.br> (raw)
In-Reply-To: 94c7eq$i89$1@nnrp1.deja.com



Robert Dewar wrote:
> >
> > But, IIRC, it was hand made and not written in a language
> like
> > [f]lex/yacc. Did this change?
> 
> No, but the question (see quote above) was a request
> specifically for information on the GNAT lexical analyzer.

Yes, I just understood that the OP was thinking of a "grammar" file.

> 
> To use something like lex for a lexical analyzer in a
> production compiler is a real mistake, because the resulting
> lexical analyzer is much less efficient than a straightforward
> hand written analyzer, tends to produce much worse error
> messages, and saves a negligible amount of effort.

I second this, we learned this by hard way while working in a parser for
ASN.1 in the earlier 90s...

> 
> Lex is fine for occasional use in generating command language
> user interfaces, but it not a tool for real compilers.
> 
> As for yacc, this particular tool is dreadfully out of date,
> generates perfectly awful error messages (since it is not
> informed by decades of work on error recovery), and also if
> you are not careful tends to generate slow parsers.
> 
> As for the issue of whether a modern up to date parser
> generator (see the work of Fisher and Charles, IBM and NYU,
> in this area, which was used for Ada/Ed) is the right choice,
> or a hand written parser, that's still an arguable discussion.

I was thinking exactly if this had changed, and it seems that not. Thank
you for the present status!

> 
> GNAT is a hand written parser, and is intended as a
> demonstration of what can be achieved by hand writing parsers
> with respect to error recovery (e.g. its ability to distinguish
> between semicolon and IS in subprograms and correct wrong
> usage).

I remember this being discussed in an earlier paper describing GNAT (and
GIGI) by NYU. I passed that to my professors in compiler design at that
time (after I finished their courses just in case!).

> 
> Recently there have been discussions of the parser in g++.
> Amazingly, this parser takes significant time, indicating one
> of the results of less than careful use of automated parsers.
> Parsing should take no detectable time if a parser is well
> written. There is by the way an active funded project to
> replace the g++ parser with a hand written version.

If this is a consolation. B. Stroustrup in his book "The Design and
Evolution of C++" reports that "...in retrospect, for me and C++ it was
a bad mistake [to use YACC].", pg. 69.

On your lines it continues with "...C++ was not a new experimental
language, it was an almost compatible superset of C - and at that time
nobody had been able to write an LARL(1) grammar for C. The LARL(1)
grammar used by ANSI C was constructed by Tom Pennello about a year and
half later - far too late to benefit me and C++."

So it seems that it still holds: if you're developing a professional
compiler, do it by hand!

Cesar



  reply	other threads:[~2001-01-20 16:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-18 14:54 Ada 95 grammar for aflex? Ralf Reißing
2001-01-18 15:07 ` Frode Tenneboe
2001-01-18 15:37 ` Ted Dennison
2001-01-19 11:15 ` Mario Amado Alves
2001-01-19 16:36   ` Robert Dewar
2001-01-19 18:29     ` Cesar Rabak
2001-01-20 14:30       ` Robert Dewar
2001-01-20 16:19         ` Cesar Rabak [this message]
2001-01-20 19:25           ` Robert Dewar
2001-01-21  1:55             ` Cesar Rabak
2001-01-21 16:01               ` Robert Dewar
2001-01-22 15:58               ` Ira D. Baxter
2001-01-22 17:32                 ` Robert Dewar
2001-01-21  4:46             ` Larry Hazel
2001-01-21 16:02               ` Robert Dewar
2001-01-21 17:30                 ` Larry Hazel
2001-01-21 22:42                   ` Larry Kilgallen
2001-01-23  4:16                     ` Warren W. Gay VE3WWG
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox