Prev: ?k???O?T?h???C
Next: JVM and java application
From: Robbo on 25 Jan 2010 17:46 I am just a man who like to know ;) I will not rest, if I do not solve this problem first. Robbo
From: Robbo on 25 Jan 2010 19:10 > I guess then your only path is chewing through the JLS, because no other > information outside of that context will make sense. I fixed "associativity" in my table, according to JLS. When there is "+" symbol, it means that it is confirmed according to JLS. If you ask, how about levels (precedence)? I have not made any progress. There is no exact information in JLS about precedences of many operators. Probably only way is to read grammar :( But on the other hand, I am not sure if grammar included such information as procedence of operators. Level Category Operator Associativity --------------------------------------------------------------- 1 postfix expr++ expr-- left --------------------------------------------------------------- 2 prefix ++expr --expr right+ unary +expr -expr logical NOT ! bitwise NOT ~ --------------------------------------------------------------- 3 cast (type) right+ --------------------------------------------------------------- 4 multiplicative * / % left+ --------------------------------------------------------------- 5 additive + - left+ --------------------------------------------------------------- 6 shift << >> >>> left+ --------------------------------------------------------------- 7 relational < <= > >= left+ type comparison instanceof --------------------------------------------------------------- 8 equality == != left+ --------------------------------------------------------------- 9 bitwise AND & left+ --------------------------------------------------------------- 10 bitwise XOR ^ left+ --------------------------------------------------------------- 11 bitwise OR | left+ --------------------------------------------------------------- 12 logical AND && left+ --------------------------------------------------------------- 13 logical OR || left+ --------------------------------------------------------------- 14 conditional ?: right+ --------------------------------------------------------------- 15 assignment = += -= *= /= right+ %= &= ^= |= <<= >>= >>>= ---------------------------------------------------------------
From: Joshua Cranmer on 25 Jan 2010 20:07 On 01/25/2010 07:10 PM, Robbo wrote: > --------------------------------------------------------------- > 2 prefix ++expr --expr right+ > unary +expr -expr > logical NOT ! > bitwise NOT ~ > --------------------------------------------------------------- > 3 cast (type) right+ Actually, UnaryExpressionNotPlusMinus contains CastExpression, so it is actually at the same precedence level as logical and bitwise NOT, which is one higher than the prefix/unary +/unary - (UnaryExpression contains PreIncrementExpression, PreDecrementExpression, and the unary +/unary -). But unary expression precedence is kind of a moot point. -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth
From: Lew on 25 Jan 2010 21:07 Mike Schilling wrote: > Lew wrote: > >> However, the JLS does refer to 'instanceof' as an >> operator. > > But it's not in the list of operators, so the JLS contradicts itself. > It really is the Java programmer's Bible! > > More seriously, the official JLS definition of "operator" describes > only operators made up of special characters; that is, it > distinguishes "operator" from "keyword". I was just going by <http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.20.2> entitled "Type Comparison Operator instanceof". That looks an awful lot like an "official JLS definition" to me. -- Lew
From: Lew on 25 Jan 2010 21:11
Robbo wrote: > Level Category Operator Associativity > --------------------------------------------------------------- > 1 postfix expr++ expr-- left As I was corrected upthread (perhaps you missed that post), there is no associativity for postfix operators. -- Lew |