// "cfa -c -o iostream.o iostream.c" // "cfa -v -E iostream.c > iostream_out.c" // "cfa -CFA iostream.c > iostream_out.c" // "cfa iostream_out.c" // "gcc32 iostream_out.c LibCfa/libcfa.a" #include "iostream.h" extern "C" { #include //#include //#include typedef long unsigned int size_t; size_t strlen(const char *s); } forall( dtype ostype | ostream( ostype ) ) ostype * ?<>?( istype *is, char *cp ) { return read( is, cp, 1 ); } forall( dtype istype | istream( istype ) ) istype * ?>>?( istype *is, int *ip ) { char cur; // skip some whitespace do { is >> &cur; if ( fail( is ) || eof( is ) ) return is; } while ( !( cur >= '0' && cur <= '9' ) ); // accumulate digits *ip = 0; while ( cur >= '0' && cur <= '9' ) { *ip = *ip * 10 + ( cur - '0' ); is >> &cur; if ( fail( is ) || eof( is ) ) return is; } unread( is, cur ); return is; }