fortran-src
fortran-src copied to clipboard
What to do with inline comments?
Currently we have BlComment
and PUComment
AST nodes that store the comment text for whole-line comments, depending on context. However we have not figured out an adequate way to represent inline comments that come after another statement. This is mainly because it would require adding a comment field to every type of statement, or so it seems. Another idea is to create a wrapper AST node that would store the code statement plus the comment, however this complicates analysis of statements.
Placeholder issue.
I have recently been thinking about this, as there are cases where multiline conditionals may be refactored and we want to avoid losing inline comments which is a bit trickier when they're not in the AST. In these cases adding a comment field to statements wouldn't be adequate, as these occur after expression nodes.
Perhaps inline comments could be added as annotations during the parsing stage, and then analysis could keep these annotations in the prevAnnotation
field, this would allow analysis to remain the same.
The annotation can't be used by the parser, by design, it's parametric.