Re: Generating a simple hand-coded like recursive descent parser

"Arthur J. O'Dwyer" <ajo@andrew.cmu.edu>
19 Dec 2006 01:04:55 -0500

          From comp.compilers

Related articles
[27 earlier articles]
Re: Generating a simple hand-coded like recursive descent parser phaywood@alphalink.com.au (2006-09-30)
Re: Generating a simple hand-coded like recursive descent parser DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-12-16)
Re: Generating a simple hand-coded like recursive descent parser bobduff@shell01.TheWorld.com (Robert A Duff) (2006-12-17)
Re: Generating a simple hand-coded like recursive descent parser tommy.thorn@gmail.com (Tommy Thorn) (2006-12-19)
Re: Generating a simple hand-coded like recursive descent parser gneuner2@comcast.net (George Neuner) (2006-12-19)
Re: Generating a simple hand-coded like recursive descent parser chris.dollin@hp.com (Chris Dollin) (2006-12-19)
Re: Generating a simple hand-coded like recursive descent parser ajo@andrew.cmu.edu (Arthur J. O'Dwyer) (2006-12-19)
Re: Generating a simple hand-coded like recursive descent parser 148f3wg02@sneakemail.com (Karsten Nyblad) (2006-12-19)
Re: Generating a simple hand-coded like recursive descent parser ik@unicals.com (Ivan A. Kosarev) (2006-12-19)
Re: Generating a simple hand-coded like recursive descent parser boldyrev@cgitftp.uiggm.nsc.ru (Ivan Boldyrev) (2006-12-19)
Re: Generating a simple hand-coded like recursive descent parser DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-12-19)
Re: Generating a simple hand-coded like recursive descent parser walter@bytecraft.com (Walter Banks) (2006-12-19)
Re: Generating a simple hand-coded like recursive descent parser cfc@shell01.TheWorld.com (Chris F Clark) (2006-12-19)
[4 later articles]
| List of all articles for this month |

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



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.