diff --git a/java/java/JavaParser.g4 b/java/java/JavaParser.g4 index a240eb308b..54a8a728ea 100644 --- a/java/java/JavaParser.g4 +++ b/java/java/JavaParser.g4 @@ -39,7 +39,7 @@ options { } compilationUnit - : packageDeclaration? (importDeclaration | ';')* (typeDeclaration | ';')* + : packageDeclaration? (importDeclaration | ';')* (typeDeclaration | ';')* EOF | moduleDeclaration EOF ; @@ -599,8 +599,8 @@ 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 @@ -608,37 +608,50 @@ expression | 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 - | 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 + | expression bop = '?' expression ':' expression #TernaryExpression // Level 1, Assignment | expression bop = ( '=' @@ -653,10 +666,10 @@ expression | '>>>=' | '<<=' | '%=' - ) expression + ) expression #BinaryOperatorExpression - // Level 0, Lambda Expression - | lambdaExpression // Java8 + // Level 0, Lambda Expression // Java8 + | lambdaExpression #ExpressionLambda ; // Java17 diff --git a/java/java/examples/ExpressionOrder.java.tree b/java/java/examples/ExpressionOrder.java.tree index f12cc6298f..62ec078221 100644 --- a/java/java/examples/ExpressionOrder.java.tree +++ b/java/java/examples/ExpressionOrder.java.tree @@ -1 +1 @@ -(compilationUnit (importDeclaration import (qualifiedName (identifier java) . (identifier util) . (identifier regex) . (identifier Pattern) . (identifier CharPredicate)) ;) (typeDeclaration (classOrInterfaceModifier public) (classDeclaration class (identifier ExpressionOrder) (classBody { (classBodyDeclaration (modifier (classOrInterfaceModifier public)) (modifier (classOrInterfaceModifier static)) (memberDeclaration (methodDeclaration (typeTypeOrVoid void) (identifier main) (formalParameters ( (formalParameterList (formalParameter (typeType (classOrInterfaceType (typeIdentifier String)) [ ]) (variableDeclaratorId (identifier args)))) )) (methodBody (block { (blockStatement (localVariableDeclaration (typeType (classOrInterfaceType (typeIdentifier Charpredicate))) (variableDeclarators (variableDeclarator (variableDeclaratorId (identifier a)) = (variableInitializer (expression (methodCall (identifier func) (arguments ( (expressionList (expression (primary (literal "a"))) , (expression (primary (literal true)))) )))))))) ;) }))))) (classBodyDeclaration (modifier (classOrInterfaceModifier public)) (modifier (classOrInterfaceModifier static)) (memberDeclaration (methodDeclaration (typeTypeOrVoid (typeType (classOrInterfaceType (typeIdentifier CharPredicate)))) (identifier func) (formalParameters ( (formalParameterList (formalParameter (typeType (classOrInterfaceType (typeIdentifier String))) (variableDeclaratorId (identifier name))) , (formalParameter (typeType (primitiveType boolean)) (variableDeclaratorId (identifier caseIns)))) )) (methodBody (block { (blockStatement (statement return (expression (expression (primary (identifier caseIns))) ? (expression (lambdaExpression (lambdaParameters (identifier c)) -> (lambdaBody (expression (expression (expression (expression (primary (identifier Character))) . (methodCall (identifier isUpperCase) (arguments ( (expressionList (expression (primary (identifier c)))) )))) || (expression (expression (primary (identifier Character))) . (methodCall (identifier isLowerCase) (arguments ( (expressionList (expression (primary (identifier c)))) ))))) || (expression (expression (primary (identifier Character))) . (methodCall (identifier isTitleCase) (arguments ( (expressionList (expression (primary (identifier c)))) )))))))) : (expression (expression (primary (identifier Character))) :: (identifier isUpperCase))) ;)) (blockStatement (statement ;)) }))))) (classBodyDeclaration (memberDeclaration (methodDeclaration (typeTypeOrVoid void) (identifier forEachRemaining) (formalParameters ( (formalParameterList (formalParameter (typeType (classOrInterfaceType (typeIdentifier Consumer) (typeArguments < (typeArgument ? super (typeType (classOrInterfaceType (typeIdentifier Double)))) >))) (variableDeclaratorId (identifier action)))) )) (methodBody (block { (blockStatement (statement (expression (methodCall (identifier forEachRemaining) (arguments ( (expressionList (expression ( (typeType (classOrInterfaceType (typeIdentifier DoubleConsumer))) ) (expression (expression (primary (identifier action))) :: (identifier accept)))) )))) ;)) }))))) })))) \ No newline at end of file +(compilationUnit (importDeclaration import (qualifiedName (identifier java) . (identifier util) . (identifier regex) . (identifier Pattern) . (identifier CharPredicate)) ;) (typeDeclaration (classOrInterfaceModifier public) (classDeclaration class (identifier ExpressionOrder) (classBody { (classBodyDeclaration (modifier (classOrInterfaceModifier public)) (modifier (classOrInterfaceModifier static)) (memberDeclaration (methodDeclaration (typeTypeOrVoid void) (identifier main) (formalParameters ( (formalParameterList (formalParameter (typeType (classOrInterfaceType (typeIdentifier String)) [ ]) (variableDeclaratorId (identifier args)))) )) (methodBody (block { (blockStatement (localVariableDeclaration (typeType (classOrInterfaceType (typeIdentifier Charpredicate))) (variableDeclarators (variableDeclarator (variableDeclaratorId (identifier a)) = (variableInitializer (expression (methodCall (identifier func) (arguments ( (expressionList (expression (primary (literal "a"))) , (expression (primary (literal true)))) )))))))) ;) }))))) (classBodyDeclaration (modifier (classOrInterfaceModifier public)) (modifier (classOrInterfaceModifier static)) (memberDeclaration (methodDeclaration (typeTypeOrVoid (typeType (classOrInterfaceType (typeIdentifier CharPredicate)))) (identifier func) (formalParameters ( (formalParameterList (formalParameter (typeType (classOrInterfaceType (typeIdentifier String))) (variableDeclaratorId (identifier name))) , (formalParameter (typeType (primitiveType boolean)) (variableDeclaratorId (identifier caseIns)))) )) (methodBody (block { (blockStatement (statement return (expression (expression (primary (identifier caseIns))) ? (expression (lambdaExpression (lambdaParameters (identifier c)) -> (lambdaBody (expression (expression (expression (expression (primary (identifier Character))) . (methodCall (identifier isUpperCase) (arguments ( (expressionList (expression (primary (identifier c)))) )))) || (expression (expression (primary (identifier Character))) . (methodCall (identifier isLowerCase) (arguments ( (expressionList (expression (primary (identifier c)))) ))))) || (expression (expression (primary (identifier Character))) . (methodCall (identifier isTitleCase) (arguments ( (expressionList (expression (primary (identifier c)))) )))))))) : (expression (expression (primary (identifier Character))) :: (identifier isUpperCase))) ;)) (blockStatement (statement ;)) }))))) (classBodyDeclaration (memberDeclaration (methodDeclaration (typeTypeOrVoid void) (identifier forEachRemaining) (formalParameters ( (formalParameterList (formalParameter (typeType (classOrInterfaceType (typeIdentifier Consumer) (typeArguments < (typeArgument ? super (typeType (classOrInterfaceType (typeIdentifier Double)))) >))) (variableDeclaratorId (identifier action)))) )) (methodBody (block { (blockStatement (statement (expression (methodCall (identifier forEachRemaining) (arguments ( (expressionList (expression ( (typeType (classOrInterfaceType (typeIdentifier DoubleConsumer))) ) (expression (expression (primary (identifier action))) :: (identifier accept)))) )))) ;)) }))))) }))) ) \ No newline at end of file diff --git a/java/java/examples/GenericConstructor.java.tree b/java/java/examples/GenericConstructor.java.tree index 5cf07fd433..d47c71a3e7 100644 --- a/java/java/examples/GenericConstructor.java.tree +++ b/java/java/examples/GenericConstructor.java.tree @@ -1 +1 @@ -(compilationUnit (importDeclaration import (qualifiedName (identifier java) . (identifier util) . (identifier ArrayList)) ;) (typeDeclaration (classOrInterfaceModifier public) (classDeclaration class (identifier GenericConstructor) (classBody { (classBodyDeclaration (modifier (classOrInterfaceModifier public)) (modifier (classOrInterfaceModifier static)) (memberDeclaration (methodDeclaration (typeTypeOrVoid void) (identifier main) (formalParameters ( (formalParameterList (formalParameter (typeType (classOrInterfaceType (typeIdentifier String)) [ ]) (variableDeclaratorId (identifier args)))) )) (methodBody (block { (blockStatement (localVariableDeclaration (typeType (classOrInterfaceType (typeIdentifier ArrayList) (typeArguments < (typeArgument (typeType (classOrInterfaceType (typeIdentifier Integer)))) >))) (variableDeclarators (variableDeclarator (variableDeclaratorId (identifier myList)) = (variableInitializer (expression new (creator (createdName (identifier ArrayList) (typeArgumentsOrDiamond < >)) (classCreatorRest (arguments ( ))))))))) ;) }))))) })))) \ No newline at end of file +(compilationUnit (importDeclaration import (qualifiedName (identifier java) . (identifier util) . (identifier ArrayList)) ;) (typeDeclaration (classOrInterfaceModifier public) (classDeclaration class (identifier GenericConstructor) (classBody { (classBodyDeclaration (modifier (classOrInterfaceModifier public)) (modifier (classOrInterfaceModifier static)) (memberDeclaration (methodDeclaration (typeTypeOrVoid void) (identifier main) (formalParameters ( (formalParameterList (formalParameter (typeType (classOrInterfaceType (typeIdentifier String)) [ ]) (variableDeclaratorId (identifier args)))) )) (methodBody (block { (blockStatement (localVariableDeclaration (typeType (classOrInterfaceType (typeIdentifier ArrayList) (typeArguments < (typeArgument (typeType (classOrInterfaceType (typeIdentifier Integer)))) >))) (variableDeclarators (variableDeclarator (variableDeclaratorId (identifier myList)) = (variableInitializer (expression new (creator (createdName (identifier ArrayList) (typeArgumentsOrDiamond < >)) (classCreatorRest (arguments ( ))))))))) ;) }))))) }))) ) \ No newline at end of file diff --git a/java/java/examples/LocalVariableDeclaration.java.tree b/java/java/examples/LocalVariableDeclaration.java.tree index 6633bac29d..6eb00ef944 100644 --- a/java/java/examples/LocalVariableDeclaration.java.tree +++ b/java/java/examples/LocalVariableDeclaration.java.tree @@ -1 +1 @@ -(compilationUnit (importDeclaration import (qualifiedName (identifier java) . (identifier util) . (identifier ArrayList)) ;) (typeDeclaration (classOrInterfaceModifier public) (classDeclaration class (identifier LocalVariableDeclaration) (classBody { (classBodyDeclaration (modifier (classOrInterfaceModifier public)) (modifier (classOrInterfaceModifier static)) (memberDeclaration (methodDeclaration (typeTypeOrVoid void) (identifier main) (formalParameters ( (formalParameterList (formalParameter (typeType (classOrInterfaceType (typeIdentifier String)) [ ]) (variableDeclaratorId (identifier args)))) )) (methodBody (block { (blockStatement (localVariableDeclaration (typeType (classOrInterfaceType (typeIdentifier ArrayList) (typeArguments < (typeArgument (typeType (classOrInterfaceType (typeIdentifier Integer)))) >))) (variableDeclarators (variableDeclarator (variableDeclaratorId (identifier myList)) = (variableInitializer (expression new (creator (createdName (identifier ArrayList) (typeArgumentsOrDiamond (typeArguments < (typeArgument (typeType (classOrInterfaceType (typeIdentifier Integer)))) >))) (classCreatorRest (arguments ( ))))))))) ;) (blockStatement (statement (expression (expression (primary (identifier myList))) . (methodCall (identifier add) (arguments ( (expressionList (expression (primary (literal (integerLiteral 2))))) )))) ;)) (blockStatement (localVariableDeclaration var (identifier myVal) = (expression (expression (primary (identifier myList))) . (methodCall (identifier get) (arguments ( (expressionList (expression (primary (literal (integerLiteral 0))))) ))))) ;) }))))) })))) \ No newline at end of file +(compilationUnit (importDeclaration import (qualifiedName (identifier java) . (identifier util) . (identifier ArrayList)) ;) (typeDeclaration (classOrInterfaceModifier public) (classDeclaration class (identifier LocalVariableDeclaration) (classBody { (classBodyDeclaration (modifier (classOrInterfaceModifier public)) (modifier (classOrInterfaceModifier static)) (memberDeclaration (methodDeclaration (typeTypeOrVoid void) (identifier main) (formalParameters ( (formalParameterList (formalParameter (typeType (classOrInterfaceType (typeIdentifier String)) [ ]) (variableDeclaratorId (identifier args)))) )) (methodBody (block { (blockStatement (localVariableDeclaration (typeType (classOrInterfaceType (typeIdentifier ArrayList) (typeArguments < (typeArgument (typeType (classOrInterfaceType (typeIdentifier Integer)))) >))) (variableDeclarators (variableDeclarator (variableDeclaratorId (identifier myList)) = (variableInitializer (expression new (creator (createdName (identifier ArrayList) (typeArgumentsOrDiamond (typeArguments < (typeArgument (typeType (classOrInterfaceType (typeIdentifier Integer)))) >))) (classCreatorRest (arguments ( ))))))))) ;) (blockStatement (statement (expression (expression (primary (identifier myList))) . (methodCall (identifier add) (arguments ( (expressionList (expression (primary (literal (integerLiteral 2))))) )))) ;)) (blockStatement (localVariableDeclaration var (identifier myVal) = (expression (expression (primary (identifier myList))) . (methodCall (identifier get) (arguments ( (expressionList (expression (primary (literal (integerLiteral 0))))) ))))) ;) }))))) }))) ) \ No newline at end of file diff --git a/java/java/examples/RecordsTesting.java.tree b/java/java/examples/RecordsTesting.java.tree index 8ba67c6fdd..70971baadb 100644 --- a/java/java/examples/RecordsTesting.java.tree +++ b/java/java/examples/RecordsTesting.java.tree @@ -1 +1 @@ -(compilationUnit (typeDeclaration (classOrInterfaceModifier public) (classDeclaration class (identifier RecordsTesting) (classBody { (classBodyDeclaration (modifier (classOrInterfaceModifier public)) (memberDeclaration (recordDeclaration record (identifier BindingsSnapshot) (recordHeader ( (recordComponentList (recordComponent (typeType (primitiveType int)) (identifier a))) )) (recordBody { })))) (classBodyDeclaration (modifier (classOrInterfaceModifier private)) (memberDeclaration (recordDeclaration record (identifier OtherRecord) (recordHeader ( (recordComponentList (recordComponent (typeType (primitiveType int)) (identifier b))) )) (recordBody { (compactConstructorDeclaration (modifier (classOrInterfaceModifier protected)) (identifier OtherRecord) (block { (blockStatement (statement ;)) })) })))) (classBodyDeclaration (memberDeclaration (recordDeclaration record (identifier NextRecord) (recordHeader ( (recordComponentList (recordComponent (typeType (primitiveType int)) (identifier c))) )) (recordBody { (classBodyDeclaration (modifier (classOrInterfaceModifier public)) (memberDeclaration (constructorDeclaration (identifier NextRecord) (formalParameters ( (formalParameterList (formalParameter (typeType (primitiveType int)) (variableDeclaratorId (identifier c)))) )) throws (qualifiedNameList (qualifiedName (identifier java) . (identifier lang) . (identifier RuntimeException))) (block { (blockStatement (statement (expression (expression (expression (primary this)) . (identifier c)) = (expression (primary (identifier c)))) ;)) })))) })))) (classBodyDeclaration (memberDeclaration (interfaceDeclaration interface (identifier InnerInterface) (interfaceBody { (interfaceBodyDeclaration (interfaceMemberDeclaration (recordDeclaration record (identifier PoolKey) (recordHeader ( (recordComponentList (recordComponent (typeType (classOrInterfaceType (typeIdentifier Name))) (identifier name)) , (recordComponent (typeType (classOrInterfaceType (typeIdentifier BsmKey))) (identifier bsmKey)) , (recordComponent (typeType (classOrInterfaceType (typeIdentifier Object))) (identifier dynamicType))) )) (recordBody { })))) })))) })))) \ No newline at end of file +(compilationUnit (typeDeclaration (classOrInterfaceModifier public) (classDeclaration class (identifier RecordsTesting) (classBody { (classBodyDeclaration (modifier (classOrInterfaceModifier public)) (memberDeclaration (recordDeclaration record (identifier BindingsSnapshot) (recordHeader ( (recordComponentList (recordComponent (typeType (primitiveType int)) (identifier a))) )) (recordBody { })))) (classBodyDeclaration (modifier (classOrInterfaceModifier private)) (memberDeclaration (recordDeclaration record (identifier OtherRecord) (recordHeader ( (recordComponentList (recordComponent (typeType (primitiveType int)) (identifier b))) )) (recordBody { (compactConstructorDeclaration (modifier (classOrInterfaceModifier protected)) (identifier OtherRecord) (block { (blockStatement (statement ;)) })) })))) (classBodyDeclaration (memberDeclaration (recordDeclaration record (identifier NextRecord) (recordHeader ( (recordComponentList (recordComponent (typeType (primitiveType int)) (identifier c))) )) (recordBody { (classBodyDeclaration (modifier (classOrInterfaceModifier public)) (memberDeclaration (constructorDeclaration (identifier NextRecord) (formalParameters ( (formalParameterList (formalParameter (typeType (primitiveType int)) (variableDeclaratorId (identifier c)))) )) throws (qualifiedNameList (qualifiedName (identifier java) . (identifier lang) . (identifier RuntimeException))) (block { (blockStatement (statement (expression (expression (expression (primary this)) . (identifier c)) = (expression (primary (identifier c)))) ;)) })))) })))) (classBodyDeclaration (memberDeclaration (interfaceDeclaration interface (identifier InnerInterface) (interfaceBody { (interfaceBodyDeclaration (interfaceMemberDeclaration (recordDeclaration record (identifier PoolKey) (recordHeader ( (recordComponentList (recordComponent (typeType (classOrInterfaceType (typeIdentifier Name))) (identifier name)) , (recordComponent (typeType (classOrInterfaceType (typeIdentifier BsmKey))) (identifier bsmKey)) , (recordComponent (typeType (classOrInterfaceType (typeIdentifier Object))) (identifier dynamicType))) )) (recordBody { })))) })))) }))) ) \ No newline at end of file diff --git a/java/java/examples/SwitchExpression.java.tree b/java/java/examples/SwitchExpression.java.tree index d3ac86c8ee..1b2e04a3ba 100644 --- a/java/java/examples/SwitchExpression.java.tree +++ b/java/java/examples/SwitchExpression.java.tree @@ -1 +1 @@ -(compilationUnit (typeDeclaration (classOrInterfaceModifier public) (classDeclaration class (identifier Switch) (classBody { (classBodyDeclaration (modifier (classOrInterfaceModifier public)) (modifier (classOrInterfaceModifier static)) (memberDeclaration (methodDeclaration (typeTypeOrVoid void) (identifier main) (formalParameters ( (formalParameterList (formalParameter (typeType (classOrInterfaceType (typeIdentifier String)) [ ]) (variableDeclaratorId (identifier args)))) )) (methodBody (block { (blockStatement (localVariableDeclaration (typeType (classOrInterfaceType (typeIdentifier String))) (variableDeclarators (variableDeclarator (variableDeclaratorId (identifier myString)) = (variableInitializer (expression (primary (literal "some_text"))))))) ;) (blockStatement (localVariableDeclaration (typeType (primitiveType int)) (variableDeclarators (variableDeclarator (variableDeclaratorId (identifier j)) = (variableInitializer (expression (switchExpression switch (parExpression ( (expression (primary (identifier myString))) )) { (switchLabeledRule case (expressionList (expression (primary (literal "some_text")))) -> (switchRuleOutcome (blockStatement (statement (expression (primary (literal (integerLiteral 0)))) ;)))) (switchLabeledRule default -> (switchRuleOutcome (block { (blockStatement (localVariableDeclaration (typeType (primitiveType int)) (variableDeclarators (variableDeclarator (variableDeclaratorId (identifier result)) = (variableInitializer (expression (primary (literal (integerLiteral 10)))))))) ;) (blockStatement (statement yield (expression (primary (identifier result))) ;)) }))) })))))) ;) }))))) })))) \ No newline at end of file +(compilationUnit (typeDeclaration (classOrInterfaceModifier public) (classDeclaration class (identifier Switch) (classBody { (classBodyDeclaration (modifier (classOrInterfaceModifier public)) (modifier (classOrInterfaceModifier static)) (memberDeclaration (methodDeclaration (typeTypeOrVoid void) (identifier main) (formalParameters ( (formalParameterList (formalParameter (typeType (classOrInterfaceType (typeIdentifier String)) [ ]) (variableDeclaratorId (identifier args)))) )) (methodBody (block { (blockStatement (localVariableDeclaration (typeType (classOrInterfaceType (typeIdentifier String))) (variableDeclarators (variableDeclarator (variableDeclaratorId (identifier myString)) = (variableInitializer (expression (primary (literal "some_text"))))))) ;) (blockStatement (localVariableDeclaration (typeType (primitiveType int)) (variableDeclarators (variableDeclarator (variableDeclaratorId (identifier j)) = (variableInitializer (expression (switchExpression switch (parExpression ( (expression (primary (identifier myString))) )) { (switchLabeledRule case (expressionList (expression (primary (literal "some_text")))) -> (switchRuleOutcome (blockStatement (statement (expression (primary (literal (integerLiteral 0)))) ;)))) (switchLabeledRule default -> (switchRuleOutcome (block { (blockStatement (localVariableDeclaration (typeType (primitiveType int)) (variableDeclarators (variableDeclarator (variableDeclaratorId (identifier result)) = (variableInitializer (expression (primary (literal (integerLiteral 10)))))))) ;) (blockStatement (statement yield (expression (primary (identifier result))) ;)) }))) })))))) ;) }))))) }))) ) \ No newline at end of file diff --git a/java/java/examples/TryStatements.java.tree b/java/java/examples/TryStatements.java.tree index 93b2daf91d..3691562a5b 100644 --- a/java/java/examples/TryStatements.java.tree +++ b/java/java/examples/TryStatements.java.tree @@ -1 +1 @@ -(compilationUnit (typeDeclaration (classOrInterfaceModifier public) (classDeclaration class (identifier TryStatements) (classBody { (classBodyDeclaration (modifier (classOrInterfaceModifier public)) (modifier (classOrInterfaceModifier static)) (memberDeclaration (methodDeclaration (typeTypeOrVoid void) (identifier main) (formalParameters ( (formalParameterList (formalParameter (typeType (classOrInterfaceType (typeIdentifier String)) [ ]) (variableDeclaratorId (identifier args)))) )) (methodBody (block { (blockStatement (statement try (resourceSpecification ( (resources (resource (qualifiedName (identifier conContext) . (identifier inputRecord)))) )) (block { (blockStatement (statement (expression (expression (expression (primary (identifier System))) . (identifier out)) . (methodCall (identifier println) (arguments ( (expressionList (expression (primary (literal "text")))) )))) ;)) }))) }))))) })))) \ No newline at end of file +(compilationUnit (typeDeclaration (classOrInterfaceModifier public) (classDeclaration class (identifier TryStatements) (classBody { (classBodyDeclaration (modifier (classOrInterfaceModifier public)) (modifier (classOrInterfaceModifier static)) (memberDeclaration (methodDeclaration (typeTypeOrVoid void) (identifier main) (formalParameters ( (formalParameterList (formalParameter (typeType (classOrInterfaceType (typeIdentifier String)) [ ]) (variableDeclaratorId (identifier args)))) )) (methodBody (block { (blockStatement (statement try (resourceSpecification ( (resources (resource (qualifiedName (identifier conContext) . (identifier inputRecord)))) )) (block { (blockStatement (statement (expression (expression (expression (primary (identifier System))) . (identifier out)) . (methodCall (identifier println) (arguments ( (expressionList (expression (primary (literal "text")))) )))) ;)) }))) }))))) }))) ) \ No newline at end of file