repositories
/
TP_AL_C.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove a useless token value copy.
[TP_AL_C.git]
/
lexer
/
lexical_analyzer.c
diff --git
a/lexer/lexical_analyzer.c
b/lexer/lexical_analyzer.c
index 36acd5e214098b47d2078cac42a2bb4d4779c15a..32efd0b5af735e648418568d72c43339dae6b10d 100644
(file)
--- a/
lexer/lexical_analyzer.c
+++ b/
lexer/lexical_analyzer.c
@@
-22,7
+22,7
@@
static bool isAlphaNum() {
c == L'\''|| c == L'#' || \
c == L'0' || c == L'1' || c == L'2' || c == L'3' || c == L'4' || c == L'5' || c == L'6' || \
c == L'7' || c == L'8' || c == L'9' || \
c == L'\''|| c == L'#' || \
c == L'0' || c == L'1' || c == L'2' || c == L'3' || c == L'4' || c == L'5' || c == L'6' || \
c == L'7' || c == L'8' || c == L'9' || \
- //
FIXME: Accentued characters (aka multibytes characters) support is still buggy
+ //FIXME: Accentued characters (aka multibytes characters) support is still buggy
c == L'à' || c == L'â' || c == L'ç' || c == L'è' || c == L'é' || c == L'î' || c == L'ô' || \
c == L'ù' || c == L'û' || \
c == L'À' || c == L'Â' || c == L'Ç' || c == L'È' || c == L'É' || c == L'Î' || c == L'Ô' || \
c == L'à' || c == L'â' || c == L'ç' || c == L'è' || c == L'é' || c == L'î' || c == L'ô' || \
c == L'ù' || c == L'û' || \
c == L'À' || c == L'Â' || c == L'Ç' || c == L'È' || c == L'É' || c == L'Î' || c == L'Ô' || \
@@
-47,6
+47,7
@@
static bool isEOF() {
}
int scanner() {
}
int scanner() {
+ tokenValue[0] = 0;
unsigned int i = 0;
wchar_t m[6];
unsigned int i = 0;
wchar_t m[6];
@@
-68,7
+69,7
@@
init:
goto S1SS1;
}
if (isAlphaNum()) {
goto S1SS1;
}
if (isAlphaNum()) {
- token
[tokenFound].v
alue[i] = c;
+ token
V
alue[i] = c;
i++;
c = fgetwc(source);
goto M1;
i++;
c = fgetwc(source);
goto M1;
@@
-80,12
+81,12
@@
init:
MC1:
if (c == L'A' && !wcscmp(fgetws(m, 6, source), L"uteur")) {
MC1:
if (c == L'A' && !wcscmp(fgetws(m, 6, source), L"uteur")) {
- wcscpy((wchar_t*)token
[tokenFound].v
alue, L">Auteur");
+ wcscpy((wchar_t*)token
V
alue, L">Auteur");
c = fgetwc(source);
goto MC2;
}
if (c == L'T' && !wcscmp(fgetws(m, 5, source), L"itre")) {
c = fgetwc(source);
goto MC2;
}
if (c == L'T' && !wcscmp(fgetws(m, 5, source), L"itre")) {
- wcscpy((wchar_t*)token
[tokenFound].v
alue, L">Titre");
+ wcscpy((wchar_t*)token
V
alue, L">Titre");
c = fgetwc(source);
goto MC2;
}
c = fgetwc(source);
goto MC2;
}
@@
-117,7
+118,7
@@
SSECTION:
M1:
if (isAlphaNum()) {
M1:
if (isAlphaNum()) {
- token
[tokenFound].v
alue[i] = c;
+ token
V
alue[i] = c;
i++;
c = fgetwc(source);
goto M1;
i++;
c = fgetwc(source);
goto M1;
@@
-137,7
+138,7
@@
initLV1:
goto initLV1LV2;
}
if (isAlphaNum()) {
goto initLV1LV2;
}
if (isAlphaNum()) {
- token
[tokenFound].v
alue[i] = c;
+ token
V
alue[i] = c;
i++;
c = fgetwc(source);
goto M1;
i++;
c = fgetwc(source);
goto M1;
@@
-182,6
+183,8
@@
NPARA:
MOT:
tokenType = MOT;
MOT:
tokenType = MOT;
+ tokenValue[i] = 0;
+ wcscpy((wchar_t*)token[tokenFound].value, (wchar_t*)tokenValue);
return EXIT_SUCCESS;
MC2:
return EXIT_SUCCESS;
MC2:
@@
-192,6
+195,7
@@
MC2:
MOTCLE:
tokenType = MOTCLE;
MOTCLE:
tokenType = MOTCLE;
+ wcscpy((wchar_t*)token[tokenFound].value, (wchar_t*)tokenValue);
return EXIT_SUCCESS;
FIN:
return EXIT_SUCCESS;
FIN:
@@
-200,13
+204,16
@@
FIN:
error:
if (tokenType == MOT || tokenType == MOTCLE) {
error:
if (tokenType == MOT || tokenType == MOTCLE) {
- wpr_error(L"Scanner error with token type: %s and value: %ls\n",
- tokenTypestr[tokenType],
- token[tokenFound].value);
+ fwprintf(stderr, L"%s error with token type: %s and value: %ls\n",
+ __func__,
+ tokenTypestr[tokenType],
+ tokenValue);
} else {
} else {
- wpr_error(L"Scanner error with token type: %s\n",
- tokenTypestr[tokenType]);
+ fwprintf(stderr, L"%s error with token type: %s\n",
+ __func__,
+ tokenTypestr[tokenType]);
}
}
+ fflush(stderr);
tokenType = FIN;
exit(EXIT_FAILURE);
}
tokenType = FIN;
exit(EXIT_FAILURE);
}