Removes //-comments and single-line C-style /* */ comments. Args: line: A line of C++ source. Returns: The line with single-line comments removed.
(line)
| 2104 | |
| 2105 | |
| 2106 | def CleanseComments(line): |
| 2107 | """Removes //-comments and single-line C-style /* */ comments. |
| 2108 | |
| 2109 | Args: |
| 2110 | line: A line of C++ source. |
| 2111 | |
| 2112 | Returns: |
| 2113 | The line with single-line comments removed. |
| 2114 | """ |
| 2115 | commentpos = line.find("//") |
| 2116 | if commentpos != -1 and not IsCppString(line[:commentpos]): |
| 2117 | line = line[:commentpos].rstrip() |
| 2118 | # get rid of /* ... */ |
| 2119 | return _RE_PATTERN_CLEANSE_LINE_C_COMMENTS.sub("", line) |
| 2120 | |
| 2121 | |
| 2122 | def ReplaceAlternateTokens(line): |
no test coverage detected
searching dependent graphs…