This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: c-exp.y
- From: David Carlton <carlton at math dot stanford dot edu>
- To: Paul Hilfinger <hilfingr at CS dot Berkeley dot EDU>
- Cc: gdb <gdb at sources dot redhat dot com>
- Date: 17 Dec 2002 13:59:07 -0800
- Subject: Re: c-exp.y
- References: <200212172143.NAA14438@tully.CS.Berkeley.EDU>
On Tue, 17 Dec 2002 13:43:22 -0800, Paul Hilfinger <hilfingr@CS.Berkeley.EDU> said:
>> Unfortunately, some sort of distinction between types and non-types
>> seems to be hard-wired into the parser at a deep level: it seems to
>> be the parser's job to actually evaluate expressions corresponding
>> to types, whereas other expressions get evaluated by somebody else.
> Yes. This is a well-known issue with C++ parsing.
I have heard that C++ parsing is a royal pain, but I'm not sure that's
the issue here: I suspect that GDB's problems are at a more basic
level. I suspect that the division of labor between what the
parse_expression does and what eval_expression does is a bit funny,
and I'm pretty sure that the rule
start : exp1
| type_exp
;
in the parser leads to some conceptual incoherence. Basically, what
the parser is trying to parse isn't a C++ expression (which, as you
point out, is ridiculously difficult if you really want to do it
correctly) but is instead either an expression or a type, so that the
same parser can be used unmodified for either GDB's 'print' command or
its 'ptype' command.
I could be wrong, though.
David Carlton
carlton@math.stanford.edu