%%
%% This is file `expkv-def.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% expkv-def.dtx  (with options: `tex')
%% 
%% --------------------------------------------------------------
%% expkv-def -- a key-defining frontend for expkv
%% E-mail: jspratte@yahoo.de
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% --------------------------------------------------------------
%% 
%% Copyright (C) 2020-2022 Jonathan P. Spratte
%% 
%% This  work may be  distributed and/or  modified under  the conditions  of the
%% LaTeX Project Public License (LPPL),  either version 1.3c  of this license or
%% (at your option) any later version.  The latest version of this license is in
%% the file:
%% 
%%   http://www.latex-project.org/lppl.txt
%% 
%% This work is "maintained" (as per LPPL maintenance status) by
%%   Jonathan P. Spratte.
%% 
%% This work consists of the file  expkv-def.dtx
%% and the derived files           expkv-def.pdf
%%                                 expkv-def.sty
%%                                 expkv-def.tex
%%                                 t-expkv-def.tex
%% 
\input expkv
\expandafter\ifx\csname ekvdVersion\endcsname\relax
\else
  \expandafter\endinput
\fi
\def\ekvdVersion{0.9}
\def\ekvdDate{2022-01-29}
\csname ekvd@tmp\endcsname
\expandafter\chardef\csname ekvd@tmp\endcsname=\catcode`\@
\catcode`\@=11
\protected\long\def\ekvd@ifprimitive#1%
  {%
    \begingroup
      \edef\ekvd@tmpa{\string #1}%
      \edef\ekvd@tmpb{\meaning#1}%
      \expandafter
    \endgroup
    \ifx\ekvd@tmpa\ekvd@tmpb
      \ekv@fi@firstoftwo
    \fi
    \@secondoftwo
  }
\protected\def\ekvd@clear@prefixes
  {%
    \let\ekvd@long\ekv@empty
    \let\ekvd@prot\ekv@empty
    \let\ekvd@ifalso\@secondoftwo
    \long\def\ekvd@ifnew##1##2##3{##3}%
  }
\ekvd@clear@prefixes
\protected\def\ekvdefinekeys#1%
  {%
    \def\ekvd@set{#1}%
    \ekvparse\ekvd@noarg\ekvd@arg
  }
\protected\long\def\ekvd@noarg#1%
  {%
    \let\ekvd@ifnoarg\@firstoftwo
    \expandafter\ekvd@handle\detokenize{#1}\ekvd@stop{}%
  }
\protected\long\def\ekvd@arg#1%
  {%
    \let\ekvd@ifnoarg\@secondoftwo
    \expandafter\ekvd@handle\detokenize{#1}\ekvd@stop
  }
\protected\long\def\ekvd@handle#1\ekvd@stop#2%
  {%
    \ekvd@clear@prefixes
    \def\ekvd@cur{#1}%
    \ekvd@ifspace{#1}%
      {\ekvd@prefix\ekv@mark#1\ekv@stop{#2}}%
      \ekvd@err@missing@type
  }
\protected\def\ekvd@prefix#1 {\ekv@strip{#1}\ekvd@prefix@\ekv@mark}
\protected\def\ekvd@prefix@#1#2\ekv@stop
  {%
    \ekv@ifdefined{ekvd@t@#1}%
      {\ekv@strip{#2}{\csname ekvd@t@#1\endcsname}}%
      {%
        \ekv@ifdefined{ekvd@p@#1}%
          {\csname ekvd@p@#1\endcsname\ekvd@prefix@after@p{#2}}%
          {\ekvd@err@undefined@prefix{#1}\@gobble}%
      }%
  }
\protected\def\ekvd@prefix@after@p#1%
  {%
    \ekvd@ifspace{#1}%
      {\ekvd@prefix#1\ekv@stop}%
      {\ekvd@err@missing@type\@gobble}%
  }
\protected\def\ekvd@p@long{\let\ekvd@long\long}
\protected\def\ekvd@p@protected{\let\ekvd@prot\protected}
\let\ekvd@p@protect\ekvd@p@protected
\protected\def\ekvd@p@also{\let\ekvd@ifalso\@firstoftwo}
\protected\def\ekvd@p@new{\let\ekvd@ifnew\ekvd@assert@new}
\protected\def\ekvd@type@set#1#2%
  {%
    \ekvd@assert@not@long
    \ekvd@assert@not@protected
    \ekvd@ifnew{NoVal}{#1}%
      {%
        \ekv@ifempty{#2}%
          {\ekvd@err@missing@definition}%
          {%
            \ekvd@ifalso
              {%
                \ekv@expargtwice{\ekvd@add@noval{#1}}%
                  {\ekvchangeset{#2}}%
                  \ekvd@assert@not@protected@also
              }%
              {\ekv@expargtwice{\ekvdefNoVal\ekvd@set{#1}}{\ekvchangeset{#2}}}%
          }%
      }%
  }
\protected\def\ekvd@t@set#1#2%
  {%
    \ekvd@ifnoarg
      {\ekvd@type@set{#1}{#1}}%
      {\ekvd@type@set{#1}{#2}}%
  }
\protected\long\def\ekvd@type@noval#1#2#3%
  {%
    \ekvd@ifnew{NoVal}{#2}%
      {%
        \ekvd@assert@arg
          {%
            \ekvd@assert@not@long
            \ekvd@prot#1\ekvd@tmp{#3}%
            \ekvd@ifalso
              {\ekv@exparg{\ekvd@add@noval{#2}}\ekvd@tmp{}}%
              {\ekvletNoVal\ekvd@set{#2}\ekvd@tmp}%
          }%
      }%
  }
\protected\def\ekvd@t@noval{\ekvd@type@noval\def}
\protected\def\ekvd@t@enoval{\ekvd@type@noval\edef}
\protected\long\def\ekvd@type@code#1#2#3%
  {%
    \ekvd@ifnew{}{#2}%
      {%
        \ekvd@assert@arg
          {%
            \ekvd@prot\ekvd@long#1\ekvd@tmp##1{#3}%
            \ekvd@ifalso
              {\ekv@exparg{\ekvd@add@val{#2}}{\ekvd@tmp{##1}}{}}%
              {\ekvlet\ekvd@set{#2}\ekvd@tmp}%
          }%
      }%
  }
\protected\def\ekvd@t@code{\ekvd@type@code\def}
\protected\def\ekvd@t@ecode{\ekvd@type@code\edef}
\protected\long\def\ekvd@type@default#1#2#3#4%
  {%
    \ekvd@assert@arg
      {%
        \ekvifdefined\ekvd@set{#3}%
          {%
            \ekvd@assert@not@new
            \ekvd@assert@not@long
            \ekvd@prot\edef\ekvd@tmp
              {%
                \ekv@unexpanded\expandafter#1%
                  {#2\csname\ekv@name\ekvd@set{#3}\endcsname{#4}}%
              }%
            \ekvd@ifalso
              {\ekv@exparg{\ekvd@add@noval{#3}}\ekvd@tmp{}}%
              {\ekvletNoVal\ekvd@set{#3}\ekvd@tmp}%
          }%
          {\ekvd@err@undefined@key{#3}}%
      }%
  }
\protected\def\ekvd@t@default{\ekvd@type@default{}{}}
\protected\def\ekvd@t@qdefault{\ekvd@type@default{\expandafter\expandafter}{}}
\let\ekvd@t@odefault\ekvd@t@qdefault
\protected\def\ekvd@t@fdefault{\ekvd@type@default{}{\romannumeral`\^^@}}
\protected\long\def\ekvd@t@edefault#1#2%
  {%
    \ekvd@assert@arg
      {%
        \ekvifdefined\ekvd@set{#1}%
          {%
            \ekvd@assert@not@new
            \ekvd@assert@not@long
            \ekvd@prot\edef\ekvd@tmp
              {\csname\ekv@name\ekvd@set{#1}\endcsname{#2}}%
            \ekvd@ifalso
              {\ekv@exparg{\ekvd@add@noval{#1}}\ekvd@tmp{}}%
              {\ekvletNoVal\ekvd@set{#1}\ekvd@tmp}%
          }%
          {\ekvd@err@undefined@key{#1}}%
      }%
  }
\long\def\ekvd@type@initial#1#2#3#4%
  {%
    \ekvd@assert@not@new
    \ekvd@assert@not@also
    \ekvd@assert@not@long
    \ekvd@assert@not@protected
    \ekvd@ifnoarg
      {%
        \ekvifdefinedNoVal\ekvd@set{#3}%
          {\csname\ekv@name\ekvd@set{#3}N\endcsname}%
          {\ekvd@err@undefined@noval{#3}}%
      }%
      {%
        \ekvifdefined\ekvd@set{#3}%
          {%
            #1{#2#4}%
            \csname\ekv@name\ekvd@set{#3}\expandafter\endcsname\expandafter
              {\ekvd@tmp}%
          }%
          {\ekvd@err@undefined@key{#3}}%
      }%
  }
\def\ekvd@t@initial{\ekvd@type@initial{\def\ekvd@tmp}{}}
\def\ekvd@t@oinitial{\ekvd@type@initial{\ekv@exparg{\def\ekvd@tmp}}{}}
\def\ekvd@t@einitial{\ekvd@type@initial{\edef\ekvd@tmp}{}}
\def\ekvd@t@finitial
  {\ekvd@type@initial{\ekv@exparg{\def\ekvd@tmp}}{\romannumeral`\^^@}}
\protected\def\ekvd@type@bool#1#2#3#4#5%
  {%
    \ekvd@ifnew{}{#4}%
      {%
        \ekvd@ifnew{NoVal}{#4}%
          {%
            \ekvd@assert@filledarg{#5}%
              {%
                \ekvd@newlet#5#3%
                \ekvd@type@choice{#4}%
                \protected\ekvdefNoVal\ekvd@set{#4}{#1\let#5#2}%
                \protected\expandafter\def
                  \csname\ekvd@choice@name\ekvd@set{#4}{true}\endcsname
                  {#1\let#5#2}%
                \protected\expandafter\def
                  \csname\ekvd@choice@name\ekvd@set{#4}{false}\endcsname
                  {#1\let#5#3}%
              }%
          }%
      }%
  }
\protected\def\ekvd@t@bool{\ekvd@type@bool{}\iftrue\iffalse}
\protected\def\ekvd@t@gbool{\ekvd@type@bool\global\iftrue\iffalse}
\protected\def\ekvd@t@boolTF{\ekvd@type@bool{}\@firstoftwo\@secondoftwo}
\protected\def\ekvd@t@gboolTF{\ekvd@type@bool\global\@firstoftwo\@secondoftwo}
\protected\def\ekvd@t@invbool{\ekvd@type@bool{}\iffalse\iftrue}
\protected\def\ekvd@t@ginvbool{\ekvd@type@bool\global\iffalse\iftrue}
\protected\def\ekvd@t@invboolTF{\ekvd@type@bool{}\@secondoftwo\@firstoftwo}
\protected\def\ekvd@t@ginvboolTF
  {\ekvd@type@bool\global\@secondoftwo\@firstoftwo}
\protected\def\ekvd@type@boolpair#1#2#3#4#5#6%
  {%
    \ekvd@ifnew{}{#4}%
      {%
        \ekvd@ifnew{NoVal}{#4}%
          {%
            \ekvd@newlet#5#3%
            \ekvd@newlet#6#2%
            \ekvd@type@choice{#4}%
            \protected\ekvdefNoVal\ekvd@set{#4}{#1\let#5#2#1\let#6#3}%
            \protected\expandafter\def
              \csname\ekvd@choice@name\ekvd@set{#4}{true}\endcsname
              {#1\let#5#2#1\let#6#3}%
            \protected\expandafter\def
              \csname\ekvd@choice@name\ekvd@set{#4}{false}\endcsname
              {#1\let#5#3#1\let#6#2}%
          }%
      }%
  }
\protected\def\ekvd@t@boolpair#1#2%
  {\ekvd@assert@twoargs{#2}{\ekvd@type@boolpair{}\iftrue\iffalse{#1}#2}}
\protected\def\ekvd@t@gboolpair#1#2%
  {\ekvd@assert@twoargs{#2}{\ekvd@type@boolpair\global\iftrue\iffalse{#1}#2}}
\protected\def\ekvd@t@boolpairTF#1#2%
  {%
    \ekvd@assert@twoargs{#2}%
      {\ekvd@type@boolpair{}\@firstoftwo\@secondoftwo{#1}#2}%
  }
\protected\def\ekvd@t@gboolpairTF#1#2%
  {%
    \ekvd@assert@twoargs{#2}%
      {\ekvd@type@boolpair\global\@firstoftwo\@secondoftwo{#1}#2}%
  }
\protected\def\ekvd@type@data#1#2#3#4#5#6%
  {%
    \ekvd@ifnew{}{#5}%
      {%
        \ekvd@assert@filledarg{#6}%
          {%
            \ekvd@newlet#6#1%
            \ekvd@ifalso
              {%
                \let\ekvd@prot\protected
                \ekvd@add@val{#5}{\long#2#6####1#3{####1{#4}}}{}%
              }%
              {%
                \protected\ekvd@long\ekvdef\ekvd@set{#5}%
                  {\long#2#6####1#3{####1{#4}}}%
              }%
          }%
      }%
  }
\protected\def\ekvd@t@data
  {\ekvd@type@data\@secondoftwo\edef{####2}{\ekv@unexpanded{##1}}}
\protected\def\ekvd@t@edata{\ekvd@type@data\@secondoftwo\edef{####2}{##1}}
\protected\def\ekvd@t@gdata
  {\ekvd@type@data\@secondoftwo\xdef{####2}{\ekv@unexpanded{##1}}}
\protected\def\ekvd@t@xdata{\ekvd@type@data\@secondoftwo\xdef{####2}{##1}}
\protected\def\ekvd@t@dataT
  {\ekvd@type@data\@gobble\edef{}{\ekv@unexpanded{##1}}}
\protected\def\ekvd@t@edataT{\ekvd@type@data\@gobble\edef{}{##1}}
\protected\def\ekvd@t@gdataT
  {\ekvd@type@data\@gobble\xdef{}{\ekv@unexpanded{##1}}}
\protected\def\ekvd@t@xdataT{\ekvd@type@data\@gobble\xdef{}{##1}}
\protected\def\ekvd@type@box#1#2#3%
  {%
    \ekvd@ifnew{}{#2}%
      {%
        \ekvd@assert@filledarg{#3}%
          {%
            \ekvd@newreg#3{box}%
            \ekvd@ifalso
              {%
                \let\ekvd@prot\protected
                \ekvd@add@val{#2}{#1\setbox#3=\hbox{\begingroup##1\endgroup}}{}%
              }%
              {%
                \protected\ekvd@long\ekvdef\ekvd@set{#2}%
                  {#1\setbox#3=\hbox{\begingroup##1\endgroup}}%
              }%
          }%
      }%
  }
\protected\def\ekvd@t@box{\ekvd@type@box{}}
\protected\def\ekvd@t@gbox{\ekvd@type@box\global}
\protected\def\ekvd@type@toks#1#2#3%
  {%
    \ekvd@ifnew{}{#2}%
      {%
        \ekvd@assert@filledarg{#3}%
          {%
            \ekvd@newreg#3{toks}%
            \ekvd@ifalso
              {%
                \let\ekvd@prot\protected
                \ekvd@add@val{#2}{#1#3={##1}}{}%
              }%
              {\protected\ekvd@long\ekvdef\ekvd@set{#2}{#1#3={##1}}}%
          }%
      }%
  }
\protected\def\ekvd@t@toks{\ekvd@type@toks{}}
\protected\def\ekvd@t@gtoks{\ekvd@type@toks\global}
\ekvd@ifprimitive\toksapp
  {%
    \protected\def\ekvd@type@preapptoks#1#2#3%
      {%
        \ekvd@ifnew{}{#2}%
          {%
            \ekvd@assert@filledarg{#3}%
              {%
                \ekvd@newreg#3{toks}%
                \ekvd@ifalso
                  {%
                    \let\ekvd@prot\protected
                    \ekvd@add@val{#2}{#1#3{##1}}{}%
                  }%
                  {\protected\ekvd@long\ekvdef\ekvd@set{#2}{#1#3{##1}}}%
              }%
          }%
      }
    \protected\def\ekvd@t@apptoks{\ekvd@type@preapptoks\toksapp}
    \protected\def\ekvd@t@gapptoks{\ekvd@type@preapptoks\gtoksapp}
    \protected\def\ekvd@t@pretoks{\ekvd@type@preapptoks\tokspre}
    \protected\def\ekvd@t@gpretoks{\ekvd@type@preapptoks\gtokspre}
  }
  {%
    \protected\def\ekvd@type@apptoks#1#2#3%
      {%
        \ekvd@ifnew{}{#2}%
          {%
            \ekvd@assert@filledarg{#3}%
              {%
                \ekvd@newreg#3{toks}%
                \ekvd@ifalso
                  {%
                    \let\ekvd@prot\protected
                    \ekvd@add@val{#2}{#1#3=\expandafter{\the#3##1}}{}%
                  }%
                  {%
                    \protected\ekvd@long\ekvdef\ekvd@set{#2}%
                      {#1#3=\expandafter{\the#3##1}}%
                  }%
              }%
          }%
      }
    \protected\def\ekvd@t@apptoks{\ekvd@type@apptoks{}}
    \protected\def\ekvd@t@gapptoks{\ekvd@type@apptoks\global}
    \newtoks\ekvd@toks
    \protected\def\ekvd@type@pretoks#1#2#3%
      {%
        \ekvd@ifnew{}{#2}%
          {%
            \ekvd@assert@filledarg{#3}%
              {%
                \ekvd@newreg#3{toks}%
                \ekvd@ifalso
                  {%
                    \let\ekvd@prot\protected
                    \ekvd@add@val{#2}%
                      {%
                        \ekvd@toks={##1}%
                        #1#3=\expandafter{\the\expandafter\ekvd@toks\the#3}%
                      }%
                      {}%
                  }%
                  {%
                    \protected\ekvd@long\ekvdef\ekvd@set{#2}%
                      {%
                        \ekvd@toks={##1}%
                        #1#3=\expandafter{\the\expandafter\ekvd@toks\the#3}%
                      }%
                  }%
              }%
          }%
      }
    \protected\def\ekvd@t@pretoks{\ekvd@type@pretoks{}}
    \protected\def\ekvd@t@gpretoks{\ekvd@type@pretoks\global}
  }
\protected\def\ekvd@type@reg#1#2#3#4#5#6%
  {%
    \ekvd@ifnew{}{#5}%
      {%
        \ekvd@assert@filledarg{#6}%
          {%
            \ekvd@newreg#6{#1}%
            \ekvd@ifalso
              {%
                \let\evkd@prot\protected
                \ekvd@add@val{#5}{#2#6=#3##1#4\relax}{}%
              }%
              {\protected\ekvd@long\ekvdef\ekvd@set{#5}{#2#6=#3##1#4\relax}}%
          }%
      }%
  }
\protected\def\ekvd@t@int{\ekvd@type@reg{count}{}{}{}}
\protected\def\ekvd@t@eint{\ekvd@type@reg{count}{}\numexpr\relax}
\protected\def\ekvd@t@gint{\ekvd@type@reg{count}\global{}{}}
\protected\def\ekvd@t@xint{\ekvd@type@reg{count}\global\numexpr\relax}
\protected\def\ekvd@t@dimen{\ekvd@type@reg{dimen}{}{}{}}
\protected\def\ekvd@t@edimen{\ekvd@type@reg{dimen}{}\dimexpr\relax}
\protected\def\ekvd@t@gdimen{\ekvd@type@reg{dimen}\global{}{}}
\protected\def\ekvd@t@xdimen{\ekvd@type@reg{dimen}\global\dimexpr\relax}
\protected\def\ekvd@t@skip{\ekvd@type@reg{skip}{}{}{}}
\protected\def\ekvd@t@eskip{\ekvd@type@reg{skip}{}\glueexpr\relax}
\protected\def\ekvd@t@gskip{\ekvd@type@reg{skip}\global{}{}}
\protected\def\ekvd@t@xskip{\ekvd@type@reg{skip}\global\glueexpr\relax}
\protected\def\ekvd@type@store#1#2#3#4%
  {%
    \ekvd@ifnew{}{#3}%
      {%
        \ekvd@assert@filledarg{#4}%
          {%
            \ekvd@newlet#4\ekv@empty
            \ekvd@ifalso
              {%
                \let\ekvd@prot\protected
                \ekvd@add@val{#3}{#1#4{#2}}{}%
              }%
              {\protected\ekvd@long\ekvdef\ekvd@set{#3}{#1#4{#2}}}%
          }%
      }%
  }
\protected\def\ekvd@t@store{\ekvd@type@store\edef{\ekv@unexpanded{##1}}}
\protected\def\ekvd@t@gstore{\ekvd@type@store\xdef{\ekv@unexpanded{##1}}}
\protected\def\ekvd@t@estore{\ekvd@type@store\edef{##1}}
\protected\def\ekvd@t@xstore{\ekvd@type@store\xdef{##1}}
\protected\long\def\ekvd@type@meta#1#2#3#4#5#6#7%
  {%
    \ekvd@ifnew{#1}{#6}%
      {%
        \ekvd@assert@filledarg{#7}%
          {%
            \edef\ekvd@tmp{\ekvd@set}%
            \expandafter\ekvd@type@meta@a\expandafter{\ekvd@tmp}{#7}{#2}%
            \ekvd@ifalso
              {\ekv@exparg{#3{#6}}{\ekvd@tmp#4}{#5}}%
              {\csname ekvlet#1\endcsname\ekvd@set{#6}\ekvd@tmp}%
          }%
      }%
  }
\protected\long\def\ekvd@type@meta@a#1#2%
  {%
    \expandafter\ekvd@type@meta@b\expandafter{\ekvset{#1}{#2}}%
  }
\protected\def\ekvd@type@meta@b
  {%
    \expandafter\ekvd@type@meta@c\expandafter
  }
\protected\long\def\ekvd@type@meta@c#1#2%
  {%
    \ekvd@prot\ekvd@long\def\ekvd@tmp#2{#1}%
  }
\protected\def\ekvd@t@meta{\ekvd@type@meta{}{##1}\ekvd@add@val{{##1}}{}}
\protected\def\ekvd@t@nmeta
  {%
    \ekvd@assert@not@long
    \ekvd@type@meta{NoVal}{}\ekvd@add@noval{}\ekvd@assert@not@long@also
  }
\protected\long\def\ekvd@type@smeta#1#2#3#4#5#6#7%
  {%
    \ekvd@ifnew{#1}{#6}%
      {%
        \ekvd@assert@twoargs{#7}%
          {%
            \ekvd@type@meta@a#7{#2}%
            \ekvd@ifalso
              {\ekv@exparg{#3{#6}}{\ekvd@tmp#4}{#5}}%
              {\csname ekvlet#1\endcsname\ekvd@set{#6}\ekvd@tmp}%
          }%
      }%
  }
\protected\def\ekvd@t@smeta{\ekvd@type@smeta{}{##1}\ekvd@add@val{{##1}}{}}
\protected\def\ekvd@t@snmeta
  {%
    \ekvd@assert@not@long
    \ekvd@type@smeta{NoVal}{}\ekvd@add@noval{}\ekvd@assert@not@long@also
  }
\protected\def\ekvd@type@choice#1%
  {%
    \ekvd@assert@not@long
    \ekv@expargtwice{\ekvd@prot\def\ekvd@tmp##1}%
      {%
        \expandafter\expandafter\expandafter
        \ekvd@h@choice
        \expandafter\expandafter\expandafter
          {\expandafter\ekvd@choice@name\expandafter{\ekvd@set}{#1}{##1}}%
      }%
    \ekvd@ifalso
      {%
        \ekvd@assert@val{#1}%
          {%
            \ekvd@if@not@already@choice{#1}%
              {%
                \ekv@exparg
                  {%
                    \expandafter\ekvd@add@aux
                      \csname\ekv@name\ekvd@set{#1}\endcsname{{##1}}{#1}%
                  }%
                  {\ekvd@tmp{##1}}%
                  {\ekvd@long\ekvdef}\ekvd@assert@not@long@also
              }%
          }%
      }%
      {\ekvlet\ekvd@set{#1}\ekvd@tmp}%
  }
\protected\def\ekvd@populate@choice
  {%
    \ekvparse\ekvd@populate@choice@noarg\ekvd@populate@choice@
  }
\protected\long\def\ekvd@populate@choice@noarg#1%
  {%
    \expandafter\ekvd@err@missing@definition@msg\expandafter{\ekvd@cur : #1}%
  }
\protected\long\def\ekvd@populate@choice@#1#2%
  {%
    \ekvd@clear@prefixes
    \ekvd@ifspace{#1}%
      {\ekvd@choice@prefix{\ekv@mark#1}\ekv@mark#1\ekv@stop}%
      {%
        \expandafter\edef
          \csname\ekvd@choice@name\ekvd@set\ekvd@set@choice{#1}\endcsname
      }%
      {\unexpanded{#2}}%
  }
\protected\def\ekvd@choice@prefix#1#2
  {%
    \ekv@strip{#2}{\ekvd@choice@prefix@{#1}}\ekv@mark
  }
\protected\def\ekvd@choice@prefix@#1#2#3\ekv@stop
  {%
    \ekv@ifdefined{ekvd@choice@p@#2}%
      {%
        \csname ekvd@choice@p@#2\endcsname
        \ekvd@ifspace{#3}%
          {\ekvd@choice@prefix{#3}#3\ekv@stop}%
          {\ekvd@choice@prefix@done{#3}}%
      }%
      {\ekvd@choice@prefix@done{#1}}%
  }
\protected\def\ekvd@choice@prefix@done#1%
  {%
    \ekvd@prot\expandafter\edef
      \csname
        \ekv@strip{#1}{\ekvd@choice@name\ekvd@set\ekvd@set@choice}%
      \endcsname
  }
\protected\def\ekvd@choice@p@protected{\let\ekvd@prot\protected}
\let\ekvd@choice@p@protect\ekvd@choice@p@protected
\protected\def\ekvd@choice@invalid@p#1\ekvd@ifspace#2%
  {%
    \expandafter\ekvd@choice@invalid@p@\expandafter{\ekv@gobble@mark#2}{#1}%
    \ekvd@ifspace{#2}%
  }
\protected\def\ekvd@choice@invalid@p@#1#2%
  {%
    \expandafter\ekvd@err@no@prefix@msg\expandafter{\ekvd@cur : #2 #1}{#2}%
  }
\protected\def\ekvd@choice@p@long{\ekvd@choice@invalid@p{long}}%
\protected\def\ekvd@choice@p@also{\ekvd@choice@invalid@p{also}}%
\protected\def\ekvd@choice@p@new{\ekvd@choice@invalid@p{new}}%
\protected\long\def\ekvd@t@choice#1#2%
  {%
    \ekvd@ifnew{}{#1}%
      {%
        \ekvd@assert@arg
          {%
            \ekvd@type@choice{#1}%
            \def\ekvd@set@choice{#1}%
            \ekvd@populate@choice{#2}%
          }%
      }%
  }
\protected\long\expandafter\def\csname ekvd@t@choice-store\endcsname
  {\ekvd@type@choicespecial\ekvd@populate@choicestore}
\protected\long\expandafter\def\csname ekvd@t@choice-enum\endcsname
  {\ekvd@type@choicespecial\ekvd@populate@choiceenum}
\protected\long\def\ekvd@type@choicespecial#1#2#3%
  {%
    \ekvd@ifnew{}{#2}%
      {%
        \ekvd@assert@twoargs{#3}%
          {%
            \ekvd@type@choice{#2}%
            \def\ekvd@set@choice{#2}%
            #1#3%
          }%
      }%
  }
\protected\long\def\ekvd@populate@choicestore#1%
  {%
    \ekvd@newlet#1\ekv@empty
    \ekvcsvloop{\ekvd@populate@choicestore@#1}%
  }
\protected\long\def\ekvd@populate@choicestore@#1#2%
  {%
    \protected\expandafter\edef
      \csname\ekvd@choice@name\ekvd@set\ekvd@set@choice{#2}\endcsname
      {\unexpanded{\edef#1{\unexpanded{#2}}}}%
  }
\protected\long\def\ekvd@populate@choiceenum#1%
  {%
    \ekvd@newreg#1{count}%
    \def\ekvd@tmp{0}%
    \ekvcsvloop{\ekvd@populate@choiceenum@#1}%
  }
\protected\long\def\ekvd@populate@choiceenum@#1#2%
  {%
    \protected\expandafter\edef
      \csname\ekvd@choice@name\ekvd@set\ekvd@set@choice{#2}\endcsname
      {#1=\@firstofone{\ekvd@tmp} }%
    \edef\ekvd@tmp{\the\numexpr\ekvd@tmp+1\relax}%
  }
\protected\long\expandafter\def\csname ekvd@t@unknown-choice\endcsname#1#2%
  {%
    \ekvd@assert@new@for@name{\ekvd@unknown@choice@name\ekvd@set{#1}}%
      {%
        \ekvd@assert@arg
          {%
            \ekvd@assert@not@long
            \ekvd@assert@not@also
            \ekvd@prot\expandafter
            \def\csname\ekvd@unknown@choice@name\ekvd@set{#1}\endcsname##1{#2}%
          }%
      }%
  }
\protected\long\def\ekvd@t@unknown#1#2%
  {%
    \ekv@ifdefined{ekvd@type@unknown@\detokenize{#1}}%
      {\csname ekvd@type@unknown@\detokenize{#1}\endcsname{#2}}%
      \ekvd@err@misused@unknown
  }
\protected\long\def\ekvd@type@unknown@noval#1%
  {%
    \ekvd@assert@new@for@name{\ekv@name\ekvd@set{}uN}%
      {%
        \ekvd@assert@arg
          {%
            \ekvd@assert@not@also
            \ekvd@assert@not@long
            \ekvd@prot\ekvdefunknownNoVal\ekvd@set{#1}%
          }%
      }%
  }
\protected\long\def\ekvd@type@unknown@code#1%
  {%
    \ekvd@assert@new@for@name{\ekv@name\ekvd@set{}u}%
      {%
        \ekvd@assert@arg
          {%
            \ekvd@assert@not@also
            \begingroup
              \def\ekvd@tmp##1##2{#1}%
              \ekv@exparg
              {%
                \endgroup
                \ekvd@prot\ekvd@long\ekvdefunknown\ekvd@set
              }%
              {\ekvd@tmp{##2}{##1}}%
          }%
      }%
  }
\protected\edef\ekvd@type@unknown@redirect#1%
  {%
    \expandafter\noexpand\csname ekvd@type@unknown@redirect-code\endcsname{#1}%
    \expandafter\noexpand\csname ekvd@type@unknown@redirect-noval\endcsname{#1}%
  }
\protected\expandafter\def\csname ekvd@type@unknown@redirect-code\endcsname#1%
  {%
    \ekvd@assert@new@for@name{\ekv@name\ekvd@set{}u}%
      {%
        \ekvd@assert@arg
          {%
            \ekvd@assert@not@also
            \ekvd@assert@not@protected
            \expandafter\ekvredirectunknown\expandafter{\ekvd@set}{#1}%
          }%
      }%
  }
\protected\expandafter\def\csname ekvd@type@unknown@redirect-noval\endcsname#1%
  {%
    \ekvd@assert@new@for@name{\ekv@name\ekvd@set{}uN}%
      {%
        \ekvd@assert@arg
          {%
            \ekvd@assert@not@also
            \ekvd@assert@not@protected
            \ekvd@assert@not@long
            \expandafter\ekvredirectunknownNoVal\expandafter{\ekvd@set}{#1}%
          }%
      }%
  }
\def\ekvd@h@choice#1%
  {%
    \expandafter\ekvd@h@choice@
      \csname\ifcsname#1\endcsname#1\else relax\fi\endcsname
      {#1}%
  }
\def\ekvd@h@choice@#1#2%
  {%
    \ifx#1\relax
      \ekvd@err@choice@invalid{#2}%
      \expandafter\@gobble
    \fi
    #1%
  }
\protected\long\def\ekvd@add@val#1#2#3%
  {%
    \ekvd@assert@val{#1}%
      {%
        \expandafter\ekvd@add@aux\csname\ekv@name\ekvd@set{#1}\endcsname{{##1}}%
          {#1}{#2}{\ekvd@long\ekvdef}{#3}%
      }%
  }
\protected\long\def\ekvd@add@noval#1#2#3%
  {%
    \ekvd@assert@noval{#1}%
      {%
        \expandafter\ekvd@add@aux\csname\ekv@name\ekvd@set{#1}N\endcsname{}%
          {#1}{#2}\ekvdefNoVal{#3}%
      }%
  }
\protected\long\def\ekvd@add@aux#1#2%
  {%
    \ekvd@extract@prefixes#1%
    \expandafter\ekvd@add@aux@\expandafter{#1#2}%
  }
\protected\long\def\ekvd@add@aux@#1#2#3#4#5%
  {%
    #5%
    \ekvd@prot#4\ekvd@set{#2}{#1#3}%
  }
\protected\def\ekvd@extract@prefixes#1%
  {%
    \expandafter\ekvd@extract@prefixes@\meaning#1\ekvd@stop
  }
\protected\def\ekvd@extract@prefixes@#1#2#3%
  {%
    \protected\def\ekvd@extract@prefixes@##1#1##2\ekvd@stop
      {%
        \ekvd@extract@prefixes@long
          ##1\ekvd@mark\@firstofone#2\ekvd@mark\@gobble\ekvd@stop
          {\let\ekvd@long\long}%
        \ekvd@extract@prefixes@prot
          ##1\ekvd@mark\@firstofone#3\ekvd@mark\@gobble\ekvd@stop
          {\let\ekvd@prot\protected}%
      }%
    \protected\def\ekvd@extract@prefixes@long##1#2##2\ekvd@mark##3##4\ekvd@stop
      {##3}%
    \protected\def\ekvd@extract@prefixes@prot##1#3##2\ekvd@mark##3##4\ekvd@stop
      {##3}%
  }
\begingroup
\edef\ekvd@tmp
  {%
    \endgroup
    \ekvd@extract@prefixes@
      {\detokenize{macro:}}%
      {\string\long}%
      {\string\protected}%
  }
\ekvd@tmp
\protected\def\ekvd@newlet#1#2%
  {%
    \ifdefined#1\ekv@fi@gobble\fi\@firstofone{\let#1#2}%
  }
\protected\def\ekvd@newreg#1#2%
  {%
    \ifdefined#1\ekv@fi@gobble\fi\@firstofone{\csname new#2\endcsname#1}%
  }
\long\def\ekvd@assert@twoargs#1%
  {%
    \ekvd@ifnottwoargs{#1}{\ekvd@err@missing@definition}%
  }
\long\def\ekvd@ifnottwoargs#1%
  {%
    \ekvd@ifempty@gtwo#1\ekv@ifempty@B
      \ekv@ifempty@false\ekv@ifempty@A\ekv@ifempty@B\@firstoftwo
  }
\long\def\ekvd@ifempty@gtwo#1#2{\ekv@ifempty@\ekv@ifempty@A}
\protected\def\ekvd@assert@val#1%
  {%
    \ekvifdefined\ekvd@set{#1}%
      {\expandafter\ekvd@assert@val@\csname\ekv@name\ekvd@set{#1}\endcsname}%
      {%
        \ekvifdefinedNoVal\ekvd@set{#1}%
          \ekvd@err@add@val@on@noval
          {\ekvd@err@undefined@key{#1}}%
        \@gobble
      }%
  }
\protected\def\ekvd@assert@val@#1%
  {%
    \expandafter\ekvd@extract@args\meaning#1\ekvd@stop
    \unless\ifx\ekvd@extracted@args\ekvd@one@arg@string
      \ekvd@err@unsupported@arg
    \fi
    \@firstofone
  }%
\protected\def\ekvd@assert@noval#1%
  {%
    \ekvifdefinedNoVal\ekvd@set{#1}%
      {\expandafter\ekvd@assert@noval@\csname\ekv@name\ekvd@set{#1}N\endcsname}%
      {%
        \ekvifdefined\ekvd@set{#1}%
          \ekvd@err@add@noval@on@val
          {\ekvd@err@undefined@key{#1}}%
        \@gobble
      }%
  }
\protected\def\ekvd@assert@noval@#1%
  {%
    \expandafter\ekvd@extract@args\meaning#1\ekvd@stop
    \unless\ifx\ekvd@extracted@args\ekv@empty
      \ekvd@err@unsupported@arg
    \fi
    \@firstofone
  }
\protected\def\ekvd@extract@args#1%
  {%
    \protected\def\ekvd@extract@args##1#1##2->##3\ekvd@stop
      {\def\ekvd@extracted@args{##2}}%
  }
\expandafter\ekvd@extract@args\expandafter{\detokenize{macro:}}
\edef\ekvd@one@arg@string{\string#1}
\def\ekvd@assert@arg{\ekvd@ifnoarg\ekvd@err@missing@definition}
\long\def\ekvd@assert@arg@msg#1%
  {%
    \ekvd@ifnoarg{\ekvd@err@missing@definition@msg{#1}}%
  }
\long\def\ekvd@assert@filledarg#1%
  {%
    \ekvd@ifnoarg@or@empty{#1}\ekvd@err@missing@definition
  }
\long\def\ekvd@ifnoarg@or@empty#1%
  {%
    \ekvd@ifnoarg
      \@firstoftwo
      {\ekv@ifempty{#1}}%
  }
\def\ekvd@assert@not@long{\ifx\ekvd@long\long\ekvd@err@no@prefix{long}\fi}
\def\ekvd@assert@not@protected
  {\ifx\ekvd@prot\protected\ekvd@err@no@prefix{protected}\fi}
\def\ekvd@assert@not@also{\ekvd@ifalso{\ekvd@err@no@prefix{also}}{}}
\def\ekvd@assert@not@long@also
  {\ifx\ekvd@long\long\ekvd@err@no@prefix@also{long}\fi}
\def\ekvd@assert@not@protected@also
  {\ifx\ekvd@prot\protected\ekvd@err@no@prefix@also{protected}\fi}
\def\ekvd@assert@new#1#2%
  {\csname ekvifdefined#1\endcsname\ekvd@set{#2}{\ekvd@err@not@new}}
\def\ekvd@assert@not@new
  {\ifx\ekvd@ifnew\ekvd@assert@new\ekvd@err@no@prefix{new}\fi}
\def\ekvd@assert@new@for@name#1%
  {%
    \ifx\ekvd@ifnew\ekvd@assert@new
      \ekv@fi@firstoftwo
    \fi
    \@secondoftwo
      {\ekv@ifdefined{#1}\ekvd@err@not@new}%
      \@firstofone
  }
\protected\def\ekvd@if@not@already@choice#1%
  {%
    \expandafter\ekvd@if@not@already@choice@a
      \csname\ekv@name\ekvd@set{#1}\endcsname
      {}\ekvd@h@choice\ekvd@stop
  }
\protected\def\ekvd@if@not@already@choice@a
  {%
    \expandafter\ekvd@if@not@already@choice@b
  }
\long\protected\def\ekvd@if@not@already@choice@b#1\ekvd@h@choice#2\ekvd@stop
  {%
    \ekv@ifempty{#2}\@firstofone\@gobble
  }
\long\def\ekvd@ifspace#1%
  {%
    \ekvd@ifspace@#1 \ekv@ifempty@B
      \ekv@ifempty@false\ekv@ifempty@A\ekv@ifempty@B\@firstoftwo
  }
\long\def\ekvd@ifspace@#1 % keep this space
  {%
    \ekv@ifempty@\ekv@ifempty@A
  }
\protected\def\ekvd@errm#1{\errmessage{expkv-def Error: #1}}
\protected\def\ekvd@err@missing@definition
  {\ekvd@errm{Missing definition for key `\ekvd@cur'}}
\protected\def\ekvd@err@missing@definition@msg#1%
  {\ekvd@errm{Missing definition for key `\ekv@unexpanded{#1}'}}
\protected\def\ekvd@err@missing@type
  {\ekvd@errm{Missing type prefix for key `\ekvd@cur'}}
\protected\def\ekvd@err@undefined@prefix#1%
  {%
    \ekvd@errm
      {%
        Undefined prefix `\ekv@unexpanded{#1}' found while processing
        `\ekvd@cur'%
      }%
  }
\protected\def\ekvd@err@undefined@key#1%
  {%
    \ekvd@errm
      {Undefined key `\ekv@unexpanded{#1}' found while processing `\ekvd@cur'}%
  }
\protected\def\ekvd@err@undefined@noval#1%
  {%
    \ekvd@errm
      {%
        Undefined noval key `\unexpanded{#1}' found while processing
        `\ekvd@cur'%
      }%
  }
\protected\def\ekvd@err@no@prefix#1%
  {\ekvd@errm{prefix `#1' not accepted in `\ekvd@cur'}}
\protected\def\ekvd@err@no@prefix@msg#1#2%
  {\ekvd@errm{prefix `#2' not accepted in `\ekv@unexpanded{#1}'}}
\protected\def\ekvd@err@no@prefix@also#1%
  {\ekvd@errm{`\ekvd@cur' not allowed with a `#1' key}}
\protected\def\ekvd@err@add@val@on@noval
  {\ekvd@errm{`\ekvd@cur' not allowed with a NoVal key}}
\protected\def\ekvd@err@add@noval@on@val
  {\ekvd@errm{`\ekvd@cur' not allowed with a value taking key}}
\protected\def\ekvd@err@unsupported@arg\fi\@firstofone#1%
  {%
    \fi
    \ekvd@errm
      {%
        Existing key-macro has the unsupported argument string
        `\ekvd@extracted@args' for key `\ekvd@cur'%
      }%
  }
\protected\def\ekvd@err@not@new
  {\ekvd@errm{The key for `\ekvd@cur' is already defined}}
\protected\long\def\ekvd@err@misused@unknown
  {\ekvd@errm{Misuse of the unknown type found while processing `\ekvd@cur'}}
\def\ekvd@err@choice@invalid#1%
  {%
    \ekvd@err@choice@invalid@#1%
  }
\begingroup
\catcode40=8
\catcode41=8
\@firstofone{\endgroup
\def\ekvd@choice@name#1#2#3%
  {%
    ekvd#1(#2)\detokenize{#3}%
  }
\def\ekvd@unknown@choice@name#1#2%
  {%
    ekvd:u:#1(#2)%
  }
\def\ekvd@err@choice@invalid@ ekvd#1(#2)\detokenize#3%
  {%
    \ekv@ifdefined{\ekvd@unknown@choice@name{#1}{#2}}%
      {\csname\ekvd@unknown@choice@name{#1}{#2}\endcsname{#3}}%
      {\ekvd@err{invalid choice `#3' for `#2' in set `#1'}}%
  }
}
\ekv@exparg{\long\def\ekvd@err#1}{\ekverr{expkv-def}{#1}}
\catcode`\@=\ekvd@tmp
%% 
%%
%% End of file `expkv-def.tex'.
