Fix for the NPARA detection.
[TP_AL_C.git] / lexer / main.c
index 3247e34c93d17bf8f2879b120b62a94941b7501e..0cb3dba1eaaaac205a7d7ec6de1a422cc94dc462 100644 (file)
@@ -56,6 +56,12 @@ init:
         i++;
         goto init;
     }
+    if (c == '\n') {
+        c = fgetc(source);
+        tokenValue[i] = c;
+        i++;
+        goto initLV1;
+    }
     if (c == '>') {
         c = fgetc(source);
         tokenValue[i] = c;
@@ -74,12 +80,6 @@ init:
         i++;
         goto M1;
     }
-    if (c == '\n') {
-        c = fgetc(source);
-        tokenValue[i] = c;
-        i++;
-        goto initLV1;
-    }
     if (c == EOF) {
         goto FIN;
     } else {
@@ -144,12 +144,18 @@ M1:
     }
 
 initLV1:
-    if (c == '\n' || c == '\t') {
+    if (c == ' ' || c == '\t') {
         c = fgetc(source);
         tokenValue[i] = c;
         i++;
         goto initLV1;
     }
+    if (c == '\n') {
+        c = fgetc(source);
+        tokenValue[i] = c;
+        i++;
+        goto initLV1LV2;
+    }
     if (istAlpha()) {
         c = fgetc(source);
         tokenValue[i] = c;
@@ -168,12 +174,6 @@ initLV1:
         i++;
         goto MC1;
     }
-    if (c == '\n') {
-        c = fgetc(source);
-        tokenValue[i] = c;
-        i++;
-        goto initLV1LV2;
-    }
     if (c == EOF) {
         goto FIN;
     }
@@ -185,6 +185,9 @@ initLV1LV2:
         i++;
         goto initLV1LV2;
     }
+    if (istAlpha()) {
+        goto NPARA;
+    }
     if (c == '>') {
         c = fgetc(source);
         tokenValue[i] = c;
@@ -197,9 +200,6 @@ initLV1LV2:
         i++;
         goto S1SS1;
     }
-    if (istAlpha()) {
-        goto NPARA;
-    }
     if (c == EOF) {
         goto FIN;
     }
@@ -263,7 +263,7 @@ int main (int argc, char const *argv[]) {
         } else {
             printf ("Token type found: %s\n", tokenTypestr[tokenType]);
         }
-        // reinit
+        // reinit tokenValue
         i = 0;
         memset(tokenValue, 0, sizeof(tokenValue));
     } while (c != EOF);    // tant que la fin du fichier n'est pas atteinte