%{
char workingDate[11]; /* The date being cycled through */
char lastUsedDate[11]; /* The date of the last date which has been completely parsed (A copy of workingDate so it can still be accessed after pointer change */
char nextDate[11]; /* The date contained within the next found token */
int bytesTotal = 0;
int flag = 0;
%}
%%
\-|\t|\n|\[ ;
(":"[0-9][0-9]":"[0-9][0-9]":"[0-9][0-9]" "\+"0""0""0""0"\] ;
[0-9][0-9].*"/"[0-9][0-9][0-9][0-9] { date(); }
[0-9]+ { size(); }
%%
date(){
strcpy(nextDate, yytext);
if( strcmp(nextDate, workingDate) == 1 ) {
strcpy(workingDate, yytext);
do_reset = 1;
if( bytesTotal != 0 ) printf("%s%10d\n", lastUsedDate, bytesTotal);
}
else {
flag = 0;
strcpy(lastUsedDate, yytext);
}
}
size(){
if( flag == 0 ) {
bytesTotal += atoi(yytext);
}
else {
bytesTotal = atoi(yytext);
flag = 0;
}
}
main() {
yylex();
}