From: | "Arthur J. O'Dwyer" <ajo@andrew.cmu.edu> |
Newsgroups: | comp.compilers |
Date: | 19 Dec 2006 01:04:55 -0500 |
Organization: | Carnegie Mellon, Pittsburgh, PA |
References: | 06-09-029 06-09-042 06-09-048 06-09-060 06-09-078 06-09-093 06-12-064 06-12-066 |
Keywords: | C, parse |
Posted-Date: | 19 Dec 2006 01:04:55 EST |
On Sun, 17 Dec 2006, Robert A Duff wrote:
> Hans-Peter Diettrich <DrDiettrich1@aol.com> writes:
>> Tommy Thorn wrote:
>>> x * y;
>>> is a declation of a pointer to x or an expression multiplying x and y.
>>
>> A more practical example, found in this group already:
>> a = (b)-c;
>> is (b) a type cast, or an expression?
[...]
> P.S. Why do you say that the "a = (b)-c;" ambiguity is more practical
> than the "x * y;" ambiguity? They seem like more-or-less the same
> thing, to me: the parser wants to know whether each identifier is a type
> name.
They are the same thing, to the parser. However,
a = (b)-c;
might just possibly crop up in a program written by a human being, in
either of its meanings (if (b) were the result of macro expansion,
perhaps); whereas no human would ever write
x * y;
in its meaning of "multiply x and y, and then discard the result".
(Someone with less respect for the C standard's formal grammar might
say, "Why don't we just make x * y; always declare a new pointer, and
ignore that other case that never comes up in practice?" They can't
say that about a = (b)-c; .)
-Arthur
Return to the
comp.compilers page.
Search the
comp.compilers archives again.