utt/lib/ser.l.template

31 lines
600 B
Plaintext

%{
#include<string.h>
int n=0;
%}
%%
PATTERN {
int start, end, len;
char *lastseg, *tmp;
if(yytext[yyleng-1]!='\n')
{fprintf(stderr,"ser: pattern matches incomplete line\n"); exit(1);}
n++;
sscanf(yytext,"%d %d",&start,&len);
yytext[yyleng-1]='\0';
if(tmp=strrchr(yytext,'\n'))
{
lastseg=tmp+1;
sscanf(lastseg,"%d %d", &end, &len);
}
else
end=start;
yytext[yyleng-1]='\n';
printf("%04d 00 BOM * ser:%d\n",start,n);
ECHO;
printf("%04d 00 EOM * ser:%d\n",end+len,n);
}
.*\n DEFAULTACTION;