Skip to content

Commit b687d3e

Browse files
authored
Change symbolLiteral to match actual implementation, clean up reserved words formatting (#1588)
Clean up reserved words formatting, change symbolLiteral to match actual implementation. Clarify the 'Symbols' section.
1 parent 8487fe0 commit b687d3e

File tree

1 file changed

+70
-36
lines changed

1 file changed

+70
-36
lines changed

specification/dartLangSpec.tex

Lines changed: 70 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8966,30 +8966,28 @@ \subsection{Symbols}
89668966
\LMHash{}%
89678967
A \IndexCustom{symbol literal}{literal!symbol}
89688968
denotes a name that would be either
8969-
a valid declaration name or a valid library name in a Dart program.
8969+
a valid declaration name, a valid library name, or \VOID.
89708970

89718971
\begin{grammar}
8972-
<symbolLiteral> ::= `#' (<operator> | (<identifier> (`.' <identifier>)*))
8972+
<symbolLiteral> ::=
8973+
`#' (<identifier> (`.' <identifier>)* | <operator> | \VOID)
89738974
\end{grammar}
89748975

89758976
\LMHash{}%
8976-
A symbol literal \code{\#\id} where \id{} is an identifier
8977-
that does not begin with an underscore (`\code{\_}'),
8978-
evaluates to an instance of \code{Symbol} representing the identifier \id.
8979-
All occurrences of \code{\#\id} evaluate to the same instance
8980-
\commentary{(symbol instances are canonicalized)},
8981-
and no other symbol literals evaluate to that \code{Symbol} instance
8982-
or to a \code{Symbol} instance that is equal
8983-
(according to the \lit{==} operator \ref{equality}) to that instance.
8977+
The static type of a symbol literal is \code{Symbol}.
8978+
8979+
\LMHash{}%
8980+
Let \id{} be an identifier that does not begin with an underscore
8981+
(`\code{\_}').
8982+
The symbol literal \code{\#\id}
8983+
evaluates to an instance of \code{Symbol}
8984+
representing the identifier \id.
89848985

89858986
\LMHash{}%
8986-
A symbol literal \code{\#$\id.\id_2\ldots\id_n$}
8987-
where $\id{} \ldots \id_n$ are identifiers,
8988-
evaluates to an instance of \code{Symbol} representing that particular sequence of identifiers.
8989-
All occurrences of \code{\#$\id.\id_2\ldots\id_n$} with the same sequence of identifiers
8990-
evaluate to the same instance,
8991-
and no other symbol literals evaluate to that \code{Symbol} instance
8992-
or to a \code{Symbol} instance that is \lit{==} to that instance.
8987+
A symbol literal \code{\#$\id_1$.$\id_2$.$\cdots$.$\id_n$}
8988+
where \List{\id}{1}{n} are identifiers
8989+
evaluates to an instance of \code{Symbol}
8990+
representing that particular sequence of identifiers.
89938991
\commentary{%
89948992
This kind of symbol literal denotes the name of a library declaration,
89958993
as specified in a \synt{libraryName}.
@@ -8998,18 +8996,39 @@ \subsection{Symbols}
89988996
}
89998997

90008998
\LMHash{}%
9001-
A symbol literal \code{\#\metavar{operator}} evaluates to an instance of \code{Symbol}
8999+
A symbol literal \code{\#\metavar{op}}
9000+
where \metavar{op} is derived from \synt{operator}
9001+
evaluates to an instance of \code{Symbol}
90029002
representing that particular operator name.
9003-
All occurrences of \code{\#\metavar{operator}} evaluate to the same instance,
9004-
and no other symbol literals evaluate to that \code{Symbol} instance
9005-
or to a \code{Symbol} instance that is \lit{==} to that instance.
90069003

90079004
\LMHash{}%
9008-
A symbol literal \code{\#\_\id}, evaluates to an instance of \code{Symbol}
9005+
The symbol literal \code{\#void}
9006+
evaluates to an instance of \code{Symbol}
9007+
representing the reserved word \VOID.
9008+
9009+
\LMHash{}%
9010+
Assume that the term $t$ is an identifier \id{}
9011+
that does not start with an underscore,
9012+
that $t$ is \VOID,
9013+
that $t$ is a period separated sequence of identifiers
9014+
\code{$id_1$.$id_2$.$\cdots$.$id_n$},
9015+
or that $t$ is derived from \synt{operator}.
9016+
Any two occurrences of \code{\#t} evaluate to the same object
9017+
(\commentary{that is, symbol instances are canonicalized}),
9018+
and no other symbol literals evaluate to that object,
9019+
nor to a \code{Symbol} instance that is equal to that object
9020+
according to the \lit{==} operator
9021+
(\ref{equality}).
9022+
9023+
\LMHash{}%
9024+
A symbol literal \code{\#\_\id} where \id{} is an identifier
9025+
evaluates to an instance of \code{Symbol}
90099026
representing the private identifier \code{\_\id} of the containing library.
9010-
All occurrences of \code{\#\_\id} \emph{in the same library} evaluate to the same instance,
9011-
and no other symbol literals evaluate to that \code{Symbol} instance
9012-
or to a \code{Symbol} instance that is \lit{==} to that instance.
9027+
All occurrences of \code{\#\_\id} \emph{in the same library} evaluate to
9028+
the same object,
9029+
and no other symbol literals evaluate to the same object,
9030+
nor to a \code{Symbol} instance that is equal to that object
9031+
according to the \lit{==} operator.
90139032

90149033
\LMHash{}%
90159034
The objects created by symbol literals all override
@@ -9043,9 +9062,6 @@ \subsection{Symbols}
90439062
convenient substitutes for enums are secondary benefits.%
90449063
}
90459064

9046-
\LMHash{}%
9047-
The static type of a symbol literal is \code{Symbol}.
9048-
90499065

90509066
\subsection{Collection Literals}
90519067
\LMLabel{collectionLiterals}
@@ -16048,6 +16064,13 @@ \subsection{Identifier Reference}
1604816064

1604916065
<qualifiedName> ::= <typeIdentifier> `.' <identifier>
1605016066
\alt <typeIdentifier> `.' <typeIdentifier> `.' <identifier>
16067+
16068+
<LETTER> ::= `a' .. `z'
16069+
\alt `A' .. `Z'
16070+
16071+
<DIGIT> ::= `0' .. `9'
16072+
16073+
<WHITESPACE> ::= (`\\t' | ` ' | <NEWLINE>)+
1605116074
\end{grammar}
1605216075

1605316076
\LMHash{}%
@@ -21424,17 +21447,28 @@ \subsubsection{Reserved Words}
2142421447
\LMLabel{reservedWords}
2142521448

2142621449
\LMHash{}%
21427-
A \Index{reserved word} may not be used as an identifier; it is a compile-time error if a reserved word is used where an identifier is expected.
21450+
A \Index{reserved word} can only be used in the syntactic positions
21451+
specified by the grammar.
21452+
In particular, a compile-time error occurs if a reserved word is used
21453+
where an identifier is expected.
2142821454

21429-
\ASSERT{}, \BREAK{}, \CASE{}, \CATCH{}, \CLASS{}, \CONST{}, \CONTINUE{}, \DEFAULT{}, \DO{}, \ELSE{}, \ENUM{}, \EXTENDS{}, \FALSE{}, \FINAL{}, \FINALLY{}, \FOR{}, \IF{}, \IN{}, \IS{}, \NEW{}, \NULL{}, \RETHROW, \RETURN{}, \SUPER{}, \SWITCH{}, \THIS{}, \THROW{}, \TRUE{}, \TRY{}, \VAR{}, \VOID{}, \WHILE{}, \WITH{}.
21455+
\commentary{%
21456+
Note that reserved words occur bold and unquoted in grammar rules
21457+
(e.g., \ASSERT{})
21458+
even though the consistent notation would use quotes
21459+
(e.g., \lit{assert}).
21460+
This notational abuse occurs because we believe
21461+
it makes the grammar rules more readable.%
21462+
}
2143021463

2143121464
\begin{grammar}
21432-
<LETTER> ::= `a' .. `z'
21433-
\alt `A' .. `Z'
21434-
21435-
<DIGIT> ::= `0' .. `9'
21436-
21437-
<WHITESPACE> ::= (`\\t' | ` ' | <NEWLINE>)+
21465+
<reservedWord> ::= \ASSERT{} | \BREAK{} | \CASE{} | \CATCH{} |
21466+
\CLASS{} | \CONST{} | \CONTINUE{}
21467+
\alt\hspace{-3mm} \DEFAULT{} | \DO{} | \ELSE{} | \ENUM{} | \EXTENDS{} |
21468+
\FALSE{} | \FINAL{} | \FINALLY{} | \FOR{} | \IF{} | \IN{} | \IS{}
21469+
\alt\hspace{-3mm} \NEW{} | \NULL{} | \RETHROW{} | \RETURN{} | \SUPER{} |
21470+
\SWITCH{} | \THIS{} | \THROW{} | \TRUE{} | \TRY{}
21471+
\alt\hspace{-3mm} \VAR{} | \VOID{} | \WHILE{} | \WITH{}
2143821472
\end{grammar}
2143921473

2144021474

0 commit comments

Comments
 (0)