%{ #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 ; \ } int ans3a = 0, ans3b = 0, ans3c = 0, ans3d = 0 , ans3e = 0 ; int correct = 1 ; %} WS [ \t] %% "answer7-3a=T"\&? { ans3a = 1 ; } "answer7-3b=T"\&? { ans3b = 1 ; } "answer7-3c=T"\&? { ans3c = 1 ; } "answer7-3d=T"\&? { ans3d = 1 ; } "answer7-3e=T"\&? { ans3e = 1 ; } \n {} %% #include main() { yylex() ; } yywrap() { if( !ans3a && !ans3b && ans3c && ans3d && !ans3e ) send_file( "ans7-3.right" ) ; else { printf( "Content-type: text/html\n\n" ) ; printf( "\n\n" ) ; printf( "Experimental C Tutorial - Part 7-3\n" ) ; printf( "\n\n" ) ; printf( "

Sorry, you answered one or more incorrectly

\n" ) ; if( ans3a ) { printf( "The identifier grad_year refers to a member of\n" ) ; printf( "any structure of the type struct student.\n" ) ; printf( "There is not variable grad_year of type\n" ) ; printf( "integer.\n" ) ; } if( ans3b ) { printf( "

The variable new_student is a structure\n" ) ; printf( "not an integer.\n" ) ; } if( !ans3c ) { printf( "

Since this_student is a structure that contains\n" ) ; printf( "a member called extension of type integer, the\n" ) ; printf( "expression this_student.extension will be of type\n" ) ; printf( "integer.\n" ) ; } if( !ans3d ) { printf( "

Since new_student is a structure that contains\n" ) ; printf( "a member called grad_year of type integer, the\n" ) ; printf( "expression new_student.grad_year will be of type\n" ) ; printf( "integer.\n" ) ; } if( ans3e ) { printf( "

The identifier student is a structure tag.\n" ) ; printf( "It is not a structure itself so we can't talk\n" ) ; printf( "about the member named grad_year.\n" ) ; printf( "The compiler would complain that student.grad_year\n" ) ; printf( "was not even a valid expression, much less an\n" ) ; printf( "integer one.\n" ) ; } printf( "

Return and try again\n" ) ; printf( "\n" ) ; } return( 1 ) ; } 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 ) ; } }