Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: programming puzzle (silly) Message-ID: <9846@smoke.BRL.MIL> Date: 14 Mar 89 01:56:19 GMT References: <24820@amdcad.AMD.COM> <218@umigw.MIAMI.EDU> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 21 In article <218@umigw.MIAMI.EDU> steve@umigw.miami.edu (steve emmerson) writes: >In article <24820@amdcad.AMD.COM> tim@amd.com (Tim Olson) opines that the >expression "n&&m*=n--" is incorrect C: >I belive the correctness of a expression is determined by whether or not >the expression can be *generated from* the grammer's production rules; not >whether or not a given implementation of a compiler can parse it. Right. >The given expression is correct C as it can be generated by the following >rules: I didn't much like your particular production. Using the pANS grammar, the conclusion that the parse is NOT effectively "(n&&m) *= n--" is a correct deduction; the key point is that "n&&m" cannot possibly be parsed as anything that is allowed as the left operand of the assignment expression (called a "unary expression" in the pANS grammar). However, the grammar does not support the production you gave, either. At least one set of parentheses would have to be added to obtain a valid expression. The phrase-structure grammar does not in general allow arbitrary expressions as operands, only limited classes of expressions.