The following passages differ on the status of (a+b+):

   3  Expressions

   aexp -> ...
         | ( expi+1 qop(a,i) )       (left section)
         | ( qop(a,i) expi+1 )       (right section)

   3.5  Sections

   Syntactic precedence rules apply to sections as follows.  (op e) is
   legal if and only if (x op e) parses in the same way as (x op (e));
   and similarly for (e op). For example, (*a+b) is syntactically invalid,
   but (+a*b) and (*(a+b)) are valid. Because (+) is left associative,
   (a+b+) is syntactically correct, but (+a+b) is not; the latter may
   legally be written as (+(a+b)).

ghc follows the grammar, rejecting (a+b+)
Hugs accepts (op a op' b) and rejects (a op b op') regardless of
associativity and precedence, while nhc accepts them both.

The grammar could be made to match the text by adding two alternatives:

         | ( lexpi qop(l,i) )       (left section)
         | ( qop(r,i) rexpi )       (right section)

Changing the text to match the grammar seems less attractive.

But the text says more than the revised grammar.  For example, it deals
with the expression glitch I mentioned the other week: together with
the disambiguation meta-rule, it implies that the expression

        (let x = 10 in x `div`)

is invalid, because

        let x = 10 in x `div` z

doesn't parse as (let x = 10 in x) `div` z

(might be worth adding this as an example)
but it's no help with SimonM's example

        let x = 10 in x == x == True
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to