repositories
/
TP_AL_C.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Increment the number of tokens found after the array storage.
[TP_AL_C.git]
/
lexer
/
main.c
diff --git
a/lexer/main.c
b/lexer/main.c
index 26ba1d5594ada06869ac350d6235bce78b048812..19fc34f8763db78ec958d8d31b7d4e656090b0c8 100644
(file)
--- a/
lexer/main.c
+++ b/
lexer/main.c
@@
-3,10
+3,13
@@
#include <string.h>
#include <stdbool.h>
#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 c;
unsigned int i = 0;
-char tokenValue[
50
];
+char tokenValue[
TOKEN_MAX_LENGTH
];
enum TokenType {
MOTCLE,
SECTION,
enum TokenType {
MOTCLE,
SECTION,
@@
-16,6
+19,7
@@
enum TokenType {
FIN
} tokenType;
const char* tokenTypestr[] = { "MOTCLE", "SECTION", "SSECTION", "NPARA", "MOT", "FIN" };
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() {
/* It looks silly to check for each characters but for debugging, it's just the way to go */
bool istAlpha() {
@@
-87,6
+91,7
@@
init:
}
MC1:
}
MC1:
+ // 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;
if (c == Titre[j] && j < strlen(Titre) - 1) {
c = fgetc(source);
tokenValue[i] = c;
@@
-247,6
+252,8
@@
int main (int argc, char const *argv[]) {
return -1;
}
return -1;
}
+ int tokenFound = 0;
+
do {
c = fgetc(source); // lecture du caractere suivant du fichier source
tokenValue[i] = c;
do {
c = fgetc(source); // lecture du caractere suivant du fichier source
tokenValue[i] = c;
@@
-261,6
+268,8
@@
int main (int argc, char const *argv[]) {
} else {
printf ("Token type found: %s\n", tokenTypestr[tokenType]);
}
} else {
printf ("Token type found: %s\n", tokenTypestr[tokenType]);
}
+ tokenList[tokenFound] = tokenTypestr[tokenType];
+ tokenFound++;
// reinit tokenValue
i = 0;
memset(tokenValue, 0, sizeof(tokenValue));
// reinit tokenValue
i = 0;
memset(tokenValue, 0, sizeof(tokenValue));