Changeset 187
- Timestamp:
- Jan 24, 2008, 6:20:09 PM (18 years ago)
- Author:
- neil.c.c.brown
- Message:
-
Added explanation of Specification in Structured
- File:
-
- 1 edited
- docs/trunk/hacking-guide/tock-intro.tex (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
docs/trunk/hacking-guide/tock-intro.tex
r186 r187 184 184 I have used `rep' as a short-hand for the replicator (which is not the focus here). Hopefully it is 185 185 now clear how Structured is used as a body for things. There is only one more aspect to explain, 186 which is definitions. 187 188 %TODO explain definitions 186 which is definitions, or rather specifications. 187 188 \occamsettings\begin{lstlisting} 189 SEQ 190 proc1 191 INT x: 192 proc2 193 \end{lstlisting} 194 195 According to occam scoping rules, `\lstinline|x|' is in scope for proc2. This is represented in the 196 AST as follows: 197 198 \haskellsettings\begin{lstlisting} 199 A.Seq m 200 (A.Several m 201 [A.OnlyP m proc1 202 ,A.Specification m spec (A.OnlyP m proc2) 203 ] 204 ) 205 \end{lstlisting} 206 207 Where `spec' is shorthand for the full specification of `x'. The specification (third argument) 208 is in scope for the whole of the body (the fourth argument). Multiple specifications lead to 209 nested Specifications: 210 211 \occamsettings\begin{lstlisting} 212 SEQ 213 proc1 214 INT x: 215 INT16 y: 216 proc2 217 \end{lstlisting} 218 219 \haskellsettings\begin{lstlisting} 220 A.Seq m 221 (A.Several m 222 [A.OnlyP m proc1 223 ,A.Specification m specX 224 (A.Specification m specY (A.OnlyP m proc2)) 225 ] 226 ) 227 \end{lstlisting} 228 229 Note that each of the actual items in a Structured is named OnlyP (Process), OnlyA (ALT guard), etc. 230 To be valid, any SEQ must contain no Only* items except OnlyP. Similarly, an ALT must contain 231 no Only* items except OnlyA, and so on. 189 232 190 233 \subsection{Monadic Code}
Note:
See TracChangeset
for help on using the changeset viewer.