Attention is currently required from: Lasse R.H. Nielsen.
Erik Ernst would like Lasse R.H. Nielsen to review this change.
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
---
M tools/spec_parser/Dart.g
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/tools/spec_parser/Dart.g b/tools/spec_parser/Dart.g
index f166720..5f79d24 100644
--- a/tools/spec_parser/Dart.g
+++ b/tools/spec_parser/Dart.g
@@ -420,11 +420,11 @@
;
constructorName
- : typeIdentifier ('.' identifier)?
+ : typeIdentifier ('.' (identifier | NEW))?
;
redirection
- : ':' THIS ('.' identifier)? arguments
+ : ':' THIS ('.' (identifier | NEW))? arguments
;
initializers
@@ -433,7 +433,7 @@
initializerListEntry
: SUPER arguments
- | SUPER '.' identifier arguments
+ | SUPER '.' (identifier | NEW) arguments
| fieldInitializer
| assertion
;
@@ -519,10 +519,12 @@
| '(' expression ')'
| literal
| identifier
+ | constructorTearoff
;
constructorInvocation
- : typeName typeArguments '.' identifier arguments
+ : typeName typeArguments '.' NEW arguments
+ | typeName '.' NEW arguments
;
literal
@@ -598,6 +600,10 @@
: AWAIT? FOR '(' forLoopParts ')' element
;
+constructorTearoff
+ : typeName typeArguments? '.' NEW
+ ;
+
throwExpression
: THROW expression
;
@@ -850,6 +856,7 @@
: '!'
| assignableSelector
| argumentPart
+ | typeArguments
;
argumentPart
@@ -900,8 +907,8 @@
;
qualifiedName
- : typeIdentifier '.' identifier
- | typeIdentifier '.' typeIdentifier '.' identifier
+ : typeIdentifier '.' (identifier | NEW)
+ | typeIdentifier '.' typeIdentifier '.' (identifier | NEW)
;
typeIdentifier
@@ -1249,7 +1256,7 @@
constructorDesignation
: typeIdentifier
| qualifiedName
- | typeName typeArguments ('.' identifier)?
+ | typeName typeArguments ('.' (identifier | NEW))?
;
symbolLiteral
To view, visit change 197161. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Lasse R.H. Nielsen.
1 comment:
Patchset:
This grammar update makes all the constructor-tearoff feature related tests succeed.
To view, visit change 197161. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Erik Ernst.
Patch set 17:Code-Review +1
1 comment:
Patchset:
CL description is no longer correct. This only covers unnamed constructor naming, not type instantiation any more.
Otherwise LGTM
To view, visit change 197161. To unsubscribe, or for help writing mail filters, visit settings.
2 comments:
Patchset:
CL description is no longer correct. […]
Thanks! Actually, the inclusion of `<typeArguments>` as a selector enables a lot of expressions, including `myFunction<int>` and `List<int>`. So in what sense does it not cover type instantiation?
(Response to comment)
To view, visit change 197161. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Erik Ernst.
1 comment:
Patchset:
Thanks! Actually, the inclusion of `<typeArguments>` as a selector enables a lot of expressions, inc […]
In the sense that I missed that one line. Very subtle! Just the way I like it!
To view, visit change 197161. To unsubscribe, or for help writing mail filters, visit settings.
2 comments:
Patchset:
In the sense that I missed that one line. […]
;-)
(Response to comment ;-)
To view, visit change 197161. To unsubscribe, or for help writing mail filters, visit settings.
Patch set 17:Commit-Queue +2
commi...@chromium.org submitted this change.
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 <l...@google.com>
Commit-Queue: Erik Ernst <eer...@google.com>
To view, visit change 197161. To unsubscribe, or for help writing mail filters, visit settings.
go/dart-cbuild result: SUCCESS
Details: https://goto.google.com/dart-cbuild/find/6facd6dfdafa2953e8523348220d3129ea884678
File tools/spec_parser/Dart.g:
Patch Set #18, Line 527: | typeName '.' NEW arguments
Sorry for interrupting. I noticed that that both lines include [NEW]. Isn't [typeName typeArguments '.' identifier arguments] a [constructorInvocation] anymore?
To view, visit change 197161. To unsubscribe, or for help writing mail filters, visit settings.
2 comments:
Patchset:
Response to question.
File tools/spec_parser/Dart.g:
Patch Set #18, Line 527: | typeName '.' NEW arguments
Sorry for interrupting. I noticed that that both lines include [NEW]. […]
No, we added `<typeArguments>` as a new alternative for `<selector>` (line 859), and this means that the old forms of `<constructorInvocation>` are now redundant.
We can still do `C<int>.name()`, and it still means "invoke the `C.name` constructor, and pass the actual type argument `int` to it", but the syntactic structure is different (it isn't a `<constructorInvocation>`, even though it is a constructor invocation ;-).
To view, visit change 197161. To unsubscribe, or for help writing mail filters, visit settings.
1 comment:
File tools/spec_parser/Dart.g:
Patch Set #18, Line 527: | typeName '.' NEW arguments
No, we added `<typeArguments>` as a new alternative for `<selector>` (line 859), and this means that […]
Thanks!
To view, visit change 197161. To unsubscribe, or for help writing mail filters, visit settings.