Already looking forward to `grep`ing warning emojis in output.
What's next? Poop emoji for errors?
(BTW my terminal does not even support emojis.)
my $line = "infinite-loop-linked-list.c:30:10: warning: infinite loop [CWE-835] [-Wanalyzer-infinite-loop]";
grammar gcc {
token filename { <-[:]>+ };
token linenumber { \d+ };
token colnumber { \d+ };
token severity { info|warning|error };
token message { .* $$ };
regex diagnostic { <filename>
[\:] <linenumber>
[\:] <colnumber>
[\:]\s <severity>
[\:]\s <message>
};
token TOP { <diagnostic> };
}
say gcc.parse($line);
which when run produces the obvious output: 「infinite-loop-linked-list.c:30:10: warning: infinite loop [CWE-835] [-Wanalyzer-infinite-loop]」
diagnostic => 「infinite-loop-linked-list.c:30:10: warning: infinite loop [CWE-835] [-Wanalyzer-infinite-loop]」
filename => 「infinite-loop-linked-list.c」
linenumber => 「30」
colnumber => 「10」
severity => 「warning」
message => 「infinite loop [CWE-835] [-Wanalyzer-infinite-loop]」
I’ll leave handling filenames containing colons as an exercise for the reader.The emoji just focus the reader’s eye on the most critical line of the explanation.