rendered paste body%{
char cur_date[11];
char temp_date[11];
char print_date[11];
int cur_total = 0;
int do_reset = 0;
%}
%%
\[ ;
(":"[0-9]{2}){3}" "\+"0"{4}\] ;
[0-9]{2}.*"/"[0-9]{4} { match_date(); }
[0-9]+ { match_byte(); }
\- ;
\t ;
\n ;
%%
match_date() {
strcpy(temp_date, yytext);
if( strcmp(temp_date, cur_date) == 0 ) {
do_reset = 0;
strcpy(print_date, yytext);
}
else {
strcpy(cur_date, yytext);
do_reset = 1;
dump();
}
}
match_byte() {
if( do_reset == 1 ) {
cur_total = atoi(yytext);
do_reset = 0;
}
else {
cur_total += atoi(yytext);
}
}
dump() {
if( cur_total != 0 ) {
printf("%s%10d\n", print_date, cur_total);
}
}
main() {
yylex();
dump();
}