Skip to content

Commit

Permalink
Add support for static access shorthands
Browse files Browse the repository at this point in the history
Change-Id: I826e230ad38388a8e1f6ccc366704a2e8c340dee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397301
Reviewed-by: Chloe Stefantsova <[email protected]>
Commit-Queue: Erik Ernst <[email protected]>
  • Loading branch information
eernstg authored and Commit Queue committed Nov 25, 2024
1 parent 19da943 commit bc30907
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/spec_parser/Dart.g
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

// CHANGES:
//
// v0.52 Support static access shorthands.
//
// v0.51 Support a `switchExpression` with no cases.
//
// v0.50 Add support for digit separators in numeric literals.
Expand Down Expand Up @@ -681,6 +683,7 @@ primary
| '(' expression ')'
| constructorTearoff
| switchExpression
| staticMemberShorthand
;

constructorInvocation
Expand Down Expand Up @@ -796,6 +799,11 @@ switchExpressionCase
: guardedPattern '=>' expression
;

staticMemberShorthand
: '.' identifierOrNew selector*
| CONST '.' identifierOrNew selector*
;

throwExpression
: THROW expression
;
Expand Down Expand Up @@ -1170,6 +1178,7 @@ constantPattern
| CONST typeArguments? '[' elements? ']'
| CONST typeArguments? LBRACE elements? RBRACE
| CONST '(' expression ')'
| staticMemberShorthand
;

variablePattern
Expand Down
9 changes: 9 additions & 0 deletions tools/spec_parser/dart_spec_parser/Dart.g4
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

// CHANGES:
//
// v0.53 Support static access shorthands.
//
// v0.52 Support a `switchExpression` with no cases.
//
// v0.51 Add support for digit separators in numeric literals.
Expand Down Expand Up @@ -687,6 +689,7 @@ primary
| '(' expression ')'
| constructorTearoff
| switchExpression
| staticMemberShorthand
;

constructorInvocation
Expand Down Expand Up @@ -802,6 +805,11 @@ switchExpressionCase
: guardedPattern '=>' expression
;

staticMemberShorthand
: '.' identifierOrNew selector*
| CONST '.' identifierOrNew selector*
;

throwExpression
: THROW expression
;
Expand Down Expand Up @@ -1176,6 +1184,7 @@ constantPattern
| CONST typeArguments? '[' elements? ']'
| CONST typeArguments? LBRACE elements? RBRACE
| CONST '(' expression ')'
| staticMemberShorthand
;

variablePattern
Expand Down

0 comments on commit bc30907

Please sign in to comment.