Index: tests/coroutine/.expect/fibonacci.txt
===================================================================
--- tests/coroutine/.expect/fibonacci.txt	(revision bf71cfdb7285490eee552b461158846f626cc52f)
+++ tests/coroutine/.expect/fibonacci.txt	(revision bf71cfdb7285490eee552b461158846f626cc52f)
@@ -0,0 +1,10 @@
+0 0
+1 1
+1 1
+2 2
+3 3
+5 5
+8 8
+13 13
+21 21
+34 34
Index: tests/coroutine/.expect/fmtLines.txt
===================================================================
--- tests/coroutine/.expect/fmtLines.txt	(revision bf71cfdb7285490eee552b461158846f626cc52f)
+++ tests/coroutine/.expect/fmtLines.txt	(revision bf71cfdb7285490eee552b461158846f626cc52f)
@@ -0,0 +1,78 @@
+// /  / Cf  oral  l Ve  rsio  
+n 1.  0.0   Copy  righ  t (C  
+) 20  17 U  nive  rsit  y of  
+ Wat  erlo  o///  / Th  e co  
+nten  ts o  f th  is f  ile   
+are   cove  red   unde  r th  
+e li  cenc  e ag  reem  ent   
+in t  he//   fil  e "L  ICEN  
+CE"   dist  ribu  ted   with  
+ Cfo  rall  .//   // f  mtLi  
+nes.  cc -  - //   //   Auth  
+or                 : P  eter  
+ A.   Buhr  // C  reat  ed O  
+n           : Su  n Se  p 17  
+ 21:  56:1  5 20  17//   Las  
+t Mo  difi  ed B  y :   Pete  
+r A.   Buh  r//   Last   Mod  
+ifie  d On   : M  on S  ep 1  
+8 11  :35:  57 2  017/  / Up  
+date   Cou  nt       :   31/  
+/ #i  nclu  de <  fstr  eam>  
+#inc  lude   <co  rout  ine>  
+coro  utin  e Fo  rmat   {	c  
+har   ch;	  				  				  		//  
+ use  d fo  r co  mmun  icat  
+ion	  int   g, b  ;			  				  
+				  // g  loba  l be  caus  
+e us  ed i  n de  stru  ctor  
+};vo  id ?  {}(   Form  at &  
+ fmt   ) {        resu  me(   
+fmt   );		  				  				  // s  
+tart   cor  outi  ne}v  oid   
+^?{}  ( Fo  rmat   & f  mt )  
+ {      if   ( f  mt.g   !=   
+0 ||   fmt  .b !  = 0   ) so  
+ut |   end  l;}v  oid   main  
+( Fo  rmat   & f  mt )   {	f  
+or (   ;;   ) {	  				  				  
+	//   for   as m  any   char  
+acte  rs		  for   ( fm  t.g   
+= 0;   fmt  .g <   5;   fmt.  
+g +=   1 )   {		  // g  roup  
+s of   5 b  lock  s			  for   
+( fm  t.b   = 0;   fmt  .b <  
+ 4;   fmt.  b +=   1 )   {	/  
+/ bl  ocks   of   4 ch  arac  
+ters  				  for   ( ;;   ) {  
+				  			/  / fo  r ne  wlin  
+e ch  arac  ters  				  	sus  
+pend  ();	  				  if (   fmt  
+.ch   != '  \n'   ) br  eak;  
+		//   ign  ore   newl  ine	  
+			}   //   for	  			s  out   
+| fm  t.ch  ;			  				  // p  
+rint   cha  ract  er		  	} /  
+/ fo  r			  sout   | "    ";  
+				  				  // p  rint   blo  
+ck s  epar  ator  		}   // f  
+or		  sout   | e  ndl;  				  
+				  	//   prin  t gr  oup   
+sepa  rato  r	}   // f  or}   
+// m  ainv  oid   prt(   For  
+mat   & fm  t, c  har   ch )  
+ {      fm  t.ch   = c  h;    
+  re  sume  ( fm  t );  } //  
+ prt  int   main  () {  	For  
+mat   fmt;  	cha  r ch  ;	fo  
+r (   ;; )   {		  sin   | ch  
+;			  				  			/  / re  ad o  
+ne c  hara  cter  	  i  f (   
+eof(   sin   ) )   bre  ak;	  
+				  		//   eof   ?		  prt(  
+ fmt  , ch   );	  } //   for  
+} //   mai  n//   Loca  l Va  
+riab  les:   ///  / ta  b-wi  
+dth:   4 /  ///   comp  ile-  
+comm  and:   "cf  a fm  tLin  
+es.c  " //  // E  nd:   //
Index: tests/coroutine/.expect/pingpong.txt
===================================================================
--- tests/coroutine/.expect/pingpong.txt	(revision bf71cfdb7285490eee552b461158846f626cc52f)
+++ tests/coroutine/.expect/pingpong.txt	(revision bf71cfdb7285490eee552b461158846f626cc52f)
@@ -0,0 +1,40 @@
+ping
+pong
+ping
+pong
+ping
+pong
+ping
+pong
+ping
+pong
+ping
+pong
+ping
+pong
+ping
+pong
+ping
+pong
+ping
+pong
+ping
+pong
+ping
+pong
+ping
+pong
+ping
+pong
+ping
+pong
+ping
+pong
+ping
+pong
+ping
+pong
+ping
+pong
+ping
+pong
Index: tests/coroutine/.expect/prodcons.txt
===================================================================
--- tests/coroutine/.expect/prodcons.txt	(revision bf71cfdb7285490eee552b461158846f626cc52f)
+++ tests/coroutine/.expect/prodcons.txt	(revision bf71cfdb7285490eee552b461158846f626cc52f)
@@ -0,0 +1,33 @@
+47 88
+47 88
+ $1
+ $1
+1
+68 24
+ # 1
+68 24
+ $2
+ $2
+2
+58 18
+ # 2
+58 18
+ $3
+ $3
+3
+55 82
+ # 3
+55 82
+ $4
+ $4
+4
+60 87
+ # 4
+60 87
+ $5
+ $5
+5
+ # 5
+cons stops
+prod stops
+main stops
Index: tests/coroutine/.expect/runningTotal.txt
===================================================================
--- tests/coroutine/.expect/runningTotal.txt	(revision bf71cfdb7285490eee552b461158846f626cc52f)
+++ tests/coroutine/.expect/runningTotal.txt	(revision bf71cfdb7285490eee552b461158846f626cc52f)
@@ -0,0 +1,10 @@
+0 0
+1 1
+2 3
+3 6
+4 10
+5 15
+6 21
+7 28
+8 36
+9 45
Index: tests/coroutine/.in/fmtLines.txt
===================================================================
--- tests/coroutine/.in/fmtLines.txt	(revision bf71cfdb7285490eee552b461158846f626cc52f)
+++ tests/coroutine/.in/fmtLines.txt	(revision bf71cfdb7285490eee552b461158846f626cc52f)
@@ -0,0 +1,67 @@
+// 
+// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+// 
+// fmtLines.cc -- 
+// 
+// Author           : Peter A. Buhr
+// Created On       : Sun Sep 17 21:56:15 2017
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Mon Sep 18 11:35:57 2017
+// Update Count     : 31
+// 
+
+#include <fstream>
+#include <coroutine>
+
+coroutine Format {
+	char ch;											// used for communication
+	int g, b;											// global because used in destructor
+};
+
+void ?{}( Format & fmt ) {
+    resume( fmt );										// start coroutine
+}
+
+void ^?{}( Format & fmt ) {
+    if ( fmt.g != 0 || fmt.b != 0 ) sout | endl;
+}
+
+void main( Format & fmt ) {
+	for ( ;; ) {										// for as many characters
+		for ( fmt.g = 0; fmt.g < 5; fmt.g += 1 ) {		// groups of 5 blocks
+			for ( fmt.b = 0; fmt.b < 4; fmt.b += 1 ) {	// blocks of 4 characters
+				for ( ;; ) {							// for newline characters
+					suspend();
+					if ( fmt.ch != '\n' ) break;		// ignore newline
+				} // for
+				sout | fmt.ch;							// print character
+			} // for
+			sout | "  ";								// print block separator
+		} // for
+		sout | endl;									// print group separator
+	} // for
+} // main
+
+void prt( Format & fmt, char ch ) {
+    fmt.ch = ch;
+    resume( fmt );
+} // prt
+
+int main() {
+	Format fmt;
+	char ch;
+
+	for ( ;; ) {
+		sin | ch;										// read one character
+	  if ( eof( sin ) ) break;							// eof ?
+		prt( fmt, ch );
+	} // for
+} // main
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "cfa fmtLines.c" //
+// End: //
Index: tests/coroutine/fibonacci.c
===================================================================
--- tests/coroutine/fibonacci.c	(revision bf71cfdb7285490eee552b461158846f626cc52f)
+++ tests/coroutine/fibonacci.c	(revision bf71cfdb7285490eee552b461158846f626cc52f)
@@ -0,0 +1,49 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// fibonacci.c -- 3-state finite-state machine
+
+//
+// Author           : Thierry Delisle
+// Created On       : Thu Jun  8 07:29:37 2017
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Fri Apr 27 08:55:31 2018
+// Update Count     : 19
+//
+
+#include <fstream>
+#include <coroutine>
+
+coroutine Fibonacci { int fn; };						// used for communication
+
+void main( Fibonacci & fib ) with( fib ) {				// called on first resume
+	int fn1, fn2;										// retained between resumes
+	fn = 0;  fn1 = fn;									// 1st case
+	suspend();											// restart last resume
+	fn = 1;  fn2 = fn1;  fn1 = fn;						// 2nd case
+	suspend();											// restart last resume
+	for ( ;; ) {
+		fn = fn1 + fn2;  fn2 = fn1;  fn1 = fn;			// general case
+		suspend();										// restart last resume
+	} // for
+}
+
+int next( Fibonacci & fib ) with( fib ) {
+	resume( fib );										// restart last suspend
+	return fn;
+}
+
+int main() {
+	Fibonacci f1, f2;
+	for ( int i = 1; i <= 10; i += 1 ) {
+		sout | next( f1 ) | next( f2 ) | endl;
+	} // for
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "cfa fibonacci.c" //
+// End: //
Index: tests/coroutine/fmtLines.c
===================================================================
--- tests/coroutine/fmtLines.c	(revision bf71cfdb7285490eee552b461158846f626cc52f)
+++ tests/coroutine/fmtLines.c	(revision bf71cfdb7285490eee552b461158846f626cc52f)
@@ -0,0 +1,65 @@
+// 
+// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+// 
+// fmtLines.cc -- format characters into blocks of 4 and groups of 5 blocks per line
+// 
+// Author           : Peter A. Buhr
+// Created On       : Sun Sep 17 21:56:15 2017
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Tue May 15 12:25:33 2018
+// Update Count     : 42
+// 
+
+#include <fstream>
+#include <coroutine>
+
+coroutine Format {
+	char ch;											// used for communication
+	int g, b;											// global because used in destructor
+};
+
+void main( Format & fmt ) with( fmt ) {
+	for ( ;; ) {										// for as many characters
+		for ( g = 0; g < 5; g += 1 ) {					// groups of 5 blocks
+			for ( b = 0; b < 4; b += 1 ) {				// blocks of 4 characters
+				for ( ;; ) {							// for newline characters
+					suspend();
+					if ( ch != '\n' ) break;			// ignore newline
+				} // for
+				sout | ch;								// print character
+			} // for
+			sout | "  ";								// print block separator
+		} // for
+		sout | endl;									// print group separator
+	} // for
+} // main
+
+void ?{}( Format & fmt ) {
+	resume( fmt );										// prime (start) coroutine
+}
+
+void ^?{}( Format & fmt ) with( fmt ) {
+	if ( g != 0 || b != 0 ) sout | endl;
+}
+
+void format( Format & fmt ) {
+	resume( fmt );
+} // prt
+
+int main() {
+	Format fmt;
+
+	eof: for ( ;; ) {									// read until end of file
+		sin | fmt.ch;									// read one character
+	  if ( eof( sin ) ) break eof;						// eof ?
+		format( fmt );									// push character for formatting
+	} // for
+} // main
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "cfa fmtLines.c" //
+// End: //
Index: tests/coroutine/pingpong.c
===================================================================
--- tests/coroutine/pingpong.c	(revision bf71cfdb7285490eee552b461158846f626cc52f)
+++ tests/coroutine/pingpong.c	(revision bf71cfdb7285490eee552b461158846f626cc52f)
@@ -0,0 +1,55 @@
+// 
+// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+// 
+// pingpong.c -- 
+// 
+// Author           : Peter A. Buhr
+// Created On       : Wed Sep 20 11:55:23 2017
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Wed Sep 20 13:41:39 2017
+// Update Count     : 26
+// 
+
+#include <coroutine>
+#include <fstream>
+
+coroutine PingPong {
+	const char * name;
+	/* const */ unsigned int N;
+	PingPong * part;
+};
+
+void ?{}( PingPong & this, const char * name, unsigned int N, PingPong & part ) {
+	this.name = name;
+	this.N = N;
+	this.part = &part;
+}
+void ?{}( PingPong & this, const char * name, unsigned int N ) {
+	this{ name, N, *(PingPong *)0 };
+}
+void cycle( PingPong & pingpong ) {
+	resume( pingpong );
+}
+void partner( PingPong & this, PingPong & part ) {
+	this.part = &part;
+	resume( this );
+}
+void main( PingPong & pingpong ) {						// ping's starter ::main, pong's starter ping
+	for ( unsigned int i = 0; i < pingpong.N; i += 1 ) {
+		sout | pingpong.name | endl;
+		cycle( *pingpong.part );
+	} // for
+}
+int main() {
+	enum { N = 20 };
+	PingPong ping = { "ping", N }, pong = { "pong", N, ping };
+	partner( ping, pong );
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "cfa pingpong.c" //
+// End: //
Index: tests/coroutine/prodcons.c
===================================================================
--- tests/coroutine/prodcons.c	(revision bf71cfdb7285490eee552b461158846f626cc52f)
+++ tests/coroutine/prodcons.c	(revision bf71cfdb7285490eee552b461158846f626cc52f)
@@ -0,0 +1,100 @@
+// 
+// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+// 
+// prodcons.c -- 
+// 
+// Author           : Peter A. Buhr
+// Created On       : Mon Sep 18 12:23:39 2017
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Tue Jan  2 12:17:01 2018
+// Update Count     : 47
+// 
+
+#include <fstream>
+#include <coroutine>
+#include <stdlib>										// random
+#include <unistd.h>										// getpid
+
+coroutine Cons;											// forward
+int delivery( Cons & cons, int p1, int p2 );
+void stop( Cons & cons );
+
+coroutine Prod {
+	Cons * c;
+	int N, money, receipt;
+};
+void main( Prod & prod ) with( prod ) {					// starter ::main
+	// 1st resume starts here
+	for ( int i = 0; i < N; i += 1 ) {
+		int p1 = random( 100 );
+		int p2 = random( 100 );
+		sout | p1 | " " | p2 | endl;
+		int status = delivery( *c, p1, p2 );
+		sout | " $" | money | endl;
+		sout | status | endl;
+		receipt += 1;
+	}
+	stop( *c );
+	sout | "prod stops" | endl;
+}
+int payment( Prod & prod, int money ) {
+	prod.money = money;
+	resume( prod );										// main 1st time, then
+	return prod.receipt;								// prod in delivery
+}
+void start( Prod & prod, int N, Cons &c ) {
+	prod.N = N;
+	prod.c = &c;
+	prod.receipt = 0;
+	resume( prod );										// activate main
+}
+
+coroutine Cons {
+	Prod * p;
+	int p1, p2, status;
+	bool done;
+};
+void ?{}( Cons & cons, Prod & p ) {
+	cons.p = &p;
+	cons.status = 0;
+	cons.done = false;
+}
+void ^?{}( Cons & cons ) {}
+void main( Cons & cons ) with( cons ) {					// starter prod
+	// 1st resume starts here
+	int money = 1, receipt;
+	for ( ; ! done; ) {
+		sout | p1 | " " | p2 | endl;
+		sout | " $" | money | endl;
+		status += 1;
+		receipt = payment( *p, money );
+		sout | " #" | receipt | endl;
+		money += 1;
+	}
+	sout | "cons stops" | endl;
+}
+int delivery( Cons & cons, int p1, int p2 ) {
+	cons.p1 = p1;
+	cons.p2 = p2;
+	resume( cons );										// main 1st time, then
+	return cons.status;									// cons in payment
+}
+void stop( Cons & cons ) {
+	cons.done = true;
+	resume( cons );										// activate payment
+}
+int main() {
+	Prod prod;
+	Cons cons = { prod };
+	srandom( /* getpid() */ 103 );						// fixed seed for testing
+	start( prod, 5, cons );
+	sout | "main stops" | endl;
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "cfa prodcons.c" //
+// End: //
Index: tests/coroutine/runningTotal.c
===================================================================
--- tests/coroutine/runningTotal.c	(revision bf71cfdb7285490eee552b461158846f626cc52f)
+++ tests/coroutine/runningTotal.c	(revision bf71cfdb7285490eee552b461158846f626cc52f)
@@ -0,0 +1,51 @@
+// 
+// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+// 
+// runningTotal.c -- 
+// 
+// Author           : Peter A. Buhr
+// Created On       : Wed Dec  6 08:05:27 2017
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Wed Dec  6 08:09:24 2017
+// Update Count     : 2
+// 
+
+#include <fstream>
+#include <coroutine>
+
+coroutine RunTotal {									// input numbers and return running total
+	int input, total;									// communication
+};
+
+void ?{}( RunTotal & rntl ) { rntl.total = 0; }
+
+void update( RunTotal & rntl, int input ) with( rntl ) { // helper
+	total += input;										// remember between activations
+	suspend();											// inactivate on stack
+}
+
+void main( RunTotal & rntl ) with( rntl ) {
+	for ( ;; ) {
+		update( rntl, input );
+	} // for
+}
+
+int add( RunTotal & rntl, int input ) {
+	rntl.input = input;									// pass input to coroutine
+	resume( rntl );
+	return rntl.total;									// return total from coroutine
+}
+int main() {
+	RunTotal rntl;
+	for ( int i = 0; i < 10; i += 1 ) {
+		sout | i | add( rntl, i ) | endl;
+	} // for
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "cfa runningTotal.c" //
+// End: //
