671d88f94286139bee7cd87159b149312c0e92c2
6 FILE *source
, *target
= NULL
;
18 const char* tokenTypestr
[] = { "MOTCLE", "SECTION", "SSECTION", "NPARA", "MOT", "FIN" };
21 if (c
== 'a' || c
== 'b' || c
== 'c' || c
== 'd' || c
== 'e' || c
== 'f' || c
== 'g' || \
22 c
== 'h' || c
== 'i' || c
== 'j' || c
== 'k' || c
== 'l' || c
== 'm' || c
== 'n' || \
23 c
== 'o' || c
== 'p' || c
== 'q' || c
== 'r' || c
== 's' || c
== 't' || c
== 'u' || \
24 c
== 'v' || c
== 'w' || c
== 'x' || c
== 'y' || c
== 'z' || \
25 c
== 'A' || c
== 'B' || c
== 'C' || c
== 'D' || c
== 'E' || c
== 'F' || c
== 'G' || \
26 c
== 'H' || c
== 'I' || c
== 'J' || c
== 'K' || c
== 'L' || c
== 'M' || c
== 'N' || \
27 c
== 'O' || c
== 'P' || c
== 'Q' || c
== 'R' || c
== 'S' || c
== 'T' || c
== 'U' || \
28 c
== 'V' || c
== 'W' || c
== 'X' || c
== 'Y' || c
== 'Z' || \
29 c
== '.' || c
== '?' || c
== '!' || c
== ',' || c
== ';' || c
== ':' || c
== '-' || \
30 c
== '\''|| c
== '#' || \
31 c
== '0' || c
== '1' || c
== '2' || c
== '3' || c
== '4' || c
== '5' || c
== '6' || \
32 c
== '7' || c
== '8' || c
== '9') {
39 if (c
== '\t' || c
== ' ' || c
== '\n') {
46 const char* Titre
= "Titre";
47 const char* Auteur
= "Auteur";
50 // The main loop get the next character
52 if (c
== ' ' || c
== '\t') {
89 if (c
== Titre
[j
] && j
< strlen(Titre
) - 1) {
96 if (c
== Auteur
[j
] && j
< strlen(Auteur
) - 1) {
110 if (isSeparator() || c
== EOF
) {
121 if (isSeparator() || c
== EOF
) {
136 if (isSeparator() || c
== EOF
) {
141 if (c
== '\n' || c
== '\t') {
210 if (isSeparator() || c
== EOF
) {
227 int main (int argc
, char const *argv
[]) {
229 // Ouvre le fichier test.txt en lecture seulement (le fichier doit exister) :
230 source
= fopen("test.txt", "r");
231 // Cree et ouvre un fichier target.html en lecture/ecriture
232 // avec suppression du contenu au prealable :
233 target
= fopen("target.html", "w+");
235 if (source
== NULL
) {
236 printf("Impossible d'ouvrir le fichier source\n");
240 if (target
== NULL
) {
241 printf("Impossible d'ouvrir le fichier target\n");
246 c
= fgetc(source
); // lecture du caractere suivant du fichier source
247 //fputc(c, target); // ecrire c dans le fichier target
250 int scanrt
= scanner();
252 printf ("Scanner error with token value: %s\n", tokenValue
);
256 printf ("Token type found: %s with value: %s\n", tokenTypestr
[tokenType
], tokenValue
);
258 printf ("Token type found: %s\n", tokenTypestr
[tokenType
]);
262 memset(tokenValue
, 0, sizeof(tokenValue
));
263 } while (c
!= EOF
); // tant que la fin du fichier n'est pas atteinte
265 if (source
!= NULL
) fclose(source
); // fermeture du fichier source
266 if (target
!= NULL
) fclose(target
); // fermeture du fichier target