repositories
/
TP_AL_C.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix for the NPARA detection.
[TP_AL_C.git]
/
lexer
/
main.c
diff --git
a/lexer/main.c
b/lexer/main.c
index 671d88f94286139bee7cd87159b149312c0e92c2..0cb3dba1eaaaac205a7d7ec6de1a422cc94dc462 100644
(file)
--- a/
lexer/main.c
+++ b/
lexer/main.c
@@
-17,6
+17,7
@@
enum TokenType {
} tokenType;
const char* tokenTypestr[] = { "MOTCLE", "SECTION", "SSECTION", "NPARA", "MOT", "FIN" };
} tokenType;
const char* tokenTypestr[] = { "MOTCLE", "SECTION", "SSECTION", "NPARA", "MOT", "FIN" };
+/* This looks silly to check for each characters but for debugging, it's just the way to go */
bool istAlpha() {
if (c == 'a' || c == 'b' || c == 'c' || c == 'd' || c == 'e' || c == 'f' || c == 'g' || \
c == 'h' || c == 'i' || c == 'j' || c == 'k' || c == 'l' || c == 'm' || c == 'n' || \
bool istAlpha() {
if (c == 'a' || c == 'b' || c == 'c' || c == 'd' || c == 'e' || c == 'f' || c == 'g' || \
c == 'h' || c == 'i' || c == 'j' || c == 'k' || c == 'l' || c == 'm' || c == 'n' || \
@@
-55,6
+56,12
@@
init:
i++;
goto init;
}
i++;
goto init;
}
+ if (c == '\n') {
+ c = fgetc(source);
+ tokenValue[i] = c;
+ i++;
+ goto initLV1;
+ }
if (c == '>') {
c = fgetc(source);
tokenValue[i] = c;
if (c == '>') {
c = fgetc(source);
tokenValue[i] = c;
@@
-73,12
+80,6
@@
init:
i++;
goto M1;
}
i++;
goto M1;
}
- if (c == '\n') {
- c = fgetc(source);
- tokenValue[i] = c;
- i++;
- goto initLV1;
- }
if (c == EOF) {
goto FIN;
} else {
if (c == EOF) {
goto FIN;
} else {
@@
-107,25
+108,30
@@
MC1:
}
S1SS1:
}
S1SS1:
- if (isSeparator() || c == EOF) {
- goto SECTION;
- }
if (c == '=') {
c = fgetc(source);
tokenValue[i] = c;
i++;
goto SS2;
}
if (c == '=') {
c = fgetc(source);
tokenValue[i] = c;
i++;
goto SS2;
}
+ if (isSeparator() || c == EOF) {
+ goto SECTION;
+ }
+
SS2:
if (isSeparator() || c == EOF) {
SS2:
if (isSeparator() || c == EOF) {
- goto SECTION;
+ goto S
S
ECTION;
}
SECTION:
tokenType = SECTION;
return 1;
}
SECTION:
tokenType = SECTION;
return 1;
+SSECTION:
+ tokenType = SSECTION;
+ return 1;
+
M1:
if (istAlpha()) {
c = fgetc(source);
M1:
if (istAlpha()) {
c = fgetc(source);
@@
-138,12
+144,18
@@
M1:
}
initLV1:
}
initLV1:
- if (c == '
\n
' || c == '\t') {
+ if (c == '
' || c == '\t') {
c = fgetc(source);
tokenValue[i] = c;
i++;
goto initLV1;
}
c = fgetc(source);
tokenValue[i] = c;
i++;
goto initLV1;
}
+ if (c == '\n') {
+ c = fgetc(source);
+ tokenValue[i] = c;
+ i++;
+ goto initLV1LV2;
+ }
if (istAlpha()) {
c = fgetc(source);
tokenValue[i] = c;
if (istAlpha()) {
c = fgetc(source);
tokenValue[i] = c;
@@
-162,12
+174,6
@@
initLV1:
i++;
goto MC1;
}
i++;
goto MC1;
}
- if (c == '\n') {
- c = fgetc(source);
- tokenValue[i] = c;
- i++;
- goto initLV1LV2;
- }
if (c == EOF) {
goto FIN;
}
if (c == EOF) {
goto FIN;
}
@@
-179,6
+185,9
@@
initLV1LV2:
i++;
goto initLV1LV2;
}
i++;
goto initLV1LV2;
}
+ if (istAlpha()) {
+ goto NPARA;
+ }
if (c == '>') {
c = fgetc(source);
tokenValue[i] = c;
if (c == '>') {
c = fgetc(source);
tokenValue[i] = c;
@@
-194,9
+203,6
@@
initLV1LV2:
if (c == EOF) {
goto FIN;
}
if (c == EOF) {
goto FIN;
}
- if (istAlpha()) {
- goto NPARA;
- }
NPARA:
tokenType = NPARA;
NPARA:
tokenType = NPARA;
@@
-257,7
+263,7
@@
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]);
}
- // reinit
+ // reinit
tokenValue
i = 0;
memset(tokenValue, 0, sizeof(tokenValue));
} while (c != EOF); // tant que la fin du fichier n'est pas atteinte
i = 0;
memset(tokenValue, 0, sizeof(tokenValue));
} while (c != EOF); // tant que la fin du fichier n'est pas atteinte