@@ -105,24 +105,41 @@ \section{Language grammar}
105
105
106
106
% FIXME: SturctOrUnionSpec should include things like typedef and so on
107
107
\begin {grammar }
108
- <StructOrUnionSpec> ::= ( `struct' | `union' ) [ <Identifier> ] \newline
108
+ <StructOrUnionSpec> ::= <Modifier> ( `struct' | `union' ) [ <Identifier> ] \newline
109
109
`{' <StructDeclList> `}' [ <VarList> ] `;'
110
110
\alt ( `struct' | `union' ) <Identifier> [ <VarList> ] `;' ;
111
111
112
112
<StructDeclList> ::= <Type> <VarList> `;' \{ <Type> <VarList> `;' \} ;
113
- \end {grammar }
114
-
115
- TODO
116
113
117
- % FIXME: Enum should allow for typedefs/... as well.
118
- \begin {grammar }
119
- <EnumSpecifier> ::= `enum' [ <Identifier> ] \newline
114
+ <EnumSpecifier> ::= <Modifier> `enum' [ <Identifier> ] \newline
120
115
`{' <EnumDeclList> `}' [ <VarList> ] `;'
121
116
\alt `enum' <Identifier> [ <VarList> ] `;' ;
122
117
123
118
<EnumDeclList> ::= <Identifier> [ `=' <Identifier> ] [ `,' ] ;
124
119
\end {grammar }
125
120
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
+
126
143
\section {Safety }
127
144
\label {sec:safety }
128
145
0 commit comments