Beautify the token list output.
[TP_AL_C.git] / lexer / main.c
index fd6a5ccc021f95a3e4d4be840b7b0d59dbded866..0cdc70b9da3f066fa591869584e4a0fae7af8cd6 100644 (file)
@@ -119,11 +119,11 @@ SS2:
 
 SECTION:
     tokenType = SECTION;
-    return 1;
+    return EXIT_SUCCESS;
 
 SSECTION:
     tokenType = SSECTION;
-    return 1;
+    return EXIT_SUCCESS;
 
 M1:
     if (istAlpha()) {
@@ -188,11 +188,11 @@ initLV1LV2:
 
 NPARA:
     tokenType = NPARA;
-    return 1;
+    return EXIT_SUCCESS;
 
 MOT:
     tokenType = MOT;
-    return 1;
+    return EXIT_SUCCESS;
 
 MC2:
     if (isSeparator() || c == WEOF) {
@@ -202,15 +202,15 @@ MC2:
 
 MOTCLE:
     tokenType = MOTCLE;
-    return 1;
+    return EXIT_SUCCESS;
 
 FIN:
     tokenType = FIN;
-    return 1;
+    return EXIT_SUCCESS;
 
 error:
     tokenType = FIN;
-    return -1;
+    return EXIT_FAILURE;
 }
 
 int main() {
@@ -233,11 +233,11 @@ int main() {
     c = fgetwc(source); // lecture du premier caractere
     do {
         int scanrt = scanner();
-        if (scanrt == -1) {
+        if (scanrt == EXIT_FAILURE) {
             wprintf(L"Scanner error with token value: %ls\n", token[tokenFound].value);
             exit(EXIT_FAILURE);
         }
-        if (c != WEOF) {
+        if (tokenType == MOT || tokenType == MOTCLE) {
             wprintf(L"%20s: %ls\n", tokenTypestr[tokenType], token[tokenFound].value);
         } else {
             wprintf(L"%20s\n", tokenTypestr[tokenType]);
@@ -249,5 +249,5 @@ int main() {
     if (source != NULL) fclose(source); // fermeture du fichier source
     if (target != NULL) fclose(target); // fermeture du fichier target
 
-    return 0;
+    return EXIT_SUCCESS;
 }