%{ #include int ur,ok,a,lin,i,j,c,n,m,d,s,q,fe,f,for_ok,curr_lin; typedef char idstr[50]; idstr l[5000], r[5000]; %} ID [a-zA-Z0-9._:\|-]* WS [\n\t ]* %s env inenv fid foc %% "\\begin"{WS}"{"("proof"|"example")"}"{WS}"[" { fe=1; for_ok=0; curr_lin=lin; BEGIN(env); // stuff that "for" keyval is recommended for } "\\begin"{WS}"{"("proof"|"example")"}" if (f) printf("Missing 'for' at line %d\n",lin); ("\\begin"{WS}"{"("definition"|"assertion"|"proof"|"omtext"|"example"|"step"|"pfcase"|"module")"}"{WS}"[")|("\\justification"{WS}"[") { fe=0; BEGIN(env); } "]" { if (fe && !for_ok && f) printf("Missing 'for' at line %d\n",curr_lin); BEGIN(INITIAL); } "id"{WS}"="{WS} BEGIN(fid); {ID} { for (i=0; i("for"){WS}"="{WS} { for_ok=1; BEGIN(foc); } ("continues"|"for"|"uses"|"premises"){WS}"="{WS} BEGIN(foc); {ID} { for (j=0; j("premises"|"uses"){WS}"="{WS}"{" BEGIN(inenv); {ID} { strncpy(r[m],yytext,yyleng); r[m][yyleng]=0; m++; } "}" BEGIN(env); \n {c++;lin++;} . c++; %% main(argc, argv) int argc; char **argv; { if (argc==1) { printf("Usage: idcheck [-q | -s | -f] filename(s)\n"); printf("Option -s shows all detected IDs. \n"); printf("Option -f shows line numbers for examples and proofs\n that have 'for' keyval missing. \n"); printf("Option -q for quiet mode.\n"); } else{ s=0; q=0; a=1; if (argv[1][0]=='-') { a++; for (j=1; j