%%
%% This is file `ted.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ted.dtx  (with options: `package')
%% 
%% ted package by Manuel P\'egouri\'e-Gonnard <mpg@elzevir.fr>
%% This is a generated file. See ted.dtx for license information.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ted}
  [2008/03/07 v1.06 \space a token list editor \space (mpg)]
\@ifdefinable\ted@toks{\newtoks\ted@toks}
\@ifdefinable\ted@list{\let\ted@list\toks@}
\@ifdefinable\ted@code{\let\ted@code\count@}
\@ifdefinable\ted@count{\newcount\ted@count}
\newcommand\ted@encloop{%
  \futurelet\@let@token
  \ted@encloop@}
\newcommand\ted@encloop@{%
  \let\next\ted@do@normal
  \ifx\@let@token\ted@@end
    \let\next\ted@gobble@end
  \fi
  \ifcat\noexpand\@let@token##%
    \ted@code0
    \let\next\ted@do@special
  \fi
  \ifcat\noexpand\@let@token\@sptoken
    \ted@code1
    \let\next\ted@do@special
  \fi
  \ifcat\noexpand\@let@token\bgroup
    \ted@code2
    \let\next\ted@do@special
  \fi
  \ifcat\noexpand\@let@token\egroup
    \ted@code3
    \let\next\ted@do@special
  \fi
  \next}
\newcommand\ted@@end{\ted@@end@}
\@ifdefinable\ted@gobble@end{%
  \def\ted@gobble@end\ted@@end{}}
\count@\catcode\z@ \catcode\z@\active
\newcommand\ted@sanitize{%
  \count@\z@ \@whilenum\count@<\@cclvi \do{%
    \uccode\z@\count@
    \uppercase{\let^^00\ted@@active}%
    \advance\count@\@ne}}
\catcode\z@\count@
\newcommand\ted@@active{\ted@@active@}
\newcommand\ted@encode[1]{%
  \ted@list{}%
  \let\ted@do@normal\ted@gobble@encloop
  \let\ted@do@special\ted@scan@special
  \ted@encloop#1\ted@@end
  \ted@toks{}%
  \let\ted@do@normal\ted@addtoks@encloop
  \let\ted@do@special\ted@special@out
  \ted@encloop#1\ted@@end
  \ted@assert@listempty}
\newcommand\ted@assert@listempty{%
  \edef\next{\the\ted@list}%
  \ifx\next\@empty \else
    \PackageError{ted}{%
      Assertion `\string\ted@list\space is empty' failed}{%
      This should not happen. Please report this bug to the author.
      \MessageBreak By the way, you're in trouble there... I'm sorry.}%
  \fi}
\newcommand\ted@gobble@encloop{%
  \afterassignment\ted@encloop
  \let\@let@token= }
\count@\catcode\z@ \catcode\z@ 12
\newcommand\ted@scan@special{%
  \begingroup
  \escapechar\if\@let@token^^00 \@ne \else \z@ \fi
  \expandafter\ted@check@space\string}
\catcode\z@\count@
\newcommand\ted@check@space{%
  \futurelet\@let@token
  \ted@check@space@}
\newcommand\ted@check@space@{%
  \ifcat\@let@token\@sptoken
    \endgroup
    \ted@addlist{32}%
    \expandafter\ted@gobble@encloop
  \else
    \expandafter\ted@list@special
  \fi}
\newcommand*\ted@list@special[1]{%
  \ted@code`#1\relax
  \expandafter\expandafter\expandafter
  \endgroup
  \ifnum\ted@code=\escapechar
    \ted@addlist{\m@ne}%
  \else
    \expandafter\ted@addlist\expandafter{\the\ted@code}%
  \fi
  \ted@encloop}
\newcommand*\ted@addlist[1]{%
  \ted@list\expandafter{\the\ted@list#1 }}
\newcommand\ted@addtoks@encloop[1]{%
  \ted@toks\expandafter{\the\ted@toks#1}%
  \ted@encloop}
\newcommand\ted@special@out{%
  \ifnum\ted@list@read=\m@ne
    \ted@list@advance
    \expandafter\ted@cs@clean
  \else
    \expandafter\ted@special@encode
  \fi}
\newcommand\ted@cs@clean[1]{%
  \expandafter\ted@add@toks{#1}%
  \expandafter\ted@cscl@loop\string#1 \@nil}
\@ifdefinable\ted@cscl@loop{%
  \def\ted@cscl@loop#1 {%
    \futurelet\@let@token
    \ted@cscl@loop@}}
\newcommand\ted@cscl@loop@{%
  \ifx\@let@token\@nil
    \expandafter\ted@gobble@encloop
  \else
    \ted@list@advance
    \expandafter\ted@cscl@loop
  \fi}
\newcommand\ted@special@encode{%
    \afterassignment\ted@special@encode@
  \let\@let@token= }
\newcommand\ted@special@encode@{%
  \expandafter\ted@special@encode@@\expandafter{%
    \csname ted@@\the\ted@code\ted@list@read\endcsname}}
\newcommand*\ted@special@encode@@[1]{%
  \ted@list@advance
  \let#1\ted@@special
  \ted@addtoks@encloop{#1}}
\newcommand\ted@@special{\ted@@special@}
\newcommand\ted@list@read{%
  \expandafter\ted@list@read@\the\ted@list\@nil}
\@ifdefinable\ted@list@read@{%
  \def\ted@list@read@#1 #2\@nil{%
    #1}}
\newcommand\ted@list@advance{%
  \expandafter\ted@list@advance@\the\ted@list\@nil}
\@ifdefinable\ted@list@advance@{
  \def\ted@list@advance@#1 #2\@nil{%
    \ted@list{#2}}}
\newcommand\ted@add@toks[1]{%
  \ted@toks\expandafter{\the\ted@toks#1}}
\newcommand\ted@decode[1]{%
  \ifx#1\ted@@end \expandafter\@gobble\else\expandafter\@firstofone\fi{%
    \ifx#1\ted@@special
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
    \fi{%
      \begingroup \escapechar\m@ne \expandafter\endgroup
      \expandafter\ted@decode@special\string#1\@nil
      }{%
      \ted@add@toks{#1}}%
    \ted@decode}}
\@ifdefinable\ted@decode@special{%
  \begingroup\escapechar\m@ne \expandafter\endgroup\expandafter
  \def\expandafter\ted@decode@special\string\ted@@#1#2\@nil{%
    \ifcase#1
      \begingroup \uccode`##=#2 \uppercase{\endgroup
        \ted@add@toks{##}}%
    \or
      \begingroup \uccode32=#2 \uppercase{\endgroup
        \ted@add@toks{ }}%
    \or
      \begingroup \ted@toks{}%
      \uccode`{=#2
    \or
      \uccode`}=#2
      \uppercase{\ted@toks\expandafter{\expandafter{\the\ted@toks}}}%
      \expandafter\endgroup
      \expandafter\ted@add@toks\expandafter{\the\ted@toks}%
    \fi}}
\newcommand\ted@Substitute[3]{%
  \begingroup \ted@sanitize
  \ted@encode{#3}%
  \expandafter\ted@def@subsmac\expandafter{\the\ted@toks}{#2}%
  \ted@encode{#1}%
  \ted@subsmac
  \ted@toks\expandafter{\expandafter}%
  \expandafter\ted@decode\the\ted@toks\ted@@end
  \expandafter\endgroup
  \expandafter\ted@output\expandafter{\the\ted@toks}}
\newcommand\ted@def@subsmac[2]{%
  \ted@encode{#2}%
  \long\expandafter\def\expandafter\ted@subsmac@loop
  \expandafter##\expandafter1\the\ted@toks##2{%
    \ted@add@toks{##1}%
    \ifx##2\ted@@end
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
    \fi{%
      \expandafter\ted@remove@nil\the\ted@toks
      }{%
      \global\advance\ted@count\@ne
      \ted@add@toks{#1}\ted@subsmac@loop##2}}%
  \expandafter\ted@def@subsmac@\expandafter{\the\ted@toks}}
\newcommand\ted@def@subsmac@[1]{%
  \def\ted@subsmac{%
    \global\ted@count\z@
    \ted@toks\expandafter{\expandafter}%
    \expandafter\ted@subsmac@loop\the\ted@toks\ted@@nil#1\ted@@end}}
\@ifdefinable\ted@remove@nil{%
  \long\def\ted@remove@nil#1\ted@@nil{%
    \ted@toks{#1}}}
\newcommand\ted@ShowTokens[1]{%
  \begingroup \ted@sanitize
  \ted@toks{#1}%
  \ted@typeout{--- Begin token decomposition of:}%
  \ted@typeout{\@spaces \the\ted@toks}%
  \ted@encode{#1}%
  \expandafter\ted@show@toks\the\ted@toks\ted@@end
  \endgroup
  \ted@typeout{--- End token decomposition.}}
\count@\catcode\z@ \catcode\z@ 12
\newcommand\ted@show@toks[1]{%
  \ted@toks{#1}\expandafter
  \ifx\the\ted@toks\ted@@end \else\expandafter
    \ifx\the\ted@toks\ted@@active
      \aftergroup\ted@type@active
      \expandafter\aftergroup\the\ted@toks
    \else
      \if\expandafter\noexpand\the\ted@toks\@sptoken
        \aftergroup\ted@type@normal
        \expandafter\aftergroup\the\ted@toks
      \else
        \begingroup
        \escapechar\if\noexpand#1^^00 \@ne \else \z@ \fi
        \expandafter\expandafter\expandafter\ted@show@toks@
        \expandafter\string\the\ted@toks\@nil
      \fi
    \fi
    \expandafter\ted@show@toks
  \fi}
\catcode\z@\count@
\@ifdefinable\ted@show@toks@{%
  \long\def\ted@show@toks@#1#2\@nil{%
    \expandafter\endgroup
    \ifnum`#1=\escapechar
      \expandafter\ifx\the\ted@toks\ted@@special
        \ted@show@special#2\@nil
      \else
        \aftergroup\ted@type@cs
        \expandafter\aftergroup\the\ted@toks
      \fi
    \else
      \aftergroup\ted@type@normal
      \expandafter\aftergroup\the\ted@toks
    \fi}}
\@ifdefinable\ted@show@special{%
  \begingroup\escapechar\m@ne \expandafter\endgroup
  \expandafter\def\expandafter\ted@show@special\string\ted@@#1#2\@nil{%
    \ifcase#1
      \aftergroup\ted@type@hash
    \or
      \aftergroup\ted@type@blank
    \or
      \aftergroup\ted@type@bgroup
    \or
      \aftergroup\ted@type@egroup
    \fi
    \begingroup \uccode`1#2
    \uppercase{\endgroup\aftergroup1}}}
\newcommand\ted@type@hash[1]{%
  \ted@typeout{#1 (macro parameter character #1)}}
\newcommand\ted@type@blank[1]{%
  \ted@typeout{#1 (blank space #1)}}
\newcommand\ted@type@bgroup[1]{%
  \ted@typeout{#1 (begin-group character #1)}}
\newcommand\ted@type@egroup[1]{%
  \ted@typeout{#1 (end-group character #1)}}
\newcommand\ted@type@normal[1]{%
  \ted@typeout{#1 (\meaning#1)}}
\newcommand\ted@type@cs[1]{%
  \ted@type@long{\string#1 (control sequence=\meaning#1}}%
\newcommand\ted@type@active[1]{%
  \ted@type@long{\string#1 (active character=\meaning#1}}%
\newcommand\ted@type@long[1]{%
  \ted@toks{}%
  \ted@code72
  \edef\next{#1}%
  \expandafter\ted@tl@loop\next\@nil}
\newcommand\ted@tl@loop{%
  \futurelet\@let@token
  \ted@tl@loop@}
\newcommand\ted@tl@loop@{%
  \ifx\@let@token\@nil
    \let\next\ted@tl@finish
  \else
    \advance\ted@code\m@ne
    \ifnum\ted@code<\z@
      \let\next\ted@tl@finish
    \else
      \ifx\@let@token\@sptoken
        \let\next\ted@tl@space
      \else
        \let\next\ted@tl@add
      \fi
    \fi
  \fi
  \next}
\newcommand*\ted@tl@add[1]{%
  \ted@toks\expandafter{\the\ted@toks #1}%
  \ted@tl@loop}
\@ifdefinable\ted@tl@space{%
  \expandafter\def\expandafter\ted@tl@space\space{%
    \ted@tl@add{ }}}
\@ifdefinable\ted@tl@finish{%
  \def\ted@tl@finish#1\@nil{%
    \ifnum\ted@code<\z@
      \ted@typeout{\the\ted@toks\string\ETC.)}
    \else
      \ted@typeout{\the\ted@toks)}
    \fi}}
\newcommand\ted@typeout{%
  \immediate\write\ted@outfile}
\newcommand\ShowTokensOnline{%
  \let\ted@outfile\@unused}
\newcommand\ShowTokensLogonly{%
  \let\ted@outfile\m@ne}
\ShowTokensOnline
\newcommand\ShowTokens{%
  \@ifstar{\ted@ShowTokens@exp}{\ted@ShowTokens}}
\newcommand\ted@ShowTokens@exp[1]{%
  \expandafter\ted@ShowTokens\expandafter{#1}}
\newcommand\Substitute{%
  \@ifstar
  {\ted@Subs@star}
  {\let\ted@Subs@cmd\ted@Substitute \ted@Subs}}
\newcommand\ted@Subs@star{%
  \@ifstar
  {\let\ted@Subs@cmd\ted@Subs@exp@iii \ted@Subs}
  {\let\ted@Subs@cmd\ted@Subs@exp@i \ted@Subs}}
\newcommand\ted@Subs@exp@i{%
  \expandafter\ted@Substitute\expandafter}
\newcommand\ted@Subs@exp@iii[3]{%
  \begingroup
  \toks0{\ted@Substitute}%
  \toks2\expandafter{#1}%
  \toks4\expandafter{#2}%
  \toks6\expandafter{#3}%
  \xdef\ted@Subs@cmd{\the\toks0{\the\toks2}{\the\toks4}{\the\toks6}}%
  \endgroup
  \ted@Subs@cmd}
\newcommand\ted@Subs[1][\ted@toks]{%
  \def\ted@output{#1}%
  \ted@Subs@cmd}
\let\ted@output\ted@toks
\endinput
%%
%% End of file `ted.sty'.