Index: tests/concurrent/waitfor/barge.c
===================================================================
--- tests/concurrent/waitfor/barge.c	(revision 200fcb3c496b08f843f691550554b21d786aad38)
+++ 	(revision )
@@ -1,92 +1,0 @@
-//---------------------------------------------------------
-// Barging test
-// Ensures that no barging can occur between :
-//   - the frontend of the waitfor and the waited call
-//   - the waited call and the backend of the waitfor
-//---------------------------------------------------------
-
-#include <fstream.hfa>
-#include <kernel.hfa>
-#include <monitor.hfa>
-#include <stdlib.hfa>
-#include <thread.hfa>
-
-#include <stdbool.h>
-
-static const unsigned long N = 5_000ul;
-
-enum state_t { WAITFOR, CALL, BARGE };
-
-monitor global_t {
-	bool done;
-	bool started;
-	state_t state;
-};
-
-void ?{} ( global_t & this ) {
-	this.done = false;
-	this.started = false;
-	this.state = BARGE;
-}
-
-void ^?{} ( global_t & mutex this ) {}
-
-global_t global;
-
-bool barge( global_t & mutex this ) {
-	this.state = BARGE;
-	return !this.done;
-}
-
-thread barger_t {};
-void main( barger_t & this ) {
-	yield();
-	while( barge( global ) ) { yield(random( 10 )); }
-}
-
-bool do_call( global_t & mutex this ) {
-	yield(random( 10 ));
-	if( this.state != WAITFOR && !this.done && this.started ) {
-		serr | "Barging before caller detected";
-	}
-
-	this.state = CALL;
-	return !this.done;
-}
-
-thread caller_t {};
-void main( caller_t & this ) {
-	while( do_call(global) ) { yield(random( 10 )); }
-}
-
-void do_wait( global_t & mutex this ) {
-	this.started = true;
-	for( int i = 0; i < N; i++) {
-		yield(random( 10 ));
-		this.state = WAITFOR;
-		waitfor(do_call, this) {
-			sout | i;
-		}
-
-		if( this.state != CALL ) {
-			serr | "Barging after caller detected";
-		}
-	}
-
-	this.done = true;
-}
-
-thread waiter_t{};
-void main( waiter_t & this ) {
-	do_wait(global);
-}
-
-int main() {
-	sout | "Starting";
-	{
-		barger_t bargers[17];
-		caller_t callers[7];
-		waiter_t waiters;
-	}
-	sout | "Stopping";
-}
Index: tests/concurrent/waitfor/barge.cfa
===================================================================
--- tests/concurrent/waitfor/barge.cfa	(revision 107b01a853d2fa7848b6015136777f62881c1779)
+++ tests/concurrent/waitfor/barge.cfa	(revision 107b01a853d2fa7848b6015136777f62881c1779)
@@ -0,0 +1,92 @@
+//---------------------------------------------------------
+// Barging test
+// Ensures that no barging can occur between :
+//   - the frontend of the waitfor and the waited call
+//   - the waited call and the backend of the waitfor
+//---------------------------------------------------------
+
+#include <fstream.hfa>
+#include <kernel.hfa>
+#include <monitor.hfa>
+#include <stdlib.hfa>
+#include <thread.hfa>
+
+#include <stdbool.h>
+
+static const unsigned long N = 5_000ul;
+
+enum state_t { WAITFOR, CALL, BARGE };
+
+monitor global_t {
+	bool done;
+	bool started;
+	state_t state;
+};
+
+void ?{} ( global_t & this ) {
+	this.done = false;
+	this.started = false;
+	this.state = BARGE;
+}
+
+void ^?{} ( global_t & mutex this ) {}
+
+global_t global;
+
+bool barge( global_t & mutex this ) {
+	this.state = BARGE;
+	return !this.done;
+}
+
+thread barger_t {};
+void main( barger_t & this ) {
+	yield();
+	while( barge( global ) ) { yield(random( 10 )); }
+}
+
+bool do_call( global_t & mutex this ) {
+	yield(random( 10 ));
+	if( this.state != WAITFOR && !this.done && this.started ) {
+		serr | "Barging before caller detected";
+	}
+
+	this.state = CALL;
+	return !this.done;
+}
+
+thread caller_t {};
+void main( caller_t & this ) {
+	while( do_call(global) ) { yield(random( 10 )); }
+}
+
+void do_wait( global_t & mutex this ) {
+	this.started = true;
+	for( int i = 0; i < N; i++) {
+		yield(random( 10 ));
+		this.state = WAITFOR;
+		waitfor(do_call, this) {
+			sout | i;
+		}
+
+		if( this.state != CALL ) {
+			serr | "Barging after caller detected";
+		}
+	}
+
+	this.done = true;
+}
+
+thread waiter_t{};
+void main( waiter_t & this ) {
+	do_wait(global);
+}
+
+int main() {
+	sout | "Starting";
+	{
+		barger_t bargers[17];
+		caller_t callers[7];
+		waiter_t waiters;
+	}
+	sout | "Stopping";
+}
Index: tests/concurrent/waitfor/dtor.c
===================================================================
--- tests/concurrent/waitfor/dtor.c	(revision 200fcb3c496b08f843f691550554b21d786aad38)
+++ 	(revision )
@@ -1,63 +1,0 @@
-//---------------------------------------------------------
-// Barging test
-// Ensures the statement order is reverse when using waitfor ^?{}
-//---------------------------------------------------------
-
-#include <fstream.hfa>
-#include <kernel.hfa>
-#include <monitor.hfa>
-#include <stdlib.hfa>
-#include <thread.hfa>
-
-#include <stdbool.h>
-
-static const unsigned long N = 5_000ul;
-
-enum state_t {
-	CTOR,
-	MAIN,
-	AFTER,
-	END,
-	DTOR
-};
-
-thread dummy_t {
-	state_t state;
-};
-
-static inline void set_state( dummy_t & this, state_t state) {
-	switch(state) {
-		case CTOR  : break;
-		case MAIN  : if( this.state != CTOR  ) { serr | "ERROR Expected state to be CTOR" ; abort(); } this.state = state; break;
-		case AFTER : if( this.state != MAIN  ) { serr | "ERROR Expected state to be MAIN" ; abort(); } this.state = state; break;
-		case END   : if( this.state != AFTER ) { serr | "ERROR Expected state to be AFTER"; abort(); } this.state = state; break;
-		case DTOR  : if( this.state != END   ) { serr | "ERROR Expected state to be END"  ; abort(); } this.state = state; break;
-	}
-}
-
-void ^?{}( dummy_t & mutex this ) {
-	set_state( this, DTOR );
-}
-
-void ?{}( dummy_t & this ) {
-	this.state = CTOR;
-}
-
-void main( dummy_t & this ) {
-	yield(random( 10 ));
-	set_state( this, MAIN );
-	waitfor( ^?{}, this ) {
-		set_state( this, AFTER );
-	}
-	set_state( this, END );
-}
-
-int main() {
-	sout | "Starting";
-	processor p;
-	for( int i = 0; i < N; i++ ){
-		dummy_t dummy[4];
-		yield( random( 100 ) );
-	}
-	sout | "Stopping";
-}
Index: tests/concurrent/waitfor/dtor.cfa
===================================================================
--- tests/concurrent/waitfor/dtor.cfa	(revision 107b01a853d2fa7848b6015136777f62881c1779)
+++ tests/concurrent/waitfor/dtor.cfa	(revision 107b01a853d2fa7848b6015136777f62881c1779)
@@ -0,0 +1,63 @@
+//---------------------------------------------------------
+// Barging test
+// Ensures the statement order is reverse when using waitfor ^?{}
+//---------------------------------------------------------
+
+#include <fstream.hfa>
+#include <kernel.hfa>
+#include <monitor.hfa>
+#include <stdlib.hfa>
+#include <thread.hfa>
+
+#include <stdbool.h>
+
+static const unsigned long N = 5_000ul;
+
+enum state_t {
+	CTOR,
+	MAIN,
+	AFTER,
+	END,
+	DTOR
+};
+
+thread dummy_t {
+	state_t state;
+};
+
+static inline void set_state( dummy_t & this, state_t state) {
+	switch(state) {
+		case CTOR  : break;
+		case MAIN  : if( this.state != CTOR  ) { serr | "ERROR Expected state to be CTOR" ; abort(); } this.state = state; break;
+		case AFTER : if( this.state != MAIN  ) { serr | "ERROR Expected state to be MAIN" ; abort(); } this.state = state; break;
+		case END   : if( this.state != AFTER ) { serr | "ERROR Expected state to be AFTER"; abort(); } this.state = state; break;
+		case DTOR  : if( this.state != END   ) { serr | "ERROR Expected state to be END"  ; abort(); } this.state = state; break;
+	}
+}
+
+void ^?{}( dummy_t & mutex this ) {
+	set_state( this, DTOR );
+}
+
+void ?{}( dummy_t & this ) {
+	this.state = CTOR;
+}
+
+void main( dummy_t & this ) {
+	yield(random( 10 ));
+	set_state( this, MAIN );
+	waitfor( ^?{}, this ) {
+		set_state( this, AFTER );
+	}
+	set_state( this, END );
+}
+
+int main() {
+	sout | "Starting";
+	processor p;
+	for( int i = 0; i < N; i++ ){
+		dummy_t dummy[4];
+		yield( random( 100 ) );
+	}
+	sout | "Stopping";
+}
Index: tests/concurrent/waitfor/else.c
===================================================================
--- tests/concurrent/waitfor/else.c	(revision 200fcb3c496b08f843f691550554b21d786aad38)
+++ 	(revision )
@@ -1,48 +1,0 @@
-#include <fstream.hfa>
-#include <monitor.hfa>
-
-#include <stdbool.h>
-
-monitor M {};
-
-void notcalled( M & mutex m ) {
-	abort();
-}
-
-void test( M & mutex m ) {
-	int i = 0;
-	sout | "Starting";
-
-	when( false ) waitfor( notcalled, m );
-
-	sout | "Step" | i++;
-
-	waitfor( notcalled, m ); or else {
-		sout | "else called";
-	}
-
-	sout | "Step" | i++;
-
-	when( true ) waitfor( notcalled, m ); or when( true ) else {
-		sout | "else called";
-	}
-
-	sout | "Step" | i++;
-
-	when( false ) waitfor( notcalled, m ); or when( true ) else {
-		sout | "else called";
-	}
-
-	sout | "Step" | i++;
-
-	when( false ) waitfor( notcalled, m ); or when( false ) else {
-		sout | "else called";
-	}
-
-	sout | "Done";
-}
-
-int main() {
-	M m;
-	test(m);
-}
Index: tests/concurrent/waitfor/else.cfa
===================================================================
--- tests/concurrent/waitfor/else.cfa	(revision 107b01a853d2fa7848b6015136777f62881c1779)
+++ tests/concurrent/waitfor/else.cfa	(revision 107b01a853d2fa7848b6015136777f62881c1779)
@@ -0,0 +1,48 @@
+#include <fstream.hfa>
+#include <monitor.hfa>
+
+#include <stdbool.h>
+
+monitor M {};
+
+void notcalled( M & mutex m ) {
+	abort();
+}
+
+void test( M & mutex m ) {
+	int i = 0;
+	sout | "Starting";
+
+	when( false ) waitfor( notcalled, m );
+
+	sout | "Step" | i++;
+
+	waitfor( notcalled, m ); or else {
+		sout | "else called";
+	}
+
+	sout | "Step" | i++;
+
+	when( true ) waitfor( notcalled, m ); or when( true ) else {
+		sout | "else called";
+	}
+
+	sout | "Step" | i++;
+
+	when( false ) waitfor( notcalled, m ); or when( true ) else {
+		sout | "else called";
+	}
+
+	sout | "Step" | i++;
+
+	when( false ) waitfor( notcalled, m ); or when( false ) else {
+		sout | "else called";
+	}
+
+	sout | "Done";
+}
+
+int main() {
+	M m;
+	test(m);
+}
Index: tests/concurrent/waitfor/parse.c
===================================================================
--- tests/concurrent/waitfor/parse.c	(revision 200fcb3c496b08f843f691550554b21d786aad38)
+++ 	(revision )
@@ -1,104 +1,0 @@
-//----------------------------------------------------------------------------------------
-//----------------------------------------------------------------------------------------
-//
-//		DEPRECATED TEST
-//		DIFFERS BETWEEN DEBUG AND RELEASE
-//
-//----------------------------------------------------------------------------------------
-//----------------------------------------------------------------------------------------
-
-#include <monitor.hfa>
-
-monitor M {};
-
-M a;
-
-void f1( M & mutex a );
-void f2( M & mutex a );
-void f2( M & mutex a, M & mutex b );
-void f3( M & mutex a );
-void f3( M & mutex a, M & mutex b );
-void f3( M & mutex a, M & mutex b, M & mutex c );
-
-void foo() {
-
-	//---------------------------------------
-	waitfor( f1, a ) {
-		1;
-	}
-
-	//---------------------------------------
-	waitfor( f1, a ) {
-		2;
-	}
-	waitfor( f2, a ) {
-		3;
-	}
-
-	//---------------------------------------
-	when( 1 < 3 ) waitfor( f2, a, a ) {
-		4;
-	}
-	or timeout( 100 ) {
-		5;
-	}
-
-	//---------------------------------------
-	when( 2 < 3 ) waitfor( f3, a ) {
-		5;
-	}
-	or else {
-		6;
-	}
-
-	//---------------------------------------
-	when( 3 < 3 ) waitfor( f3, a, a ) {
-		7;
-	}
-	or when( 4 < 3 ) timeout( 101 ) {
-		8;
-	}
-	or when( 5 < 3 ) else {
-		9;
-	}
-
-	//---------------------------------------
-	when( 6 < 3 ) waitfor( f3, a, a, a ) {
-		10;
-	}
- 	or when( 7 < 3 ) waitfor( f1, a  ) {
-		11;
-	}
-	or else {
-		12;
-	}
-
-	//---------------------------------------
-	when( 8 < 3 ) waitfor( f3, a, a ) {
-		13;
-	}
- 	or waitfor( f1, a  ) {
-		14;
-	}
-	or when( 9 < 3 ) timeout( 102 ) {
-		15;
-	}
-
-	//---------------------------------------
-	when( 10 < 3 ) waitfor( f1, a ) {
-		16;
-	}
- 	or waitfor( f2, a, a ) {
-		17;
-	}
-	or timeout( 103 ) {
-		18;
-	}
-	or when( 11 < 3 ) else {
-		19;
-	}
-}
-
-int main() {
-
-}
Index: tests/concurrent/waitfor/parse.cfa
===================================================================
--- tests/concurrent/waitfor/parse.cfa	(revision 107b01a853d2fa7848b6015136777f62881c1779)
+++ tests/concurrent/waitfor/parse.cfa	(revision 107b01a853d2fa7848b6015136777f62881c1779)
@@ -0,0 +1,104 @@
+//----------------------------------------------------------------------------------------
+//----------------------------------------------------------------------------------------
+//
+//		DEPRECATED TEST
+//		DIFFERS BETWEEN DEBUG AND RELEASE
+//
+//----------------------------------------------------------------------------------------
+//----------------------------------------------------------------------------------------
+
+#include <monitor.hfa>
+
+monitor M {};
+
+M a;
+
+void f1( M & mutex a );
+void f2( M & mutex a );
+void f2( M & mutex a, M & mutex b );
+void f3( M & mutex a );
+void f3( M & mutex a, M & mutex b );
+void f3( M & mutex a, M & mutex b, M & mutex c );
+
+void foo() {
+
+	//---------------------------------------
+	waitfor( f1, a ) {
+		1;
+	}
+
+	//---------------------------------------
+	waitfor( f1, a ) {
+		2;
+	}
+	waitfor( f2, a ) {
+		3;
+	}
+
+	//---------------------------------------
+	when( 1 < 3 ) waitfor( f2, a, a ) {
+		4;
+	}
+	or timeout( 100 ) {
+		5;
+	}
+
+	//---------------------------------------
+	when( 2 < 3 ) waitfor( f3, a ) {
+		5;
+	}
+	or else {
+		6;
+	}
+
+	//---------------------------------------
+	when( 3 < 3 ) waitfor( f3, a, a ) {
+		7;
+	}
+	or when( 4 < 3 ) timeout( 101 ) {
+		8;
+	}
+	or when( 5 < 3 ) else {
+		9;
+	}
+
+	//---------------------------------------
+	when( 6 < 3 ) waitfor( f3, a, a, a ) {
+		10;
+	}
+ 	or when( 7 < 3 ) waitfor( f1, a  ) {
+		11;
+	}
+	or else {
+		12;
+	}
+
+	//---------------------------------------
+	when( 8 < 3 ) waitfor( f3, a, a ) {
+		13;
+	}
+ 	or waitfor( f1, a  ) {
+		14;
+	}
+	or when( 9 < 3 ) timeout( 102 ) {
+		15;
+	}
+
+	//---------------------------------------
+	when( 10 < 3 ) waitfor( f1, a ) {
+		16;
+	}
+ 	or waitfor( f2, a, a ) {
+		17;
+	}
+	or timeout( 103 ) {
+		18;
+	}
+	or when( 11 < 3 ) else {
+		19;
+	}
+}
+
+int main() {
+
+}
Index: tests/concurrent/waitfor/parse2.c
===================================================================
--- tests/concurrent/waitfor/parse2.c	(revision 200fcb3c496b08f843f691550554b21d786aad38)
+++ 	(revision )
@@ -1,249 +1,0 @@
-// 
-// 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.
-// 
-// waitfor.c -- 
-// 
-// Author           : Peter A. Buhr
-// Created On       : Wed Aug 30 17:53:29 2017
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Aug 30 17:55:17 2017
-// Update Count     : 2
-// 
-
-#include <stdbool.h>
-
-int fred() {
-	int x, z;
-
-	// test waitfor and when
-
-	waitfor( x );
-
-	waitfor( x ) {
-	}
-
-	waitfor( x, z ) {
-	}
-
-	when( true ) waitfor( x );
-
-	when( true ) waitfor( x ) {
-	}
-
-	waitfor( x );
-	or waitfor( y );
-
-	waitfor( x, z );
-	or waitfor( y );
-
-	when( true ) waitfor( x );
-	or when( true ) waitfor( y );
-
-	when( true ) waitfor( x, z );
-	or when( true ) waitfor( y );
-
-	waitfor( x ) {
-	} or waitfor( y ) {
-	}
-
-	waitfor( x, z ) {
-	} or waitfor( y ) {
-	}
-
-	when( true ) waitfor( x ) {
-	} or when( true ) waitfor( y ) {
-	}
-
-	waitfor( x );
-	or waitfor( y ) {
-	}
-
-	when( true ) waitfor( x );
-	or when( true ) waitfor( y ) {
-	}
-
-	waitfor( x ) {
-	} or waitfor( y );
-
-	when( true ) waitfor( x ) {
-	} or when( true ) waitfor( y );
-
-	// test when, waitfor and else
-
-	waitfor( x );
-	or else;
-
-	when( true ) waitfor( x );
-	or else;
-
-	when( true ) waitfor( x, z );
-	or else;
-
-	waitfor( x ) {
-	} or else {
-	}
-
-	when( true ) waitfor( x ) {
-	} or else {
-	}
-
-	waitfor( x );
-	or else {
-	}
-
-	when( true ) waitfor( x );
-	or else {
-	}
-
-	when( true ) waitfor( x, z );
-	or else {
-	}
-
-	waitfor( x ) {
-	} or else;
-
-	when( true ) waitfor( x ) {
-	} or else;
-
-	waitfor( x );
-	or when( true ) else;
-
-	when( true ) waitfor( x );
-	or when( true ) else;
-
-	when( true ) waitfor( x, z );
-	or when( true ) else;
-
-	waitfor( x ) {
-	} or when( true ) else {
-	}
-
-	when( true ) waitfor( x ) {
-	} or when( true ) else {
-	}
-
-	waitfor( x );
-	or when( true ) else {
-	}
-
-	when( true ) waitfor( x );
-	or when( true ) else {
-	}
-
-	when( true ) waitfor( x, z );
-	or when( true ) else {
-	}
-
-	waitfor( x ) {
-	} or when( true ) else;
-
-	when( true ) waitfor( x ) {
-	} or when( true ) else;
-
-	// test when, waitfor and timeout
-
-	waitfor( x );
-	or timeout( 3 );
-
-	waitfor( x, z );
-	or timeout( 3 );
-
-	when( true ) waitfor( x );
-	or timeout( 3 );
-
-	waitfor( x ) {
-	} or timeout( 3 ) {
-	}
-
-	when( true ) waitfor( x ) {
-	} or timeout( 3 ) {
-	}
-
-	when( true ) waitfor( x, z ) {
-	} or timeout( 3 ) {
-	}
-
-	when( true ) waitfor( x ) {
-	} or when ( true ) timeout( 3 ) {
-	}
-
-	when( true ) waitfor( x, z ) {
-	} or when ( true ) timeout( 3 ) {
-	}
-
-	waitfor( x );
-	or timeout( 3 ) {
-	}
-
-	when( true ) waitfor( x );
-	or timeout( 3 ) {
-	}
-
-	when( true ) waitfor( x );
-	or when( true ) timeout( 3 ) {
-	}
-
-	waitfor( x ) {
-	} or timeout( 3 );
-
-	when( true ) waitfor( x ) {
-	} or timeout( 3 );
-
-	when( true ) waitfor( x ) {
-	} or when( true ) timeout( 3 );
-
-	// test when, waitfor, timeout and else
-
-	waitfor( x ) {
-	} or timeout( 3 ) {
-	} or when( true ) else {}
-
-	when( true ) waitfor( x ) {
-	} or timeout( 3 ) {
-	} or when( true ) else {}
-
-	waitfor( x ) {
-	} or timeout( 3 ) {
-	} or when( true ) else {}
-
-	waitfor( x ) {
-	} or when( true ) timeout( 3 ) {
-	} or when( true ) else {}
-
-	when( true ) waitfor( x ) {
-	} or timeout( 3 ) {
-	} or when( true ) else {}
-
-	waitfor( x ) {
-	} or when( true ) timeout( 3 ) {
-	} or when( true ) else {}
-
-	when( true ) waitfor( x ) {
-	} or when( true ) timeout( 3 ) {
-	} or when( true ) else {}
-
-	// test quasi-keywords "or" and "timeout"
-
-	int or, timeout;
-	waitfor( timeout, 7 ) 3;
-	waitfor( timeout, 7 ) 3; or waitfor( timeout, 7 ) 3;
-	when( or ) waitfor( or, ) { 4; } or timeout( 1 ) 3;
-	when( 3 ) waitfor( or, 2 ) 4; or else 4;
-	when( 3 ) waitfor( or, 3 ) 4; or when( or ) timeout( or ) 4; or when( or ) else timeout;
-	when( 3 ) waitfor( or, or ) 3; or when( or ) waitfor( or, timeout ) 4; or else 4;
-	when( 3 ) waitfor( or, or ) 3; or waitfor( or, 9 ) 4; or when( or ) timeout( timeout ) 4;
-	when( 3 ) waitfor( or, 3 ) 3; or waitfor( or, 7 ) or; or timeout( 1 ) or; or when( 3 ) else or;
-
-	// test else selection
-
-	if ( or > timeout ) waitfor( or ) 3;
-	else waitfor( timeout ) 4;
-}
-
-// Local Variables: //
-// tab-width: 4 //
-// compile-command: "cfa waitfor.c" //
-// End: //
Index: tests/concurrent/waitfor/parse2.cfa
===================================================================
--- tests/concurrent/waitfor/parse2.cfa	(revision 107b01a853d2fa7848b6015136777f62881c1779)
+++ tests/concurrent/waitfor/parse2.cfa	(revision 107b01a853d2fa7848b6015136777f62881c1779)
@@ -0,0 +1,249 @@
+// 
+// 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.
+// 
+// waitfor.c -- 
+// 
+// Author           : Peter A. Buhr
+// Created On       : Wed Aug 30 17:53:29 2017
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Wed Aug 30 17:55:17 2017
+// Update Count     : 2
+// 
+
+#include <stdbool.h>
+
+int fred() {
+	int x, z;
+
+	// test waitfor and when
+
+	waitfor( x );
+
+	waitfor( x ) {
+	}
+
+	waitfor( x, z ) {
+	}
+
+	when( true ) waitfor( x );
+
+	when( true ) waitfor( x ) {
+	}
+
+	waitfor( x );
+	or waitfor( y );
+
+	waitfor( x, z );
+	or waitfor( y );
+
+	when( true ) waitfor( x );
+	or when( true ) waitfor( y );
+
+	when( true ) waitfor( x, z );
+	or when( true ) waitfor( y );
+
+	waitfor( x ) {
+	} or waitfor( y ) {
+	}
+
+	waitfor( x, z ) {
+	} or waitfor( y ) {
+	}
+
+	when( true ) waitfor( x ) {
+	} or when( true ) waitfor( y ) {
+	}
+
+	waitfor( x );
+	or waitfor( y ) {
+	}
+
+	when( true ) waitfor( x );
+	or when( true ) waitfor( y ) {
+	}
+
+	waitfor( x ) {
+	} or waitfor( y );
+
+	when( true ) waitfor( x ) {
+	} or when( true ) waitfor( y );
+
+	// test when, waitfor and else
+
+	waitfor( x );
+	or else;
+
+	when( true ) waitfor( x );
+	or else;
+
+	when( true ) waitfor( x, z );
+	or else;
+
+	waitfor( x ) {
+	} or else {
+	}
+
+	when( true ) waitfor( x ) {
+	} or else {
+	}
+
+	waitfor( x );
+	or else {
+	}
+
+	when( true ) waitfor( x );
+	or else {
+	}
+
+	when( true ) waitfor( x, z );
+	or else {
+	}
+
+	waitfor( x ) {
+	} or else;
+
+	when( true ) waitfor( x ) {
+	} or else;
+
+	waitfor( x );
+	or when( true ) else;
+
+	when( true ) waitfor( x );
+	or when( true ) else;
+
+	when( true ) waitfor( x, z );
+	or when( true ) else;
+
+	waitfor( x ) {
+	} or when( true ) else {
+	}
+
+	when( true ) waitfor( x ) {
+	} or when( true ) else {
+	}
+
+	waitfor( x );
+	or when( true ) else {
+	}
+
+	when( true ) waitfor( x );
+	or when( true ) else {
+	}
+
+	when( true ) waitfor( x, z );
+	or when( true ) else {
+	}
+
+	waitfor( x ) {
+	} or when( true ) else;
+
+	when( true ) waitfor( x ) {
+	} or when( true ) else;
+
+	// test when, waitfor and timeout
+
+	waitfor( x );
+	or timeout( 3 );
+
+	waitfor( x, z );
+	or timeout( 3 );
+
+	when( true ) waitfor( x );
+	or timeout( 3 );
+
+	waitfor( x ) {
+	} or timeout( 3 ) {
+	}
+
+	when( true ) waitfor( x ) {
+	} or timeout( 3 ) {
+	}
+
+	when( true ) waitfor( x, z ) {
+	} or timeout( 3 ) {
+	}
+
+	when( true ) waitfor( x ) {
+	} or when ( true ) timeout( 3 ) {
+	}
+
+	when( true ) waitfor( x, z ) {
+	} or when ( true ) timeout( 3 ) {
+	}
+
+	waitfor( x );
+	or timeout( 3 ) {
+	}
+
+	when( true ) waitfor( x );
+	or timeout( 3 ) {
+	}
+
+	when( true ) waitfor( x );
+	or when( true ) timeout( 3 ) {
+	}
+
+	waitfor( x ) {
+	} or timeout( 3 );
+
+	when( true ) waitfor( x ) {
+	} or timeout( 3 );
+
+	when( true ) waitfor( x ) {
+	} or when( true ) timeout( 3 );
+
+	// test when, waitfor, timeout and else
+
+	waitfor( x ) {
+	} or timeout( 3 ) {
+	} or when( true ) else {}
+
+	when( true ) waitfor( x ) {
+	} or timeout( 3 ) {
+	} or when( true ) else {}
+
+	waitfor( x ) {
+	} or timeout( 3 ) {
+	} or when( true ) else {}
+
+	waitfor( x ) {
+	} or when( true ) timeout( 3 ) {
+	} or when( true ) else {}
+
+	when( true ) waitfor( x ) {
+	} or timeout( 3 ) {
+	} or when( true ) else {}
+
+	waitfor( x ) {
+	} or when( true ) timeout( 3 ) {
+	} or when( true ) else {}
+
+	when( true ) waitfor( x ) {
+	} or when( true ) timeout( 3 ) {
+	} or when( true ) else {}
+
+	// test quasi-keywords "or" and "timeout"
+
+	int or, timeout;
+	waitfor( timeout, 7 ) 3;
+	waitfor( timeout, 7 ) 3; or waitfor( timeout, 7 ) 3;
+	when( or ) waitfor( or, ) { 4; } or timeout( 1 ) 3;
+	when( 3 ) waitfor( or, 2 ) 4; or else 4;
+	when( 3 ) waitfor( or, 3 ) 4; or when( or ) timeout( or ) 4; or when( or ) else timeout;
+	when( 3 ) waitfor( or, or ) 3; or when( or ) waitfor( or, timeout ) 4; or else 4;
+	when( 3 ) waitfor( or, or ) 3; or waitfor( or, 9 ) 4; or when( or ) timeout( timeout ) 4;
+	when( 3 ) waitfor( or, 3 ) 3; or waitfor( or, 7 ) or; or timeout( 1 ) or; or when( 3 ) else or;
+
+	// test else selection
+
+	if ( or > timeout ) waitfor( or ) 3;
+	else waitfor( timeout ) 4;
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "cfa waitfor.c" //
+// End: //
Index: tests/concurrent/waitfor/recurse.c
===================================================================
--- tests/concurrent/waitfor/recurse.c	(revision 200fcb3c496b08f843f691550554b21d786aad38)
+++ 	(revision )
@@ -1,146 +1,0 @@
-//----------------------------------------------------------------
-// Recursion test
-// Ensures that proper ordering occurs between the nested waitfors
-//-----------------------------------------------------------------
-
-#include <fstream.hfa>
-#include <kernel.hfa>
-#include <monitor.hfa>
-#include <stdlib.hfa>
-#include <thread.hfa>
-
-#include <stdbool.h>
-#include <time.h>
-
-static const unsigned long N = 5_000ul;
-
-static inline void rand_yield() { yield(random( 10 )); }
-
-enum state_t { FIRST, SECOND, THIRD, LAST, STOP };
-void shuffle(enum state_t * array)
-{
-	int i;
-	for (i = 0; i < 4; i++)
-	{
-		int j = random( 4 );
-		enum state_t t = array[j];
-		array[j] = array[i];
-		array[i] = t;
-	}
-}
-
-
-monitor global_t {
-	int counter;
-	volatile bool ready;
-	state_t actions[4];
-};
-
-void ?{} ( global_t & this ) {
-	this.counter = 0;
-	this.ready = false;
-	this.actions[0] = FIRST;
-	this.actions[1] = SECOND;
-	this.actions[2] = THIRD;
-	this.actions[3] = LAST;
-	shuffle( this.actions );
-}
-
-void ^?{} ( global_t & mutex this ) {}
-
-global_t global;
-
-state_t call4( global_t & mutex this, int idx ) {
-	sout | "Last";
-
-	rand_yield();
-	this.counter++;
-	this.ready = false;
-	shuffle( this.actions );
-
-	return this.counter < N ? (state_t)this.actions[idx] : (state_t)STOP;
-}
-
-state_t call3( global_t & mutex this, int idx ) {
-	sout | "3rd";
-
-	rand_yield();
-	waitfor( call4, this );
-	rand_yield();
-
-	sout | "3rd";
-
-	return this.counter < N ? (state_t)this.actions[idx] : (state_t)STOP;
-}
-
-state_t call2( global_t & mutex this, int idx ) {
-	sout | "2nd";
-
-	rand_yield();
-	waitfor( call3, this );
-	rand_yield();
-
-	sout | "2nd";
-
-	return this.counter < N ? (state_t)this.actions[idx] : (state_t)STOP;
-}
-
-state_t call1( global_t & mutex this, int idx ) {
-	this.ready = true;
-
-	sout | this.counter | "1st";
-
-	rand_yield();
-	waitfor( call2, this );
-	rand_yield();
-
-	sout | "1st" | nl;
-
-	return this.counter < N ? (state_t)this.actions[idx] : (state_t)STOP;
-}
-
-thread waiter_t{
-	int     idx;
-	state_t state;
-};
-
-void ^?{} ( waiter_t & mutex this ) {}
-void ?{} ( waiter_t & this ) {}
-
-void ?{}( waiter_t & this, int idx, state_t state ) {
-	this.idx   = idx;
-	this.state = state;
-}
-
-
-void main( waiter_t & this ) {
-	while( this.state != STOP ) {
-		rand_yield();
-
-		switch( this.state ) {
-			case FIRST  :                                     this.state = call1( global, this.idx ); break;
-			case SECOND : while( !global.ready ) { yield(); } this.state = call2( global, this.idx ); break;
-			case THIRD  : while( !global.ready ) { yield(); } this.state = call3( global, this.idx ); break;
-			case LAST   : while( !global.ready ) { yield(); } this.state = call4( global, this.idx ); break;
-			case STOP   : serr | "This should not happen" | nl;
-		}
-	}
-}
-
-static waiter_t * volatile the_threads;
-
-int main() {
-	srandom( time(NULL) );
-	sout | nlOff;					// turn off auto newline
-	sout | "Starting" | nl;
-	{
-		waiter_t waiters[4] = {
-			{ 0, FIRST  },
-			{ 1, SECOND },
-			{ 2, THIRD  },
-			{ 3, LAST   }
-		};
-		the_threads = waiters;
-	}
-	sout | "Stopping" | nl;
-}
Index: tests/concurrent/waitfor/recurse.cfa
===================================================================
--- tests/concurrent/waitfor/recurse.cfa	(revision 107b01a853d2fa7848b6015136777f62881c1779)
+++ tests/concurrent/waitfor/recurse.cfa	(revision 107b01a853d2fa7848b6015136777f62881c1779)
@@ -0,0 +1,146 @@
+//----------------------------------------------------------------
+// Recursion test
+// Ensures that proper ordering occurs between the nested waitfors
+//-----------------------------------------------------------------
+
+#include <fstream.hfa>
+#include <kernel.hfa>
+#include <monitor.hfa>
+#include <stdlib.hfa>
+#include <thread.hfa>
+
+#include <stdbool.h>
+#include <time.h>
+
+static const unsigned long N = 5_000ul;
+
+static inline void rand_yield() { yield(random( 10 )); }
+
+enum state_t { FIRST, SECOND, THIRD, LAST, STOP };
+void shuffle(enum state_t * array)
+{
+	int i;
+	for (i = 0; i < 4; i++)
+	{
+		int j = random( 4 );
+		enum state_t t = array[j];
+		array[j] = array[i];
+		array[i] = t;
+	}
+}
+
+
+monitor global_t {
+	int counter;
+	volatile bool ready;
+	state_t actions[4];
+};
+
+void ?{} ( global_t & this ) {
+	this.counter = 0;
+	this.ready = false;
+	this.actions[0] = FIRST;
+	this.actions[1] = SECOND;
+	this.actions[2] = THIRD;
+	this.actions[3] = LAST;
+	shuffle( this.actions );
+}
+
+void ^?{} ( global_t & mutex this ) {}
+
+global_t global;
+
+state_t call4( global_t & mutex this, int idx ) {
+	sout | "Last";
+
+	rand_yield();
+	this.counter++;
+	this.ready = false;
+	shuffle( this.actions );
+
+	return this.counter < N ? (state_t)this.actions[idx] : (state_t)STOP;
+}
+
+state_t call3( global_t & mutex this, int idx ) {
+	sout | "3rd";
+
+	rand_yield();
+	waitfor( call4, this );
+	rand_yield();
+
+	sout | "3rd";
+
+	return this.counter < N ? (state_t)this.actions[idx] : (state_t)STOP;
+}
+
+state_t call2( global_t & mutex this, int idx ) {
+	sout | "2nd";
+
+	rand_yield();
+	waitfor( call3, this );
+	rand_yield();
+
+	sout | "2nd";
+
+	return this.counter < N ? (state_t)this.actions[idx] : (state_t)STOP;
+}
+
+state_t call1( global_t & mutex this, int idx ) {
+	this.ready = true;
+
+	sout | this.counter | "1st";
+
+	rand_yield();
+	waitfor( call2, this );
+	rand_yield();
+
+	sout | "1st" | nl;
+
+	return this.counter < N ? (state_t)this.actions[idx] : (state_t)STOP;
+}
+
+thread waiter_t{
+	int     idx;
+	state_t state;
+};
+
+void ^?{} ( waiter_t & mutex this ) {}
+void ?{} ( waiter_t & this ) {}
+
+void ?{}( waiter_t & this, int idx, state_t state ) {
+	this.idx   = idx;
+	this.state = state;
+}
+
+
+void main( waiter_t & this ) {
+	while( this.state != STOP ) {
+		rand_yield();
+
+		switch( this.state ) {
+			case FIRST  :                                     this.state = call1( global, this.idx ); break;
+			case SECOND : while( !global.ready ) { yield(); } this.state = call2( global, this.idx ); break;
+			case THIRD  : while( !global.ready ) { yield(); } this.state = call3( global, this.idx ); break;
+			case LAST   : while( !global.ready ) { yield(); } this.state = call4( global, this.idx ); break;
+			case STOP   : serr | "This should not happen" | nl;
+		}
+	}
+}
+
+static waiter_t * volatile the_threads;
+
+int main() {
+	srandom( time(NULL) );
+	sout | nlOff;					// turn off auto newline
+	sout | "Starting" | nl;
+	{
+		waiter_t waiters[4] = {
+			{ 0, FIRST  },
+			{ 1, SECOND },
+			{ 2, THIRD  },
+			{ 3, LAST   }
+		};
+		the_threads = waiters;
+	}
+	sout | "Stopping" | nl;
+}
Index: tests/concurrent/waitfor/simple.c
===================================================================
--- tests/concurrent/waitfor/simple.c	(revision 200fcb3c496b08f843f691550554b21d786aad38)
+++ 	(revision )
@@ -1,85 +1,0 @@
-#include <fstream.hfa>
-#include <kernel.hfa>
-#include <monitor.hfa>
-#include <stdlib.hfa>
-#include <thread.hfa>
-
-#include <time.h>
-
-static const unsigned long N = 500ul;
-
-#ifndef PREEMPTION_RATE
-#define PREEMPTION_RATE 10`ms
-#endif
-
-Duration default_preemption() {
-	return PREEMPTION_RATE;
-}
-
-monitor global_t {};
-
-global_t globalA;
-
-thread Acceptor {};
-thread Acceptee {};
-
-volatile bool done;
-
-//----------------------------------------------------------------------------------------------------
-// Acceptor
-void do_notify( global_t * mutex a );
-
-void do_wait( global_t * mutex a ) {
-	sout | "Waiting to accept";
-	yield( random( 10 ) );
-
-	sout | "Accepting";
-
-	__acceptable_t acceptable;
-	acceptable.func          = (fptr_t)do_notify;
-	acceptable.count         = 1;
-	acceptable.monitors      = &a;
-
-	__waitfor_internal( 1, &acceptable );
-
-	sout | "Accepted";
-	yield( random( 10 ) );
-}
-
-void main( Acceptor* this ) {
-	for( int i = 0; i < N; i++ ) {
-		do_wait( &globalA );
-		sout | i;
-	}
-
-	done = true;
-}
-
-//----------------------------------------------------------------------------------------------------
-// Acceptee
-void do_notify( global_t * mutex a ) {
-
-}
-
-void main( Acceptee* this ) {
-	while( !done ) {
-		yield( random( 10 ) );
-		do_notify( &globalA );
-		yield( random( 10 ) );
-	}
-}
-
-//----------------------------------------------------------------------------------------------------
-// Main
-int main(int argc, char* argv[]) {
-	done = false;
-	srandom( time( NULL ) );
-	printf("%p\n", &globalA);
-	sout | "Starting";
-	{
-		Acceptor r;
-		Acceptee e[13];
-
-	}
-	sout | "Done";
-}
Index: tests/concurrent/waitfor/simple.cfa
===================================================================
--- tests/concurrent/waitfor/simple.cfa	(revision 107b01a853d2fa7848b6015136777f62881c1779)
+++ tests/concurrent/waitfor/simple.cfa	(revision 107b01a853d2fa7848b6015136777f62881c1779)
@@ -0,0 +1,85 @@
+#include <fstream.hfa>
+#include <kernel.hfa>
+#include <monitor.hfa>
+#include <stdlib.hfa>
+#include <thread.hfa>
+
+#include <time.h>
+
+static const unsigned long N = 500ul;
+
+#ifndef PREEMPTION_RATE
+#define PREEMPTION_RATE 10`ms
+#endif
+
+Duration default_preemption() {
+	return PREEMPTION_RATE;
+}
+
+monitor global_t {};
+
+global_t globalA;
+
+thread Acceptor {};
+thread Acceptee {};
+
+volatile bool done;
+
+//----------------------------------------------------------------------------------------------------
+// Acceptor
+void do_notify( global_t * mutex a );
+
+void do_wait( global_t * mutex a ) {
+	sout | "Waiting to accept";
+	yield( random( 10 ) );
+
+	sout | "Accepting";
+
+	__acceptable_t acceptable;
+	acceptable.func          = (fptr_t)do_notify;
+	acceptable.count         = 1;
+	acceptable.monitors      = &a;
+
+	__waitfor_internal( 1, &acceptable );
+
+	sout | "Accepted";
+	yield( random( 10 ) );
+}
+
+void main( Acceptor* this ) {
+	for( int i = 0; i < N; i++ ) {
+		do_wait( &globalA );
+		sout | i;
+	}
+
+	done = true;
+}
+
+//----------------------------------------------------------------------------------------------------
+// Acceptee
+void do_notify( global_t * mutex a ) {
+
+}
+
+void main( Acceptee* this ) {
+	while( !done ) {
+		yield( random( 10 ) );
+		do_notify( &globalA );
+		yield( random( 10 ) );
+	}
+}
+
+//----------------------------------------------------------------------------------------------------
+// Main
+int main(int argc, char* argv[]) {
+	done = false;
+	srandom( time( NULL ) );
+	printf("%p\n", &globalA);
+	sout | "Starting";
+	{
+		Acceptor r;
+		Acceptee e[13];
+
+	}
+	sout | "Done";
+}
Index: tests/concurrent/waitfor/statment.c
===================================================================
--- tests/concurrent/waitfor/statment.c	(revision 200fcb3c496b08f843f691550554b21d786aad38)
+++ 	(revision )
@@ -1,136 +1,0 @@
-#include <fstream.hfa>
-#include <kernel.hfa>
-#include <monitor.hfa>
-#include <thread.hfa>
-
-#include <stdbool.h>
-
-monitor M {
-	int index;
-	int last_val;
-	int calls[7];
-};
-
-volatile bool start = false;
-
-void ?{}( M & this ) {
-	this.index = 0;
-	this.last_val = 0;
-	for( int i = 0; i < 7; i++ ) {
-		this.calls[i] = 100; //10_000;
-	}
-}
-
-void ^?{} ( M &  mutex this ) {}
-
-int get_index( M & mutex this ) {
-	this.index += 1;
-	return this.index;
-}
-
-bool call1( M & mutex this ) {
-	this.last_val = 1;
-	this.calls[0] -= 1;
-	return this.calls[0] > 0;
-}
-
-bool call2( M & mutex this ) {
-	this.last_val = 2;
-	this.calls[1] -= 1;
-	return this.calls[1] > 0;
-}
-
-bool call3( M & mutex this ) {
-	this.last_val = 3;
-	this.calls[2] -= 1;
-	return this.calls[2] > 0;
-}
-
-bool call4( M & mutex this ) {
-	this.last_val = 4;
-	this.calls[3] -= 1;
-	return this.calls[3] > 0;
-}
-
-bool call5( M & mutex this ) {
-	this.last_val = 5;
-	this.calls[4] -= 1;
-	return this.calls[4] > 0;
-}
-
-bool call6( M & mutex this ) {
-	this.last_val = 6;
-	this.calls[5] -= 1;
-	return this.calls[5] > 0;
-}
-
-bool call7( M & mutex this ) {
-	this.last_val = 7;
-	this.calls[6] -= 1;
-	return this.calls[6] > 0;
-}
-
-M m;
-thread caller{};
-
-bool call( int index ) {
-	switch( index ) {
-		case 1: return call1( m );
-		case 2: return call2( m );
-		case 3: return call3( m );
-		case 4: return call4( m );
-		case 5: return call5( m );
-		case 6: return call6( m );
-		case 7: return call7( m );
-		default :
-			serr | "Incorrect index" | index;
-			abort();
-	}
-}
-
-void main( caller & this ) {
-	int index = get_index( m );
-	while( !start ) yield();
-	while( call( index ) );
-}
-
-void do_wait( M & mutex this ) {
-	bool done = false;
-
-	start = true;
-
-	while( !done ) {
-		   waitfor( get_index, this );
-		or waitfor( call1, this ) { sout | "Statement"; if( this.last_val != 1 ) { serr | "Incorrect index: expected" | 1 | "got" | this.last_val; } }
-		or waitfor( call2, this ) { sout | "Statement"; if( this.last_val != 2 ) { serr | "Incorrect index: expected" | 2 | "got" | this.last_val; } }
-		or waitfor( call3, this ) { sout | "Statement"; if( this.last_val != 3 ) { serr | "Incorrect index: expected" | 3 | "got" | this.last_val; } }
-		or waitfor( call4, this ) { sout | "Statement"; if( this.last_val != 4 ) { serr | "Incorrect index: expected" | 4 | "got" | this.last_val; } }
-		or waitfor( call5, this ) { sout | "Statement"; if( this.last_val != 5 ) { serr | "Incorrect index: expected" | 5 | "got" | this.last_val; } }
-		or waitfor( call6, this ) { sout | "Statement"; if( this.last_val != 6 ) { serr | "Incorrect index: expected" | 6 | "got" | this.last_val; } }
-		or waitfor( call7, this ) { sout | "Statement"; if( this.last_val != 7 ) { serr | "Incorrect index: expected" | 7 | "got" | this.last_val; } }
-
-		done = true;
-		for( int i = 0; i < 7; i++ ) {
-			if( this.calls[i] > 0 ) {
-				done = false;
-				break;
-			}
-		}
-	}
-}
-
-thread waiter{};
-
-void main( waiter & this ) {
-	do_wait( m );
-}
-
-int main() {
-	processor p[2];
-	sout | "Starting";
-	{
-		caller c[7];
-		waiter w;
-	}
-	sout | "Stopping";
-}
Index: tests/concurrent/waitfor/statment.cfa
===================================================================
--- tests/concurrent/waitfor/statment.cfa	(revision 107b01a853d2fa7848b6015136777f62881c1779)
+++ tests/concurrent/waitfor/statment.cfa	(revision 107b01a853d2fa7848b6015136777f62881c1779)
@@ -0,0 +1,136 @@
+#include <fstream.hfa>
+#include <kernel.hfa>
+#include <monitor.hfa>
+#include <thread.hfa>
+
+#include <stdbool.h>
+
+monitor M {
+	int index;
+	int last_val;
+	int calls[7];
+};
+
+volatile bool start = false;
+
+void ?{}( M & this ) {
+	this.index = 0;
+	this.last_val = 0;
+	for( int i = 0; i < 7; i++ ) {
+		this.calls[i] = 100; //10_000;
+	}
+}
+
+void ^?{} ( M &  mutex this ) {}
+
+int get_index( M & mutex this ) {
+	this.index += 1;
+	return this.index;
+}
+
+bool call1( M & mutex this ) {
+	this.last_val = 1;
+	this.calls[0] -= 1;
+	return this.calls[0] > 0;
+}
+
+bool call2( M & mutex this ) {
+	this.last_val = 2;
+	this.calls[1] -= 1;
+	return this.calls[1] > 0;
+}
+
+bool call3( M & mutex this ) {
+	this.last_val = 3;
+	this.calls[2] -= 1;
+	return this.calls[2] > 0;
+}
+
+bool call4( M & mutex this ) {
+	this.last_val = 4;
+	this.calls[3] -= 1;
+	return this.calls[3] > 0;
+}
+
+bool call5( M & mutex this ) {
+	this.last_val = 5;
+	this.calls[4] -= 1;
+	return this.calls[4] > 0;
+}
+
+bool call6( M & mutex this ) {
+	this.last_val = 6;
+	this.calls[5] -= 1;
+	return this.calls[5] > 0;
+}
+
+bool call7( M & mutex this ) {
+	this.last_val = 7;
+	this.calls[6] -= 1;
+	return this.calls[6] > 0;
+}
+
+M m;
+thread caller{};
+
+bool call( int index ) {
+	switch( index ) {
+		case 1: return call1( m );
+		case 2: return call2( m );
+		case 3: return call3( m );
+		case 4: return call4( m );
+		case 5: return call5( m );
+		case 6: return call6( m );
+		case 7: return call7( m );
+		default :
+			serr | "Incorrect index" | index;
+			abort();
+	}
+}
+
+void main( caller & this ) {
+	int index = get_index( m );
+	while( !start ) yield();
+	while( call( index ) );
+}
+
+void do_wait( M & mutex this ) {
+	bool done = false;
+
+	start = true;
+
+	while( !done ) {
+		   waitfor( get_index, this );
+		or waitfor( call1, this ) { sout | "Statement"; if( this.last_val != 1 ) { serr | "Incorrect index: expected" | 1 | "got" | this.last_val; } }
+		or waitfor( call2, this ) { sout | "Statement"; if( this.last_val != 2 ) { serr | "Incorrect index: expected" | 2 | "got" | this.last_val; } }
+		or waitfor( call3, this ) { sout | "Statement"; if( this.last_val != 3 ) { serr | "Incorrect index: expected" | 3 | "got" | this.last_val; } }
+		or waitfor( call4, this ) { sout | "Statement"; if( this.last_val != 4 ) { serr | "Incorrect index: expected" | 4 | "got" | this.last_val; } }
+		or waitfor( call5, this ) { sout | "Statement"; if( this.last_val != 5 ) { serr | "Incorrect index: expected" | 5 | "got" | this.last_val; } }
+		or waitfor( call6, this ) { sout | "Statement"; if( this.last_val != 6 ) { serr | "Incorrect index: expected" | 6 | "got" | this.last_val; } }
+		or waitfor( call7, this ) { sout | "Statement"; if( this.last_val != 7 ) { serr | "Incorrect index: expected" | 7 | "got" | this.last_val; } }
+
+		done = true;
+		for( int i = 0; i < 7; i++ ) {
+			if( this.calls[i] > 0 ) {
+				done = false;
+				break;
+			}
+		}
+	}
+}
+
+thread waiter{};
+
+void main( waiter & this ) {
+	do_wait( m );
+}
+
+int main() {
+	processor p[2];
+	sout | "Starting";
+	{
+		caller c[7];
+		waiter w;
+	}
+	sout | "Stopping";
+}
Index: tests/concurrent/waitfor/when.c
===================================================================
--- tests/concurrent/waitfor/when.c	(revision 200fcb3c496b08f843f691550554b21d786aad38)
+++ 	(revision )
@@ -1,87 +1,0 @@
-//----------------------------------------------------------------
-// When test
-// Ensures that when clauses on waitfor are respected
-//-----------------------------------------------------------------
-
-#include <fstream.hfa>
-#include <kernel.hfa>
-#include <monitor.hfa>
-#include <stdlib.hfa>
-#include <thread.hfa>
-
-#include <stdbool.h>
-#include <time.h>
-
-static const unsigned long N = 4_998ul;
-
-static inline void rand_yield() { yield(random( 10 )); }
-
-monitor global_t {
-	int last_call;
-	bool done;
-};
-
-void ?{} ( global_t & this ) {
-	this.last_call = 6;
-	this.done = false;
-}
-
-void ^?{} ( global_t & mutex this ) {}
-
-global_t global;
-
-bool call1( global_t & mutex this ) { this.last_call = 1; return this.done; }
-bool call2( global_t & mutex this ) { this.last_call = 2; return this.done; }
-bool call3( global_t & mutex this ) { this.last_call = 3; return this.done; }
-bool call4( global_t & mutex this ) { this.last_call = 4; return this.done; }
-bool call5( global_t & mutex this ) { this.last_call = 5; return this.done; }
-bool call6( global_t & mutex this ) { this.last_call = 6; return this.done; }
-
-thread caller_t{};
-void main( caller_t & this ) {
-	while( true ) {
-		rand_yield();
-		if( call1( global ) ) return;
-		rand_yield();
-		if( call2( global ) ) return;
-		rand_yield();
-		if( call3( global ) ) return;
-		rand_yield();
-		if( call4( global ) ) return;
-		rand_yield();
-		if( call5( global ) ) return;
-		rand_yield();
-		if( call6( global ) ) return;
-	}
-}
-
-void arbiter( global_t & mutex this ) {
-	for( int i = 0; i < N; i++ ) {
-		   when( this.last_call == 6 ) waitfor( call1, this ) { if( this.last_call != 1) { serr | "Expected last_call to be 1 got" | this.last_call; } }
-		or when( this.last_call == 1 ) waitfor( call2, this ) { if( this.last_call != 2) { serr | "Expected last_call to be 2 got" | this.last_call; } }
-		or when( this.last_call == 2 ) waitfor( call3, this ) { if( this.last_call != 3) { serr | "Expected last_call to be 3 got" | this.last_call; } }
-		or when( this.last_call == 3 ) waitfor( call4, this ) { if( this.last_call != 4) { serr | "Expected last_call to be 4 got" | this.last_call; } }
-		or when( this.last_call == 4 ) waitfor( call5, this ) { if( this.last_call != 5) { serr | "Expected last_call to be 5 got" | this.last_call; } }
-		or when( this.last_call == 5 ) waitfor( call6, this ) { if( this.last_call != 6) { serr | "Expected last_call to be 6 got" | this.last_call; } }
-
-		sout | this.last_call;
-	}
-
-	this.done = true;
-}
-
-thread arbiter_t{};
-void main( arbiter_t & this ) {
-	arbiter( global );
-}
-
-int main() {
-	srandom( time(NULL) );
-	sout | "Starting";
-	{
-		arbiter_t arbiter;
-		caller_t callers[7];
-
-	}
-	sout | "Stopping";
-}
Index: tests/concurrent/waitfor/when.cfa
===================================================================
--- tests/concurrent/waitfor/when.cfa	(revision 107b01a853d2fa7848b6015136777f62881c1779)
+++ tests/concurrent/waitfor/when.cfa	(revision 107b01a853d2fa7848b6015136777f62881c1779)
@@ -0,0 +1,87 @@
+//----------------------------------------------------------------
+// When test
+// Ensures that when clauses on waitfor are respected
+//-----------------------------------------------------------------
+
+#include <fstream.hfa>
+#include <kernel.hfa>
+#include <monitor.hfa>
+#include <stdlib.hfa>
+#include <thread.hfa>
+
+#include <stdbool.h>
+#include <time.h>
+
+static const unsigned long N = 4_998ul;
+
+static inline void rand_yield() { yield(random( 10 )); }
+
+monitor global_t {
+	int last_call;
+	bool done;
+};
+
+void ?{} ( global_t & this ) {
+	this.last_call = 6;
+	this.done = false;
+}
+
+void ^?{} ( global_t & mutex this ) {}
+
+global_t global;
+
+bool call1( global_t & mutex this ) { this.last_call = 1; return this.done; }
+bool call2( global_t & mutex this ) { this.last_call = 2; return this.done; }
+bool call3( global_t & mutex this ) { this.last_call = 3; return this.done; }
+bool call4( global_t & mutex this ) { this.last_call = 4; return this.done; }
+bool call5( global_t & mutex this ) { this.last_call = 5; return this.done; }
+bool call6( global_t & mutex this ) { this.last_call = 6; return this.done; }
+
+thread caller_t{};
+void main( caller_t & this ) {
+	while( true ) {
+		rand_yield();
+		if( call1( global ) ) return;
+		rand_yield();
+		if( call2( global ) ) return;
+		rand_yield();
+		if( call3( global ) ) return;
+		rand_yield();
+		if( call4( global ) ) return;
+		rand_yield();
+		if( call5( global ) ) return;
+		rand_yield();
+		if( call6( global ) ) return;
+	}
+}
+
+void arbiter( global_t & mutex this ) {
+	for( int i = 0; i < N; i++ ) {
+		   when( this.last_call == 6 ) waitfor( call1, this ) { if( this.last_call != 1) { serr | "Expected last_call to be 1 got" | this.last_call; } }
+		or when( this.last_call == 1 ) waitfor( call2, this ) { if( this.last_call != 2) { serr | "Expected last_call to be 2 got" | this.last_call; } }
+		or when( this.last_call == 2 ) waitfor( call3, this ) { if( this.last_call != 3) { serr | "Expected last_call to be 3 got" | this.last_call; } }
+		or when( this.last_call == 3 ) waitfor( call4, this ) { if( this.last_call != 4) { serr | "Expected last_call to be 4 got" | this.last_call; } }
+		or when( this.last_call == 4 ) waitfor( call5, this ) { if( this.last_call != 5) { serr | "Expected last_call to be 5 got" | this.last_call; } }
+		or when( this.last_call == 5 ) waitfor( call6, this ) { if( this.last_call != 6) { serr | "Expected last_call to be 6 got" | this.last_call; } }
+
+		sout | this.last_call;
+	}
+
+	this.done = true;
+}
+
+thread arbiter_t{};
+void main( arbiter_t & this ) {
+	arbiter( global );
+}
+
+int main() {
+	srandom( time(NULL) );
+	sout | "Starting";
+	{
+		arbiter_t arbiter;
+		caller_t callers[7];
+
+	}
+	sout | "Stopping";
+}
