larmel / lacc

A simple, self-hosting C compiler
MIT License
872 stars 64 forks source link

cpp can't be used for non-C files #19

Closed rofl0r closed 4 years ago

rofl0r commented 5 years ago

i'm evaluating a bunch of C preprocessor sources for usage as macro assembler in custom assembly files. when i try lacc on such a file (which is perfectly fine preprocessed by e.g. GCC's cpp) i get "Unrecognized input files.". btw, would it be hard to unwire the preprocessor code from the rest ?

larmel commented 5 years ago

What is the suffix of the files you are trying to process? Currently lacc will only recognize .c and .i as containing source code, but that is of course not necessarily correct. I need to find a better heuristic here to determine which files are meant for the linker and which are supposed to be processed.

The preprocessor should be very easy to extract from the rest, if you want to. Take a look at src/preprocessor/preprocess.c#L676, where only the preprocessor part is invoked in order to produce preprocessed output.

rofl0r commented 5 years ago

thanks! although meanwhile i'm almost finished writing my own ;) i was trying with -E (so i suppose this should turn off filetype detection)

larmel commented 4 years ago

I did some changes to improve language detection, and also have to option to explicitly set the input language with -x.