%
%  Let me explain how the template-generator works:
%
%  It goes down your list of column types, and for each one it
%  puts the template down.  It also defines something called
%  \b@tween that would go after this thing, but only if it ends
%  up between two fields (most often, an ampersand).
%
\expandafter\xdef\csname c@tcode\endcsname{\the\catcode`\@}
\catcode`\@=11
%
\def\t@bleparsechar{%
\let\n@xt=\t@bleparseend
\if\n@xttok l\t@blebetween\t@bleappend{\p@rm\hfil}\def\b@tween{&\ }%
\let\n@xt=\t@bleparseloop\fi
\if\n@xttok r\t@blebetween\t@bleappend{\hfil\ignorespaces\p@rm}%
\def\b@tween{&\ }\let\n@xt=\t@bleparseloop\fi
\if\n@xttok c\t@blebetween\t@bleappend{\hfil\ignorespaces\p@rm\hfil}%
\def\b@tween{&\ }\let\n@xt=\t@bleparseloop\fi
\if\n@xttok p\t@blebetween\let\n@xt=\t@bleparbox\def\b@tween{}\fi
\if\n@xttok |%
\ifx\b@tween\relax
\t@bleappend{\strut\vrule}\def\b@tween{\ }%
\else\t@bleappend{\ \strut\vrule}%
\expandafter\def\expandafter\b@tween\expandafter{\expandafter\ \b@tween}%
\fi
\let\n@xt=\t@bleparseloop\fi
\if\n@xttok\bgroup\t@blebetween\let\n@xt=\t@blelit\def\b@tween{}\fi
\if\n@xttok.\t@blebetween\t@bleappend{\catcode46=4% Make . a tab character
\hfil\p@rm\unskip.&\ignorespaces\p@rm\hfil}\def\b@tween{&\ }%
\let\n@xt=\t@bleparseloop\fi
%\if\n@xttok*\let\n@xt=\t@bleparseend\fi
\n@xt}
%
\def\t@bleparseerror{\errmessage{Error while parsing argument to "table"}}
\def\t@bleparse{\futurelet\n@xttok\t@bleparsechar}
\def\t@bleparseloop#1{\t@bleparse}
\def\t@blelit#1{\t@bleappend{#1}\t@bleparse}
\def\t@bleappend#1{\expandafter\def\expandafter\t@mp\expandafter{\t@mp #1}}
\def\t@blebetween{\expandafter\t@bleappend\expandafter{\b@tween}}
\def\t@bleparseend#1{}
\def\t@bleparbox p#1{\t@bleappend{\vtop{\hsize=#1\relax \p@rm}}%
\def\b@tween{&\ }\t@bleparse}
%
\def\table#1{\begingroup%
\smallskip
\let\hr@le\hrule \def\hrule{\noalign{\hr@le}}%
\let\b@tween=\relax
\catcode`\&=4\def\t@mp{}%
\t@bleparse #1*%
\def\p@rm{########}%
\edef\t@mp{\t@mp}%
\let\\=\cr%
%\show\t@mp
\halign\bgroup\span\t@mp\cr}
%
\def\endtable{\crcr\egroup\endgroup\smallskip}
%
\catcode`\&=12
\catcode`\@=\c@tcode
