diff --git a/tools/spec_parser/Dart.g b/tools/spec_parser/Dart.g index c20183f4248..4481d8dcf6a 100644 --- a/tools/spec_parser/Dart.g +++ b/tools/spec_parser/Dart.g @@ -4,6 +4,8 @@ // CHANGES: // +// v0.44 Support null-aware elements. +// // v0.43 Change rule structure such that the association of metadata // with non-terminals can be explained in a simple and consistent way. // The derivable terms do not change. Remove `metadata` from the kind @@ -732,13 +734,24 @@ elements ; element - : expressionElement + : nullAwareExpressionElement + | nullAwareMapElement + | expressionElement | mapElement | spreadElement | ifElement | forElement ; +nullAwareExpressionElement + : '?' expression + ; + +nullAwareMapElement + : '?' expression ':' '?'? expression + | expression ':' '?' expression + ; + expressionElement : expression ; diff --git a/tools/spec_parser/dart_spec_parser/Dart.g4 b/tools/spec_parser/dart_spec_parser/Dart.g4 index c7673f7b720..a3697e83c24 100644 --- a/tools/spec_parser/dart_spec_parser/Dart.g4 +++ b/tools/spec_parser/dart_spec_parser/Dart.g4 @@ -10,6 +10,14 @@ // of `forLoopParts` where the iteration variable is an existing variable // in scope (this is not implemented, is inconsistent anyway). // +// v0.45 Support null-aware elements. +// +// v0.44 Change rule structure such that the association of metadata +// with non-terminals can be explained in a simple and consistent way. +// The derivable terms do not change. Remove `metadata` from the kind +// of `forLoopParts` where the iteration variable is an existing variable +// in scope (this is not implemented, is inconsistent anyway). +// // v0.43 Support updated augmented `extensionDeclaration`. // // v0.42 Add missing `enumEntry` update for augmentations. @@ -738,13 +746,24 @@ elements ; element - : expressionElement + : nullAwareExpressionElement + | nullAwareMapElement + | expressionElement | mapElement | spreadElement | ifElement | forElement ; +nullAwareExpressionElement + : '?' expression + ; + +nullAwareMapElement + : '?' expression ':' '?'? expression + | expression ':' '?' expression + ; + expressionElement : expression ;