comp.lang.ada
 help / color / mirror / Atom feed
From: "Ira D. Baxter" <idbaxter@semdesigns.com>
Subject: Re: Ada 95 grammar for aflex?
Date: Mon, 22 Jan 2001 09:58:31 -0600
Date: 2001-01-22T09:58:31-06:00	[thread overview]
Message-ID: <t6olt4ohqu4la7@corp.supernews.com> (raw)
In-Reply-To: 3A6A418E.80F1ADC@uol.com.br


> > Robert Dewar wrote:
> >
> > In article <3A69BA8F.A26A531E@uol.com.br>,
> >   Cesar Rabak <csrabak@uol.com.br> wrote:
> > > On your lines it continues with "...C++ was not a new
> > > experimental language, it was an almost compatible superset
> > > of C - and at that tim 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++."
> >
> > I find that a bit odd, there has been no problem in
> > constructing the necessary grammars for parsing C with these
> > kind of tools, and they have been around for years, but that's
> > not the issue.
> >
> > The issues are
> >
> > a) these tools generate rather slow parsers. This is fixable.

And maybe it doesn't matter that much.  After all, if parsing is only 10%
of the compile time...

> >
> > b) these tools generate junk error messages. This is also
> > quite fixable. ...

> > If you are not interested in error recovery, there is
> > absolutely no difficulty in writing a table driven parser
> > for C++.

Even if you are interested in error recovery, you can build
good error recovery in a table driven parser.
You just can't use the simple hack provided by YACC and its clones.

> > To be fair, many other C++ compilers give equally horrible
> > error messages, but they do not seem to suffer from the time
> > penalty in parsing to such an extent.
>
> > Parsing should take zero time. In my assembly language scanner
> > and parser for Ada 83, which runs at something approaching
> > ten million lines a minute on a fast PC, perhaps more, I have
> > not run it for a while, parsing takes less than 10% of the
> > total time (the rest is I/O and lexical analysis).

That's impressively fast, but it depends on what you mean by "parsing".
Our automatically generated
parsers automatically capture identifier
and other kinds of strings and place them in string dictionaries,
carry out integer and floating point value conversions,
produce abstract syntax trees,
capture and attach comments and source line information
to AST nodes, etc.

If you stick to just and-coded lexing and recursive descent recognition,
you can go pretty fast.  When you start to add other work,
(all the above) it slows down some (remember Amdahl's law).

Its still OK.  Even with all
extra work, and not a lot of optimization, we manage
to generate parsers that do several thousand lines per second
(180K lines/minute).   We assume with hard work
(the kind you do to produce "assembly langauge parsers"),
we can generate parsers that are twice as fast.


--
Ira D. Baxter, Ph.D.,CTO           email: idbaxter@semdesigns.com
Semantic Designs, Inc.              web: http://www.semdesigns.com
12636 Research Blvd. C-214    voice: (512) 250-1018 x140
Austin, TX 78759-2200             fax: (512) 250-1191






  parent reply	other threads:[~2001-01-22 15:58 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
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 [this message]
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