1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
% \iffalse meta-comment
%
% Copyright (C) 2008-2014 by Ulrich M. Schwarz
% Copyright (C) 2019 by Frank Mittelbach
% Copyright (C) 2020- by Yukai Chou
%
% This file may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, version 1.3c.
% The license can be obtained from
% http://www.latex-project.org/lppl/lppl-1-3c.txt
%
% \fi
%
%\iffalse (hide this from DocInput)
%<*parseargs>
%\fi
%
% The main command provided by the package is |\parse|\marg{spec}.
% \emph{spec} consists of groups of commands. Each group should set up the
% command |\@parsecmd| which is then run. The important point is that
% |\@parsecmd| will pick up its arguments from the running text, not from
% the rest of \emph{spec}. When it's done storing the arguments,
% |\@parsecmd| must call |\@parse| to continue with the next element of
% \emph{spec}. The process terminates when we run out of spec.
%
% Helper macros are provided for the three usual argument types: mandatory,
% optional, and flag.
%
%\StopEventually{}
% \begin{macrocode}
\newtoks\@parsespec
\def\parse@endquark{\parse@endquark}
\newcommand\parse[1]{%
\@parsespec{#1\parse@endquark}\@parse}
\newcommand\@parse{%
\edef\p@tmp{\the\@parsespec}%
\ifx\p@tmp\parse@endquark
\expandafter\@gobble
\else
% \typeout{parsespec remaining: \the\@parsespec}%
\expandafter\@firstofone
\fi{%
\@parsepop
}%
}
\def\@parsepop{%
\expandafter\p@rsepop\the\@parsespec\@nil
\@parsecmd
}
\def\p@rsepop#1#2\@nil{%
#1%
\@parsespec{#2}%
}
\newcommand\parseOpt[4]{%
%\parseOpt{openchar}{closechar}{yes}{no}
% \typeout{attemping #1#2...}%
\def\@parsecmd{%
\@ifnextchar#1{\@@reallyparse}{#4\@parse}%
}%
\def\@@reallyparse#1##1#2{%
#3\@parse
}%
}
\newcommand\parseMand[1]{%
%\parseMand{code}
\def\@parsecmd##1{#1\@parse}%
}
\newcommand\parseFlag[3]{%
%\parseFlag{flagchar}{yes}{no}
\def\@parsecmd{%
\@ifnextchar#1{#2\expandafter\@parse\@gobble}{#3\@parse}%
}%
}
% \end{macrocode}
%\iffalse
%</parseargs>
%\fi
|