« Mkd (Extracteur de documents)/Comprendre les options » : différence entre les versions

Contenu supprimé Contenu ajouté
Ligne 225 :
===== Mettre à jour la structure de chaque fichier =====
avec le pseudo code. Code 'S' et 'O' et 'w', <br />
'''exerciceasm.struct'''
{{Exercice|
titre=Aperçu|
solution=
'''mkd -Cswn OSw asm.c asm.struct'''
}}
<pre>
(fichier asm.c :)
98 { /*S asm */
109 /*O tant que pas fin de fichier source (c1, c2, c3 diff�rents de EOF)*/
111 { /*S tq !EOF */
112 /*O si d�but de texte faire c1=LF */
114 /*O sinon prendre pour c1 le char suivant */
116 /*O si le char est NL rep�rer la position qui suit 'NL' (rep�rer dans
117 -- l'entier long nl) */
119 { /*S reperage debut de ligne */
123 } /*S reperage debut de ligne */
125 /*O----- si le char est NL ---------------------------------------------------*/
127 { /*S ; en colonne 1 */
130 /*O si c1 est suivi par c2 = ';' et
131 -- si codes[0]=0 ou si suivi par un des 5 char code d'utilisateur */
141 /*O alors copier les caract�res dans le fichier doc, et si option s
142 -- ajouter au terminal */
143 { /*S copier */
144 /*O si option n ins�rer le num�ro de ligne et si option s l'ajouter au
145 -- terminal */
147 { /*S n */
150 } /*S n */
151 /*O si l'option t est fausse (pas de texte seul) */
153 { /*S !t */
154 /*O copier le d�but de ligne */
156 /*O si option s copier le commentaire au terminal */
158 { /*S si opt s */
161 } /*S si opt s */
162 } /*S !t */
163 /*O sinon si il ne faut pas copier tout le commentaire:
164 -- reculer de 1 caract�re */
166 /*O tant que l'on a pas trouv� le caract�re fin de ligne NL ('\n')*/
168 { /*S w copy line */
169 /*O copier les caract�res de la ligne */
172 } /*S w copy line */
173 /*O copier aussi le caract�re de fin de ligne et, avec l'option s
174 -- envoyer le retour-chariot au terminal */
177 /*O revenir sur LF du fichier source */
179 } /*S copier */
180 /*O sinon restituer les deux derniers caract�res */
182 { /*S sinon */
185 } /*S sinon */
186 } /*S ; en colonne 1 */
188 /*O--------- sinon si c1 = ';' est dans la ligne ----------------------------*/
190 { /*S else */
191 /*O si le caract�re c1 est une tabulation incr�menter tab */
193 /*O sinon si c1 = ; */
195 /*O alors: */
196 { /*S char = ; */
198 /*O si codes[0]=0 ou si suivi par c2 = char code utilisateur */
206 /*O alors: */
207 { /*S commentaire page */
208 /*O rep�rer la position de d�but de commentaire */
211 /*O si l'option bool�enne t est fausse (pas de texte seul) */
213 { /*S !t */
214 /*O se positionner en d�but de ligne */
217 /*O si l'option n est vraie, ins�rer le num�ro de ligne */
219 { /*S n (num�ro de ligne) */
221 /*O si option s vraie, ajouter le num�ro de ligne � l'�cran */
223 } /*S n */
224 /*O copier toute la ligne tq pas NL (CR/LF), dans le fichier doc */
226 { /*S w */
229 } /*S w*/
230 } /*S !t */
231 /*O sinon: (option t) */
233 { /*S option t */
234 /*O se positionner en dedut de ligne */
237 /*O si option n vraie, ins�rer le num�ro de ligne */
239 { /*S n (numero de ligne) */
241 /*O si s vrai, ajouter le num�ro de ligne � l'�cran */
243 } /*S n */
246 //P { /*S tabs */
249 //P } /*S tabs */
250 /*O copier toute la ligne jusqu'� la position commentaire */
252 { /*S w */
255 } /*S w*/
256 /*O ajouter un espace pour remplacer le caract�re ';' */
258 { /*S espaces */
261 } /*S espaces */
262 /*O puis copier le commentaire tant que NL n'est pas trouv� */
264 { /*S copier commentaire */
267 } /*S copier commentaire */
268 } /*S option t */
269 putc('\n',pfdoc);if(s)putch('\n'); /*O copier NL */
270 ungetc(c1,pnfile); /*O revenir sur NL */
271 } /*S commentaire page */
272 /*O sinon: */
274 { /*S*/
275 /*O revenir un caract�re en arri�re */
277 } /*S*/
278 } /*S char = ; */
279 } /*S else */
280 } /*S tq !EOF */
282 } /*S asm */�
</pre>
 
'''mkd -Cswn OSw cpp.c cpp.struct'''
<pre>
(fichier cpp.c :)
210 { //S Function begin for Konsole version
216 extern unsigned char n,s,t; //w Konsole version
217 extern char codes[]; //w Konsole version
219 { //S Function begin for gtkmm
227 /*O While next character is not End Of File */
229 { /*S while !EOF */
231 /*O If it is the first char then c1=LF */
233 /*O Else c1 is the next char */
235 /*O If the char is New Line
236 -- then mark the followed position in memory (long int 'nl') */
238 { /*S NL */
242 } /*S NL */
244 { /*S !NL */
245 /*O If the char is '\t' tabulation, then tab++ */
247 /*O Else if the char is '/' */
249 /*O Then: */
250 { /*S char = '/' */
253 /*O If the char is followed by c2 = '*' or '/' and if options[0]=0
254 -- or if it is followed by user char 'code[]' */
263 /*O Then: */
264 { /*S Treat the comment C */
265 /*O If c2 = '/' set the Boolean 'ligne' to true (=1) */
267 /*O Recognise the comment position */
271 /*O If option n is true then insert the line number */
273 { /*S*/
276 } /*S*/
277 /*O If option t is not true,
278 then: */
280 { /*S option t false */
281 /*O Positioning at the beginning line */
283 /*w or: fseek(pnfile,(nl-ftell(pnfile)),1); */
284 /*O Copy the line to comment in the doc file */
286 { /*S*/
290 } /*S*/
291 } /*S option t false */
292 /*O Else: (option t) */
294 { /*S option t true */
295 /*O Copy the tabulations as much as there is in the source file */
297 { /*S*/
300 } /*S*/
301 /*O Copy space up to comment */
303 { /*S*/
306 } /*S*/
307 } /*S option t true and */
308 /*O If the line boolean 'ligne' is true (=1) */
310 /*O Then:
311 copy the comment to End Of Line (EOL) or (EOF) */
312 { /*S Copy the line */
314 { /*S Copy the comment */
317 } /*S Copy the comment */
319 } /*S Copy the line */
320 /*O Else while does not find the char * followed by / :
321 copy the comment */
323 { /*S Else !(line) copy to end of page comment */
325 { /*Sw*/
327 { /*S*/
328 /*www if(c1=='\n') fprintf(pfdoc, "%s", NL );*/
329 /*www /*P CR/LF under DOS */
330 /*www Else */
333 /*O If option n is true and char c1=NL
334 then: insert the line number following NL */
336 { /*S*/
340 } /*S*/
341 } /*S*/
343 { /*S*/
345 { /*S*/
348 } /*S*/
350 { /*S False alarm */
354 } /*S False alarm */
355 } /*S*/
356 } /*Sw*/
357 } /*S Else !(line) copy to end of page comment */
360 /*O BEGIN FULL_LINE *** Compil. option */
361 /*O If t option is false,
362 then: */
364 { /*S Option t false */
365 /*O Copy the comment to End Of Line or EOF
366 -- including '\r' (CR/LF) under DOS */
368 { /*S*/
371 } /*S*/
372 } /*S Option t false */
373 /*O Else (option t true) */
376 /*O END FULL_LINE *** Compil. option */
378 /*O t is true by default if FULL_LINE is not denined at the
379 compilation */
380 { /*S (t is true) */
381 /*O Go to EOL without copying, except the carriage return */
383 { /*Sw*/
385 { /*S*/
388 } /*S*/
389 } /*Sw*/
390 } /*S (t is true) */
391 /*O And next copy New Lines under this form: \n */
396 /*O And backward to NL */
398 } /*S Treat the comment C */
399 /*O Else: (it is not a comment) */
401 { /*S Not a comment */
402 /*O Back behind two characters */
405 } /*S Not a comment */
406 } /*S endif char = '/' */
407 } /*S endif!NL */
408 } /*S end tq !EOF */
409 /*O Return of a character back to avoid the End Of File EOF ! */
410 /*w Verify in tests this � character back � with EOF and EOL at end of file */
420 } /*S End funtion cpp_ konsole, or windowed version with gtkmm */�
</pre>
}}
 
===== Mettre à jour la documentation globale pour les programmeurs =====