10 #include "type_hash.h"
15 void get_output_name(char *buf, size_t buflen, const char *inputname,
18 size_t last_dot = 0xffffffff;
20 for(const char *c = inputname; *c != 0; ++c) {
25 if(last_dot == 0xffffffff)
28 if(last_dot >= buflen)
29 panic("filename too long");
30 memcpy(buf, inputname, last_dot);
32 size_t extlen = strlen(newext) + 1;
33 if(extlen + last_dot >= buflen)
34 panic("filename too long");
35 memcpy(buf+last_dot, newext, extlen);
40 void compile(const char *fname)
42 FILE *in = fopen(fname, "r");
44 fprintf(stderr, "Couldn't open '%s': %s\n", fname, strerror(errno));
48 lexer_open_stream(in, fname);
56 void lextest(const char *fname)
58 FILE *in = fopen(fname, "r");
60 fprintf(stderr, "Couldn't open '%s': %s\n", fname, strerror(errno));
64 lexer_open_stream(in, fname);
67 lexer_next_preprocessing_token();
68 print_token(stdout, &lexer_token);
70 } while(lexer_token.type != T_EOF);
75 int main(int argc, char **argv)
85 if(argc > 2 && strcmp(argv[1], "--lextest") == 0) {
90 for(int i = 1; i < argc; ++i) {