Skip to content

Commit 6facd6d

Browse files
eernstgcommit-bot@chromium.org
authored andcommitted
Adjust Dart.g to allow constructor tearoffs
This CL updates the grammar Dart.g such that it supports constructor tearoffs, as well as explicit instantiations of generic functions and methods, and parameterized types as type literals. Change-Id: I2e30d0eb185b84fc2103c21ba962f4cbff40905a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197161 Reviewed-by: Lasse R.H. Nielsen <[email protected]> Commit-Queue: Erik Ernst <[email protected]>
1 parent e92cee7 commit 6facd6d

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

tools/spec_parser/Dart.g

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,11 @@ constructorSignature
420420
;
421421
422422
constructorName
423-
: typeIdentifier ('.' identifier)?
423+
: typeIdentifier ('.' (identifier | NEW))?
424424
;
425425
426426
redirection
427-
: ':' THIS ('.' identifier)? arguments
427+
: ':' THIS ('.' (identifier | NEW))? arguments
428428
;
429429
430430
initializers
@@ -433,7 +433,7 @@ initializers
433433
434434
initializerListEntry
435435
: SUPER arguments
436-
| SUPER '.' identifier arguments
436+
| SUPER '.' (identifier | NEW) arguments
437437
| fieldInitializer
438438
| assertion
439439
;
@@ -519,10 +519,12 @@ primary
519519
| '(' expression ')'
520520
| literal
521521
| identifier
522+
| constructorTearoff
522523
;
523524
524525
constructorInvocation
525-
: typeName typeArguments '.' identifier arguments
526+
: typeName typeArguments '.' NEW arguments
527+
| typeName '.' NEW arguments
526528
;
527529
528530
literal
@@ -598,6 +600,10 @@ forElement
598600
: AWAIT? FOR '(' forLoopParts ')' element
599601
;
600602
603+
constructorTearoff
604+
: typeName typeArguments? '.' NEW
605+
;
606+
601607
throwExpression
602608
: THROW expression
603609
;
@@ -850,6 +856,7 @@ selector
850856
: '!'
851857
| assignableSelector
852858
| argumentPart
859+
| typeArguments
853860
;
854861
855862
argumentPart
@@ -900,8 +907,8 @@ identifier
900907
;
901908
902909
qualifiedName
903-
: typeIdentifier '.' identifier
904-
| typeIdentifier '.' typeIdentifier '.' identifier
910+
: typeIdentifier '.' (identifier | NEW)
911+
| typeIdentifier '.' typeIdentifier '.' (identifier | NEW)
905912
;
906913
907914
typeIdentifier
@@ -1249,7 +1256,7 @@ typedIdentifier
12491256
constructorDesignation
12501257
: typeIdentifier
12511258
| qualifiedName
1252-
| typeName typeArguments ('.' identifier)?
1259+
| typeName typeArguments ('.' (identifier | NEW))?
12531260
;
12541261
12551262
symbolLiteral

0 commit comments

Comments
 (0)