From d3eb30efdbdd46508f1034c1c1aed4bd5e23bbc5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 21 Oct 2017 18:53:02 +0200 Subject: [PATCH] Fix the sub section detector. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- lexer/main.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) 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; -- 2.34.1