On 06/07/2010 13:17, Christian Maeder wrote:
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))".
The grammar is non-ambiguous and all you have to do is flatten the
result to apply fixity resolution. I don't really see how generalising
the grammar would help - the tree still has to be flattened to apply
fixity resolution, and the parser would have to make an arbitrary choice
from one of the possible parses. Or perhaps I'm missing something here?
Cheers,
Simon
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
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-prime
_______________________________________________
Haskell-prime mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-prime