X-Git-Url: https://git.piment-noir.org/?p=TP_AL_C.git;a=blobdiff_plain;f=lexer%2Flexical_analyzer.c;h=32efd0b5af735e648418568d72c43339dae6b10d;hp=6f995ba1c414b209d7603d8296a0b8e5821a8a8e;hb=dfbc1df9a95408687918ecc2bc6774d4646dd4f9;hpb=a20d3e7405deb4b0565e41968ff2047f4e9e37af diff --git a/lexer/lexical_analyzer.c b/lexer/lexical_analyzer.c index 6f995ba..32efd0b 100644 --- a/lexer/lexical_analyzer.c +++ b/lexer/lexical_analyzer.c @@ -47,6 +47,7 @@ static bool isEOF() { } int scanner() { + tokenValue[0] = 0; unsigned int i = 0; wchar_t m[6]; @@ -68,7 +69,7 @@ init: goto S1SS1; } if (isAlphaNum()) { - token[tokenFound].value[i] = c; + tokenValue[i] = c; i++; c = fgetwc(source); goto M1; @@ -80,12 +81,12 @@ init: MC1: if (c == L'A' && !wcscmp(fgetws(m, 6, source), L"uteur")) { - wcscpy((wchar_t*)token[tokenFound].value, L">Auteur"); + wcscpy((wchar_t*)tokenValue, L">Auteur"); c = fgetwc(source); goto MC2; } if (c == L'T' && !wcscmp(fgetws(m, 5, source), L"itre")) { - wcscpy((wchar_t*)token[tokenFound].value, L">Titre"); + wcscpy((wchar_t*)tokenValue, L">Titre"); c = fgetwc(source); goto MC2; } @@ -117,7 +118,7 @@ SSECTION: M1: if (isAlphaNum()) { - token[tokenFound].value[i] = c; + tokenValue[i] = c; i++; c = fgetwc(source); goto M1; @@ -137,7 +138,7 @@ initLV1: goto initLV1LV2; } if (isAlphaNum()) { - token[tokenFound].value[i] = c; + tokenValue[i] = c; i++; c = fgetwc(source); goto M1; @@ -182,6 +183,8 @@ NPARA: MOT: tokenType = MOT; + tokenValue[i] = 0; + wcscpy((wchar_t*)token[tokenFound].value, (wchar_t*)tokenValue); return EXIT_SUCCESS; MC2: @@ -192,6 +195,7 @@ MC2: MOTCLE: tokenType = MOTCLE; + wcscpy((wchar_t*)token[tokenFound].value, (wchar_t*)tokenValue); return EXIT_SUCCESS; FIN: @@ -201,13 +205,13 @@ FIN: error: if (tokenType == MOT || tokenType == MOTCLE) { fwprintf(stderr, L"%s error with token type: %s and value: %ls\n", - __func__, - tokenTypestr[tokenType], - token[tokenFound].value); + __func__, + tokenTypestr[tokenType], + tokenValue); } else { fwprintf(stderr, L"%s error with token type: %s\n", - __func__, - tokenTypestr[tokenType]); + __func__, + tokenTypestr[tokenType]); } fflush(stderr); tokenType = FIN;