public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mark Mitchell <mmitchell@usa.net>
To: mrs@wrs.com (Mike Stump)
Cc: egcs@cygnus.com
Subject: Re: Parsing templates as baseclasses
Date: Mon, 02 Mar 1998 20:02:00 -0000	[thread overview]
Message-ID: <199803021911.TAA28112@quickstep.stanford.edu> (raw)
In-Reply-To: <199803030157.RAA02370@kankakee.wrs.com>

>>>>> "Mike" == Mike Stump <mrs@wrs.com> writes:

    >> Date: Sun, 1 Mar 1998 17:02:45 GMT From: Mark Mitchell
    >> <mmitchell@usa.net>

    >> As we speak, I'm engaged in the process of redoing the
    >> cp/parse.y from scratch

    Mike> This is something that needs to be done.

    Mike> Do you understand the hard parsing issues with C++?  If you

Yes. 

    Mike> think the grammar in the standard is the be all end all in
    Mike> grammars, then I suspect there are things that you don't yet
    Mike> understand, and without that understanding, completing this
    Mike> project to the level of completeness that makes the project
    Mike> worthwhile will be hard.  Do you think the grammar in the
    Mike> standard just works?  If so, why?

I know very well that there are a host of ambiguities, and that the
grammar in the standard is not LALR(1).  In fact, I'm familiar with
all the problems you mentioned below.  It's those problems, and the
fact that g++ gets some of the wrong at the moment, that inspired my
work.  Jason and I have been discussing my proposed techniques in some
private email.  We've been debating my approach (still based on bison)
versus and a recursive-descent parser.

Of course, since C++ is not LALR(1) no pure bison approach will work.
In fact, no finite amount of lookahead will do.  As you know, there
are certain statements that could be either function or object
declarations, so it is occasionally necessary to do `trial parses' or
build multiple parse trees and pick the right one later, or something
like this.

My plan involves a hybrid approach, whereby bison is used to much of
the work, but where there will sometimes be recursive parsing calls to
do trial parses, or hand-parsing.  It is easy to make bison generate a
re-entrant parser, and it's possible to have bison parse certain
constructs "by hand", with a bit more work.

At present, I've still got some work to do.  However, the parser in
its current state uses no precedence declarations (one of the major
maintenance nightmares of the current parser, in my opinion), and is
down to a handful (literally) of conflicts that need to be resolved
correctly.

I've suggested that this hybrid approach will be simpler than a
completely by-hand approach, and will allow us to substitue
hand-written parsers as we find it necessary for speed, better
error-recover, of what have you.

Jason has pointed out that most (all?) vendors now use
recursive-descent parsers, and that they tend to provide better
error-recovery. 

At this point, I'm inclined to go a bit farther with my approach;
either I will hit an unanticipated technial snag, or suceed; in the
latter case, everyone will get a chance to see what I've done and
decide whether or not it is satisfactory.

-- 
Mark Mitchell		mmitchell@usa.net
Stanford University	http://www.stanford.edu


  reply	other threads:[~1998-03-02 20:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-03-03  1:08 Mike Stump
1998-03-02 20:02 ` Mark Mitchell [this message]
1998-03-04 13:54   ` Neal Becker
  -- strict thread matches above, loose matches on Subject: below --
1998-03-01 16:07 Martin von Loewis
1998-03-01 16:59 ` Mark Mitchell
1998-05-09  3:34   ` Martin von Loewis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199803021911.TAA28112@quickstep.stanford.edu \
    --to=mmitchell@usa.net \
    --cc=egcs@cygnus.com \
    --cc=mrs@wrs.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).