Index: doc/theses/thierry_delisle_PhD/thesis/fig/base.fig
===================================================================
--- doc/theses/thierry_delisle_PhD/thesis/fig/base.fig	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ doc/theses/thierry_delisle_PhD/thesis/fig/base.fig	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -12,4 +12,9 @@
 1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6900 4200 20 20 6900 4200 6920 4200
 1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6975 4200 20 20 6975 4200 6995 4200
+-6
+6 6375 5100 6675 5250
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6450 5175 20 20 6450 5175 6470 5175
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6525 5175 20 20 6525 5175 6545 5175
+1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6600 5175 20 20 6600 5175 6620 5175
 -6
 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 3900 2400 300 300 3900 2400 4200 2400
@@ -75,4 +80,13 @@
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
 	 2400 2475 3000 2475
+2 3 0 1 0 7 50 -1 -1 0.000 0 0 0 0 0 7
+	 3300 5210 3150 4950 2850 4950 2700 5210 2850 5470 3150 5470
+	 3300 5210
+2 3 0 1 0 7 50 -1 -1 0.000 0 0 0 0 0 7
+	 4500 5210 4350 4950 4050 4950 3900 5210 4050 5470 4350 5470
+	 4500 5210
+2 3 0 1 0 7 50 -1 -1 0.000 0 0 0 0 0 7
+	 5700 5210 5550 4950 5250 4950 5100 5210 5250 5470 5550 5470
+	 5700 5210
 4 2 -1 50 -1 0 12 0.0000 2 135 630 2100 3075 Threads\001
 4 2 -1 50 -1 0 12 0.0000 2 165 450 2100 2850 Ready\001
@@ -82,2 +96,3 @@
 4 1 -1 50 -1 0 11 0.0000 2 135 180 2700 3550 TS\001
 4 1 -1 50 -1 0 11 0.0000 2 135 180 2700 2650 TS\001
+4 2 -1 50 -1 0 12 0.0000 2 135 900 2100 5175 Processors\001
Index: doc/theses/thierry_delisle_PhD/thesis/glossary.tex
===================================================================
--- doc/theses/thierry_delisle_PhD/thesis/glossary.tex	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ doc/theses/thierry_delisle_PhD/thesis/glossary.tex	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -40,4 +40,10 @@
 
 \textit{Synonyms : User threads, Lightweight threads, Green threads, Virtual threads, Tasks.}
+}
+
+\longnewglossaryentry{rmr}
+{name={remote memory reference}}
+{
+
 }
 
Index: doc/theses/thierry_delisle_PhD/thesis/text/core.tex
===================================================================
--- doc/theses/thierry_delisle_PhD/thesis/text/core.tex	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ doc/theses/thierry_delisle_PhD/thesis/text/core.tex	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -49,73 +49,113 @@
 
 \section{Design}
-In general, a na\"{i}ve \glsxtrshort{fifo} ready-queue does not scale with increased parallelism from \glspl{hthrd}, resulting in decreased performance. The problem is adding/removing \glspl{thrd} is a single point of contention. As shown in the evaluation sections, most production schedulers do scale when adding \glspl{hthrd}. The common solution to the single point of contention is to shard the ready-queue so each \gls{hthrd} can access the ready-queue without contention, increasing performance.
+In general, a na\"{i}ve \glsxtrshort{fifo} ready-queue does not scale with increased parallelism from \glspl{hthrd}, resulting in decreased performance. The problem is adding/removing \glspl{thrd} is a single point of contention. As shown in the evaluation sections, most production schedulers do scale when adding \glspl{hthrd}. The solution to this problem is to shard the ready-queue : create multiple sub-ready-queues that multiple \glspl{hthrd} can access and modify without interfering.
 
-\subsection{Sharding} \label{sec:sharding}
-An interesting approach to sharding a queue is presented in \cit{Trevors paper}. This algorithm presents a queue with a relaxed \glsxtrshort{fifo} guarantee using an array of strictly \glsxtrshort{fifo} sublists as shown in Figure~\ref{fig:base}. Each \emph{cell} of the array has a timestamp for the last operation and a pointer to a linked-list with a lock. Each node in the list is marked with a timestamp indicating when it is added to the list. A push operation is done by picking a random cell, acquiring the list lock, and pushing to the list. If the cell is locked, the operation is simply retried on another random cell until a lock is acquired. A pop operation is done in a similar fashion except two random cells are picked. If both cells are unlocked with non-empty lists, the operation pops the node with the oldest timestamp. If one of the cells is unlocked and non-empty, the operation pops from that cell. If both cells are either locked or empty, the operation picks two new random cells and tries again.
+Before going into the design of \CFA's scheduler proper, I want to discuss two sharding solutions which served as the inspiration scheduler in this thesis.
 
+\subsection{Work-Stealing}
+
+As I mentioned in \ref{existing:workstealing}, a popular pattern shard the ready-queue is work-stealing. As mentionned, in this pattern each \gls{proc} has its own ready-queue and \glspl{proc} only access each other's ready-queue if they run out of work.
+The interesting aspect of workstealing happen in easier scheduling cases, \ie enough work for everyone but no more and no load balancing needed. In these cases, work-stealing is close to optimal scheduling: it can achieve perfect locality and have no contention.
+On the other hand, work-stealing schedulers only attempt to do load-balancing when a \gls{proc} runs out of work.
+This means that the scheduler may never balance unfairness that does not result in a \gls{proc} running out of work.
+Chapter~\ref{microbench} shows that in pathological cases this problem can lead to indefinite starvation.
+
+
+Based on these observation, I conclude that \emph{perfect} scheduler should behave very similarly to work-stealing in the easy cases, but should have more proactive load-balancing if the need arises.
+
+\subsection{Relaxed-Fifo}
+An entirely different scheme is to create a ``relaxed-FIFO'' queue as in \todo{cite Trevor's paper}. This approach forgos any ownership between \gls{proc} and ready-queue, and simply creates a pool of ready-queues from which the \glspl{proc} can pick from.
+\Glspl{proc} choose ready-queus at random, but timestamps are added to all elements of the queue and dequeues are done by picking two queues and dequeing the oldest element.
+The result is a queue that has both decent scalability and sufficient fairness.
+The lack of ownership means that as long as one \gls{proc} is still able to repeatedly dequeue elements, it is unlikely that any element will stay on the queue for much longer than any other element.
+This contrasts with work-stealing, where \emph{any} \gls{proc} busy for an extended period of time results in all the elements on its local queue to have to wait. Unless another \gls{proc} runs out of work.
+
+An important aspects of this scheme's fairness approach is that the timestamps make it possible to evaluate how long elements have been on the queue.
+However, another major aspect is that \glspl{proc} will eagerly search for these older elements instead of focusing on specific queues.
+
+While the fairness, of this scheme is good, it does suffer in terms of performance.
+It requires very wide sharding, \eg at least 4 queues per \gls{hthrd}, and the randomness means locality can suffer significantly and finding non-empty queues can be difficult.
+
+\section{\CFA}
+The \CFA is effectively attempting to merge these two approaches, keeping the best of both.
+It is based on the
 \begin{figure}
 	\centering
 	\input{base.pstex_t}
-	\caption[Relaxed FIFO list]{Relaxed FIFO list \smallskip\newline List at the base of the scheduler: an array of strictly FIFO lists. The timestamp is in all nodes and cell arrays.}
+	\caption[Base \CFA design]{Base \CFA design \smallskip\newline A list of sub-ready queues offers the sharding, two per \glspl{proc}. However, \glspl{proc} can access any of the sub-queues.}
 	\label{fig:base}
 \end{figure}
 
-\subsection{Finding threads}
-Once threads have been distributed onto multiple queues, identifying empty queues becomes a problem. Indeed, if the number of \glspl{thrd} does not far exceed the number of queues, it is probable that several of the cell queues are empty. Figure~\ref{fig:empty} shows an example with 2 \glspl{thrd} running on 8 queues, where the chances of getting an empty queue is 75\% per pick, meaning two random picks yield a \gls{thrd} only half the time. This scenario leads to performance problems since picks that do not yield a \gls{thrd} are not useful and do not necessarily help make more informed guesses.
 
-\begin{figure}
-	\centering
-	\input{empty.pstex_t}
-	\caption[``More empty'' Relaxed FIFO list]{``More empty'' Relaxed FIFO list \smallskip\newline Emptier state of the queue: the array contains many empty cells, that is strictly FIFO lists containing no elements.}
-	\label{fig:empty}
-\end{figure}
 
-There are several solutions to this problem, but they ultimately all have to encode if a cell has an empty list. My results show the density and locality of this encoding is generally the dominating factor in these scheme. Classic solutions to this problem use one of three techniques to encode the information:
+% The common solution to the single point of contention is to shard the ready-queue so each \gls{hthrd} can access the ready-queue without contention, increasing performance.
 
-\paragraph{Dense Information} Figure~\ref{fig:emptybit} shows a dense bitmask to identify the cell queues currently in use. This approach means processors can often find \glspl{thrd} in constant time, regardless of how many underlying queues are empty. Furthermore, modern x86 CPUs have extended bit manipulation instructions (BMI2) that allow searching the bitmask with very little overhead compared to the randomized selection approach for a filled ready queue, offering good performance even in cases with many empty inner queues. However, this technique has its limits: with a single word\footnote{Word refers here to however many bits can be written atomically.} bitmask, the total amount of ready-queue sharding is limited to the number of bits in the word. With a multi-word bitmask, this maximum limit can be increased arbitrarily, but the look-up time increases. Finally, a dense bitmap, either single or multi-word, causes additional contention problems that reduces performance because of cache misses after updates. This central update bottleneck also means the information in the bitmask is more often stale before a processor can use it to find an item, \ie mask read says there are available \glspl{thrd} but none on queue when the subsequent atomic check is done.
+% \subsection{Sharding} \label{sec:sharding}
+% An interesting approach to sharding a queue is presented in \cit{Trevors paper}. This algorithm presents a queue with a relaxed \glsxtrshort{fifo} guarantee using an array of strictly \glsxtrshort{fifo} sublists as shown in Figure~\ref{fig:base}. Each \emph{cell} of the array has a timestamp for the last operation and a pointer to a linked-list with a lock. Each node in the list is marked with a timestamp indicating when it is added to the list. A push operation is done by picking a random cell, acquiring the list lock, and pushing to the list. If the cell is locked, the operation is simply retried on another random cell until a lock is acquired. A pop operation is done in a similar fashion except two random cells are picked. If both cells are unlocked with non-empty lists, the operation pops the node with the oldest timestamp. If one of the cells is unlocked and non-empty, the operation pops from that cell. If both cells are either locked or empty, the operation picks two new random cells and tries again.
 
-\begin{figure}
-	\centering
-	\vspace*{-5pt}
-	{\resizebox{0.75\textwidth}{!}{\input{emptybit.pstex_t}}}
-	\vspace*{-5pt}
-	\caption[Underloaded queue with bitmask]{Underloaded queue with bitmask indicating array cells with items.}
-	\label{fig:emptybit}
+% \begin{figure}
+% 	\centering
+% 	\input{base.pstex_t}
+% 	\caption[Relaxed FIFO list]{Relaxed FIFO list \smallskip\newline List at the base of the scheduler: an array of strictly FIFO lists. The timestamp is in all nodes and cell arrays.}
+% 	\label{fig:base}
+% \end{figure}
 
-	\vspace*{10pt}
-	{\resizebox{0.75\textwidth}{!}{\input{emptytree.pstex_t}}}
-	\vspace*{-5pt}
-	\caption[Underloaded queue with binary search-tree]{Underloaded queue with binary search-tree indicating array cells with items.}
-	\label{fig:emptytree}
+% \subsection{Finding threads}
+% Once threads have been distributed onto multiple queues, identifying empty queues becomes a problem. Indeed, if the number of \glspl{thrd} does not far exceed the number of queues, it is probable that several of the cell queues are empty. Figure~\ref{fig:empty} shows an example with 2 \glspl{thrd} running on 8 queues, where the chances of getting an empty queue is 75\% per pick, meaning two random picks yield a \gls{thrd} only half the time. This scenario leads to performance problems since picks that do not yield a \gls{thrd} are not useful and do not necessarily help make more informed guesses.
 
-	\vspace*{10pt}
-	{\resizebox{0.95\textwidth}{!}{\input{emptytls.pstex_t}}}
-	\vspace*{-5pt}
-	\caption[Underloaded queue with per processor bitmask]{Underloaded queue with per processor bitmask indicating array cells with items.}
-	\label{fig:emptytls}
-\end{figure}
+% \begin{figure}
+% 	\centering
+% 	\input{empty.pstex_t}
+% 	\caption[``More empty'' Relaxed FIFO list]{``More empty'' Relaxed FIFO list \smallskip\newline Emptier state of the queue: the array contains many empty cells, that is strictly FIFO lists containing no elements.}
+% 	\label{fig:empty}
+% \end{figure}
 
-\paragraph{Sparse Information} Figure~\ref{fig:emptytree} shows an approach using a hierarchical tree data-structure to reduce contention and has been shown to work in similar cases~\cite{ellen2007snzi}. However, this approach may lead to poorer performance due to the inherent pointer chasing cost while still allowing significant contention on the nodes of the tree if the tree is shallow.
+% There are several solutions to this problem, but they ultimately all have to encode if a cell has an empty list. My results show the density and locality of this encoding is generally the dominating factor in these scheme. Classic solutions to this problem use one of three techniques to encode the information:
 
-\paragraph{Local Information} Figure~\ref{fig:emptytls} shows an approach using dense information, similar to the bitmap, but each \gls{hthrd} keeps its own independent copy. While this approach can offer good scalability \emph{and} low latency, the liveliness and discovery of the information can become a problem. This case is made worst in systems with few processors where even blind random picks can find \glspl{thrd} in a few tries.
+% \paragraph{Dense Information} Figure~\ref{fig:emptybit} shows a dense bitmask to identify the cell queues currently in use. This approach means processors can often find \glspl{thrd} in constant time, regardless of how many underlying queues are empty. Furthermore, modern x86 CPUs have extended bit manipulation instructions (BMI2) that allow searching the bitmask with very little overhead compared to the randomized selection approach for a filled ready queue, offering good performance even in cases with many empty inner queues. However, this technique has its limits: with a single word\footnote{Word refers here to however many bits can be written atomically.} bitmask, the total amount of ready-queue sharding is limited to the number of bits in the word. With a multi-word bitmask, this maximum limit can be increased arbitrarily, but the look-up time increases. Finally, a dense bitmap, either single or multi-word, causes additional contention problems that reduces performance because of cache misses after updates. This central update bottleneck also means the information in the bitmask is more often stale before a processor can use it to find an item, \ie mask read says there are available \glspl{thrd} but none on queue when the subsequent atomic check is done.
 
-I built a prototype of these approaches and none of these techniques offer satisfying performance when few threads are present. All of these approach hit the same 2 problems. First, randomly picking sub-queues is very fast. That speed means any improvement to the hit rate can easily be countered by a slow-down in look-up speed, whether or not there are empty lists. Second, the array is already sharded to avoid contention bottlenecks, so any denser data structure tends to become a bottleneck. In all cases, these factors meant the best cases scenario, \ie many threads, would get worst throughput, and the worst-case scenario, few threads, would get a better hit rate, but an equivalent poor throughput. As a result I tried an entirely different approach.
+% \begin{figure}
+% 	\centering
+% 	\vspace*{-5pt}
+% 	{\resizebox{0.75\textwidth}{!}{\input{emptybit.pstex_t}}}
+% 	\vspace*{-5pt}
+% 	\caption[Underloaded queue with bitmask]{Underloaded queue with bitmask indicating array cells with items.}
+% 	\label{fig:emptybit}
 
-\subsection{Dynamic Entropy}\cit{https://xkcd.com/2318/}
-In the worst-case scenario there are only few \glspl{thrd} ready to run, or more precisely given $P$ \glspl{proc}\footnote{For simplicity, this assumes there is a one-to-one match between \glspl{proc} and \glspl{hthrd}.}, $T$ \glspl{thrd} and $\epsilon$ a very small number, than the worst case scenario can be represented by $T = P + \epsilon$, with $\epsilon \ll P$. It is important to note in this case that fairness is effectively irrelevant. Indeed, this case is close to \emph{actually matching} the model of the ``Ideal multi-tasking CPU'' on page \pageref{q:LinuxCFS}. In this context, it is possible to use a purely internal-locality based approach and still meet the fairness requirements. This approach simply has each \gls{proc} running a single \gls{thrd} repeatedly. Or from the shared ready-queue viewpoint, each \gls{proc} pushes to a given sub-queue and then pops from the \emph{same} subqueue. The challenge is for the the scheduler to achieve good performance in both the $T = P + \epsilon$ case and the $T \gg P$ case, without affecting the fairness guarantees in the later.
+% 	\vspace*{10pt}
+% 	{\resizebox{0.75\textwidth}{!}{\input{emptytree.pstex_t}}}
+% 	\vspace*{-5pt}
+% 	\caption[Underloaded queue with binary search-tree]{Underloaded queue with binary search-tree indicating array cells with items.}
+% 	\label{fig:emptytree}
 
-To handle this case, I use a \glsxtrshort{prng}\todo{Fix missing long form} in a novel way. There exist \glsxtrshort{prng}s that are fast, compact and can be run forward \emph{and} backwards.  Linear congruential generators~\cite{wiki:lcg} are an example of \glsxtrshort{prng}s of such \glsxtrshort{prng}s. The novel approach is to use the ability to run backwards to ``replay'' the \glsxtrshort{prng}. The scheduler uses an exclusive \glsxtrshort{prng} instance per \gls{proc}, the random-number seed effectively starts an encoding that produces a list of all accessed subqueues, from latest to oldest. Replaying the \glsxtrshort{prng} to identify cells accessed recently and which probably have data still cached.
+% 	\vspace*{10pt}
+% 	{\resizebox{0.95\textwidth}{!}{\input{emptytls.pstex_t}}}
+% 	\vspace*{-5pt}
+% 	\caption[Underloaded queue with per processor bitmask]{Underloaded queue with per processor bitmask indicating array cells with items.}
+% 	\label{fig:emptytls}
+% \end{figure}
 
-The algorithm works as follows:
-\begin{itemize}
-	\item Each \gls{proc} has two \glsxtrshort{prng} instances, $F$ and $B$.
-	\item Push and Pop operations occur as discussed in Section~\ref{sec:sharding} with the following exceptions:
-	\begin{itemize}
-		\item Push operations use $F$ going forward on each try and on success $F$ is copied into $B$.
-		\item Pop operations use $B$ going backwards on each try.
-	\end{itemize}
-\end{itemize}
+% \paragraph{Sparse Information} Figure~\ref{fig:emptytree} shows an approach using a hierarchical tree data-structure to reduce contention and has been shown to work in similar cases~\cite{ellen2007snzi}. However, this approach may lead to poorer performance due to the inherent pointer chasing cost while still allowing significant contention on the nodes of the tree if the tree is shallow.
 
-The main benefit of this technique is that it basically respects the desired properties of Figure~\ref{fig:fair}. When looking for work, a \gls{proc} first looks at the last cell they pushed to, if any, and then move backwards through its accessed cells. As the \gls{proc} continues looking for work, $F$ moves backwards and $B$ stays in place. As a result, the relation between the two becomes weaker, which means that the probablisitic fairness of the algorithm reverts to normal. Chapter~\ref{proofs} discusses more formally the fairness guarantees of this algorithm.
+% \paragraph{Local Information} Figure~\ref{fig:emptytls} shows an approach using dense information, similar to the bitmap, but each \gls{hthrd} keeps its own independent copy. While this approach can offer good scalability \emph{and} low latency, the liveliness and discovery of the information can become a problem. This case is made worst in systems with few processors where even blind random picks can find \glspl{thrd} in a few tries.
 
-\section{Details}
+% I built a prototype of these approaches and none of these techniques offer satisfying performance when few threads are present. All of these approach hit the same 2 problems. First, randomly picking sub-queues is very fast. That speed means any improvement to the hit rate can easily be countered by a slow-down in look-up speed, whether or not there are empty lists. Second, the array is already sharded to avoid contention bottlenecks, so any denser data structure tends to become a bottleneck. In all cases, these factors meant the best cases scenario, \ie many threads, would get worst throughput, and the worst-case scenario, few threads, would get a better hit rate, but an equivalent poor throughput. As a result I tried an entirely different approach.
+
+% \subsection{Dynamic Entropy}\cit{https://xkcd.com/2318/}
+% In the worst-case scenario there are only few \glspl{thrd} ready to run, or more precisely given $P$ \glspl{proc}\footnote{For simplicity, this assumes there is a one-to-one match between \glspl{proc} and \glspl{hthrd}.}, $T$ \glspl{thrd} and $\epsilon$ a very small number, than the worst case scenario can be represented by $T = P + \epsilon$, with $\epsilon \ll P$. It is important to note in this case that fairness is effectively irrelevant. Indeed, this case is close to \emph{actually matching} the model of the ``Ideal multi-tasking CPU'' on page \pageref{q:LinuxCFS}. In this context, it is possible to use a purely internal-locality based approach and still meet the fairness requirements. This approach simply has each \gls{proc} running a single \gls{thrd} repeatedly. Or from the shared ready-queue viewpoint, each \gls{proc} pushes to a given sub-queue and then pops from the \emph{same} subqueue. The challenge is for the the scheduler to achieve good performance in both the $T = P + \epsilon$ case and the $T \gg P$ case, without affecting the fairness guarantees in the later.
+
+% To handle this case, I use a \glsxtrshort{prng}\todo{Fix missing long form} in a novel way. There exist \glsxtrshort{prng}s that are fast, compact and can be run forward \emph{and} backwards.  Linear congruential generators~\cite{wiki:lcg} are an example of \glsxtrshort{prng}s of such \glsxtrshort{prng}s. The novel approach is to use the ability to run backwards to ``replay'' the \glsxtrshort{prng}. The scheduler uses an exclusive \glsxtrshort{prng} instance per \gls{proc}, the random-number seed effectively starts an encoding that produces a list of all accessed subqueues, from latest to oldest. Replaying the \glsxtrshort{prng} to identify cells accessed recently and which probably have data still cached.
+
+% The algorithm works as follows:
+% \begin{itemize}
+% 	\item Each \gls{proc} has two \glsxtrshort{prng} instances, $F$ and $B$.
+% 	\item Push and Pop operations occur as discussed in Section~\ref{sec:sharding} with the following exceptions:
+% 	\begin{itemize}
+% 		\item Push operations use $F$ going forward on each try and on success $F$ is copied into $B$.
+% 		\item Pop operations use $B$ going backwards on each try.
+% 	\end{itemize}
+% \end{itemize}
+
+% The main benefit of this technique is that it basically respects the desired properties of Figure~\ref{fig:fair}. When looking for work, a \gls{proc} first looks at the last cell they pushed to, if any, and then move backwards through its accessed cells. As the \gls{proc} continues looking for work, $F$ moves backwards and $B$ stays in place. As a result, the relation between the two becomes weaker, which means that the probablisitic fairness of the algorithm reverts to normal. Chapter~\ref{proofs} discusses more formally the fairness guarantees of this algorithm.
+
+% \section{Details}
Index: doc/theses/thierry_delisle_PhD/thesis/text/eval_macro.tex
===================================================================
--- doc/theses/thierry_delisle_PhD/thesis/text/eval_macro.tex	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ doc/theses/thierry_delisle_PhD/thesis/text/eval_macro.tex	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -4,6 +4,4 @@
 
 In Memory Plain Text
-
-Networked Plain Text
 
 Networked ZIPF
Index: doc/theses/thierry_delisle_PhD/thesis/text/eval_micro.tex
===================================================================
--- doc/theses/thierry_delisle_PhD/thesis/text/eval_micro.tex	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ doc/theses/thierry_delisle_PhD/thesis/text/eval_micro.tex	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -2,26 +2,24 @@
 
 The first step of evaluation is always to test-out small controlled cases, to ensure that the basics are working properly.
-This sections presents four different experimental setup, evaluating some of the basic features of \CFA's scheduler.
+This sections presents five different experimental setup, evaluating some of the basic features of \CFA's scheduler.
 
 \section{Cycling latency}
 The most basic evaluation of any ready queue is to evaluate the latency needed to push and pop one element from the ready-queue.
-While these two operation also describe a \texttt{yield} operation, many systems use this as the most basic benchmark.
-However, yielding can be treated as a special case, since it also carries the information that the length of the ready queue will not change.
+Since these two operation also describe a \texttt{yield} operation, many systems use this as the most basic benchmark.
+However, yielding can be treated as a special case, since it also carries the information that the number of the ready \glspl{at} will not change.
 Not all systems use this information, but those which do may appear to have better performance than they would for disconnected push/pop pairs.
 For this reason, I chose a different first benchmark, which I call the Cycle Benchmark.
-This benchmark arranges many threads into multiple rings of threads.
+This benchmark arranges many \glspl{at} into multiple rings of \glspl{at}.
 Each ring is effectively a circular singly-linked list.
-At runtime, each thread unparks the next thread before parking itself.
+At runtime, each \gls{at} unparks the next \gls{at} before parking itself.
 This corresponds to the desired pair of ready queue operations.
-Unparking the next thread requires pushing that thread onto the ready queue and the ensuing park will cause the runtime to pop a thread from the ready-queue.
+Unparking the next \gls{at} requires pushing that \gls{at} onto the ready queue and the ensuing park will cause the runtime to pop a \gls{at} from the ready-queue.
 Figure~\ref{fig:cycle} shows a visual representation of this arrangement.
 
-The goal of this ring is that the underlying runtime cannot rely on the guarantee that the number of ready threads will stay constant over the duration of the experiment.
-In fact, the total number of threads waiting on the ready is expected to vary a little because of the race between the next thread unparking and the current thread parking.
-The size of the cycle is also decided based on this race: cycles that are too small may see the
-chain of unparks go full circle before the first thread can park.
+The goal of this ring is that the underlying runtime cannot rely on the guarantee that the number of ready \glspl{at} will stay constant over the duration of the experiment.
+In fact, the total number of \glspl{at} waiting on the ready queue is expected to vary because of the race between the next \gls{at} unparking and the current \gls{at} parking.
+The size of the cycle is also decided based on this race: cycles that are too small may see the chain of unparks go full circle before the first \gls{at} can park.
 While this would not be a correctness problem, every runtime system must handle that race, it could lead to pushes and pops being optimized away.
-Since silently omitting ready-queue operations would throw off the measuring of these operations.
-Therefore the ring of threads must be big enough so the threads have the time to fully park before they are unparked.
+Since silently omitting ready-queue operations would throw off the measuring of these operations, the ring of \glspl{at} must be big enough so the \glspl{at} have the time to fully park before they are unparked.
 Note that this problem is only present on SMP machines and is significantly mitigated by the fact that there are multiple rings in the system.
 
@@ -29,22 +27,144 @@
 	\centering
 	\input{cycle.pstex_t}
-	\caption[Cycle benchmark]{Cycle benchmark\smallskip\newline Each thread unparks the next thread in the cycle before parking itself.}
+	\caption[Cycle benchmark]{Cycle benchmark\smallskip\newline Each \gls{at} unparks the next \gls{at} in the cycle before parking itself.}
 	\label{fig:cycle}
 \end{figure}
 
 \todo{check term ``idle sleep handling''}
-To avoid this benchmark from being dominated by the idle sleep handling, the number of rings is kept at least as high as the number of processors available.
+To avoid this benchmark from being dominated by the idle sleep handling, the number of rings is kept at least as high as the number of \glspl{proc} available.
 Beyond this point, adding more rings serves to mitigate even more the idle sleep handling.
-This is to avoid the case where one of the worker threads runs out of work because of the variation on the number of ready threads mentionned above.
+This is to avoid the case where one of the worker \glspl{at} runs out of work because of the variation on the number of ready \glspl{at} mentionned above.
 
 The actual benchmark is more complicated to handle termination, but that simply requires using a binary semphore or a channel instead of raw \texttt{park}/\texttt{unpark} and carefully picking the order of the \texttt{P} and \texttt{V} with respect to the loop condition.
 
-\todo{mention where to get the code.}
+\todo{code, setup, results}
+\begin{lstlisting}
+	Thread.main() {
+		count := 0
+		for {
+			wait()
+			this.next.wake()
+			count ++
+			if must_stop() { break }
+		}
+		global.count += count
+	}
+\end{lstlisting}
+
 
 \section{Yield}
 For completion, I also include the yield benchmark.
-This benchmark is much simpler than the cycle tests, it simply creates many threads that call \texttt{yield}.
+This benchmark is much simpler than the cycle tests, it simply creates many \glspl{at} that call \texttt{yield}.
+As mentionned in the previous section, this benchmark may be less representative of usages that only make limited use of \texttt{yield}, due to potential shortcuts in the routine.
+Its only interesting variable is the number of \glspl{at} per \glspl{proc}, where ratios close to 1 means the ready queue(s) could be empty.
+This sometimes puts more strain on the idle sleep handling, compared to scenarios where there is clearly plenty of work to be done.
+
+\todo{code, setup, results}
+
+\begin{lstlisting}
+	Thread.main() {
+		count := 0
+		while !stop {
+			yield()
+			count ++
+		}
+		global.count += count
+	}
+\end{lstlisting}
+
+
+\section{Churn}
+The Cycle and Yield benchmark represents an ``easy'' scenario for a scheduler, \eg, an embarrassingly parallel application.
+In these benchmarks, \glspl{at} can be easily partitioned over the different \glspl{proc} up-front and none of the \glspl{at} communicate with each other.
+
+The Churn benchmark represents more chaotic usages, where there is no relation between the last \gls{proc} on which a \gls{at} ran and the \gls{proc} that unblocked it.
+When a \gls{at} is unblocked from a different \gls{proc} than the one on which it last ran, the unblocking \gls{proc} must either ``steal'' the \gls{at} or place it on a remote queue.
+This results can result in either contention on the remote queue or \glspl{rmr} on \gls{at} data structure.
+In either case, this benchmark aims to highlight how each scheduler handles these cases, since both cases can lead to performance degradation if they are not handled correctly.
+
+To achieve this the benchmark uses a fixed size array of \newterm{chair}s, where a chair is a data structure that holds a single blocked \gls{at}.
+When a \gls{at} attempts to block on the chair, it must first unblocked the \gls{at} currently blocked on said chair, if any.
+This creates a flow where \glspl{at} push each other out of the chairs before being pushed out themselves.
+For this benchmark to work however, the number of \glspl{at} must be equal or greater to the number of chairs plus the number of \glspl{proc}.
+
+\todo{code, setup, results}
+\begin{lstlisting}
+	Thread.main() {
+		count := 0
+		for {
+			r := random() % len(spots)
+			next := xchg(spots[r], this)
+			if next { next.wake() }
+			wait()
+			count ++
+			if must_stop() { break }
+		}
+		global.count += count
+	}
+\end{lstlisting}
 
 \section{Locality}
 
+\todo{code, setup, results}
+
 \section{Transfer}
+The last benchmark is more exactly characterize as an experiment than a benchmark.
+It tests the behavior of the schedulers for a particularly misbehaved workload.
+In this workload, one of the \gls{at} is selected at random to be the leader.
+The leader then spins in a tight loop until it has observed that all other \glspl{at} have acknowledged its leadership.
+The leader \gls{at} then picks a new \gls{at} to be the ``spinner'' and the cycle repeats.
+
+The benchmark comes in two flavours for the behavior of the non-leader \glspl{at}:
+once they acknowledged the leader, they either block on a semaphore or yield repeatadly.
+
+This experiment is designed to evaluate the short term load balancing of the scheduler.
+Indeed, schedulers where the runnable \glspl{at} are partitioned on the \glspl{proc} may need to balance the \glspl{at} for this experient to terminate.
+This is because the spinning \gls{at} is effectively preventing the \gls{proc} from runnning any other \glspl{thrd}.
+In the semaphore flavour, the number of runnable \glspl{at} will eventually dwindle down to only the leader.
+This is a simpler case to handle for schedulers since \glspl{proc} eventually run out of work.
+In the yielding flavour, the number of runnable \glspl{at} stays constant.
+This is a harder case to handle because corrective measures must be taken even if work is still available.
+Note that languages that have mandatory preemption do circumvent this problem by forcing the spinner to yield.
+
+\todo{code, setup, results}
+\begin{lstlisting}
+	Thread.lead() {
+		this.idx_seen = ++lead_idx
+		if lead_idx > stop_idx {
+			done := true
+			return
+		}
+
+		// Wait for everyone to acknowledge my leadership
+		start: = timeNow()
+		for t in threads {
+			while t.idx_seen != lead_idx {
+				asm pause
+				if (timeNow() - start) > 5 seconds { error() }
+			}
+		}
+
+		// pick next leader
+		leader := threads[ prng() % len(threads) ]
+
+		// wake every one
+		if !exhaust {
+			for t in threads {
+				if t != me { t.wake() }
+			}
+		}
+	}
+
+	Thread.wait() {
+		this.idx_seen := lead_idx
+		if exhaust { wait() }
+		else { yield() }
+	}
+
+	Thread.main() {
+		while !done  {
+			if leader == me { this.lead() }
+			else { this.wait() }
+		}
+	}
+\end{lstlisting}
Index: doc/theses/thierry_delisle_PhD/thesis/text/existing.tex
===================================================================
--- doc/theses/thierry_delisle_PhD/thesis/text/existing.tex	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ doc/theses/thierry_delisle_PhD/thesis/text/existing.tex	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -33,5 +33,5 @@
 
 
-\section{Work Stealing}
+\section{Work Stealing}\label{existing:workstealing}
 One of the most popular scheduling algorithm in practice (see~\ref{existing:prod}) is work-stealing. This idea, introduce by \cite{DBLP:conf/fpca/BurtonS81}, effectively has each worker work on its local tasks first, but allows the possibility for other workers to steal local tasks if they run out of tasks. \cite{DBLP:conf/focs/Blumofe94} introduced the more familiar incarnation of this, where each workers has queue of tasks to accomplish and workers without tasks steal tasks from random workers. (The Burton and Sleep algorithm had trees of tasks and stole only among neighbours). Blumofe and Leiserson also prove worst case space and time requirements for well-structured computations.
 
Index: src/AST/Convert.cpp
===================================================================
--- src/AST/Convert.cpp	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/AST/Convert.cpp	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -9,7 +9,7 @@
 // Author           : Thierry Delisle
 // Created On       : Thu May 09 15::37::05 2019
-// Last Modified By : Andrew Beach
-// Last Modified On : Wed Jul 14 16:15:00 2021
-// Update Count     : 37
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Wed Feb  2 13:19:22 2022
+// Update Count     : 41
 //
 
@@ -393,6 +393,6 @@
 		auto stmt = new IfStmt(
 			get<Expression>().accept1( node->cond ),
-			get<Statement>().accept1( node->thenPart ),
-			get<Statement>().accept1( node->elsePart ),
+			get<Statement>().accept1( node->then ),
+			get<Statement>().accept1( node->else_ ),
 			get<Statement>().acceptL( node->inits )
 		);
@@ -419,10 +419,11 @@
 	}
 
-	const ast::Stmt * visit( const ast::WhileStmt * node ) override final {
+	const ast::Stmt * visit( const ast::WhileDoStmt * node ) override final {
 		if ( inCache( node ) ) return nullptr;
 		auto inits = get<Statement>().acceptL( node->inits );
-		auto stmt = new WhileStmt(
+		auto stmt = new WhileDoStmt(
 			get<Expression>().accept1( node->cond ),
 			get<Statement>().accept1( node->body ),
+			get<Statement>().accept1( node->else_ ),
 			inits,
 			node->isDoWhile
@@ -437,5 +438,6 @@
 			get<Expression>().accept1( node->cond ),
 			get<Expression>().accept1( node->inc ),
-			get<Statement>().accept1( node->body )
+			get<Statement>().accept1( node->body ),
+			get<Statement>().accept1( node->else_ )
 		);
 		return stmtPostamble( stmt, node );
@@ -1872,6 +1874,6 @@
 			old->location,
 			GET_ACCEPT_1(condition, Expr),
-			GET_ACCEPT_1(thenPart, Stmt),
-			GET_ACCEPT_1(elsePart, Stmt),
+			GET_ACCEPT_1(then, Stmt),
+			GET_ACCEPT_1(else_, Stmt),
 			GET_ACCEPT_V(initialization, Stmt),
 			GET_LABELS_V(old->labels)
@@ -1902,10 +1904,11 @@
 	}
 
-	virtual void visit( const WhileStmt * old ) override final {
+	virtual void visit( const WhileDoStmt * old ) override final {
 		if ( inCache( old ) ) return;
-		this->node = new ast::WhileStmt(
+		this->node = new ast::WhileDoStmt(
 			old->location,
 			GET_ACCEPT_1(condition, Expr),
 			GET_ACCEPT_1(body, Stmt),
+			GET_ACCEPT_1(else_, Stmt),
 			GET_ACCEPT_V(initialization, Stmt),
 			old->isDoWhile,
@@ -1923,4 +1926,5 @@
 			GET_ACCEPT_1(increment, Expr),
 			GET_ACCEPT_1(body, Stmt),
+			GET_ACCEPT_1(else_, Stmt),
 			GET_LABELS_V(old->labels)
 		);
Index: src/AST/Fwd.hpp
===================================================================
--- src/AST/Fwd.hpp	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/AST/Fwd.hpp	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Wed May  8 16:05:00 2019
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Mar 12 18:37:39 2021
-// Update Count     : 4
+// Last Modified On : Tue Feb  1 09:08:33 2022
+// Update Count     : 5
 //
 
@@ -44,5 +44,5 @@
 class DirectiveStmt;
 class IfStmt;
-class WhileStmt;
+class WhileDoStmt;
 class ForStmt;
 class SwitchStmt;
Index: src/AST/Node.cpp
===================================================================
--- src/AST/Node.cpp	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/AST/Node.cpp	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Thu May 16 14:16:00 2019
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Mar 12 18:25:06 2021
-// Update Count     : 2
+// Last Modified On : Tue Feb  1 09:09:39 2022
+// Update Count     : 3
 //
 
@@ -146,6 +146,6 @@
 template class ast::ptr_base< ast::IfStmt, ast::Node::ref_type::weak >;
 template class ast::ptr_base< ast::IfStmt, ast::Node::ref_type::strong >;
-template class ast::ptr_base< ast::WhileStmt, ast::Node::ref_type::weak >;
-template class ast::ptr_base< ast::WhileStmt, ast::Node::ref_type::strong >;
+template class ast::ptr_base< ast::WhileDoStmt, ast::Node::ref_type::weak >;
+template class ast::ptr_base< ast::WhileDoStmt, ast::Node::ref_type::strong >;
 template class ast::ptr_base< ast::ForStmt, ast::Node::ref_type::weak >;
 template class ast::ptr_base< ast::ForStmt, ast::Node::ref_type::strong >;
Index: src/AST/Pass.hpp
===================================================================
--- src/AST/Pass.hpp	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/AST/Pass.hpp	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -146,5 +146,5 @@
 	const ast::Stmt *             visit( const ast::DirectiveStmt        * ) override final;
 	const ast::Stmt *             visit( const ast::IfStmt               * ) override final;
-	const ast::Stmt *             visit( const ast::WhileStmt            * ) override final;
+	const ast::Stmt *             visit( const ast::WhileDoStmt          * ) override final;
 	const ast::Stmt *             visit( const ast::ForStmt              * ) override final;
 	const ast::Stmt *             visit( const ast::SwitchStmt           * ) override final;
Index: src/AST/Pass.impl.hpp
===================================================================
--- src/AST/Pass.impl.hpp	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/AST/Pass.impl.hpp	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -756,6 +756,6 @@
 		maybe_accept( node, &IfStmt::inits    );
 		maybe_accept( node, &IfStmt::cond     );
-		maybe_accept_as_compound( node, &IfStmt::thenPart );
-		maybe_accept_as_compound( node, &IfStmt::elsePart );
+		maybe_accept_as_compound( node, &IfStmt::then );
+		maybe_accept_as_compound( node, &IfStmt::else_ );
 	}
 
@@ -764,7 +764,7 @@
 
 //--------------------------------------------------------------------------
-// WhileStmt
-template< typename core_t >
-const ast::Stmt * ast::Pass< core_t >::visit( const ast::WhileStmt * node ) {
+// WhileDoStmt
+template< typename core_t >
+const ast::Stmt * ast::Pass< core_t >::visit( const ast::WhileDoStmt * node ) {
 	VISIT_START( node );
 
@@ -772,7 +772,7 @@
 		// while statements introduce a level of scope (for the initialization)
 		guard_symtab guard { *this };
-		maybe_accept( node, &WhileStmt::inits );
-		maybe_accept( node, &WhileStmt::cond  );
-		maybe_accept_as_compound( node, &WhileStmt::body  );
+		maybe_accept( node, &WhileDoStmt::inits );
+		maybe_accept( node, &WhileDoStmt::cond  );
+		maybe_accept_as_compound( node, &WhileDoStmt::body  );
 	}
 
Index: src/AST/Print.cpp
===================================================================
--- src/AST/Print.cpp	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/AST/Print.cpp	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -511,12 +511,12 @@
 		++indent;
 		os << indent;
-		safe_print( node->thenPart );
-		--indent;
-
-		if ( node->elsePart != 0 ) {
+		safe_print( node->then );
+		--indent;
+
+		if ( node->else_ != 0 ) {
 			os << indent << "... else:" << endl;
 			++indent;
 			os << indent;
-			node->elsePart->accept( *this );
+			node->else_->accept( *this );
 			--indent;
 		} // if
@@ -524,5 +524,5 @@
 	}
 
-	virtual const ast::Stmt * visit( const ast::WhileStmt * node ) override final {
+	virtual const ast::Stmt * visit( const ast::WhileDoStmt * node ) override final {
 		if ( node->isDoWhile ) { os << "Do-"; }
 		os << "While on condition:" << endl;
Index: src/AST/Stmt.hpp
===================================================================
--- src/AST/Stmt.hpp	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/AST/Stmt.hpp	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Wed May  8 13:00:00 2019
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Jan 31 22:38:53 2022
-// Update Count     : 12
+// Last Modified On : Tue Feb  1 17:44:46 2022
+// Update Count     : 24
 //
 
@@ -42,5 +42,5 @@
 		: ParseNode(loc), labels(std::move(labels)) {}
 
-	Stmt(const Stmt& o) : ParseNode(o), labels(o.labels) {}
+	Stmt(const Stmt & o) : ParseNode(o), labels(o.labels) {}
 
 	const Stmt * accept( Visitor & v ) const override = 0;
@@ -56,9 +56,9 @@
 
 	CompoundStmt(const CodeLocation & loc, std::list<ptr<Stmt>> && ks = {},
-				 std::vector<Label>&& labels = {} )
+				 std::vector<Label> && labels = {} )
 		: Stmt(loc, std::move(labels)), kids(std::move(ks)) {}
 
-	CompoundStmt( const CompoundStmt& o );
-	CompoundStmt( CompoundStmt&& o ) = default;
+	CompoundStmt( const CompoundStmt & o );
+	CompoundStmt( CompoundStmt && o ) = default;
 
 	void push_back( const Stmt * s ) { kids.emplace_back( s ); }
@@ -88,5 +88,5 @@
 	ptr<Expr> expr;
 
-	ExprStmt( const CodeLocation& loc, const Expr* e, std::vector<Label>&& labels = {} )
+	ExprStmt( const CodeLocation & loc, const Expr* e, std::vector<Label> && labels = {} )
 		: Stmt(loc, std::move(labels)), expr(e) {}
 
@@ -139,12 +139,12 @@
   public:
 	ptr<Expr> cond;
-	ptr<Stmt> thenPart;
-	ptr<Stmt> elsePart;
+	ptr<Stmt> then;
+	ptr<Stmt> else_;
 	std::vector<ptr<Stmt>> inits;
 
-	IfStmt( const CodeLocation & loc, const Expr * cond, const Stmt * thenPart,
-			const Stmt * elsePart = nullptr, std::vector<ptr<Stmt>> && inits = {},
+	IfStmt( const CodeLocation & loc, const Expr * cond, const Stmt * then,
+			const Stmt * else_ = nullptr, std::vector<ptr<Stmt>> && inits = {},
 			std::vector<Label> && labels = {} )
-		: Stmt(loc, std::move(labels)), cond(cond), thenPart(thenPart), elsePart(elsePart),
+		: Stmt(loc, std::move(labels)), cond(cond), then(then), else_(else_),
 		  inits(std::move(inits)) {}
 
@@ -191,19 +191,23 @@
 
 // While loop: while (...) ... else ... or do ... while (...) else ...;
-class WhileStmt final : public Stmt {
+class WhileDoStmt final : public Stmt {
   public:
 	ptr<Expr> cond;
 	ptr<Stmt> body;
-	ptr<Stmt> elsePart;
+	ptr<Stmt> else_;
 	std::vector<ptr<Stmt>> inits;
 	bool isDoWhile;
 
-	WhileStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body,
+	WhileDoStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body,
 			   std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, std::vector<Label> && labels = {} )
-		: Stmt(loc, std::move(labels)), cond(cond), body(body), inits(std::move(inits)), isDoWhile(isDoWhile) {}
-
-	const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
-  private:
-	WhileStmt * clone() const override { return new WhileStmt{ *this }; }
+		: Stmt(loc, std::move(labels)), cond(cond), body(body), else_(nullptr), inits(std::move(inits)), isDoWhile(isDoWhile) {}
+
+	WhileDoStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body, const Stmt * else_,
+			   std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, std::vector<Label> && labels = {} )
+		: Stmt(loc, std::move(labels)), cond(cond), body(body), else_(else_), inits(std::move(inits)), isDoWhile(isDoWhile) {}
+
+	const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
+  private:
+	WhileDoStmt * clone() const override { return new WhileDoStmt{ *this }; }
 	MUTATE_FRIEND
 };
@@ -216,9 +220,13 @@
 	ptr<Expr> inc;
 	ptr<Stmt> body;
-	ptr<Stmt> elsePart;
+	ptr<Stmt> else_;
 
 	ForStmt( const CodeLocation & loc, std::vector<ptr<Stmt>> && inits, const Expr * cond,
-			 const Expr * inc, const Stmt * body, std::vector<Label> && labels = {} )
-		: Stmt(loc, std::move(labels)), inits(std::move(inits)), cond(cond), inc(inc), body(body) {}
+			 const Expr * inc, const Stmt * body, std::vector<Label> && label = {} )
+		: Stmt(loc, std::move(label)), inits(std::move(inits)), cond(cond), inc(inc), body(body), else_(nullptr) {}
+
+	ForStmt( const CodeLocation & loc, std::vector<ptr<Stmt>> && inits, const Expr * cond,
+			 const Expr * inc, const Stmt * body, const Stmt * else_, std::vector<Label> && labels = {} )
+		: Stmt(loc, std::move(labels)), inits(std::move(inits)), cond(cond), inc(inc), body(body), else_(else_) {}
 
 	const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
Index: src/AST/Visitor.hpp
===================================================================
--- src/AST/Visitor.hpp	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/AST/Visitor.hpp	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Thr May 9 15:28:00 2019
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Mar 12 18:25:07 2021
-// Update Count     : 1
+// Last Modified On : Tue Feb  1 09:09:34 2022
+// Update Count     : 2
 //
 
@@ -38,5 +38,5 @@
     virtual const ast::Stmt *             visit( const ast::DirectiveStmt        * ) = 0;
     virtual const ast::Stmt *             visit( const ast::IfStmt               * ) = 0;
-    virtual const ast::Stmt *             visit( const ast::WhileStmt            * ) = 0;
+    virtual const ast::Stmt *             visit( const ast::WhileDoStmt          * ) = 0;
     virtual const ast::Stmt *             visit( const ast::ForStmt              * ) = 0;
     virtual const ast::Stmt *             visit( const ast::SwitchStmt           * ) = 0;
Index: src/CodeGen/CodeGenerator.cc
===================================================================
--- src/CodeGen/CodeGenerator.cc	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/CodeGen/CodeGenerator.cc	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Mar 12 19:00:42 2021
-// Update Count     : 536
+// Last Modified On : Tue Feb  1 16:29:25 2022
+// Update Count     : 540
 //
 #include "CodeGenerator.h"
@@ -42,5 +42,5 @@
 	bool wantSpacing( Statement * stmt) {
 		return dynamic_cast< IfStmt * >( stmt ) || dynamic_cast< CompoundStmt * >( stmt ) ||
-			dynamic_cast< WhileStmt * >( stmt ) || dynamic_cast< ForStmt * >( stmt ) || dynamic_cast< SwitchStmt *>( stmt );
+			dynamic_cast< WhileDoStmt * >( stmt ) || dynamic_cast< ForStmt * >( stmt ) || dynamic_cast< SwitchStmt *>( stmt );
 	}
 
@@ -955,9 +955,9 @@
 		output << " ) ";
 
-		ifStmt->get_thenPart()->accept( *visitor );
-
-		if ( ifStmt->get_elsePart() != 0) {
+		ifStmt->get_then()->accept( *visitor );
+
+		if ( ifStmt->get_else() != 0) {
 			output << " else ";
-			ifStmt->get_elsePart()->accept( *visitor );
+			ifStmt->get_else()->accept( *visitor );
 		} // if
 	}
@@ -1125,22 +1125,22 @@
 	}
 
-	void CodeGenerator::postvisit( WhileStmt * whileStmt ) {
-		if ( whileStmt->get_isDoWhile() ) {
+	void CodeGenerator::postvisit( WhileDoStmt * whileDoStmt ) {
+		if ( whileDoStmt->get_isDoWhile() ) {
 			output << "do";
 		} else {
 			output << "while (";
-			whileStmt->get_condition()->accept( *visitor );
+			whileDoStmt->get_condition()->accept( *visitor );
 			output << ")";
 		} // if
 		output << " ";
 
-		output << CodeGenerator::printLabels( whileStmt->get_body()->get_labels() );
-		whileStmt->get_body()->accept( *visitor );
+		output << CodeGenerator::printLabels( whileDoStmt->get_body()->get_labels() );
+		whileDoStmt->get_body()->accept( *visitor );
 
 		output << indent;
 
-		if ( whileStmt->get_isDoWhile() ) {
+		if ( whileDoStmt->get_isDoWhile() ) {
 			output << " while (";
-			whileStmt->get_condition()->accept( *visitor );
+			whileDoStmt->get_condition()->accept( *visitor );
 			output << ");";
 		} // if
Index: src/CodeGen/CodeGenerator.h
===================================================================
--- src/CodeGen/CodeGenerator.h	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/CodeGen/CodeGenerator.h	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Mar 12 18:35:38 2021
-// Update Count     : 63
+// Last Modified On : Tue Feb  1 09:23:21 2022
+// Update Count     : 64
 //
 
@@ -116,5 +116,5 @@
 		void postvisit( WaitForStmt * );
 		void postvisit( WithStmt * );
-		void postvisit( WhileStmt * );
+		void postvisit( WhileDoStmt * );
 		void postvisit( ForStmt * );
 		void postvisit( NullStmt * );
Index: src/Common/CodeLocationTools.cpp
===================================================================
--- src/Common/CodeLocationTools.cpp	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/Common/CodeLocationTools.cpp	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Fri Dec  4 15:42:00 2020
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Mar 12 18:35:37 2021
-// Update Count     : 2
+// Last Modified On : Tue Feb  1 09:14:39 2022
+// Update Count     : 3
 //
 
@@ -109,5 +109,5 @@
     macro(DirectiveStmt, Stmt) \
     macro(IfStmt, Stmt) \
-    macro(WhileStmt, Stmt) \
+    macro(WhileDoStmt, Stmt) \
     macro(ForStmt, Stmt) \
     macro(SwitchStmt, Stmt) \
Index: src/Common/PassVisitor.h
===================================================================
--- src/Common/PassVisitor.h	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/Common/PassVisitor.h	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -92,6 +92,6 @@
 	virtual void visit( IfStmt * ifStmt ) override final;
 	virtual void visit( const IfStmt * ifStmt ) override final;
-	virtual void visit( WhileStmt * whileStmt ) override final;
-	virtual void visit( const WhileStmt * whileStmt ) override final;
+	virtual void visit( WhileDoStmt * whileDoStmt ) override final;
+	virtual void visit( const WhileDoStmt * whileDoStmt ) override final;
 	virtual void visit( ForStmt * forStmt ) override final;
 	virtual void visit( const ForStmt * forStmt ) override final;
@@ -277,5 +277,5 @@
 	virtual Statement * mutate( DirectiveStmt * dirStmt ) override final;
 	virtual Statement * mutate( IfStmt * ifStmt ) override final;
-	virtual Statement * mutate( WhileStmt * whileStmt ) override final;
+	virtual Statement * mutate( WhileDoStmt * whileDoStmt ) override final;
 	virtual Statement * mutate( ForStmt * forStmt ) override final;
 	virtual Statement * mutate( SwitchStmt * switchStmt ) override final;
Index: src/Common/PassVisitor.impl.h
===================================================================
--- src/Common/PassVisitor.impl.h	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/Common/PassVisitor.impl.h	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -1189,6 +1189,6 @@
 		maybeAccept_impl( node->initialization, *this );
 		visitExpression ( node->condition );
-		node->thenPart = visitStatement( node->thenPart );
-		node->elsePart = visitStatement( node->elsePart );
+		node->then = visitStatement( node->then );
+		node->else_ = visitStatement( node->else_ );
 	}
 	VISIT_END( node );
@@ -1203,6 +1203,6 @@
 		maybeAccept_impl( node->initialization, *this );
 		visitExpression ( node->condition );
-		visitStatement  ( node->thenPart );
-		visitStatement  ( node->elsePart );
+		visitStatement  ( node->then );
+		visitStatement  ( node->else_ );
 	}
 	VISIT_END( node );
@@ -1217,6 +1217,6 @@
 		maybeMutate_impl( node->initialization, *this );
 		node->condition = mutateExpression( node->condition );
-		node->thenPart  = mutateStatement ( node->thenPart  );
-		node->elsePart  = mutateStatement ( node->elsePart  );
+		node->then  = mutateStatement ( node->then  );
+		node->else_  = mutateStatement ( node->else_  );
 	}
 	MUTATE_END( Statement, node );
@@ -1224,7 +1224,7 @@
 
 //--------------------------------------------------------------------------
-// WhileStmt
-template< typename pass_type >
-void PassVisitor< pass_type >::visit( WhileStmt * node ) {
+// WhileDoStmt
+template< typename pass_type >
+void PassVisitor< pass_type >::visit( WhileDoStmt * node ) {
 	VISIT_START( node );
 
@@ -1241,5 +1241,5 @@
 
 template< typename pass_type >
-void PassVisitor< pass_type >::visit( const WhileStmt * node ) {
+void PassVisitor< pass_type >::visit( const WhileDoStmt * node ) {
 	VISIT_START( node );
 
@@ -1256,5 +1256,5 @@
 
 template< typename pass_type >
-Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) {
+Statement * PassVisitor< pass_type >::mutate( WhileDoStmt * node ) {
 	MUTATE_START( node );
 
Index: src/ControlStruct/ForExprMutator.cc
===================================================================
--- src/ControlStruct/ForExprMutator.cc	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/ControlStruct/ForExprMutator.cc	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Mar 11 22:26:52 2019
-// Update Count     : 14
+// Last Modified On : Tue Feb  1 09:26:12 2022
+// Update Count     : 16
 //
 
@@ -45,6 +45,6 @@
 		return hoist( forStmt, forStmt->initialization );
 	}
-	Statement * ForExprMutator::postmutate( WhileStmt * whileStmt ) {
-		return hoist( whileStmt, whileStmt->initialization );
+	Statement * ForExprMutator::postmutate( WhileDoStmt * whileDoStmt ) {
+		return hoist( whileDoStmt, whileDoStmt->initialization );
 	}
 } // namespace ControlStruct
Index: src/ControlStruct/ForExprMutator.h
===================================================================
--- src/ControlStruct/ForExprMutator.h	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/ControlStruct/ForExprMutator.h	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sun Jan 30 09:14:46 2022
-// Update Count     : 6
+// Last Modified On : Tue Feb  1 09:18:50 2022
+// Update Count     : 7
 //
 
@@ -18,5 +18,5 @@
 class IfStmt;
 class ForStmt;
-class WhileStmt;
+class WhileDoStmt;
 class Statement;
 
@@ -26,5 +26,5 @@
 		Statement * postmutate( IfStmt * );
 		Statement * postmutate( ForStmt * );
-		Statement * postmutate( WhileStmt * );
+		Statement * postmutate( WhileDoStmt * );
 	};
 } // namespace ControlStruct
Index: src/ControlStruct/HoistControlDecls.cpp
===================================================================
--- src/ControlStruct/HoistControlDecls.cpp	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/ControlStruct/HoistControlDecls.cpp	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Fri Dec  3 15:34:00 2021
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Jan 31 18:52:35 2022
-// Update Count     : 23
+// Last Modified On : Tue Feb  1 18:59:47 2022
+// Update Count     : 25
 //
 
@@ -35,6 +35,5 @@
 
 	CompoundStmt * block = new CompoundStmt( stmt->location ); // create empty compound statement
-	//    {
-	//    }
+	//    {}
 
 	for ( const Stmt * next : stmt->inits ) {			// link conditional declarations into compound
@@ -69,6 +68,6 @@
 		return hoist<ForStmt>( stmt );
 	}
-	const Stmt * postvisit( const WhileStmt * stmt ) {
-		return hoist<WhileStmt>( stmt );
+	const Stmt * postvisit( const WhileDoStmt * stmt ) {
+		return hoist<WhileDoStmt>( stmt );
 	}
 };
Index: src/ControlStruct/LabelFixer.cc
===================================================================
--- src/ControlStruct/LabelFixer.cc	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/ControlStruct/LabelFixer.cc	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Jan 31 22:28:31 2022
-// Update Count     : 161
+// Last Modified On : Tue Feb  1 09:12:09 2022
+// Update Count     : 162
 //
 
@@ -29,5 +29,5 @@
 bool LabelFixer::Entry::insideLoop() {
 	return ( dynamic_cast< ForStmt * > ( definition ) ||
-		dynamic_cast< WhileStmt * > ( definition )  );
+		dynamic_cast< WhileDoStmt * > ( definition )  );
 }
 
Index: src/ControlStruct/LabelGeneratorNew.cpp
===================================================================
--- src/ControlStruct/LabelGeneratorNew.cpp	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/ControlStruct/LabelGeneratorNew.cpp	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Jan 31 18:51:10 2022
-// Update Count     : 71
+// Last Modified On : Wed Feb  2 09:11:17 2022
+// Update Count     : 72
 //
 
@@ -28,15 +28,15 @@
 	static int current = 0;
 
-	assert( ( (void)"CFA internal error: parameter statement cannot be null pointer", stmt ) );
+	assertf( stmt, "CFA internal error: parameter statement cannot be null pointer" );
 
 	enum { size = 128 };
 	char buf[size];										// space to build label
 	int len = snprintf( buf, size, "__L%d__%s", current++, suffix.c_str() );
-	assert( ( (void)"CFA Internal error: buffer overflow creating label", len < size ) );
+	assertf( len < size, "CFA Internal error: buffer overflow creating label" );
 
 	// What does this do?
 	if ( ! stmt->labels.empty() ) {
 		len = snprintf( buf + len, size - len, "_%s__", stmt->labels.front().name.c_str() );
-		assert( ( (void)"CFA Internal error: buffer overflow creating label", len < size - len ) );
+		assertf( len < size - len, "CFA Internal error: buffer overflow creating label" );
 	} // if
 
Index: src/ControlStruct/MLEMutator.cc
===================================================================
--- src/ControlStruct/MLEMutator.cc	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/ControlStruct/MLEMutator.cc	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -9,7 +9,7 @@
 // Author           : Rodolfo G. Esteves
 // Created On       : Mon May 18 07:44:20 2015
-// Last Modified By : Andrew Beach
-// Last Modified On : Wed Jan 22 11:50:00 2020
-// Update Count     : 223
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Tue Feb  1 09:26:28 2022
+// Update Count     : 225
 //
 
@@ -39,5 +39,5 @@
 	namespace {
 		bool isLoop( const MultiLevelExitMutator::Entry & e ) {
-			return dynamic_cast< WhileStmt * >( e.get_controlStructure() )
+			return dynamic_cast< WhileDoStmt * >( e.get_controlStructure() )
 				|| dynamic_cast< ForStmt * >( e.get_controlStructure() );
 		}
@@ -295,6 +295,6 @@
 	}
 
-	void MultiLevelExitMutator::premutate( WhileStmt * whileStmt ) {
-		return prehandleLoopStmt( whileStmt );
+	void MultiLevelExitMutator::premutate( WhileDoStmt * whileDoStmt ) {
+		return prehandleLoopStmt( whileDoStmt );
 	}
 
@@ -303,6 +303,6 @@
 	}
 
-	Statement * MultiLevelExitMutator::postmutate( WhileStmt * whileStmt ) {
-		return posthandleLoopStmt( whileStmt );
+	Statement * MultiLevelExitMutator::postmutate( WhileDoStmt * whileDoStmt ) {
+		return posthandleLoopStmt( whileDoStmt );
 	}
 
Index: src/ControlStruct/MLEMutator.h
===================================================================
--- src/ControlStruct/MLEMutator.h	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/ControlStruct/MLEMutator.h	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -9,7 +9,7 @@
 // Author           : Rodolfo G. Esteves
 // Created On       : Mon May 18 07:44:20 2015
-// Last Modified By : Andrew Beach
-// Last Modified On : Wed Jan 22 11:50:00 2020
-// Update Count     : 48
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Tue Feb  1 09:27:24 2022
+// Update Count     : 50
 //
 
@@ -42,6 +42,6 @@
 		void premutate( CompoundStmt *cmpndStmt );
 		Statement * postmutate( BranchStmt *branchStmt ) throw ( SemanticErrorException );
-		void premutate( WhileStmt *whileStmt );
-		Statement * postmutate( WhileStmt *whileStmt );
+		void premutate( WhileDoStmt *whileDoStmt );
+		Statement * postmutate( WhileDoStmt *whileDoStmt );
 		void premutate( ForStmt *forStmt );
 		Statement * postmutate( ForStmt *forStmt );
@@ -67,5 +67,5 @@
 				stmt( stmt ), breakExit( breakExit ), contExit( contExit ) {}
 
-			explicit Entry( WhileStmt *stmt, Label breakExit, Label contExit ) :
+			explicit Entry( WhileDoStmt *stmt, Label breakExit, Label contExit ) :
 				stmt( stmt ), breakExit( breakExit ), contExit( contExit ) {}
 
Index: src/ControlStruct/MultiLevelExit.cpp
===================================================================
--- src/ControlStruct/MultiLevelExit.cpp	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/ControlStruct/MultiLevelExit.cpp	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Mon Nov  1 13:48:00 2021
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Jan 31 22:35:08 2022
-// Update Count     : 28
+// Last Modified On : Tue Feb  1 18:48:47 2022
+// Update Count     : 29
 //
 
@@ -40,5 +40,5 @@
 
 	enum Kind {
-		ForStmtK, WhileStmtK, CompoundStmtK, IfStmtK, CaseStmtK, SwitchStmtK, TryStmtK
+		ForStmtK, WhileDoStmtK, CompoundStmtK, IfStmtK, CaseStmtK, SwitchStmtK, TryStmtK
 	} kind;
 
@@ -53,6 +53,6 @@
 	Entry( const ForStmt * stmt, Label breakExit, Label contExit ) :
 		stmt( stmt ), firstTarget( breakExit ), secondTarget( contExit ), kind( ForStmtK ) {}
-	Entry( const WhileStmt * stmt, Label breakExit, Label contExit ) :
-		stmt( stmt ), firstTarget( breakExit ), secondTarget( contExit ), kind( WhileStmtK ) {}
+	Entry( const WhileDoStmt * stmt, Label breakExit, Label contExit ) :
+		stmt( stmt ), firstTarget( breakExit ), secondTarget( contExit ), kind( WhileDoStmtK ) {}
 	Entry( const CompoundStmt *stmt, Label breakExit ) :
 		stmt( stmt ), firstTarget( breakExit ), secondTarget(), kind( CompoundStmtK ) {}
@@ -66,5 +66,5 @@
 		stmt( stmt ), firstTarget( breakExit ), secondTarget(), kind( TryStmtK ) {}
 
-	bool isContTarget() const { return kind <= WhileStmtK; }
+	bool isContTarget() const { return kind <= WhileDoStmtK; }
 	bool isBreakTarget() const { return kind != CaseStmtK; }
 	bool isFallTarget() const { return kind == CaseStmtK; }
@@ -72,5 +72,5 @@
 
 	// These routines set a target as being "used" by a BranchStmt
-	Label useContExit() { assert( kind <= WhileStmtK ); return useTarget(secondTarget); }
+	Label useContExit() { assert( kind <= WhileDoStmtK ); return useTarget(secondTarget); }
 	Label useBreakExit() { assert( kind != CaseStmtK ); return useTarget(firstTarget); }
 	Label useFallExit() { assert( kind == CaseStmtK );  return useTarget(firstTarget); }
@@ -78,5 +78,5 @@
 
 	// These routines check if a specific label for a statement is used by a BranchStmt
-	bool isContUsed() const { assert( kind <= WhileStmtK ); return secondTarget.used; }
+	bool isContUsed() const { assert( kind <= WhileDoStmtK ); return secondTarget.used; }
 	bool isBreakUsed() const { assert( kind != CaseStmtK ); return firstTarget.used; }
 	bool isFallUsed() const { assert( kind == CaseStmtK ); return firstTarget.used; }
@@ -112,6 +112,6 @@
 	const CompoundStmt * previsit( const CompoundStmt * );
 	const BranchStmt * postvisit( const BranchStmt * );
-	void previsit( const WhileStmt * );
-	const WhileStmt * postvisit( const WhileStmt * );
+	void previsit( const WhileDoStmt * );
+	const WhileDoStmt * postvisit( const WhileDoStmt * );
 	void previsit( const ForStmt * );
 	const ForStmt * postvisit( const ForStmt * );
@@ -342,9 +342,9 @@
 }
 
-void MultiLevelExitCore::previsit( const WhileStmt * stmt ) {
+void MultiLevelExitCore::previsit( const WhileDoStmt * stmt ) {
 	return prehandleLoopStmt( stmt );
 }
 
-const WhileStmt * MultiLevelExitCore::postvisit( const WhileStmt * stmt ) {
+const WhileDoStmt * MultiLevelExitCore::postvisit( const WhileDoStmt * stmt ) {
 	return posthandleLoopStmt( stmt );
 }
Index: src/Parser/ParseNode.h
===================================================================
--- src/Parser/ParseNode.h	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/Parser/ParseNode.h	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Sat May 16 13:28:16 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sat Jan 29 09:45:56 2022
-// Update Count     : 901
+// Last Modified On : Wed Feb  2 09:15:49 2022
+// Update Count     : 905
 //
 
@@ -410,11 +410,11 @@
 
 Expression * build_if_control( CondCtl * ctl, std::list< Statement * > & init );
-Statement * build_if( CondCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );
+Statement * build_if( CondCtl * ctl, StatementNode * then, StatementNode * else_ );
 Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt );
 Statement * build_case( ExpressionNode * ctl );
 Statement * build_default();
-Statement * build_while( CondCtl * ctl, StatementNode * stmt );
-Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt );
-Statement * build_for( ForCtrl * forctl, StatementNode * stmt );
+Statement * build_while( CondCtl * ctl, StatementNode * stmt, StatementNode * else_ = nullptr );
+Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt, StatementNode * else_ = nullptr );
+Statement * build_for( ForCtrl * forctl, StatementNode * stmt, StatementNode * else_ = nullptr );
 Statement * build_branch( BranchStmt::Type kind );
 Statement * build_branch( std::string * identifier, BranchStmt::Type kind );
@@ -424,6 +424,6 @@
 Statement * build_resume( ExpressionNode * ctl );
 Statement * build_resume_at( ExpressionNode * ctl , ExpressionNode * target );
-Statement * build_try( StatementNode * try_stmt, StatementNode * catch_stmt, StatementNode * finally_stmt );
-Statement * build_catch( CatchStmt::Kind kind, DeclarationNode *decl, ExpressionNode *cond, StatementNode *body );
+Statement * build_try( StatementNode * try_, StatementNode * catch_, StatementNode * finally_ );
+Statement * build_catch( CatchStmt::Kind kind, DeclarationNode * decl, ExpressionNode * cond, StatementNode * body );
 Statement * build_finally( StatementNode * stmt );
 Statement * build_compound( StatementNode * first );
Index: src/Parser/StatementNode.cc
===================================================================
--- src/Parser/StatementNode.cc	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/Parser/StatementNode.cc	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -5,11 +5,12 @@
 // file "LICENCE" distributed with Cforall.
 //
-// StatementNode.cc --
+// StatementNode.cc -- Transform from parse data-structures to AST data-structures, usually deleting the parse
+//     data-structure after the transformation.
 //
 // Author           : Rodolfo G. Esteves
 // Created On       : Sat May 16 14:59:41 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sat Jan 29 09:45:51 2022
-// Update Count     : 384
+// Last Modified On : Wed Feb  2 12:27:58 2022
+// Update Count     : 424
 //
 
@@ -63,5 +64,5 @@
 	// convert from StatementNode list to Statement list
 	StatementNode * node = dynamic_cast< StatementNode * >(prev);
-	std::list< Statement * > stmts;
+	list< Statement * > stmts;
 	buildMoveList( stmt, stmts );
 	// splice any new Statements to end of current Statements
@@ -78,5 +79,5 @@
 } // build_expr
 
-Expression * build_if_control( CondCtl * ctl, std::list< Statement * > & init ) {
+Expression * build_if_control( CondCtl * ctl, list< Statement * > & init ) {
 	if ( ctl->init != 0 ) {
 		buildMoveList( ctl->init, init );
@@ -100,28 +101,29 @@
 } // build_if_control
 
-Statement * build_if( CondCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ) {
-	Statement * thenb, * elseb = nullptr;
-	std::list< Statement * > branches;
-	buildMoveList< Statement, StatementNode >( then_stmt, branches );
-	assert( branches.size() == 1 );
-	thenb = branches.front();
-
-	if ( else_stmt ) {
-		std::list< Statement * > branches;
-		buildMoveList< Statement, StatementNode >( else_stmt, branches );
-		assert( branches.size() == 1 );
-		elseb = branches.front();
-	} // if
-
-	std::list< Statement * > init;
-	Expression * cond = build_if_control( ctl, init );
-	return new IfStmt( cond, thenb, elseb, init );
+Statement * build_if( CondCtl * ctl, StatementNode * then, StatementNode * else_ ) {
+	list< Statement * > astinit;						// maybe empty
+	Expression * astcond = build_if_control( ctl, astinit ); // ctl deleted, cond/init set
+
+	Statement * astthen, * astelse = nullptr;
+	list< Statement * > aststmt;
+	buildMoveList< Statement, StatementNode >( then, aststmt );
+	assert( aststmt.size() == 1 );
+	astthen = aststmt.front();
+
+	if ( else_ ) {
+		list< Statement * > aststmt;
+		buildMoveList< Statement, StatementNode >( else_, aststmt );
+		assert( aststmt.size() == 1 );
+		astelse = aststmt.front();
+	} // if
+
+	return new IfStmt( astcond, astthen, astelse, astinit );
 } // build_if
 
 Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt ) {
-	std::list< Statement * > branches;
-	buildMoveList< Statement, StatementNode >( stmt, branches );
-	if ( ! isSwitch ) {										// choose statement
-		for ( Statement * stmt : branches ) {
+	list< Statement * > aststmt;
+	buildMoveList< Statement, StatementNode >( stmt, aststmt );
+	if ( ! isSwitch ) {									// choose statement
+		for ( Statement * stmt : aststmt ) {
 			CaseStmt * caseStmt = strict_dynamic_cast< CaseStmt * >( stmt );
 			if ( ! caseStmt->stmts.empty() ) {			// code after "case" => end of case list
@@ -131,57 +133,61 @@
 		} // for
 	} // if
-	// branches.size() == 0 for switch (...) {}, i.e., no declaration or statements
-	return new SwitchStmt( maybeMoveBuild< Expression >(ctl), branches );
+	// aststmt.size() == 0 for switch (...) {}, i.e., no declaration or statements
+	return new SwitchStmt( maybeMoveBuild< Expression >(ctl), aststmt );
 } // build_switch
 
 Statement * build_case( ExpressionNode * ctl ) {
-	std::list< Statement * > branches;
-	return new CaseStmt( maybeMoveBuild< Expression >(ctl), branches );
+	return new CaseStmt( maybeMoveBuild< Expression >(ctl), {} ); // no init
 } // build_case
 
 Statement * build_default() {
-	std::list< Statement * > branches;
-	return new CaseStmt( nullptr, branches, true );
+	return new CaseStmt( nullptr, {}, true );			// no init
 } // build_default
 
-Statement * build_while( CondCtl * ctl, StatementNode * stmt ) {
-	std::list< Statement * > branches;
-	buildMoveList< Statement, StatementNode >( stmt, branches );
-	assert( branches.size() == 1 );
-
-	std::list< Statement * > init;
-	Expression * cond = build_if_control( ctl, init );
-	return new WhileStmt( cond, branches.front(), init, false );
+Statement * build_while( CondCtl * ctl, StatementNode * stmt, StatementNode * else_ ) {
+	list< Statement * > astinit;						// maybe empty
+	Expression * astcond = build_if_control( ctl, astinit ); // ctl deleted, cond/init set
+
+	list< Statement * > aststmt;						// loop body, compound created if empty
+	buildMoveList< Statement, StatementNode >( stmt, aststmt );
+	assert( aststmt.size() == 1 );
+
+	list< Statement * > astelse;						// else clause, maybe empty
+	buildMoveList< Statement, StatementNode >( else_, astelse );
+
+	return new WhileDoStmt( astcond, aststmt.front(), astelse.front(), astinit, false );
 } // build_while
 
-Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt ) {
-	std::list< Statement * > branches;
-	buildMoveList< Statement, StatementNode >( stmt, branches );
-	assert( branches.size() == 1 );
-
-	std::list< Statement * > init;
-	return new WhileStmt( notZeroExpr( maybeMoveBuild< Expression >(ctl) ), branches.front(), init, true );
+Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt, StatementNode * else_ ) {
+	list< Statement * > aststmt;						// loop body, compound created if empty
+	buildMoveList< Statement, StatementNode >( stmt, aststmt );
+	assert( aststmt.size() == 1 );						// compound created if empty
+
+	list< Statement * > astelse;						// else clause, maybe empty
+	buildMoveList< Statement, StatementNode >( else_, astelse );
+
+	// do-while cannot have declarations in the contitional, so init is always empty
+	return new WhileDoStmt( notZeroExpr( maybeMoveBuild< Expression >(ctl) ), aststmt.front(), astelse.front(), {}, true );
 } // build_do_while
 
-Statement * build_for( ForCtrl * forctl, StatementNode * stmt ) {
-	std::list< Statement * > branches;
-	buildMoveList< Statement, StatementNode >( stmt, branches );
-	assert( branches.size() == 1 );
-
-	std::list< Statement * > init;
-	if ( forctl->init != 0 ) {
-		buildMoveList( forctl->init, init );
-	} // if
-
-	Expression * cond = 0;
-	if ( forctl->condition != 0 )
-		cond = notZeroExpr( maybeMoveBuild< Expression >(forctl->condition) );
-
-	Expression * incr = 0;
-	if ( forctl->change != 0 )
-		incr = maybeMoveBuild< Expression >(forctl->change);
-
+Statement * build_for( ForCtrl * forctl, StatementNode * stmt, StatementNode * else_ ) {
+	list< Statement * > astinit;						// maybe empty
+	buildMoveList( forctl->init, astinit );
+
+	Expression * astcond = nullptr;						// maybe empty
+	astcond = notZeroExpr( maybeMoveBuild< Expression >(forctl->condition) );
+
+	Expression * astincr = nullptr;						// maybe empty
+	astincr = maybeMoveBuild< Expression >(forctl->change);
 	delete forctl;
-	return new ForStmt( init, cond, incr, branches.front() );
+
+	list< Statement * > aststmt;						// loop body, compound created if empty
+	buildMoveList< Statement, StatementNode >( stmt, aststmt );
+	assert( aststmt.size() == 1 );
+
+	list< Statement * > astelse;						// else clause, maybe empty
+	buildMoveList< Statement, StatementNode >( else_, astelse );
+
+	return new ForStmt( astinit, astcond, astincr, aststmt.front(), astelse.front() );
 } // build_for
 
@@ -191,5 +197,5 @@
 } // build_branch
 
-Statement * build_branch( std::string * identifier, BranchStmt::Type kind ) {
+Statement * build_branch( string * identifier, BranchStmt::Type kind ) {
 	Statement * ret = new BranchStmt( * identifier, kind );
 	delete identifier; 									// allocated by lexer
@@ -202,5 +208,5 @@
 
 Statement * build_return( ExpressionNode * ctl ) {
-	std::list< Expression * > exps;
+	list< Expression * > exps;
 	buildMoveList( ctl, exps );
 	return new ReturnStmt( exps.size() > 0 ? exps.back() : nullptr );
@@ -208,14 +214,14 @@
 
 Statement * build_throw( ExpressionNode * ctl ) {
-	std::list< Expression * > exps;
+	list< Expression * > exps;
 	buildMoveList( ctl, exps );
-	assertf( exps.size() < 2, "This means we are leaking memory");
+	assertf( exps.size() < 2, "CFA internal error: leaking memory" );
 	return new ThrowStmt( ThrowStmt::Terminate, !exps.empty() ? exps.back() : nullptr );
 } // build_throw
 
 Statement * build_resume( ExpressionNode * ctl ) {
-	std::list< Expression * > exps;
+	list< Expression * > exps;
 	buildMoveList( ctl, exps );
-	assertf( exps.size() < 2, "This means we are leaking memory");
+	assertf( exps.size() < 2, "CFA internal error: leaking memory" );
 	return new ThrowStmt( ThrowStmt::Resume, !exps.empty() ? exps.back() : nullptr );
 } // build_resume
@@ -227,24 +233,24 @@
 } // build_resume_at
 
-Statement * build_try( StatementNode * try_stmt, StatementNode * catch_stmt, StatementNode * finally_stmt ) {
-	std::list< CatchStmt * > branches;
-	buildMoveList< CatchStmt, StatementNode >( catch_stmt, branches );
-	CompoundStmt * tryBlock = strict_dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_stmt));
-	FinallyStmt * finallyBlock = dynamic_cast< FinallyStmt * >(maybeMoveBuild< Statement >(finally_stmt) );
-	return new TryStmt( tryBlock, branches, finallyBlock );
+Statement * build_try( StatementNode * try_, StatementNode * catch_, StatementNode * finally_ ) {
+	list< CatchStmt * > aststmt;
+	buildMoveList< CatchStmt, StatementNode >( catch_, aststmt );
+	CompoundStmt * tryBlock = strict_dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_));
+	FinallyStmt * finallyBlock = dynamic_cast< FinallyStmt * >(maybeMoveBuild< Statement >(finally_) );
+	return new TryStmt( tryBlock, aststmt, finallyBlock );
 } // build_try
 
 Statement * build_catch( CatchStmt::Kind kind, DeclarationNode * decl, ExpressionNode * cond, StatementNode * body ) {
-	std::list< Statement * > branches;
-	buildMoveList< Statement, StatementNode >( body, branches );
-	assert( branches.size() == 1 );
-	return new CatchStmt( kind, maybeMoveBuild< Declaration >(decl), maybeMoveBuild< Expression >(cond), branches.front() );
+	list< Statement * > aststmt;
+	buildMoveList< Statement, StatementNode >( body, aststmt );
+	assert( aststmt.size() == 1 );
+	return new CatchStmt( kind, maybeMoveBuild< Declaration >(decl), maybeMoveBuild< Expression >(cond), aststmt.front() );
 } // build_catch
 
 Statement * build_finally( StatementNode * stmt ) {
-	std::list< Statement * > branches;
-	buildMoveList< Statement, StatementNode >( stmt, branches );
-	assert( branches.size() == 1 );
-	return new FinallyStmt( dynamic_cast< CompoundStmt * >( branches.front() ) );
+	list< Statement * > aststmt;
+	buildMoveList< Statement, StatementNode >( stmt, aststmt );
+	assert( aststmt.size() == 1 );
+	return new FinallyStmt( dynamic_cast< CompoundStmt * >( aststmt.front() ) );
 } // build_finally
 
@@ -254,5 +260,5 @@
 	node->type = type;
 
-	std::list< Statement * > stmts;
+	list< Statement * > stmts;
 	buildMoveList< Statement, StatementNode >( then, stmts );
 	if(!stmts.empty()) {
@@ -319,5 +325,5 @@
 } // build_waitfor_timeout
 
-WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when,  StatementNode * else_stmt, ExpressionNode * else_when ) {
+WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when,  StatementNode * else_, ExpressionNode * else_when ) {
 	auto node = new WaitForStmt();
 
@@ -326,5 +332,5 @@
 	node->timeout.condition = notZeroExpr( maybeMoveBuild<Expression>( when ) );
 
-	node->orelse.statement  = maybeMoveBuild<Statement >( else_stmt );
+	node->orelse.statement  = maybeMoveBuild<Statement >( else_ );
 	node->orelse.condition  = notZeroExpr( maybeMoveBuild<Expression>( else_when ) );
 
@@ -333,5 +339,5 @@
 
 Statement * build_with( ExpressionNode * exprs, StatementNode * stmt ) {
-	std::list< Expression * > e;
+	list< Expression * > e;
 	buildMoveList( exprs, e );
 	Statement * s = maybeMoveBuild<Statement>( stmt );
@@ -361,6 +367,6 @@
 
 Statement * build_asm( bool voltile, Expression * instruction, ExpressionNode * output, ExpressionNode * input, ExpressionNode * clobber, LabelNode * gotolabels ) {
-	std::list< Expression * > out, in;
-	std::list< ConstantExpr * > clob;
+	list< Expression * > out, in;
+	list< ConstantExpr * > clob;
 
 	buildMoveList( output, out );
@@ -375,5 +381,5 @@
 
 Statement * build_mutex( ExpressionNode * exprs, StatementNode * stmt ) {
-	std::list< Expression * > expList;
+	list< Expression * > expList;
 	buildMoveList( exprs, expList );
 	Statement * body = maybeMoveBuild<Statement>( stmt );
Index: src/Parser/parser.yy
===================================================================
--- src/Parser/parser.yy	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/Parser/parser.yy	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Sat Sep  1 20:22:55 2001
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sun Jan 30 09:41:13 2022
-// Update Count     : 5165
+// Last Modified On : Tue Feb  1 11:06:13 2022
+// Update Count     : 5167
 //
 
@@ -1197,5 +1197,6 @@
 		{ $$ = new StatementNode( build_while( $3, maybe_build_compound( $5 ) ) ); }
 	| WHILE '(' conditional_declaration ')' statement ELSE statement // CFA
-		{ SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; }
+		// { SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; }
+		{ $$ = new StatementNode( build_while( $3, maybe_build_compound( $5 ), $7 ) ); }
 	| DO statement WHILE '(' ')' ';'					// CFA => do while( 1 )
 		{ $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), maybe_build_compound( $2 ) ) ); }
@@ -1203,5 +1204,6 @@
 		{ $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ) ) ); }
 	| DO statement WHILE '(' comma_expression ')' ELSE statement // CFA
-		{ SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; }
+		// { SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; }
+		{ $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ), $8 ) ); }
 	| FOR '(' ')' statement								// CFA => for ( ;; )
 		{ $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), maybe_build_compound( $4 ) ) ); }
@@ -1209,5 +1211,6 @@
 	  	{ $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ) ) ); }
 	| FOR '(' for_control_expression_list ')' statement ELSE statement // CFA
-		{ SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; }
+		// { SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; }
+		{ $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ), $7 ) ); }
 	;
 
Index: src/ResolvExpr/Resolver.cc
===================================================================
--- src/ResolvExpr/Resolver.cc	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/ResolvExpr/Resolver.cc	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -9,7 +9,7 @@
 // Author           : Aaron B. Moss
 // Created On       : Sun May 17 12:17:01 2015
-// Last Modified By : Andrew Beach
-// Last Modified On : Fri Mar 27 11:58:00 2020
-// Update Count     : 242
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Tue Feb  1 16:27:14 2022
+// Update Count     : 245
 //
 
@@ -80,5 +80,5 @@
 		void previsit( AsmStmt * asmStmt );
 		void previsit( IfStmt * ifStmt );
-		void previsit( WhileStmt * whileStmt );
+		void previsit( WhileDoStmt * whileDoStmt );
 		void previsit( ForStmt * forStmt );
 		void previsit( SwitchStmt * switchStmt );
@@ -502,6 +502,6 @@
 	}
 
-	void Resolver_old::previsit( WhileStmt * whileStmt ) {
-		findIntegralExpression( whileStmt->condition, indexer );
+	void Resolver_old::previsit( WhileDoStmt * whileDoStmt ) {
+		findIntegralExpression( whileDoStmt->condition, indexer );
 	}
 
@@ -572,8 +572,8 @@
 
 	void Resolver_old::previsit( CatchStmt * catchStmt ) {
-		// Until we are very sure this invarent (ifs that move between passes have thenPart)
+		// Until we are very sure this invarent (ifs that move between passes have then)
 		// holds, check it. This allows a check for when to decode the mangling.
 		if ( IfStmt * ifStmt = dynamic_cast<IfStmt *>( catchStmt->body ) ) {
-			assert( ifStmt->thenPart );
+			assert( ifStmt->then );
 		}
 		// Encode the catchStmt so the condition can see the declaration.
@@ -588,11 +588,11 @@
 		// Decode the catchStmt so everything is stored properly.
 		IfStmt * ifStmt = dynamic_cast<IfStmt *>( catchStmt->body );
-		if ( nullptr != ifStmt && nullptr == ifStmt->thenPart ) {
+		if ( nullptr != ifStmt && nullptr == ifStmt->then ) {
 			assert( ifStmt->condition );
-			assert( ifStmt->elsePart );
+			assert( ifStmt->else_ );
 			catchStmt->cond = ifStmt->condition;
-			catchStmt->body = ifStmt->elsePart;
+			catchStmt->body = ifStmt->else_;
 			ifStmt->condition = nullptr;
-			ifStmt->elsePart = nullptr;
+			ifStmt->else_ = nullptr;
 			delete ifStmt;
 		}
@@ -1272,5 +1272,5 @@
 		const ast::AsmStmt *         previsit( const ast::AsmStmt * );
 		const ast::IfStmt *          previsit( const ast::IfStmt * );
-		const ast::WhileStmt *       previsit( const ast::WhileStmt * );
+		const ast::WhileDoStmt *       previsit( const ast::WhileDoStmt * );
 		const ast::ForStmt *         previsit( const ast::ForStmt * );
 		const ast::SwitchStmt *      previsit( const ast::SwitchStmt * );
@@ -1581,7 +1581,7 @@
 	}
 
-	const ast::WhileStmt * Resolver_new::previsit( const ast::WhileStmt * whileStmt ) {
+	const ast::WhileDoStmt * Resolver_new::previsit( const ast::WhileDoStmt * whileDoStmt ) {
 		return ast::mutate_field(
-			whileStmt, &ast::WhileStmt::cond, findIntegralExpression( whileStmt->cond, symtab ) );
+			whileDoStmt, &ast::WhileDoStmt::cond, findIntegralExpression( whileDoStmt->cond, symtab ) );
 	}
 
@@ -1669,8 +1669,8 @@
 
 	const ast::CatchStmt * Resolver_new::previsit( const ast::CatchStmt * catchStmt ) {
-		// Until we are very sure this invarent (ifs that move between passes have thenPart)
+		// Until we are very sure this invarent (ifs that move between passes have then)
 		// holds, check it. This allows a check for when to decode the mangling.
 		if ( auto ifStmt = catchStmt->body.as<ast::IfStmt>() ) {
-			assert( ifStmt->thenPart );
+			assert( ifStmt->then );
 		}
 		// Encode the catchStmt so the condition can see the declaration.
@@ -1687,10 +1687,10 @@
 		// Decode the catchStmt so everything is stored properly.
 		const ast::IfStmt * ifStmt = catchStmt->body.as<ast::IfStmt>();
-		if ( nullptr != ifStmt && nullptr == ifStmt->thenPart ) {
+		if ( nullptr != ifStmt && nullptr == ifStmt->then ) {
 			assert( ifStmt->cond );
-			assert( ifStmt->elsePart );
+			assert( ifStmt->else_ );
 			ast::CatchStmt * stmt = ast::mutate( catchStmt );
 			stmt->cond = ifStmt->cond;
-			stmt->body = ifStmt->elsePart;
+			stmt->body = ifStmt->else_;
 			// ifStmt should be implicately deleted here.
 			return stmt;
Index: src/SynTree/Mutator.h
===================================================================
--- src/SynTree/Mutator.h	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/SynTree/Mutator.h	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Mar 12 18:35:36 2021
-// Update Count     : 18
+// Last Modified On : Tue Feb  1 09:26:49 2022
+// Update Count     : 20
 //
 #pragma once
@@ -42,5 +42,5 @@
 	virtual Statement * mutate( DirectiveStmt * dirStmt ) = 0;
 	virtual Statement * mutate( IfStmt * ifStmt ) = 0;
-	virtual Statement * mutate( WhileStmt * whileStmt ) = 0;
+	virtual Statement * mutate( WhileDoStmt * whileDoStmt ) = 0;
 	virtual Statement * mutate( ForStmt * forStmt ) = 0;
 	virtual Statement * mutate( SwitchStmt * switchStmt ) = 0;
Index: src/SynTree/Statement.cc
===================================================================
--- src/SynTree/Statement.cc	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/SynTree/Statement.cc	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -9,7 +9,7 @@
 // Author           : Richard C. Bilson
 // Created On       : Mon May 18 07:44:20 2015
-// Last Modified By : Andrew Beach
-// Last Modified On : Mon Jan 20 16:03:00 2020
-// Update Count     : 71
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Wed Feb  2 11:55:19 2022
+// Update Count     : 80
 //
 
@@ -145,9 +145,9 @@
 }
 
-IfStmt::IfStmt( Expression * condition, Statement * thenPart, Statement * elsePart, std::list<Statement *> initialization ):
-	Statement(), condition( condition ), thenPart( thenPart ), elsePart( elsePart ), initialization( initialization ) {}
+IfStmt::IfStmt( Expression * condition, Statement * then, Statement * else_, std::list<Statement *> initialization ):
+	Statement(), condition( condition ), then( then ), else_( else_ ), initialization( initialization ) {}
 
 IfStmt::IfStmt( const IfStmt & other ) :
-	Statement( other ), condition( maybeClone( other.condition ) ), thenPart( maybeClone( other.thenPart ) ), elsePart( maybeClone( other.elsePart ) ) {
+	Statement( other ), condition( maybeClone( other.condition ) ), then( maybeClone( other.then ) ), else_( maybeClone( other.else_ ) ) {
 	cloneAll( other.initialization, initialization );
 }
@@ -156,6 +156,6 @@
 	deleteAll( initialization );
 	delete condition;
-	delete thenPart;
-	delete elsePart;
+	delete then;
+	delete else_;
 }
 
@@ -177,10 +177,10 @@
 
 	os << indent+1;
-	thenPart->print( os, indent+1 );
-
-	if ( elsePart != nullptr ) {
+	then->print( os, indent+1 );
+
+	if ( else_ != nullptr ) {
 		os << indent << "... else: " << endl;
 		os << indent+1;
-		elsePart->print( os, indent+1 );
+		else_->print( os, indent+1 );
 	} // if
 }
@@ -246,18 +246,22 @@
 }
 
-WhileStmt::WhileStmt( Expression * condition, Statement * body, std::list< Statement * > & initialization, bool isDoWhile ):
-	Statement(), condition( condition), body( body), initialization( initialization ), isDoWhile( isDoWhile) {
-}
-
-WhileStmt::WhileStmt( const WhileStmt & other ):
+WhileDoStmt::WhileDoStmt( Expression * condition, Statement * body, const std::list< Statement * > & initialization, bool isDoWhile ):
+	Statement(), condition( condition ), body( body ), else_( nullptr ), initialization( initialization ), isDoWhile( isDoWhile) {
+}
+
+WhileDoStmt::WhileDoStmt( Expression * condition, Statement * body, Statement * else_, const std::list< Statement * > & initialization, bool isDoWhile ):
+	Statement(), condition( condition), body( body ), else_( else_ ), initialization( initialization ), isDoWhile( isDoWhile) {
+}
+
+WhileDoStmt::WhileDoStmt( const WhileDoStmt & other ):
 	Statement( other ), condition( maybeClone( other.condition ) ), body( maybeClone( other.body ) ), isDoWhile( other.isDoWhile ) {
 }
 
-WhileStmt::~WhileStmt() {
+WhileDoStmt::~WhileDoStmt() {
 	delete body;
 	delete condition;
 }
 
-void WhileStmt::print( std::ostream & os, Indenter indent ) const {
+void WhileDoStmt::print( std::ostream & os, Indenter indent ) const {
 	os << "While on condition: " << endl ;
 	condition->print( os, indent+1 );
@@ -268,10 +272,10 @@
 }
 
-ForStmt::ForStmt( std::list<Statement *> initialization, Expression * condition, Expression * increment, Statement * body ):
-	Statement(), initialization( initialization ), condition( condition ), increment( increment ), body( body ) {
+ForStmt::ForStmt( std::list<Statement *> initialization, Expression * condition, Expression * increment, Statement * body, Statement * else_ ):
+	Statement(), initialization( initialization ), condition( condition ), increment( increment ), body( body ), else_( else_ ) {
 }
 
 ForStmt::ForStmt( const ForStmt & other ):
-	Statement( other ), condition( maybeClone( other.condition ) ), increment( maybeClone( other.increment ) ), body( maybeClone( other.body ) ) {
+	Statement( other ), condition( maybeClone( other.condition ) ), increment( maybeClone( other.increment ) ), body( maybeClone( other.body ) ), else_( maybeClone( other.else_ ) ) {
 		cloneAll( other.initialization, initialization );
 
@@ -283,4 +287,5 @@
 	delete increment;
 	delete body;
+	delete else_;
 }
 
@@ -311,4 +316,9 @@
 		os << "\n" << indent << "... with body: \n" << indent+1;
 		body->print( os, indent+1 );
+	}
+
+	if ( else_ != nullptr ) {
+		os << "\n" << indent << "... with body: \n" << indent+1;
+		else_->print( os, indent+1 );
 	}
 	os << endl;
Index: src/SynTree/Statement.h
===================================================================
--- src/SynTree/Statement.h	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/SynTree/Statement.h	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Jan 10 14:13:24 2020
-// Update Count     : 85
+// Last Modified On : Wed Feb  2 11:49:17 2022
+// Update Count     : 94
 //
 
@@ -148,9 +148,9 @@
   public:
 	Expression * condition;
-	Statement * thenPart;
-	Statement * elsePart;
+	Statement * then;
+	Statement * else_;
 	std::list<Statement *> initialization;
 
-	IfStmt( Expression * condition, Statement * thenPart, Statement * elsePart,
+	IfStmt( Expression * condition, Statement * then, Statement * else_,
 			std::list<Statement *> initialization = std::list<Statement *>() );
 	IfStmt( const IfStmt & other );
@@ -160,8 +160,8 @@
 	Expression * get_condition() { return condition; }
 	void set_condition( Expression * newValue ) { condition = newValue; }
-	Statement * get_thenPart() { return thenPart; }
-	void set_thenPart( Statement * newValue ) { thenPart = newValue; }
-	Statement * get_elsePart() { return elsePart; }
-	void set_elsePart( Statement * newValue ) { elsePart = newValue; }
+	Statement * get_then() { return then; }
+	void set_then( Statement * newValue ) { then = newValue; }
+	Statement * get_else() { return else_; }
+	void set_else( Statement * newValue ) { else_ = newValue; }
 
 	virtual IfStmt * clone() const override { return new IfStmt( *this ); }
@@ -225,14 +225,16 @@
 };
 
-class WhileStmt : public Statement {
+class WhileDoStmt : public Statement {
   public:
 	Expression * condition;
 	Statement * body;
+	Statement * else_;
 	std::list<Statement *> initialization;
 	bool isDoWhile;
 
-	WhileStmt( Expression * condition, Statement * body, std::list<Statement *> & initialization, bool isDoWhile = false );
-	WhileStmt( const WhileStmt & other );
-	virtual ~WhileStmt();
+	WhileDoStmt( Expression * condition, Statement * body, const std::list<Statement *> & initialization, bool isDoWhile = false );
+	WhileDoStmt( Expression * condition, Statement * body, Statement * else_, const std::list<Statement *> & initialization, bool isDoWhile = false );
+	WhileDoStmt( const WhileDoStmt & other );
+	virtual ~WhileDoStmt();
 
 	Expression * get_condition() { return condition; }
@@ -243,5 +245,5 @@
 	void set_isDoWhile( bool newValue ) { isDoWhile = newValue; }
 
-	virtual WhileStmt * clone() const override { return new WhileStmt( *this ); }
+	virtual WhileDoStmt * clone() const override { return new WhileDoStmt( *this ); }
 	virtual void accept( Visitor & v ) override { v.visit( this ); }
 	virtual void accept( Visitor & v ) const override { v.visit( this ); }
@@ -256,6 +258,7 @@
 	Expression * increment;
 	Statement * body;
-
-	ForStmt( std::list<Statement *> initialization, Expression * condition = nullptr, Expression * increment = nullptr, Statement * body = nullptr );
+	Statement * else_;
+
+	ForStmt( std::list<Statement *> initialization, Expression * condition = nullptr, Expression * increment = nullptr, Statement * body = nullptr, Statement * else_ = nullptr );
 	ForStmt( const ForStmt & other );
 	virtual ~ForStmt();
Index: src/SynTree/SynTree.h
===================================================================
--- src/SynTree/SynTree.h	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/SynTree/SynTree.h	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Mar 12 18:56:44 2021
-// Update Count     : 13
+// Last Modified On : Tue Feb  1 09:22:33 2022
+// Update Count     : 14
 //
 
@@ -45,5 +45,5 @@
 class DirectiveStmt;
 class IfStmt;
-class WhileStmt;
+class WhileDoStmt;
 class ForStmt;
 class SwitchStmt;
Index: src/SynTree/Visitor.h
===================================================================
--- src/SynTree/Visitor.h	(revision 4de48c588c60ac044d761e489e81a19e392a419d)
+++ src/SynTree/Visitor.h	(revision 8cb149f7e778de6a5b951bad4dcc95485937eb69)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Mar 12 18:35:35 2021
-// Update Count     : 15
+// Last Modified On : Tue Feb  1 09:26:57 2022
+// Update Count     : 17
 //
 
@@ -60,6 +60,6 @@
 	virtual void visit( IfStmt * node ) { visit( const_cast<const IfStmt *>(node) ); }
 	virtual void visit( const IfStmt * ifStmt ) = 0;
-	virtual void visit( WhileStmt * node ) { visit( const_cast<const WhileStmt *>(node) ); }
-	virtual void visit( const WhileStmt * whileStmt ) = 0;
+	virtual void visit( WhileDoStmt * node ) { visit( const_cast<const WhileDoStmt *>(node) ); }
+	virtual void visit( const WhileDoStmt * whileDoStmt ) = 0;
 	virtual void visit( ForStmt * node ) { visit( const_cast<const ForStmt *>(node) ); }
 	virtual void visit( const ForStmt * forStmt ) = 0;
