% LAST EDIT: Wed Sep  4 15:40:34 1996 by Peter Pepper (basti!pepper) 
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% A LaTeX2e style for TeXing programs
%
% by P. Pepper
%
% (Note: This package is almost completely written in TeX!)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{basicprg}[1996/04/07 TU Berlin basicprg package (v 0.1)]
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load other packages
%
\RequirePackage{scanner}
\RequirePackage{xspace}
%     +-------------------------------------------------------+
%     | Used variables from "scanner.sty":                    |
%     |                                                       |
%     |     \@TeXCmnt                                         |
%     |     \@CmntSymb                                        |
%     |                                                       |
%     | Redefined variables from "scanner.sty":               |
%     |                                                       |
%     |     \@Cmnt                                            |
%     |     \@EndLine                                         |
%     |     \@EmptyLine                                       |
%     |                                                       |
%     +-------------------------------------------------------+
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Options (none available)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                             %
\AtBeginDocument{\@SetProgramSizes}%                          %
%                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                             %
%     +-------------------------------------------------------+
%     | Interface: The following variables and macros may be  |
%     |            redefined (or used to redefine sizes)      |
%     |            in texts and by other styles               |
%     |                                                       |
%     |            \ProgramWidth                              |
%     |            \ProgramLeftIndent                         |
%     |            \ProgramRightIndent                        |
%     |            \ProgramInnerIndent                        |
%     |            \ProgramSkip                               |
%     |                                                       |
%     |            \EmptyLineSkip                             |
%     |                                                       |
%     |            \Comment                                   |
%     |            \UaCmnt                                    |
%     |                                                       |
%     |            \Number                                    |
%     |            \NumberWidth                               |
%     |            \lnr                                       |
%     |                                                       |
%     |            \KeyWord{...}                              |
%     |            \`...'                                     |
%     |                                                       |
%     |            \ProgramPrelude                            |
%     |            \EmbeddedProgramPrelude                    |
%     |                                                       |
%     +-------------------------------------------------------+
%                                                             %
\def\ProgramWidth#1{\def\@@PrgWdth{\@PrgWdth=#1}}%            %
\def\ProgramLeftIndent#1{\def\@@PrgLftInd{\@PrgLftInd=#1}}%   %
\def\ProgramRightIndent#1{\def\@@PrgRgtInd{\@PrgRgtInd=#1}}%  %
\def\ProgramInnerIndent#1{\def\@@PrgInnInd{\@PrgInnInd=#1}}%  %
\def\ProgramSkip#1{\def\@@PrgSkp{\@PrgSkp=#1}}%               %
\def\EmptyLineSkip#1{\def\@@@EmptyLnSkp{\@EmptyLnSkp=#1}}%    %
\def\NumberWidth#1{\def\@@NmbrWdth{\@NmbrWdth=#1}}%           %
%                                                             %
\ProgramWidth{\textwidth}%                                    %
\ProgramLeftIndent{0pt}%                                      %
\ProgramRightIndent{0pt}%                                     %
\ProgramInnerIndent{3em}%                                     %
\ProgramSkip{\parskip}%                                       %
\EmptyLineSkip{.6\baselineskip}%                              % geht nicht!?
\NumberWidth{2em}%                                            %
%                                                             %
\def\@SetProgramSizes{%                                       %
  \@@PrgWdth%                                                 %
  \@@PrgLftInd%                                               %
  \@@PrgRgtInd%                                               %
  \@@PrgInnInd%                                               %
  \@@PrgSkp%                                                  %
  \@@@EmptyLnSkp%                                             %
  \@@NmbrWdth%                                                %
}%                                                            %
%                                                             %
\def\Number#1{\texttt{\footnotesize#1}}                       %
\def\lnr{\@Nmbr}%                                             %
\def\@Number#1{\Number{#1}}%                                  %
%                                                             %
\def\Comment#1{\textit{#1}}%                %default          %
\def\UaCmnt{\@MiniCmnt}%         % start unaligned comment    %
\def\@CommentSymb{\texttt{--}}%                               %
\def\@Comment#1{\Comment{#1}}%                                %
%                                                             %
\def\KeyWord#1{\textsc{\lowercase{#1}}}%    % default         %
\def\`#1'{\KeyWord{#1}}%                                      %
%                                                             %
\def\ProgramPrelude{\relax}%                                  %
\def\EmbeddedProgramPrelude{\relax}%                          %
%                                                             %
%     +-------------------------------------------------------+
%     | Interface: The following macro may be                 |
%     |            redefined by other styles                  |
%     |                                                       |
%     |            \@CommentSymb                              |
%     |                                                       |
%     +-------------------------------------------------------+
%                                                             %
%                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  Miscellaneous
%%          - \Language: produce a language name
%%          - \DefLanguage: produce a macro for a language name
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                   %
\def\Language#1{\textsc{#1}\xspace}%                % LaTeX2e !
\def\DefLanguage#1{%                                %
\expandafter\def\csname #1\endcsname{%              %
\textsc{#1}\xspace}%                                %
}%                                                  %
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% The main environment: "program"
%% ---------------------
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                  %
\newenvironment{program}{%                         % LaTeX!
   \@SetProgramSizes%                              %
   \vskip\@PrgSkp%                                 %
   \bgroup%                                        % prog -------------+
   \lineskip=0pt%                                  %                   |
   \obeylines%                                     %                   |
   \@ActivateSpecSymbs%                            %                   |
   \catcode`\"12%                                  %                   |
   \Prog@Options}{%                                %                   |
   \End@Program%                                   %                   |
   \egroup%                                        % end prog ---------+
   \par%                                           %
   \vskip\@PrgSkp%                                 %
   }%                                              %
%                                                  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% 
%%   --- D e f i n i t i o n s ---  (and nothing else)
%% 
%% 
%%   (the real layout begins with \Start@Program) 
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                   %
\newtoks\@tc\newtoks\@td%                           %
%                                                   %
\newdimen\@PrgWdth%                                 %
\newdimen\@PrgLftInd%                               %
\newdimen\@PrgRgtInd%                               %
\newdimen\@PrgInnInd%                               %
\newdimen\@PrgSkp%                                  %
\newdimen\@EmptyLnSkp%                              %
\newdimen\@NmbrWdth%                                %
%                                                   %
\newdimen\@PBxWdth%                                 %
\newdimen\@PWdth%                                   %
\newdimen\@PLInd%                                   %
\newdimen\@InnerIndent%                             %
\newdimen\@FrameIndent%                             %
\newdimen\@RuleSkip%                                %
\newcount\@ProgNmbr%                                %
\newcount\@TabNesting                               %
%                                                   %
\newbox\@TabBox%                                    %
\newdimen\@TbBxHt%                                  %
\newdimen\@TbBxDp%                                  %
\newdimen\@Depth%                                   %
%                                                   %
\newbox\@FragmentBox%                               %
\newdimen\@FrBxHt\@FrBxHt=0pt%                      %
\newdimen\@FrBxDp\@FrBxDp=0pt%                      %
%                                                   %
\newif\if@InFragment%                               %
\newif\if@EmptyFrag%                                %
\newif\if@FreshLine%                                %
\newif\if@Cmnt%                                     %
\newif\if@Nmbr%                                     %
\newif\if@EmptyTab%                                 %
\newif\if@Break%                                    %
\newif\if@FirstIf%                                  %
\newif\if@plainProg%                                % default
\newif\if@centeredProg%                             %
\newif\if@framedProg%                               %
\newif\if@numberedProg%                             %
%                                                   %
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% \Program@Initialize:  Initialization of variables and macros
%% -------------------  
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                   %
\def\Program@Initialize{%                           %
   \@PWdth=\the\textwidth%                          % \@PWdth =
   \advance\@PWdth by-\the\@PrgLftInd%              %  min(\textwidth-Indent.,
   \advance\@PWdth by-\the\@PrgRgtInd%              %      \@PrgWdth)
   \ifdim\the\@PWdth>\the\@PrgWdth\relax%           %
      \@PWdth=\the\@PrgWdth%                        %
   \fi%                                             %
   \@PBxWdth=\the\@PWdth%                           %
   \advance\@PBxWdth by-1ex%                        % spaces from frame
   \advance\@PBxWdth by-1pt%                        % thickness of rules
   \@RuleSkip=.2\baselineskip%                      %
   \def\@Width{}%                                   %
   \def\@VSkip{}%                                   %
   \def\Cmnt@List{}%                                %
   \def\Prepare@Cmnt{}%                             %
   \def\Nmbr@List{}%                                %
   \def\@DlydTab{}%                                 %
   \@TabNesting=0%                                  %
   \@EmptyFragtrue%                                 %
   \@FreshLinetrue%                                 %
   \@InFragmentfalse%                               %
   \@Cmntfalse%                                     %
   \@Nmbrfalse%                                     %
   \@Breaktrue%                                     %
   \@FirstIftrue%                                   %
   }%                                               %
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% \Program@Prelude: Standard commands that are generally available 
%% ----------------  within program environments
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                   %
\def\Program@Prelude{%                              %
   \let\[=\Open@Tab%                                %
   \let\]=\Close@Tab%                               %
   \let\&=\Set@Tab%                                 %
   \let\-=\@CmntSymb%                               %
   \let\%=\@TeXCmnt%                                %
   \let\Break=\Break@Program%                       %
   \let\Rule=\@LongRule%                            %
   \let\@KeyWord=\KeyWord%                          %
   \SetSymbol{-----}{\Rule}%                        % from scanner.sty
   \let\Shrink=\@Shrink%                            %
   \let\0=\Null@Tab%                                %
   \def\@EndLine{\@EoL}%                            %
   \Special@Macros%                                 %
   }%                                               %
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% program environment
%% -------------------
%%        \Program@Options
%%        \Begin@Program
%%        \Break@Program
%%        \End@Program
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% \Program@Options: Analyzing the program options
%% ----------------  (sets global if-values)
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                  %
\def\Prog@Options{\futurelet\@Next\Prog@Opt}%      %
{\obeylines%                                       %
 \gdef\Prog@Opt{%                                  %
   \if[\noexpand\@Next\relax%                      %
      \def\@Cont{\Prog@@Opt}%                      %
   \else%                                          %
      \def\@Cont{\Prog@@Opt[p]}%                   %
   \fi%                                            %
   \@Cont%                                         %
   }%                                              %
}%                                                 %
\def\Prog@@Opt[#1]{%                               %
   \Prog@@@Opt#1\Prog@Opt%                         %
   }%                                              %
\def\Prog@@@Opt#1{%                                %
   \ifx#1\Prog@Opt%                                %
     \def\@Cont{\Begin@Program}%                   %
   \else%                                          %
     \if#1p\@plainProgtrue%                        %
     \else\if#1c\@centeredProgtrue%                %
     \else\if#1f\@framedProgtrue%                  %
     \else\if#1n\@numberedProgtrue%                %
     \else%                                        %
     \PackageError{basicprg.sty}{Invalid option -- only "p,c,f,n" allowed}{}%
     \fi\fi\fi\fi%                                 %
     \def\@Cont{\Prog@@@Opt}%                      %
   \fi%                                            %
   \@Cont%                                         %
   }%                                              %
%                                                  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                   %
{\obeylines%                                        %
 \gdef\Begin@Program#1^^M{%                         %
     \Begin@@Program#1%                             %
     }%                                             %
}%                                                  %
\def\Begin@@Program{%                               %
   \ProgramPrelude%    % definitions from user      %
   \Program@Prelude%   % standard defns. (see above)%
   \@InnerIndent=0pt%                               %
   \@FrameIndent=4pt%                               %
   \DisableMathScan%                                %
   \@ProgNmbr=0%                                    %
   \if@framedProg%    % for framed programs         %
         \def\@LVrule{\vrule}%                      %
         \def\@RVrule{\vrule}%                      % 
         \def\@THrule{\hrule\kern\@RuleSkip}%       % 
         \def\@BHrule{\kern\@RuleSkip\hrule}%       %
         \def\@HBoX{\hbox to\the\@PBxWdth}%         % 
   \else%              % for unframed programs      %
         \def\@LVrule{\relax}%                      %
         \def\@RVrule{\relax}%                      %
         \def\@THrule{\relax}%                      %
         \def\@BHrule{\relax}%                      %
         \def\@HBoX{\hbox}%                         %
   \fi%                                             %   
   \Start@Program{\@THrule}%                        %
   \@Scan%                                          %          
}%                                                  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%                         %
\def\End@Program{%                                  %
   \Finish@Program{\@BHrule}%                       %
   \EnableMathScan%                                 %
   }%                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%                         %
\def\Break@Program{%                                %
\gdef\@EndLine{\relax\global\let\@EndLine=\@EoL}%   %
\Finish@Program{\relax}%                            %
% potential page break                              %   
\global\@Breaktrue%                                 %   
\kern-\lineskip%                                    %
\Start@Program{\relax}%                             %
}%                                                  %
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%                         %
\def\@LongRule{%                                    %       
\gdef\@EndLine{\relax\global\let\@EndLine=\@EoL}%   %
\Finish@Program{\kern\@RuleSkip}%                   % 
% potential page break                              %
\global\@Breaktrue%                                 %
\xdef\Prepare@Cmnt{}%                               %
\xdef\Prepare@Nmbr{}%                               %
\@AddCmnt%                                          %
\@AddNmbr%                                          %
\kern-\lineskip%                                    %
\Start@Program{\@THrule\kern\@RuleSkip}%            %
}%                                                  %
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% 
%%   --- The  r e a l  Layout ---
%% 
%% 
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%              %
\def\Start@Program#1{%                              %
\Program@Initialize%                                %
%\par\noindent%                                     %
\hbox to \the\textwidth\bgroup% --------------------%--hbox---------------+
   \if@centeredProg\relax%                          %                     |
      \hfil%                                        %                     |
   \else%                                           %                     |
      \hskip\the\@PrgLftInd%                        %                     |
      %% Einfügung                                  %                     |
      \hskip\leftmargin                             %                     |
   \fi%                                             %                     |
   \hbox\bgroup\@LVrule\vbox\bgroup% ===============%===hbox=vbox======+  |
      #1% %\@THrule or \relax                       %                  |  |
      \hbox\bgroup%\kern.5em% ----------------------%----hbox--------+ |  |
        \@HBoX\bgroup% -----------------------------%-----@HBoX----+ | |  |
           \vtop\bgroup% ---------------------------%------vtop--+ | | |  |
             \global\let\@DlydTab=\Open@@Tb%        %            | | | |  |
             \global\@EmptyTabtrue%                 %            | | | |  |
             \Begin@Fragment%                       %            | | | |  |
   }%                                               %            | | | |  |
%%%%%%%%%%%%%%%%%%%%%%%%%%%                         %            | | | |  |
\def\Finish@Program#1{%                             %            | | | |  |
           \global\let\@DlydTab=\relax%             %            | | | |  |
           \@CloseAllTabs% % left-over tabs         %            | | | |  |
           \egroup%   (the \vtop-group) ------------%------------+ | | |  |
           \if@Nmbr\relax%                          %              | | |  |
              \else\if@numberedProg\Set@Nmbr\fi%    %              | | |  |
           \fi%                                     %              | | |  |
           \hfil\vtop{\Cmnt@List}%                  %              | | |  |
           \hfil\vtop{\Nmbr@List}%                  %              | | |  |
       \egroup%      (the \HBoX-group) -------------%--------------+ | |  |
   \kern.5em\egroup% -------------------------------%----hbox--------+ |  |
       #1% % \@BHrule  or \relax                    %                  |  |
   \egroup\@RVrule\egroup% (the \vbox\hbox-group) ==%==================+  |
   \hfil%                                           %                     |
   \egroup%   (the \hbox to\the\textwidth-group) ---%---------------------+
}%                                                  %
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Table-building macros
%% ---------------------
%%     \Open@Tab           starts a new \halign
%%                         increases \@TabNesting,
%%                         stacks old \@TabLevel, sets actual one to 0
%%     \Close@Tab          closes \halign, resets the counters
%%     \DoPendingClose@Tabs closes (at "end of line") as many tables as
%%                         there have been closing keywords in the line
%%
%%     variables: \@TabNesting
%%                \PendingClose@Tab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%                         %
\def\Null@Tab{%                                     %
  \gdef\@Width{to0pt}%                              %
  }%                                                %
%%%%%%%%%%%%%%%%%%%%%%%%%%%                         %
\def\Open@Tab{%                                     % \ [
   \End@Fragment%                                   %
   \@DlydTab%                                       %
   \the@Frag%                                       %
   \global\let\@DlydTab=\Open@@Tb%                  %
   \global\@EmptyTabtrue%                           %
   \global\@FreshLinefalse%                         %
   \Begin@Fragment%                                 %
   }%                                               %
%%%%%%                                              %
\def\Open@@Tb{%                                     %
   \global\advance\@TabNesting by+1%                %
   \hbox\@Width\bgroup%                             % --hbox{---------------+  
     \gdef\@Width{}%                                %                       |
     \global\setbox\@TabBox=\vtop\bgroup%           % ----vtop{-----------+ |
       \halign\bgroup&##\hss\crcr%                  % ------halign{-----+ | |
   }%                                               %                   | | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%                         %                   | | |
\def\Close@Tab{%                                    % \ ]               | | |
   \End@Fragment%                                   %                   | | |
   \if@EmptyFrag%                                   %                   | | |
      \if@EmptyTab%                                 %                   | | |
         \relax%                                    %                   | | |
         \global\let\@DlydTab=\relax%               %                   | | |
      \else%                                        %                   | | |
         \@DlydTab%                                 %                   | | |
         \global\let\@DlydTab=\Close@@Tb%           %                   | | |
      \fi%                                          %                   | | |
   \else%                                           %                   | | |
      \@DlydTab%                                    %                   | | |
      \the@Frag%                                    %                   | | |
      \global\let\@DlydTab=\Close@@Tb%              %                   | | |
   \fi%                                             %                   | | |
   \global\@FreshLinefalse%                         %                   | | |
   \global\@EmptyTabfalse%                          %                   | | |
   \Begin@Fragment%                                 %                   | | |
   }%                                               %                   | | |
%%%%%%                                              %                   | | |
\def\Close@@Tb{%                                    %                   | | |
   \global\advance\@TabNesting by-1%                %                   | | |
   \ifnum\the\@TabNesting<0 %                       %                   | | |
     \PackageError{basicprg.sty}{Too many tabular environments closed}{}%| |
   \else%                                           %                   | | |
        \crcr\egroup%  (the \halign-group)          % ------------------+ | |
      \egroup%    (the \vtop-group)                 % --------------------+ |
      \@TbBxHt=\ht\@TabBox%                         %                       |
      \@TbBxDp=\dp\@TabBox%                         %                       |
      \box\the\@TabBox%                             %                       |
      \@Depth=\@TbBxDp%                             %                       |
      \advance\@Depth by -1\@FrBxHt%                %                       |
      \advance\@Depth by -1\@FrBxDp%                %                       |
      \ifdim\@Depth>0pt%                            %                       |
      \xdef\@VSkip{\hbox{\vrule width0pt height\the\@TbBxHt depth\the\@Depth}}%
      \fi%                                          %                       |
   \hss\egroup%  (the \hbox-group)                  % ----------------------+
   \fi%                                             %
   }%                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%                         %
\def\@CloseAllTabs{%                                %
   \End@Fragment%                                   %
   \@DlydTab%                                       %
   \if@EmptyFrag%                                   %
      \relax%                                       %
   \else%                                           %
      \the@Frag%                                    %
      \@EmptyTabfalse%                              %
   \fi%                                             %
   \@FinishTabs%                                    %
   }%                                               %
%                                                   %
\def\@FinishTabs{%                                  %
   \ifnum\the\@TabNesting>0 %                       %
      \Close@@Tb%                                   %
      \let\@Cont=\@FinishTabs%                      %
   \else%                                           %
      \let\@Cont=\relax%                            % Should this be \@EndLine?
   \fi%                                             %
   \@Cont%                                          %
   }%                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%                         %
\def\Set@Tab{%                                      % \&
   \End@Fragment%                                   %
   \global\@EmptyTabfalse%                          %
   \@DlydTab%                                       %
   \the@Frag%                                       %
   \global\@FreshLinefalse%                         %
   \global\let\@DlydTab=\Set@@Tb%                   %
   \Begin@Fragment%                                 %
   }%                                               %
%%%%%%                                              %
\def\Set@@Tb{%                                      %
   \ifnum\the\@TabNesting>0 %                       %
     \@TabStopSymb%                                 %
   \else%                                           %
     \PackageError{basicprg.sty}{Tabstop outside of table!}{}%
   \fi%                                             %
   }%                                               %
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%                         %
\def\@TabStopSymb{&}%                               %
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% ProgramFragment environment (the lowest macro level)
%% ---------------------------
%%     \Begin@Fragment starts an \hbox;
%%                     starts math
%%     \End@Fragment   ends math;
%%                     finishes the \hbox and stores it in \@FragmentBox;
%%                     sets boolean switches:
%%                          - \@ifEmptyBox
%%                          - \@ifEmptyLine
%%                          - \if@InFragment
%%                     calculates info. for vertical size of comment list
%%     variables: \@FragmentBox
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                   %
\def\the@Fragment{\vtop{\@VSkip\box\@FragmentBox}}% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%                         %
\def\Begin@Fragment{%                               %
   \if@InFragment \relax%                           %
   \else%                                           %
     \global\@InFragmenttrue%                       %
     \global\setbox\@FragmentBox=\hbox\bgroup%      % ---- open \@FragmentBox
     $%              % $ starts math                %                       |
   \fi%                                             %                       |
   }%                                               %                       |
%%%%%%%%%%%%%%%%%%%%%%%%%%%                         %                       |
\def\End@Fragment{%                                 %                       |
  \if@InFragment%                                   %                       |
     $\strut\egroup %   % $ ends math               % --- close \@FragmentBox
     \ifdim\wd\@FragmentBox>0pt%                    %
       \global\@FrBxHt=\ht\@FragmentBox%            %
       \global\@FrBxDp=\dp\@FragmentBox%            %
       \@PrepCmnt{\vrule width0pt height\the\@FrBxHt depth\the\@FrBxDp}%
       \@PrepNmbr{\vrule width0pt height\the\@FrBxHt depth\the\@FrBxDp}%
       \global\@EmptyFragfalse%                     %
       \global\@FreshLinefalse%                     %
       \global\let\the@Frag=\the@Fragment%          %
     \else%                                         %
       \global\@EmptyFragtrue%                      %
       \global\let\the@Frag=\relax%                 %
     \fi %                                          %
   \else%                                           %
      \relax%                                       %
   \fi%                                             %
   \global\@InFragmentfalse%                        %
   }%                                               %
%                                                   %
\def\@PrepCmnt#1{%                                  %
   \edef\@Ta{#1}%                                   %
   \@td=\expandafter{\Prepare@Cmnt}%                %
   \xdef\Prepare@Cmnt{\the\@td\@Ta}%                %
   }%                                               %
\def\@PrepNmbr#1{%                                  %
   \edef\@Ta{#1}%                                   %
   \@td=\expandafter{\Prepare@Nmbr}%                %
   \xdef\Prepare@Nmbr{\the\@td\@Ta}%                %
   }%                                               %
%                                                   %
\def\@Shrink#1{\hbox to 1pt{$#1$\hss}}              %
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Comments  and Numbers                             %
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Comments: The macro \@Cmnt is redefined here;     %
% --------  it is actually found and recognized     %
%           and provided with the proper parameter  %
%           by the style "scanner.sty".             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                   %
\newif\if@InMiniCmnt%                               %
\def\@MiniCmnt{%                                    %
   \global\@InMiniCmnttrue%                         %
   \hbox to 1pt\bgroup$%                            %
      \def\Identifier##1{\@Comment{##1}~}%          %
      \quad\@CommentSymb%                           %
}%                                                  %
\def\@FinishMiniCmnt{%                              %
   $\hss\egroup%                                    %
   \global\@InMiniCmntfalse%                        %
   }%                                               %
%                                                   %
\def\@Cmnt#1{%                                      %
   ~\End@Fragment%                                  % ~ copes with empty line
   \global\@EmptyTabfalse%                          %
   \@DlydTab%                                       %
   \the@Frag%                                       %
   \@tc={#1}%                                       %
   \@td=\expandafter{\Prepare@Cmnt}%                %
   \xdef\Prepare@Cmnt{%                             %
 \hbox{\strut\the\@td\quad\noexpand\@CommentSymb\noexpand\@Comment{\the\@tc}}%
     }%                                             %
   \@AddCmnt%                                       %
   \global\@Cmnttrue%                               %
   \global\@FreshLinefalse%                         %
   \global\let\@DlydTab=\relax%                     %
   }%                                               %
\def\@AddCmnt{%                                     %
   \@tc=\expandafter{\Prepare@Cmnt}%                %
   \@td=\expandafter{\Cmnt@List}%                   %
   \xdef\Cmnt@List{\the\@td\the\@tc}%               %
   \gdef\Prepare@Cmnt{}%                            %
   }%                                               %
%                                                   %
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%                         %
% Numbers                                           %
%%%%%%%%%%%%%%%%%%%%%%%%%%%                         %
%                                                   %
\def\Prepare@Nmbr{}%                                %
%                                                   %
\def\@Nmbr{%                                        %
   ~\End@Fragment%                                  % ~ copes with empty line
   \global\@EmptyTabfalse%                          %
   \@DlydTab%                                       %
   \the@Frag%                                       %
   \Set@Nmbr%                                       %
   \global\@Nmbrtrue%                               %
   \global\@FreshLinefalse%                         %
   \global\let\@DlydTab=\relax%                     %
   }%                                               %
%                                                   %
\def\Set@Nmbr{%                                     %
   \global\advance\@ProgNmbr by 1%                  %
   \@tc=\expandafter{\the\@ProgNmbr}%               %
   \@td=\expandafter{\Prepare@Nmbr}%                %
   \xdef\Prepare@Nmbr{%                             %
     \hbox to \@NmbrWdth{\hfil\the\@td\hfill\noexpand\@Number{\the\@tc}}%
     }%                                             %
   \@AddNmbr%                                       %
   }%                                               %
%                                                   %
\def\@AddNmbr{%                                     %
   \@tc=\expandafter{\Prepare@Nmbr}%                %
   \@td=\expandafter{\Nmbr@List}%                   %
   \xdef\Nmbr@List{\the\@td\the\@tc}%%
   \gdef\Prepare@Nmbr{}%                            %
   }%                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% End-of-Line activities
%% ----------------------
%%     \@EoL (=\@EndLine)  completes the current program fragment box;
%%           if nonempty, it is output with necessary leading tabstops;
%%           then the table line is completed with \cr;
%%           
%%     \@EmptyLine actually only adds a little vertical space
%%           (also in the Comment and Number lists)
%%                         
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                   %
\def\@EoL{%                                         %
   \if@InMiniCmnt\@FinishMiniCmnt\fi%               %
   \End@Fragment%                                   %
   \@DlydTab%                                       %
   \the@Frag%                                       %
   \global\let\@DlydTab=\@@EoL%                     %
   \global\@FreshLinetrue%                          %
   \global\@Breakfalse%                             %
   \global\@EmptyTabfalse%                          %
   \Begin@Fragment%                                 %
   }%                                               %
%                                                   %
\def\@@EoL{%                                        %
   \ifnum\the\@TabNesting>0 \crcr\noalign{\@@EmptyLnSkp}%
     \else\par\@@EmptyLnSkp%                        %
   \fi%                                             %
   \if@Cmnt\relax%                                  %
   \else\@td=\expandafter{\Prepare@Cmnt}%           %
        \xdef\Prepare@Cmnt{\hbox{\the\@td}}%        %
        \@AddCmnt%                                  %
   \fi%                                             %
   \if@Nmbr\relax%                                  %
   \else\if@numberedProg\Set@Nmbr%                  %
        \else\@td=\expandafter{\Prepare@Nmbr}%      %
             \xdef\Prepare@Nmbr{\hbox{\the\@td}}%   %
             \@AddNmbr%                             %
        \fi%                                        %
   \fi%                                             %
   \xdef\Prepare@Cmnt{\@@EmptyLnSkp}%               %
   \@AddCmnt%                                       %
   \xdef\Prepare@Nmbr{\@@EmptyLnSkp}%               %
   \@AddNmbr%                                       %
   \gdef\@@EmptyLnSkp{}%                            %
   \global\@Cmntfalse%                              %
   \global\@Nmbrfalse%                              %
   \global\@TbBxHt=0pt%                             %
   \global\@TbBxDp=0pt%                             %
   \gdef\@VSkip{}%                                  %
   \global\let\@DlydTab=\relax%                     %
   }%                                               %
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%                             %
\def\@@EmptyLnSkp{}%                                %
\def\@EmptyLine{%                                   %
   \gdef\@@EmptyLnSkp{\kern\@EmptyLnSkp}%           %
}%                                                  %
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  For macros like IF, THEN, ....
%  ------------------------------
%
%  These macros are essentially based on the macros \[, \&, \].
%  But we need a delaying policy, since sometimes the macros have
%  to be partly set before/after the end of line.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                   %
\def\@TopKW#1#2{%                                   % SIGNATURE, ...
   \global\@InnerIndent=\the\@PrgInnInd%            %
   \if@Break%                                       %
      \relax%                                       %
   \else%                                           %
      \global\let\@DlydTab=\relax%                  %
      \@CloseAllTabs%                               %
      \@EoL%                                        %
   \fi%                                             %
   \global\def\@VSkip{}%                            %
   \global\@FirstIftrue%                            %
   \if@framedProg%                                  %
      \[\hskip\@FrameIndent#1{#2}\[%       %\]      %
   \else%                                           %
      \[#1{#2}\[%       %\]                         %
   \fi%                                             %
  }%                                                %
%%%%%%%%%%                                          %
%                                                   %
\def\@MainKW#1#2{%                                  % IMPORT, FUN, ...
   \if@Break%                                       %
      \relax%                                       %
   \else%                                           %
      \global\let\@DlydTab=\relax%                  %
      \@CloseAllTabs%                               %
      \@EoL%                                        %
   \fi%                                             %
   \global\def\@VSkip{}%                            %
   \global\@FirstIftrue%                            %
   \if@framedProg%                                  %
      \[\hskip\@FrameIndent\hskip\@InnerIndent#1{#2}\[% %\] %
   \else%                                           %
      \[\hskip\@InnerIndent#1{#2}\[%       %\]      %
   \fi%                                             %
  }%                                                %
%%%%%%%%%%%                                         %
%                                                   %
\newif\if@FrshLn%                                   %
\newbox\@SvBx%                                      %
%                                                   %
\def\@FollowKW#1#2{%                                % ONLY, COMPLETELY ...
  \if@FreshLine\global\@FrshLntrue\else\global\@FrshLnfalse\fi%
  \End@Fragment%                                    %
  \if@FrshLn%                                       %
      \global\let\@DlydTab=\relax%                  %
      \global\setbox\@SvBx=\hbox{\the@Frag}%        %
      \def\the@Frag{}%                              %
      \]\@EoL%                                      %
      \box\@SvBx\&~#1{#2}~\&\[%     %\]             %
  \else%                                            %
      \&\@LeadSpace#1{#2}~\&\[%    %\]                        %
  \fi%                                              %
  }%                                                %
%%%%%%%%%%                                          %
%                                                   %
\def\@BeginKW#1#2{%                                 % LET, BEGIN
   \End@Fragment%                                   %
   \if@FreshLine%                                   %
         \[#1{#2}~                  %\]             %
   \else%                                           %
      \[#1{#2}~                     %\]             %
   \fi%                                             %
  }%                                                %
%
%%%%%%%%%%                                          %
%                                                   %
\def\@IfKW#1#2{%                                    % IF
   \End@Fragment%                                   %
   \if@FreshLine%                                   %
      \if@FirstIf                                   %
         \[#1{#2}~\&\[%   %\]                       %
      \else%                                        %
         \global\let\@DlydTab=\relax%               %
         \]\@EoL%                                   %
         #1{#2}~\&\[%     %\]                       %
      \fi%                                          %
   \else%                                           %
      \[#1{#2}~\&\[%   %\]                          %
   \fi%                                             %
\global\@FirstIffalse%                              %
  }%                                                %
%%%%%%%%%%                                          %
%                                                   %
\def\@ThenKW#1#2{%                                  % THEN, ...
   \End@Fragment%                                   %
   \if@FreshLine%                                   %
      \global\let\@DlydTab=\relax%                  %
      \global\def\@ElseLyta{\[}%    %\]             %
      \global\def\@ElseLytb{}%                      %
      \]\@EoL%                                      %
      \&\[#1{#2}~\&%                %\]             %
   \else%                                           %
      \global\def\@ElseLyta{\&}%                    %
      \global\def\@ElseLytb{\[}%    %\]             %
      \]\@LeadSpace\&#1{#2}~\&\[%   %\]             %
   \fi%                                             %
  }%                                                %
%%%%%%%%%%                                          %
%                                                   %
\def\@ElseKW#1#2{%                                  % ELSE, ...
   \End@Fragment%                                   %
   \if@FreshLine%                                   %
      \global\let\@DlydTab=\relax%                  %
      \]\@EoL%                                      %
      \&\@ElseLyta#1{#2}~\&\@ElseLytb%              %
   \else%                                           %
      \]\@LeadSpace\&#1{#2}~\&\[%       %\]         %
   \fi%                                             %
  }%                                                %
%%%%%%%%%%                                          %
%                                                   %
\def\@EndKW#1#2{%                                   % FI, ...
   \End@Fragment%                                   %
   \if@FreshLine%                                   %
      \global\let\@DlydTab=\relax%                  %
      \]\@EoL%                                      %
      #1{#2}~\]%                                    %
   \else%                                           %
      \]\@LeadSpace#1{#2}~\]%                                 %
   \fi%                                             %
  }%                                                %
                                                    %
%%%%%%%%%%                                          %
%                                                   %
\def\@PlainKW#1#2{%                                 % AS, ...
   #1{#2}~%                                         %
  }%                                                %
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  Macros for introducing keywords
%%  ------------------------------
%%          - \TopKeyWord      can introduce {SIGNATURE,THEORY,...}
%%          - \MainKeyWord     can introduce {IMPORT,FUN,DEF,...}
%%          - \FollowKeyWord   can introduce {ONLY,COMPLETELY...}
%%          - \BeginKeyWord    can introduce {LET,...}
%%          - \IfLikeKeyWord   can introduce {IF,...}
%%          - \ThenLikeKeyWord can introduce {THEN,...}
%%          - \ElseLikeKeyWord can introduce {ELSE,IN,...}
%%          - \EndKeyWord      can introduce {FI,...}
%%          - \PlainKeyWord    can introduce {AS,...}
%%  (all these macros take a comma-separated list of keywords as argument)
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  first the auxiliary commands ...
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                   %
\newtoks\@kwkind%                                   %
\def\@KyWrd#1{%                                     %
   \@kwkind={#1}%                                   %
   \futurelet\@Next\@KyWrdA%                        %
   }%                                               %
\def\@KyWrdA{%                                      %
   \ifx\@Next[\def\@Cont{\@KyWrdB}%                 %
   \else\def\@Cont{\@KyWrdC}%                       %
   \fi%                                             %
   \@Cont%                                          %
   }%                                               %
\def\@KyWrdB[#1]#2{%                                %
   \expandafter\@KyWrdBB\the\@kwkind{#1}{#2}%       %
   }%                                               %
\def\@KyWrdBB#1#2#3{%                               %
   \SetCommand{#3}{#1{\hbox to #2}{\KeyWord{#3}\hss}}%
   \DefPlain@KW{#3}%                                %
   }%                                               %
\def\@KyWrdC#1{%                                    %
   \expandafter\@KyWrdCC\the\@kwkind{#1}%           %
   }%                                               %
\def\@KyWrdCC#1#2{%                                 %
   \SetCommand{#2}{#1{}{\KeyWord{#2}}}%             %
   \DefPlain@KW{#2}%                                %
   }%                                               %
%                                                   %
\def\DefPlain@KW#1{%                                %
\expandafter\gdef\csname#1\endcsname{\@KeyWord{#1}}%%
}%                                                  %
%                                                   %
\def\@KeyWord#1{\KeyWord{#1}\xspace}%               % to be used outside
%                                                   %            of programs
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                   %
\def\TopKeyWord{\@KyWrd{\@TopKW}}%                  %
%                                                   %
\def\MainKeyWord{\@KyWrd{\@MainKW}}%                %
%                                                   %
\def\FollowKeyWord{\@KyWrd{\@FollowKW}}%            %
%                                                   %
\def\BeginKeyWord{\@KyWrd{\@BeginKW}}%              %
%                                                   %
\def\IfLikeKeyWord{\@KyWrd{\@IfKW}}%                %
%                                                   %
\def\ThenLikeKeyWord{\@KyWrd{\@ThenKW}}%            %
%                                                   %
\def\ElseLikeKeyWord{\@KyWrd{\@ElseKW}}%            %
%                                                   %
\def\EndKeyWord{\@KyWrd{\@EndKW}}%                  %
%                                                   %
\def\PlainKeyWord{\@KyWrd{\@PlainKW}}%              %
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% The other main environment: "embedded program"
%% ---------------------
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                   %
\newenvironment{embeddedProgram}{%                  % LaTeX!
   \bgroup$%       % $ starts math                  %
   \catcode`\"12%                                   %
   \@ActivateSpecSymbs%                             %
   \EmbeddedProgramPrelude%                         %
   \@EmbeddedProgramPrelude%                        %
   \@@EmbeddedProgramPrelude%                       %
   \@Scan}{%                                        %
   \@EndScan%                                       %
   $\egroup%       % $ ends math                    %
   }%                                               %
%                                                   %
\def\({\begin{embeddedProgram}}%                    %
\def\){\end{embeddedProgram}}%                      %
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                   %
\def\@EmbeddedProgramPrelude{\relax}%               %
\def\@@EmbeddedProgramPrelude{%                     %
   \let\@KeyWord=\KeyWord%                          %
   \def\@TopKW##1##2{##2\@TrailSpace}%              %
   \def\@MainKW##1##2{##2\@TrailSpace}%             %
   \def\@FollowKW##1##2{\@LeadSpace##2\@TrailSpace}%%
   \def\@BeginKW##1##2{\@LeadSpace##2\@TrailSpace}% %
   \def\@IfKW##1##2{\@LeadSpace##2\@TrailSpace}%    %
   \def\@ThenKW##1##2{\@LeadSpace##2\@TrailSpace}%  %
   \def\@ElseKW##1##2{\@LeadSpace##2\@TrailSpace}%  %
   \def\@EndKW##1##2{\@LeadSpace##2\@TrailSpace}%   %
   \def\@PlainKW##1##2{\@LeadSpace##2\@TrailSpace}% %
   \Special@Macros%                                 %
   }%                                               %
%                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% end of file "basicprg.sty"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

