Open GitMensch opened 2 years ago
You are right, of course, and one way around it could be restructuring the parser and add a "pre-preprocessing" phase (there are already hooks for this, libgixpp actually is structured as sort of a pipeline).
One more idea I am working on (this is more for the IDE, actually) is using GnuCOBOL's scanner/parser in cobc as a library, obviously extending it to support EXEC SQL (or generic EXEC
The main problem, from the experiments I have performed so far, is that it is difficult to this cleanly: the scanner/parser is obviously tightly connected (and rightly so) with the other parts of cobc, and you have to bring along a lot of libcob anyway. I'll keep investigating anyway to see if anything comes from it.
For the IDE and for cobc the following would be reasonable (it may also be done to gixsql but in this case this would be fixed to "newest GnuCOBOL version only - no older versions, no other compilers" which I'd recommend against), too:
EXEC
statements during its preprocessing, and remembers which EXEC
targets (in this case SQL
) the preprocessor can leave #error
directives in or outputs errors/warnings on its own.
If you would like to work on this in GnuCOBOL then I'd luckily create a feature-branch for you. (even then gixsql could have a 'stand alone' variant which doesn't require cobc - but then also don't support conditional compilation)
If you would like to work on this in GnuCOBOL then I'd luckily create a feature-branch for you. (even then gixsql could have a 'stand alone' variant which doesn't require cobc - but then also don't support conditional compilation)
This would be interesting and I'll take it into serious consideration but obviously it it will take some time before we get there.
The samples already include samples of conditional compilation in ISO2002 format, but those are just skipped completely for now. Additional there's the Micro Focus format to handle.
Actually doing the conditional compilation is important for "partial" construct, as those must lead the parser to fail currently. Example:
With the current "ignore the directives" approach this leads to bad COBOL (two
OCCURS
).Note: nothing that needs to be done "soon", just an issue to keep in mind when working on the parser, maybe with mridoni/gixsql#20.