%{ #define YY_INPUT(buf,result,max_size) \ { int digit ; \ int c = getc( yyin ) ; \ result = c == EOF ? 0 : 1 ; \ if( c == '%' ) { \ c = getc( yyin ) ; \ digit = c >= 'A' ? (( c & 0xdf ) - 'A' ) + 10 : c - '0' ; \ digit *= 16 ; \ c = getc( yyin ) ; \ digit += c >= 'A' ? (( c & 0xdf ) - 'A' ) + 10 : c - '0' ; \ buf[0] = (char) digit ; \ } \ else if( c == '+' ) \ buf[0] = ' ' ; \ else \ buf[0] = (char) c ; \ } %} WS [ \t]* ARG1 {WS}\&{WS}store{WS}\[{WS}n{WS}\]{WS},{WS} ARG2 sizeof{WS}\({WS}struct{WS}video{WS}\){WS},{WS} ARG3 1{WS},{WS} ARG4 file2{WS} ARGS {ARG1}{ARG2}{ARG3}{ARG4} %% answer9-4={WS}fwrite{WS}\({ARGS}\){WS};{WS} { send_file( "ans9-4.right" ) ; return( 0 ) ; } [^\r]* { send_file( "ans9-4.wrong" ) ; return( 0 ) ; } %% #include main() { yylex() ; } send_file( s ) char *s ; { FILE *fp ; char buf[81] ; printf( "Content-type: text/html\n\n" ) ; fp = fopen( s, "r" ) ; if( fp ) { while( fgets( buf, 80, fp )) { printf( "%s", buf ) ; } fclose( fp ) ; } }