fortran-src icon indicating copy to clipboard operation
fortran-src copied to clipboard

What to do with inline comments?

Open mrd opened this issue 6 years ago • 2 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.

mrd avatar Feb 13 '19 15:02 mrd

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.

RaoulHC avatar May 26 '20 12:05 RaoulHC

The annotation can't be used by the parser, by design, it's parametric.

mrd avatar May 27 '20 00:05 mrd