Changeset 208
- Timestamp:
- Feb 7, 2008, 6:28:15 PM (18 years ago)
- Author:
- neil.c.c.brown
- Message:
-
Fixed the tock introduction to reflect Structured becoming parameterised.
- File:
-
- 1 edited
- docs/trunk/hacking-guide/tock-intro.tex (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
docs/trunk/hacking-guide/tock-intro.tex
r198 r208 94 94 \subsection{A.Structured} 95 95 96 The main item in the AST that I (Neil) found confusing at first was the Structured item. In case it 97 confuses anyone else I thought I would explain it here. Structured is the body of most occam constructs, 96 The main item in the AST that I (Neil) found confusing at first was the Structured item. 97 Thankfully, I've recently changed Structured to be parameterised, but I've left this explanation 98 in anyway, it case it helps. Structured is the body of most occam constructs, 98 99 such as SEQ, PAR, ALT, CASE. Because occam allows the inter-mingling of processes and declarations, 99 100 and also replication on most of its constructs (SEQ, PAR, ALT, IF) Structured eliminates redundancy 100 by grouping this together. So for example, given this occam pseudo-code: 101 by grouping this together. SEQ and PAR have a \lstinline|A.Structured A.Process| as their `body', 102 whereas, for example, ALT has a \lstinline|A.Structured A.Alternative|. 103 So for example, given this occam pseudo-code: 101 104 102 105 \occamsettings\begin{lstlisting} … … 112 115 A.Seq m 113 116 (A.Several m 114 [A.Only (削除) P (削除ここまで)m proc1115 ,A.Only (削除) P (削除ここまで)m proc2117 [A.Only(追記) (追記ここまで) m proc1 118 ,A.Only(追記) (追記ここまで) m proc2 116 119 ] 117 120 ) 118 121 \end{lstlisting} 119 122 120 You can see the combination of Seq with Several and Only (削除) P (削除ここまで)to nest the processes. Here's another example123 You can see the combination of Seq with Several and Only(追記) (追記ここまで) to nest the processes. Here's another example 121 124 of some occam and corresponding Haskell: 122 125 … … 132 135 A.Seq m 133 136 (A.Several m 134 [A.Only (削除) P (削除ここまで)m proc1135 ,A.Only (削除) P (削除ここまで)m137 [A.Only(追記) (追記ここまで) m proc1 138 ,A.Only(追記) (追記ここまで) m 136 139 (A.Par m A.PlainPar 137 140 (A.Several m 138 [A.Only (削除) P (削除ここまで)m proc2139 ,A.Only (削除) P (削除ここまで)m proc3141 [A.Only(追記) (追記ここまで) m proc2 142 ,A.Only(追記) (追記ここまで) m proc3 140 143 ] 141 144 ) … … 159 162 A.Seq m 160 163 (A.Several m 161 [A.Only (削除) P (削除ここまで)m proc1164 [A.Only(追記) (追記ここまで) m proc1 162 165 , (A.Several m 163 [A.Only (削除) P (削除ここまで)m proc2164 ,A.Only (削除) P (削除ここまで)m proc3166 [A.Only(追記) (追記ここまで) m proc2 167 ,A.Only(追記) (追記ここまで) m proc3 165 168 ] 166 169 ) … … 185 188 A.Par m A.PlainPar 186 189 (A.Several m 187 [A.Only (削除) P (削除ここまで)m proc1188 ,A.Rep m rep (A.Only (削除) P (削除ここまで)m proc2)190 [A.Only(追記) (追記ここまで) m proc1 191 ,A.Rep m rep (A.Only(追記) (追記ここまで) m proc2) 189 192 ] 190 193 ) … … 208 211 A.Seq m 209 212 (A.Several m 210 [A.Only (削除) P (削除ここまで)m proc1211 ,A.Specification m spec (A.Only (削除) P (削除ここまで)m proc2)213 [A.Only(追記) (追記ここまで) m proc1 214 ,A.Specification m spec (A.Only(追記) (追記ここまで) m proc2) 212 215 ] 213 216 ) … … 229 232 A.Seq m 230 233 (A.Several m 231 [A.Only (削除) P (削除ここまで)m proc1234 [A.Only(追記) (追記ここまで) m proc1 232 235 ,A.Specification m specX 233 (A.Specification m specY (A.Only (削除) P (削除ここまで)m proc2))236 (A.Specification m specY (A.Only(追記) (追記ここまで) m proc2)) 234 237 ] 235 238 ) 236 239 \end{lstlisting} 237 (削除) (削除ここまで)238 (削除) Note that each of the actual items in a Structured is named OnlyP (Process), OnlyA (ALT guard), etc. (削除ここまで)239 (削除) To be valid, any SEQ must contain no Only* items except OnlyP. Similarly, an ALT must contain (削除ここまで)240 (削除) no Only* items except OnlyA, and so on. (削除ここまで)241 240 242 241 \subsection{Monadic Code} … … 283 282 | (v, v') <- zip vs temps] 284 283 return $ A.Seq m $ foldl (\s spec -> A.Spec m spec s) 285 (A.Several m (map (A.Only (削除) P (削除ここまで)m) (first ++ second))) specs284 (A.Several m (map (A.Only(追記) (追記ここまで) m) (first ++ second))) specs 286 285 doProcess p = doGeneric p 287 286 \end{lstlisting}
Note:
See TracChangeset
for help on using the changeset viewer.