http://www.haskell.org/~simonmar/haskell-2010-draft-report-2/haskellch3.html

infixexp →      lexp qop infixexp (infix operator application)
        |       - infixexp        (prefix negation)
        |       lexp

This grammar rule describes a right associative nesting of (any) infix
operators "qop" and prefix negation as binding weaker than any infix.

Thus a parser would create from "- 1 /= 1 && a" the tree
 "- (1 /= (1 && a))".

Would it not be better to give an ambiguous grammar and leave it to the
infix resolution algorithm to allow only the intended trees, rather than
letting the infix resolution algorithm correct a wrong tree?

My suggestion would be to change the rule to:

infixexp →      infixexp qop infixexp (infix operator application)
        |       - infixexp        (prefix negation)
        |       lexp

thus only replacing the first lexp by infixexp.

Cheers Christian

_______________________________________________
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime

Reply via email to