From: Jérôme Benoit Date: Sat, 21 Oct 2017 20:07:13 +0000 (+0200) Subject: Fix for the NPARA detection. X-Git-Url: https://git.piment-noir.org/?p=TP_AL_C.git;a=commitdiff_plain;h=fde9417f42248445f08321ce9ee57bc2876f0b2c Fix for the NPARA detection. I'm afraid this is not enough ... Signed-off-by: Jérôme Benoit --- 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 diff --git a/lexer/test.txt b/lexer/test.txt index f07f979..727498e 100644 --- a/lexer/test.txt +++ b/lexer/test.txt @@ -9,6 +9,7 @@ chevron suivi du nom de l'auteur. Vient ensuite un ou plusieurs paragraphes optionnels comme celui que vous lisez. + Les paragraphes sont separes par une ou plusieurs lignes blanches. Vous etes donc entrain de lire un deuxieme paragraphe. Les sections sont introduites par le symbole plus suivi du titre, comme