36
36
% that `o` is desugared as `o.call` when the context type is a function type.
37
37
% - Clarify the treatment of `covariant` parameters in the interface of a class
38
38
% that inherits an implementation where those parameters are not covariant.
39
+ % - Adjust and clarify simple string interpolation (to allow `'$this'`, which
40
+ % is already implemented and useful).
41
+ % - Add several lexical rules about identifiers, clarifying different kinds.
39
42
%
40
43
% 2.14
41
44
% - Add constraint on type of parameter which is covariant-by-declaration in
@@ -2397,7 +2400,7 @@ \section{Classes}
2397
2400
2398
2401
\begin{grammar}
2399
2402
<classDeclaration> ::=
2400
- \ABSTRACT? \CLASS{} <identifier > <typeParameters>?
2403
+ \ABSTRACT? \CLASS{} <typeIdentifier > <typeParameters>?
2401
2404
\gnewline{} <superclass>? <interfaces>?
2402
2405
\gnewline{} `{' (<metadata> <classMemberDeclaration>)* `}'
2403
2406
\alt \ABSTRACT? \CLASS{} <mixinApplicationClass>
@@ -5484,7 +5487,7 @@ \subsection{Mixin Declaration}
5484
5487
for static member declarations.
5485
5488
5486
5489
\begin{grammar}
5487
- <mixinDeclaration> ::= \MIXIN{} <identifier > <typeParameters>?
5490
+ <mixinDeclaration> ::= \MIXIN{} <typeIdentifier > <typeParameters>?
5488
5491
\gnewline{} (\ON{} <typeNotVoidList>)? <interfaces>?
5489
5492
\gnewline{} `\{' (<metadata> <classMemberDeclaration>)* `\}'
5490
5493
\end{grammar}
@@ -9165,7 +9168,7 @@ \subsubsection{String Interpolation}
9165
9168
\alt `${' <expression> `}'
9166
9169
9167
9170
<SIMPLE\_STRING\_INTERPOLATION> ::= \gnewline{}
9168
- `$' <IDENTIFIER\_NO\_DOLLAR>
9171
+ `$' ( <IDENTIFIER\_NO\_DOLLAR> | <BUILT\_IN\_IDENTIFIER> | \THIS)
9169
9172
\end{grammar}
9170
9173
9171
9174
\commentary{%
@@ -9179,7 +9182,9 @@ \subsubsection{String Interpolation}
9179
9182
the beginning of an interpolated expression.
9180
9183
The \lit{\$} sign may be followed by either:
9181
9184
\begin{itemize}
9182
- \item A single identifier \id{} that does not contain the \lit{\$} character.
9185
+ \item A single identifier \id{} that does not contain the \lit{\$} character
9186
+ (but it can be a built-in identifier),
9187
+ or the reserved word \THIS.
9183
9188
\item An expression $e$ delimited by curly braces.
9184
9189
\end{itemize}
9185
9190
@@ -16537,62 +16542,70 @@ \subsection{Identifier Reference}
16537
16542
\LMHash{}%
16538
16543
An \Index{identifier expression} consists of a single identifier;
16539
16544
it provides access to an object via an unqualified name.
16545
+ A \synt{typeIdentifier} is an identifier which can be used
16546
+ as the name of a type declaration.
16547
+
16548
+ \commentary{%
16549
+ A \synt{qualifiedName} is not an identifier expression,
16550
+ but we specify its syntax here because it is used in several different contexts,
16551
+ and it is more closely related to the plain identifier
16552
+ than it is to any single one of those grammar rules where it is used.%
16553
+ }
16540
16554
16541
16555
\begin{grammar}
16542
16556
<identifier> ::= <IDENTIFIER>
16557
+ \alt <BUILT\_IN\_IDENTIFIER>
16558
+ \alt <OTHER\_IDENTIFIER>
16543
16559
16544
- <IDENTIFIER\_NO\_DOLLAR > ::= <IDENTIFIER\_START\_NO\_DOLLAR >
16545
- \gnewline{} <IDENTIFIER\_PART\_NO\_DOLLAR>*
16560
+ <typeIdentifier > ::= <IDENTIFIER>
16561
+ \alt <OTHER\_IDENTIFIER>
16546
16562
16547
- <IDENTIFIER> ::= <IDENTIFIER\_START> <IDENTIFIER\_PART>*
16563
+ <qualifiedName> ::= <typeIdentifier> `.' <identifier>
16564
+ \alt <typeIdentifier> `.' <typeIdentifier> `.' <identifier>
16548
16565
16549
- <BUILT\_IN\_IDENTIFIER> ::= \ABSTRACT{}
16550
- \alt \AS{}
16551
- \alt \COVARIANT{}
16552
- \alt \DEFERRED{}
16553
- \alt \DYNAMIC{}
16554
- \alt \EXPORT{}
16555
- \alt \EXTERNAL{}
16556
- \alt \EXTENSION{}
16557
- \alt \FACTORY{}
16558
- \alt \FUNCTION{}
16559
- \alt \GET{}
16560
- \alt \IMPLEMENTS{}
16561
- \alt \IMPORT{}
16562
- \alt \INTERFACE{}
16563
- \alt \LATE{}
16564
- \alt \LIBRARY{}
16565
- \alt \MIXIN{}
16566
- \alt \OPERATOR{}
16567
- \alt \PART{}
16568
- \alt \REQUIRED{}
16569
- \alt \SET{}
16570
- \alt \STATIC{}
16571
- \alt \TYPEDEF{}
16566
+ <BUILT\_IN\_IDENTIFIER> ::= \ABSTRACT{} | \AS{} | \COVARIANT{} | \DEFERRED{}
16567
+ \alt\hspace{-3mm} \DYNAMIC{} | \EXPORT{} | \EXTERNAL{} | \EXTENSION{} |
16568
+ \FACTORY{} | \FUNCTION{} | \GET{}
16569
+ \alt\hspace{-3mm} \IMPLEMENTS{} | \IMPORT{} | \INTERFACE{} | \LATE{} |
16570
+ \LIBRARY{} | \MIXIN{} | \OPERATOR{}
16571
+ \alt\hspace{-3mm} \PART{} | \REQUIRED{} | \SET{} | \STATIC{} | \TYPEDEF{}
16572
16572
16573
- <IDENTIFIER\_START> ::= <IDENTIFIER\_START\_NO\_DOLLAR> | `$'
16573
+ <OTHER\_IDENTIFIER> ::= \gnewline{}
16574
+ \ASYNC{} | \HIDE{} | \OF{} | \ON{} | \SHOW{} | \SYNC{} |
16575
+ \AWAIT{} | \YIELD{}
16576
+
16577
+ <IDENTIFIER\_NO\_DOLLAR> ::= <IDENTIFIER\_START\_NO\_DOLLAR>
16578
+ \gnewline{} <IDENTIFIER\_PART\_NO\_DOLLAR>*
16574
16579
16575
16580
<IDENTIFIER\_START\_NO\_DOLLAR> ::= <LETTER> | `_'
16576
16581
16577
16582
<IDENTIFIER\_PART\_NO\_DOLLAR> ::= \gnewline{}
16578
16583
<IDENTIFIER\_START\_NO\_DOLLAR> | <DIGIT>
16579
16584
16580
- <IDENTIFIER\_PART > ::= <IDENTIFIER\_START> | <DIGIT>
16585
+ <IDENTIFIER> ::= <IDENTIFIER\_START> <IDENTIFIER\_PART>*
16581
16586
16582
- <qualifiedName> ::= <typeIdentifier> `.' <identifier>
16583
- \alt <typeIdentifier> `.' <typeIdentifier> `.' <identifier>
16587
+ <IDENTIFIER\_START> ::= <IDENTIFIER\_START\_NO\_DOLLAR> | `$'
16588
+
16589
+ <IDENTIFIER\_PART> ::= <IDENTIFIER\_START> | <DIGIT>
16584
16590
16585
- <LETTER> ::= `a' .. `z'
16586
- \alt `A' .. `Z'
16591
+ <LETTER> ::= `a' .. `z' | `A' .. `Z'
16587
16592
16588
16593
<DIGIT> ::= `0' .. `9'
16589
16594
16590
16595
<WHITESPACE> ::= (`\\t' | ` ' | <NEWLINE>)+
16591
16596
\end{grammar}
16592
16597
16593
16598
\LMHash{}%
16594
- A built-in identifier is one of the identifiers produced by the production
16595
- \synt{BUILT\_IN\_IDENTIFIER}.
16599
+ The ordering of the lexical rules above ensure that \synt{IDENTIFIER}
16600
+ and \synt{IDENTIFIER\_NO\_DOLLAR} do not derive any built-in identifiers.
16601
+ Similarly, the lexical rule for reserved words (\ref{reservedWords})
16602
+ must be considered to come before the rule for \synt{BUILT\_IN\_IDENTIFIER},
16603
+ such that \synt{IDENTIFIER} and \synt{IDENTIFIER\_NO\_DOLLAR}
16604
+ also do not derive any reserved words.
16605
+
16606
+ \LMHash{}%
16607
+ A \Index{built-in identifier} is one of
16608
+ the identifiers produced by the production \synt{BUILT\_IN\_IDENTIFIER}.
16596
16609
It is a compile-time error if a built-in identifier is used as
16597
16610
the declared name of a prefix, class, mixin, type parameter, or type alias.
16598
16611
It is a compile-time error to use a built-in identifier
@@ -16610,8 +16623,8 @@ \subsection{Identifier Reference}
16610
16623
16611
16624
\LMHash{}%
16612
16625
It is a compile-time error if either of the identifiers \AWAIT{} or \YIELD{}
16613
- is used as an identifier in a function body
16614
- marked with either \ASYNC, \code{\ASYNC*} or \code{\SYNC*}.
16626
+ is used as an \synt{ identifier} in a function body
16627
+ marked with either \ASYNC, \code{\ASYNC*}, or \code{\SYNC*}.
16615
16628
16616
16629
\rationale{%
16617
16630
This makes the identifiers \AWAIT{} and \YIELD{} behave like reserved words
@@ -16622,8 +16635,10 @@ \subsection{Identifier Reference}
16622
16635
}
16623
16636
16624
16637
\LMHash{}%
16625
- A \Index{qualified identifier} is an identifier preceded by
16626
- \syntax{<identifier> `.'}.
16638
+ A \Index{qualified name} is two or three identifiers separated by \lit{.}.
16639
+ All but the last one must be a \synt{typeIdentifier}.
16640
+ It is used to denote a declaration which is imported with a prefix,
16641
+ or a \STATIC{} declaration in a class, mixin, or extension, or both.
16627
16642
16628
16643
\LMHash{}%
16629
16644
The static type of an identifier expression $e$ which is an identifier \id{}
@@ -19988,16 +20003,12 @@ \subsection{Static Types}
19988
20003
Type annotations are used during static checking and when running programs.
19989
20004
Types are specified using the following grammar rules.
19990
20005
19991
- %% TODO(eernst): The following non-terminal is currently undefined (it will
19992
- %% be defined when more rules are transferred from Dart.g): <typeIdentifier>.
19993
- %% The precise rules are slightly different than the following sentence, but
19994
- %% we should be able to make do with that for now.
19995
- \LMHash{}%
19996
- In the grammar rules below, \synt{typeIdentifier} denotes
19997
- an identifier which can be
19998
- the name of a type, that is, it denotes an \synt{IDENTIFIER} which is not a
19999
- \synt{BUILT\_IN\_IDENTIFIER}.
20000
-
20006
+ \commentary{%
20007
+ A \synt{typeIdentifier} is an identifier which can be the name of a type,
20008
+ that is,
20009
+ it denotes an \synt{IDENTIFIER} which is not a \synt{BUILT\_IN\_IDENTIFIER}
20010
+ (\ref{identifierReference}).%
20011
+ }
20001
20012
%% TODO(eernst): The following non-terminals are currently unused (they will
20002
20013
%% be used when we transfer more grammar rules from Dart.g): <typeNotVoid>
20003
20014
%% and <typeNotVoidNotFunctionList>. They are used in the syntax for
@@ -22232,15 +22243,25 @@ \subsubsection{Reserved Words}
22232
22243
}
22233
22244
22234
22245
\begin{grammar}
22235
- <reservedWord > ::= \ASSERT{} | \BREAK{} | \CASE{} | \CATCH{} |
22236
- \CLASS{} | \CONST{} | \CONTINUE{}
22237
- \alt\hspace{-3mm} \DEFAULT {} | \DO {} | \ELSE {} | \ENUM {} | \EXTENDS {} |
22238
- \FALSE {} | \FINAL {} | \FINALLY {} | \FOR {} | \IF{} | \IN{} | \IS {}
22239
- \alt\hspace{-3mm} \NEW {} | \NULL {} | \RETHROW {} | \RETURN {} | \SUPER {} |
22240
- \SWITCH {} | \THIS {} | \THROW {} | \TRUE {} | \TRY {}
22241
- \alt\hspace{-3mm} \VAR{} | \VOID{} | \WHILE{} | \WITH{}
22246
+ <RESERVED\_WORD > ::= \ASSERT{} | \BREAK{} | \CASE{} | \CATCH{} |
22247
+ \CLASS{} | \CONST{}
22248
+ \alt\hspace{-3mm} \CONTINUE {} | \DEFAULT {} | \DO {} | \ELSE {} | \ENUM {} |
22249
+ \EXTENDS {} | \FALSE {} | \FINAL {} | \FINALLY {} | \FOR {}
22250
+ \alt\hspace{-3mm} \IF {} | \IN {} | \IS {} | \NEW {} | \NULL{} | \RETHROW {} |
22251
+ \RETURN {} | \SUPER {} | \SWITCH {} | \THIS {} | \THROW {}
22252
+ \alt\hspace{-3mm} \TRUE{} | \TRY{} | \ VAR{} | \VOID{} | \WHILE{} | \WITH{}
22242
22253
\end{grammar}
22243
22254
22255
+ \LMHash{}%
22256
+ In the grammar, the rule for reserved words above must occur
22257
+ before the rule for \synt{BUILT\_IN\_IDENTIFIER}
22258
+ (\ref{identifierReference}).
22259
+
22260
+ \commentary{%
22261
+ This ensures that \synt{IDENTIFIER} and \synt{IDENTIFIER\_NO\_DOLLAR} do not
22262
+ derive any reserved words, and they do not derive any built-in identifiers.
22263
+ }
22264
+
22244
22265
22245
22266
\subsubsection{Comments}
22246
22267
\LMLabel{comments}
0 commit comments