X-Git-Url: https://git.piment-noir.org/?p=TP_AL_C.git;a=blobdiff_plain;f=lexer%2Fmain.c;h=0cb3dba1eaaaac205a7d7ec6de1a422cc94dc462;hp=3247e34c93d17bf8f2879b120b62a94941b7501e;hb=fde9417f42248445f08321ce9ee57bc2876f0b2c;hpb=d3eb30efdbdd46508f1034c1c1aed4bd5e23bbc5 diff --git a/lexer/main.c b/lexer/main.c index 3247e34..0cb3dba 100644 --- a/lexer/main.c +++ b/lexer/main.c @@ -56,6 +56,12 @@ init: i++; goto init; } + if (c == '\n') { + c = fgetc(source); + tokenValue[i] = c; + i++; + goto initLV1; + } if (c == '>') { c = fgetc(source); tokenValue[i] = c; @@ -74,12 +80,6 @@ init: i++; goto M1; } - if (c == '\n') { - c = fgetc(source); - tokenValue[i] = c; - i++; - goto initLV1; - } if (c == EOF) { goto FIN; } else { @@ -144,12 +144,18 @@ M1: } initLV1: - if (c == '\n' || c == '\t') { + if (c == ' ' || c == '\t') { 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; @@ -168,12 +174,6 @@ initLV1: i++; goto MC1; } - if (c == '\n') { - c = fgetc(source); - tokenValue[i] = c; - i++; - goto initLV1LV2; - } if (c == EOF) { goto FIN; } @@ -185,6 +185,9 @@ initLV1LV2: i++; goto initLV1LV2; } + if (istAlpha()) { + goto NPARA; + } if (c == '>') { c = fgetc(source); tokenValue[i] = c; @@ -197,9 +200,6 @@ initLV1LV2: i++; goto S1SS1; } - if (istAlpha()) { - goto NPARA; - } if (c == EOF) { goto FIN; } @@ -263,7 +263,7 @@ int main (int argc, char const *argv[]) { } 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