Skip to content

Commit a1d2eea

Browse files
committed
Allow for modifiers in struct and enum. Define what a modifier is.
1 parent 4a12683 commit a1d2eea

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

specification/chap-opendtrace-dlang.tex

+24-7
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,41 @@ \section{Language grammar}
105105

106106
% FIXME: SturctOrUnionSpec should include things like typedef and so on
107107
\begin{grammar}
108-
<StructOrUnionSpec> ::= ( `struct' | `union' ) [ <Identifier> ] \newline
108+
<StructOrUnionSpec> ::= <Modifier> ( `struct' | `union' ) [ <Identifier> ] \newline
109109
`{' <StructDeclList> `}' [ <VarList> ] `;'
110110
\alt ( `struct' | `union' ) <Identifier> [ <VarList> ] `;' ;
111111

112112
<StructDeclList> ::= <Type> <VarList> `;' \{ <Type> <VarList> `;' \} ;
113-
\end{grammar}
114-
115-
TODO
116113

117-
% FIXME: Enum should allow for typedefs/... as well.
118-
\begin{grammar}
119-
<EnumSpecifier> ::= `enum' [ <Identifier> ] \newline
114+
<EnumSpecifier> ::= <Modifier> `enum' [ <Identifier> ] \newline
120115
`{' <EnumDeclList> `}' [ <VarList> ] `;'
121116
\alt `enum' <Identifier> [ <VarList> ] `;' ;
122117

123118
<EnumDeclList> ::= <Identifier> [ `=' <Identifier> ] [ `,' ] ;
124119
\end{grammar}
125120

121+
\noindent
122+
Here we introduce a new non-terminal, \texttt{Modifier} which encapsulates the
123+
modifiers that may occur before a \texttt{struct} or \texttt{enum} definition.
124+
It is defined as follows:
125+
126+
\begin{grammar}
127+
<Modifier> ::= `const'
128+
\alt `volatile'
129+
\alt `typedef'
130+
\alt `register'
131+
\alt `restrict'
132+
\alt `static'
133+
\alt `extern' ;
134+
\end{grammar}
135+
136+
Eventhough \texttt{Modifier} is permissive in terms of what keywords are
137+
allowed, the definitions of these keywords are equivalent to those in C and may
138+
only be used when appropriate. The compiler may choose to emit a warning and
139+
ignore modifiers that are not applicable or it may choose to be more strict and
140+
treat misuse of a modifier as an error. Using these modifiers when not
141+
applicable is considered undefined behaviour. \newline
142+
126143
\section{Safety}
127144
\label{sec:safety}
128145

0 commit comments

Comments
 (0)