#include <string.h>
#include <stdbool.h>
-FILE *source, *target = NULL;
+#define TOKEN_MAX_LENGTH 50
+#define TOKEN_LIST_MAX 500
+
+FILE *source = NULL, *target = NULL;
char c;
unsigned int i = 0;
-char tokenValue[50];
+char tokenValue[TOKEN_MAX_LENGTH];
enum TokenType {
MOTCLE,
SECTION,
FIN
} tokenType;
const char* tokenTypestr[] = { "MOTCLE", "SECTION", "SSECTION", "NPARA", "MOT", "FIN" };
+const char* tokenList[TOKEN_LIST_MAX];
/* It looks silly to check for each characters but for debugging, it's just the way to go */
bool istAlpha() {
}
MC1:
- // FIXME: Partial match need a rewind in the characters extraction from the file
+ // FIXME: Partial match need a rewind in the characters extraction from the file
if (c == Titre[j] && j < strlen(Titre) - 1) {
c = fgetc(source);
tokenValue[i] = c;
return -1;
}
+ int tokenFound = 0;
+
do {
c = fgetc(source); // lecture du caractere suivant du fichier source
tokenValue[i] = c;
} else {
printf ("Token type found: %s\n", tokenTypestr[tokenType]);
}
+ tokenFound++;
+ tokenList[tokenFound] = tokenTypestr[tokenType];
// reinit tokenValue
i = 0;
memset(tokenValue, 0, sizeof(tokenValue));