[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [photran] Hook for custom preprocessor
|
Hi Mike,
I'm working on a Fortran program which uses a homegrown preprocessor. It
has directives of the form ##IF etc., which cause Photran to complain of
unexpected extraneous characters. What are the most natural extension
point(s) to enable analysis and refactoring on such code? Will this
change much in version 5?
Preprocessing makes refactoring and source-level static analysis
extremely difficult, particularly when conditional compilation is
involved. One of my colleagues (Alejandra Garrido) did her entire PhD
dissertation on refactoring C-preprocessed code.
So, unfortunately, there isn't an extension point for custom preprocessors.
A big part of my research agenda for the Fall focuses on preprocessing.
Without going into the details, I hope to end up with something like
that, where you could plug in an arbitrary preprocessor and it would
heuristically try to map the syntactic and semantic models back to the
unpreprocessed code. But since that's an open research problem, I can't
guarantee anything. :)
At the moment, we treat C preprocessor lines as comments. So macros
(for example) can still kill the parser, but it works as a stopgap
measure. I could pretty easily modify the lexer/parser to do the same
with other types of directives, if that would help.
On that note, what other preprocessors are people using? m4? m5? sed?
others?
Jeff