X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/68a620ab55d7a8f5ba26a53ff2a0ba491cc2d25c..4307347660f48628e307f299eb4fac58ba35fd1a:/doc/syntax.tex diff --git a/doc/syntax.tex b/doc/syntax.tex index aff02ab..1090262 100644 --- a/doc/syntax.tex +++ b/doc/syntax.tex @@ -353,12 +353,14 @@ declarations instead. \begin{grammar} ::= - "code" ":" @[@] + "code" ":" @[@] "{" "}" ::= "[" $[\mbox{@}]$ "]" - ::= @^+ + ::= @^+ + + ::= @! "(" @^+ ")" \end{grammar} The @ will be output unchanged to one of the output files. @@ -367,18 +369,19 @@ The first @ is the symbolic name of an output file. Predefined output file names are @"c" and @"h", which are the implementation code and header file respectively; other output files can be defined by extensions. -The second @ provides a name for the output item. Several C -fragments can have the same name: they will be concatenated together in the -order in which they were encountered. +Output items are named with a sequence of identifiers, separated by +whitespace, and enclosed in parentheses. As an abbreviation, a name +consisting of a single identifier may be written as just that identifier, +without the parentheses. The @ provide a means for specifying where in the output file the output item should appear. (Note the two kinds of square brackets shown in the syntax: square brackets must appear around the constraints if they are present, but that they may be omitted.) Each comma-separated @ -is a sequence of identifiers naming output items, and indicates that the -output items must appear in the order given -- though the translator is free -to insert additional items in between them. (The particular output items -needn't be defined already -- indeed, they needn't be defined ever.) +is a sequence of names of output items, and indicates that the output items +must appear in the order given -- though the translator is free to insert +additional items in between them. (The particular output items needn't be +defined already -- indeed, they needn't be defined ever.) There is a predefined output item @"includes" in both the @"c" and @"h" output files which is a suitable place for inserting @"\#include" @@ -466,7 +469,7 @@ 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 @, and one of the following, up to reordering. +more @s, and one of the following, up to reordering. \begin{itemize} \item @ \item @"struct" @, @"union" @, @"enum" @ @@ -490,27 +493,27 @@ 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{@}]$ @["," "..."@] ::= @^+ - ::= $[\mbox{@ @! $\epsilon$}]$ - - ::= $[\mbox{@}]$ + ::= + $[\mbox{@ @! $\epsilon$}, \mbox{@}]$ - ::= "." + ::= + $[\mbox{@}, \mbox{@}]$ \end{grammar} The declarator syntax is taken from C, but with some differences. @@ -525,6 +528,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}