/*!@file \brief IR Driver \details This is a testing driver for the IR system of APC. \author Jordan Lavatai \date Aug 2016 ----------------------------------------------------------------------------*/ /* Standard */ #include //print #include #include //lib errors /* Internal */ #include extern //scanner.c int scanner(void); extern //scanner.c int scanner_init(void); extern //scanner.c void scanner_quit(void); extern //parser.tab.h YYSTYPE yylval; extern //lexer.c int lexer(void); extern //lexer.c int lexer_init(void); /* Ansi Term Colors */ #define RED "\x1b[31m" #define GREEN "\x1b[32m" #define YELLOW "\x1b[33m" #define BLUE "\x1b[34m" #define MAGENTA "\x1b[35m" #define CYAN "\x1b[36m" #define CLRC "\x1b[0m" //clear current color int main(void); int test_init(void); int test_scan(void); int test_lex(void); const char* cargs['Z'] = {0}; int main #define $($)#$ #define PRINTFAIL(U) printf(RED $(U) " FAILED\n" CLRC) #define PRINTPASS(U) printf(GREEN $(U) " PASSED\n" CLRC) #define PRINTINFO(S) printf(YELLOW S CLRC) #define RUN_UNIT(U,T) \ do { \ PRINTINFO(T); \ if (U()) \ PRINTFAIL(U); \ else \ PRINTPASS(U); \ } while (0) () { cargs['d'] = "../../src"; RUN_UNIT(test_scan,"Scanning\n"); return 0; } int test_scan () { static int scanned_total = 0; static int n = 0; int scanned, lexed; int i; if (lexer_init()) { perror("LIB:"); return -1; } loop: if ((lexed = test_lex()) == 0) { printf("No tokens to parse\n"); return 0; } else { printf("Parsed %i Token%c\n", lexed, lexed > 1 ? 's' : ' '); goto loop; } return 0; } int test_lex () { int tok_val, n = 0; while ((tok_val = lexer()) || yylval.val) { if (++n % 9 == 0) printf("\n"); printf("[T:%4i|Y:%4i]",tok_val,yylval.val); yylval.val = 0; } printf(";\n"); return n; }