17 Feb 2005 11:04
double checking precedence rules
A couple of operators are missing in the New Groovy grammar which I've
just added - I wanted to double check folks thought the precedence
rules look OK; they may need a bit of tweaking...
// lowest (13) = *= /= %= += -= <<= >>= >>>= &= ^= |=
// (12) ?:
// (11) ||
// (10) &&
// ( 9) |
// ( 8) ^
// ( 7) &
// ( 6) == != <=>
// ( 5) < <= > >=
// ( 4) << >>
// ( 3) +(binary) -(binary)
// ( 2) * / %
// ( 1) ++ -- +(unary) -(unary) ~ ! (type)
// [] () (method call) . (dot -- identifier qualification)
// new () (explicit parenthesis)
I've put <=> the comparator operator which works like this...
a <=> b
is equivalent to
a.compareTo(b)
at the same precedence as != and ==. Does that fit? Its kinda like an
operator that does both level 5 and 6 combined into one numeric result
(rather than binary true/false)
Also we need to fit in the regex operators
=~ (find)
==~ (match)
Should we put these in an existing bucket? Currently I've dropped them
in 9.5 as a starting place - anyone have any better ideas?
James
-------
http://radio.weblogs.com/0112098/
RSS Feed