Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!postnews.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 07 May 2012 04:48:24 -0500 Message-ID: <4FA79A67.5017@mindspring.com> Date: Mon, 07 May 2012 05:48:23 -0400 From: pete Reply-To: pfiland@mindspring.com Organization: PF X-Mailer: Mozilla 3.04Gold (WinNT; I) MIME-Version: 1.0 Newsgroups: comp.lang.c Subject: Re: Operator precedence. References: <76630b90-04ab-4976-b1a0-76868d85ccf5@vy9g2000pbc.googlegroups.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 35 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.154.216.54 X-Trace: sv3-UyhZOgzegjlU0Z/cmT3C1pJ7tEX3Lu8QOnA4gHEdfS96pOvd6X1SFPqF7ytXldXJ9QZQGHzXf+M/iz6!t+PcqouCF++Z21JrvS4KtR0lApZ7W9oDeE+I/6YfasQjhB1uAZR8LqLrmt6DYF33Gw9L3owc6/Ow!vQmgMUQPAw== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2361 Xref: csiph.com comp.lang.c:20443 somenath wrote: > > Hi All, > > While browsing through the old article in this group I have come > across one article by Chrish Torek. > http://groups.google.com/group/gnu.gcc.help/browse_thread/thread/31750b84b212325/d97a0f655e96ce16?lnk=gst&q=compiler+munching+%2B++chrish+torek#d97a0f655e96ce16 > > In this article he said. > > "Finally, let me say one last time that the Standard C grammar DOES > NOT use operator precedence. (At most, one can say that the grammar > "implies" a precedence. I believe the word "specifies" is too > strong, despite its appearance in a non-normative footnote." > > So the following expression > > 2+3*5; > is equal to 17. For human * has higher precedence than + so * > operator will be first operated on 3*5 and then the resultant will be > added to 2. So the result will be 2+(3*5) . > > Then my question is how C compiler with out bothering about precedence > produce the same result as 2+(3*5). > > I tried to explain myself the outcome of 2+3*5 the way Chris Torek > has explained the expression -- - x but I am not able to construes > how the precedence of * will be enforced by the C grammar with out > using operator precedence. I can't do it either. I use the precedence table in chapter 2 of K&R instead. -- pete