X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/db56b1d3c3d4bc9ffb6500b1f40c27c77d868aa4..388ca1cdcd263e6ad8731e9680d4097a6820e87a:/doc/syntax.tex diff --git a/doc/syntax.tex b/doc/syntax.tex index b8ae797..21f835e 100644 --- a/doc/syntax.tex +++ b/doc/syntax.tex @@ -506,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. @@ -543,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} @@ -582,6 +601,8 @@ class Sub : Super { ::= \alt +\alt +\alt \alt \alt \end{grammar} @@ -659,9 +680,9 @@ class Example : Super { \begin{grammar} ::= @["class"@] $[\mbox{@}]$ ";" - ::= "=" + ::= @["=" @] - :: "{" "}" | + :: \end{grammar} An @ provides an initial value for one or more slots. If @@ -672,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}