Re: Dangling else

Dave Thompson <david.thompson1@worldnet.att.net>
5 Mar 2006 02:18:54 -0500

          From comp.compilers

Related articles
[3 earlier articles]
Re: Dangling else rsc@swtch.com (Russ Cox) (2006-02-24)
Re: Dangling else rsc@swtch.com (Russ Cox) (2006-02-24)
Re: Dangling else wyrmwif@tsoft.org (SM Ryan) (2006-03-05)
Re: Dangling else wyrmwif@tsoft.org (SM Ryan) (2006-03-05)
Re: Dangling else jvorbrueggen-not@mediasec.de (=?ISO-8859-1?Q?Jan_Vorbr=FCggen?=) (2006-03-05)
Re: Dangling else henry@spsystems.net (2006-03-05)
Re: Dangling else david.thompson1@worldnet.att.net (Dave Thompson) (2006-03-05)
Re: Dangling else mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2006-03-06)
Re: Dangling else rsc@swtch.com (Russ Cox) (2006-03-06)
Re: Dangling else marcov@stack.nl (Marco van de Voort) (2006-03-11)
Re: Dangling else Brian.Inglis@SystematicSW.ab.ca (Brian Inglis) (2006-03-11)
Re: Dangling else henry@spsystems.net (2006-03-14)
Re: Dangling else 148f3wg02@sneakemail.com (Karsten Nyblad) (2006-03-15)
[3 later articles]
| List of all articles for this month |
From: Dave Thompson <david.thompson1@worldnet.att.net>
Newsgroups: comp.compilers
Date: 5 Mar 2006 02:18:54 -0500
Organization: AT&T Worldnet
References: 06-02-154 06-02-168
Keywords: parse
Posted-Date: 05 Mar 2006 02:18:54 EST

On 24 Feb 2006 13:20:47 -0500, "Russ Cox" <rsc@swtch.com> wrote:


> It doesn't make any sense at all to me to say, as the ANSI C grammar does:
<snip example>
> Should I really have to know, when writing the relational_expression
> rules, that shift_expression is the next level down in the precedence


(I agree) that's a nuisance -- the names aren't very meaningful; they
are in effect (as you said and I snipped) mechanically generated.


> hierarchy? What if some new operator comes along later that I want
> to put between them? Then I have to go find all the rules that implicitly
> "know" that shift comes after relational.
>
But that's not the problem -- they have to always be adjacent levels,
hence in one place if you organize the grammar by NT, or you don't
have (fully-ordered) precedence. In fact C has two places that aren't
expressible as precedence:
    - (int) x is - ( (int) x ) but (int) -x is (int) (- x)
    x = a ? b , c : d is x = (a? (b, c): d) but
    a ? b : d , e is (a?b:d) , e.
C++ shares the former but partially fixes the latter by going down to
assignment-expression (but still not expression).


and on 24 Feb 2006 18:03:20 -0500, "Russ Cox" <rsc@swtch.com> wrote:


> > [<snip> How do you like
> > the APL rule that everything binds and associates the same? -John]
>
> I haven't used APL much, but troff expressions have the same
> rule--everything left to right, equal precedence <snip>


Same idea but not same rule. APL is right to left.


- David.Thompson1 at worldnet.att.net



Post a followup to this message

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