← every case · 2000 · string forms
a Zig multiline string literal is written as one \\ line per line of text, and each \\ opens a raw string that runs to the end of its own line with no closing symbol. The first line holds // right after \\, so a counter that reads no \\ string and ignores punctuation beside a comment counts that line as a comment, while the second holds a lone double quote, which opens an unclosed string in a counter whose double quotes cross lines. Two real comments follow the string, so taking the first line as a comment and losing the comments below to the lone quote cannot cancel out
| 1 | codecodecodecodecodecodecode | const msg = |
| 2 | codecodecodecodecodecodecode | \\// inside the string |
| 3 | codecodecodecodecodecodecode | \\it holds one " quote |
| 4 | codecodecodeextracodecodecode | ; |
| 5 | commentscommentscommentscommentscommentscommentscomments | // a real comment |
| 6 | commentscommentscommentscommentscommentscommentscomments | // a second real comment |
| 7 | codecodecodecodecodecodecode | const x = 1; |
stringcommentthe tag around another language
cloc --json --config /tmp/linejudge-empty-file cases/2000-string_forms/2200-line_string_holding_a_comment_symbol_and_a_quote/input.zig
--strip-str-comments
cloc --json --config /tmp/linejudge-empty-file cases/2000-string_forms/2200-line_string_holding_a_comment_symbol_and_a_quote/input.zig --strip-str-comments
cloc --json --config /tmp/linejudge-empty-file cases/2000-string_forms/2200-line_string_holding_a_comment_symbol_and_a_quote/input.zig --docstring-as-code
codestats cases/2000-string_forms/2200-line_string_holding_a_comment_symbol_and_a_quote/input.zig --output json-compact --include-generated --no-gitignore --hidden --no-config
mezura cases/2000-string_forms/2200-line_string_holding_a_comment_symbol_and_a_quote/input.zig --output json --hide timing --no-default-config --no-local --counting content
mezura cases/2000-string_forms/2200-line_string_holding_a_comment_symbol_and_a_quote/input.zig --output json --hide timing --no-default-config --no-local --counting region
the \\ on line 2 opens a string that does not close when the line ends, so every line from there to the end of the file counts as code, and the answer is the same with the quote on line 3 taken out
scc --format json --no-config cases/2000-string_forms/2200-line_string_holding_a_comment_symbol_and_a_quote/input.zig
its Zig carries no \\ string symbol, so the quote on line 3 opens a string that crosses lines and swallows both comments below it. With that quote taken out the file comes out right
tokei --output json cases/2000-string_forms/2200-line_string_holding_a_comment_symbol_and_a_quote/input.zig