Changeset a0cfa44
- Timestamp:
- May 15, 2018, 12:27:10 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- a61fa0bb
- Parents:
- 2b22e050
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/coroutine/fmtLines.c
r2b22e050 ra0cfa44 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // fmtLines.cc -- 7 // fmtLines.cc -- format characters into blocks of 4 and groups of 5 blocks per line 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sun Sep 17 21:56:15 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 5 21:56:35 201713 // Update Count : 3812 // Last Modified On : Tue May 15 12:25:33 2018 13 // Update Count : 42 14 14 // 15 15 … … 21 21 int g, b; // global because used in destructor 22 22 }; 23 24 void ?{}( Format & fmt ) {25 resume( fmt ); // prime (start) coroutine26 }27 28 void ^?{}( Format & fmt ) with( fmt ) {29 if ( g != 0 || b != 0 ) sout | endl;30 }31 23 32 24 void main( Format & fmt ) with( fmt ) { … … 46 38 } // main 47 39 48 void prt( Format & fmt, char ch ) { 49 fmt.ch = ch; 40 void ?{}( Format & fmt ) { 41 resume( fmt ); // prime (start) coroutine 42 } 43 44 void ^?{}( Format & fmt ) with( fmt ) { 45 if ( g != 0 || b != 0 ) sout | endl; 46 } 47 48 void format( Format & fmt ) { 50 49 resume( fmt ); 51 50 } // prt 52 51 53 52 int main() { 54 Format fmt; // format characters into blocks of 4 and groups of 5 blocks per line 55 char ch; 53 Format fmt; 56 54 57 Eof: for ( ;; ) { // read until end of file58 sin | ch;// read one character59 if ( eof( sin ) ) break Eof; // eof ?60 prt( fmt, ch); // push character for formatting55 eof: for ( ;; ) { // read until end of file 56 sin | fmt.ch; // read one character 57 if ( eof( sin ) ) break eof; // eof ? 58 format( fmt ); // push character for formatting 61 59 } // for 62 60 } // main
Note: See TracChangeset
for help on using the changeset viewer.