LogicalFile.Macros.LineComment (LogicalFile v1.1.1)

View Source

A sample implementation of a macro that supports single-line comments where a comment expression is recognised at the beginning of a line and it transforms the entire content of that line into whitespace. Note that this does not allow a line comment to appear at the end of an expression!

While a regular expression could be specified to recognise whitespace as part of the comment marker a more sophisticated implementation would allow the comment marker to appear after an expression. It is also left as an exercise to implement multi-line comments (a la C /.../)

Summary

Functions

The general strategy is to process sections in order. For each section find any line matching the expression and transform the entire contents of the line into whitespace.

Functions

process_comments(file, expr)

The general strategy is to process sections in order. For each section find any line matching the expression and transform the entire contents of the line into whitespace.