Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@zwingli.cygnus.com>
To: Fernando Nasser <fnasser@redhat.com>
Cc: Elena Zannoni <ezannoni@cygnus.com>,
	Daniel Berlin <dan@cgsoftware.com>,
	gdb-patches@sources.redhat.com
Subject: Re: [RFA] linespec.c change to stop "malformed template specification"   error
Date: Thu, 07 Jun 2001 09:09:00 -0000	[thread overview]
Message-ID: <nplmn41dam.fsf@zwingli.cygnus.com> (raw)
In-Reply-To: <3B1F7A4B.4626F9D9@redhat.com>

Fernando Nasser <fnasser@redhat.com> writes:
> Jim Blandy wrote:
> > So how does our poor little decode_line_1 handle that?  Basically, we
> > need to replace decode_line_1 with a real parser.
> 
> It will be hard.  As it accepts a variety of types of input, there are
> ambiguities in the allowed syntax that are hard to describe in any
> formal language.

Don't worry about producing a grammar Bison would like.  We can write
N parsers, some of them Bison-based, some of them hand-coded, but each
one which handles a single case correctly and cleanly.  Then, we can
invoke them each in turn, and use the result from the first one which
doesn't return an error.  The C, C++, and other language parsers would
just be members of the list.

> Maybe we could improve things if GDB commands were parsed under some
> language context (e.g. care about C++ stuff or not) and even some
> host context (to distinguish filename syntaxes between Unix and
> Windows for instance).

Well, language is a per-compilation-unit kind of thing.  And the user
should just be able to say "break foo^..bratwurst" whenever
foo^..bratwurst is a well-defined breakpoint location, even if it's
not in the current compilation unit.

There's even a trick we can use to get our existing parsers to work
for this.  We don't need to write new grammars.

Right now, the start symbol for our C++ grammar is `start', which is
either an expression or a type.  Suppose we want to parse expressions,
types, and function names.  We make up three new magic token types:
START_EXPRESSION, START_TYPE, and START_FUNCTION_NAME.  We change the
syntax of our start symbol to be:

start   :	START_EXPRESSION exp1
	|	START_TYPE type_exp
        |       START_FUNCTION_NAME function_name
	;

(I don't think function_name exists yet, but that work is necessary no
matter how we do this.)

Then, we change our yylex function to return START_EXPRESSION,
START_TYPE, or START_FUNCTION_NAME as the first token, depending on
which one we want to parse.  These tokens don't correspond to
anything in the text stream at all --- they just serve to get the
parser in the right state to recognize what we're giving it.

But to be clear, we do *not* need to encode the full glory of
breakpoint locations here.  We extend the grammar to handle what it
can do naturally --- probably just template applications and
overloading.


  reply	other threads:[~2001-06-07  9:09 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-22 14:06 Daniel Berlin
2001-06-06 16:09 ` Elena Zannoni
2001-06-06 17:00   ` Fernando Nasser
2001-06-06 21:00   ` Jim Blandy
2001-06-06 22:09     ` Daniel Berlin
2001-06-07  8:40       ` Jim Blandy
2001-06-07  8:47       ` macro-expanding expressions in GDB Jim Blandy
2001-06-07  9:01         ` Daniel Berlin
2001-06-07 11:52           ` Jim Blandy
2001-06-07 12:04             ` Daniel Berlin
2001-06-07 11:16         ` Stan Shebs
2001-06-06 23:36     ` [RFA] linespec.c change to stop "malformed template specification" error Daniel Berlin
2001-06-07  6:00     ` Fernando Nasser
2001-06-07  9:09       ` Jim Blandy [this message]
2001-06-07  7:40     ` Elena Zannoni
     [not found]       ` <nppucg1eq5.fsf@zwingli.cygnus.com>
2001-06-07  9:13         ` Daniel Berlin
2001-06-07 11:18           ` Jim Blandy
2001-06-07 11:35             ` Daniel Berlin
2001-06-07 15:22               ` Jim Blandy
2001-06-07 16:40                 ` Daniel Berlin
2001-06-07 10:27         ` Elena Zannoni
2001-06-07 12:30           ` Fernando Nasser
2001-06-07 15:14           ` Jim Blandy

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=nplmn41dam.fsf@zwingli.cygnus.com \
    --to=jimb@zwingli.cygnus.com \
    --cc=dan@cgsoftware.com \
    --cc=ezannoni@cygnus.com \
    --cc=fnasser@redhat.com \
    --cc=gdb-patches@sources.redhat.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