← every case · 2000 · string forms
Groovy opens a string that runs over several lines with three apostrophes. A counter that reads the first apostrophe as the start of an ordinary one line string ends that string where the line ends, and is then outside a string when it meets the two comment openers below, so it reads them as comments instead of as the text they are. The second one opens a block that nothing closes, which takes the rest of the file with it. A counter that does not treat the apostrophe as a string symbol of Groovy at all ends up in the same place, outside a string when the openers arrive. Case 2090 holds the same three character delimiter in Python
| 1 | codecodecodecodecode | def a = ''' |
| 2 | codecodecodecodecode | // this is text inside the string |
| 3 | codecodecodecodecode | /* and so is this |
| 4 | codecodecodecodecode | ''' |
| 5 | codecodecodecodecode | def b = 1 |
stringcommentthe tag around another language
a // at the head of a line opens a comment inside a triple apostrophe string too, so that line counts as one, while the /* under it opens nothing and takes no line with it
cloc --json cases/2000-string_forms/2190-triple_quote_read_as_three_short_ones/input.groovy
mezura cases/2000-string_forms/2190-triple_quote_read_as_three_short_ones/input.groovy --output json --hide timing --counting content
mezura cases/2000-string_forms/2190-triple_quote_read_as_three_short_ones/input.groovy --output json --hide timing --counting region
an apostrophe does not open a string in Groovy, so the three apostrophes are code, the // below counts as a comment and the /* under it opens a block that nothing closes
scc --format json cases/2000-string_forms/2190-triple_quote_read_as_three_short_ones/input.groovy
an apostrophe does not open a string in Groovy, so the three apostrophes are code, the // below counts as a comment and the /* under it opens a block that nothing closes
tokei --output json cases/2000-string_forms/2190-triple_quote_read_as_three_short_ones/input.groovy