Skip to content

Commit c771d7c

Browse files
committed
Add UnqualifiedClassInstanceCreationExpression
1 parent b4157dd commit c771d7c

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

src/grammar/parser.y

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import java.util.Stack;
6060
%type <annoval> Expression Literal Annotation ElementValue ElementValueArrayInitializer
6161
%type <annoval> ConditionalExpression ConditionalOrExpression ConditionalAndExpression InclusiveOrExpression ExclusiveOrExpression AndExpression
6262
%type <annoval> EqualityExpression RelationalExpression ShiftExpression AdditiveExpression MultiplicativeExpression
63-
%type <annoval> UnaryExpression UnaryExpressionNotPlusMinus PreIncrementExpression PreDecrementExpression Primary PrimaryNoNewArray ArrayCreationExpression MethodInvocation MethodReference ClassInstanceCreationExpression
63+
%type <annoval> UnaryExpression UnaryExpressionNotPlusMinus PreIncrementExpression PreDecrementExpression Primary PrimaryNoNewArray ArrayCreationExpression MethodInvocation MethodReference ClassInstanceCreationExpression UnqualifiedClassInstanceCreationExpression
6464
%type <annoval> PostfixExpression PostIncrementExpression PostDecrementExpression CastExpression Assignment LeftHandSide AssignmentExpression
6565
%type <ival> Dims Dims_opt
6666
%type <sval> QualifiedIdentifier TypeDeclSpecifier MethodBody AssignmentOperator ModuleName
@@ -1013,24 +1013,31 @@ PrimaryNoNewArray: Literal
10131013
;
10141014

10151015
// ClassInstanceCreationExpression:
1016-
// new [TypeArguments] {Annotation} Identifier [TypeArgumentsOrDiamond] ( [ArgumentList] ) [ClassBody]
1017-
// ExpressionName . new [TypeArguments] {Annotation} Identifier [TypeArgumentsOrDiamond] ( [ArgumentList] ) [ClassBody]
1018-
// Primary . new [TypeArguments] {Annotation} Identifier [TypeArgumentsOrDiamond] ( [ArgumentList] ) [ClassBody]
1019-
//// TypeArguments_opt confuses parser
1020-
ClassInstanceCreationExpression: NEW TypeArguments IDENTIFIER TypeArgumentsOrDiamond_opt PARENOPEN ArgumentList_opt PARENCLOSE CODEBLOCK_opt
1021-
{
1022-
CreatorDef creator = new CreatorDef();
1023-
creator.setCreatedName( $3 );
1024-
$$ = creator;
1025-
}
1026-
| NEW IDENTIFIER TypeArgumentsOrDiamond_opt PARENOPEN ArgumentList_opt PARENCLOSE CODEBLOCK_opt
1027-
{
1028-
CreatorDef creator = new CreatorDef();
1029-
creator.setCreatedName( $2 );
1030-
$$ = creator;
1031-
}
1016+
// UnqualifiedClassInstanceCreationExpression
1017+
// ExpressionName . UnqualifiedClassInstanceCreationExpression
1018+
// Primary . UnqualifiedClassInstanceCreationExpression
1019+
ClassInstanceCreationExpression: UnqualifiedClassInstanceCreationExpression
1020+
| ExpressionName DOT UnqualifiedClassInstanceCreationExpression
1021+
| Primary DOT UnqualifiedClassInstanceCreationExpression
10321022
;
10331023

1024+
// UnqualifiedClassInstanceCreationExpression:
1025+
// new [TypeArguments] ClassOrInterfaceTypeToInstantiate ( [ArgumentList] ) [ClassBody]
1026+
//// TypeArguments_opt confuses parser
1027+
UnqualifiedClassInstanceCreationExpression: NEW TypeArguments IDENTIFIER TypeArgumentsOrDiamond_opt PARENOPEN ArgumentList_opt PARENCLOSE CODEBLOCK_opt
1028+
{
1029+
CreatorDef creator = new CreatorDef();
1030+
creator.setCreatedName( $3 );
1031+
$$ = creator;
1032+
}
1033+
| NEW IDENTIFIER TypeArgumentsOrDiamond_opt PARENOPEN ArgumentList_opt PARENCLOSE CODEBLOCK_opt
1034+
{
1035+
CreatorDef creator = new CreatorDef();
1036+
creator.setCreatedName( $2 );
1037+
$$ = creator;
1038+
}
1039+
;
1040+
10341041
CODEBLOCK_opt:
10351042
| CODEBLOCK
10361043
;

0 commit comments

Comments
 (0)