% \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 % %\fi