You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2015/06/22 13:49:46 UTC
incubator-groovy git commit: align comments with implementation
Repository: incubator-groovy
Updated Branches:
refs/heads/master 0dc6cffce -> cabc132da
align comments with implementation
Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/cabc132d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/cabc132d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/cabc132d
Branch: refs/heads/master
Commit: cabc132da8209e1df53b4ecb6aba6f41afc0b9f1
Parents: 0dc6cff
Author: Paul King <pa...@asert.com.au>
Authored: Mon Jun 22 21:49:33 2015 +1000
Committer: Paul King <pa...@asert.com.au>
Committed: Mon Jun 22 21:49:33 2015 +1000
----------------------------------------------------------------------
src/main/org/codehaus/groovy/antlr/groovy.g | 69 ++++++++++++------------
1 file changed, 34 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/cabc132d/src/main/org/codehaus/groovy/antlr/groovy.g
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/antlr/groovy.g b/src/main/org/codehaus/groovy/antlr/groovy.g
index 2cc12f2..9b5786d 100644
--- a/src/main/org/codehaus/groovy/antlr/groovy.g
+++ b/src/main/org/codehaus/groovy/antlr/groovy.g
@@ -2342,27 +2342,28 @@ commandArgument
// nextHigherPrecedenceExpression
// (OPERATOR nextHigherPrecedenceExpression)*
// which is a standard recursive definition for a parsing an expression.
-// The operators in java have the following precedences:
-// lowest ( 15) = **= *= /= %= += -= <<= >>= >>>= &= ^= |=
+// The operators have the following precedences:
+// lowest ( 15) = **= *= /= %= += -= <<= >>= >>>= &= ^= |= (assignments)
// ( 14) ?: (conditional expression and elvis)
-// ( 13) ||
-// ( 12) &&
-// ( 11) |
-// ( 10) ^
-// ( 9) &
-// (8.5) =~ ==~
-// ( 8) == != <=> === !==
-// ( 7) < <= > >= instanceof as in
-// ( 6) << >> .. ..<
-// ( 5) +(binary) -(binary)
-// ( 4) * / %
-// ( 3) **(power)
-// ( 2) ++(pre) --(pre) +(unary) -(unary)
-// ( 1) ~ ! $ (type) ++(post) --(post)
-// . ?. *. (dot -- identifier qualification)
-// [] () (method call) {} (closableBlock) [] (list/map)
-// new () (explicit parenthesis)
-// $x (scope escape)
+// ( 13) || (logical or)
+// ( 12) && (logical and)
+// ( 11) | ()binary or
+// ( 10) ^ (binary xor)
+// ( 9) & (binary and)
+// (8.5) =~ ==~ (regex find/match)
+// ( 8) == != <=> === !== (equals, not equals, compareTo)
+// ( 7) < <= > >= instanceof as in (relational, in, instanceof, type coercion)
+// ( 6) << >> >>> .. ..< (shift, range)
+// ( 5) + - (addition, subtraction)
+// ( 4) * / % (multiply div modulo)
+// ( 3) ++ -- + - (pre dec/increment, unary signs)
+// ( 2) ** (power)
+// ( 1) ~ ! $ (type) (negate, not, typecast)
+// ?. * *. *: (safe dereference, spread, spread-dot, spread-map)
+// . .& .@ (member access, method closure, field/attribute access)
+// [] ++ -- (list/map/array index, post inc/decrement)
+// () {} [] (method call, closableBlock, list/map literal)
+// new () (object creation, explicit parenthesis)
//
// the last two are not usually on a precedence chart; I put them in
// to point out that new has a higher precedence than '.', so you
@@ -2840,12 +2841,21 @@ multiplicativeExpression[int lc_stmt]
| ( powerExpressionNotPlusMinus[lc_stmt] ((STAR^ | DIV^ | MOD^ ) nls! powerExpression[0])* )
;
-// math power operator (**) (level 3)
+// ++(prefix)/--(prefix)/+(unary)/-(unary) (level 3)
+unaryExpression[int lc_stmt]
+ : INC^ nls! unaryExpression[0]
+ | DEC^ nls! unaryExpression[0]
+ | MINUS^ {#MINUS.setType(UNARY_MINUS);} nls! unaryExpression[0]
+ | PLUS^ {#PLUS.setType(UNARY_PLUS);} nls! unaryExpression[0]
+ | unaryExpressionNotPlusMinus[lc_stmt]
+ ;
+
+// math power operator (**) (level 2)
powerExpression[int lc_stmt]
: unaryExpression[lc_stmt] (STAR_STAR^ nls! unaryExpression[0])*
;
-// math power operator (**) (level 3)
+// math power operator (**) (level 2)
// (without ++(prefix)/--(prefix)/+(unary)/-(unary))
// The different rules are needed to avoid ambiguous selection
// of alternatives.
@@ -2853,20 +2863,9 @@ powerExpressionNotPlusMinus[int lc_stmt]
: unaryExpressionNotPlusMinus[lc_stmt] (STAR_STAR^ nls! unaryExpression[0])*
;
-// ++(prefix)/--(prefix)/+(unary)/-(unary) (level 2)
-unaryExpression[int lc_stmt]
- : INC^ nls! unaryExpression[0]
- | DEC^ nls! unaryExpression[0]
- | MINUS^ {#MINUS.setType(UNARY_MINUS);} nls! unaryExpression[0]
- | PLUS^ {#PLUS.setType(UNARY_PLUS);} nls! unaryExpression[0]
- | unaryExpressionNotPlusMinus[lc_stmt]
- ;
-
// ~(BNOT)/!(LNOT)/(type casting) (level 1)
unaryExpressionNotPlusMinus[int lc_stmt]
- : //BAND^ {#BAND.setType(MEMBER_POINTER_DEFAULT);} nls! namePart
- //|
- BNOT^ nls! unaryExpression[0]
+ : BNOT^ nls! unaryExpression[0]
| LNOT^ nls! unaryExpression[0]
| ( // subrule allows option to shut off warnings
options {
@@ -2894,7 +2893,7 @@ unaryExpressionNotPlusMinus[int lc_stmt]
)
;
-// qualified names, array expressions, method invocation, post inc/dec
+// qualified names, array expressions, method invocation, post inc/dec (level 1)
postfixExpression[int lc_stmt]
:
pathExpression[lc_stmt]