ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since d6ad99e was
2aab69b,
checked in by Peter A. Buhr <pabuhr@…>, 5 years ago
|
files added to concurrency paper
|
-
Property mode set to
100644
|
File size:
909 bytes
|
Rev | Line | |
---|
[2aab69b] | 1 | function * Format() { |
---|
| 2 | var g, b; |
---|
| 3 | fini: while ( true ) { |
---|
| 4 | for ( g = 0; g < 5; g += 1 ) { // groups of 5 blocks |
---|
| 5 | for ( b = 0; b < 4; b += 1 ) { // blocks of 4 characters |
---|
| 6 | while ( true ) { |
---|
| 7 | ch = (yield) // receive from send |
---|
| 8 | if ( ch == '\0' ) break fini; |
---|
| 9 | if ( '\n' != ch ) break |
---|
| 10 | } |
---|
| 11 | process.stdout.write( ch ) // receive from send |
---|
| 12 | } |
---|
| 13 | process.stdout.write( ' ' ) // block separator |
---|
| 14 | } |
---|
| 15 | process.stdout.write( '\n' ) // group separator |
---|
| 16 | } |
---|
| 17 | if ( g != 0 || b != 0 ) process.stdout.write( '\n' ) |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | var input = "abcdefghijklmnop\nqrstuvwx\nyzxxxxxxxxxxxxx" |
---|
| 21 | |
---|
| 22 | fmt = Format() |
---|
| 23 | fmt.next() // prime generator |
---|
| 24 | for ( var i = 0; i < input.length; i += 1 ) { |
---|
| 25 | fmt.next( input[i] ); // send to yield |
---|
| 26 | } |
---|
| 27 | fmt.next( '\0' ); // EOF |
---|
| 28 | |
---|
| 29 | // Local Variables: // |
---|
| 30 | // comment-column: 56 // |
---|
| 31 | // tab-width: 4 // |
---|
| 32 | // compile-command: "node Format.js" // |
---|
| 33 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.