Lexer actually lexes filenames now, and odats are made out of mapvariants
[henge/webcc.git] / src / bin / tools / testapc.c
index c51ba41..77b825e 100644 (file)
@@ -9,6 +9,7 @@
 #include <stdio.h>  //print
 #include <errno.h>  //errors
 #include <string.h> //strnlen
+#include <setjmp.h> //non-local jumps
 /* Posix */
 #include <stdlib.h> //exit
 #include <unistd.h> //getopt
@@ -28,9 +29,11 @@ int testapc_yyparse(void);
 int test_yyparse(void);
 
 extern //bison
-int yyparse(void);
+int  yyparse(void);
 extern //lexer.c
 int  lexer_init(void);
+extern //scanner.c
+int  scanner_init(void);
 extern //apc.c
 const char* cargs['Z'];
 
@@ -39,6 +42,9 @@ YYSTYPE yylval;
 extern //lexer.c
 int  lexer(void);
 
+static
+jmp_buf testapc_jump;
+
 /* Ansi Term Colors */
 #define RED     "\x1b[31m"
 #define GREEN   "\x1b[32m"
@@ -55,7 +61,8 @@ int main
 ( int   argc,
   char* argv[]
 )
-{ apc_main(argc, argv);
+{ setjmp(testapc_jump);
+  apc_main(argc, argv);
   printf(GREEN "PASS" CLRC "\n");
   exit(EXIT_SUCCESS);
 }
@@ -79,7 +86,7 @@ int testapc_yyparse
          return YYABORT;
        }
       bPassedTest = 't';
-      apc_main(0,NULL);
+      longjmp(testapc_jump,0);
     }
   return yyparse();
 }
@@ -113,13 +120,20 @@ int test_yyparse
          TOK_CASE(CLOPEN,'i');
          TOK_CASE(CLCLOSE,'i');
          default:
-           tok_string = "UNKNOWN";
+           tok_string = 0;
            tok_pattern[LOFFS] = 'i';
            break;
           case 0:
            goto done;
        }
-      printf(tok_pattern, tok_string, yylval.val);
+      if (tok_string == NULL)
+       { tok_pattern[TOFFS] = 'i';
+         printf(tok_pattern, tok, yylval.val);
+       }
+      else
+       { tok_pattern[TOFFS] = 's';
+         printf(tok_pattern, tok_string, yylval.val);
+       }
       if (i % 4 == 0 || yylval.val == 0)
        printf(";\n");
     }