Re: Precedence rules for QuantifiedExpr - OrExpr - AndExpr

Peter Coppens wrote:
> 
> I always thought that the EBNF (A.1) and the precedence rules (A.4) contain
> "duplicate" information.

They should. Section A.4 bills itself as a summary of the precedence
defined in section A.1 (and thus, should perhaps be non-normative).

> In other words the non-terminals of the EBNF or
> chosen so that they "reduce" in a way that the operator priorities are
> implemented as expected. A.4 also says that in case of doubt (the same
> level), the rules are applied left to right (left associative I believe it
> is called in "grammar" lingo).
> ...
> The same reasoning led me to believe that
> 
> "some .... or ...." has to be interpreted as "(some ....) or (....)" and not
> as "some ... or ...."
> 
> Can you indicate where my failure is.

The failure is in the precedence table.

Parsing "some $v in $X satisfies A or B" as

                        OrExpr
                          |
             +------------+-----------+
             |            |           |
          AndExpr        "or"      AndExpr
             |                        |
        QuantifiedExpr                B
             |
    some $v in $X satisfies A

is disallowed by Section A.1, because AndExpr does not derive
QuantifiedExpr.

However, section A.4 does not convey this, which leads to confusion. The
fix is presumably to move "or" from precedence level 2 to a new level
between the current levels 2 and 3. I think this is what you meant by

> > (3) would it not be possible to add an extra level of precendence where
> > the OrExpr comes to sit between QuantifiedExpr and AndExpr

though I'm not sure.

-Michael Dyck

Received on Saturday, 20 December 2003 16:52:07 UTC