X-Git-Url: https://git.piment-noir.org/?p=TP_AL_C.git;a=blobdiff_plain;f=lexer%2Fmain.c;h=3247e34c93d17bf8f2879b120b62a94941b7501e;hp=671d88f94286139bee7cd87159b149312c0e92c2;hb=d3eb30efdbdd46508f1034c1c1aed4bd5e23bbc5;hpb=4b580abd19143650b3e78d6ffbbb38c333570e5c 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;