From: Jérôme Benoit Date: Sat, 21 Oct 2017 16:53:02 +0000 (+0200) Subject: Fix the sub section detector. X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d3eb30efdbdd46508f1034c1c1aed4bd5e23bbc5;p=TP_AL_C.git Fix the sub section detector. Signed-off-by: Jérôme Benoit --- diff --git a/lexer/main.c b/lexer/main.c index 671d88f..3247e34 100644 --- a/lexer/main.c +++ b/lexer/main.c @@ -17,6 +17,7 @@ enum TokenType { } 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' || \ @@ -107,25 +108,30 @@ MC1: } S1SS1: - if (isSeparator() || c == EOF) { - goto SECTION; - } if (c == '=') { c = fgetc(source); tokenValue[i] = c; i++; goto SS2; } + if (isSeparator() || c == EOF) { + goto SECTION; + } + SS2: if (isSeparator() || c == EOF) { - goto SECTION; + goto SSECTION; } SECTION: tokenType = SECTION; return 1; +SSECTION: + tokenType = SSECTION; + return 1; + M1: if (istAlpha()) { c = fgetc(source); @@ -191,12 +197,12 @@ initLV1LV2: i++; goto S1SS1; } - if (c == EOF) { - goto FIN; - } if (istAlpha()) { goto NPARA; } + if (c == EOF) { + goto FIN; + } NPARA: tokenType = NPARA;