% Usage:
% \fundef\Foo{Foo}
%
% \progbody
% procedure $\Foo(x) =\null$
% \begblock
% while $x<0$ do
% \begblock
% $x — 0$
% \rem{At this point either $x\neq\pi$ or $x=\pi$}
% $x — x + 1$
% ...
% \endblock
% \endblock
% \endbody
%
\outer\def\progbody{\smallvbreak
\begingroup
\parindent\z@ \hangindent\z@ \hangafter\z@
\leftglue\z@\rightglue\z@
\parsep\z@ \baselinesep-\p@ \linesep\z@
\nb@rs\z@ \st@pwidth\hsize
\advance\st@pwidth by -\progindent
\mathcode`\:="603A % treat colon as punctuation
\def\begblock{\begingroup
\advance\nb@rs by 1 \proge@r\z@\z@
\advance\st@pwidth by -\proglevelindent\par\pr@glin@}
\def\endblock{\proge@r\z@\z@\endgroup\par\pr@glin@}
\def\endbody{\endgroup\par\medvbreak}
\def\rem##1{\pr@gitem\progcommindent{\normalsize\it
\hmode\strut ##1\strut}\par\pr@glin@}
\obeylines
\pr@glin@}
% \pr@glin@ eats things up to next <cr>, and
% calls \pr@gstep or \pr@gcomm if appropriate.
\def\pr@glin@{\futurelet\next\pr@glin@@}
% the following must be read with \endlinechar=-1:
{\catcode`\^^M=\active
\global\long\def\pr@glin@@#1^^M{
\ifx\next\par \def\next{\pr@glin@}
\else \ifx\next\rem \def\next{#1}
\else \ifx\next\begblock % do nothing
\else \ifx\next\endblock % do nothin
\else \ifx\next\endbody % do nothin
\else \def\next{\pr@gitem\progstepindent{\normalsize\kw
\hmode\strut #1\strut}\par\pr@glin@}\fi\fi\fi\fi\fi\next}}