X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/ae0f15ee8427fa91cfd1945bfded847032cb8a25..c808d837f8b1a3baf4ba5871ddc3a82822de7f9e:/doc/syntax.tex?ds=sidebyside diff --git a/doc/syntax.tex b/doc/syntax.tex index 560dc47..15948cb 100644 --- a/doc/syntax.tex +++ b/doc/syntax.tex @@ -58,7 +58,7 @@ enough that they deserve special notation. \syntax{$x^*$ ::= $[x]$ ::= $\epsilon$ @! $[x]$ $x$} \end{quote} -\item $x^+$ abbreviates @$[x]$, denoting a sequence of zero or +\item $x^+$ abbreviates @$[x]$, denoting a sequence of one or more occurrences of $x$: \begin{quote} \syntax{$x^+$ ::= $[x]$ ::= $[x]$ $x$} @@ -451,6 +451,7 @@ recognized. \alt "bool" | "_Bool" \alt "imaginary" | "_Imaginary" | "complex" | "_Complex" \alt +\alt \alt ::= | "const" | "volatile" | "restrict" @@ -460,6 +461,10 @@ recognized. ::= "atomic" | "_Atomic" + ::= "(" ")" + + ::= "alignas" "_Alignas" + ::= \end{grammar} @@ -475,7 +480,8 @@ defined in the built-in module. Declaration specifiers may appear in any order. However, not all combinations are permitted. A declaration specifier must consist of zero or -more @s, and one of the following, up to reordering. +more @s, zero or more @s, and one of the +following, up to reordering. \begin{itemize} \item @ \item @ @@ -500,29 +506,30 @@ All of these have their usual C meanings. \subsubsection{Declarators} \begin{grammar} -$[k]$ ::= @^* $[k]$ +$[k, a]$ ::= @^* $[k, a]$ -$[k]$ ::= $k$ -\alt "(" $[k]$ ")" -\alt $[k]$ @ +$[k, a]$ ::= $k$ +\alt "(" $[k, a]$ ")" +\alt $[k, a]$ @$[a]$ ::= "*" @^* - ::= "[" "]" -\alt "(" ")" +$[a]$ ::= "[" "]" +\alt "(" $a$ ")" ::= $\epsilon$ | "..." \alt $[\mbox{@}]$ @["," "..."@] ::= @^+ - ::= $[\epsilon]$ + ::= $[\epsilon, \mbox{@}]$ ::= $[\mbox{@ @! $\epsilon$}]$ + ::= + $[\mbox{@ @! $\epsilon$}, \mbox{@}]$ - ::= $[\mbox{@}]$ - - ::= "." + ::= + $[\mbox{@}, \mbox{@}]$ \end{grammar} The declarator syntax is taken from C, but with some differences. @@ -537,6 +544,24 @@ The declarator syntax is taken from C, but with some differences. The remaining differences are (I hope) a matter of presentation rather than substance. +There is additional syntax to support messages and methods which accept +keyword arguments. + +\begin{grammar} + ::= @["=" @] + + ::= + @[$[\mbox{@}]$@] + "?" @[$[\mbox{@}]$@] + + ::= @! + + ::= "." + +$[k]$ ::= + $[k, \mbox{@}]$ +\end{grammar} + \subsection{Class definitions} \label{sec:syntax.module.class} @@ -576,6 +601,8 @@ class Sub : Super { ::= \alt +\alt +\alt \alt \alt \end{grammar} @@ -653,9 +680,9 @@ class Example : Super { \begin{grammar} ::= @["class"@] $[\mbox{@}]$ ";" - ::= "=" + ::= @["=" @] - :: "{" "}" | + :: \end{grammar} An @ provides an initial value for one or more slots. If @@ -666,15 +693,28 @@ The first component of the @ must be the nickname of one of the class's superclasses (including itself); the second must be the name of a slot defined in that superclass. -The initializer has one of two forms. -\begin{itemize} -\item A @ enclosed in braces denotes an aggregate initializer. - This is suitable for initializing structure, union or array slots. -\item A @ \emph{not} beginning with an open brace is a `bare' - initializer, and continues until the next @`,' or @`;' which is not within - nested brackets. Bare initializers are suitable for initializing scalar - slots, such as pointers or integers, and strings. -\end{itemize} +An @|initarg| property may be set on an instance slot initializer (or a +direct slot definition). See \xref{sec:concepts.lifecycle.birth} for the +details. An initializer item must have either an @|initarg| property, or an +initializer expression, or both. + +Each class may define at most one initializer item with an explicit +initializer expression for a given slot. + +\subsubsection{Initarg items} +\begin{grammar} + ::= + "initarg" + @^+ + $[\mbox{@}]$ ";" +\end{grammar} + +\subsubsection{Fragment items} +\begin{grammar} + ::= "{" "}" + + ::= "init" | "teardown" +\end{grammar} \subsubsection{Message items} \begin{grammar}