Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add hashed labels to expression rule in JavaParser #4310

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 40 additions & 27 deletions java/java/JavaParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -599,46 +599,59 @@ methodCall
expression
// Expression order in accordance with https://introcs.cs.princeton.edu/java/11precedence/
// Level 16, Primary, array and member access
: primary
| expression '[' expression ']'
: primary #PrimaryExpression
| expression '[' expression ']' #SquareBracketExpression
| expression bop = '.' (
identifier
| methodCall
| THIS
| NEW nonWildcardTypeArguments? innerCreator
| SUPER superSuffix
| explicitGenericInvocation
)
) #MemberReferenceExpression
// Method calls and method references are part of primary, and hence level 16 precedence
| methodCall
| expression '::' typeArguments? identifier
| typeType '::' (typeArguments? identifier | NEW)
| classType '::' typeArguments? NEW
| switchExpression // Java17
| methodCall #MethodCallExpression
| expression '::' typeArguments? identifier #MethodReferenceExpression
| typeType '::' (typeArguments? identifier | NEW) #MethodReferenceExpression
| classType '::' typeArguments? NEW #MethodReferenceExpression

// Java17
| switchExpression #ExpressionSwitch

// Level 15 Post-increment/decrement operators
| expression postfix = ('++' | '--')
| expression postfix = ('++' | '--') #PostIncrementDecrementOperatorExpression

// Level 14, Unary operators
| prefix = ('+' | '-' | '++' | '--' | '~' | '!') expression
| prefix = ('+' | '-' | '++' | '--' | '~' | '!') expression #UnaryOperatorExpression

// Level 13 Cast and object creation
| '(' annotation* typeType ('&' typeType)* ')' expression
| NEW creator
| '(' annotation* typeType ('&' typeType)* ')' expression #CastExpression
| NEW creator #ObjectCreationExpression

// Level 12 to 1, Remaining operators
| expression bop = ('*' | '/' | '%') expression // Level 12, Multiplicative operators
| expression bop = ('+' | '-') expression // Level 11, Additive operators
| expression ('<' '<' | '>' '>' '>' | '>' '>') expression // Level 10, Shift operators
| expression bop = ('<=' | '>=' | '>' | '<') expression // Level 9, Relational operators
| expression bop = INSTANCEOF (typeType | pattern)
| expression bop = ('==' | '!=') expression // Level 8, Equality Operators
| expression bop = '&' expression // Level 7, Bitwise AND
| expression bop = '^' expression // Level 6, Bitwise XOR
| expression bop = '|' expression // Level 5, Bitwise OR
| expression bop = '&&' expression // Level 4, Logic AND
| expression bop = '||' expression // Level 3, Logic OR
| <assoc = right> expression bop = '?' expression ':' expression // Level 2, Ternary
// Level 12, Multiplicative operators
| expression bop = ('*' | '/' | '%') expression #BinaryOperatorExpression
// Level 11, Additive operators
| expression bop = ('+' | '-') expression #BinaryOperatorExpression
// Level 10, Shift operators
| expression ('<' '<' | '>' '>' '>' | '>' '>') expression #BinaryOperatorExpression
// Level 9, Relational operators
| expression bop = ('<=' | '>=' | '>' | '<') expression #BinaryOperatorExpression
| expression bop = INSTANCEOF (typeType | pattern) #InstanceOfOperatorExpression
// Level 8, Equality Operators
| expression bop = ('==' | '!=') expression #BinaryOperatorExpression
// Level 7, Bitwise AND
| expression bop = '&' expression #BinaryOperatorExpression
// Level 6, Bitwise XOR
| expression bop = '^' expression #BinaryOperatorExpression
// Level 5, Bitwise OR
| expression bop = '|' expression #BinaryOperatorExpression
// Level 4, Logic AND
| expression bop = '&&' expression #BinaryOperatorExpression
// Level 3, Logic OR
| expression bop = '||' expression #BinaryOperatorExpression
// Level 2, Ternary
| <assoc = right> expression bop = '?' expression ':' expression #TernaryExpression
// Level 1, Assignment
| <assoc = right> expression bop = (
'='
Expand All @@ -653,10 +666,10 @@ expression
| '>>>='
| '<<='
| '%='
) expression
) expression #BinaryOperatorExpression

// Level 0, Lambda Expression
| lambdaExpression // Java8
// Level 0, Lambda Expression // Java8
| lambdaExpression #ExpressionLambda
;

// Java17
Expand Down