#include "collection.h" #include "parse.h" #include #include #include #include #include int main(int argc, char* argv[]) { if (argc < 2) { fprintf(stderr, "error: no filename\n"); return EXIT_FAILURE; } char* filename = argv[1]; char* text = read_textfile(filename); if (!text) { return EXIT_FAILURE; } printf("--- text ---\n%s\n", text); Preproc* preproc; preproc_init(&preproc, strdup(filename), text); printf("--- tokens ---\n"); int line = 1; int col = 1; Tok tok; while ((tok = preproc_next(preproc)).ty != Tok_Eof) { // printf("%s\t%s\n", tokty_str(tok.ty), tok.text); if (line > tok.line) { line = 0; } while (line < tok.line) { printf("\n"); line += 1; col = 1; } while (col < tok.col) { printf(" "); col += 1; } printf("%s", tok.text); line = tok.line; col = tok.col + strlen(tok.text); } fputs("\n", stdout); preproc_deinit(preproc); }