Skip to content

Commit

Permalink
Very early and partial grammar changes for lambda rewiring
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanth-sankaran committed Dec 15, 2023
1 parent 86aa2dd commit e254da8
Show file tree
Hide file tree
Showing 34 changed files with 1,872 additions and 1,987 deletions.
20 changes: 7 additions & 13 deletions org.eclipse.jdt.core.compiler.batch/grammar/java.g
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ $Terminals
BeginLambda
BeginIntersectionCast
BeginTypeArguments
ElidedSemicolonAndRightBrace
AT308
AT308DOTDOTDOT
BeginCaseExpr
Expand Down Expand Up @@ -1835,7 +1834,6 @@ PrimaryNoNewArray -> ArrayAccess
-- Start of rules for JSR 335
-----------------------------------------------------------------------

PrimaryNoNewArray -> LambdaExpression
PrimaryNoNewArray -> ReferenceExpression
/:$readableName Expression:/

Expand Down Expand Up @@ -1931,17 +1929,12 @@ TypeElidedFormalParameter ::= Modifiersopt Identifier
/:$readableName TypeElidedFormalParameter:/
/:$compliance 1.8:/

-- A lambda body of the form x is really '{' return x; '}'
LambdaBody -> ElidedLeftBraceAndReturn Expression ElidedSemicolonAndRightBrace
LambdaBody ::= Expression
/.$putCase consumeLambdaBody(false); $break ./
LambdaBody -> Block
/:$readableName LambdaBody:/
/:$compliance 1.8:/

ElidedLeftBraceAndReturn ::= $empty
/.$putCase consumeElidedLeftBraceAndReturn(); $break ./
/:$readableName ElidedLeftBraceAndReturn:/
/:$compliance 1.8:/

-----------------------------------------------------------------------
-- End of rules for JSR 335
-----------------------------------------------------------------------
Expand Down Expand Up @@ -2261,6 +2254,7 @@ ConditionalOrExpression ::= ConditionalOrExpression '||' ConditionalAndExpressio

ConditionalExpression -> ConditionalOrExpression
ConditionalExpression ::= ConditionalOrExpression '?' Expression ':' ConditionalExpression
ConditionalExpression ::= ConditionalOrExpression '?' Expression ':' LambdaExpression
/.$putCase consumeConditionalExpression(OperatorIds.QUESTIONCOLON) ; $break ./
/:$readableName Expression:/

Expand Down Expand Up @@ -2308,10 +2302,8 @@ AssignmentOperator ::= '|='
/:$readableName AssignmentOperator:/
/:$recovery_template =:/

-- For handling lambda expressions, we need to know when a full Expression
-- has been reduced.
Expression ::= AssignmentExpression
/.$putCase consumeExpression(); $break ./
Expression -> LambdaExpression
Expression -> AssignmentExpression
/:$readableName Expression:/
/:$recovery_template Identifier:/

Expand Down Expand Up @@ -3206,3 +3198,5 @@ COLON_COLON ::= '::'

$end
-- need a carriage return after the $end


1 change: 1 addition & 0 deletions org.eclipse.jdt.core.compiler.batch/scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/GenerateParserScript.class
Loading

0 comments on commit e254da8

Please sign in to comment.