6 ms·
A problem with tools like these is dealing with the C preprocessor. You can either parse preprocessed code (in which case you can't deal with the source file a
by pfdietz 7y ago
A problem with tools like these is dealing with the C preprocessor. You can either parse preprocessed code (in which case you can't deal with the source file as written, for example to do rewrites or searches on it), or you hack on it to somehow accept "common" preprocessor idioms (but that's fragile and imperfect).
- rightbyte 7y agoOf all the pitfalls how can the text replace preprocessor be the hard part? Just apply the preprocessor on any input before the rest of the processing. The project looks kinda cool. I wonder if I could hack it for "real time feedback" of c code in Eclipse some how.
- pfdietz 7y agoThat's fine if you want to compile or interpret the program for a particular set of definitions. It's not so good if you want to manipulate the program text as a structured object.
- userbinator 7y agoThat's fine if you want to compile or interpret the program for a particular set of definitions. That's what this does. No one said anything about your second point.
- pfdietz 7y agoI was pointing out a problem with C parsers. This is not really the tool's fault; it's a problem with the design of C itself. One would not have this problem with, say, Java. I don't much like preprocessors for this reason.
- userbinator 7y agoIt has a preprocessor. You'll start to see it at around 20% of the way through cparser.py . I don't know how standards-compliant it is, because I just quickly skimmed over the code, but fortunately the correct algorithm has been documented: https://www.spinellis.gr/blog/20060626/cpp.algo.pdf https://www.spinellis.gr/blog/20060626/cpp.algo.pdf