diff options
author | Norbert Preining <norbert@preining.info> | 2020-09-08 03:02:12 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-09-08 03:02:12 +0000 |
commit | bc2d0660f4f460b55009ab4e525f2a0e4cde6187 (patch) | |
tree | d35815089faf23c45f4f21690e42cfcc7c65a5fd /macros/latex | |
parent | 57edbaffbe7daad894e3036a4123acd03e0fdb9b (diff) |
CTAN sync 202009080302
Diffstat (limited to 'macros/latex')
96 files changed, 10095 insertions, 4937 deletions
diff --git a/macros/latex/contrib/l3kernel/CHANGELOG.md b/macros/latex/contrib/l3kernel/CHANGELOG.md index c3fe7c7141..1c8206f28f 100644 --- a/macros/latex/contrib/l3kernel/CHANGELOG.md +++ b/macros/latex/contrib/l3kernel/CHANGELOG.md @@ -7,9 +7,12 @@ this project uses date-based 'snapshot' version identifiers. ## [Unreleased] -## [2020-09-03] +## [2020-09-06] + +### Fixed +- Loading in generic mode (issue #800) -## [2020-01-03] +## [2020-09-03] ### Fixed - Save primitive definition of `\pdfoutput` with CSLaTeX @@ -762,9 +765,9 @@ this project uses date-based 'snapshot' version identifiers. - Step functions have been added for dim variables, e.g. `\dim_step_inline:nnnn` -[Unreleased]: https://github.com/latex3/latex3/compare/2020-09-03...HEAD -[2020-09-03]: https://github.com/latex3/latex3/compare/2020-01-03...2020-09-03 -[2020-01-03]: https://github.com/latex3/latex3/compare/2020-09-01...2020-01-03 +[Unreleased]: https://github.com/latex3/latex3/compare/2020-09-06...HEAD +[2020-09-06]: https://github.com/latex3/latex3/compare/2020-09-03...2020-09-06 +[2020-09-03]: https://github.com/latex3/latex3/compare/2020-09-01...2020-09-03 [2020-09-01]: https://github.com/latex3/latex3/compare/2020-08-07...2020-09-01 [2020-08-07]: https://github.com/latex3/latex3/compare/2020-07-17...2020-08-07 [2020-07-17]: https://github.com/latex3/latex3/compare/2020-06-18...2020-07-17 diff --git a/macros/latex/contrib/l3kernel/README.md b/macros/latex/contrib/l3kernel/README.md index 0bcb85a677..d90d237fe6 100644 --- a/macros/latex/contrib/l3kernel/README.md +++ b/macros/latex/contrib/l3kernel/README.md @@ -1,7 +1,7 @@ LaTeX3 Programming Conventions ============================== -Release 2020-09-03 +Release 2020-09-06 Overview -------- diff --git a/macros/latex/contrib/l3kernel/expl3.dtx b/macros/latex/contrib/l3kernel/expl3.dtx index 25639b4690..140e507b63 100644 --- a/macros/latex/contrib/l3kernel/expl3.dtx +++ b/macros/latex/contrib/l3kernel/expl3.dtx @@ -24,7 +24,7 @@ % %<*driver|generic|package|2ekernel> %</driver|generic|package|2ekernel> -\def\ExplFileDate{2020-09-03}% +\def\ExplFileDate{2020-09-06}% %<*driver> \documentclass[full]{l3doc} \usepackage{graphicx} @@ -51,7 +51,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % @@ -1065,13 +1065,23 @@ % It seems to be common to have stray format files in the user tree % which trigger errors due to mismatched versions (\emph{e.g.} % \url{https://github.com/latex3/latex3/issues/781}). +% +% This block also goes to the generic loader, as \pkg{expl3} isn't +% preloaded there, so the kernel date should be equal to the loader +% date. % \begin{macrocode} -%<*2ekernel> -\unless\ifcsname\detokenize{c__kernel_expl_date_tl}\endcsname - \global\expandafter\let\csname\detokenize - {c__kernel_expl_date_tl}\endcsname\ExplFileDate -\fi -%</2ekernel> +%<*2ekernel|generic> +\begingroup + \catcode`\>=12 + \def\aux#1>{} + \def\auxi{c__kernel_expl_date_tl}% + \edef\auxi{\expandafter\aux\meaning\auxi}% + \expandafter + \ifx\csname\auxi\endcsname\relax + \global\expandafter\let\csname\auxi\endcsname\ExplFileDate + \fi +\endgroup +%</2ekernel|generic> % \end{macrocode} % \end{macro} % diff --git a/macros/latex/contrib/l3kernel/expl3.pdf b/macros/latex/contrib/l3kernel/expl3.pdf Binary files differindex eea5fcfaff..b48b54946a 100644 --- a/macros/latex/contrib/l3kernel/expl3.pdf +++ b/macros/latex/contrib/l3kernel/expl3.pdf diff --git a/macros/latex/contrib/l3kernel/interface3.pdf b/macros/latex/contrib/l3kernel/interface3.pdf Binary files differindex 43115927b3..79ba503768 100644 --- a/macros/latex/contrib/l3kernel/interface3.pdf +++ b/macros/latex/contrib/l3kernel/interface3.pdf diff --git a/macros/latex/contrib/l3kernel/interface3.tex b/macros/latex/contrib/l3kernel/interface3.tex index 213ccdbca2..8a163631f1 100644 --- a/macros/latex/contrib/l3kernel/interface3.tex +++ b/macros/latex/contrib/l3kernel/interface3.tex @@ -54,7 +54,7 @@ for those people who are interested. {latex-team@latex-project.org}% }% } -\date{Released 2020-09-03} +\date{Released 2020-09-06} \pagenumbering{roman} \maketitle diff --git a/macros/latex/contrib/l3kernel/l3basics.dtx b/macros/latex/contrib/l3kernel/l3basics.dtx index cbc62b895a..b167eb6dcf 100644 --- a/macros/latex/contrib/l3kernel/l3basics.dtx +++ b/macros/latex/contrib/l3kernel/l3basics.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3bootstrap.dtx b/macros/latex/contrib/l3kernel/l3bootstrap.dtx index ee955fcd4d..810de9812c 100644 --- a/macros/latex/contrib/l3kernel/l3bootstrap.dtx +++ b/macros/latex/contrib/l3kernel/l3bootstrap.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3box.dtx b/macros/latex/contrib/l3kernel/l3box.dtx index e890c7c931..d3a00d00f3 100644 --- a/macros/latex/contrib/l3kernel/l3box.dtx +++ b/macros/latex/contrib/l3kernel/l3box.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3candidates.dtx b/macros/latex/contrib/l3kernel/l3candidates.dtx index 55dc608771..7c745269ec 100644 --- a/macros/latex/contrib/l3kernel/l3candidates.dtx +++ b/macros/latex/contrib/l3kernel/l3candidates.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3cctab.dtx b/macros/latex/contrib/l3kernel/l3cctab.dtx index 1f00ceda74..79f1f45fcd 100644 --- a/macros/latex/contrib/l3kernel/l3cctab.dtx +++ b/macros/latex/contrib/l3kernel/l3cctab.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3clist.dtx b/macros/latex/contrib/l3kernel/l3clist.dtx index b8169e2847..b125b7f2f8 100644 --- a/macros/latex/contrib/l3kernel/l3clist.dtx +++ b/macros/latex/contrib/l3kernel/l3clist.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3coffins.dtx b/macros/latex/contrib/l3kernel/l3coffins.dtx index 186bd2c60f..849eddaaea 100644 --- a/macros/latex/contrib/l3kernel/l3coffins.dtx +++ b/macros/latex/contrib/l3kernel/l3coffins.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3color-base.dtx b/macros/latex/contrib/l3kernel/l3color-base.dtx index 462b452ab2..f34fab4020 100644 --- a/macros/latex/contrib/l3kernel/l3color-base.dtx +++ b/macros/latex/contrib/l3kernel/l3color-base.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3debug.dtx b/macros/latex/contrib/l3kernel/l3debug.dtx index ecea4a9e77..5a214de133 100644 --- a/macros/latex/contrib/l3kernel/l3debug.dtx +++ b/macros/latex/contrib/l3kernel/l3debug.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3deprecation.dtx b/macros/latex/contrib/l3kernel/l3deprecation.dtx index 1e39888d48..be0f204446 100644 --- a/macros/latex/contrib/l3kernel/l3deprecation.dtx +++ b/macros/latex/contrib/l3kernel/l3deprecation.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3doc.dtx b/macros/latex/contrib/l3kernel/l3doc.dtx index 01a08a806e..60f5e465c3 100644 --- a/macros/latex/contrib/l3kernel/l3doc.dtx +++ b/macros/latex/contrib/l3kernel/l3doc.dtx @@ -79,7 +79,7 @@ and all files in that bundle must be distributed together. % % \title{The \cls{l3doc} class} % \author{\Team} -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % \maketitle % \tableofcontents % diff --git a/macros/latex/contrib/l3kernel/l3docstrip.dtx b/macros/latex/contrib/l3kernel/l3docstrip.dtx index de570c03a6..c0e139cb3b 100644 --- a/macros/latex/contrib/l3kernel/l3docstrip.dtx +++ b/macros/latex/contrib/l3kernel/l3docstrip.dtx @@ -63,7 +63,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3docstrip.pdf b/macros/latex/contrib/l3kernel/l3docstrip.pdf Binary files differindex a11d13f2de..6eaac9700b 100644 --- a/macros/latex/contrib/l3kernel/l3docstrip.pdf +++ b/macros/latex/contrib/l3kernel/l3docstrip.pdf diff --git a/macros/latex/contrib/l3kernel/l3expan.dtx b/macros/latex/contrib/l3kernel/l3expan.dtx index 38f75a3584..41af274e8b 100644 --- a/macros/latex/contrib/l3kernel/l3expan.dtx +++ b/macros/latex/contrib/l3kernel/l3expan.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3file.dtx b/macros/latex/contrib/l3kernel/l3file.dtx index bbfd23957f..67d708da28 100644 --- a/macros/latex/contrib/l3kernel/l3file.dtx +++ b/macros/latex/contrib/l3kernel/l3file.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % @@ -3597,37 +3597,43 @@ kpsewhich ~ --all ~ --engine = \c_sys_engine_exec_str \c_space_tl \c_sys_engine_format_str - \tl_if_empty:NF \development@branch@name { -dev } .fmt + \bool_lazy_and:nnF + { \tl_if_exist_p:N \development@branch@name } + { ! \tl_if_empty_p:N \development@branch@name } + { -dev } .fmt } \seq_clear:N \l_@@_tmp_seq \ior_map_inline:Nn \g_@@_internal_ior { \seq_put_right:Nn \l_@@_tmp_seq {##1} } \ior_close:N \g_@@_internal_ior + \__kernel_msg_error:nnnn { kernel } { mismatched-support-file } + {#1} {#2} % \end{macrocode} -% Now define a some shorthands so that we can use \cs{@latex@error} -% (almost) easily: +% And finish by ending the current file. % \begin{macrocode} - \group_begin: - \cs_set:Npn \\ { \MessageBreak } - \cs_set_eq:NN \ \c_space_tl - \@latex@error - { - Mismatched~LaTeX~support~files~detected. \\ - Loading~'#2'~aborted! + \tex_endinput:D + } +% \begin{macrocode} +% +% Now define the actual error message: +% \begin{macrocode} +\__kernel_msg_new:nnnn { kernel } { mismatched-support-file } + { + Mismatched~LaTeX~support~files~detected. \\ + Loading~'#2'~aborted! % \end{macrocode} % \cs{c__kernel_expl_date_tl} may not exist, due to an older format, % so only print the dates when the sentinel token list exists: % \begin{macrocode} - \tl_if_exist:NT \c__kernel_expl_date_tl - { - \\ \\ - The~L3~programming~layer~in~the~LaTeX~format \\ - is~dated~\c__kernel_expl_date_tl,~but~in~your~TeX~ - tree~the~files~require \\ at~least~#1. - } - \use_none:n - } - { + \tl_if_exist:NT \c__kernel_expl_date_tl + { + \\ \\ + The~L3~programming~layer~in~the~LaTeX~format \\ + is~dated~\c__kernel_expl_date_tl,~but~in~your~TeX~ + tree~the~files~require \\ at~least~#1. + } + } + { % \end{macrocode} % The sequence containing the format files should have exactly one % item: the format file currently being run. If that's the case, the @@ -3636,31 +3642,25 @@ % the list to the user, with appropriate indications of what's in the % system and what's in the user tree. % \begin{macrocode} - \int_compare:nNnTF { \seq_count:N \l_@@_tmp_seq } > 1 - { - The~cause~seems~to~be~an~old~format~file~in~the~user~tree. \\ - LaTeX~found~these~files: - \seq_map_tokens:Nn \l_@@_tmp_seq { \\~-~\use:n } \\ - Try~deleting~the~file~in~the~user~tree~then~run~LaTeX~again. - } - { - The~most~likely~causes~are: - \\~-~A~recent~format~generation~failed; - \\~-~A~stray~format~file~in~the~user~tree~which~needs~ - to~be~removed~or~rebuilt; - \\~-~You~are~running~a~manually~installed~version~of~#2 \\ - \ \ \ which~is~incompatible~with~the~version~in~LaTeX. \\ - } - \\ - LaTeX~will~abort~loading~the~incompatible~support~files~ - but~this~may~lead~to \\ later~errors.~Please~ensure~that~ - your~LaTeX~format~is~correctly~regenerated. - } - \group_end: -% \end{macrocode} -% And finish by ending the current file. -% \begin{macrocode} - \tex_endinput:D + \int_compare:nNnTF { \seq_count:N \l_@@_tmp_seq } > 1 + { + The~cause~seems~to~be~an~old~format~file~in~the~user~tree. \\ + LaTeX~found~these~files: + \seq_map_tokens:Nn \l_@@_tmp_seq { \\~-~\use:n } \\ + Try~deleting~the~file~in~the~user~tree~then~run~LaTeX~again. + } + { + The~most~likely~causes~are: + \\~-~A~recent~format~generation~failed; + \\~-~A~stray~format~file~in~the~user~tree~which~needs~ + to~be~removed~or~rebuilt; + \\~-~You~are~running~a~manually~installed~version~of~#2 \\ + \ \ \ which~is~incompatible~with~the~version~in~LaTeX. \\ + } + \\ + LaTeX~will~abort~loading~the~incompatible~support~files~ + but~this~may~lead~to \\ later~errors.~Please~ensure~that~ + your~LaTeX~format~is~correctly~regenerated. } % \end{macrocode} % \end{macro} diff --git a/macros/latex/contrib/l3kernel/l3flag.dtx b/macros/latex/contrib/l3kernel/l3flag.dtx index 1051a13cfc..697a9bd0de 100644 --- a/macros/latex/contrib/l3kernel/l3flag.dtx +++ b/macros/latex/contrib/l3kernel/l3flag.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-assign.dtx b/macros/latex/contrib/l3kernel/l3fp-assign.dtx index dcf1a91a57..4635d8a5af 100644 --- a/macros/latex/contrib/l3kernel/l3fp-assign.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-assign.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % \maketitle % % \begin{documentation} diff --git a/macros/latex/contrib/l3kernel/l3fp-aux.dtx b/macros/latex/contrib/l3kernel/l3fp-aux.dtx index b493e809d9..a01a2aa3a3 100644 --- a/macros/latex/contrib/l3kernel/l3fp-aux.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-aux.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-basics.dtx b/macros/latex/contrib/l3kernel/l3fp-basics.dtx index 2d917ea017..e0a2b26b1a 100644 --- a/macros/latex/contrib/l3kernel/l3fp-basics.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-basics.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-convert.dtx b/macros/latex/contrib/l3kernel/l3fp-convert.dtx index 4c38963d42..a18213f911 100644 --- a/macros/latex/contrib/l3kernel/l3fp-convert.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-convert.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-expo.dtx b/macros/latex/contrib/l3kernel/l3fp-expo.dtx index c59e18e17b..b7e4e1bb29 100644 --- a/macros/latex/contrib/l3kernel/l3fp-expo.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-expo.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-extended.dtx b/macros/latex/contrib/l3kernel/l3fp-extended.dtx index 27d603f026..f801c860b5 100644 --- a/macros/latex/contrib/l3kernel/l3fp-extended.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-extended.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-logic.dtx b/macros/latex/contrib/l3kernel/l3fp-logic.dtx index 131652e9b6..daf38c1a39 100644 --- a/macros/latex/contrib/l3kernel/l3fp-logic.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-logic.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-parse.dtx b/macros/latex/contrib/l3kernel/l3fp-parse.dtx index 3f407c59d8..0753398abc 100644 --- a/macros/latex/contrib/l3kernel/l3fp-parse.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-parse.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-random.dtx b/macros/latex/contrib/l3kernel/l3fp-random.dtx index 10cdb8f6ee..4b86d9aa07 100644 --- a/macros/latex/contrib/l3kernel/l3fp-random.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-random.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-round.dtx b/macros/latex/contrib/l3kernel/l3fp-round.dtx index 5ec8f14fd9..76400b3bac 100644 --- a/macros/latex/contrib/l3kernel/l3fp-round.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-round.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-traps.dtx b/macros/latex/contrib/l3kernel/l3fp-traps.dtx index 010e56cb70..6948b7104a 100644 --- a/macros/latex/contrib/l3kernel/l3fp-traps.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-traps.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % \maketitle % % \begin{documentation} diff --git a/macros/latex/contrib/l3kernel/l3fp-trig.dtx b/macros/latex/contrib/l3kernel/l3fp-trig.dtx index db1eb4cd03..3719dd113d 100644 --- a/macros/latex/contrib/l3kernel/l3fp-trig.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-trig.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp.dtx b/macros/latex/contrib/l3kernel/l3fp.dtx index c6a59f5673..f19f21c1c3 100644 --- a/macros/latex/contrib/l3kernel/l3fp.dtx +++ b/macros/latex/contrib/l3kernel/l3fp.dtx @@ -49,7 +49,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fparray.dtx b/macros/latex/contrib/l3kernel/l3fparray.dtx index 5f7659ee98..449f786201 100644 --- a/macros/latex/contrib/l3kernel/l3fparray.dtx +++ b/macros/latex/contrib/l3kernel/l3fparray.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3int.dtx b/macros/latex/contrib/l3kernel/l3int.dtx index efb01e35c3..02c29627da 100644 --- a/macros/latex/contrib/l3kernel/l3int.dtx +++ b/macros/latex/contrib/l3kernel/l3int.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3intarray.dtx b/macros/latex/contrib/l3kernel/l3intarray.dtx index 226d69667f..e41a839d39 100644 --- a/macros/latex/contrib/l3kernel/l3intarray.dtx +++ b/macros/latex/contrib/l3kernel/l3intarray.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3kernel-functions.dtx b/macros/latex/contrib/l3kernel/l3kernel-functions.dtx index 5a1ece81d9..e73b8d6c55 100644 --- a/macros/latex/contrib/l3kernel/l3kernel-functions.dtx +++ b/macros/latex/contrib/l3kernel/l3kernel-functions.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3keys.dtx b/macros/latex/contrib/l3kernel/l3keys.dtx index 0cfd1eabbb..812b0941e1 100644 --- a/macros/latex/contrib/l3kernel/l3keys.dtx +++ b/macros/latex/contrib/l3kernel/l3keys.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3legacy.dtx b/macros/latex/contrib/l3kernel/l3legacy.dtx index 0ad9794d44..0dcb0a5cb6 100644 --- a/macros/latex/contrib/l3kernel/l3legacy.dtx +++ b/macros/latex/contrib/l3kernel/l3legacy.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3luatex.dtx b/macros/latex/contrib/l3kernel/l3luatex.dtx index 8f9b25e4b0..b8f00b1187 100644 --- a/macros/latex/contrib/l3kernel/l3luatex.dtx +++ b/macros/latex/contrib/l3kernel/l3luatex.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3msg.dtx b/macros/latex/contrib/l3kernel/l3msg.dtx index 0bcddab852..748aa87885 100644 --- a/macros/latex/contrib/l3kernel/l3msg.dtx +++ b/macros/latex/contrib/l3kernel/l3msg.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3names.dtx b/macros/latex/contrib/l3kernel/l3names.dtx index 1c65f6839c..08dad0f48d 100644 --- a/macros/latex/contrib/l3kernel/l3names.dtx +++ b/macros/latex/contrib/l3kernel/l3names.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3news.pdf b/macros/latex/contrib/l3kernel/l3news.pdf Binary files differindex a511841ae9..c33a4eeb9b 100644 --- a/macros/latex/contrib/l3kernel/l3news.pdf +++ b/macros/latex/contrib/l3kernel/l3news.pdf diff --git a/macros/latex/contrib/l3kernel/l3news01.pdf b/macros/latex/contrib/l3kernel/l3news01.pdf Binary files differindex 03331351d2..3c03c1e8aa 100644 --- a/macros/latex/contrib/l3kernel/l3news01.pdf +++ b/macros/latex/contrib/l3kernel/l3news01.pdf diff --git a/macros/latex/contrib/l3kernel/l3news02.pdf b/macros/latex/contrib/l3kernel/l3news02.pdf Binary files differindex 3df2abeff5..837f5d75a7 100644 --- a/macros/latex/contrib/l3kernel/l3news02.pdf +++ b/macros/latex/contrib/l3kernel/l3news02.pdf diff --git a/macros/latex/contrib/l3kernel/l3news03.pdf b/macros/latex/contrib/l3kernel/l3news03.pdf Binary files differindex 03f24f254d..1ff9ae5d1d 100644 --- a/macros/latex/contrib/l3kernel/l3news03.pdf +++ b/macros/latex/contrib/l3kernel/l3news03.pdf diff --git a/macros/latex/contrib/l3kernel/l3news04.pdf b/macros/latex/contrib/l3kernel/l3news04.pdf Binary files differindex 38342aa9b6..b1338bc9b7 100644 --- a/macros/latex/contrib/l3kernel/l3news04.pdf +++ b/macros/latex/contrib/l3kernel/l3news04.pdf diff --git a/macros/latex/contrib/l3kernel/l3news05.pdf b/macros/latex/contrib/l3kernel/l3news05.pdf Binary files differindex 42aa52c844..c23deb667e 100644 --- a/macros/latex/contrib/l3kernel/l3news05.pdf +++ b/macros/latex/contrib/l3kernel/l3news05.pdf diff --git a/macros/latex/contrib/l3kernel/l3news06.pdf b/macros/latex/contrib/l3kernel/l3news06.pdf Binary files differindex d819c31935..3baec319d1 100644 --- a/macros/latex/contrib/l3kernel/l3news06.pdf +++ b/macros/latex/contrib/l3kernel/l3news06.pdf diff --git a/macros/latex/contrib/l3kernel/l3news07.pdf b/macros/latex/contrib/l3kernel/l3news07.pdf Binary files differindex e4f86d86a3..95a233af7a 100644 --- a/macros/latex/contrib/l3kernel/l3news07.pdf +++ b/macros/latex/contrib/l3kernel/l3news07.pdf diff --git a/macros/latex/contrib/l3kernel/l3news08.pdf b/macros/latex/contrib/l3kernel/l3news08.pdf Binary files differindex 94963487b3..b7c4726818 100644 --- a/macros/latex/contrib/l3kernel/l3news08.pdf +++ b/macros/latex/contrib/l3kernel/l3news08.pdf diff --git a/macros/latex/contrib/l3kernel/l3news09.pdf b/macros/latex/contrib/l3kernel/l3news09.pdf Binary files differindex 565221a7f6..ae6753d976 100644 --- a/macros/latex/contrib/l3kernel/l3news09.pdf +++ b/macros/latex/contrib/l3kernel/l3news09.pdf diff --git a/macros/latex/contrib/l3kernel/l3news10.pdf b/macros/latex/contrib/l3kernel/l3news10.pdf Binary files differindex 412459b151..2891b8cbf2 100644 --- a/macros/latex/contrib/l3kernel/l3news10.pdf +++ b/macros/latex/contrib/l3kernel/l3news10.pdf diff --git a/macros/latex/contrib/l3kernel/l3news11.pdf b/macros/latex/contrib/l3kernel/l3news11.pdf Binary files differindex e9e4bbac55..92eeb57981 100644 --- a/macros/latex/contrib/l3kernel/l3news11.pdf +++ b/macros/latex/contrib/l3kernel/l3news11.pdf diff --git a/macros/latex/contrib/l3kernel/l3news12.pdf b/macros/latex/contrib/l3kernel/l3news12.pdf Binary files differindex f3a18ae2e0..e71980d1cf 100644 --- a/macros/latex/contrib/l3kernel/l3news12.pdf +++ b/macros/latex/contrib/l3kernel/l3news12.pdf diff --git a/macros/latex/contrib/l3kernel/l3prefixes.pdf b/macros/latex/contrib/l3kernel/l3prefixes.pdf Binary files differindex f89808da3a..2e60fc555c 100644 --- a/macros/latex/contrib/l3kernel/l3prefixes.pdf +++ b/macros/latex/contrib/l3kernel/l3prefixes.pdf diff --git a/macros/latex/contrib/l3kernel/l3prg.dtx b/macros/latex/contrib/l3kernel/l3prg.dtx index 8345aeed89..6003f49343 100644 --- a/macros/latex/contrib/l3kernel/l3prg.dtx +++ b/macros/latex/contrib/l3kernel/l3prg.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3prop.dtx b/macros/latex/contrib/l3kernel/l3prop.dtx index 6bb93e9738..9125c5ec8e 100644 --- a/macros/latex/contrib/l3kernel/l3prop.dtx +++ b/macros/latex/contrib/l3kernel/l3prop.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3quark.dtx b/macros/latex/contrib/l3kernel/l3quark.dtx index df5b3d8dd6..8361fa47f2 100644 --- a/macros/latex/contrib/l3kernel/l3quark.dtx +++ b/macros/latex/contrib/l3kernel/l3quark.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3regex.dtx b/macros/latex/contrib/l3kernel/l3regex.dtx index d17ab25cf8..faa41bc68a 100644 --- a/macros/latex/contrib/l3kernel/l3regex.dtx +++ b/macros/latex/contrib/l3kernel/l3regex.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3seq.dtx b/macros/latex/contrib/l3kernel/l3seq.dtx index 45424fb54f..0201692ebb 100644 --- a/macros/latex/contrib/l3kernel/l3seq.dtx +++ b/macros/latex/contrib/l3kernel/l3seq.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3skip.dtx b/macros/latex/contrib/l3kernel/l3skip.dtx index 26a27c5b87..3ecd3004d0 100644 --- a/macros/latex/contrib/l3kernel/l3skip.dtx +++ b/macros/latex/contrib/l3kernel/l3skip.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3sort.dtx b/macros/latex/contrib/l3kernel/l3sort.dtx index cdbb13c721..4c981becf9 100644 --- a/macros/latex/contrib/l3kernel/l3sort.dtx +++ b/macros/latex/contrib/l3kernel/l3sort.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3str-convert.dtx b/macros/latex/contrib/l3kernel/l3str-convert.dtx index 0d85d89c62..324f9f8b92 100644 --- a/macros/latex/contrib/l3kernel/l3str-convert.dtx +++ b/macros/latex/contrib/l3kernel/l3str-convert.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3str.dtx b/macros/latex/contrib/l3kernel/l3str.dtx index 971746e70b..84d2e2d7ae 100644 --- a/macros/latex/contrib/l3kernel/l3str.dtx +++ b/macros/latex/contrib/l3kernel/l3str.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3styleguide.pdf b/macros/latex/contrib/l3kernel/l3styleguide.pdf Binary files differindex 5dc6b6b38b..75a93c51d5 100644 --- a/macros/latex/contrib/l3kernel/l3styleguide.pdf +++ b/macros/latex/contrib/l3kernel/l3styleguide.pdf diff --git a/macros/latex/contrib/l3kernel/l3styleguide.tex b/macros/latex/contrib/l3kernel/l3styleguide.tex index 5013d07852..096b29e3e7 100644 --- a/macros/latex/contrib/l3kernel/l3styleguide.tex +++ b/macros/latex/contrib/l3kernel/l3styleguide.tex @@ -32,7 +32,7 @@ The released version of this bundle is available from CTAN. {latex-team@latex-project.org}% }% } -\date{Released 2020-09-03} +\date{Released 2020-09-06} \begin{document} diff --git a/macros/latex/contrib/l3kernel/l3syntax-changes.pdf b/macros/latex/contrib/l3kernel/l3syntax-changes.pdf Binary files differindex 26e081ca79..c86eef33d3 100644 --- a/macros/latex/contrib/l3kernel/l3syntax-changes.pdf +++ b/macros/latex/contrib/l3kernel/l3syntax-changes.pdf diff --git a/macros/latex/contrib/l3kernel/l3syntax-changes.tex b/macros/latex/contrib/l3kernel/l3syntax-changes.tex index a41a431e0e..ee8f8abed3 100644 --- a/macros/latex/contrib/l3kernel/l3syntax-changes.tex +++ b/macros/latex/contrib/l3kernel/l3syntax-changes.tex @@ -32,7 +32,7 @@ The released version of this bundle is available from CTAN. {latex-team@latex-project.org}% }% } -\date{Released 2020-09-03} +\date{Released 2020-09-06} \newcommand{\TF}{\textit{(TF)}} diff --git a/macros/latex/contrib/l3kernel/l3sys.dtx b/macros/latex/contrib/l3kernel/l3sys.dtx index 347e51e754..9c9b8fa84b 100644 --- a/macros/latex/contrib/l3kernel/l3sys.dtx +++ b/macros/latex/contrib/l3kernel/l3sys.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3term-glossary.pdf b/macros/latex/contrib/l3kernel/l3term-glossary.pdf Binary files differindex b7388d7b44..10cb4d25f8 100644 --- a/macros/latex/contrib/l3kernel/l3term-glossary.pdf +++ b/macros/latex/contrib/l3kernel/l3term-glossary.pdf diff --git a/macros/latex/contrib/l3kernel/l3term-glossary.tex b/macros/latex/contrib/l3kernel/l3term-glossary.tex index 0f60f77a98..59b3a89bbe 100644 --- a/macros/latex/contrib/l3kernel/l3term-glossary.tex +++ b/macros/latex/contrib/l3kernel/l3term-glossary.tex @@ -32,7 +32,7 @@ The released version of this bundle is available from CTAN. {latex-team@latex-project.org}% }% } -\date{Released 2020-09-03} +\date{Released 2020-09-06} \newcommand{\TF}{\textit{(TF)}} diff --git a/macros/latex/contrib/l3kernel/l3text-case.dtx b/macros/latex/contrib/l3kernel/l3text-case.dtx index cffe7b60b1..c44bede9f7 100644 --- a/macros/latex/contrib/l3kernel/l3text-case.dtx +++ b/macros/latex/contrib/l3kernel/l3text-case.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3text-purify.dtx b/macros/latex/contrib/l3kernel/l3text-purify.dtx index 800ac8ae74..5b0770e6f3 100644 --- a/macros/latex/contrib/l3kernel/l3text-purify.dtx +++ b/macros/latex/contrib/l3kernel/l3text-purify.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3text.dtx b/macros/latex/contrib/l3kernel/l3text.dtx index b80ead9476..e062326286 100644 --- a/macros/latex/contrib/l3kernel/l3text.dtx +++ b/macros/latex/contrib/l3kernel/l3text.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3tl-analysis.dtx b/macros/latex/contrib/l3kernel/l3tl-analysis.dtx index d39f6d686f..532c514263 100644 --- a/macros/latex/contrib/l3kernel/l3tl-analysis.dtx +++ b/macros/latex/contrib/l3kernel/l3tl-analysis.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3tl.dtx b/macros/latex/contrib/l3kernel/l3tl.dtx index 81715a3b2e..095a51d948 100644 --- a/macros/latex/contrib/l3kernel/l3tl.dtx +++ b/macros/latex/contrib/l3kernel/l3tl.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3token.dtx b/macros/latex/contrib/l3kernel/l3token.dtx index 8b7bc70e02..473cd48a82 100644 --- a/macros/latex/contrib/l3kernel/l3token.dtx +++ b/macros/latex/contrib/l3kernel/l3token.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3unicode.dtx b/macros/latex/contrib/l3kernel/l3unicode.dtx index 3a38610e75..4b024350af 100644 --- a/macros/latex/contrib/l3kernel/l3unicode.dtx +++ b/macros/latex/contrib/l3kernel/l3unicode.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-03} +% \date{Released 2020-09-06} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/source3.pdf b/macros/latex/contrib/l3kernel/source3.pdf Binary files differindex 790d04ca5a..cf1f926b77 100644 --- a/macros/latex/contrib/l3kernel/source3.pdf +++ b/macros/latex/contrib/l3kernel/source3.pdf diff --git a/macros/latex/contrib/l3kernel/source3.tex b/macros/latex/contrib/l3kernel/source3.tex index 9804ff7def..33b5ecbb45 100644 --- a/macros/latex/contrib/l3kernel/source3.tex +++ b/macros/latex/contrib/l3kernel/source3.tex @@ -53,7 +53,7 @@ for those people who are interested. {latex-team@latex-project.org}% }% } -\date{Released 2020-09-03} +\date{Released 2020-09-06} \pagenumbering{roman} \maketitle diff --git a/macros/latex/contrib/semantex/README.md b/macros/latex/contrib/semantex/README.md index 6da44d3d9c..8e177e4f7b 100644 --- a/macros/latex/contrib/semantex/README.md +++ b/macros/latex/contrib/semantex/README.md @@ -1,15 +1,24 @@ -SemanTeX - semantic mathematics +SemanTeX -- semantic, keyval-based mathematics -------------------------------------- The SemanTeX package for LaTeX delivers a more semantic, -systematized way of writing mathematics compared to the -ordinary math syntax in LaTeX. The system uses keyval syntax -and is highly customizable. At the same time, care has been -taken to make it the syntax as simple, natural, practical, -and lightweight as possible. +systematized way of writing mathematics, compared to the +classical math syntax in LaTeX. The system uses keyval +syntax, and the user can define their own keys and +customize the system down to the last detail. At the same +time, care has been taken to make the syntax as simple, +natural, practical, and lightweight as possible. + +Furthermore, the package has a companion package, +called stripsemantex, which allows you to completely strip +your documents of SemanTeX markup to prepare them e.g. for publication. + +The package is still in beta, but is considered feature-complete +and more or less stable, so using it at this point should be safe. +Still, suggestions, ideas, and bug reports are more than welcome! ---------------------------------------------------------------- -SemanTeX --- object-oriented mathematics +SemanTeX -- semantic, keyval-based mathematics Maintained by Sebastian Ørsted E-mail: sorsted@gmail.com Released under the LaTeX Project Public License v1.3c or later diff --git a/macros/latex/contrib/semantex/semantex.pdf b/macros/latex/contrib/semantex/semantex.pdf Binary files differindex 240ae06b3c..860064bf45 100644 --- a/macros/latex/contrib/semantex/semantex.pdf +++ b/macros/latex/contrib/semantex/semantex.pdf diff --git a/macros/latex/contrib/semantex/semantex.sty b/macros/latex/contrib/semantex/semantex.sty index e5125e921f..c2ca6e552b 100644 --- a/macros/latex/contrib/semantex/semantex.sty +++ b/macros/latex/contrib/semantex/semantex.sty @@ -1,104 +1,115 @@ -\RequirePackage{expl3,xparse} -\ProvidesExplPackage{semantex}{2020/07/21}{0.3alpha}{} +\RequirePackage{xparse,l3keys2e,semtex,leftindex} +\ProvidesExplPackage{semantex}{2020/09/07}{0.4beta}{} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SemanTeX -- semantic, keyval-based mathematics % +% https://ctan.org/pkg/semantex % +% (C) 2020 Sebastian Ørsted % +% sorsted@gmail.com % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % -% SemanTeX -- semantic mathematics % -% https://ctan.org/pkg/semantex % -% (C) 2020 Sebastian Ørsted % -% sorsted@gmail.com % -% % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\cs_set_eq:NN \semantex_keyval_parse:NNn \keyval_parse:NNn + +\keys_define:nn { semantex } +{ + keyvalparser .code:n = \cs_set_eq:NN \semantex_keyval_parse:NNn #1, + keyvalparser .value_required:n = true, + semtexfile .choice:, + semtexfile / true .code:n = \semantex_turn_semtex_file_on:, + semtexfile / false .code:n = \semantex_turn_semtex_file_off:, + semtexfile / unknown .code:n = \msg_error:nnnn { semantex } { semantex_setup_key_value_not_found } { semtexfile } { #1 }, + unknown .code:n = \msg_error:nnx { semantex } { semantex_setup_key_not_found } { \l_keys_key_str } +} + +\DeclareDocumentCommand\SemantexSetup { m } +{ + \keys_set:nn { semantex } { #1 } +} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% ERROR MESSAGES +% THE .semtex FILE % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\bool_new:N \g__semantex_semtex_file_was_opened -\msg_new:nnnn { semantex } { valuekey_not_found } { Unknown~key~#2~passed~to~#1~on~line~\msg_line_number: } {} - -\msg_new:nnnn { semantex } { arg_valuekey_not_found } { Unknown~argument~key~#2~passed~to~#1~on~line~\msg_line_number: } {} - -\msg_new:nnnn { semantex } { data_tl_not_found } { Unknown~data~#2~requested~from~#1~on~line~\msg_line_number: } {} - -\msg_new:nnnn { semantex } { data_int_not_found } { Unknown~integer~#2~requested~from~#1~on~line~\msg_line_number: } {} - -\msg_new:nnnn { semantex } { data_bool_not_found } { Unknown~boolean~#2~requested~from~#1~on~line~\msg_line_number: } {} - -\msg_new:nnnn { semantex } { data_cs_not_found } { Unknown~command~sequence~#2~requested~from~#1~on~line~\msg_line_number: } {} - -\msg_new:nnnn { semantex } { data_prop_not_found } { Unknown~property~list~#2~requested~from~#1~on~line~\msg_line_number: } {} +\iow_new:N \g__semantex_semtex_file_stream_temp_iow -\msg_new:nnnn { semantex } { key_value_not_found } { Unknown~value~#3~passed~to~key~#2~in~#1~on~line~\msg_line_number: } {} - -\msg_new:nnnn { semantex } { class_already_defined } { Class~#1~already~defined;~you~tried~defining~it~again~on~line~\msg_line_number: } {} - -\msg_new:nnnn { semantex } { object_already_defined } { Object~#1~already~defined;~you~tried~defining~it~again~on~line~\msg_line_number: } {} - -\msg_new:nnnn { semantex } { class_not_found } { Unknown~class~#3~declared~as~#2~of~#1~on~line~\msg_line_number: } {} - -\msg_new:nnnn { semantex } { object_not_found } { You~set~#1~as~#2~of~unknown~object~#3~on~line~\msg_line_number: } {} - -\msg_new:nnnn { semantex } { created_object_of_unknown_class } { Unknown~class~#1~declared~as~class~of~#2~on~line~\msg_line_number: } {} - -\msg_new:nnnn { semantex } { setup_unknown_class } { You~tried~setting~up~an~unknown~#1~on~line~\msg_line_number: } {} - -\msg_new:nnnn { semantex } { setup_unknown_object } { You~tried~setting~up~an~unknown~#1~on~line~\msg_line_number: } {} - -\msg_new:nnnn { semantex } { created_a_SemantexBaseObject } { Never~create~objects~of~class~\SemantexBaseObject;~create~a~new~class~yourself~instead.~You~created~the~object~#1~on~line~\msg_line_number: } {} +\cs_new_protected:Npn \semantex_turn_semtex_file_on: +{ + \bool_if:NF \g__semantex_semtex_file_was_opened + { + \iow_open:Nn \g__semantex_semtex_file_stream_temp_iow { \jobname.semtex } + \iow_now:Nn \g__semantex_semtex_file_stream_temp_iow { \DeclareClass {\SemantexBaseObject } } + } + + \cs_set:Npn\semantex_write_to_semtex_file:n##1 + { + \iow_now:Nn \g__semantex_semtex_file_stream_temp_iow { ##1 } + } + + \bool_set_true:N \g__semantex_semtex_file_was_opened +} -\msg_new:nnnn { semantex } { generic_error } { #2~#1~on~line~\msg_line_number: } {} +\cs_new_protected:Npn \semantex_turn_semtex_file_off: +{ + \bool_if:NT \g__semantex_semtex_file_was_opened + { + \iow_close:N \g__semantex_semtex_file_stream_temp_iow + } + + \cs_set:Npn\semantex_write_to_semtex_file:n##1 {} -\cs_generate_variant:Nn \msg_error:nnnn { nnnx } + \bool_set_false:N \g__semantex_semtex_file_was_opened +} -\tl_new:N\l__semantex_error_output_format_temp +\semantex_turn_semtex_file_off: -\cs_new:Npn\semantex_error_output_format:nN#1#2 +\cs_new_protected:Npn\semantex_write_original_source_to_semtex_file:n#1 { - \tl_set:Nn \l__semantex_error_output_format_temp { #1 } - \tl_replace_all:Nnn \l__semantex_error_output_format_temp { object_ } { object~\cs:w } - \tl_replace_all:Nnn \l__semantex_error_output_format_temp { class_ } { class~\cs:w } - \tl_put_right:Nn \l__semantex_error_output_format_temp { \cs_end: } - \tl_trim_spaces:N \l__semantex_error_output_format_temp - \tl_set_eq:NN #2 \l__semantex_error_output_format_temp + \semantex_write_to_semtex_file:n { \BeginSource } + \semantex_write_to_semtex_file:n { #1 } } -\cs_generate_variant:Nn \semantex_error_output_format:nN { xN } - -\cs_generate_variant:Nn \msg_error:nnnnn { nnxnn } +\cs_set_eq:NN\SemantexRecordSource\semantex_write_original_source_to_semtex_file:n -\cs_generate_variant:Nn \msg_error:nnnn { nnxn } +\cs_new_protected:Npn\semantex_add_to_existing_original_source_in_semtex_file:n#1 +{ + \semantex_write_to_semtex_file:n { #1 } +} -\cs_generate_variant:Nn \msg_error:nnn { nnx } +\cs_new_protected:Npn\semantex_write_output_to_semtex_file:n#1 +{ + \semantex_write_to_semtex_file:n { \EndSource } + \semantex_write_to_semtex_file:n { \BeginOutput } + \semantex_write_to_semtex_file:n { #1 } + \semantex_write_to_semtex_file:n { \EndOutput } +} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% COMMANDS FOR BULLETS AND SLOTS -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\cs_generate_variant:Nn\semantex_write_output_to_semtex_file:n { V } +\cs_generate_variant:Nn\semantex_write_original_source_to_semtex_file:n { o } -\box_new:N \l__semantex_bullet_box -\hbox_set:Nn \l__semantex_bullet_box { $\cdot$ } -\box_scale:Nnn \l__semantex_bullet_box {1.2} {1.2} -\tl_set:Nn\g_semantex_bullet +\cs_new_protected:Npn\semantex_write_class_declaration_to_semtex_file:n#1 { - \box_move_up:nn{-0.25ex}{\box_use:N \l__semantex_bullet_box} + \semantex_write_to_semtex_file:n { \DeclareClass{#1} } } -\tl_set:Nn\g_semantex_double_bullet{\g_semantex_bullet \g_semantex_bullet} - -\tl_set_eq:NN\SemantexBullet \g_semantex_bullet - -\tl_set_eq:NN \SemantexDoubleBullet \g_semantex_double_bullet +\cs_new_protected:Npn\semantex_write_object_declaration_to_semtex_file:n#1 +{ + \semantex_write_to_semtex_file:n { \DeclareObject{#1} } +} -\tl_set:Nn \g_semantex_slot { \mathord{-} } +\cs_new_protected:Npn\SemantexIDcommand#1 +{ + \semantex_write_to_semtex_file:n { \SemantexID{#1} } +} -\tl_set_eq:NN \SemantexSlot \g_semantex_slot +\cs_set_eq:NN\SemantexRecordObject\semantex_write_object_declaration_to_semtex_file:n %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -106,25 +117,28 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\DeclareDocumentCommand\semantex_new_plain_class:Nw{mO{}} % new simple-type class +\DeclareDocumentCommand\semantex_new_simple_class:Nw{mO{}} % new simple-type class { % #1 = class name % #2 = options \semantex_new_class:Nn { #1 } { \semantex_class_set_keys:Nn #1 { #2 } } - %\semantex_new_class:Nn { #1 } { #2 } - \DeclareDocumentCommand{#1}{m}{ + \DeclareDocumentCommand{#1}{m} + { % the actual \#1 command + \semantex_write_original_source_to_semtex_file:n { #1 { ##1 } } \semantex_render_class:Nn #1 { \semantex_class_set_symbol:Nn #1 { ##1 } } } - \exp_args:Nc\DeclareDocumentCommand{__semantex_make_object_of_class_\cs_to_str:N #1_with_options:nnw}{mm}{ + \exp_args:Nc\DeclareDocumentCommand{__semantex_make_object_of_\semantex_class_to_register:N #1_with_options:nnw}{mm} + { + %\semantex_add_to_existing_original_source_in_semtex_file:n { } % add nothing to file \semantex_render_class:Nn #1 { \semantex_class_set_symbol:Nn #1 { ##2 } ##1 } } - \exp_args:Nc\DeclareDocumentCommand{__semantex_new_object_of_class_\cs_to_str:N #1:Nw}{mgO{}} + \exp_args:Nc\DeclareDocumentCommand{__semantex_new_object_of_\semantex_class_to_register:N #1:Nw}{mgO{}} { % the command for creating a new object of class #1 % ##1 = command name, with backslash @@ -143,25 +157,28 @@ } } % create the object with name ##1 - \DeclareDocumentCommand{##1}{}{ + \DeclareDocumentCommand{##1}{} + { % the actual \##1 command + \semantex_write_original_source_to_semtex_file:n { ##1 } \semantex_render_object:Nn ##1 { } } } } -\tl_set_eq:NN\NewPlainClass\semantex_new_plain_class:Nw +\tl_set_eq:NN\NewSimpleClass\semantex_new_simple_class:Nw -\DeclareDocumentCommand\semantex_new_simple_class:Nw{mO{}} % new simple-type class +\DeclareDocumentCommand\semantex_new_symbol_class:Nw{mO{}} % new symbol-type class { % #1 = class name % #2 = options \semantex_new_class:Nn { #1 } { \semantex_class_set_keys:Nn #1 { #2 } } - %\semantex_new_class:Nn { #1 } { #2 } - \DeclareDocumentCommand{#1}{mo}{ + \DeclareDocumentCommand{#1}{mo} + { % the actual \#1 command \IfValueTF{##2} { + \semantex_write_original_source_to_semtex_file:n { #1 { ##1 } { ##2 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##1 } @@ -169,14 +186,17 @@ } } { + \semantex_write_original_source_to_semtex_file:n { #1 { ##1 } } \semantex_render_class:Nn #1 { \semantex_class_set_symbol:Nn #1 { ##1 } } } } - \exp_args:Nc\DeclareDocumentCommand{__semantex_make_object_of_class_\cs_to_str:N #1_with_options:nnw}{mmo}{ + \exp_args:Nc\DeclareDocumentCommand{__semantex_make_object_of_\semantex_class_to_register:N #1_with_options:nnw}{mmo} + { \IfValueTF{##3} { + \semantex_add_to_existing_original_source_in_semtex_file:n { [##3] } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -185,13 +205,14 @@ } } { + %\semantex_add_to_existing_original_source_in_semtex_file:n { } % write nothing to file \semantex_render_class:Nn #1 { \semantex_class_set_symbol:Nn #1 { ##2 } ##1 } } } - \exp_args:Nc\DeclareDocumentCommand{__semantex_new_object_of_class_\cs_to_str:N #1:Nw}{mgO{}} + \exp_args:Nc\DeclareDocumentCommand{__semantex_new_object_of_\semantex_class_to_register:N #1:Nw}{mgO{}} { % the command for creating a new object of class #1 % ##1 = command name, with backslash @@ -210,25 +231,26 @@ } } % create the object with name ##1 - \DeclareDocumentCommand{##1}{o}{ + \DeclareDocumentCommand{##1}{o} + { % the actual \##1 command \IfValueTF { ####1 } { + \semantex_write_original_source_to_semtex_file:n { ##1 [ ####1 ] } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_set_keys:Nn ##1 { ####1 } } } { + \semantex_write_original_source_to_semtex_file:n { ##1 } \semantex_render_object:Nn ##1 { } } } } } -\tl_set_eq:NN\NewSimpleClass\semantex_new_simple_class:Nw - -%IM Consider using \semantexIfNoValueOrDotTF on the argument +\tl_set_eq:NN\NewSymbolClass\semantex_new_symbol_class:Nw \DeclareDocumentCommand\semantex_new_variable_class:Nw{mO{}} % new variable-type class { @@ -236,12 +258,14 @@ % #2 = options \semantex_new_class:Nn { #1 } { \semantex_class_set_keys:Nn #1 { #2 } } %\semantex_new_class:Nn #1 { #2 } - \DeclareDocumentCommand{#1}{mog}{ + \DeclareDocumentCommand{#1}{mog} + { % the actual \#1 command \IfValueTF { ##2 } { \IfValueTF { ##3 } { + \semantex_write_original_source_to_semtex_file:n { #1 { ##1 } [ ##2 ] { ##3 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##1 } @@ -250,6 +274,7 @@ } } { + \semantex_write_original_source_to_semtex_file:n { #1 { ##1 } [ ##2 ] } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##1 } @@ -260,6 +285,7 @@ { \IfValueTF { ##3 } { + \semantex_write_original_source_to_semtex_file:n { #1 { ##1 } { ##3 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##1 } @@ -267,16 +293,19 @@ } } { + \semantex_write_original_source_to_semtex_file:n { #1 { ##1 } } \semantex_render_class:Nn #1 { \semantex_class_set_symbol:Nn #1 { ##1 } } } } } - \exp_args:Nc\DeclareDocumentCommand{__semantex_make_object_of_class_\cs_to_str:N #1_with_options:nnw}{mmog}{ + \exp_args:Nc\DeclareDocumentCommand{__semantex_make_object_of_\semantex_class_to_register:N #1_with_options:nnw}{mmog} + { \IfValueTF { ##3 } { \IfValueTF { ##4 }{ + \semantex_add_to_existing_original_source_in_semtex_file:n { [ ##3 ] { ##4 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -286,6 +315,7 @@ } } { + \semantex_add_to_existing_original_source_in_semtex_file:n { [ ##3 ] } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -297,6 +327,7 @@ { \IfValueTF { ##4 } { + \semantex_add_to_existing_original_source_in_semtex_file:n { { ##4 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -305,6 +336,7 @@ } } { + % \semantex_add_to_existing_original_source_in_semtex_file:n { } % write nothing to file \semantex_render_class:Nn #1 { \semantex_class_set_symbol:Nn #1 { ##2 } ##1 @@ -312,7 +344,7 @@ } } } - \exp_args:Nc\DeclareDocumentCommand{__semantex_new_object_of_class_\cs_to_str:N #1:Nw}{mgO{}} + \exp_args:Nc\DeclareDocumentCommand{__semantex_new_object_of_\semantex_class_to_register:N #1:Nw}{mgO{}} { % the command for creating a new object of class #1 % ##1 = command name, with backslash @@ -336,6 +368,10 @@ \IfValueTF{####1}{ \IfValueTF{####2} { + \semantex_write_original_source_to_semtex_file:n + { + ##1 [ ####1 ] { ####2 } + } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_set_keys:Nn ##1 { ####1 } @@ -343,6 +379,10 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { + ##1 [ ####1 ] + } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_set_keys:Nn ##1 { ####1 } @@ -352,12 +392,20 @@ { \IfValueTF{####2} { + \semantex_write_original_source_to_semtex_file:n + { + ##1 {####2} + } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_set_arg:Nn ##1 { ####2 } } } { + \semantex_write_original_source_to_semtex_file:n + { + ##1 + } \semantex_render_object:Nn ##1 {} } } @@ -378,10 +426,12 @@ { \IfValueTF { ##3 } { - \tl_if_eq:nnTF { ##3 }{ * } + \str_if_eq:nnTF { ##3 }{ * } { \IfValueTF { ##4 } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } [ ##2 ] { * } { ##4 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##1 } @@ -391,6 +441,8 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } [ ##2 ] { * } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##1 } @@ -400,10 +452,12 @@ } } { - \tl_if_eq:nnTF { ##3 }{ ** } + \str_if_eq:nnTF { ##3 }{ ** } { \IfValueTF { ##4 } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } [ ##2 ] { ** } { ##4 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##1 } @@ -413,6 +467,8 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } [ ##2 ] { ** } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##1 } @@ -424,6 +480,8 @@ { \IfValueTF { ##4 } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } [ ##2 ] { ##3 } { ##4 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##1 } @@ -433,6 +491,8 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } [ ##2 ] { ##3 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##1 } @@ -446,6 +506,8 @@ { \IfValueTF { ##4 } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } [ ##2 ] { ##4 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##1 } @@ -454,6 +516,8 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } [ ##2 ] } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##1 } @@ -465,10 +529,12 @@ { \IfValueTF { ##3 } { - \tl_if_eq:nnTF { ##3 }{ * } + \str_if_eq:nnTF { ##3 }{ * } { \IfValueTF { ##4 } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } { * } { ##4 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:N #1 { ##1 } @@ -477,6 +543,8 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } { * } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:N #1 { ##1 } @@ -485,10 +553,12 @@ } } { - \tl_if_eq:nnTF { ##3 }{ ** } + \str_if_eq:nnTF { ##3 }{ ** } { \IfValueTF { ##4 } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } { ** } { ##4 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:N #1 { ##1 } @@ -497,6 +567,8 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } { ** } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:N #1 { ##1 } @@ -507,6 +579,8 @@ { \IfValueTF { ##4 } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } { ##3 } { ##4 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:N #1 { ##1 } @@ -515,6 +589,8 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } { ##3 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:N #1 { ##1 } @@ -527,6 +603,8 @@ { \IfValueTF { ##4 } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } { ##4 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##1 } @@ -534,6 +612,8 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } } \semantex_render_class:Nn #1 { \semantex_class_set_symbol:Nn #1 { ##1 } } @@ -541,15 +621,18 @@ } } } - \exp_args:Nc\DeclareDocumentCommand{__semantex_make_object_of_class_\cs_to_str:N #1_with_options:nnw}{mmogg}{ + \exp_args:Nc\DeclareDocumentCommand{__semantex_make_object_of_\semantex_class_to_register:N #1_with_options:nnw}{mmogg} + { \IfValueTF{##3} { \IfValueTF { ##4 } { - \tl_if_eq:nnTF { ##4 }{ * } + \str_if_eq:nnTF { ##4 }{ * } { \IfValueTF { ##5 } { + \semantex_add_to_existing_original_source_in_semtex_file:n + { [ ##3 ] { * } { ##5 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -560,6 +643,8 @@ } } { + \semantex_add_to_existing_original_source_in_semtex_file:n + { [ ##3 ] { * } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -570,10 +655,12 @@ } } { - \tl_if_eq:nnTF { ##4 }{ ** } + \str_if_eq:nnTF { ##4 }{ ** } { \IfValueTF { ##5 } { + \semantex_add_to_existing_original_source_in_semtex_file:n + { [ ##3 ] { ** } { ##5 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -584,6 +671,8 @@ } } { + \semantex_add_to_existing_original_source_in_semtex_file:n + { [ ##3 ] { ** } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -596,6 +685,8 @@ { \IfValueTF { ##5 } { + \semantex_add_to_existing_original_source_in_semtex_file:n + { [ ##3 ] { ##4 } { ##5 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -606,6 +697,8 @@ } } { + \semantex_add_to_existing_original_source_in_semtex_file:n + { [ ##3 ] { ##4 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -620,6 +713,8 @@ { \IfValueTF { ##5 } { + \semantex_add_to_existing_original_source_in_semtex_file:n + { [ ##3 ] { ##5 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -629,6 +724,8 @@ } } { + \semantex_add_to_existing_original_source_in_semtex_file:n + { [ ##3 ] } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -641,10 +738,12 @@ { \IfValueTF { ##4 } { - \tl_if_eq:nnTF { ##4 }{ * } + \str_if_eq:nnTF { ##4 }{ * } { \IfValueTF { ##5 } { + \semantex_add_to_existing_original_source_in_semtex_file:n + { { * } { ##5 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -654,6 +753,8 @@ } } { + \semantex_add_to_existing_original_source_in_semtex_file:n + { { * } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -663,10 +764,12 @@ } } { - \tl_if_eq:nnTF { ##4 }{ ** } + \str_if_eq:nnTF { ##4 }{ ** } { \IfValueTF { ##5 } { + \semantex_add_to_existing_original_source_in_semtex_file:n + { { ** } { ##5 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -676,6 +779,8 @@ } } { + \semantex_add_to_existing_original_source_in_semtex_file:n + { { ** } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -687,6 +792,8 @@ { \IfValueTF { ##5 } { + \semantex_add_to_existing_original_source_in_semtex_file:n + { { ##4 } { ##5 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -696,6 +803,8 @@ } } { + \semantex_add_to_existing_original_source_in_semtex_file:n + { { ##4 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -709,6 +818,8 @@ { \IfValueTF { ##5 } { + \semantex_add_to_existing_original_source_in_semtex_file:n + { { ##5 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -717,6 +828,7 @@ } } { + % \semantex_add_to_existing_original_source_in_semtex_file:n { } % write nothing to file \semantex_render_class:Nn #1 { \semantex_class_set_symbol:Nn #1 { ##2 } ##1 @@ -725,7 +837,7 @@ } } } - \exp_args:Nc\DeclareDocumentCommand{__semantex_new_object_of_class_\cs_to_str:N #1:Nw}{mgO{}} + \exp_args:Nc\DeclareDocumentCommand{__semantex_new_object_of_\semantex_class_to_register:N #1:Nw}{mgO{}} { % the command for creating a new object of class #1 % ##1 = command name, with backslash @@ -744,16 +856,19 @@ } } % creates the object with name ##1 - \DeclareDocumentCommand{##1}{ogg}{ + \DeclareDocumentCommand{##1}{ogg} + { % the actual \##1 command \IfValueTF{####1} { \IfValueTF{####2} { - \tl_if_eq:nnTF { ####2 } { * } + \str_if_eq:nnTF { ####2 } { * } { \IfValueTF{####3} { + \semantex_write_original_source_to_semtex_file:n + { ##1 [ ####1 ] { * } { ####3 } } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_set_keys:Nn ##1 { ####1 } @@ -762,6 +877,8 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { ##1 [ ####1 ] { * } } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_set_keys:Nn ##1 { ####1 } @@ -770,10 +887,12 @@ } } { - \tl_if_eq:nnTF { ####2 } { ** } + \str_if_eq:nnTF { ####2 } { ** } { \IfValueTF{####3} { + \semantex_write_original_source_to_semtex_file:n + { ##1 [ ####1 ] { ** } { ####3 } } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_set_keys:Nn ##1 { ####1 } @@ -782,6 +901,8 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { ##1 [ ####1 ] { ** } } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_set_keys:Nn ##1 { ####1 } @@ -792,6 +913,8 @@ { \IfValueTF{####3} { + \semantex_write_original_source_to_semtex_file:n + { ##1 [ ####1 ] { ####2 } { ####3 } } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_set_keys:Nn ##1 { ####1 } @@ -800,6 +923,8 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { ##1 [ ####1 ] { ####2 } } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_set_keys:Nn ##1 { ####1 } @@ -812,6 +937,8 @@ { \IfValueTF{####3} { + \semantex_write_original_source_to_semtex_file:n + { ##1 [ ####1 ] { ####3 } } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_set_keys:Nn ##1 { ####1 } @@ -819,6 +946,8 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { ##1 [ ####1 ] } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_set_keys:Nn ##1 { ####1 } @@ -829,10 +958,12 @@ { \IfValueTF{####2} { - \tl_if_eq:nnTF { ####2 } { * } + \str_if_eq:nnTF { ####2 } { * } { \IfValueTF{####3} { + \semantex_write_original_source_to_semtex_file:n + { ##1 { * } { ####3 } } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_use_bullet:N ##1 @@ -840,6 +971,8 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { ##1 { * } } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_use_bullet:N ##1 @@ -847,10 +980,12 @@ } } { - \tl_if_eq:nnTF { ####2 } { ** } + \str_if_eq:nnTF { ####2 } { ** } { \IfValueTF{####3} { + \semantex_write_original_source_to_semtex_file:n + { ##1 { ** } { ####3 } } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_use_double_bullet:N ##1 @@ -858,6 +993,8 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { ##1 { ** } } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_use_double_bullet:N ##1 @@ -867,6 +1004,8 @@ { \IfValueTF{####3} { + \semantex_write_original_source_to_semtex_file:n + { ##1 { ####2 } { ####3 } } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_set_degreedefault:Nn ##1 { ####2 } @@ -874,6 +1013,8 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { ##1 { ####2 } } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_set_degreedefault:Nn ##1 { ####2 } @@ -885,12 +1026,16 @@ { \IfValueTF{####3} { + \semantex_write_original_source_to_semtex_file:n + { ##1 { ####3 } } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_set_arg:Nn ##1 { ####3 } } } { + \semantex_write_original_source_to_semtex_file:n + { ##1 } \semantex_render_object:Nn ##1 { } } } @@ -912,6 +1057,8 @@ { \IfValueTF { ##3 } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } [ ##2 ] { ##3 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##1 } @@ -920,6 +1067,8 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } [ ##2 ] } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##1 } @@ -930,6 +1079,8 @@ { \IfValueTF { ##3 } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } { ##3 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##1 } @@ -937,6 +1088,8 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { #1 { ##1 } } \semantex_render_class:Nn #1 { \semantex_class_set_symbol:Nn #1 { ##1 } } @@ -944,12 +1097,14 @@ } } % the actual \#1 command - \exp_args:Nc\DeclareDocumentCommand{__semantex_make_object_of_class_\cs_to_str:N #1_with_options:nnw}{mmog} + \exp_args:Nc\DeclareDocumentCommand{__semantex_make_object_of_\semantex_class_to_register:N #1_with_options:nnw}{mmog} { \IfValueTF { ##3 } { \IfValueTF { ##4 } { + \semantex_add_to_existing_original_source_in_semtex_file:n + { [ ##3 ] { ##4 } } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } @@ -959,11 +1114,13 @@ } } { + \semantex_add_to_existing_original_source_in_semtex_file:n + { [ ##3 ] } \semantex_render_class:Nn #1 { \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } ##1 - \semantex_class_set_keys:Nn #1{ ##3 } + \semantex_class_set_keys:Nn #1 { ##3 } } } } @@ -971,6 +1128,8 @@ \IfValueTF { ##4 } { \semantex_render_class:Nn #1 { + \semantex_add_to_existing_original_source_in_semtex_file:n + { { ##4 } } \semantex_class_do_output:N #1 \semantex_class_set_symbol:Nn #1 { ##2 } ##1 @@ -978,6 +1137,7 @@ } } { + % \semantex_add_to_existing_original_source_in_semtex_file:n { } % write nothing to file \semantex_render_class:Nn #1 { \semantex_class_set_symbol:Nn #1 { ##2 } ##1 @@ -985,7 +1145,7 @@ } } } - \exp_args:Nc\DeclareDocumentCommand{__semantex_new_object_of_class_\cs_to_str:N #1:Nw}{mmmO{}} + \exp_args:Nc\DeclareDocumentCommand{__semantex_new_object_of_\semantex_class_to_register:N #1:Nw}{mmmO{}} { % the command for creating a new object of class #1 % ##1 = command name, with backslash @@ -997,12 +1157,15 @@ \semantex_object_set_keys:Nn ##1 { ##4 } } % creates the object with name ##1 - \DeclareDocumentCommand{##1}{og}{ + \DeclareDocumentCommand{##1}{og} + { % the actual \##1 command \IfValueTF { ####1 } { \IfValueTF { ####2 } { + \semantex_write_original_source_to_semtex_file:n + { ##1 [ ####1] { ####2 } } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_set_keys:Nn ##1 { ####1 } @@ -1010,6 +1173,8 @@ } } { + \semantex_write_original_source_to_semtex_file:n + { ##1 [ ####1] } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_set_keys:Nn ##1 { ####1 } @@ -1019,12 +1184,16 @@ { \IfValueTF { ####2 } { + \semantex_write_original_source_to_semtex_file:n + { ##1 { ####2 } } \semantex_render_object:Nn ##1 { \semantex_object_do_output:N ##1 \semantex_object_set_arg:Nn ##1 { ####2 } } } { + \semantex_write_original_source_to_semtex_file:n + { ##1 } \semantex_render_object:Nn ##1 { } } } @@ -1040,72 +1209,128 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\cs_new:Npn\NewObject#1 +% Internally, objects and classes are both special cases of what we call "registers". +% A register is a collection of data and key definitions, and different registers can +% inherit from each other. Each register has a name which is a token list, with no +% backslash. The class \<MyClass> corresponds to the register "class_<MyClass>", +% and the object \<MyObject> corresponds to the register "object_<MyObject>". +% Firstly, we need a couple of commands to convert class and object names into +% register names. + +\cs_new:Npn\semantex_class_to_register:N#1 +{ + % #1 = name of class + class_\cs_to_str:N #1 +} + +\cs_new:Npn\semantex_object_to_register:N#1 { - \cs_if_exist_use:cF { __semantex_new_object_of_class_\cs_to_str:N#1:Nw } + % #1 = name of object + object_\cs_to_str:N #1 +} + +\DeclareDocumentCommand\NewObject { m } +{ + % #1 = name of object + \semantex_class_if_exist:NTF #1 + { + \use:c { __semantex_new_object_of_\semantex_class_to_register:N #1:Nw } + } { \msg_error:nnnn { semantex } { created_object_of_unknown_class } { #1 } } } -\cs_new:Npn \__semantex_new_class_or_object:nn#1#2 +\DeclareDocumentCommand\UseClassInCommand { mo } { - % create new object - % #1 = name of command, without backslash + \semantex_class_if_exist:NTF #1 + { + \IfValueTF { #2 } + { + \use:c { __semantex_make_object_of_\semantex_class_to_register:N #1_with_options:nnw } + { + \semantex_keys_set:nn { \semantex_class_to_register:N #1 } { #2 } + } + } + { + \use:c { __semantex_make_object_of_\semantex_class_to_register:N #1_with_options:nnw } {} + } + } + { + \msg_error:nnnn { semantex } { used_unknown_class } { #1 } + } +} + +\cs_new_protected:Npn \semantex_new_register:nn#1#2 +{ + % create new register + % #1 = name of register % #2 = standard keyval setup \semantex_data_tl_provide:nn { #1 } { parent } \semantex_data_tl_set:nnn { #1 } { parent } { class_SemantexBaseObject } + % The parent class by default is \SemantexBaseObject \cs_set:cpn { __semantex_data_cs_#1_valuekey:nn } ##1##2 % command controlling valuekeys - { \semantex_valuekey:nnn { #1 } { ##1 } { ##2 } } + { \semantex_valuekey:nnn { #1 } { ##1 } { ##2 } } \cs_set:cpn { __semantex_data_cs_#1_singlekey:n } ##1 % command controlling singlekeys - { \semantex_singlekey:nn { #1 } { ##1 } } + { \semantex_singlekey:nn { #1 } { ##1 } } + + \cs_generate_variant:cn { __semantex_data_cs_#1_valuekey:nn } { nx } + + \cs_set:cpn { __semantex_data_cs_#1_singlekey_x:n } ##1 % command controlling executed singlekeys + { \semantex_singlekey_x:nn { #1 } { ##1 } } % Now a similar collection of keyval commands for the *argument* \cs_set:cpn { __semantex_data_cs_#1_arg_valuekey:nn } ##1##2 - { \semantex_arg_valuekey:nnn { #1 } { ##1 } { ##2 } } + { \semantex_arg_valuekey:nnn { #1 } { ##1 } { ##2 } } \cs_set:cpn { __semantex_data_cs_#1_arg_singlekey:n } ##1 - { \semantex_arg_singlekey:nn { #1 } { ##1 } } + { \semantex_arg_singlekey:nn { #1 } { ##1 } } - \cs_set:cpn { __semantex_data_cs_#1_outputoptions:n } ##1 {} + \cs_generate_variant:cn { __semantex_data_cs_#1_arg_valuekey:nn } { nx } - \cs_set:cpn { __semantex_data_cs_#1_parseoptions:n } ##1 {} + \cs_set:cpn { __semantex_data_cs_#1_arg_singlekey_x:n } ##1 + { \semantex_arg_singlekey_x:nn { #1 } { ##1 } } - % This is used to set up the class/object when creating it + % This is used to set up the register when creating it #2 } -\cs_generate_variant:Nn \__semantex_new_class_or_object:nn { xn } +\cs_generate_variant:Nn \semantex_new_register:nn { xn } -\cs_new:Npn \semantex_new_class:Nn#1#2{ +\cs_new_protected:Npn \semantex_new_class:Nn#1#2 +{ % create a new class % #1 = name of class - % #2 = standard keyval setup; the parent class by default is SemantexBaseObject + % #2 = standard keyval setup \semantex_class_if_exist:NTF #1 { \msg_error:nnn { semantex } { class_already_defined } { #1 } } { - \semantex_class_register:N #1 - \__semantex_new_class_or_object:xn { class_\cs_to_str:N #1 } { #2 } + \semantex_add_to_list_of_classes:N #1 + \semantex_new_register:xn { \semantex_class_to_register:N #1 } { #2 } } } -\cs_set:Npn \semantex_new_object:NNn#1#2#3 +\cs_set_protected:Npn \semantex_new_object:NNn#1#2#3 { + % create a new object + % #1 = name of class + % #2 = name of object + % #3 = standard keyval setup \semantex_object_if_exist:NTF #2 { \msg_error:nnn { semantex } { object_already_defined } { #2 } } { - \semantex_object_register:N #2 - \__semantex_new_class_or_object:xn { object_\cs_to_str:N #2 } { - %class=#1, #3 + \semantex_add_to_list_of_objects:N #2 + \semantex_new_register:xn { \semantex_object_to_register:N #2 } + { \semantex_object_set_class:Nn #2 { #1 } #3 } @@ -1113,246 +1338,272 @@ } % The following commands are used in the code for creating class types: +% Writing the actual content of the commands is not that much more +% complicated, but I've decided to use them anyway to make it more +% user-friendly to create your own class type. -\cs_set:Npn\semantex_class_set_symbol:Nn#1#2 +\cs_new_protected:Npn\semantex_class_set_symbol:Nn#1#2 { - %\semantex_data_tl_set:xnn { class_\cs_to_str:N#1 } { symbol } { #2 } - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_symbol:xn { class_\cs_to_str:N #1 } { #2 } + \semantex_valuekey:nnn { \semantex_class_to_register:N #1 } { symbol } { #2 } } -\cs_set:Npn\semantex_object_set_symbol:Nn#1#2 +\cs_new_protected:Npn\semantex_object_set_symbol:Nn#1#2 { - %\semantex_data_tl_set:xnn { object_\cs_to_str:N#1 } { symbol } { #2 } - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_symbol:xn { object_\cs_to_str:N #1 } { #2 } + \semantex_valuekey:nnn { \semantex_object_to_register:N #1 } { symbol } { #2 } } -\cs_set:Npn\semantex_class_do_output:N#1 +\cs_new_protected:Npn\semantex_class_do_output:N#1 { - \semantex_data_bool_set_true:xn { class_\cs_to_str:N#1 } { output } + \semantex_data_bool_set_true:nn { \semantex_class_to_register:N #1 } { output } } -\cs_set:Npn\semantex_object_do_output:N#1 +\cs_new_protected:Npn\semantex_object_do_output:N#1 { - \semantex_data_bool_set_true:xn { object_\cs_to_str:N#1 } { output } + \semantex_data_bool_set_true:nn { \semantex_object_to_register:N #1 } { output } } -\cs_set:Npn\semantex_class_set_keys:Nn#1#2 +\cs_new_protected:Npn\semantex_class_set_keys:Nn#1#2 { - \semantex_keys_set:xn { class_\cs_to_str:N #1 } { #2 } + \semantex_keys_set:nn { \semantex_class_to_register:N #1 } { #2 } } -\cs_set:Npn\semantex_object_set_keys:Nn#1#2 +\cs_new_protected:Npn\semantex_object_set_keys:Nn#1#2 { - \semantex_keys_set:xn { object_\cs_to_str:N #1 } { #2 } + \semantex_keys_set:nn { \semantex_object_to_register:N #1 } { #2 } } -\cs_set:Npn\semantex_class_set_arg:Nn#1#2 +\cs_new_protected:Npn\semantex_class_set_arg:Nn#1#2 { - \semantex_valuekey:xnn { class_\cs_to_str:N#1 } { arg } { #2 } + \semantex_valuekey:nnn { \semantex_class_to_register:N #1 } { arg } { #2 } } -\cs_set:Npn\semantex_object_set_arg:Nn#1#2 +\cs_new_protected:Npn\semantex_object_set_arg:Nn#1#2 { - \semantex_valuekey:xnn { object_\cs_to_str:N#1 } { arg } { #2 } + \semantex_valuekey:nnn { \semantex_object_to_register:N #1 } { arg } { #2 } } -\cs_set:Npn\semantex_class_set_degreedefault:Nn#1#2 +\cs_new_protected:Npn\semantex_class_set_degreedefault:Nn#1#2 { - \semantex_valuekey:xnn { class_\cs_to_str:N#1 } { degreedefault } { #2 } - % should there be \exp_not:n around #2? Probably not, based on the above + \semantex_valuekey:nnn { \semantex_class_to_register:N #1 } { degreedefault } { #2 } } -\cs_set:Npn\semantex_object_set_degreedefault:Nn#1#2 +\cs_new_protected:Npn\semantex_object_set_degreedefault:Nn#1#2 { - \semantex_valuekey:xnn { object_\cs_to_str:N#1 } { degreedefault } { #2 } - % should there be \exp_not:n around #2? Probably not, based on the above + \semantex_valuekey:nnn { \semantex_object_to_register:N #1 } { degreedefault } { #2 } } -\cs_set:Npn\semantex_class_use_bullet:N#1 +\cs_new_protected:Npn\semantex_class_use_bullet:N#1 { - \semantex_singlekey:xn { class_\cs_to_str:N#1 } { * } + \semantex_singlekey:nn { \semantex_class_to_register:N #1 } { * } } -\cs_set:Npn\semantex_object_use_bullet:N#1 +\cs_new_protected:Npn\semantex_object_use_bullet:N#1 { - \semantex_singlekey:xn { object_\cs_to_str:N#1 } { * } + \semantex_singlekey:nn { \semantex_object_to_register:N #1 } { * } } -\cs_set:Npn\semantex_class_use_double_bullet:N#1 +\cs_new_protected:Npn\semantex_class_use_double_bullet:N#1 { - \semantex_singlekey:xn { class_\cs_to_str:N#1 } { * } + \semantex_singlekey:nn { \semantex_class_to_register:N #1 } { * } } -\cs_set:Npn\semantex_object_use_double_bullet:N#1 +\cs_new_protected:Npn\semantex_object_use_double_bullet:N#1 { - \semantex_singlekey:xn { object_\cs_to_str:N#1 } { * } + \semantex_singlekey:nn { \semantex_object_to_register:N #1 } { * } } -\cs_set:Npn\semantex_class_set_leftpar:Nn#1#2 +\cs_new_protected:Npn\semantex_class_set_leftpar:Nn#1#2 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_leftpar:xn { class_\cs_to_str:N#1 } { #2 } + \semantex_data_tl_set:nnn { \semantex_class_to_register:N #1 } { leftpar } { #2 } } -\cs_set:Npn\semantex_object_set_leftpar:Nn#1#2 +\cs_new_protected:Npn\semantex_object_set_leftpar:Nn#1#2 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_leftpar:xn { object_\cs_to_str:N#1 } { #2 } + \semantex_data_tl_set:nnn { \semantex_object_to_register:N #1 } { leftpar } { #2 } } -\cs_set:Npn\semantex_class_set_rightpar:Nn#1#2 +\cs_new_protected:Npn\semantex_class_set_rightpar:Nn#1#2 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_rightpar:xn { class_\cs_to_str:N#1 } { #2 } + \semantex_data_tl_set:nnn { \semantex_class_to_register:N #1 } { rightpar } { #2 } } -\cs_set:Npn\semantex_object_set_rightpar:Nn#1#2 +\cs_new_protected:Npn\semantex_object_set_rightpar:Nn#1#2 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_rightpar:xn { object_\cs_to_str:N#1 } { #2 } + \semantex_data_tl_set:nnn { \semantex_object_to_register:N #1 } { rightpar } { #2 } } -\cs_set:Npn\semantex_object_set_class:Nn#1#2 +\cs_new_protected:Npn\semantex_object_set_class:Nn#1#2 { - \semantex_data_class_set:xn { object_\cs_to_str:N #1 } { #2 } + \semantex_data_class_set:nn { \semantex_object_to_register:N #1 } { #2 } } -\seq_new:N \g__semantex_all_classes_seq % a register for all objects created +\seq_new:N \g__semantex_all_classes_seq % a list of all objects created -\cs_new:Npn\semantex_class_register:N#1 +\cs_new_protected:Npn\semantex_add_to_list_of_classes:N#1 { - \seq_put_right:Nx\g__semantex_all_classes_seq { class_\cs_to_str:N #1 } + \seq_put_right:Nx\g__semantex_all_classes_seq { \semantex_class_to_register:N #1 } + \semantex_write_class_declaration_to_semtex_file:n { #1 } } -\cs_new:Npn\semantex_class_if_exist:NTF#1#2#3 +\cs_new_protected:Npn\semantex_class_if_exist:NTF#1#2#3 { - \seq_if_in:NxTF\g__semantex_all_classes_seq { class_\cs_to_str:N#1 } { #2 } { #3 } + \seq_if_in:NxTF\g__semantex_all_classes_seq { \semantex_class_to_register:N #1 } { #2 } { #3 } } -\seq_new:N \g__semantex_all_objects_seq % a register for all objects created +\seq_new:N \g__semantex_all_objects_seq % a list of all objects created -\cs_new:Npn\semantex_object_register:N#1 +\cs_new_protected:Npn\semantex_add_to_list_of_objects:N#1 { - \seq_put_right:Nx\g__semantex_all_objects_seq { object_\cs_to_str:N #1 } + \seq_put_right:Nx\g__semantex_all_objects_seq { \semantex_object_to_register:N #1 } + \semantex_write_object_declaration_to_semtex_file:n { #1 } } -\cs_new:Npn\semantex_object_if_exist:NTF#1#2#3 +\cs_new_protected:Npn\semantex_object_if_exist:NTF#1#2#3 { - \seq_if_in:NxTF\g__semantex_all_objects_seq { object_\cs_to_str:N#1 } { #2 } { #3 } + \seq_if_in:NxTF\g__semantex_all_objects_seq { \semantex_object_to_register:N #1 } { #2 } { #3 } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% COMMANDS FOR RENDERING OBJECTS AND CLASSES +% COMMANDS FOR RENDERING REGISTERS % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \cs_generate_variant:Nn\tl_if_blank:nTF { xTF } -\cs_new_protected:Npn \__semantex_render:nn#1#2 +\cs_new_protected:Npn \semantex_render_register:nn#1#2 { - % the main command for rendering a class/object - % #1 = name of object + % the main command for rendering a register + % #1 = name of register % #2 = options \group_begin: - \semantex_provide_user_commands:n { #1 } + \cs_set:Nn\semantex_this: { #1 } \semantex_data_tl_inherit:nn { #1 } { symbol } % Inherit the symbol from parent if not done already - %\semantex_keys_set:nn { #1 } { #2 } % Setup the keys - #2 - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_parse:nn { #1 } { } % Run the "parse" routine, i.e. the collection of code that the user has added to the parse register - \semantex_data_bool_get:nnTF { #1 } { output } % Checks if the object/class is supposed to output + #2 % This is where keys can be set up + \semantex_parse:n { #1 } % Run the "parse" routine, i.e. run the collection of code that the user has added via the key "parseoptions" + \semantex_data_bool_get:nnTF { #1 } { output } % Checks if the register is supposed to output { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_innerreturn:nn { #1 }{} + \semantex_inner_return:n { #1 } \semantex_data_int_if_positive:nnTF { #1 } { numberofarguments } % Checks if more than one argument has been received, i.e. whether we want to render any argument { \semantex_data_bool_get:nnTF { #1 } { leftargument } % Checks if left or right argument { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_leftreturn:nn { #1 }{} + \semantex_left_return:n { #1 } } { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_rightreturn:nn { #1 }{} + \semantex_right_return:n { #1 } } } { % do nothing } - \tl_set:Nx\l__semantex_render_symbol_temp { \semantex_data_tl_get:nn { #1 } { symbol } } % Stores the symbol in a temporary command - \tl_set:Nx \l__semantex_render_temp + \tl_set:Nx\l__semantex_render_symbol_temp_tl { \semantex_data_tl_get_exp_not:nn { #1 } { symbol } } % Stores the symbol in a temporary command + \tl_set:Nx \l__semantex_render_output_class_temp_tl { \semantex_data_tl_get:nn { #1 } { output } } % The output class + \exp_args:NNx\cs_set:Nn\l__semantex_render_outputoptions_temp_cs:n + { \semantex_data_tl_get_exp_not:nn { #1 } { outputoptions } } + % \cs_set:Nx did not work here, as it changes ##1 to #1, which we don't want. + \tl_set:Nn\l__semantex_render_outputoptions_temp_tl + { + \l__semantex_render_outputoptions_temp_cs:n + } + \tl_put_right:Nx \l__semantex_render_outputoptions_temp_tl + { + { \l__semantex_render_output_class_temp_tl } + } + \exp_args:NNo\tl_set:No \l__semantex_render_outputoptions_temp_tl + { + \l__semantex_render_outputoptions_temp_tl + } % This was necessary, trust me. + \tl_set:Nx \l__semantex_render_temp_tl { \exp_not:c { - __semantex_make_object_of_\semantex_data_tl_get:nn { #1 } { output }_with_options:nnw - } % This is for outputting -- the command \__semantex_make_object_of_class_???_with_options:nnw makes a one-time object of class ??? and allows us to immediately parse options to it - { - \exp_not:N\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperputleft:nn { \semantex_data_tl_get:nn { #1 } { output } } { \semantex_data_tl_get_exp_not:nn { #1 } { upper } } - \exp_not:N\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerputleft:nn { \semantex_data_tl_get:nn { #1 } { output } } { \semantex_data_tl_get_exp_not:nn { #1 } { lower } } - \exp_not:N\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperleftputright:nn { \semantex_data_tl_get:nn { #1 } { output } } { \semantex_data_tl_get_exp_not:nn { #1 } { upperleft } } - \exp_not:N\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerleftputright:nn { \semantex_data_tl_get:nn { #1 } { output } } { \semantex_data_tl_get_exp_not:nn { #1 } { lowerleft } } - \exp_not:N\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_preupper:nn { \semantex_data_tl_get:nn { #1 } { output } } { \semantex_data_tl_get_exp_not:nn { #1 } { preupper } } - \exp_not:N\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postupper:nn { \semantex_data_tl_get:nn { #1 } { output } } { \semantex_data_tl_get_exp_not:nn { #1 } { postupper } } - \exp_not:N\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_prelower:nn { \semantex_data_tl_get:nn { #1 } { output } } { \semantex_data_tl_get_exp_not:nn { #1 } { prelower } } - \exp_not:N\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postlower:nn { \semantex_data_tl_get:nn { #1 } { output } } { \semantex_data_tl_get_exp_not:nn { #1 } { postlower } } - \exp_not:N\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_preupperleft:nn { \semantex_data_tl_get:nn { #1 } { output } } { \semantex_data_tl_get_exp_not:nn { #1 } { preupperleft } } - \exp_not:N\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postupperleft:nn { \semantex_data_tl_get:nn { #1 } { output } } { \semantex_data_tl_get_exp_not:nn { #1 } { postupperleft } } - \exp_not:N\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_prelowerleft:nn { \semantex_data_tl_get:nn { #1 } { output } } { \semantex_data_tl_get_exp_not:nn { #1 } { prelowerleft } } - \exp_not:N\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postlowerleft:nn { \semantex_data_tl_get:nn { #1 } { output } } { \semantex_data_tl_get_exp_not:nn { #1 } { postlowerleft } } - \exp_not:N\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_texclass:nn { \semantex_data_tl_get:nn { #1 } { output } } { \semantex_data_tl_get:nn { #1 } { texclass } } - %\exp_not:N\semantex_keys_set:nn { \semantex_data_tl_get:nn { #1 } { output } } { \semantex_data_tl_get_exp_not:nn { #1 } { outputoptions } } - %\semantex_data_tl_get_exp_not:nn { #1 } { outputoptions } - %\exp_not:c -% \exp_args:Nc\exp_not:N -% { __semantex_data_cs_#1_outputoptions:n } { -% \semantex_data_tl_get:nn { #1 } { output } -% } -% \semantex_data_cs_get_exp_not:nn { #1 } { outputoptions:n } { \semantex_data_tl_get:nn { #1 } { output } } - \semantex_data_cs_get:nn { #1 } { outputoptions:n } { \semantex_data_tl_get:nn { #1 } { output } } - % These are the options we parse to our object -- this is all - % information that we pass on to the output class so that it + __semantex_make_object_of_\l__semantex_render_output_class_temp_tl _with_options:nnw + } + % This is for outputting -- the command + % \__semantex_make_object_of_class_???_with_options:nnw + % makes a one-time object of class ??? and allows us to + % immediately pass options to it + { + \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl } + { upperputleft } { \semantex_data_tl_get_exp_not:nn { #1 } { upper } } + \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl } + { lowerputleft } { \semantex_data_tl_get_exp_not:nn { #1 } { lower } } + \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl } + { upperleftputright } { \semantex_data_tl_get_exp_not:nn { #1 } { upperleft } } + \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl } + { lowerleftputright } { \semantex_data_tl_get_exp_not:nn { #1 } { lowerleft } } + \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl } + { preupper } { \semantex_data_tl_get_exp_not:nn { #1 } { preupper } } + \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl } + { postupper } { \semantex_data_tl_get_exp_not:nn { #1 } { postupper } } + \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl } + { prelower } { \semantex_data_tl_get_exp_not:nn { #1 } { prelower } } + \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl } + { postlower } { \semantex_data_tl_get_exp_not:nn { #1 } { postlower } } + \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl } + { preupperleft } { \semantex_data_tl_get_exp_not:nn { #1 } { preupperleft } } + \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl } + { postupperleft } { \semantex_data_tl_get_exp_not:nn { #1 } { postupperleft } } + \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl } + { prelowerleft } { \semantex_data_tl_get_exp_not:nn { #1 } { prelowerleft } } + \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl } + { postlowerleft } { \semantex_data_tl_get_exp_not:nn { #1 } { postlowerleft } } + \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl } + { heightphantom } { \semantex_data_tl_get_exp_not:nn { #1 } { heightphantom } } + \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl } + { slantingphantom } { \semantex_data_tl_get_exp_not:nn { #1 } { slantingphantom } } + \exp_not:N\semantex_base_object_valuekey:nnn { \l__semantex_render_output_class_temp_tl } + { texclass } { \semantex_data_tl_get_exp_not:nn { #1 } { texclass } } + \exp_not:V \l__semantex_render_outputoptions_temp_tl + % These are the options we pass to the output class so that it % can eventually render it } - { \exp_not:V \l__semantex_render_symbol_temp } + { \exp_not:V \l__semantex_render_symbol_temp_tl } } } { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_return:nn { #1 }{} % Returns the object/class, i.e. adds all remaining indices and arguments to it - \tl_if_blank:xTF { \semantex_data_tl_get:nn { #1 } { texclass } } + \semantex_pre_return:n { #1 } % Performs the pre_return routine, i.e. adds all remaining indices and arguments to the symbol + \tl_if_blank:xTF { \semantex_data_tl_get_exp_not:nn { #1 } { texclass } } % Checks whether the texclass register has been declared -- this is % where you store \mathord, \mathbin, \mathrel, etc., if you want % the object to be eventually wrapped in this. { - \tl_set:Nx\l__semantex_render_symbol_temp { \semantex_data_tl_get:nn { #1 } { symbol } } + \tl_set:Nx\l__semantex_render_temp_tl + { + \semantex_data_tl_get_exp_not:nn { #1 } { symbol } + } } { - \tl_set:Nx\l__semantex_render_symbol_temp { \semantex_data_tl_get:nn { #1 } { texclass } { \semantex_data_tl_get:nn { #1 } { symbol } } } - } - \tl_set:Nx\l__semantex_render_temp { - \exp_not:V \l__semantex_render_symbol_temp + \tl_set:Nx\l__semantex_render_temp_tl + { + \semantex_data_tl_get_exp_not:nn { #1 } { texclass } + { \semantex_data_tl_get_exp_not:nn { #1 } { symbol } } + } } + \group_begin: + \semantex_write_output_to_semtex_file:V \l__semantex_render_temp_tl + % Adds the output to the .semtex file, if this has been turned on, + % which it is not by default. + \group_end: } \exp_last_unbraced:NV \group_end: - \l__semantex_render_temp % This neat trick allows outputting to different classes to work as expected + \l__semantex_render_temp_tl + % This neat trick allows outputting to different classes to work as expected } -%\cs_generate_variant:Nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperputleft:nn { nx } -%\cs_generate_variant:Nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerputleft:nn { nx } -%\cs_generate_variant:Nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperleftputright:nn { nx } -%\cs_generate_variant:Nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerleftputright:nn { nx } -%\cs_generate_variant:Nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_preupper:nn { nx } -%\cs_generate_variant:Nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postupper:nn { nx } -%\cs_generate_variant:Nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_prelower:nn { nx } -%\cs_generate_variant:Nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postlower:nn { nx } -%\cs_generate_variant:Nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_preupperleft:nn { nx } -%\cs_generate_variant:Nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postupperleft:nn { nx } -%\cs_generate_variant:Nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_prelowerleft:nn { nx } -%\cs_generate_variant:Nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postlowerleft:nn { nx } -%\cs_generate_variant:Nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_texclass:nn { nx } - -\cs_generate_variant:Nn \__semantex_render:nn { xn } +\cs_generate_variant:Nn \semantex_render_register:nn { xn } -\cs_set:Npn\semantex_render_class:Nn#1#2 % a front-end command +\cs_new_protected:Npn\semantex_render_class:Nn#1#2 % a front-end command { - \__semantex_render:xn { class_\cs_to_str:N #1 } { #2 } + \semantex_render_register:xn { \semantex_class_to_register:N #1 } { #2 } } -\cs_set:Npn\semantex_render_object:Nn#1#2 +\cs_new_protected:Npn\semantex_render_object:Nn#1#2 { - \__semantex_render:xn { object_\cs_to_str:N #1 } { #2 } % Actually, it seems to all still work out fine with n-type instead of x-type, but better be sure + \semantex_render_register:xn { \semantex_object_to_register:N #1 } { #2 } + % Actually, it seems to all still work out fine with n-type + % instead of x-type, but better be sure } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1361,338 +1612,642 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\tl_new:N\SemantexDelimiterSize - -%%So far, this is experimental: -%%\makeatletter %this part requires amsmath -%\tl_set:Nn\semantexnormalscaling{\bBigg@{0.8}} -%\tl_set:Nn\semantexnormalscalingl{\mathopen\semantexnormalscaling} -%\tl_set:Nn\semantexnormalscalingr{\mathclose\semantexnormalscaling} -%\tl_set:Nn\semantexnormalscalingm{\mathrel\semantexnormalscaling} -%%\makeatother - -\cs_new:Npn \__semantex_parentheses_normal:nnn#1#2#3 +\cs_new_protected:Npn \semantex_parentheses_store:nN#1#2 { - \group_begin: - %\semantexnormalscalingl#2 #4 #5 #6 \semantexnormalscalingr#3 - \mathopen#1 #3 \mathclose#2 - \group_end: + \semantex_data_tl_get_store:nnN { #1 } { parsize } \l__semantex_parentheses_store_temp_tl + \semantex_data_bool_get:nnTF { #1 } { allowSemantexDelimiterSize } + { + \tl_set:Nn#2 { \SemantexParentheses } + \tl_put_right:Nx#2 + { + { \exp_not:V \l__semantex_parentheses_store_temp_tl } + { \semantex_data_tl_get_exp_not:nn { #1 } { leftpar } } + { \semantex_data_tl_get_exp_not:nn { #1 } { rightpar } } + { + \semantex_data_tl_get_exp_not:nn { #1 } { prearg } + \semantex_data_tl_get_exp_not:nn { #1 } { arg } + \semantex_data_tl_get_exp_not:nn { #1 } { postarg } + } + } + } + { + \str_case:VnF { \l__semantex_parentheses_store_temp_tl } % This is where \big,\Big, etc. go. + { + { normal } { + \tl_set:Nx#2 + { + \semantex_data_tl_get_exp_not:nn { #1 } { prearg } + \semantex_data_tl_get_exp_not:nn { #1 } { arg } + \semantex_data_tl_get_exp_not:nn { #1 } { postarg } + } + \str_if_eq:xnF { \semantex_data_tl_get_exp_not:nn { #1 } { leftpar } } { . } + { + \tl_put_left:Nx#2 + { + \exp_not:N \mathopen \semantex_data_tl_get_exp_not:nn { #1 } { leftpar } + } + } + \str_if_eq:xnF { \semantex_data_tl_get_exp_not:nn { #1 } { rightpar } } { . } + { + \tl_put_right:Nx#2 + { + \exp_not:N \mathclose \semantex_data_tl_get_exp_not:nn { #1 } { rightpar } + } + } + } + { auto } { + \tl_set:Nx#2 + { + \exp_not:N \SemantexLeft \semantex_data_tl_get_exp_not:nn { #1 } { leftpar } + \semantex_data_tl_get_exp_not:nn { #1 } { prearg } + \semantex_data_tl_get_exp_not:nn { #1 } { arg } + \semantex_data_tl_get_exp_not:nn { #1 } { postarg } + \exp_not:N \SemantexRight \semantex_data_tl_get_exp_not:nn { #1 } { rightpar } + } + } + { * } { + \tl_set:Nx#2 + { + \exp_not:N \SemantexLeft \semantex_data_tl_get_exp_not:nn { #1 } { leftpar } + \semantex_data_tl_get_exp_not:nn { #1 } { prearg } + \semantex_data_tl_get_exp_not:nn { #1 } { arg } + \semantex_data_tl_get_exp_not:nn { #1 } { postarg } + \exp_not:N \SemantexRight \semantex_data_tl_get_exp_not:nn { #1 } { rightpar } + } + } + } + { + \tl_set:Nx#2 + { + \exp_not:N \mathopen + \exp_not:V \l__semantex_parentheses_store_temp_tl + \semantex_data_tl_get_exp_not:nn { #1 } { leftpar } + \semantex_data_tl_get_exp_not:nn { #1 } { prearg } + \semantex_data_tl_get_exp_not:nn { #1 } { arg } + \semantex_data_tl_get_exp_not:nn { #1 } { postarg } + \exp_not:N \mathclose + \exp_not:V \l__semantex_parentheses_store_temp_tl + \semantex_data_tl_get_exp_not:nn { #1 } { rightpar } + } + } + } } -\cs_new:Npn \__semantex_parentheses_auto:nnn#1#2#3 -{ - \group_begin: - \tl_set:Nn\SemantexDelimiterSize{\middle} - %\tl_set_eq:NN\SemantexDelimiterSize\middle - \mathopen{}\mathclose\bgroup\left#1 - #3 - \aftergroup\egroup\right#2 - \group_end: -} +\cs_generate_variant:Nn \str_case:nnF { VnF } +\cs_generate_variant:Nn \str_if_eq:nnF { xnF } -\cs_new:Npn \__semantex_parentheses_other:nnnn#1#2#3#4 +\cs_new_protected:Npn \semantex_no_parentheses_store:nN#1#2 +% The central command for handling the rendering of arguments with no parentheses around { - \group_begin: - \tl_set_eq:NN\SemantexDelimiterSize#4 - %\tl_set:Nx\SemantexDelimiterSize{\exp_not:N#1} - \mathopen#4#1 #3 \mathclose#4#2 - \group_end: + \semantex_data_bool_get:nnTF { #1 } { allowSemantexDelimiterSize } + { + \tl_set:Nn#2 { \SemantexNoParentheses } + \tl_put_right:Nx#2 + { + { + \semantex_data_tl_get_exp_not:nn { #1 } { prearg } + \semantex_data_tl_get_exp_not:nn { #1 } { arg } + \semantex_data_tl_get_exp_not:nn { #1 } { postarg } + } + } + } + { + \tl_set:Nx#2 + { + \semantex_data_tl_get_exp_not:nn { #1 } { prearg } + \semantex_data_tl_get_exp_not:nn { #1 } { arg } + \semantex_data_tl_get_exp_not:nn { #1 } { postarg } + } + } } - -\cs_generate_variant:Nn \str_case:nnF { xnF } - -\cs_new:Npn \__semantex_parentheses_store:nnnnN#1#2#3#4#5 -% The central command handling the rendering of argument parentheses +\cs_new_protected:Npn \__semantex_symbol_parentheses_store:nnnnN#1#2#3#4#5 +% The central command handling the rendering of symbol parentheses { - \tl_set:Nx#5 - { - { #2 } - { #3 } - { #4 } - } - \str_case:xnF { #1 } % This is where \big,\Big, etc. go. To my surprise, an x-type expansion did not cause any issues with this + \str_case:nnF { #1 } % This is where \big,\Big, etc. go. { { normal } { - \tl_put_left:Nn#5 + \tl_set:Nn#5 { - \exp_not:N - \__semantex_parentheses_normal:nnn + #4 + } + \str_if_eq:nnF { #2 } { . } + { + \tl_put_left:Nn#5 + { + \mathopen #2 + } + } + \str_if_eq:nnF { #3 } { . } + { + \tl_put_right:Nn#5 + { + \mathclose #3 + } } } { auto } { - \tl_put_left:Nn#5 + \tl_set:Nn#5 { - \exp_not:N - \__semantex_parentheses_auto:nnn + \SemantexLeft #2 + #4 + \SemantexRight #3 } } { * } { - \tl_put_left:Nn#5 + \tl_set:Nn#5 { - \exp_not:N - \__semantex_parentheses_auto:nnn + \SemantexLeft #2 + #4 + \SemantexRight #3 } } } { - \tl_put_right:Nx#5 - { - { \exp_not:V #1 } - } - \tl_put_left:Nn#5 + \tl_set:Nn#5 { - \exp_not:N - \__semantex_parentheses_other:nnnn + \mathopen #1 #2 + #4 + \mathclose #1 #3 } } } -\cs_new:Npn \__semantex_no_parentheses:n#1 +\cs_generate_variant:Nn \__semantex_symbol_parentheses_store:nnnnN { xxxxN } + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% COMMANDS FOR THE RETURN ROUTINES +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\cs_new_protected:Npn\semantex_return:n#1 { - \group_begin: - \tl_clear:N\SemantexDelimiterSize - #1 - \group_end: + % This is an umbrella key that runs all of the three + % return routines, innerreturn, rightreturn, and leftreturn + \semantex_inner_return:n { #1 } + \semantex_left_return:n { #1 } + \semantex_right_return:n { #1 } } -\cs_new:Npn \__semantex_no_parentheses_store:nN#1#2 -% The central command for handling the rendering of arguments with no parentheses around +\cs_new_protected:Npn\semantex_pre_return:n#1 { - \tl_set:Nx#2 - { - { #1 } - } - \tl_put_left:Nn#2 + % The pre-return routines are like the return routines, except + % they do not reset all the parameters we need. This is only + % intended for use when rendering and not outputting, as + % resetting parameters in this case would just waste + % time. + \semantex_inner_pre_return:n { #1 } + \semantex_left_pre_return:n { #1 } + \semantex_right_pre_return:n { #1 } +} + +\cs_new_protected:Npn\semantex_inner_return:n#1 +{ + \semantex_inner_pre_return:n { #1 } + \semantex_data_seq_clear:nn { #1 } { commands_sequence } +} + +\cs_new_protected:Npn\semantex_inner_pre_return:n#1 +{ + % This adds all of the commands added via the command key + % to the symbol + \semantex_data_seq_get_store:nnN { #1 } { commands_sequence } + \l__semantex_data_seq_commands_sequence_temp + \seq_map_inline:Nn \l__semantex_data_seq_commands_sequence_temp { - \exp_not:N - \__semantex_no_parentheses:n + \semantex_data_tl_set:nnx { #1 } { symbol } + { + \exp_not:N ##1 + { + \semantex_data_tl_get_exp_not:nn { #1 } { symbol } + } + } } + \semantex_data_seq_clear:nn { #1 } { commands_sequence } } -\cs_new:Npn \__semantex_symbol_parentheses_normal:nnn#1#2#3 +\cs_new_protected:Npn\semantex_right_return:n#1 { - \mathopen#1 #3 \mathclose#2 + \semantex_right_indices_return_store:nN { #1 } + \l__semantex_rightreturn_right_indices_temp + \semantex_data_tl_put_right:nnx { #1 } { symbol } + { + \exp_not:V \l__semantex_rightreturn_right_indices_temp + } + \semantex_data_bool_get:nnTF { #1 } { leftargument } + { + % do nothing + } + { + \semantex_arg_return_store:nN { #1 } \l__semantex_rightreturn_arg_temp + \semantex_data_tl_put_right:nnx { #1 } { symbol } + { + \exp_not:V + \l__semantex_rightreturn_arg_temp + } + \semantex_data_tl_clear:nn { #1 } { arg } + \semantex_data_tl_clear:nn { #1 } { prearg } + \semantex_data_tl_clear:nn { #1 } { postarg } + \semantex_data_int_clear:nn { #1 } { numberofarguments } + \semantex_data_bool_set_false:nn { #1 } { nextargwithsep } + } + \semantex_data_tl_clear:nn { #1 } { upper } + \semantex_data_tl_clear:nn { #1 } { preupper } + \semantex_data_tl_clear:nn { #1 } { postupper } + \semantex_data_bool_set_false:nn { #1 } { nextupperwithsep } + \semantex_data_int_clear:nn { #1 } { numberofupperindices } + \semantex_data_tl_clear:nn { #1 } { lower } + \semantex_data_tl_clear:nn { #1 } { prelower } + \semantex_data_tl_clear:nn { #1 } { postlower } + \semantex_data_bool_set_false:nn { #1 } { nextlowerwithsep } + \semantex_data_int_clear:nn { #1 } { numberoflowerindices } } -\cs_new:Npn \__semantex_symbol_parentheses_auto:nnn#1#2#3 +\cs_new_protected:Npn\semantex_right_pre_return:n#1 { - \mathopen{}\mathclose\bgroup\left#1 - #3 - \aftergroup\egroup\right#2 + \semantex_right_indices_return_store:nN { #1 } + \l__semantex_rightreturn_right_indices_temp + \semantex_data_tl_put_right:nnx { #1 } { symbol } + { + \exp_not:V \l__semantex_rightreturn_right_indices_temp + } + \semantex_data_bool_get:nnTF { #1 } { leftargument } + { + % do nothing + } + { + \semantex_arg_return_store:nN { #1 } \l__semantex_rightreturn_arg_temp + \semantex_data_tl_put_right:nnx { #1 } { symbol } + { + \exp_not:V + \l__semantex_rightreturn_arg_temp + } + } } -\cs_new:Npn \__semantex_symbol_parentheses_other:nnnn#1#2#3#4 +\cs_new_protected:Npn \semantex_right_indices_return_store:nN#1#2 { - \mathopen#4#1 #3 \mathclose#4#2 + \tl_set:Nn#2{} + \semantex_data_int_if_positive:nnTF { #1 } { numberoflowerindices } + { + \tl_put_right:Nx#2 + { + \sb{ + \semantex_data_tl_get_exp_not:nn { #1 } { prelower } + \semantex_data_tl_get_exp_not:nn { #1 } { lower } + \semantex_data_tl_get_exp_not:nn { #1 } { postlower } + } + } + } + { + % do nothing + } + \semantex_data_int_if_positive:nnTF { #1 } { numberofupperindices } + { + \tl_put_right:Nx#2 + { + \sp{ + \semantex_data_tl_get_exp_not:nn { #1 } { preupper } + \semantex_data_tl_get_exp_not:nn { #1 } { upper } + \semantex_data_tl_get_exp_not:nn { #1 } { postupper } + } + } + } + { + % do nothing + } } +\cs_new_protected:Npn\semantex_left_return:n#1 +{ + \semantex_left_indices_return_store:nN { #1 } + \l__semantex_leftreturn_left_indices_temp + \semantex_data_tl_put_left:nnx { #1 } { symbol } + { + \exp_not:V \l__semantex_leftreturn_left_indices_temp + } + \semantex_data_bool_get:nnTF { #1 } { leftargument } + { + \semantex_arg_return_store:nN { #1 } \l__semantex_leftreturn_arg_temp + \semantex_data_tl_put_left:nnx { #1 } { symbol } + { + \exp_not:V \l__semantex_leftreturn_arg_temp + } + \semantex_data_tl_clear:nn { #1 } { arg } + \semantex_data_tl_clear:nn { #1 } { prearg } + \semantex_data_tl_clear:nn { #1 } { postarg } + \semantex_data_int_clear:nn { #1 } { numberofarguments } + \semantex_data_bool_set_false:nn { #1 } { nextargwithsep } + } + { + % do nothing + } + \semantex_data_tl_clear:nn { #1 } { upperleft } + \semantex_data_tl_clear:nn { #1 } { preupperleft } + \semantex_data_tl_clear:nn { #1 } { postupperleft } + \semantex_data_bool_set_false:nn { #1 } { nextupperleftwithsep } + \semantex_data_int_clear:nn { #1 } { numberofupperleftindices } + \semantex_data_tl_clear:nn { #1 } { lowerleft } + \semantex_data_tl_clear:nn { #1 } { prelowerleft } + \semantex_data_tl_clear:nn { #1 } { postlowerleft } + \semantex_data_bool_set_false:nn { #1 } { nextlowerleftwithsep } + \semantex_data_int_clear:nn { #1 } { numberoflowerleftindices } + \semantex_data_tl_set:nnx { #1 } { heightphantom } + { + \semantex_data_tl_get_exp_not:nn { #1 } { symbol } + } + \semantex_data_tl_clear:nn { #1 } { slantingphantom } +} -\cs_new:Npn \__semantex_symbol_parentheses_store:nnnnN#1#2#3#4#5 -% The central command handling the rendering of symbol parentheses +\cs_new_protected:Npn\semantex_left_pre_return:n#1 { - \tl_set:Nx#5 + \semantex_left_indices_return_store:nN { #1 } + \l__semantex_leftreturn_left_indices_temp + \semantex_data_tl_put_left:nnx { #1 } { symbol } { - { #2 } - { #3 } - { #4 } + \exp_not:V \l__semantex_leftreturn_left_indices_temp } - \str_case:xnF { #1 } % This is where \big,\Big, etc. go. To my surprise, an x-type expansion did not cause any issues with this + \semantex_data_bool_get:nnTF { #1 } { leftargument } { - { normal } { - \tl_put_left:Nn#5 + \semantex_arg_return_store:nN { #1 } \l__semantex_leftreturn_arg_temp + \semantex_data_tl_put_left:nnx { #1 } { symbol } + { + \exp_not:V \l__semantex_leftreturn_arg_temp + } + } + { + % do nothing + } +} + +\cs_new_protected:Npn \semantex_left_indices_return_store:nN#1#2 +{ + \tl_set:Nn#2{} + \semantex_data_int_if_positive:nnTF { #1 } { numberofupperleftindices } + { + \tl_put_right:Nn #2 { \manualleftindex } + \tl_put_right:Nx #2 + { + { \semantex_data_tl_get_exp_not:nn { #1 } { heightphantom } } + { \semantex_data_tl_get_exp_not:nn { #1 } { slantingphantom} } { - \exp_not:N - \__semantex_symbol_parentheses_normal:nnn + \semantex_data_tl_get_exp_not:nn { #1 } { preupperleft } + \semantex_data_tl_get_exp_not:nn { #1 } { upperleft } + \semantex_data_tl_get_exp_not:nn { #1 } { postupperleft } } } - { auto } { - \tl_put_left:Nn#5 + \semantex_data_int_if_positive:nnTF { #1 } { numberoflowerleftindices } + { + \tl_put_right:Nx#2 { - \exp_not:N - \__semantex_symbol_parentheses_auto:nnn + { + \semantex_data_tl_get_exp_not:nn { #1 } { prelowerleft } + \semantex_data_tl_get_exp_not:nn { #1 } { lowerleft } + \semantex_data_tl_get_exp_not:nn { #1 } { postlowerleft } + } } } - { * } { - \tl_put_left:Nn#5 + { + \tl_put_right:Nn#2 { - \exp_not:N - \__semantex_symbol_parentheses_auto:nnn + { } } } } { - \tl_put_right:Nx#5 + \semantex_data_int_if_positive:nnTF { #1 } { numberoflowerleftindices } { - { \exp_not:V #1 } + \tl_put_right:Nn #2 { \manualleftindex } + \tl_put_right:Nx #2 + { + { \semantex_data_tl_get_exp_not:nn { #1 } { heightphantom } } + { \semantex_data_tl_get_exp_not:nn { #1 } { slantingphantom} } + { } + { + \semantex_data_tl_get_exp_not:nn { #1 } { prelowerleft } + \semantex_data_tl_get_exp_not:nn { #1 } { lowerleft } + \semantex_data_tl_get_exp_not:nn { #1 } { postlowerleft } + } + } } - \tl_put_left:Nn#5 { - \exp_not:N - \__semantex_symbol_parentheses_other:nnnn + % do nothing } } } +\cs_new_protected:Npn \semantex_arg_return_store:nN#1#2 +{ + \semantex_data_tl_get_store:nnN { #1 } { parsize } \l__arg_return_store_parsize_temp_tl + \semantex_data_bool_get:nnTF { #1 } { par } + { + \semantex_data_int_if_positive:nnTF { #1 } { numberofarguments } + { + \semantex_parentheses_store:nN { #1 } #2 + } + { + \tl_set:Nn#2{} + } + } + { + \semantex_data_bool_get:nnTF { #1 } { flexpar } + { + \semantex_data_int_if_greater_than_one:nnTF { #1 } { numberofarguments } + { + \semantex_parentheses_store:nN { #1 } #2 + } + { + \semantex_data_int_if_positive:nnTF { #1 } { numberofarguments } + { + \semantex_no_parentheses_store:nN { #1 } #2 + } + { + \tl_set:Nn#2{} + } + } + } + { + \semantex_data_int_if_positive:nnTF { #1 } { numberofarguments } + { + \semantex_no_parentheses_store:nN { #1 } #2 + } + { + \tl_set:Nn#2{} + } + } + } +} +\cs_generate_variant:Nn \__semantex_parentheses_store:nnnnN { xxxxN , ooooN } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% COMMANDS FOR MODIFYING AND OBTAINING DATA +% COMMANDS HADNLING "spar" -- SYMBOL PARENTHESES % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%-------------------------------------------- -% Commands to modify and obtain data - -%\cs_new:Npn \semantex_data_tl_get_proto:nnn#1#2#3 -%{ -% % #1 = name of object -% % #2 = the data to get -% % #3 = also the name of object, but being stored -% % when passing to the parent, in order to make -% % error messages meaningful -% \tl_if_exist:cTF { g__semantex_data_tl_#1_#2 } -% { -% \use:c { g__semantex_data_tl_#1_#2 } -% } -% { -% \tl_if_eq:nnTF { #1 } { SemantexBaseObject } -% { -% \msg_error:nnnn { semantex } { data_tl_not_found } { #2 } { #3 } -% } -% { -% \semantex_data_tl_get_proto:nnn { \semantex_data_tl_get:nn { #1 } { parent } } { #2 } { #1 } -% } -% } -%} -% -%\cs_new:Npn \semantex_data_tl_get:nn#1#2 -%{ -% \semantex_data_tl_get_proto:nnn { #1 } { #2 } { #1 } -%} - - - -% COMMANDS FOR HANDLING THE PARENT OF A CLASS/OBJECT: - -\cs_new:Npn \semantex_data_parent_get:n#1 -{ - % #1 = object - % A command to get the parent of an object - \use:c { g__semantex_data_tl_#1_parent } -} - -\cs_new:Npn \semantex_data_parent_set:nn#1#2 +\cs_new_protected:Npn\semantex_spar:nn#1#2 { - \semantex_class_if_exist:NTF { #2 } + % Abbreviation for "symbol parentheses" + % Adds parentheses around the current symbol + \semantex_return:n { #1 } + \tl_if_blank:nTF { #2 } { - \tl_set:cx { g__semantex_data_tl_#1_parent } { class_\cs_to_str:N#2 } + \semantex_data_tl_get_store:nnN { #1 } { sparsize } + \l__semantex_spar_sparsize_temp_tl } { - \semantex_error_output_format:nN { #1 } \l__semantex_data_parent_set_temp_tl - \msg_error:nnxnn { semantex } { class_not_found } { \l__semantex_data_parent_set_temp_tl } { parent } { #2 } + \tl_set:Nn \l__semantex_spar_sparsize_temp_tl { #2 } } + \__semantex_symbol_parentheses_store:xxxxN + { \exp_not:V\l__semantex_spar_sparsize_temp_tl } + { \semantex_data_tl_get_exp_not:nn { #1 } { leftspar } } + { \semantex_data_tl_get_exp_not:nn { #1 } { rightspar } } + { \semantex_data_tl_get_exp_not:nn { #1 } { symbol } } + \l__semantex_spar_temp_tl + \semantex_data_tl_set:nnx { #1 } { symbol } + { + \exp_not:V \l__semantex_spar_temp_tl + } + \semantex_spar_set_height_phantom_to_parentheses_size:nx { #1 } + { \exp_not:V \l__semantex_spar_sparsize_temp_tl } } -\cs_new:Npn \semantex_data_class_set:nn#1#2 +\cs_new_protected:Npn\semantex_other_spar:nnn#1#2#3 { - \semantex_class_if_exist:NTF { #2 } - { - \tl_set:cx { g__semantex_data_tl_#1_parent } { class_\cs_to_str:N#2 } - } + \semantex_return:n { #1 } + \semantex_data_tl_get_store:nnN { #1 } { sparsize } + \l__semantex_other_spar_sparsize_temp_tl + \__semantex_symbol_parentheses_store:xxxxN + { \exp_not:V \l__semantex_other_spar_sparsize_temp_tl } + { \exp_not:n { #2 } } + { \exp_not:n { #3 } } + { \semantex_data_tl_get_exp_not:nn { #1 } { symbol } } + \l__semantex_other_spar_temp_tl + \semantex_data_tl_set:nnx { #1 } { symbol } { - \semantex_error_output_format:nN { #1 } \l__semantex_data_class_set_temp_tl - \msg_error:nnxnn { semantex } { class_not_found } { \l__semantex_data_class_set_temp_tl } { class } { #2 } + \exp_not:V \l__semantex_other_spar_temp_tl } + \semantex_spar_set_height_phantom_to_parentheses_size:nx { #1 } + { \exp_not:V \l__semantex_other_spar_sparsize_temp_tl } } -\cs_generate_variant:Nn \semantex_data_class_set:nn { xn } - -\cs_new:Npn \semantex_data_copy_object:nn#1#2 +\cs_new_protected:Npn\semantex_other_spar_with_size:nnnn#1#2#3#4 { - \semantex_object_if_exist:NTF { #2 } - { - \tl_set:cx { g__semantex_data_tl_#1_parent } { object_\cs_to_str:N#2 } - } + \semantex_return:n { #1 } + \__semantex_symbol_parentheses_store:xxxxN + { \exp_not:n { #4 } } + { \exp_not:n { #2 } } + { \exp_not:n { #3 } } + { \semantex_data_tl_get_exp_not:nn { #1 } { symbol } } + \l__semantex_other_spar_with_size_temp_tl + \semantex_data_tl_set:nnx { #1 } { symbol } { - \semantex_error_output_format:nN { #1 } \l__semantex_data_copy_object_temp_tl - \msg_error:nnxnn { semantex } { object_not_found } { \l__semantex_data_copy_object_temp_tl } { copy } { #2 } + \exp_not:V \l__semantex_other_spar_with_size_temp_tl } + \semantex_spar_set_height_phantom_to_parentheses_size:nn { #1 } + { #4 } } -\cs_new:Npn \semantex_data_clone_object:nn#1#2 +\cs_new_protected:Npn\semantex_spar_set_height_phantom_to_parentheses_size:nn#1#2 { - \semantex_object_if_exist:NTF { #2 } + % #1 = register + % #2 = parentheses size + \str_case:nnF { #2 } { - \tl_set:cx { g__semantex_data_tl_#1_parent } { object_\cs_to_str:N#2 } + { normal } { + \semantex_data_tl_set:nnn { #1 } { heightphantom } { \vert } + } + { auto } { + \semantex_data_tl_set:nnx { #1 } { heightphantom } + { + \semantex_data_tl_get_exp_not:nn { #1 } { symbol } + } + } + { * } { + \semantex_data_tl_set:nnx { #1 } { heightphantom } + { + \semantex_data_tl_get_exp_not:nn { #1 } { symbol } + } + } } { - \semantex_error_output_format:nN { #1 } \l__semantex_data_clone_object_temp_tl - \msg_error:nnxnn { semantex } { object_not_found } { \l__semantex_data_clone_object_temp_tl } { clone } { #2 } + \semantex_data_tl_set:nnx { #1 } { heightphantom } + { + \exp_not:n { #2 \vert } + } } } -% COMMANDS FOR HANDLING DATA CONSISTING OF COMMAND SEQUENCES: +\cs_generate_variant:Nn \semantex_spar_set_height_phantom_to_parentheses_size:nn { nx } + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% COMMANDS FOR MODIFYING AND OBTAINING DATA +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% COMMANDS FOR HANDLING THE PARENT OF A CLASS/OBJECT: -\cs_new:Npn\semantex_data_cs_set:nnn#1#2#3 +\cs_new:Npn \semantex_data_parent_get:n#1 { - \cs_set:cn { __semantex_data_cs_#1_#2 } { #3 } + % #1 = register + % A command to get the parent of an object + \use:c { g__semantex_data_tl_#1_parent } } -\cs_generate_variant:Nn \cs_set:Nn { cn } - -\cs_generate_variant:Nn \semantex_data_cs_set:nnn { nno , nnV , nnv } +\cs_new_protected:Npn \semantex_data_parent_set:nn#1#2 +{ + % #1 = reigster + % Sets the parent + \semantex_class_if_exist:NTF { #2 } + { + \tl_set:cx { g__semantex_data_tl_#1_parent } { \semantex_class_to_register:N #2 } + } + { + \semantex_msg_error:nnnn { #1 } { class_not_found } { parent } { #2 } + } +} -\cs_new:Npn\semantex_data_cs_get:nn#1#2 +\cs_new_protected:Npn \semantex_data_class_set:nn#1#2 { - % #1 = name of the object - % #2 = command sequence to get - \cs_if_exist:cTF { __semantex_data_cs_#1_#2 } + % #1 = register + % Sets the parent to be a class + \semantex_class_if_exist:NTF { #2 } { - \use:c { __semantex_data_cs_#1_#2 } + \tl_set:cx { g__semantex_data_tl_#1_parent } { \semantex_class_to_register:N #2 } } { - \str_if_eq:nnTF { #1 } { class_SemantexVariable } - { - % should probably throw an error by now, but later! - } - { - \semantex_data_cs_get:fn { \semantex_data_parent_get:n {#1} } { #2 } - } + \semantex_msg_error:nnnn { #1 } { class_not_found } { class } { #2 } } } -\cs_generate_variant:Nn \semantex_data_cs_get:nn { fn } +\cs_generate_variant:Nn \semantex_data_class_set:nn { xn } -\cs_new:Npn\semantex_data_cs_get_exp_not:nn#1#2 +\cs_new_protected:Npn \semantex_data_copy_object:nn#1#2 { - % #1 = name of the object - % #2 = command sequence to get - \cs_if_exist:cTF { __semantex_data_cs_#1_#2 } + \semantex_object_if_exist:NTF { #2 } { - \exp_not:c { __semantex_data_cs_#1_#2 } + \tl_set:cx { g__semantex_data_tl_#1_parent } { \semantex_object_to_register:N #2 } } { - \str_if_eq:nnTF { #1 } { class_SemantexVariable } - { - % should probably throw an error by now, but later! - } - { - \semantex_data_cs_get_exp_not:fn { \semantex_data_parent_get:n {#1} } { #2 } - } + \semantex_msg_error:nnnn { #1 } { object_not_found } { copy } { #2 } } } -\cs_generate_variant:Nn \semantex_data_cs_get_exp_not:nn { fn } - -\cs_new:Npn\semantex_data_cs_clear:nn#1#2 +\cs_new_protected:Npn \semantex_data_clone_object:nn#1#2 { - \cs_set:cn { __semantex_data_cs_#1_#2 } {} + \semantex_object_if_exist:NTF { #2 } + { + \tl_set:cx { g__semantex_data_tl_#1_parent } { \semantex_object_to_register:N #2 } + } + { + \semantex_msg_error:nnnn { #1 } { object_not_found } { clone } { #2 } + } } % COMMANDS FOR HANDLING DATA CONSISTING OF TOKEN LISTS @@ -1704,24 +2259,19 @@ \__semantex_data_tl_get_auxiliary:nnn { #1 } { #2 } { #1 } } -\cs_generate_variant:Nn \str_if_eq:nnTF { fnTF } - -\cs_generate_variant:Nn \tl_if_eq:nnTF { fnTF } - \cs_new:Npn \__semantex_data_tl_get_auxiliary:nnn#1#2#3 { - % #1 = name of class/object + % #1 = name of register % #2 = the data to get - % #3 = the original class/object, used for error messaging + % #3 = the original register, used for error messaging \tl_if_exist:cTF { g__semantex_data_tl_#1_#2 } { \use:c { g__semantex_data_tl_#1_#2 } } { - \str_if_eq:nnTF { #1 } { class_SemantexBaseObject } % Apparently, f-type expansion seemed to work here for once + \str_if_eq:nnTF { #1 } { class_SemantexBaseObject } { - \semantex_error_output_format:nN { #3 } \l__semantex_data_tl_get_auxiliary_temp_tl - \msg_error:nnxn { semantex } { data_tl_not_found } { \l__semantex_data_tl_get_auxiliary_temp_tl } { #2 } + \semantex_msg_error:nnn { #3 } { data_tl_not_found } { #2 } } { \__semantex_data_tl_get_auxiliary:fnn { \semantex_data_parent_get:n { #1 } } { #2 } { #3 } @@ -1731,40 +2281,26 @@ \cs_generate_variant:Nn \__semantex_data_tl_get_auxiliary:nnn { fnn } -%\cs_new:Npn \semantex_data_tl_get_exp_not:nn#1#2 -%{ -% % #1 = name of object -% % #2 = the data to get -% \tl_if_exist:cTF { g__semantex_data_tl_#1_#2 } -% { -% \exp_not:v { g__semantex_data_tl_#1_#2 } -% } -% { -% \semantex_data_tl_get:nn { \semantex_data_parent_get:n { #1 } } { #2 } -% } -%} - \cs_new:Npn \semantex_data_tl_get_exp_not:nn#1#2 { - % #1 = name of object + % #1 = name of register % #2 = the data to get \__semantex_data_tl_get_exp_not_auxiliary:nnn { #1 } { #2 } { #1 } } \cs_new:Npn \__semantex_data_tl_get_exp_not_auxiliary:nnn#1#2#3 { - % #1 = name of class/object + % #1 = name of register % #2 = the data to get - % #3 = the original class/object, used for error messaging + % #3 = the original register, used for error messaging \tl_if_exist:cTF { g__semantex_data_tl_#1_#2 } { \exp_not:v { g__semantex_data_tl_#1_#2 } } { - \str_if_eq:nnTF { #1 } { class_SemantexBaseObject } % Apparently, f-type expansion seemed to work here for once + \str_if_eq:nnTF { #1 } { class_SemantexBaseObject } { - \semantex_error_output_format:nN { #3 } \l__semantex_data_tl_get_exp_not_auxiliary_temp_tl - \msg_error:nnxn { semantex } { data_tl_not_found } { \l__semantex_data_tl_get_exp_not_auxiliary_temp_tl } { #2 } + \semantex_msg_error:nnn { #3 } { data_tl_not_found } { #2 } } { \__semantex_data_tl_get_exp_not_auxiliary:fnn { \semantex_data_parent_get:n { #1 } } { #2 } { #3 } @@ -1774,8 +2310,7 @@ \cs_generate_variant:Nn \__semantex_data_tl_get_exp_not_auxiliary:nnn { fnn } - -\cs_new:Npn \semantex_data_tl_get_store:nnN#1#2#3% maybe should be PROTECTED?? +\cs_new_protected:Npn \semantex_data_tl_get_store:nnN#1#2#3 { % #1 = name of object % #2 = the data to get @@ -1783,11 +2318,12 @@ \__semantex_data_tl_get_store_auxiliary:nnNn { #1 } { #2 } #3 { #1 } } -\cs_new:Npn \__semantex_data_tl_get_store_auxiliary:nnNn#1#2#3#4% maybe should be PROTECTED?? +\cs_new_protected:Npn \__semantex_data_tl_get_store_auxiliary:nnNn#1#2#3#4 { - % #1 = name of object + % #1 = name of register % #2 = the data to get % #3 = where to store it + % #4 = name of original register, for error message purposes \tl_if_exist:cTF { g__semantex_data_tl_#1_#2 } { \tl_set_eq:Nc #3 { g__semantex_data_tl_#1_#2 } @@ -1795,8 +2331,7 @@ { \str_if_eq:nnTF { #1 } { class_SemantexBaseObject } { - \semantex_error_output_format:nN { #4 } \l__semantex_data_tl_get_store_auxiliary_temp_tl - \msg_error:nnxn { semantex } { data_tl_not_found } { \l__semantex_data_tl_get_store_auxiliary_temp_tl } { #2 } + \msg_error:nnn { #4 } { data_tl_not_found } { #2 } } { \__semantex_data_tl_get_store_auxiliary:fnNn { \semantex_data_parent_get:n { #1 } } { #2 } #3 { #4 } @@ -1808,17 +2343,19 @@ \cs_generate_variant:Nn \semantex_data_tl_get_store:nnN { nnc } -\cs_new:Npn\semantex_data_tl_provide:nn#1#2 +\cs_new_protected:Npn\semantex_data_tl_provide:nn#1#2 { + % #1 = name of register + % #2 = the data to provide \tl_if_exist:cF { g__semantex_data_tl_#1_#2 } { \tl_set:cn { g__semantex_data_tl_#1_#2 } {} } } -\cs_new:Npn\semantex_data_tl_inherit:nn#1#2 +\cs_new_protected:Npn\semantex_data_tl_inherit:nn#1#2 { - % #1 = object + % #1 = register % #2 = piece of token list data % Takes the data #2 from the parent of #1 and saves it locally % to the object #1. After this, no more inheritance is taking place @@ -1830,21 +2367,15 @@ } } -\cs_set_eq:NN\semantex_data_tl_inherit_x:nn\semantex_data_tl_inherit:nn - % The same as inherit; historically, this one did an x type - % expansion first, but after changes in other places, this - % no longer appeard to be necessary. I decided to keep up the - % separation of the two, just in case. - -\cs_new:Npn \semantex_data_tl_set:nnn#1#2#3 +\cs_new_protected:Npn \semantex_data_tl_set:nnn#1#2#3 { \tl_set:cn { g__semantex_data_tl_#1_#2 } { #3 } } -\cs_generate_variant:Nn \semantex_data_tl_set:nnn { nnx , xnn , xnx } +\cs_generate_variant:Nn \semantex_data_tl_set:nnn { nnx } -\cs_new:Npn \semantex_data_tl_put_right:nnn#1#2#3 +\cs_new_protected:Npn \semantex_data_tl_put_right:nnn#1#2#3 { \semantex_data_tl_inherit:nn { #1 } { #2 } \tl_put_right:cn { g__semantex_data_tl_#1_#2 } { #3 } @@ -1852,7 +2383,7 @@ \cs_generate_variant:Nn \semantex_data_tl_put_right:nnn { nnx } -\cs_new:Npn \semantex_data_tl_put_left:nnn#1#2#3 +\cs_new_protected:Npn \semantex_data_tl_put_left:nnn#1#2#3 { \semantex_data_tl_inherit:nn { #1 } { #2 } \tl_put_left:cn { g__semantex_data_tl_#1_#2 } { #3 } @@ -1860,7 +2391,7 @@ \cs_generate_variant:Nn \semantex_data_tl_put_left:nnn { nnx } -\cs_new:Npn \semantex_data_tl_clear:nn#1#2 +\cs_new_protected:Npn \semantex_data_tl_clear:nn#1#2 { \semantex_data_tl_provide:nn { #1 } { #2 } \tl_clear:c { g__semantex_data_tl_#1_#2 } @@ -1868,7 +2399,7 @@ % DATA OF TYPE INTEGER: -\cs_new:Npn\semantex_data_int_provide:nn#1#2 +\cs_new_protected:Npn\semantex_data_int_provide:nn#1#2 { \bool_if_exist:cTF { g__semantex_data_int_#1_#2_bool_if_provided } { @@ -1884,13 +2415,14 @@ } } -\cs_new:Npn\semantex_data_int_inherit:nn#1#2 +\cs_new_protected:Npn\semantex_data_int_inherit:nn#1#2 { \bool_if_exist:cTF { g__semantex_data_int_#1_#2_bool_if_provided } { \bool_if:cF { g__semantex_data_int_#1_#2_bool_if_provided } { - \semantex_data_int_get_store:nnc { \semantex_data_parent_get:n { #1 } } { #2 } { g__semantex_data_int_#1_#2 } + \semantex_data_int_get_store:nnc { \semantex_data_parent_get:n { #1 } } { #2 } + { g__semantex_data_int_#1_#2 } \bool_set_true:c { g__semantex_data_int_#1_#2_bool_if_provided } } } @@ -1898,21 +2430,21 @@ \bool_new:c { g__semantex_data_int_#1_#2_bool_if_provided } \bool_set_true:c { g__semantex_data_int_#1_#2_bool_if_provided } \int_new:c { g__semantex_data_int_#1_#2 } - \semantex_data_int_get_store:nnc { \semantex_data_parent_get:n { #1 } } { #2 } { g__semantex_data_int_#1_#2 } + \semantex_data_int_get_store:nnc { \semantex_data_parent_get:n { #1 } } { #2 } + { g__semantex_data_int_#1_#2 } } } -\cs_new:Npn \semantex_data_int_get:nn#1#2{% maybe should be PROTECTED?? +\cs_new:Npn \semantex_data_int_get:nn#1#2{ % #1 = name of object % #2 = the intuence to get - % #3 = the command to store it in \__semantex_data_int_get_auxiliary:nnn { #1 } { #2 } { #1 } } -\cs_new:Npn \__semantex_data_int_get_auxiliary:nnn#1#2#3{% maybe should be PROTECTED?? +\cs_new:Npn \__semantex_data_int_get_auxiliary:nnn#1#2#3{ % #1 = name of object % #2 = the intuence to get - % #3 = the command to store it in + % #3 = stores the original register, for error message purposes \bool_if_exist:cTF { g__semantex_data_int_#1_#2_bool_if_provided } { \bool_if:cTF { g__semantex_data_int_#1_#2_bool_if_provided } @@ -1922,8 +2454,7 @@ { \str_if_eq:nnTF { #1 } { class_SemantexBaseObject } { - \semantex_error_output_format:nN { #3 } \__semantex_data_int_get_auxiliary_temp_tl - \msg_error:nnxn { semantex } { data_int_not_found } { \__semantex_data_int_get_auxiliary_temp_tl } { #2 } + \semantex_msg_error:nnn { #3 } { data_int_not_found } { #2 } } { \__semantex_data_int_get_auxiliary:fnn { \semantex_data_parent_get:n { #1 } } { #2 } { #3 } @@ -1933,8 +2464,7 @@ { \str_if_eq:nnTF { #1 } { class_SemantexBaseObject } { - \semantex_error_output_format:nN { #3 } \__semantex_data_int_get_auxiliary_temp_tl - \msg_error:nnxn { semantex } { data_int_not_found } { \__semantex_data_int_get_auxiliary_temp_tl } { #2 } + \semantex_msg_error:nnn { #3 } { data_int_not_found } { #2 } } { \__semantex_data_int_get_auxiliary:fnn { \semantex_data_parent_get:n { #1 } } { #2 } { #3 } @@ -1945,14 +2475,14 @@ \cs_generate_variant:Nn \__semantex_data_int_get_auxiliary:nnn { fnn } -\cs_new:Npn \semantex_data_int_get_store:nnN#1#2#3{% maybe should be PROTECTED?? +\cs_new_protected:Npn \semantex_data_int_get_store:nnN#1#2#3{ % #1 = name of object % #2 = the intuence to get % #3 = the command to store it in \__semantex_data_int_get_store_auxiliary:nnNn { #1 } { #2 } #3 { #1 } } -\cs_new:Npn\__semantex_data_int_get_store_auxiliary:nnNn#1#2#3#4{% maybe should be PROTECTED?? +\cs_new_protected:Npn\__semantex_data_int_get_store_auxiliary:nnNn#1#2#3#4{ % #1 = name of object % #2 = the intuence to get % #3 = the command to store it in @@ -1965,8 +2495,7 @@ { \str_if_eq:nnTF { #1 } { class_SemantexBaseObject } { - \semantex_error_output_format:nN { #4 } \l__semantex_data_int_get_store_auxiliary_temp_tl - \msg_error:nnxn { semantex } { data_int_not_found } { \l__semantex_data_int_get_store_auxiliary_temp_tl } { #2 } + \semantex_msg_error:nnn { #4 } { data_int_not_found } { #2 } } { \__semantex_data_int_get_store_auxiliary:fnNn { \semantex_data_parent_get:n { #1 } } { #2 } #3 { #4 } @@ -1976,8 +2505,7 @@ { \str_if_eq:nnTF { #1 } { class_SemantexBaseObject } { - \semantex_error_output_format:nN { #4 } \l__semantex_data_int_get_store_auxiliary_temp_tl - \msg_error:nnxn { semantex } { data_int_not_found } { \l__semantex_data_int_get_store_auxiliary_temp_tl } { #2 } + \semantex_msg_error:nnn { #4 } { data_int_not_found } { #2 } } { \__semantex_data_int_get_store_auxiliary:fnNn { \semantex_data_parent_get:n { #1 } } { #2 } #3 { #4 } @@ -1989,59 +2517,29 @@ \cs_generate_variant:Nn \semantex_data_int_get_store:nnN { nnc } -\cs_new:Npn\semantex_data_int_incr:nn#1#2 +\cs_new_protected:Npn\semantex_data_int_incr:nn#1#2 { \semantex_data_int_inherit:nn { #1 } { #2 } \int_incr:c { g__semantex_data_int_#1_#2 } } -\cs_new:Npn\semantex_data_int_set:nnn#1#2#3 +\cs_new_protected:Npn\semantex_data_int_set:nnn#1#2#3 { \semantex_data_int_provide:nn { #1 } { #2 } \int_set:cn { g__semantex_data_int_#1_#2 } { #3 } } -\cs_new:Npn\semantex_data_int_if_positive:nnTF#1#2#3#4 +\cs_new_protected:Npn\semantex_data_int_if_positive:nnTF#1#2#3#4 { -% \semantex_data_int_inherit:nn { #1 } { #2 } % This should not be necessary, ubt is, for unkonwn reasons \int_compare:nNnTF { \semantex_data_int_get:nn { #1 } { #2 } } > { 0 } { #3 } { #4 } } -\cs_generate_variant:Nn\semantex_data_int_if_positive:nnTF { nnT } - -\cs_new:Npn\semantex_data_int_if_positive:nnF#1#2#3 -{ - \semantex_data_int_if_positive:nnTF { #1 } { #2 } { } { #3 } -} - -\cs_new:Npn\semantex_data_int_if_greater_than_one:nnTF#1#2#3#4 +\cs_new_protected:Npn\semantex_data_int_if_greater_than_one:nnTF#1#2#3#4 { \int_compare:nNnTF { \semantex_data_int_get:nn { #1 } { #2 } } > { 1 } { #3 } { #4 } } -\cs_generate_variant:Nn\semantex_data_int_if_greater_than_one:nnTF { nnT } - -\cs_new:Npn\semantex_data_int_if_greater_than_one:nnF#1#2#3 -{ - \semantex_data_int_if_greater_than_one:nnTF { #1 } { #2 } { } { #3 } -} - -\cs_new:Npn\semantex_data_int_if_greater_than:nnnTF#1#2#3#4#5 -{ - \int_compare:nNnTF { \semantex_data_int_get:nn { #1 } { #2 } } > { #3 } { #4 } { #5 } -} - -\cs_new:Npn\semantex_data_int_if_less_than:nnnTF#1#2#3#4#5 -{ - \int_compare:nNnTF { \semantex_data_int_get:nn { #1 } { #2 } } < { #3 } { #4 } { #5 } -} - -\cs_new:Npn\semantex_data_int_if_equal:nnnTF#1#2#3#4#5 -{ - \int_compare:nNnTF { \semantex_data_int_get:nn { #1 } { #2 } } < { #3 } { #4 } { #5 } -} - -\cs_new:Npn\semantex_data_int_clear:nn#1#2 +\cs_new_protected:Npn\semantex_data_int_clear:nn#1#2 { \semantex_data_int_provide:nn { #1 } { #2 } \int_zero:c { g__semantex_data_int_#1_#2 } @@ -2049,7 +2547,7 @@ % COMMANDS FOR HANDLING DATA OF SEQUENCE TYPE -\cs_new:Npn \semantex_data_seq_get_store:nnN#1#2#3{% maybe should be PROTECTED?? +\cs_new_protected:Npn \semantex_data_seq_get_store:nnN#1#2#3{ % #1 = name of object % #2 = the sequence to get % #3 = the command to store it in @@ -2060,17 +2558,17 @@ \seq_set_eq:Nc#3 { g__semantex_data_seq_#1_#2 } } { - \semantex_data_seq_get_store:nnN{ \semantex_data_parent_get:n { #1 } }{#2}#3 + \semantex_data_seq_get_store:nnN { \semantex_data_parent_get:n { #1 } } { #2 } #3 } } { - \semantex_data_seq_get_store:nnN{ \semantex_data_parent_get:n { #1 } }{#2}#3% + \semantex_data_seq_get_store:nnN { \semantex_data_parent_get:n { #1 } } { #2 } #3 } } -\cs_generate_variant:Nn \semantex_data_seq_get_store:nnN { vnN, nnc, vnc } % Remove these later +\cs_generate_variant:Nn \semantex_data_seq_get_store:nnN { nnc } -\cs_new:Npn\semantex_data_seq_provide:nn#1#2 +\cs_new_protected:Npn\semantex_data_seq_provide:nn#1#2 { \bool_if_exist:cTF { g__semantex_data_seq_#1_#2_bool_if_provided } { @@ -2086,7 +2584,7 @@ } } -\cs_new:Npn\semantex_data_seq_inherit:nn#1#2 +\cs_new_protected:Npn\semantex_data_seq_inherit:nn#1#2 { \bool_if_exist:cTF { g__semantex_data_seq_#1_#2_bool_if_provided } { @@ -2097,20 +2595,20 @@ } } { - \semantex_data_seq_get_store:nnc { \semantex_data_parent_get:n { #1 } } { #2 } { g__semantex_data_seq_#1_#2 } \bool_new:c { g__semantex_data_seq_#1_#2_bool_if_provided } \bool_set_true:c { g__semantex_data_seq_#1_#2_bool_if_provided } \seq_if_exist:cF { g__semantex_data_seq_#1_#2 } { \seq_new:c { g__semantex_data_seq_#1_#2 } } + \semantex_data_seq_get_store:nnc { \semantex_data_parent_get:n { #1 } } { #2 } { g__semantex_data_seq_#1_#2 } } } -\cs_new:Npn\semantex_data_seq_put_right:nnn#1#2#3 +\cs_new_protected:Npn\semantex_data_seq_put_right:nnn#1#2#3 { \semantex_data_seq_inherit:nn { #1 } { #2 } \seq_put_right:cn { g__semantex_data_seq_#1_#2 } { #3 } } -\cs_new:Npn\semantex_data_seq_clear:nn#1#2 +\cs_new_protected:Npn\semantex_data_seq_clear:nn#1#2 { \semantex_data_seq_provide:nn { #1 } { #2 } \seq_clear:c { g__semantex_data_seq_#1_#2 } @@ -2151,16 +2649,16 @@ } } -\cs_generate_variant:Nn \semantex_data_bool_get:nnTF { onTF, fnTF, xnTF, vnTF, nnT } +\cs_generate_variant:Nn \semantex_data_bool_get:nnTF { fnTF, nnT } \cs_new:Npn\semantex_data_bool_get:nnF#1#2#3 { \semantex_data_bool_get:nnTF { #1 } { #2 } { } { #3 } } -\cs_new:Npn\semantex_data_bool_provide:nn#1#2 +\cs_new_protected:Npn\semantex_data_bool_provide:nn#1#2 { - % #1 = name of the object + % #1 = name of the register % #2 = boolean to provide \bool_if_exist:cTF { g__semantex_data_bool_#1_if_#2_bool_if_provided } { @@ -2176,73 +2674,99 @@ } } -\cs_new:Npn\semantex_data_bool_set_true:nn#1#2 +\cs_new_protected:Npn\semantex_data_bool_set_true:nn#1#2 { - % #1 = name of the object - % #2 = boolean to provide + % #1 = name of the register + % #2 = boolean to set true \semantex_data_bool_provide:nn { #1 } { #2 } \bool_set_true:c { g__semantex_data_bool_#1_if_#2 } } -\cs_generate_variant:Nn \semantex_data_bool_set_true:nn { xn } - -\cs_new:Npn\semantex_data_bool_set_false:nn#1#2 +\cs_new_protected:Npn\semantex_data_bool_set_false:nn#1#2 { - % #1 = name of the object - % #2 = boolean to provide + % #1 = name of the register + % #2 = boolean to set false \semantex_data_bool_provide:nn { #1 } { #2 } \bool_set_false:c { g__semantex_data_bool_#1_if_#2 } } -% COMMANDS FOR HANDLING COMMAND SEQUENCE DATA AND KEYVAL SYNTAX: +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% COMMANDS FOR HANDLING KEYVAL INTERFACES +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\cs_generate_variant:Nn \keyval_parse:NNn { cco , ccn } +\cs_generate_variant:Nn \semantex_keyval_parse:NNn { ccn } -\cs_new:Npn \semantex_keys_set:nn#1#2 +\cs_new_protected:Npn \semantex_keys_set:nn#1#2 { - \semantex_provide_user_commands:n { #1 } + \cs_set_eq:NN\l__semantex_keys_set_old_this_temp_cs:\semantex_this: + \cs_set:Nn\semantex_this:{#1} % The central command for doing keyval setup % #1 = object % #2 = keys - \keyval_parse:ccn % Used to use o-type expansions, but no longer seems necessary - { __semantex_data_cs_#1_singlekey:n } - { __semantex_data_cs_#1_valuekey:nn } - { #2 } + \semantex_keyval_parse:ccn % Used to use o-type expansions, but no longer seems necessary + { __semantex_data_cs_#1_singlekey:n } + { __semantex_data_cs_#1_valuekey:nn } + { #2 } + \cs_set_eq:NN\semantex_this:\l__semantex_keys_set_old_this_temp_cs: } -\cs_new:Npn \semantex_arg_keys_set:nn#1#2 +\cs_new_protected:Npn \semantex_keys_set_x:nn#1#2 +{ + \cs_set_eq:NN\l__semantex_keys_set_old_this_temp_cs:\semantex_this: + \cs_set:Nn\semantex_this:{#1} + % The central command for doing expanded keyval setup + % #1 = object + % #2 = keys + \semantex_keyval_parse:ccn % Used to use o-type expansions, but no longer seems necessary + { __semantex_data_cs_#1_singlekey_x:n } + { __semantex_data_cs_#1_valuekey:nx } + { #2 } + \cs_set_eq:NN\semantex_this:\l__semantex_keys_set_old_this_temp_cs: +} + +\cs_new_protected:Npn \semantex_arg_keys_set:nn#1#2 { % The central command for doing keyval setup for the argument % #1 = object % #2 = keys - \keyval_parse:ccn % See last command - { __semantex_data_cs_#1_arg_singlekey:n } - { __semantex_data_cs_#1_arg_valuekey:nn } - { #2 } + \semantex_keyval_parse:ccn % See last command + { __semantex_data_cs_#1_arg_singlekey:n } + { __semantex_data_cs_#1_arg_valuekey:nn } + { #2 } +} + +\cs_new_protected:Npn \semantex_arg_keys_set_x:nn#1#2 +{ + % The central command for doing expanded keyval setup for the argument + % #1 = object + % #2 = keys + \semantex_keyval_parse:ccn % See last command + { __semantex_data_cs_#1_arg_singlekey_x:n } + { __semantex_data_cs_#1_arg_valuekey:nx } + { #2 } } \cs_generate_variant:Nn \clist_map_function:nN { nc } -\cs_new:Npn \semantex_arg_singlekeys_set:nn#1#2 +\cs_new_protected:Npn \semantex_arg_singlekeys_set:nn#1#2 { % This command is necessary because you sometimes want to only allow singlekeys % and not valuekeys in arguments (for instance, if you allow valuekeys, anything - % containing an equality sign will die horribly in the argument of any object + % containing an equality sign will die horribly in the argument of any object) \clist_map_function:nc {#2} { __semantex_data_cs_#1_arg_singlekey:n } } -\cs_generate_variant:Nn \semantex_keys_set:nn { xn } - \DeclareDocumentCommand\SetupClass{mm}{ % a user-level command for setting up the object % #1 = class % #2 = setup \semantex_class_if_exist:NTF #1 { - \semantex_keys_set:xn { class_\cs_to_str:N #1 }{ #2 } + \semantex_keys_set:nn { \semantex_class_to_register:N #1 }{ #2 } } { - \semantex_error_output_format:xN { class_\cs_to_str:N #1 } \l__setup_class_temp_tl - \msg_error:nnx { semantex } { setup_unknown_class } { \l__setup_class_temp_tl } + \semantex_msg_error:nn { \semantex_class_to_register:N #1 } { setup_unknown_class } } } @@ -2251,25 +2775,25 @@ % #2 = setup \semantex_object_if_exist:NTF #1 { - \semantex_keys_set:xn { object_\cs_to_str:N #1 }{ #2 } + \semantex_keys_set:nn { \semantex_object_to_register:N #1 }{ #2 } } { - \semantex_error_output_format:xN { object_\cs_to_str:N #1 } \l__setup_object_temp_tl - \msg_error:nnx { semantex } { setup_unknown_object } { \l__setup_object_temp_tl } + \semantex_msg_error:nn { \semantex_object_to_register:N #1 } { setup_unknown_object } } } -\cs_new:Npn\semantex_valuekey:nnn#1#2#3 +\cs_new_protected:Npn\semantex_valuekey:nnn#1#2#3 { + % The central command for executing valuekeys, + % i.e. keys taking a value + % #1 = register + % #2 = name of the key + % #3 = value \__semantex_valuekey:nnnn { #1 } { #2 } { #3 } { #1 } } -\cs_new:Npn \__semantex_valuekey:nnnn#1#2#3#4 +\cs_new_protected:Npn \__semantex_valuekey:nnnn#1#2#3#4 { - % Takes care of valuekeys, keys taking a value - % #1 = class/object - % #2 = name of the key - % #3 = value \cs_if_exist:cTF { __semantex_data_cs_custom_valuekey_#1_#2:nn } { \use:c { __semantex_data_cs_custom_valuekey_#1_#2:nn } { #4 } { #3 } @@ -2277,8 +2801,7 @@ { \str_if_eq:nnTF { #1 } { class_SemantexBaseObject } { - \semantex_error_output_format:nN { #4 } \l__semantex_valuekey_unknown_key_temp_tl - \msg_error:nnxn { semantex } { valuekey_not_found } { \l__semantex_valuekey_unknown_key_temp_tl } { #2 } + \semantex_msg_error:nnn { #4 } { valuekey_not_found } { #2 } } { \__semantex_valuekey:fnnn { \semantex_data_parent_get:n { #1 } } { #2 } { #3 } { #4 } @@ -2288,18 +2811,37 @@ \cs_generate_variant:Nn \__semantex_valuekey:nnnn { fnnn } -\cs_generate_variant:Nn \semantex_valuekey:nnn { xnn } +\cs_generate_variant:Nn \semantex_valuekey:nnn { nnx } -\cs_new:Npn\semantex_singlekey:nn#1#2 +\cs_new_protected:Npn\semantex_base_object_valuekey:nnn#1#2#3 { - \__semantex_singlekey:nnn { #1 } { #2 } { #1 } + % Skips through the steps above to go directly to the + % valuekey as defined by \SemantexBaseObject. + % This is only being used in the rendering routine, + % so so far, an corresponding command for singlekeys + % has not been needed. + % #1 = register + % #2 = key + % #3 = value + \use:c { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_#2:nn } { #1 } { #3 } } -\cs_new:Npn\__semantex_singlekey:nnn#1#2#3 +\cs_new_protected:Npn\semantex_singlekey:nn#1#2 { - % #1 = class/object + % The central command for executing singlekeys, + % i.e. keys taking no + % #1 = register % #2 = name of the key - \cs_if_exist:cTF { \tl_to_str:n{__semantex_data_cs_custom_singlekey_#1_#2:n } } + \__semantex_singlekey:nnn { #1 } { #2 } { #1 } +} + +\cs_new_protected:Npn\__semantex_singlekey:nnn#1#2#3 +{ + \cs_if_exist:cTF { __semantex_data_cs_custom_singlekey_#1_\tl_to_str:n{ #2 }:n } + % This is necessary in order to allow the case where something nasty + % and unexpandable gets passed as singlekey -- this often happens + % because of the convention that \<Object>[<something not a key>] + % just prints <something not a key> { \use:c { __semantex_data_cs_custom_singlekey_#1_#2:n } { #3 } } @@ -2307,7 +2849,6 @@ \str_if_eq:nnTF { #1 } { class_SemantexBaseObject } { \semantex_valuekey:nnn { #3 } { default } { #2 } - %#2 } { \__semantex_singlekey:fnn { \semantex_data_parent_get:n { #1 } } { #2 } { #3 } @@ -2317,22 +2858,48 @@ \cs_generate_variant:Nn \__semantex_singlekey:nnn { fnn } -\cs_generate_variant:Nn \semantex_singlekey:nn { xn } +\cs_new_protected:Npn\semantex_singlekey_x:nn#1#2 +{ + % The central command for executing expanded singlekeys, + % i.e. keys taking no + % #1 = register + % #2 = name of the key + \__semantex_singlekey_x:nnn { #1 } { #2 } { #1 } +} -\cs_new:Npn\semantex_arg_valuekey:nnn#1#2#3 +\cs_new_protected:Npn\__semantex_singlekey_x:nnn#1#2#3 { - % CHANGE ORDER OF KEYS - \__semantex_arg_valuekey:nnnn { #1 } { #2 } { #3 } { #1 } + \cs_if_exist:cTF { __semantex_data_cs_custom_singlekey_#1_\tl_to_str:n{ #2 }:n } + { + \use:c { __semantex_data_cs_custom_singlekey_#1_#2:n } { #3 } + % and no, we don't want :x here; we don't need to expand + % the name of the register + } + { + \str_if_eq:nnTF { #1 } { class_SemantexBaseObject } + { + \semantex_valuekey:nnx { #3 } { default } { #2 } + } + { + \__semantex_singlekey_x:fnn { \semantex_data_parent_get:n { #1 } } { #2 } { #3 } + } + } } -\cs_new:Npn \__semantex_arg_valuekey:nnnn#1#2#3#4 +\cs_generate_variant:Nn \__semantex_singlekey_x:nnn { fnn } + +\cs_new_protected:Npn\semantex_arg_valuekey:nnn#1#2#3 { - % Takes care of valuekeys, keys with a value - % For the sake of implementation, the arguments - % come in a strange order - % #1 = class/object + % Takes care of argument valuekeys, + % i.e. argument keys with a value + % #1 = register % #2 = name of the key % #3 = value of the key + \__semantex_arg_valuekey:nnnn { #1 } { #2 } { #3 } { #1 } +} + +\cs_new_protected:Npn \__semantex_arg_valuekey:nnnn#1#2#3#4 +{ \cs_if_exist:cTF { __semantex_data_cs_custom_arg_valuekey_#1_#2:nn } { \use:c { __semantex_data_cs_custom_arg_valuekey_#1_#2:nn } { #4 } { #3 } @@ -2340,8 +2907,7 @@ { \str_if_eq:nnTF { #1 } { class_SemantexBaseObject } { - \semantex_error_output_format:nN { #4 } \l__semantex_valuekey_unknown_arg_key_temp_tl - \msg_error:nnxn { semantex } { arg_valuekey_not_found } { \l__semantex_valuekey_unknown_arg_key_temp_tl } { #2 } + \msg_error:nnn { #1 } { arg_valuekey_not_found } { #2 } } { \__semantex_arg_valuekey:fnnn { \semantex_data_parent_get:n { #1 } } { #2 } { #3 } { #4 } @@ -2351,16 +2917,20 @@ \cs_generate_variant:Nn \__semantex_arg_valuekey:nnnn { fnnn } -\cs_new:Npn \semantex_arg_singlekey:nn#1#2 +\cs_generate_variant:Nn \semantex_arg_valuekey:nnn { nnx } + +\cs_new_protected:Npn \semantex_arg_singlekey:nn#1#2 { + % The central command for executing argument singlekeys, + % i.e. keys taking no + % #1 = register + % #2 = name of the key \__semantex_arg_singlekey:nnn { #1 } { #2 } { #1 } } -\cs_new:Npn \__semantex_arg_singlekey:nnn#1#2#3 +\cs_new_protected:Npn \__semantex_arg_singlekey:nnn#1#2#3 { - % #1 = class/object - % #2 = name of the key - \cs_if_exist:cTF { \tl_to_str:n{__semantex_data_cs_custom_arg_singlekey_#1_#2:n } } + \cs_if_exist:cTF { __semantex_data_cs_custom_arg_singlekey_#1_\tl_to_str:n{ #2 }:n } { \use:c { __semantex_data_cs_custom_arg_singlekey_#1_#2:n } { #3 } } @@ -2368,7 +2938,6 @@ \str_if_eq:nnTF { #1 } { class_SemantexBaseObject } { \semantex_arg_valuekey:nnn { #3 } { default } { #2 } - %#2 } { \__semantex_arg_singlekey:fnn { \semantex_data_parent_get:n { #1 } } { #2 } { #3 } @@ -2378,4018 +2947,2734 @@ \cs_generate_variant:Nn \__semantex_arg_singlekey:nnn { fnn } -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% THE VALUEKEYS FOR \SemantexBaseObject -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -% Now for the commands that are the basis of the keyval interface, -% namely the keys providing the keyval interface for the -% class \SemantexBaseObject. For historical reasons, they are defined -% as below as standalone commands and not when delcaring the -% class \SemantexBaseObject. I hope to change this in the future, but -% this is purely a matter of aesthetics, with no practical consequences. - -% For all of them, #1 = name of the class/object, and #2 = value of -% the key. - -% First, some very simple keys that we shall need over and over again: - -\cs_new:Npn\semantex_grab_first_argument_of_two:nn#1#2{#1} -\cs_new:Npn\semantex_grab_second_argument_of_two:nn#1#2{#2} - -\cs_new:Npn\semantex_grab_first_argument_of_three:nnn#1#2#3{#1} -\cs_new:Npn\semantex_grab_second_argument_of_three:nnn#1#2#3{#2} -\cs_new:Npn\semantex_grab_third_argument_of_three:nnn#1#2#3{#3} - -\cs_new:Npn\semantex_grab_first_argument_of_four:nnnn#1#2#3#4{#1} -\cs_new:Npn\semantex_grab_second_argument_of_four:nnnn#1#2#3#4{#2} -\cs_new:Npn\semantex_grab_third_argument_of_four:nnnn#1#2#3#4{#3} -\cs_new:Npn\semantex_grab_fourth_argument_of_four:nnnn#1#2#3#4{#4} - -\cs_new:Npn\semantex_grab_first_argument_of_five:nnnnn#1#2#3#4#5{#1} -\cs_new:Npn\semantex_grab_second_argument_of_five:nnnnn#1#2#3#4#5{#2} -\cs_new:Npn\semantex_grab_third_argument_of_five:nnnnn#1#2#3#4#5{#3} -\cs_new:Npn\semantex_grab_fourth_argument_of_five:nnnnn#1#2#3#4#5{#4} -\cs_new:Npn\semantex_grab_fifth_argument_of_five:nnnnn#1#2#3#4#5{#5} - -\cs_new:Npn\semantex_grab_first_argument_of_six:nnnnnn#1#2#3#4#5#6{#1} -\cs_new:Npn\semantex_grab_second_argument_of_six:nnnnnn#1#2#3#4#5#6{#2} -\cs_new:Npn\semantex_grab_third_argument_of_six:nnnnnn#1#2#3#4#5#6{#3} -\cs_new:Npn\semantex_grab_fourth_argument_of_six:nnnnnn#1#2#3#4#5#6{#4} -\cs_new:Npn\semantex_grab_fifth_argument_of_six:nnnnnn#1#2#3#4#5#6{#5} -\cs_new:Npn\semantex_grab_sixth_argument_of_six:nnnnnn#1#2#3#4#5#6{#6} - -\cs_new:Npn\semantex_grab_first_argument_of_seven:nnnnnnn#1#2#3#4#5#6#7{#1} -\cs_new:Npn\semantex_grab_second_argument_of_seven:nnnnnnn#1#2#3#4#5#6#7{#2} -\cs_new:Npn\semantex_grab_third_argument_of_seven:nnnnnnn#1#2#3#4#5#6#7{#3} -\cs_new:Npn\semantex_grab_fourth_argument_of_seven:nnnnnnn#1#2#3#4#5#6#7{#4} -\cs_new:Npn\semantex_grab_fifth_argument_of_seven:nnnnnnn#1#2#3#4#5#6#7{#5} -\cs_new:Npn\semantex_grab_sixth_argument_of_seven:nnnnnnn#1#2#3#4#5#6#7{#6} -\cs_new:Npn\semantex_grab_seventh_argument_of_seven:nnnnnnn#1#2#3#4#5#6#7{#7} - -\cs_new:Npn\semantex_grab_first_argument_of_eight:nnnnnnnn#1#2#3#4#5#6#7#8{#1} -\cs_new:Npn\semantex_grab_second_argument_of_eight:nnnnnnnn#1#2#3#4#5#6#7#8{#2} -\cs_new:Npn\semantex_grab_third_argument_of_eight:nnnnnnnn#1#2#3#4#5#6#7#8{#3} -\cs_new:Npn\semantex_grab_fourth_argument_of_eight:nnnnnnnn#1#2#3#4#5#6#7#8{#4} -\cs_new:Npn\semantex_grab_fifth_argument_of_eight:nnnnnnnn#1#2#3#4#5#6#7#8{#5} -\cs_new:Npn\semantex_grab_sixth_argument_of_eight:nnnnnnnn#1#2#3#4#5#6#7#8{#6} -\cs_new:Npn\semantex_grab_seventh_argument_of_eight:nnnnnnnn#1#2#3#4#5#6#7#8{#7} -\cs_new:Npn\semantex_grab_eighth_argument_of_eight:nnnnnnnn#1#2#3#4#5#6#7#8{#8} - -\cs_new:Npn\semantex_grab_first_argument_of_nine:nnnnnnnnn#1#2#3#4#5#6#7#8#9{#1} -\cs_new:Npn\semantex_grab_second_argument_of_nine:nnnnnnnnn#1#2#3#4#5#6#7#8#9{#2} -\cs_new:Npn\semantex_grab_third_argument_of_nine:nnnnnnnnn#1#2#3#4#5#6#7#8#9{#3} -\cs_new:Npn\semantex_grab_fourth_argument_of_nine:nnnnnnnnn#1#2#3#4#5#6#7#8#9{#4} -\cs_new:Npn\semantex_grab_fifth_argument_of_nine:nnnnnnnnn#1#2#3#4#5#6#7#8#9{#5} -\cs_new:Npn\semantex_grab_sixth_argument_of_nine:nnnnnnnnn#1#2#3#4#5#6#7#8#9{#6} -\cs_new:Npn\semantex_grab_seventh_argument_of_nine:nnnnnnnnn#1#2#3#4#5#6#7#8#9{#7} -\cs_new:Npn\semantex_grab_eighth_argument_of_nine:nnnnnnnnn#1#2#3#4#5#6#7#8#9{#8} -\cs_new:Npn\semantex_grab_ninth_argument_of_nine:nnnnnnnnn#1#2#3#4#5#6#7#8#9{#9} - - -\cs_generate_variant:Nn\str_if_eq:nnTF {xxTF,ooTF} - -\cs_generate_variant:Nn\str_if_eq:nnT {xxT, ooT} - -\cs_generate_variant:Nn\str_if_eq:nnF {xxF, ooF} - -\cs_generate_variant:Nn\tl_if_blank:nTF { xTF, xT } - -\cs_generate_variant:Nn \tl_if_blank:nF { xF } - -\cs_new:Npn\semantex_provide_user_commands:n#1 -{ - % This keys just executes whatever data you plug into it. - % Possibly, going forward, it might make more sense to define all - % of these commands in the keyval handling command - % so that the get commands are accessible from all keys. - \cs_set:Npn\SemantexDataProvide##1{\semantex_data_tl_provide:nn{#1}{\tl_trim_spaces:n{##1}}} - \cs_set:Npn\SemantexDataSet##1##2{\semantex_data_tl_set:nnn{#1}{\tl_trim_spaces:n{##1}}{##2}} - \cs_set:Npn\SemantexDataSetx##1##2{\semantex_data_tl_set:nnx{#1}{\tl_trim_spaces:n{##1}}{##2}} - \cs_set:Npn\SemantexDataPutRight##1##2{\semantex_data_tl_put_right:nnn{#1}{\tl_trim_spaces:n{##1}}{##2}} - \cs_set:Npn\SemantexDataPutRightx##1##2{\semantex_data_tl_put_right:nnx{#1}{\tl_trim_spaces:n{##1}}{##2}} - \cs_set:Npn\SemantexDataPutLeft##1##2{\semantex_data_tl_put_left:nnn{#1}{\tl_trim_spaces:n{##1}}{##2}} - \cs_set:Npn\SemantexDataPutLeftx##1##2{\semantex_data_tl_put_left:nnx{#1}{\tl_trim_spaces:n{##1}}{##2}} - \cs_set:Npn\SemantexDataGet##1{\semantex_data_tl_get:nn{#1}{\tl_trim_spaces:n{##1}}} - \cs_set:Npn\SemantexDataGetExpNot##1{\semantex_data_tl_get_exp_not:nn{#1}{\tl_trim_spaces:n{##1}}} - \cs_set:Npn\SemantexDataClear##1{\semantex_data_tl_clear:nn{#1}{\tl_trim_spaces:n{##1}}} - \cs_set:Npn\SemantexKeysSet##1{\semantex_keys_set:nn{#1}{##1}} - \cs_set:Npn\SemantexKeysSetx##1{\semantex_keys_set:nx{#1}{##1}} - \cs_set:Npn\SemantexStrIfEqTF##1##2##3##4{\str_if_eq:xxTF{##1}{##2}{##3}{##4}} - \cs_set:Npn\SemantexStrIfEqT##1##2##3{\str_if_eq:xxT{##1}{##2}{##3}} - \cs_set:Npn\SemantexStrIfEqF##1##2##3{\str_if_eq:xxF{##1}{##2}{##3}} - \cs_set:Npn\SemantexIfBlankTF##1##2##3{\tl_if_blank:xTF{##1}{##2}{##3}} - \cs_set:Npn\SemantexIfBlankT##1##2{\tl_if_blank:xT{##1}{##2}} - \cs_set:Npn\SemantexIfBlankF##1##2{\tl_if_blank:xF{##1}{##2}} - \cs_set:Npn\SemantexBoolProvide##1{\semantex_data_bool_provide:nn{#1}{\tl_trim_spaces:n{##1}}} - \cs_set:Npn\SemantexBoolSetTrue##1{\semantex_data_bool_set_true:nn{#1}{\tl_trim_spaces:n{##1}}} - \cs_set:Npn\SemantexBoolSetFalse##1{\semantex_data_bool_set_false:nn{#1}{\tl_trim_spaces:n{##1}}} - \cs_set:Npn\SemantexBoolIfTF##1##2##3{\semantex_data_bool_get:nnTF{#1}{\tl_trim_spaces:n{##1}}{##2}{##3}} - \cs_set:Npn\SemantexBoolIfT##1##2{\semantex_data_bool_get:nnTF{#1}{\tl_trim_spaces:n{##1}}{##2}{}} - \cs_set:Npn\SemantexBoolIfF##1##2{\semantex_data_bool_get:nnTF{#1}{\tl_trim_spaces:n{##1}}{}{##2}} - \cs_set:Npn\SemantexIntProvide##1{\semantex_data_int_provide:nn{#1}{\tl_trim_spaces:n{##1}}} - \cs_set:Npn\SemantexIntGet##1{\semantex_data_int_get:nn{#1}{\tl_trim_spaces:n{\tl_trim_spaces:n{##1}}}} - \cs_set:Npn\SemantexIntClear##1{\semantex_data_int_clear:nn{#1}{\tl_trim_spaces:n{##1}}} - \cs_set:Npn\SemantexIntIncr##1{\semantex_data_int_incr:nn{#1}{\tl_trim_spaces:n{##1}}} - \cs_set:Npn\SemantexIntSet##1##2{\semantex_data_int_set:nnn{#1}{\tl_trim_spaces:n{##1}}{##2}} - \cs_set:Npn\SemantexIntIfGreaterThanTF##1##2##3##4 - { - \int_compare:nNnTF - { ##1 } - > - { ##2 } - { ##3 } - { ##4 } - } - \cs_set:Npn\SemantexIntIfGreaterThanT##1##2##3 - { - \int_compare:nNnTF - { ##1 } - > - { ##2 } - { ##3 } - { } - } - \cs_set:Npn\SemantexIntIfGreaterThanF##1##2##3 - { - \int_compare:nNnTF - { ##1 } - > - { ##2 } - { } - { ##3 } - } - \cs_set:Npn\SemantexIntIfEqualTF##1##2##3##4 - { - \int_compare:nNnTF - { ##1 } - = - { ##2 } - { ##3 } - { ##4 } - } - \cs_set:Npn\SemantexIntIfEqualT##1##2##3 - { - \int_compare:nNnTF - { ##1 } - = - { ##2 } - { ##3 } - { } - } - \cs_set:Npn\SemantexIntIfEqualF##1##2##3 - { - \int_compare:nNnTF - { ##1 } - = - { ##2 } - { } - { ##3 } - } - \cs_set:Npn\SemantexIntIfLessThanTF##1##2##3##4 - { - \int_compare:nNnTF - { ##1 } - < - { ##2 } - { ##3 } - { ##4 } - } - \cs_set:Npn\SemantexIntIfLessThanT##1##2##3 - { - \int_compare:nNnTF - { ##1 } - < - { ##2 } - { ##3 } - { } - } - \cs_set:Npn\SemantexIntIfLessThanF##1##2##3 - { - \int_compare:nNnTF - { ##1 } - < - { ##2 } - { } - { ##3 } - } - \cs_set:Npn\SemantexExpNot##1{\exp_not:n{##1}} - \cs_set:Npn\SemantexERRORKeyValueNotFound##1 - { - \semantex_error_output_format:nN { #1 } \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ERRORkeyvaluenotfound_temp_tl - \msg_error:nnxoo { semantex } { key_value_not_found } - { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ERRORkeyvaluenotfound_temp_tl } - { \semantex_grab_first_argument_of_two:nn ##1 } - { \semantex_grab_second_argument_of_two:nn ##1 } - } - - \cs_set:Npn\SemantexERROR##1 - { - \semantex_error_output_format:nN { #1 } \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ERROR_temp_tl - \msg_error:nnxoo { semantex } { generic_error } - { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ERROR_temp_tl } - { \semantex_grab_first_argument_of_two:nn ##1 } - { \semantex_grab_second_argument_of_two:nn ##1 } - } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_dataprovide:nn#1#2 -{ - \semantex_data_tl_provide:nn { #1 } { #2 } -} - -\cs_generate_variant:Nn \semantex_data_tl_set:nnn { noo , nox , nno , nnx } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_dataset:nn#1#2 -{ - \semantex_data_tl_set:nno { #1 } - { \tl_trim_spaces:n { \semantex_grab_first_argument_of_two:nn #2 } } - { \semantex_grab_second_argument_of_two:nn #2 } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_datasetx:nn#1#2 -{ - \semantex_data_tl_set:nnx { #1 } - { \tl_trim_spaces:n { \semantex_grab_first_argument_of_two:nn #2 } } - { \semantex_grab_second_argument_of_two:nn #2 } -} - -\cs_generate_variant:Nn \semantex_data_tl_put_right:nnn { noo , nox } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_dataputright:nn#1#2{ - \semantex_data_tl_put_right:nno { #1 } - { \tl_trim_spaces:n { \semantex_grab_first_argument_of_two:nn #2 } } - { \semantex_grab_second_argument_of_two:nn #2 } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_dataputrightx:nn#1#2{ - \semantex_data_tl_put_right:nnx { #1 } - { \tl_trim_spaces:n { \semantex_grab_first_argument_of_two:nn #2 } } - { \semantex_grab_second_argument_of_two:nn #2 } -} - -\cs_generate_variant:Nn \semantex_data_tl_put_left:nnn { noo , nox } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_dataputleft:nn#1#2 -{ - \semantex_data_tl_put_left:nno { #1 } - { \tl_trim_spaces:n { \semantex_grab_first_argument_of_two:nn #2 } } - { \semantex_grab_second_argument_of_two:nn #2 } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_dataputleftx:nn#1#2 -{ - \semantex_data_tl_put_left:nnx { #1 } - { \tl_trim_spaces:n { \semantex_grab_first_argument_of_two:nn #2 } } - { \semantex_grab_second_argument_of_two:nn #2 } -} - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_dataclear:nn#1#2 -{ - \semantex_data_tl_clear:nn { #1 } { \tl_trim_spaces:n { #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_keysset:nn#1#2 -{ - \semantex_keys_set:nn { #1 } { #2 } -} - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setkeys:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_keysset:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_keyssetx:nn#1#2 -{ - \semantex_keys_set:nx { #1 }{ #2 } -} - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setkeysx:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_keyssetx:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifeqTF:nn#1#2 -{ - \str_if_eq:xxTF - { \semantex_grab_first_argument_of_four:nnnn #2 } - { \semantex_grab_second_argument_of_four:nnnn #2 } - { \semantex_keys_set:no { #1 } { \semantex_grab_third_argument_of_four:nnnn #2 } } - { \semantex_keys_set:no { #1 } { \semantex_grab_fourth_argument_of_four:nnnn #2 } } -} - -\cs_generate_variant:Nn \str_if_eq:nnTF { ffTF } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifeqT:nn#1#2 -{ - \str_if_eq:xxTF - { \semantex_grab_first_argument_of_three:nnn #2 } - { \semantex_grab_second_argument_of_three:nnn #2 } - { \semantex_keys_set:no { #1 } { \semantex_grab_third_argument_of_three:nnn #2 } } - { } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifeqF:nn#1#2 -{ - \str_if_eq:xxTF - { \semantex_grab_first_argument_of_three:nnn #2 } - { \semantex_grab_second_argument_of_three:nnn #2 } - { } - { \semantex_keys_set:no { #1 } { \semantex_grab_third_argument_of_three:nnn #2 } } -} - -\cs_generate_variant:Nn \semantex_keys_set:nn { no } - -\cs_generate_variant:Nn \tl_if_blank:nTF { fTF } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifblankTF:nn#1#2 -{ - \tl_if_blank:xTF - { \semantex_grab_first_argument_of_three:nnn #2 } - { \semantex_keys_set:no { #1 } { \semantex_grab_second_argument_of_three:nnn #2 } } - { \semantex_keys_set:no { #1 } { \semantex_grab_third_argument_of_three:nnn #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifblankT:nn#1#2 -{ - \tl_if_blank:xTF - { \semantex_grab_first_argument_of_two:nn #2 } - { \semantex_keys_set:no { #1 } { \semantex_grab_second_argument_of_two:nn #2 } } - { } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifblankF:nn#1#2 -{ - \tl_if_blank:xTF - { \semantex_grab_first_argument_of_two:nn #2 } - { } - { semantex_keys_set:no { #1 } { \semantex_grab_second_argument_of_two:nn #2 } } -} - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_boolprovide:nn#1#2 -{ - \semantex_data_bool_provide:nn { #1 } { \tl_trim_spaces:n { #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_boolsettrue:nn#1#2 -{ - \semantex_data_bool_set_true:nn { #1 } { \tl_trim_spaces:n { #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_boolsetfalse:nn#1#2 -{ - \semantex_data_bool_set_false:nn { #1 } { \tl_trim_spaces:n { #2 } } -} - -\cs_generate_variant:Nn \semantex_data_bool_get:nnTF { noTF, nfTF , neTF , ffTF } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_boolifTF:nn#1#2 -{ - \semantex_data_bool_get:nnTF { #1 } - { \tl_trim_spaces:n { \semantex_grab_first_argument_of_three:nnn #2 } } - { \semantex_keys_set:no { #1 } { \semantex_grab_second_argument_of_three:nnn #2 } } - { \semantex_keys_set:no { #1 } { \semantex_grab_third_argument_of_three:nnn #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_boolifT:nn#1#2 -{ - \semantex_data_bool_get:nnTF { #1 } - { \tl_trim_spaces:n { \semantex_grab_first_argument_of_two:nn #2 } } - { \semantex_keys_set:no { #1 } { \semantex_grab_second_argument_of_two:nn #2 } } - { } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_boolifF:nn#1#2 -{ - \semantex_data_bool_get:nnTF { #1 } - { \tl_trim_spaces:n { \semantex_grab_first_argument_of_two:nn #2 } } - { } - { \semantex_keys_set:no { #1 } { \semantex_grab_second_argument_of_two:nn #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_intprovide:nn#1#2 -{ - \semantex_data_int_provide:nn { #1 } { \tl_trim_spaces:n { #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_intclear:nn#1#2 -{ - \semantex_data_int_clear:nn { #1 } { \tl_trim_spaces:n { #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_intincr:nn#1#2 -{ - \semantex_data_int_incr:nn { #1 } { \tl_trim_spaces:n { #2 } } -} - -\cs_generate_variant:Nn \semantex_data_int_set:nnn { noo , nno } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_intset:nn#1#2 -{ - \semantex_data_int_set:noo { #1 } - { \tl_trim_spaces:n { \semantex_grab_first_argument_of_two:nn #2 } } - { \semantex_grab_second_argument_of_two:nn #2 } -} - -\cs_generate_variant:Nn \int_compare:nNnTF { oNoTF , fNfTF , xNxTF } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_intifgreaterthanTF:nn#1#2 -{ - \int_compare:oNoTF - { \semantex_grab_first_argument_of_four:nnnn #2 } - > - { \semantex_grab_second_argument_of_four:nnnn #2 } - { \semantex_keys_set:no { #1 } { \semantex_grab_third_argument_of_four:nnnn #2 } } - { \semantex_keys_set:no { #1 } { \semantex_grab_fourth_argument_of_four:nnnn #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_intifgreaterthanT:nn#1#2 -{ - \int_compare:oNoTF - { \semantex_grab_first_argument_of_three:nnn #2 } - > - { \semantex_grab_second_argument_of_three:nnn #2 } - { \semantex_keys_set:no { #1 } { \semantex_grab_third_argument_of_three:nnn #2 } } - { } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_intifgreaterthanF:nn#1#2 -{ - \int_compare:oNoTF - { \semantex_grab_first_argument_of_three:nnn #2 } - > - { \semantex_grab_second_argument_of_three:nnn #2 } - { } - { \semantex_keys_set:no { #1 } { \semantex_grab_third_argument_of_three:nnn #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_intifequalTF:nn#1#2 -{ - \int_compare:oNoTF - { \semantex_grab_first_argument_of_four:nnnn #2 } - = - { \semantex_grab_second_argument_of_four:nnnn #2 } - { \semantex_keys_set:no { #1 } { \semantex_grab_third_argument_of_four:nnnn #2 } } - { \semantex_keys_set:no { #1 } { \semantex_grab_fourth_argument_of_four:nnnn #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_intifequalT:nn#1#2 -{ - \int_compare:oNoTF - { \semantex_grab_first_argument_of_three:nnn #2 } - = - { \semantex_grab_second_argument_of_three:nnn #2 } - { \semantex_keys_set:no { #1 } { \semantex_grab_third_argument_of_three:nnn #2 } } - { } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_intifequalF:nn#1#2 +\cs_new_protected:Npn \semantex_arg_singlekey_x:nn#1#2 { - \int_compare:oNoTF - { \semantex_grab_first_argument_of_three:nnn #2 } - = - { \semantex_grab_second_argument_of_three:nnn #2 } - { } - { \semantex_keys_set:no { #1 } { \semantex_grab_third_argument_of_three:nnn #2 } } + % The central command for executing expanded argument singlekeys, + % i.e. keys taking no + % #1 = register + % #2 = name of the key + \__semantex_arg_singlekey_x:nnn { #1 } { #2 } { #1 } } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_intiflessthanTF:nn#1#2 +\cs_new_protected:Npn \__semantex_arg_singlekey_x:nnn#1#2#3 { - \int_compare:oNoTF - { \semantex_grab_first_argument_of_four:nnnn #2 } - < - { \semantex_grab_second_argument_of_four:nnnn #2 } - { \semantex_keys_set:no { #1 } { \semantex_grab_third_argument_of_four:nnnn #2 } } - { \semantex_keys_set:no { #1 } { \semantex_grab_fourth_argument_of_four:nnnn #2 } } + \cs_if_exist:cTF { \tl_to_str:n{__semantex_data_cs_custom_arg_singlekey_#1_#2:n } } + { + \use:c { __semantex_data_cs_custom_arg_singlekey_#1_#2:n } { #3 } + % and no, we don't want :x here; we don't need to expand + % the name of the register + } + { + \str_if_eq:nnTF { #1 } { class_SemantexBaseObject } + { + \semantex_arg_valuekey:nnx { #3 } { default } { #2 } + } + { + \__semantex_arg_singlekey:fnn { \semantex_data_parent_get:n { #1 } } { #2 } { #3 } + } + } } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_intiflessthanT:nn#1#2 -{ - \int_compare:oNoTF - { \semantex_grab_first_argument_of_three:nnn #2 } - < - { \semantex_grab_second_argument_of_three:nnn #2 } - { \semantex_keys_set:no { #1 } { \semantex_grab_third_argument_of_three:nnn #2 } } - { } -} +\cs_generate_variant:Nn \__semantex_arg_singlekey_x:nnn { fnn } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_intiflessthanF:nn#1#2 +\cs_new_protected:Npn\semantex_arg_without_keyval:nn#1#2 { - \int_compare:oNoTF - { \semantex_grab_first_argument_of_three:nnn #2 } - < - { \semantex_grab_second_argument_of_three:nnn #2 } - { } - { \semantex_keys_set:no { #1 } { \semantex_grab_third_argument_of_three:nnn #2 } } + % Sets the argument (no keyval interface allowed) + \semantex_data_tl_put_right:nnn { #1 } { arg } { #2 } + \semantex_data_int_incr:nn { #1 } { numberofarguments } + \semantex_data_bool_set_true:nn { #1 } { nextargwithsep } } -\cs_generate_variant:Nn\msg_error:nnnnn { nnxoo } +\cs_generate_variant:Nn \semantex_arg_without_keyval:nn { nx } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ERRORkeyvaluenotfound:nn#1#2 -{ - \semantex_error_output_format:nN { #1 } \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ERRORkeyvaluenotfound_temp_tl - \msg_error:nnxoo { semantex } { key_value_not_found } - { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ERRORkeyvaluenotfound_temp_tl } - { \semantex_grab_first_argument_of_two:nn #2 } - { \semantex_grab_second_argument_of_two:nn #2 } -} +% NOW SOME KEYS FOR DEFINING NEW KEYS: -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ERROR:nn#1#2 -{ - \semantex_error_output_format:nN { #1 } \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ERROR_temp_tl - \msg_error:nnxoo { semantex } { generic_error } - { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ERROR_temp_tl } - { \semantex_grab_first_argument_of_two:nn #2 } - { \semantex_grab_second_argument_of_two:nn #2 } -} +% First, we define the central commands for preprocessing keys -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_execute:nn#1#2 -{ - %\exp_not:n{#2} - % how about forget? - #2 -} +\cs_generate_variant:Nn \semantex_keyval_parse:NNn { NNo } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_parse:nn#1#2 +\cs_new_protected:Npn\semantex_preprocess_keys:nN#1#2 { - % This command runs all the keys that the user may have - % stored via the parseoptions key - %\semantex_data_tl_inherit:nn { #1 } { parseoptions } -% \semantex_keys_set:nx { #1 } { -% \semantex_data_tl_get_exp_not:nn { #1 } { parseoptions } -% } -% \semantex_data_tl_clear:nn { #1 } { parseoptions } % this is probably necessary - \semantex_data_cs_get:nn { #1 } { parseoptions:n } { #1 } - \semantex_data_tl_clear:nn { #1 } { parseoptions } % this is probably necessary - \semantex_data_cs_clear:nn { #1 } { parseoptions:n } -} - -%\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_parseoptions:nn#1#2 -%{ -% % This adds keys to the parseoptions token list -% \semantex_data_tl_put_right:nnn { #1 } { parseoptions } { #2 } -%} - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_parseoptions:nn#1#2{ - \tl_set:Nn\l__semantex_parseoptions_auxiliary_temp_tl{} - \cs_set:Npn\l__semantex_parseoptions_auxiliary_singlekey_temp_cs:n##1 - { - \__semantex_parseoptions_process_singlekey:nnN { ####1 } { ##1 } \l__semantex_parseoptions_auxiliary_temp_tl - } - \cs_set:Npn\l__semantex_parseoptions_auxiliary_valuekey_temp_cs:nn##1##2 + \cs_set:Npn\l__semantex_preprocess_singlekey_temp_cs:n##1 { - \__semantex_parseoptions_process_valuekey:nnnN { ####1 } { ##1 } { ##2 } \l__semantex_parseoptions_auxiliary_temp_tl + \__semantex_preprocess_singlekey:nnN { ####1 } { ##1 } #2 } - \keyval_parse:NNn - \l__semantex_parseoptions_auxiliary_singlekey_temp_cs:n - \l__semantex_parseoptions_auxiliary_valuekey_temp_cs:nn - { #2 } - \semantex_data_tl_put_right:nno { #1 } { parseoptions } { \l__semantex_parseoptions_auxiliary_temp_tl } - %\exp_args:NNno\exp_args:Nno\cs_set:co { __semantex_data_cs_#1_parseoptions:n } - %\exp_args:Nnno - \semantex_data_cs_set:nnx { #1 } { parseoptions:n } + \cs_set:Npn\l__semantex_preprocess_valuekey_temp_cs:nn##1##2 { -% g__semantex_data_tl_#1_parseoptions -% \semantex_data_tl_get:nn { #1 } { parseoptions } - \semantex_data_tl_get_exp_not:nn { #1 } { parseoptions } - %\l__semantex_parseoptions_auxiliary_temp_tl + \__semantex_preprocess_valuekey:nnnN { ####1 } { ##1 } { ##2 } #2 } + \semantex_keyval_parse:NNn + \l__semantex_preprocess_singlekey_temp_cs:n + \l__semantex_preprocess_valuekey_temp_cs:nn + { #1 } } +\cs_generate_variant:Nn \semantex_preprocess_keys:nN { oN } -\cs_new:Npn\__semantex_parseoptions_process_singlekey:nnN#1#2#3 +\cs_new_protected:Npn\__semantex_preprocess_singlekey:nnN#1#2#3 { \tl_put_right:Nn#3 { \semantex_singlekey:nn { #1 } { #2 } } } - -\cs_new:Npn\__semantex_parseoptions_process_valuekey:nnnN#1#2#3#4 +\cs_new_protected:Npn\__semantex_preprocess_valuekey:nnnN#1#2#3#4 { - \tl_if_eq:nnTF { #2 } { execute } + \str_case:nnF { #2 } { - \tl_put_right:Nn#4 - { - #3 + { execute }{ + \tl_put_right:Nn #4 { #3 } } - } - { - \tl_put_right:Nn#4 - { - \semantex_valuekey:nnn { #1 } { #2 } { #3 } + { setkeys }{ + \semantex_preprocess_keys:nN { #3 } #4 } - } -} - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_return:nn#1#2 -{ - % This is an umbrella key that runs all of the three - % return routines, innerreturn, rightreturn, and leftreturn - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_innerreturn:nn { #1 }{} - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_rightreturn:nn { #1 }{} - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_leftreturn:nn { #1 }{} -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_innerreturn:nn#1#2 -{ - % This adds all of the commands added via the command key - % to the symbol - \semantex_data_tl_inherit:nn { #1 } { symbol } - \semantex_data_seq_inherit:nn { #1 } { commands_sequence } - \semantex_data_seq_get_store:nnN { #1 } { commands_sequence } \l__semantex_data_seq_commands_sequence_temp - \seq_map_inline:Nn \l__semantex_data_seq_commands_sequence_temp - { - \semantex_data_tl_set:nnx { #1 } { symbol } + { keysset }{ + \semantex_preprocess_keys:nN { #3 } #4 + } + { setkeysx }{ + \semantex_preprocess_keys_x:nN { #3 } #4 + } + { keyssetx }{ + \semantex_preprocess_keys_x:nN { #3 } #4 + } + { setargkeys }{ + \semantex_preprocess_arg_keys:nN { #3 } #4 + } + { argkeysset }{ + \semantex_preprocess_arg_keys:nN { #3 } #4 + } + { setargkeysx }{ + \semantex_preprocess_arg_keys_x:nN { #3 } #4 + } + { argkeyssetx }{ + \semantex_preprocess_arg_keys_x:nN { #3 } #4 + } + { setargsinglekeys }{ + \semantex_preprocess_arg_singlekeys:nN { #3 } #4 + } + { argsinglekeysset }{ + \semantex_preprocess_arg_singlekeys:nN { #3 } #4 + } + { setargsinglekeysx }{ + \semantex_preprocess_arg_singlekeys_x:nN { #3 } #4 + } + { argsinglekeyssetx }{ + \semantex_preprocess_arg_singlekeys_x:nN { #3 } #4 + } + { parseoptions }{ + \tl_put_right:Nn#4 { - \exp_not:n {\exp_not:N ##1} { - \semantex_data_tl_get_exp_not:nn { #1 } { symbol } + \semantex_add_raw_commands_to_parse_options:nn { #1 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { #3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + } + { outputoptions }{ + \tl_put_right:Nn#4 + { + \semantex_add_raw_commands_to_output_options:nn { #1 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_pre_temp_tl {} + \semantex_preprocess_keys:nN { #3 } \l__semantex_preprocess_valuekey_keys_pre_temp_tl + \cs_set:Npo\l__semantex_preprocess_valuekey_keys_temp_cs:nn##1##2 + { + \l__semantex_preprocess_valuekey_keys_pre_temp_tl + } + \tl_set:No\l__semantex_preprocess_valuekey_keys_temp_tl + { + \l__semantex_preprocess_valuekey_keys_temp_cs:nn { ###1 } { ##2 } } - % This was the solution that happened to solve - % the expansion issues best + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } } } - \semantex_data_seq_clear:nn { #1 } { commands_sequence } -} - -\cs_generate_variant:Nn \semantex_keys_set:nn { nx , no } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_rightreturn:nn#1#2 -{ - \semantex_right_indices_return_store:nN { #1 } \l_semantex_rightreturn_right_indices_temp - \semantex_data_tl_put_right:nnx { #1 } { symbol } - { - \exp_not:V\l_semantex_rightreturn_right_indices_temp - } - \semantex_data_bool_get:nnTF { #1 } { leftargument } - { - % do nothing - } - { - \semantex_arg_return_store:nN { #1 } \l_semantex_rightreturn_arg_temp - \semantex_data_tl_put_right:nnx { #1 } { symbol } - { - \exp_not:V\l_semantex_rightreturn_arg_temp + { boolifTF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_boolifTF_temp_cs:nTF##1##2##3 + { + \tl_put_right:Nn#4 + { + \semantex_data_bool_get:nnTF { ####1 } { \tl_trim_spaces:n { ##1 } } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##2 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V \l__semantex_preprocess_valuekey_keys_temp_tl } + } + } + \l__semantex_preprocess_valuekey_boolifTF_temp_cs:nTF #3 } - } -} - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_leftreturn:nn#1#2 -{ - \semantex_left_indices_return_store:nN { #1 } \l_semantex_leftreturn_left_indices_temp - \semantex_data_tl_put_left:nnx { #1 } { symbol } - { - \exp_not:V\l_semantex_leftreturn_left_indices_temp - } - \semantex_data_bool_get:nnTF { #1 } { leftargument } - { - \semantex_arg_return_store:nN { #1 } \l_semantex_leftreturn_arg_temp - \semantex_data_tl_put_left:nnx { #1 } { symbol } - { - \exp_not:V\l_semantex_leftreturn_arg_temp + { boolifT }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_boolifT_temp_cs:nT##1##2 + { + \tl_put_right:Nn#4 + { + \semantex_data_bool_get:nnTF { ####1 } { \tl_trim_spaces:n { ##1 } } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##2 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + { } + } + } + \l__semantex_preprocess_valuekey_boolifT_temp_cs:nT #3 } - } - { - % do nothing - } -} - -\cs_new:Npn \semantex_left_indices_return_store:nN#1#2 -{ - \semantex_data_tl_inherit_x:nn { #1 } { upperleft } - \semantex_data_tl_inherit_x:nn { #1 } { lowerleft } - \semantex_data_tl_inherit_x:nn { #1 } { preupperleft } - \semantex_data_tl_inherit_x:nn { #1 } { postupperleft } - \semantex_data_tl_inherit_x:nn { #1 } { prelowerleft } - \semantex_data_tl_inherit_x:nn { #1 } { postlowerleft } - \tl_set:Nn#2{} - \semantex_data_int_if_positive:nnTF { #1 } { numberofupperleftindices } - { - \semantex_data_int_if_positive:nnTF { #1 } { numberoflowerleftindices } - { - \tl_put_right:Nx#2 + { boolifF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_boolifF_temp_cs:nF##1##2 { - {}\sp{ - \semantex_data_tl_get_exp_not:nn { #1 } { preupperleft } - \semantex_data_tl_get_exp_not:nn { #1 } { upperleft } - \semantex_data_tl_get_exp_not:nn { #1 } { postupperleft } + \tl_put_right:Nn#4 + { + \semantex_data_bool_get:nnTF { ####1 } { \tl_trim_spaces:n { ##1 } } } - \sb{ - \semantex_data_tl_get_exp_not:nn { #1 } { prelowerleft } - \semantex_data_tl_get_exp_not:nn { #1 } { lowerleft } - \semantex_data_tl_get_exp_not:nn { #1 } { postlowerleft } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##2 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { } + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } } } + \l__semantex_preprocess_valuekey_boolifF_temp_cs:nF #3 } - { - \tl_put_right:Nx#2 + { ifblankTF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_ifblankTF_temp_cs:nTF##1##2##3 { - {}\sp{ - \semantex_data_tl_get_exp_not:nn { #1 } { preupperleft } - \semantex_data_tl_get_exp_not:nn { #1 } { upperleft } - \semantex_data_tl_get_exp_not:nn { #1 } { postupperleft } + \tl_put_right:Nn#4 + { + \tl_if_blank:xTF { ##1 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##2 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V \l__semantex_preprocess_valuekey_keys_temp_tl } } } + \l__semantex_preprocess_valuekey_ifblankTF_temp_cs:nTF #3 } - } - { - \semantex_data_int_if_positive:nnTF { #1 } { numberoflowerleftindices } - { - \tl_put_right:Nx#2 + { ifblankT }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_ifblankT_temp_cs:nT##1##2 { - {}\sb{ - \semantex_data_tl_get_exp_not:nn { #1 } { prelowerleft } - \semantex_data_tl_get_exp_not:nn { #1 } { lowerleft } - \semantex_data_tl_get_exp_not:nn { #1 } { postlowerleft } + \tl_put_right:Nn#4 + { + \tl_if_blank:xTF { ##1 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##2 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + { } } } + \l__semantex_preprocess_valuekey_ifblankT_temp_cs:nT #3 } - { - % do nothing + { ifblankF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_ifblankF_temp_cs:nF##1##2 + { + \tl_put_right:Nn#4 + { + \tl_if_blank:xTF { ##1 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##2 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { } + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + } + \l__semantex_preprocess_valuekey_ifblankF_temp_cs:nF #3 } - } - \semantex_data_tl_clear:nn { #1 } { upperleft } - \semantex_data_bool_provide:nn { #1 } { nextupperleftwithsep } % is it necessary to provide it before declaring it false? - \semantex_data_bool_set_false:nn { #1 } { nextupperleftwithsep } - \semantex_data_tl_clear:nn { #1 } { lowerleft } - \semantex_data_bool_provide:nn { #1 } { nextlowerleftwithsep } % is it necessary to provide it before declaring it false? - \semantex_data_bool_set_false:nn { #1 } { nextlowerleftwithsep } - \semantex_data_tl_clear:nn { #1 } { preupperleft } - \semantex_data_tl_clear:nn { #1 } { postupperleft } - \semantex_data_tl_clear:nn { #1 } { prelowerleft } - \semantex_data_tl_clear:nn { #1 } { postlowerleft } - \semantex_data_int_clear:nn { #1 } { numberofupperleftindices } - \semantex_data_int_clear:nn { #1 } { numberoflowerleftindices } -} - - -\cs_new:Npn \semantex_arg_return_store:nN#1#2 -{ - \semantex_data_tl_inherit_x:nn { #1 } { arg } - \semantex_data_int_inherit:nn { #1 } { numberofarguments } - %\semantex_data_tl_inherit:nn { #1 } { parsize } % This was necessary for unkonwn reasons -- otherwise it will fail when doing inheritance - \semantex_data_tl_get_store:nnN { #1 } { parsize } \l__arg_return_store_parsize_temp_tl - \semantex_data_bool_get:nnTF { #1 } { par } - { - \semantex_data_int_if_positive:nnTF { #1 } { numberofarguments } - { - \__semantex_parentheses_store:nnnnN - { \l__arg_return_store_parsize_temp_tl } - { \semantex_data_tl_get_exp_not:nn { #1 } { leftpar } } - { \semantex_data_tl_get_exp_not:nn { #1 } { rightpar } } + { strifeqTF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_strifeqTF_temp_cs:nnTF##1##2##3##4 { - \semantex_data_tl_get_exp_not:nn { #1 } { prearg } - \semantex_data_tl_get_exp_not:nn { #1 } { arg } - \semantex_data_tl_get_exp_not:nn { #1 } { postarg } + \tl_put_right:Nn#4 + { + \str_if_eq:xxTF { ##1 } { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##4 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V \l__semantex_preprocess_valuekey_keys_temp_tl } + } } - #2 + \l__semantex_preprocess_valuekey_strifeqTF_temp_cs:nnTF #3 } - { - \tl_set:Nn#2{} + { strifeqT }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_strifeqT_temp_cs:nnT##1##2##3 + { + \tl_put_right:Nn#4 + { + \str_if_eq:xxTF { ##1 } { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + { } + } + } + \l__semantex_preprocess_valuekey_strifeqT_temp_cs:nnT #3 } - } - { - \semantex_data_bool_get:nnTF { #1 } { flexpar } - { - \semantex_data_int_if_greater_than_one:nnTF { #1 } { numberofarguments } + { strifeqF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_strifeqF_temp_cs:nnF##1##2##3 { - \__semantex_parentheses_store:nnnnN - { \l__arg_return_store_parsize_temp_tl } - { \semantex_data_tl_get_exp_not:nn { #1 } { leftpar } } - { \semantex_data_tl_get_exp_not:nn { #1 } { rightpar } } + \tl_put_right:Nn#4 { - \semantex_data_tl_get_exp_not:nn { #1 } { prearg } - \semantex_data_tl_get_exp_not:nn { #1 } { arg } - \semantex_data_tl_get_exp_not:nn { #1 } { postarg } + \str_if_eq:xxTF { ##1 } { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { } + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } } - #2 } + \l__semantex_preprocess_valuekey_strifeqF_temp_cs:nnF #3 + } + { intifgreaterTF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_intifgreaterTF_temp_cs:nnTF##1##2##3##4 { - \semantex_data_int_if_positive:nnTF { #1 } { numberofarguments } + \tl_put_right:Nn#4 { - \__semantex_no_parentheses_store:nN - { - \semantex_data_tl_get_exp_not:nn { #1 } { prearg } - \semantex_data_tl_get_exp_not:nn { #1 } { arg } - \semantex_data_tl_get_exp_not:nn { #1 } { postarg } - } - #2 + \int_compare:nNnTF { ##1 } > { ##2 } } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 { - \tl_set:Nn#2{} + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##4 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V \l__semantex_preprocess_valuekey_keys_temp_tl } } } + \l__semantex_preprocess_valuekey_intifgreaterTF_temp_cs:nnTF #3 } - { - \semantex_data_int_if_positive:nnTF { #1 } { numberofarguments } + { intifgreaterT }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_intifgreaterT_temp_cs:nnT##1##2##3 { - \__semantex_no_parentheses_store:nN + \tl_put_right:Nn#4 { - \semantex_data_tl_get_exp_not:nn { #1 } { prearg } - \semantex_data_tl_get_exp_not:nn { #1 } { arg } - \semantex_data_tl_get_exp_not:nn { #1 } { postarg } + \int_compare:nNnTF { ##1 } > { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + { } } - #2 } + \l__semantex_preprocess_valuekey_intifgreaterT_temp_cs:nnT #3 + } + { intifgreaterF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_intifgreaterF_temp_cs:nnF##1##2##3 { - \tl_set:Nn#2{} + \tl_put_right:Nn#4 + { + \int_compare:nNnTF { ##1 } > { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { } + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } } + \l__semantex_preprocess_valuekey_intifgreaterF_temp_cs:nnF #3 } - } - \semantex_data_tl_clear:nn { #1 } { arg } - \semantex_data_tl_clear:nn { #1 } { prearg } % Is it right to clear these? - \semantex_data_tl_clear:nn { #1 } { postarg } - \semantex_data_int_clear:nn { #1 } { numberofarguments } - \semantex_data_bool_provide:nn { #1 } { nextargwithsep } % is it necessary to provide it before declaring it false? - \semantex_data_bool_set_false:nn { #1 } { nextargwithsep } -} - -\cs_new:Npn \semantex_right_indices_return_store:nN#1#2 -{ - \semantex_data_tl_inherit_x:nn { #1 } { upper } - \semantex_data_tl_inherit_x:nn { #1 } { lower } - \semantex_data_tl_inherit_x:nn { #1 } { preupper } - \semantex_data_tl_inherit_x:nn { #1 } { postupper } - \semantex_data_tl_inherit_x:nn { #1 } { prelower } - \semantex_data_tl_inherit_x:nn { #1 } { postlower } - \tl_set:Nn#2{} - \semantex_data_int_if_positive:nnTF { #1 } { numberofupperindices } - { - \tl_put_right:Nx#2 - { - \sp{ - \semantex_data_tl_get_exp_not:nn { #1 } { preupper } - \semantex_data_tl_get_exp_not:nn { #1 } { upper } - \semantex_data_tl_get_exp_not:nn { #1 } { postupper } + { intifeqTF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_intifeqTF_temp_cs:nnTF##1##2##3##4 + { + \tl_put_right:Nn#4 + { + \int_compare:nNnTF { ##1 } = { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##4 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V \l__semantex_preprocess_valuekey_keys_temp_tl } + } } + \l__semantex_preprocess_valuekey_intifeqTF_temp_cs:nnTF #3 } - } - { - % do nothing - } - \semantex_data_int_if_positive:nnTF { #1 } { numberoflowerindices } - { - \tl_put_right:Nx#2 - { - \sb{ - \semantex_data_tl_get_exp_not:nn { #1 } { prelower } - \semantex_data_tl_get_exp_not:nn { #1 } { lower } - \semantex_data_tl_get_exp_not:nn { #1 } { postlower } + { intifeqT }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_intifeqT_temp_cs:nnT##1##2##3 + { + \tl_put_right:Nn#4 + { + \int_compare:nNnTF { ##1 } = { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + { } + } } + \l__semantex_preprocess_valuekey_intifeqT_temp_cs:nnT #3 } - } - { - % do nothing - } - \semantex_data_tl_clear:nn { #1 } { upper } - \semantex_data_bool_provide:nn { #1 } { nextupperwithsep } % is it necessary to provide it before declaring it false? - \semantex_data_bool_set_false:nn { #1 } { nextupperwithsep } - \semantex_data_tl_clear:nn { #1 } { lower } - \semantex_data_bool_provide:nn { #1 } { nextlowerwithsep } % is it necessary to provide it before declaring it false? - \semantex_data_bool_set_false:nn { #1 } { nextlowerwithsep } - \semantex_data_tl_clear:nn { #1 } { preupper } - \semantex_data_tl_clear:nn { #1 } { postupper } - \semantex_data_tl_clear:nn { #1 } { prelower } - \semantex_data_tl_clear:nn { #1 } { postlower } - \semantex_data_int_clear:nn { #1 } { numberofupperindices } - \semantex_data_int_clear:nn { #1 } { numberoflowerindices } -} - - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_parent:nn#1#2{ - % Must inherit everything from the parent class - \semantex_data_parent_set:nn { #1 } { #2 } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_class:nn#1#2{ - % Must inherit everything from the parent class - \semantex_data_class_set:nn { #1 } { #2 } -} - -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_class:nn { xn } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_copy:nn#1#2{ - % Similarly to parent and class, but inherits from other objects rather than classes - \semantex_data_copy_object:nn { #1 } { #2 } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clone:nn#1#2{ - % Similarly to parent and class, but inherits from other objects rather than classes - \semantex_data_clone_object:nn { #1 } { #2 } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_valuekeys:nn#1#2{ - % Add new valuekeys - \clist_map_inline:nn { #2 }{ - \__semantex_valuekey_format_auxiliary:nnn{#1}##1 - } -} - -\cs_new:Npn\__semantex_process_singlekey:nnN#1#2#3 -{ - \tl_put_right:Nn#3 - { - \semantex_singlekey:nn { #1 } { #2 } - } -} - -\cs_generate_variant:Nn \semantex_valuekey:nnn { nnx } - -\cs_new:Npn\__semantex_process_valuekey:nnnN#1#2#3#4 -{ - \tl_if_eq:nnTF { #2 } { execute } - { - \tl_put_right:Nn#4 - { - #3 + { intifeqF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_intifeqF_temp_cs:nnF##1##2##3 + { + \tl_put_right:Nn#4 + { + \int_compare:nNnTF { ##1 } = { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { } + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + } + \l__semantex_preprocess_valuekey_intifeqF_temp_cs:nnF #3 + } + { intiflessTF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_intiflessTF_temp_cs:nnTF##1##2##3##4 + { + \tl_put_right:Nn#4 + { + \int_compare:nNnTF { ##1 } < { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##4 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V \l__semantex_preprocess_valuekey_keys_temp_tl } + } + } + \l__semantex_preprocess_valuekey_intiflessTF_temp_cs:nnTF #3 + } + { intiflessT }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_intiflessT_temp_cs:nnT##1##2##3 + { + \tl_put_right:Nn#4 + { + \int_compare:nNnTF { ##1 } < { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + { } + } + } + \l__semantex_preprocess_valuekey_intiflessT_temp_cs:nnT #3 + } + { intiflessF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_intiflessF_temp_cs:nnF##1##2##3 + { + \tl_put_right:Nn#4 + { + \int_compare:nNnTF { ##1 } < { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { } + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + } + \l__semantex_preprocess_valuekey_intiflessF_temp_cs:nnF #3 } } { \tl_put_right:Nn#4 { \semantex_valuekey:nnn { #1 } { #2 } { #3 } - } - } -} - -\cs_new:Npn\__semantex_valuekey_format_auxiliary:nnn#1#2#3 -{ - \tl_set:Nn\l__semantex_valuekey_auxiliary_temp_tl{} - \cs_set:Npn\l__semantex_valuekey_auxiliary_singlekey_temp_cs:n##1 - { - \__semantex_process_singlekey:nnN { ####1 } { ##1 } \l__semantex_valuekey_auxiliary_temp_tl - } - \cs_set:Npn\l__semantex_valuekey_auxiliary_valuekey_temp_cs:nn##1##2 - { - \__semantex_process_valuekey:nnnN { ####1 } { ##1 } { ##2 } \l__semantex_valuekey_auxiliary_temp_tl - } - \cs_set:Npn\l__semantex_valuekey_auxiliary_temp_cs:n##1 { #3 } - \keyval_parse:NNo - \l__semantex_valuekey_auxiliary_singlekey_temp_cs:n - \l__semantex_valuekey_auxiliary_valuekey_temp_cs:nn - { - \l__semantex_valuekey_auxiliary_temp_cs:n { ##2 } } - \cs_set:cpo { __semantex_data_cs_custom_valuekey_#1_#2:nn } ##1##2 { - \l__semantex_valuekey_auxiliary_temp_tl } - % remove spaces } -\cs_generate_variant:Nn \cs_set:Npn { cpo } - -\cs_generate_variant:Nn \keyval_parse:NNn { NNo } +% The x version: -%CHECK - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_singlekeys:nn#1#2{ - % Add keys taking no values - \clist_map_inline:nn { #2 }{ - \__semantex_singlekeys_format_auxiliary:nnn{#1}##1 - } -} - -\cs_new:Npn \__semantex_singlekeys_format_auxiliary:nnn#1#2#3{ - \tl_set:Nn\l__semantex_singlekey_auxiliary_temp_tl{} - \cs_set:Npn\l__semantex_singlekey_auxiliary_singlekey_temp_cs:n##1 +\cs_new_protected:Npn\semantex_preprocess_keys_x:nN#1#2 +{ + \cs_set:Npn\l__semantex_preprocess_singlekey_x_temp_cs:n##1 { - \__semantex_process_singlekey:nnN { ####1 } { ##1 } \l__semantex_singlekey_auxiliary_temp_tl + \__semantex_preprocess_singlekey_x:nnN { ####1 } { ##1 } #2 } - \cs_set:Npn\l__semantex_singlekey_auxiliary_valuekey_temp_cs:nn##1##2 + \cs_set:Npn\l__semantex_preprocess_valuekey_x_temp_cs:nn##1##2 { - \__semantex_process_valuekey:nnnN { ####1 } { ##1 } { ##2 } \l__semantex_singlekey_auxiliary_temp_tl - } - \cs_set:Npn\l__semantex_singlekey_auxiliary_temp_cs: { #3 } - \keyval_parse:NNo - \l__semantex_singlekey_auxiliary_singlekey_temp_cs:n - \l__semantex_singlekey_auxiliary_valuekey_temp_cs:nn - { \l__semantex_singlekey_auxiliary_temp_cs: } - \cs_set:cpo { __semantex_data_cs_custom_singlekey_#1_#2:n } ##1 { - \l__semantex_singlekey_auxiliary_temp_tl - } -% \seq_put_right:cn { g__semantex_data_seq_#1_list_of_singlekeys } { #2 } -% %IM Remove spaces in #2 -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_removesinglekey:nn#1#2 -{ - \cs_undefine:c { __semantex_data_cs_custom_singlekey_#1_#2:n } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_removevaluekey:nn#1#2 -{ - \cs_undefine:c { __semantex_data_cs_custom_valuekey_#1_#2:nn } -} - -\cs_set_eq:cN { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_1valuekeys:nn } \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_valuekeys:nn - -\cs_new:cpn { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_2valuekeys:nn }#1#2{ - % Add new valuekeys - \clist_map_inline:nn { #2 }{ - \__semantex_two_valuekey_format_auxiliary:nnn{#1}##1 + \__semantex_preprocess_valuekey_x:nnnN { ####1 } { ##1 } { ##2 } #2 } + \semantex_keyval_parse:NNn + \l__semantex_preprocess_singlekey_x_temp_cs:n + \l__semantex_preprocess_valuekey_x_temp_cs:nn + { #1 } } -\cs_new:Npn\__semantex_two_valuekey_format_auxiliary:nnn#1#2#3 +\cs_new_protected:Npn\__semantex_preprocess_singlekey_x:nnN#1#2#3 { - \cs_set:Npn\l__semantex_two_valuekey_format_auxiliary_temp:nn##1##2{#3} - %IM Remove spaces in #2 - \__semantex_valuekey_format_auxiliary:nno { #1 } { #2 } + \tl_put_right:Nn#3 { - \l__semantex_two_valuekey_format_auxiliary_temp:nn - { - \semantex_grab_first_argument_of_two:nn ##1 - } - { - \semantex_grab_second_argument_of_two:nn ##1 - } - } -} -\cs_generate_variant:Nn \__semantex_valuekey_format_auxiliary:nnn { nno } - -\cs_new:cpn { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_3valuekeys:nn }#1#2{ - % Add new valuekeys - \clist_map_inline:nn { #2 }{ - \__semantex_three_valuekey_format_auxiliary:nnn{#1}##1 + \semantex_singlekey_x:nn { #1 } { #2 } } } -\cs_new:Npn\__semantex_three_valuekey_format_auxiliary:nnn#1#2#3 +\cs_new_protected:Npn\__semantex_preprocess_valuekey_x:nnnN#1#2#3#4 { - \cs_set:Npn\l__semantex_three_valuekey_format_auxiliary_temp:nnn##1##2##3{#3} - \__semantex_valuekey_format_auxiliary:nno { #1 } { #2 } + \str_case:nnF { #2 } { - \l__semantex_three_valuekey_format_auxiliary_temp:nnn - { - \semantex_grab_first_argument_of_three:nnn ##1 + { execute } { + \tl_put_right:Nn#4 + { + #3 + } } - { - \semantex_grab_second_argument_of_three:nnn ##1 + { setkeys }{ + \semantex_preprocess_keys:nN { #3 } #4 } - { - \semantex_grab_third_argument_of_three:nnn ##1 + { keysset }{ + \semantex_preprocess_keys:nN { #3 } #4 } - } - %IM Remove spaces in #2 -} - -\cs_new:cpn { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_4valuekeys:nn }#1#2{ - % Add new valuekeys - \clist_map_inline:nn { #2 }{ - \__semantex_four_valuekey_format_auxiliary:nnn{#1}##1 - } -} - -\cs_new:Npn\__semantex_four_valuekey_format_auxiliary:nnn#1#2#3 -{ - \cs_set:Npn\l__semantex_four_valuekey_format_auxiliary_temp:nnnn##1##2##3##4{#3} - \__semantex_valuekey_format_auxiliary:nno { #1 } { #2 } - { - \l__semantex_four_valuekey_format_auxiliary_temp:nnnn - { - \semantex_grab_first_argument_of_four:nnnn ##1 + { setkeysx }{ + \semantex_preprocess_keys_x:nN { #3 } #4 } - { - \semantex_grab_second_argument_of_four:nnnn ##1 + { keyssetx }{ + \semantex_preprocess_keys_x:nN { #3 } #4 } - { - \semantex_grab_third_argument_of_four:nnnn ##1 + { setargkeys }{ + \semantex_preprocess_arg_keys:nN { #3 } #4 } - { - \semantex_grab_fourth_argument_of_four:nnnn ##1 + { argkeysset }{ + \semantex_preprocess_arg_keys:nN { #3 } #4 } - } - %IM Remove spaces in #2 -} - -\cs_new:cpn { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_5valuekeys:nn }#1#2{ - % Add new valuekeys - \clist_map_inline:nn { #2 }{ - \__semantex_five_valuekey_format_auxiliary:nnn{#1}##1 - } -} - -\cs_new:Npn\__semantex_five_valuekey_format_auxiliary:nnn#1#2#3 -{ - \cs_set:Npn\l__semantex_five_valuekey_format_auxiliary_temp:nnnnn##1##2##3##4##5{#3} - \__semantex_valuekey_format_auxiliary:nno { #1 } { #2 } - { - \l__semantex_five_valuekey_format_auxiliary_temp:nnnnn - { - \semantex_grab_first_argument_of_five:nnnnn ##1 + { setargkeysx }{ + \semantex_preprocess_arg_keys_x:nN { #3 } #4 } - { - \semantex_grab_second_argument_of_five:nnnnn ##1 + { argkeyssetx }{ + \semantex_preprocess_arg_keys_x:nN { #3 } #4 } - { - \semantex_grab_third_argument_of_five:nnnnn ##1 + { setargsinglekeys }{ + \semantex_preprocess_arg_singlekeys:nN { #3 } #4 } - { - \semantex_grab_fourth_argument_of_five:nnnnn ##1 + { argsinglekeysset }{ + \semantex_preprocess_arg_singlekeys:nN { #3 } #4 } - { - \semantex_grab_fifth_argument_of_five:nnnnn ##1 + { setargsinglekeysx }{ + \semantex_preprocess_arg_singlekeys_x:nN { #3 } #4 } - } - %IM Remove spaces in #2 -} - -\cs_new:cpn { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_6valuekeys:nn }#1#2{ - % Add new valuekeys - \clist_map_inline:nn { #2 }{ - \__semantex_six_valuekey_format_auxiliary:nnn{#1}##1 - } -} - -\cs_new:Npn\__semantex_six_valuekey_format_auxiliary:nnn#1#2#3 -{ - \cs_set:Npn\l__semantex_six_valuekey_format_auxiliary_temp:nnnnnn##1##2##3##4##5##6{#3} - \__semantex_valuekey_format_auxiliary:nno { #1 } { #2 } - { - \l__semantex_six_valuekey_format_auxiliary_temp:nnnnnn - { - \semantex_grab_first_argument_of_six:nnnnnn ##1 + { argsinglekeyssetx }{ + \semantex_preprocess_arg_singlekeys_x:nN { #3 } #4 } - { - \semantex_grab_second_argument_of_six:nnnnnn ##1 + { parseoptions }{ + \tl_put_right:Nn#4 + { + \semantex_add_raw_commands_to_parse_options:nn { #1 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { #3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } } - { - \semantex_grab_third_argument_of_six:nnnnnn ##1 + { outputoptions }{ + \tl_put_right:Nn#4 + { + \semantex_add_raw_commands_to_output_options:nn { #1 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_pre_temp_tl {} + \semantex_preprocess_keys_x:nN { #3 } \l__semantex_preprocess_valuekey_keys_pre_temp_tl + \cs_set:Npo\l__semantex_preprocess_valuekey_keys_temp_cs:nn##1##2 + { + \l__semantex_preprocess_valuekey_keys_pre_temp_tl + } + \tl_set:No\l__semantex_preprocess_valuekey_keys_temp_tl + { + \l__semantex_preprocess_valuekey_keys_temp_cs:nn { ###1 } { ##2 } + } + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } } - { - \semantex_grab_fourth_argument_of_six:nnnnnn ##1 + { boolifTF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_boolifTF_temp_cs:nTF##1##2##3 + { + \tl_put_right:Nn#4 + { + \semantex_data_bool_get:nnTF { ####1 } { \tl_trim_spaces:n { ##1 } } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##2 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V \l__semantex_preprocess_valuekey_keys_temp_tl } + } + } + \l__semantex_preprocess_valuekey_boolifTF_temp_cs:nTF #3 } - { - \semantex_grab_fifth_argument_of_six:nnnnnn ##1 + { boolifT }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_boolifT_temp_cs:nT##1##2 + { + \tl_put_right:Nn#4 + { + \semantex_data_bool_get:nnTF { ####1 } { \tl_trim_spaces:n { ##1 } } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##2 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + { } + } + } + \l__semantex_preprocess_valuekey_boolifT_temp_cs:nT #3 } - { - \semantex_grab_sixth_argument_of_six:nnnnnn ##1 + { boolifF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_boolifF_temp_cs:nF##1##2 + { + \tl_put_right:Nn#4 + { + \semantex_data_bool_get:nnTF { ####1 } { \tl_trim_spaces:n { ##1 } } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##2 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { } + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + } + \l__semantex_preprocess_valuekey_boolifF_temp_cs:nF #3 } - } - %IM Remove spaces in #2 -} - -\cs_new:cpn { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_7valuekeys:nn }#1#2{ - % Add new valuekeys - \clist_map_inline:nn { #2 }{ - \__semantex_seven_valuekey_format_auxiliary:nnn{#1}##1 - } -} - -\cs_new:Npn\__semantex_seven_valuekey_format_auxiliary:nnn#1#2#3 -{ - \cs_set:Npn\l__semantex_seven_valuekey_format_auxiliary_temp:nnnnnnn##1##2##3##4##5##6##7{#3} - \__semantex_valuekey_format_auxiliary:nno { #1 } { #2 } - { - \l__semantex_seven_valuekey_format_auxiliary_temp:nnnnnnn - { - \semantex_grab_first_argument_of_seven:nnnnnnn ##1 + { ifblankTF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_ifblankTF_temp_cs:nTF##1##2##3 + { + \tl_put_right:Nn#4 + { + \tl_if_blank:xTF { ##1 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##2 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V \l__semantex_preprocess_valuekey_keys_temp_tl } + } + } + \l__semantex_preprocess_valuekey_ifblankTF_temp_cs:nTF #3 } - { - \semantex_grab_second_argument_of_seven:nnnnnnn ##1 + { ifblankT }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_ifblankT_temp_cs:nT##1##2 + { + \tl_put_right:Nn#4 + { + \tl_if_blank:xTF { ##1 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##2 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + { } + } + } + \l__semantex_preprocess_valuekey_ifblankT_temp_cs:nT #3 } - { - \semantex_grab_third_argument_of_seven:nnnnnnn ##1 + { ifblankF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_ifblankF_temp_cs:nF##1##2 + { + \tl_put_right:Nn#4 + { + \tl_if_blank:xTF { ##1 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##2 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { } + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + } + \l__semantex_preprocess_valuekey_ifblankF_temp_cs:nF #3 } - { - \semantex_grab_fourth_argument_of_seven:nnnnnnn ##1 + { strifeqTF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_strifeqTF_temp_cs:nnTF##1##2##3##4 + { + \tl_put_right:Nn#4 + { + \str_if_eq:xxTF { ##1 } { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##4 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V \l__semantex_preprocess_valuekey_keys_temp_tl } + } + } + \l__semantex_preprocess_valuekey_strifeqTF_temp_cs:nnTF #3 } - { - \semantex_grab_fifth_argument_of_seven:nnnnnnn ##1 + { strifeqT }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_strifeqT_temp_cs:nnT##1##2##3 + { + \tl_put_right:Nn#4 + { + \str_if_eq:xxTF { ##1 } { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + { } + } + } + \l__semantex_preprocess_valuekey_strifeqT_temp_cs:nnT #3 } - { - \semantex_grab_sixth_argument_of_seven:nnnnnnn ##1 + { strifeqF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_strifeqF_temp_cs:nnF##1##2##3 + { + \tl_put_right:Nn#4 + { + \str_if_eq:xxTF { ##1 } { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { } + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + } + \l__semantex_preprocess_valuekey_strifeqF_temp_cs:nnF #3 } - { - \semantex_grab_seventh_argument_of_seven:nnnnnnn ##1 + { intifgreaterTF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_intifgreaterTF_temp_cs:nnTF##1##2##3##4 + { + \tl_put_right:Nn#4 + { + \int_compare:nNnTF { ##1 } > { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##4 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V \l__semantex_preprocess_valuekey_keys_temp_tl } + } + } + \l__semantex_preprocess_valuekey_intifgreaterTF_temp_cs:nnTF #3 } - } - %IM Remove spaces in #2 -} - -\cs_new:cpn { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_8valuekeys:nn }#1#2{ - % Add new valuekeys - \clist_map_inline:nn { #2 }{ - \__semantex_eight_valuekey_format_auxiliary:nnn{#1}##1 - } -} - -\cs_new:Npn\__semantex_eight_valuekey_format_auxiliary:nnn#1#2#3 -{ - \cs_set:Npn\l__semantex_eight_valuekey_format_auxiliary_temp:nnnnnnnn##1##2##3##4##5##6##7##8{#3} - \__semantex_valuekey_format_auxiliary:nno { #1 } { #2 } - { - \l__semantex_eight_valuekey_format_auxiliary_temp:nnnnnnnn - { - \semantex_grab_first_argument_of_eight:nnnnnnnn ##1 + { intifgreaterT }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_intifgreaterT_temp_cs:nnT##1##2##3 + { + \tl_put_right:Nn#4 + { + \int_compare:nNnTF { ##1 } > { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + { } + } + } + \l__semantex_preprocess_valuekey_intifgreaterT_temp_cs:nnT #3 } - { - \semantex_grab_second_argument_of_eight:nnnnnnnn ##1 + { intifgreaterF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_intifgreaterF_temp_cs:nnF##1##2##3 + { + \tl_put_right:Nn#4 + { + \int_compare:nNnTF { ##1 } > { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { } + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + } + \l__semantex_preprocess_valuekey_intifgreaterF_temp_cs:nnF #3 } - { - \semantex_grab_third_argument_of_eight:nnnnnnnn ##1 + { intifeqTF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_intifeqTF_temp_cs:nnTF##1##2##3##4 + { + \tl_put_right:Nn#4 + { + \int_compare:nNnTF { ##1 } = { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##4 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V \l__semantex_preprocess_valuekey_keys_temp_tl } + } + } + \l__semantex_preprocess_valuekey_intifeqTF_temp_cs:nnTF #3 } - { - \semantex_grab_fourth_argument_of_eight:nnnnnnnn ##1 + { intifeqT }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_intifeqT_temp_cs:nnT##1##2##3 + { + \tl_put_right:Nn#4 + { + \int_compare:nNnTF { ##1 } = { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + { } + } + } + \l__semantex_preprocess_valuekey_intifeqT_temp_cs:nnT #3 } - { - \semantex_grab_fifth_argument_of_eight:nnnnnnnn ##1 + { intifeqF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_intifeqF_temp_cs:nnF##1##2##3 + { + \tl_put_right:Nn#4 + { + \int_compare:nNnTF { ##1 } = { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { } + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + } + \l__semantex_preprocess_valuekey_intifeqF_temp_cs:nnF #3 } - { - \semantex_grab_sixth_argument_of_eight:nnnnnnnn ##1 + { intiflessTF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_intiflessTF_temp_cs:nnTF##1##2##3##4 + { + \tl_put_right:Nn#4 + { + \int_compare:nNnTF { ##1 } < { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##4 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V \l__semantex_preprocess_valuekey_keys_temp_tl } + } + } + \l__semantex_preprocess_valuekey_intiflessTF_temp_cs:nnTF #3 } - { - \semantex_grab_seventh_argument_of_eight:nnnnnnnn ##1 + { intiflessT }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_intiflessT_temp_cs:nnT##1##2##3 + { + \tl_put_right:Nn#4 + { + \int_compare:nNnTF { ##1 } < { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + { } + } + } + \l__semantex_preprocess_valuekey_intiflessT_temp_cs:nnT #3 + } + { intiflessF }{ + \cs_set:Npn \l__semantex_preprocess_valuekey_intiflessF_temp_cs:nnF##1##2##3 + { + \tl_put_right:Nn#4 + { + \int_compare:nNnTF { ##1 } < { ##2 } + } + \group_begin: + \tl_set:Nn\l__semantex_preprocess_valuekey_keys_temp_tl {} + \semantex_preprocess_keys_x:nN { ##3 } \l__semantex_preprocess_valuekey_keys_temp_tl + \exp_args:NNNx + \group_end: + \tl_put_right:Nn#4 + { + { } + { \exp_not:V\l__semantex_preprocess_valuekey_keys_temp_tl } + } + } + \l__semantex_preprocess_valuekey_intiflessF_temp_cs:nnF #3 } + } + { + \tl_put_right:Nn#4 { - \semantex_grab_eighth_argument_of_eight:nnnnnnnn ##1 + \semantex_valuekey:nnx { #1 } { #2 } { #3 } } } - %IM Remove spaces in #2 } -\cs_new:cpn { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_9valuekeys:nn }#1#2{ +\cs_new_protected:Npn\semantex_define_valuekeys:nn#1#2 +{ % Add new valuekeys \clist_map_inline:nn { #2 }{ - \__semantex_nine_valuekey_format_auxiliary:nnn{#1}##1 + \__semantex_valuekey_format_auxiliary:nnn { #1 } ##1 } } -\cs_new:Npn\__semantex_nine_valuekey_format_auxiliary:nnn#1#2#3 +\cs_new_protected:Npn\__semantex_valuekey_format_auxiliary:nnn#1#2#3 { - \cs_set:Npn\l__semantex_nine_valuekey_format_auxiliary_temp:nnnnnnnnn##1##2##3##4##5##6##7##8##9{#3} - \__semantex_valuekey_format_auxiliary:nno { #1 } { #2 } + \cs_set:Npn\l__semantex_valuekey_auxiliary_temp_cs:n##1 { #3 } + \tl_set:Nn \l__semantex_valuekey_auxiliary_temp_tl {} + \semantex_preprocess_keys:oN { - \l__semantex_nine_valuekey_format_auxiliary_temp:nnnnnnnnn - { - \semantex_grab_first_argument_of_nine:nnnnnnnnn ##1 - } - { - \semantex_grab_second_argument_of_nine:nnnnnnnnn ##1 - } - { - \semantex_grab_third_argument_of_nine:nnnnnnnnn ##1 - } - { - \semantex_grab_fourth_argument_of_nine:nnnnnnnnn ##1 - } - { - \semantex_grab_fifth_argument_of_nine:nnnnnnnnn ##1 - } - { - \semantex_grab_sixth_argument_of_nine:nnnnnnnnn ##1 - } - { - \semantex_grab_seventh_argument_of_nine:nnnnnnnnn ##1 - } - { - \semantex_grab_eighth_argument_of_nine:nnnnnnnnn ##1 - } - { - \semantex_grab_ninth_argument_of_nine:nnnnnnnnn ##1 - } + \l__semantex_valuekey_auxiliary_temp_cs:n { ##2 } + } \l__semantex_valuekey_auxiliary_temp_tl + \cs_set_protected:cpo { __semantex_data_cs_custom_valuekey_#1_\tl_trim_spaces:n{#2}:nn } ##1##2 + { + \l__semantex_valuekey_auxiliary_temp_tl } - %IM Remove spaces in #2 } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_novaluekeys:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_singlekeys:nn % Previously, "singlekeys" was called "novaluekeys", so I am keeping this alias for backwards compatibility - -\cs_set_eq:cN { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_0valuekeys:nn } \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_singlekeys:nn - - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_removenovaluekey:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_removesinglekey:nn % Previously, "singlekeys" was called "novaluekeys", so I am keeping this alias for backwards compatibility +\cs_generate_variant:Nn \cs_set:Npn { Npo } -\cs_set_eq:cN { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_remove0valuekey:nn } \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_removesinglekey:nn +\cs_generate_variant:Nn \cs_set_protected:Npn { cpo , Npo } -% KEYS FOR SETTING UP THE ARGUMENT KEYVAL INTERFACE: - -\cs_new:Npn\__semantex_process_arg_singlekey:nnN#1#2#3 +\cs_new_protected:Npn\semantex_remove_valuekey:nn#1#2 { - \tl_put_right:Nn#3 - { - \semantex_arg_singlekey:nn { #1 } { #2 } - } + \cs_undefine:c { __semantex_data_cs_custom_valuekey_#1_\tl_trim_spaces:n{#2}:nn } } -\cs_generate_variant:Nn \semantex_valuekey:nnn { nnx } - -\cs_new:Npn\__semantex_process_arg_valuekey:nnnN#1#2#3#4 +\cs_new_protected:Npn\semantex_define_singlekeys:nn#1#2 { - \tl_put_right:Nn#4 - { - \semantex_arg_valuekey:nnn { #1 } { #2 } { #3 } - } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_argvaluekeys:nn#1#2{ - % Add argument valuekeys + % Add keys taking no values \clist_map_inline:nn { #2 }{ - \__semantex_arg_valuekey_format_auxiliary:nnn{#1}##1 + \__semantex_singlekeys_format_auxiliary:nnn { #1 } ##1 } } -\cs_new:Npn \__semantex_arg_valuekey_format_auxiliary:nnn#1#2#3 +\cs_new_protected:Npn \__semantex_singlekeys_format_auxiliary:nnn#1#2#3 { - \tl_set:Nn\l__semantex_arg_valuekey_auxiliary_temp_tl{} - \cs_set:Npn\l__semantex_arg_valuekey_auxiliary_singlekey_temp_cs:n##1 - { - \__semantex_process_arg_singlekey:nnN { ####1 } { ##1 } \l__semantex_arg_valuekey_auxiliary_temp_tl - } - \cs_set:Npn\l__semantex_arg_valuekey_auxiliary_valuekey_temp_cs:nn##1##2 - { - \__semantex_process_arg_valuekey:nnnN { ####1 } { ##1 } { ##2 } \l__semantex_arg_valuekey_auxiliary_temp_tl - } - \cs_set:Npn\l__semantex_arg_valuekey_auxiliary_temp_cs:n##1 { #3 } - \keyval_parse:NNo - \l__semantex_arg_valuekey_auxiliary_singlekey_temp_cs:n - \l__semantex_arg_valuekey_auxiliary_valuekey_temp_cs:nn - { - \l__semantex_arg_valuekey_auxiliary_temp_cs:n { ##2 } - } - \cs_set:cpo { __semantex_data_cs_custom_arg_valuekey_#1_#2:nn } ##1##2 { - \l__semantex_arg_valuekey_auxiliary_temp_tl - } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_argsinglekeys:nn#1#2{ - % Add argument keys taking no values - \clist_map_inline:nn { #2 }{ - \__semantex_arg_singlekeys_format_auxiliary:nnn{#1}##1 - } -} - -\cs_new:Npn \__semantex_arg_singlekeys_format_auxiliary:nnn#1#2#3{ - \tl_set:Nn\l__semantex_arg_singlekey_auxiliary_temp_tl{} - \cs_set:Npn\l__semantex_arg_singlekey_auxiliary_singlekey_temp_cs:n##1 + \cs_set:Npn\l__semantex_singlekey_auxiliary_temp_cs: { #3 } + \tl_set:Nn \l__semantex_singlekey_auxiliary_temp_tl {} + \semantex_preprocess_keys:oN { - \__semantex_process_arg_singlekey:nnN { ####1 } { ##1 } \l__semantex_arg_singlekey_auxiliary_temp_tl - } - \cs_set:Npn\l__semantex_arg_singlekey_auxiliary_valuekey_temp_cs:nn##1##2 + \l__semantex_singlekey_auxiliary_temp_cs: + } \l__semantex_singlekey_auxiliary_temp_tl + \cs_set_protected:cpo { __semantex_data_cs_custom_singlekey_#1_\tl_trim_spaces:n{#2}:n } ##1 { - \__semantex_process_arg_valuekey:nnnN { ####1 } { ##1 } { ##2 } \l__semantex_arg_singlekey_auxiliary_temp_tl - } - \cs_set:Npn\l__semantex_arg_singlekey_auxiliary_temp_cs: { #3 } - \keyval_parse:NNo - \l__semantex_arg_singlekey_auxiliary_singlekey_temp_cs:n - \l__semantex_arg_singlekey_auxiliary_valuekey_temp_cs:nn - { \l__semantex_arg_singlekey_auxiliary_temp_cs: } - \cs_set:cpo { __semantex_data_cs_custom_arg_singlekey_#1_#2:n } ##1 { - \l__semantex_arg_singlekey_auxiliary_temp_tl + \l__semantex_singlekey_auxiliary_temp_tl } } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_removeargsinglekey:nn#1#2 +\cs_new_protected:Npn\semantex_remove_singlekey:nn#1#2 { - \cs_undefine:c { __semantex_data_cs_custom_arg_singlekey_#1_#2:n } + \cs_undefine:c { __semantex_data_cs_custom_singlekey_#1_#2:n } } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_removeargvaluekey:nn#1#2 +\cs_new_protected:Npn\semantex_define_two_valuekeys:nn#1#2 { - \cs_undefine:c { __semantex_data_cs_custom_arg_valuekey_#1_#2:nn } -} - -\cs_set_eq:cN { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_arg1valuekeys:nn } \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_arg_valuekeys:nn - -\cs_new:cpn { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_arg2valuekeys:nn }#1#2{ - % Add new valuekeys + % Add new valuekeys with 2 values \clist_map_inline:nn { #2 }{ - \__semantex_two_arg_valuekey_format_auxiliary:nnn{#1}##1 + \__semantex_two_valuekey_format_auxiliary:nnn { #1 } ##1 } } -\cs_generate_variant:Nn \__semantex_arg_valuekey_format_auxiliary:nnn { nno } - -\cs_new:Npn\__semantex_two_arg_valuekey_format_auxiliary:nnn#1#2#3 +\cs_new_protected:Npn\__semantex_two_valuekey_format_auxiliary:nnn#1#2#3 { - \cs_set:Npn\l__semantex_two_arg_valuekey_format_auxiliary_temp:nn##1##2{#3} - \__semantex_arg_valuekey_format_auxiliary:nno { #1 } { #2 } + \cs_set:Npn\l__semantex_two_valuekey_auxiliary_temp_cs:nn##1##2 { #3 } + \tl_set:Nn\l__semantex_two_valuekey_auxiliary_temp_tl{} + \semantex_preprocess_keys:oN { - \l__semantex_two_arg_valuekey_format_auxiliary_temp:nn - { - \semantex_grab_first_argument_of_two:nn ##1 - } - { - \semantex_grab_second_argument_of_two:nn ##1 - } - } - %IM Remove spaces in #2 -} - -\cs_new:cpn { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_arg3valuekeys:nn }#1#2{ - % Add new valuekeys - \clist_map_inline:nn { #2 }{ - \__semantex_three_arg_valuekey_format_auxiliary:nnn{#1}##1 + \l__semantex_two_valuekey_auxiliary_temp_cs:nn { ##2 } { ##3 } + } \l__semantex_two_valuekey_auxiliary_temp_tl + \cs_set_protected:cpo { __semantex_data_cs_custom_two_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnn } ##1##2##3 + { + \l__semantex_two_valuekey_auxiliary_temp_tl } -} - -\cs_new:Npn\__semantex_three_arg_valuekey_format_auxiliary:nnn#1#2#3 -{ - \cs_set:Npn\l__semantex_three_arg_valuekey_format_auxiliary_temp:nnn##1##2##3{#3} - \__semantex_arg_valuekey_format_auxiliary:nno { #1 } { #2 } + \cs_set_protected:cpn { __semantex_data_cs_custom_valuekey_#1_\tl_trim_spaces:n{#2}:nn } ##1##2 { - \l__semantex_three_arg_valuekey_format_auxiliary_temp:nnn - { - \semantex_grab_first_argument_of_three:nnn ##1 - } - { - \semantex_grab_second_argument_of_three:nnn ##1 - } - { - \semantex_grab_third_argument_of_three:nnn ##1 - } + \use:c { __semantex_data_cs_custom_two_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnn } { ##1 } ##2 } - %IM Remove spaces in #2 } -\cs_new:cpn { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_arg4valuekeys:nn }#1#2{ - % Add new valuekeys +\cs_new_protected:Npn\semantex_define_three_valuekeys:nn#1#2 +{ + % Add new valuekeys with 3 values \clist_map_inline:nn { #2 }{ - \__semantex_four_arg_valuekey_format_auxiliary:nnn{#1}##1 + \__semantex_three_valuekey_format_auxiliary:nnn {#1} ##1 } } -\cs_new:Npn\__semantex_four_arg_valuekey_format_auxiliary:nnn#1#2#3 +\cs_new_protected:Npn\__semantex_three_valuekey_format_auxiliary:nnn#1#2#3 { - \cs_set:Npn\l__semantex_four_arg_valuekey_format_auxiliary_temp:nnnn##1##2##3##4{#3} - \__semantex_arg_valuekey_format_auxiliary:nno { #1 } { #2 } + \cs_set:Npn\l__semantex_three_valuekey_auxiliary_temp_cs:nnn##1##2##3 { #3 } + \tl_set:Nn\l__semantex_three_valuekey_auxiliary_temp_tl{} + \semantex_preprocess_keys:oN { - \l__semantex_four_arg_valuekey_format_auxiliary_temp:nnnn - { - \semantex_grab_first_argument_of_four:nnnn ##1 - } - { - \semantex_grab_second_argument_of_four:nnnn ##1 - } - { - \semantex_grab_third_argument_of_four:nnnn ##1 - } - { - \semantex_grab_fourth_argument_of_four:nnnn ##1 - } - } - %IM Remove spaces in #2 -} - -\cs_new:cpn { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_arg5valuekeys:nn }#1#2{ - % Add new valuekeys - \clist_map_inline:nn { #2 }{ - \__semantex_five_arg_valuekey_format_auxiliary:nnn{#1}##1 + \l__semantex_three_valuekey_auxiliary_temp_cs:nnn { ##2 } { ##3 } { ##4 } + } \l__semantex_three_valuekey_auxiliary_temp_tl + \cs_set_protected:cpo { __semantex_data_cs_custom_three_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnn } ##1##2##3##4 + { + \l__semantex_three_valuekey_auxiliary_temp_tl } -} - -\cs_new:Npn\__semantex_five_arg_valuekey_format_auxiliary:nnn#1#2#3 -{ - \cs_set:Npn\l__semantex_five_arg_valuekey_format_auxiliary_temp:nnnnn##1##2##3##4##5{#3} - \__semantex_arg_valuekey_format_auxiliary:nno { #1 } { #2 } + \cs_set_protected:cpn { __semantex_data_cs_custom_valuekey_#1_\tl_trim_spaces:n{#2}:nn } ##1##2 { - \l__semantex_five_arg_valuekey_format_auxiliary_temp:nnnnn - { - \semantex_grab_first_argument_of_five:nnnnn ##1 - } - { - \semantex_grab_second_argument_of_five:nnnnn ##1 - } - { - \semantex_grab_third_argument_of_five:nnnnn ##1 - } - { - \semantex_grab_fourth_argument_of_five:nnnnn ##1 - } - { - \semantex_grab_fifth_argument_of_five:nnnnn ##1 - } + \use:c { __semantex_data_cs_custom_three_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnn } { ##1 } ##2 } - %IM Remove spaces in #2 } -\cs_new:cpn { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_arg6valuekeys:nn }#1#2{ - % Add new valuekeys +\cs_new_protected:Npn\semantex_define_four_valuekeys:nn#1#2 +{ + % Add new valuekeys with 4 values \clist_map_inline:nn { #2 }{ - \__semantex_six_arg_valuekey_format_auxiliary:nnn{#1}##1 + \__semantex_four_valuekey_format_auxiliary:nnn{#1}##1 } } -\cs_new:Npn\__semantex_six_arg_valuekey_format_auxiliary:nnn#1#2#3 +\cs_new_protected:Npn\__semantex_four_valuekey_format_auxiliary:nnn#1#2#3 { - \cs_set:Npn\l__semantex_six_arg_valuekey_format_auxiliary_temp:nnnnnn##1##2##3##4##5##6{#3} - \__semantex_arg_valuekey_format_auxiliary:nno { #1 } { #2 } + \cs_set:Npn\l__semantex_four_valuekey_auxiliary_temp_cs:nnnn##1##2##3##4 { #3 } + \tl_set:Nn\l__semantex_four_valuekey_auxiliary_temp_tl{} + \semantex_preprocess_keys:oN { - \l__semantex_six_arg_valuekey_format_auxiliary_temp:nnnnnn - { - \semantex_grab_first_argument_of_six:nnnnnn ##1 - } - { - \semantex_grab_second_argument_of_six:nnnnnn ##1 - } - { - \semantex_grab_third_argument_of_six:nnnnnn ##1 - } - { - \semantex_grab_fourth_argument_of_six:nnnnnn ##1 - } - { - \semantex_grab_fifth_argument_of_six:nnnnnn ##1 - } - { - \semantex_grab_sixth_argument_of_six:nnnnnn ##1 - } - } - %IM Remove spaces in #2 -} - -\cs_new:cpn { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_arg7valuekeys:nn }#1#2{ - % Add new valuekeys - \clist_map_inline:nn { #2 }{ - \__semantex_seven_arg_valuekey_format_auxiliary:nnn{#1}##1 + \l__semantex_four_valuekey_auxiliary_temp_cs:nnnn { ##2 } { ##3 } { ##4 } { ##5 } + } \l__semantex_four_valuekey_auxiliary_temp_tl + \cs_set_protected:cpo { __semantex_data_cs_custom_four_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnn } ##1##2##3##4##5 + { + \l__semantex_four_valuekey_auxiliary_temp_tl } -} - -\cs_new:Npn\__semantex_seven_arg_valuekey_format_auxiliary:nnn#1#2#3 -{ - \cs_set:Npn\l__semantex_seven_arg_valuekey_format_auxiliary_temp:nnnnnnn##1##2##3##4##5##6##7{#3} - \__semantex_arg_valuekey_format_auxiliary:nno { #1 } { #2 } + \cs_set_protected:cpn { __semantex_data_cs_custom_valuekey_#1_\tl_trim_spaces:n{#2}:nn } ##1##2 { - \l__semantex_seven_arg_valuekey_format_auxiliary_temp:nnnnnnn - { - \semantex_grab_first_argument_of_seven:nnnnnnn ##1 - } - { - \semantex_grab_second_argument_of_seven:nnnnnnn ##1 - } - { - \semantex_grab_third_argument_of_seven:nnnnnnn ##1 - } - { - \semantex_grab_fourth_argument_of_seven:nnnnnnn ##1 - } - { - \semantex_grab_fifth_argument_of_seven:nnnnnnn ##1 - } - { - \semantex_grab_sixth_argument_of_seven:nnnnnnn ##1 - } - { - \semantex_grab_seventh_argument_of_seven:nnnnnnn ##1 - } + \use:c { __semantex_data_cs_custom_four_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnn } { ##1 } ##2 } - %IM Remove spaces in #2 } -\cs_new:cpn { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_arg8valuekeys:nn }#1#2{ - % Add new valuekeys +\cs_new_protected:Npn\semantex_define_five_valuekeys:nn#1#2 +{ + % Add new valuekeys with 5 values \clist_map_inline:nn { #2 }{ - \__semantex_eight_arg_valuekey_format_auxiliary:nnn{#1}##1 + \__semantex_five_valuekey_format_auxiliary:nnn{#1}##1 } } -\cs_new:Npn\__semantex_eight_arg_valuekey_format_auxiliary:nnn#1#2#3 +\cs_new_protected:Npn\__semantex_five_valuekey_format_auxiliary:nnn#1#2#3 { - \cs_set:Npn\l__semantex_eight_arg_valuekey_format_auxiliary_temp:nnnnnnnn##1##2##3##4##5##6##7##8{#3} - \__semantex_arg_valuekey_format_auxiliary:nno { #1 } { #2 } + \cs_set:Npn\l__semantex_five_valuekey_auxiliary_temp_cs:nnnnn##1##2##3##4##5 { #3 } + \tl_set:Nn\l__semantex_five_valuekey_auxiliary_temp_tl{} + \semantex_preprocess_keys:oN { - \l__semantex_eight_arg_valuekey_format_auxiliary_temp:nnnnnnnn - { - \semantex_grab_first_argument_of_eight:nnnnnnnn ##1 - } - { - \semantex_grab_second_argument_of_eight:nnnnnnnn ##1 - } - { - \semantex_grab_third_argument_of_eight:nnnnnnnn ##1 - } - { - \semantex_grab_fourth_argument_of_eight:nnnnnnnn ##1 - } - { - \semantex_grab_fifth_argument_of_eight:nnnnnnnn ##1 - } - { - \semantex_grab_sixth_argument_of_eight:nnnnnnnn ##1 - } - { - \semantex_grab_seventh_argument_of_eight:nnnnnnnn ##1 - } - { - \semantex_grab_eighth_argument_of_eight:nnnnnnnn ##1 - } - } - %IM Remove spaces in #2 -} - -\cs_new:cpn { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_arg9valuekeys:nn }#1#2{ - % Add new valuekeys - \clist_map_inline:nn { #2 }{ - \__semantex_nine_arg_valuekey_format_auxiliary:nnn{#1}##1 + \l__semantex_five_valuekey_auxiliary_temp_cs:nnnnn { ##2 } { ##3 } { ##4 } { ##5 } { ##6 } + } \l__semantex_five_valuekey_auxiliary_temp_tl + \cs_set_protected:cpo { __semantex_data_cs_custom_five_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnn } ##1##2##3##4##5##6 + { + \l__semantex_five_valuekey_auxiliary_temp_tl } -} - -\cs_new:Npn\__semantex_nine_arg_valuekey_format_auxiliary:nnn#1#2#3 -{ - \cs_set:Npn\l__semantex_nine_arg_valuekey_format_auxiliary_temp:nnnnnnnnn##1##2##3##4##5##6##7##8##9{#3} - \__semantex_arg_valuekey_format_auxiliary:nno { #1 } { #2 } + \cs_set_protected:cpn { __semantex_data_cs_custom_valuekey_#1_\tl_trim_spaces:n{#2}:nn } ##1##2 { - \l__semantex_nine_arg_valuekey_format_auxiliary_temp:nnnnnnnnn - { - \semantex_grab_first_argument_of_nine:nnnnnnnnn ##1 - } - { - \semantex_grab_second_argument_of_nine:nnnnnnnnn ##1 - } - { - \semantex_grab_third_argument_of_nine:nnnnnnnnn ##1 - } - { - \semantex_grab_fourth_argument_of_nine:nnnnnnnnn ##1 - } - { - \semantex_grab_fifth_argument_of_nine:nnnnnnnnn ##1 - } - { - \semantex_grab_sixth_argument_of_nine:nnnnnnnnn ##1 - } - { - \semantex_grab_seventh_argument_of_nine:nnnnnnnnn ##1 - } - { - \semantex_grab_eighth_argument_of_nine:nnnnnnnnn ##1 - } - { - \semantex_grab_ninth_argument_of_nine:nnnnnnnnn ##1 - } + \use:c { __semantex_data_cs_custom_five_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnn } { ##1 } ##2 } - %IM Remove spaces in #2 -} - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_argnovaluekeys:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_argsinglekeys:nn % Previously, "singlekeys" was called "novaluekeys", so I am keeping this alias for backwards compatibility - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_removeargnovaluekey:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_removeargsinglekey:nn % Previously, "singlekeys" was called "novaluekeys", so I am keeping this alias for backwards compatibility - -\cs_set_eq:cN { __semantex_data_cs_custom_valuekey_class_SemantexBaseObject_removearg0valuekey:nn } \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_removeargsinglekey:nn - -% THESE ARE REALLY THE COMMANDS MANIPULATING DATA: - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_symbol:nn#1#2{ - % Sets the value of the symbol - \semantex_data_tl_set:nnn { #1 } { symbol } { \exp_not:n { #2 } } -} - -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_symbol:nn { xn } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_texclass:nn#1#2{ - % Sets the TeX class of the output, e.g. \mathord, \mathbin, \mathop etc. - \semantex_data_tl_set:nnn { #1 } { texclass } { \exp_not:n { #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setslot:nn#1#2{ - % Sets the argument slot, i.e. the - in f(-,x) - \semantex_data_tl_set:nnn { #1 } { argslot } { \exp_not:n { #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_symbolputright:nn#1#2{ - % Add something to the right of the symbol - \semantex_data_tl_put_right:nnn { #1 } { symbol } { \exp_not:n { #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_symbolputleft:nn#1#2{ - % Add something to the left of the symbol - \semantex_data_tl_put_left:nnn { #1 } { symbol } { \exp_not:n { #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_command:nn#1#2{ - % Adds one entry on the left of the command - % sequence to be applied to the symbol - \semantex_data_seq_put_right:nnn { #1 } { commands_sequence } { #2 } %IM maybe \exp_not:n { #2 }? -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearcommand:nn#1#2{ - % Adds one entry on the left of the command - % sequence to be applied to the symbol - \semantex_data_seq_clear:nn { #1 } { commands_sequence } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_argwithkeyval:nn#1#2{ - % Sets the argument (allows keyval interface) - \semantex_arg_keys_set:nn { #1 } { #2 } - %IMPORTANT: Previously, we needed three braces around #2, but suddenly - % this changed, even though I did not really change anything related - % to this (except I added _auxiliary_ in the command names related - % to arg keyvals) -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_argwithsinglekeys:nn#1#2{ - % Sets the argument (only allows singlekeys) - \semantex_arg_singlekeys_set:nn { #1 } { #2 } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_argwithonesinglekey:nn#1#2{ - % Sets the argument (only allows one singlekey) - \use:c { __semantex_data_cs_#1_arg_singlekey:n } { #2 } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_argwithoutkeyval:nn#1#2{ - % Sets the argument (no keyval interface allowed) - \semantex_data_tl_put_right:nnn { #1 } { arg } { \exp_not:n { #2 } } - \semantex_data_int_incr:nn { #1 } { numberofarguments } % Check if this has been added elsewhere - \semantex_data_bool_set_true:nn { #1 } { nextargwithsep } } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setargsep:nn#1#2 +\cs_new_protected:Npn\semantex_define_six_valuekeys:nn#1#2 { - % Sets the argument separator - \semantex_data_tl_set:nnn { #1 } { argsep } { \exp_not:n { #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setargdots:nn#1#2 -{ - % Sets the argument dot command - \semantex_data_tl_set:nnn { #1 } { argdots } { \exp_not:n { #2 } } + % Add new valuekeys with 6 values + \clist_map_inline:nn { #2 }{ + \__semantex_six_valuekey_format_auxiliary:nnn{#1}##1 + } } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setargslot:nn#1#2 +\cs_new_protected:Npn\__semantex_six_valuekey_format_auxiliary:nnn#1#2#3 { - % Sets the argument dot command - \semantex_data_tl_set:nnn { #1 } { argslot } { \exp_not:n { #2 } } -} - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_prearg:nn#1#2{ - % Sets something to write before the argument - \tl_if_blank:nF{#2} + \cs_set:Npn\l__semantex_six_valuekey_auxiliary_temp_cs:nnnnnn##1##2##3##4##5##6 { #3 } + \tl_set:Nn\l__semantex_six_valuekey_auxiliary_temp_tl{} + \semantex_preprocess_keys:oN + { + \l__semantex_six_valuekey_auxiliary_temp_cs:nnnnnn { ##2 } { ##3 } { ##4 } { ##5 } { ##6 } { ##7 } + } \l__semantex_six_valuekey_auxiliary_temp_tl + \cs_set_protected:cpo { __semantex_data_cs_custom_six_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnnn } ##1##2##3##4##5##6##7 { - \semantex_data_tl_put_left:nnn { #1 } { prearg } { \exp_not:n { #2 } } + \l__semantex_six_valuekey_auxiliary_temp_tl } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearprearg:nn#1#2 -{ - \semantex_data_tl_clear:nn { #1 } { prearg } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postarg:nn#1#2{ - % Sets something to write after the argument - \tl_if_blank:nF{#2} + \cs_set_protected:cpn { __semantex_data_cs_custom_valuekey_#1_\tl_trim_spaces:n{#2}:nn } ##1##2 { - \semantex_data_tl_put_right:nnn { #1 } { postarg } { \exp_not:n{ #2 } } + \use:c { __semantex_data_cs_custom_six_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnnn } { ##1 } ##2 } } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpostarg:nn#1#2 -{ - \semantex_data_tl_clear:nn { #1 } { postarg } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_output:nn#1#2 +\cs_new_protected:Npn\semantex_define_seven_valuekeys:nn#1#2 { - % Tells what class the object is supposed to output - \semantex_class_if_exist:NTF { #2 } - { - \semantex_data_tl_set:nnx { #1 } { output } { class_\cs_to_str:N #2 } - } - { - \semantex_error_output_format:nN { #1 } \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_output_temp_tl - \msg_error:nnxnn { semantex } { class_not_found } { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_output_temp_tl } { output } { #2 } + % Add new valuekeys with 7 values + \clist_map_inline:nn { #2 }{ + \__semantex_seven_valuekey_format_auxiliary:nnn{#1}##1 } - % Maybe allow output=self } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_outputoptions:nn#1#2{ - \tl_set:Nn\l__semantex_outputoptions_auxiliary_temp_tl{} - \cs_set:Npn\l__semantex_outputoptions_auxiliary_singlekey_temp_cs:n##1 +\cs_new_protected:Npn\__semantex_seven_valuekey_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_seven_valuekey_auxiliary_temp_cs:nnnnnnn##1##2##3##4##5##6##7 { #3 } + \tl_set:Nn\l__semantex_seven_valuekey_auxiliary_temp_tl{} + \semantex_preprocess_keys:oN { - \__semantex_outputoptions_process_singlekey:nnN { ####1 } { ##1 } \l__semantex_outputoptions_auxiliary_temp_tl - } - \cs_set:Npn\l__semantex_outputoptions_auxiliary_valuekey_temp_cs:nn##1##2 + \l__semantex_seven_valuekey_auxiliary_temp_cs:nnnnnnn { ##2 } { ##3 } { ##4 } { ##5 } { ##6 } { ##7 } { ##8 } + } \l__semantex_seven_valuekey_auxiliary_temp_tl + \cs_set_protected:cpo { __semantex_data_cs_custom_seven_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnnnn } ##1##2##3##4##5##6##7##8 { - \__semantex_outputoptions_process_valuekey:nnnN { ####1 } { ##1 } { ##2 } \l__semantex_outputoptions_auxiliary_temp_tl + \l__semantex_seven_valuekey_auxiliary_temp_tl } - \keyval_parse:NNn - \l__semantex_outputoptions_auxiliary_singlekey_temp_cs:n - \l__semantex_outputoptions_auxiliary_valuekey_temp_cs:nn - { #2 } - \semantex_data_tl_put_right:nno { #1 } { outputoptions } { \l__semantex_outputoptions_auxiliary_temp_tl } - %\exp_args:NNno\exp_args:Nno\cs_set:co { __semantex_data_cs_#1_outputoptions:n } - %\exp_args:Nnno - \semantex_data_cs_set:nnx { #1 } { outputoptions:n } + \cs_set_protected:cpn { __semantex_data_cs_custom_valuekey_#1_\tl_trim_spaces:n{#2}:nn } ##1##2 { -% g__semantex_data_tl_#1_outputoptions -% \semantex_data_tl_get:nn { #1 } { outputoptions } - \semantex_data_tl_get_exp_not:nn { #1 } { outputoptions } - %\l__semantex_outputoptions_auxiliary_temp_tl + \use:c { __semantex_data_cs_custom_seven_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnnnn } { ##1 } ##2 } } -\cs_generate_variant:Nn \semantex_data_cs_set:nnn { nnf , nnv , nnx } - -\cs_generate_variant:Nn \semantex_data_tl_put_right:nnn { nno } - - -\cs_new:Npn\__semantex_outputoptions_process_singlekey:nnN#1#2#3 +\cs_new_protected:Npn\semantex_define_eight_valuekeys:nn#1#2 { - \tl_put_right:Nn#3 - { - \exp_not:N\semantex_singlekey:nn { #1 } { \exp_not:n { #2 } } + % Add new valuekeys with 8 values + \clist_map_inline:nn { #2 }{ + \__semantex_eight_valuekey_format_auxiliary:nnn{#1}##1 } } -\cs_generate_variant:Nn \semantex_valuekey:nnn { nnx } - -\cs_new:Npn\__semantex_outputoptions_process_valuekey:nnnN#1#2#3#4 +\cs_new_protected:Npn\__semantex_eight_valuekey_format_auxiliary:nnn#1#2#3 { - \tl_if_eq:nnTF { #2 } { execute } + \cs_set:Npn\l__semantex_eight_valuekey_auxiliary_temp_cs:nnnnnnnn##1##2##3##4##5##6##7##8 { #3 } + \tl_set:Nn\l__semantex_eight_valuekey_auxiliary_temp_tl{} + \semantex_preprocess_keys:oN { - \tl_put_right:Nn#4 - { - \exp_not:n { #3 } - } + \l__semantex_eight_valuekey_auxiliary_temp_cs:nnnnnnnn { ##2 } { ##3 } { ##4 } { ##5 } { ##6 } { ##7 } { ##8 } { ##9 } + } \l__semantex_eight_valuekey_auxiliary_temp_tl + \cs_set_protected:cpo { __semantex_data_cs_custom_eight_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnnnnn } ##1##2##3##4##5##6##7##8##9 + { + \l__semantex_eight_valuekey_auxiliary_temp_tl } + \cs_set_protected:cpn { __semantex_data_cs_custom_valuekey_#1_\tl_trim_spaces:n{#2}:nn } ##1##2 { - \tl_put_right:Nn#4 - { - \exp_not:N\semantex_valuekey:nnn { #1 } { #2 } { \exp_not:n { #3 } } - } + \use:c { __semantex_data_cs_custom_eight_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnnnnn } { ##1 } ##2 } } -%---------------- - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifleftargument:nn#1#2{ - % Tells whether to rightreturn before rendering the output. - \str_if_eq:nnTF { #2 } { true } - { - \semantex_data_bool_set_true:nn { #1 } { leftargument } - } - { - \str_if_eq:nnTF { #2 } { false } - { - \semantex_data_bool_set_false:nn { #1 } { leftargument } - } - { - \semantex_error_output_format:nN { #1 } \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifleftargumen_temp_tl - \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifleftargumen_temp_tl } { ifleftargument } { #2 } - } +\cs_new_protected:Npn\semantex_define_nine_valuekeys:nn#1#2 +{ + % Add new valuekeys with 9 values + \clist_map_inline:nn { #2 }{ + \__semantex_nine_valuekey_format_auxiliary:nnn{#1}##1 } } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifoutput:nn#1#2{ %IMPLEMENT THIS - % Tells whether to output or not - \str_if_eq:nnTF { #2 } { true } + +\cs_new_protected:Npn\__semantex_nine_valuekey_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_nine_valuekey_auxiliary_temp_cs:nnnnnnnnn##1##2##3##4##5##6##7##8##9 { #3 } + \tl_set:Nn\l__semantex_nine_valuekey_auxiliary_temp_tl{} + \cs_set:Npn\l__semantex_nine_valuekey_auxiliary_singlekey_temp_cs:n##1 { - \semantex_data_bool_set_true:nn { #1 } { output } + \__semantex_preprocess_singlekey:nnN { \__semantex_nine_valuekey_format_auxiliary_name_of_register_temp_tl } { ##1 } \l__semantex_nine_valuekey_auxiliary_temp_tl } + \cs_set:Npn\l__semantex_nine_valuekey_auxiliary_valuekey_temp_cs:nn##1##2 { - \str_if_eq:nnTF { #2 } { false } - { - \semantex_data_bool_set_false:nn { #1 } { output } - } - { - \semantex_error_output_format:nN { #1 } \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifoutput_temp_tl - \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifoutput_temp_tl } { ifoutput } { #2 } - } + \__semantex_preprocess_valuekey:nnnN { \__semantex_nine_valuekey_format_auxiliary_name_of_register_temp_tl } { ##1 } { ##2 } \l__semantex_nine_valuekey_auxiliary_temp_tl } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_gradingposition:nn#1#2{ - % Tells whether to use upper or lower indices - \semantex_data_bool_provide:nn { #1 } { uppergrading } - \str_if_eq:nnTF { #2 } { upper } - { - \semantex_data_bool_set_true:nn { #1 } { uppergrading } - } + \semantex_keyval_parse:NNo + \l__semantex_nine_valuekey_auxiliary_singlekey_temp_cs:n + \l__semantex_nine_valuekey_auxiliary_valuekey_temp_cs:nn { - \str_if_eq:nnTF { #2 } { lower } - { - \semantex_data_bool_set_false:nn { #1 } { uppergrading } - } - { - \semantex_error_output_format:nN { #1 } \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_gradingposition_temp_tl - \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_gradingposition_temp_tl } { gradingposition } { #2 } - } + \l__semantex_nine_valuekey_auxiliary_temp_cs:nnnnnnnnn { ##1 } { ##2 } { ##3 } { ##4 } { ##5 } { ##6 } { ##7 } { ##8 } { ##9 } } -} - -\cs_set_eq:NN \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_gradingpos:nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_gradingposition:nn - -% Upper and lower right indices: - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upper:nn#1#2{ - % adds to the upper index - \tl_if_blank:nF{#2}{ - \semantex_data_tl_put_right:nnn { #1 } { upper } { \exp_not:n{ #2 } } - \semantex_data_bool_set_true:nn { #1 } { nextupperwithsep } - \semantex_data_int_incr:nn { #1 } { numberofupperindices } - } -} - - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_supper:nn#1#2{ - % Adds to the upper index, with a separator - \tl_if_blank:nF{#2} + \cs_set_protected:cpo { __semantex_data_cs_custom_nine_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnnnnn } ##1##2##3##4##5##6##7##8##9 { - \semantex_data_bool_get:nnTF { #1 } { nextupperwithsep } - { - \semantex_data_tl_put_right:nnx { #1 } { upper } - { \exp_not:n { \semantex_data_tl_get:nn { #1 } { uppersep } } } - \semantex_data_tl_put_right:nnn { #1 } { upper } { \exp_not:n { #2 } } - } - { - \semantex_data_tl_put_right:nnn { #1 } { upper } { \exp_not:n { #2 } } - } - \semantex_data_bool_set_true:nn { #1 } { nextupperwithsep } - \semantex_data_int_incr:nn { #1 } { numberofupperindices } - } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperputleft:nn#1#2{ - % Adds to the left of the upper index - \tl_if_blank:nF{#2}{ - \semantex_data_tl_put_left:nnn { #1 } { upper } { \exp_not:n{ #2 } } - \semantex_data_bool_set_true:nn { #1 } { nextupperwithsep } - \semantex_data_int_incr:nn { #1 } { numberofupperindices } + \l__semantex_nine_valuekey_auxiliary_temp_tl } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_preupper:nn#1#2{ - % Sets what to write before upper - \tl_if_blank:nF{#2} - { - \semantex_data_tl_put_left:nnn { #1 } { preupper } { \exp_not:n{ #2 } } - } -} -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postupper:nn#1#2{ - % Sets what to write after upper - \tl_if_blank:nF{#2} + \cs_set_protected:cpn { __semantex_data_cs_custom_valuekey_#1_\tl_trim_spaces:n{#2}:nn } ##1##2 { - \semantex_data_tl_put_right:nnn { #1 } { postupper } { \exp_not:n{ #2 } } + \tl_set:Nn \__semantex_nine_valuekey_format_auxiliary_name_of_register_temp_tl { ##1 } + \use:c { __semantex_data_cs_custom_nine_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnnnnn } ##2 } } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearupper:nn#1#2{ - \semantex_data_tl_clear:nn { #1 } { upper } - \semantex_data_bool_set_false:nn { #1 } { nextupperwithsep } - \semantex_data_int_clear:nn { #1 } { numberofupperindices } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpreupper:nn#1#2{ - \semantex_data_tl_clear:nn { #1 } { preupper } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpostupper:nn#1#2{ - \semantex_data_tl_clear:nn { #1 } { postupper } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setupperdots:nn#1#2 -{ - \semantex_data_tl_set:nnn { #1 } { upperdots } { \exp_not:n { #2 } } -} - -\cs_generate_variant:Nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upper:nn { nx } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperdots:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upper:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperdots } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setupperslot:nn#1#2 -{ - \semantex_data_tl_set:nnn { #1 } { upperslot } { \exp_not:n { #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperslot:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upper:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperslot } } -} - -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_supper:nn { nx } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_supperdots:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_supper:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperdots } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_supperslot:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_supper:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperslot } } -} - -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cupper:nn { nx } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cupperdots:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cupper:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperdots } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cupperslot:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cupper:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperslot } } -} -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperwithothersep:nn { nx } +% SETTING UP THE ARGUMENT KEYVAL INTERFACE -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperdotswithothersep:nn#1#2 +\cs_new_protected:Npn\semantex_preprocess_arg_keys:nN#1#2 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperwithothersep:nx { #1 } { { \exp_not:n { #2 } } { \semantex_data_tl_get:nn { #1 } { upperdots } } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperslotwithothersep:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperwithothersep:nx { #1 } { { \exp_not:n { #2 } } { \semantex_data_tl_get:nn { #1 } { upperslot } } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lower:nn#1#2{ - % Adds to the lower index - \tl_if_blank:nF{#2} + \cs_set:Npn\l__semantex_preprocess_arg_singlekey_temp_cs:n##1 { - \semantex_data_tl_put_right:nnn { #1 } { lower } { \exp_not:n { #2 } } - \semantex_data_bool_set_true:nn { #1 } { nextlowerwithsep } - \semantex_data_int_incr:nn { #1 } { numberoflowerindices } + \__semantex_preprocess_arg_singlekey:nnN { ####1 } { ##1 } #2 } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_slower:nn#1#2{ - % Adds to the lower index, with a separator - \tl_if_blank:nF{#2} + \cs_set:Npn\l__semantex_preprocess_arg_valuekey_temp_cs:nn##1##2 { - \semantex_data_bool_get:nnTF { #1 } { nextlowerwithsep } - { - \semantex_data_tl_put_right:nnx { #1 } { lower } - { \exp_not:n { \semantex_data_tl_get:nn { #1 } { lowersep } } } - \semantex_data_tl_put_right:nnn { #1 } { lower } { \exp_not:n { #2 } } - } - { - \semantex_data_tl_put_right:nnn { #1 } { lower } { \exp_not:n { #2 } } - } - \semantex_data_bool_set_true:nn { #1 } { nextlowerwithsep } - \semantex_data_int_incr:nn { #1 } { numberoflowerindices } - } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerputleft:nn#1#2{ - % Adds to the lower index - \tl_if_blank:nF{#2} - { - \semantex_data_tl_put_left:nnn { #1 } { lower } { \exp_not:n { #2 } } - \semantex_data_bool_set_true:nn { #1 } { nextlowerwithsep } - \semantex_data_int_incr:nn { #1 } { numberoflowerindices } + \__semantex_preprocess_arg_valuekey:nnnN { ####1 } { ##1 } { ##2 } #2 } + \semantex_keyval_parse:NNn + \l__semantex_preprocess_arg_singlekey_temp_cs:n + \l__semantex_preprocess_arg_valuekey_temp_cs:nn + { #1 } } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_prelower:nn#1#2{ - % Sets what to write before the lower index - \tl_if_blank:nF{#2} - { - \semantex_data_tl_put_left:nnn { #1 } { prelower } { \exp_not:n { #2 } } - } -} +\cs_generate_variant:Nn \semantex_preprocess_arg_keys:nN { oN } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postlower:nn#1#2{ - % Sets what to write after the lower index - \tl_if_blank:nF{#2} +\cs_new_protected:Npn\semantex_preprocess_arg_singlekeys:nN#1#2 +{ + \cs_set:Npn\l__semantex_preprocess_arg_singlekey_temp_cs:n##1 { - \semantex_data_tl_put_right:nnn { #1 } { postlower } { \exp_not:n{ #2 } } + \__semantex_preprocess_arg_singlekey:nnN { ####1 } { ##1 } #2 } + \clist_map_function:nN { #1 } \l__semantex_preprocess_arg_singlekey_temp_cs:n } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearlower:nn#1#2{ - \semantex_data_tl_clear:nn { #1 } { lower } - \semantex_data_bool_set_false:nn { #1 } { nextlowerwithsep } - \semantex_data_int_clear:nn { #1 } { numberoflowerindices } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearprelower:nn#1#2{ - \semantex_data_tl_clear:nn { #1 } { prelower } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpostlower:nn#1#2{ - \semantex_data_tl_clear:nn { #1 } { postlower } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setlowerdots:nn#1#2 -{ - \semantex_data_tl_set:nnn { #1 } { lowerdots } { \exp_not:n { #2 } } -} - -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lower:nn { nx } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerdots:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lower:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerdots } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setlowerslot:nn#1#2 -{ - \semantex_data_tl_set:nnn { #1 } { lowerslot } { \exp_not:n { #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerslot:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lower:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerslot } } -} - -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_slower:nn { nx } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_slowerdots:nn#1#2 +\cs_new_protected:Npn\__semantex_preprocess_arg_singlekey:nnN#1#2#3 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_slower:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerdots } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_slowerslot:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_slower:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerslot } } -} - -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clower:nn { nx } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clowerdots:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clower:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerdots } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clowerslot:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clower:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerslot } } + \tl_put_right:Nn#3 + { + \semantex_arg_singlekey:nn { #1 } { #2 } + } } -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerwithothersep:nn { nx } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerdotswithothersep:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerwithothersep:nx { #1 } { { \exp_not:n { #2 } } { \semantex_data_tl_get:nn { #1 } { lowerdots } } } -} -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerslotwithothersep:nn#1#2 +\cs_new_protected:Npn\__semantex_preprocess_arg_valuekey:nnnN#1#2#3#4 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerwithothersep:nx { #1 } { { \exp_not:n { #2 } } { \semantex_data_tl_get:nn { #1 } { lowerslot } } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperwithothersep:nn#1#2{ - % upperwithsep={separator}{contents} adds contents to the upper index - % with the appropriate index separator - \semantex_data_bool_get:nnTF { #1 } { nextupperwithsep } + \str_case:nnF { #2 } { - \semantex_data_tl_put_right:nnn { #1 } { upper } { - \exp_not:n { - \semantex_grab_first_argument_of_two:nn #2 - \semantex_grab_second_argument_of_two:nn #2 + { execute }{ + \tl_put_right:Nn#4 + { + #3 } } - } - { - \semantex_data_tl_put_right:nnn { #1 } { upper } { - \exp_not:n { - \semantex_grab_second_argument_of_two:nn #2 - } + { setkeys }{ + \semantex_preprocess_keys:nN { #3 } #4 } - } - \semantex_data_bool_set_true:nn { #1 } { nextupperwithsep } - \semantex_data_int_incr:nn { #1 } { numberofupperindices } -} - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerwithothersep:nn#1#2{ - % lowerwithsep={separator}{contents} adds contents to the lower index - % with the appropriate index separator - \semantex_data_bool_get:nnTF { #1 } { nextlowerwithsep } - { - \semantex_data_tl_put_right:nnn { #1 } { lower } { - \exp_not:n { - \semantex_grab_first_argument_of_two:nn #2 - \semantex_grab_second_argument_of_two:nn #2 - } + { keysset }{ + \semantex_preprocess_keys:nN { #3 } #4 } - } - { - \semantex_data_tl_put_right:nnn { #1 } { lower } { - \exp_not:n { - \semantex_grab_second_argument_of_two:nn #2 - } + { setkeysx }{ + \semantex_preprocess_keys_x:nN { #3 } #4 } - } - \semantex_data_bool_set_true:nn { #1 } { nextlowerwithsep } - \semantex_data_int_incr:nn { #1 } { numberofupperindices } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cupper:nn#1#2{ - % Adds to the upper index, with a comma as separator - \tl_if_blank:nF{#2} - { - \semantex_data_bool_get:nnTF { #1 } { nextupperwithsep } - { - \semantex_data_tl_put_right:nnn { #1 } { upper } { , \exp_not:n { #2 } } + { keyssetx }{ + \semantex_preprocess_keys_x:nN { #3 } #4 } - { - \semantex_data_tl_put_right:nnn { #1 } { upper } { \exp_not:n { #2 } } + { setargkeys }{ + \semantex_preprocess_arg_keys:nN { #3 } #4 } - \semantex_data_bool_set_true:nn { #1 } { nextupperwithsep } - \semantex_data_int_incr:nn { #1 } { numberofupperindices } - } -} - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clower:nn#1#2{ - % Adds to the lower index, with a comma as separator - \tl_if_blank:nF{#2} - { - \semantex_data_bool_get:nnTF { #1 } { nextlowerwithsep } - { - \semantex_data_tl_put_right:nnn { #1 } { lower } { , \exp_not:n { #2 } } + { argkeysset }{ + \semantex_preprocess_arg_keys:nN { #3 } #4 } - { - \semantex_data_tl_put_right:nnn { #1 } { lower } { \exp_not:n { #2 } } + { setargkeysx }{ + \semantex_preprocess_arg_keys_x:nN { #3 } #4 } - \semantex_data_bool_set_true:nn { #1 } { nextlowerwithsep } - \semantex_data_int_incr:nn { #1 } { numberoflowerindices } - } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextupperwithsep:nn#1#2 -{ - % Tells whether the upper index is the first one - \tl_if_eq:nnTF { #2 } { false } - { - \semantex_data_bool_set_false:nn { #1 } { nextupperwithsep } - } - { - \tl_if_eq:nnTF { #2 } { true } - { - \semantex_data_bool_set_true:nn { #1 } { nextupperwithsep } + { argkeyssetx }{ + \semantex_preprocess_arg_keys_x:nN { #3 } #4 } - { - \semantex_error_output_format:nN { #1 } \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextupperwithsep_temp_tl - \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextupperwithsep_temp_tl } { ifnextupperwithsep } { #2 } + { setargsinglekeys }{ + \semantex_preprocess_arg_singlekeys:nN { #3 } #4 } - } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextlowerwithsep:nn#1#2 % should be removed later -{ - % Tells whether the lower index is the first one - \tl_if_eq:nnTF { #2 } { false } - { - \semantex_data_bool_set_false:nn { #1 } { nextlowerwithsep } - } - { - \tl_if_eq:nnTF { #2 } { true } - { - \semantex_data_bool_set_true:nn { #1 } { nextlowerwithsep } + { argsinglekeysset }{ + \semantex_preprocess_arg_singlekeys:nN { #3 } #4 } - { - \semantex_error_output_format:nN { #1 } \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextlowerwithsep_temp_tl - \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextlowerwithsep_temp_tl } { ifnextlowerwithsep } { #2 } + { setargsinglekeysx }{ + \semantex_preprocess_arg_singlekeys_x:nN { #3 } #4 + } + { argsinglekeyssetx }{ + \semantex_preprocess_arg_singlekeys_x:nN { #3 } #4 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setuppersep:nn#1#2 -{ - % Sets the separator for the upper index - \semantex_data_tl_set:nnn { #1 } { uppersep } { \exp_not:n { #2 }} -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setlowersep:nn#1#2 -{ - % Sets the separator for the lower index - \semantex_data_tl_set:nnn { #1 } { lowersep } { \exp_not:n { #2 }} -} - -%--------------- Left indices: (I don't repeat all of the documentation) - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperleft:nn#1#2{ - % adds to the upper left index - \tl_if_blank:nF{#2}{ - \semantex_data_tl_put_left:nnn { #1 } { upperleft } { \exp_not:n{ #2 } } - \semantex_data_bool_set_true:nn { #1 } { nextupperleftwithsep } - \semantex_data_int_incr:nn { #1 } { numberofupperleftindices } - } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_supperleft:nn#1#2{ - \tl_if_blank:nF{#2} { - \semantex_data_bool_get:nnTF { #1 } { nextupperwithsep } - { - \semantex_data_tl_put_left:nnx { #1 } { upperleft } - { \exp_not:n { \semantex_data_tl_get:nn { #1 } { uppersep } } } - \semantex_data_tl_put_left:nnn { #1 } { upperleft } { \exp_not:n { #2 } } - } + \tl_put_right:Nn#4 { - \semantex_data_tl_put_left:nnn { #1 } { upperleft } { \exp_not:n { #2 } } + \semantex_arg_valuekey:nnn { #1 } { #2 } { #3 } } - \semantex_data_bool_set_true:nn { #1 } { nextupperleftwithsep } - \semantex_data_int_incr:nn { #1 } { numberofupperleftindices } - } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperleftputright:nn#1#2{ - \tl_if_blank:nF{#2}{ - \semantex_data_tl_put_right:nnn { #1 } { upperleft } { \exp_not:n{ #2 } } - \semantex_data_bool_set_true:nn { #1 } { nextupperleftwithsep } - \semantex_data_int_incr:nn { #1 } { numberofupperleftindices } - } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_preupperleft:nn#1#2{ - \tl_if_blank:nF{#2} - { - \semantex_data_tl_put_left:nnn { #1 } { preupperleft } { \exp_not:n{ #2 } } } } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postupperleft:nn#1#2{ - % adds to the lower index - \tl_if_blank:nF{#2} - { - \semantex_data_tl_put_right:nnn { #1 } { postupperleft } { \exp_not:n{ #2 } } - } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearupperleft:nn#1#2{ - \semantex_data_tl_clear:nn { #1 } { upperleft } - \semantex_data_bool_set_false:nn { #1 } { nextupperleftwithsep } - \semantex_data_int_clear:nn { #1 } { numberofupperleftindices } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpreupperleft:nn#1#2{ - \semantex_data_tl_clear:nn { #1 } { preupperleft } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpostupperleft:nn#1#2{ - \semantex_data_tl_clear:nn { #1 } { preupperleft } -} +% The x version: -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setupperleftdots:nn#1#2 +\cs_new_protected:Npn\semantex_preprocess_arg_keys_x:nN#1#2 { - \semantex_data_tl_set:nnn { #1 } { upperleftdots } { \exp_not:n { #2 } } -} - -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperleft:nn { nx } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperleftdots:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperleftdots } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setupperleftslot:nn#1#2 -{ - \semantex_data_tl_set:nnn { #1 } { upperleftslot } { \exp_not:n { #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperleftslot:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperleftslot } } -} - -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_supperleft:nn { nx } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_supperleftdots:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_supperleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperleftdots } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_supperleftslot:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_supperleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperleftslot } } -} - -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cupperleft:nn { nx } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cupperleftdots:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cupperleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperleftdots } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cupperleftslot:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cupperleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperleftslot } } -} - -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperleftwithothersep:nn { nx } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperleftdotswithothersep:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperleftwithothersep:nx { #1 } { { \exp_not:n { #2 } } { \semantex_data_tl_get:nn { #1 } { upperleftdots } } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperleftslotwithothersep:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperleftwithothersep:nx { #1 } { { \exp_not:n { #2 } } { \semantex_data_tl_get:nn { #1 } { upperleftslot } } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerleft:nn#1#2{ - \tl_if_blank:nF{#2} + \cs_set:Npn\l__semantex_preprocess_arg_singlekey_x_temp_cs:n##1 { - \semantex_data_tl_put_left:nnn { #1 } { lowerleft } { \exp_not:n{ #2 } } - \semantex_data_bool_set_true:nn { #1 } { nextlowerleftwithsep } - \semantex_data_int_incr:nn { #1 } { numberoflowerleftindices } + \__semantex_preprocess_arg_singlekey_x:nnN { ####1 } { ##1 } #2 } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_slowerleft:nn#1#2{ - \tl_if_blank:nF{#2} + \cs_set:Npn\l__semantex_preprocess_arg_valuekey_x_temp_cs:nn##1##2 { - \semantex_data_bool_get:nnTF { #1 } { nextlowerleftwithsep } - { - \semantex_data_tl_put_left:nnx { #1 } { lowerleft } - { \exp_not:n { \semantex_data_tl_get:nn { #1 } { lowerleftsep } } } - \semantex_data_tl_put_left:nnn { #1 } { lowerleft } { \exp_not:n { #2 } } - } - { - \semantex_data_tl_put_left:nnn { #1 } { lowerleft } { \exp_not:n { #2 } } - } - \semantex_data_bool_set_true:nn { #1 } { nextlowerleftwithsep } - \semantex_data_int_incr:nn { #1 } { numberoflowerleftindices } + \__semantex_preprocess_arg_valuekey_x:nnnN { ####1 } { ##1 } { ##2 } #2 } + \semantex_keyval_parse:NNn + \l__semantex_preprocess_arg_singlekey_x_temp_cs:n + \l__semantex_preprocess_arg_valuekey_x_temp_cs:nn + { #1 } } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerleftputright:nn#1#2{ - \tl_if_blank:nF{#2} %This test really shouldn’t be made. +\cs_new_protected:Npn\semantex_preprocess_arg_singlekeys_x:nN#1#2 +{ + \cs_set:Npn\l__semantex_preprocess_arg_singlekey_x_temp_cs:n##1 { - \semantex_data_tl_put_right:nnn { #1 } { lowerleft } { \exp_not:n{ #2 } } - \semantex_data_bool_set_true:nn { #1 } { nextlowerleftwithsep } - \semantex_data_int_incr:nn { #1 } { numberoflowerleftindices } + \__semantex_preprocess_arg_singlekey_x:nnN { ####1 } { ##1 } #2 } + \clist_map_function:nN { #1 } \l__semantex_preprocess_arg_singlekey_x_temp_cs:n } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_prelowerleft:nn#1#2{ - \tl_if_blank:nF{#2} - { - \semantex_data_tl_put_left:nnn { #1 } { prelowerleft } { \exp_not:n{ #2 } } - } -} -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postlowerleft:nn#1#2{ - \tl_if_blank:nF{#2} +\cs_new_protected:Npn\__semantex_preprocess_arg_singlekey_x:nnN#1#2#3 +{ + \tl_put_right:Nn#3 { - \semantex_data_tl_put_right:nnn { #1 } { postlowerleft } { \exp_not:n{ #2 } } + \semantex_arg_singlekey_x:nn { #1 } { #2 } } } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperleftwithothersep:nn#1#2{ - \semantex_data_bool_get:nnTF { #1 } { nextupperleftwithsep } - { - \semantex_data_tl_put_left:nnn { #1 } { upperleft } { - \exp_not:n { \semantex_grab_second_argument_of_two:nn #2 \semantex_grab_first_argument_of_two:nn #2 } - } - } +\cs_new_protected:Npn\__semantex_preprocess_arg_valuekey_x:nnnN#1#2#3#4 +{ + \str_case:nnF { #2 } { - \semantex_data_tl_put_left:nnn { #1 } { upperleft } { - \exp_not:n { \semantex_grab_second_argument_of_two:nn #2 } + { execute } { + \tl_put_right:Nn#4 + { + #3 + } } - } - \semantex_data_bool_set_true:nn { #1 } { nextupperleftwithsep } - \semantex_data_int_incr:nn { #1 } { numberofupperleftindices } -} - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerleftwithothersep:nn#1#2{ - \semantex_data_bool_get:nnTF { #1 } { nextlowerleftwithsep } - { - \semantex_data_tl_put_left:nnn { #1 } { lowerleft } { - \exp_not:n { \semantex_grab_second_argument_of_two:nn #2 \semantex_grab_first_argument_of_two:nn #2 } + { setkeys }{ + \semantex_preprocess_keys:nN { #3 } #4 } - } - { - \semantex_data_tl_put_left:nnn { #1 } { lowerleft } { - \exp_not:n { \semantex_grab_second_argument_of_two:nn #2 } + { keysset }{ + \semantex_preprocess_keys:nN { #3 } #4 } - } - \semantex_data_bool_set_true:nn { #1 } { nextlowerleftwithsep } - \semantex_data_int_incr:nn { #1 } { numberoflowerleftindices } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearlowerleft:nn#1#2{ - \semantex_data_tl_clear:nn { #1 } { lowerleft } - \semantex_data_bool_set_false:nn { #1 } { nextlowerleftwithsep } - \semantex_data_int_clear:nn { #1 } { numberoflowerleftindices } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearprelowerleft:nn#1#2{ - \semantex_data_tl_clear:nn { #1 } { prelowerleft } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpostlowerleft:nn#1#2{ - \semantex_data_tl_clear:nn { #1 } { prelowerleft } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setlowerleftdots:nn#1#2 -{ - \semantex_data_tl_set:nnn { #1 } { lowerleftdots } { \exp_not:n { #2 } } -} - -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerleft:nn { nx } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerleftdots:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerleftdots } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setlowerleftslot:nn#1#2 -{ - \semantex_data_tl_set:nnn { #1 } { lowerleftslot } { \exp_not:n { #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerleftslot:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerleftslot } } -} - -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_slowerleft:nn { nx } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_slowerleftdots:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_slowerleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerleftdots } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_slowerleftslot:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_slowerleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerleftslot } } -} - -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clowerleft:nn { nx } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clowerleftdots:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clowerleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerleftdots } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clowerleftslot:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clowerleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerleftslot } } -} - -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerleftwithothersep:nn { nx } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerleftdotswithothersep:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerleftwithothersep:nx { #1 } { { \exp_not:n { #2 } } { \semantex_data_tl_get:nn { #1 } { lowerleftdots } } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerleftslotwithothersep:nn#1#2 -{ - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerleftwithothersep:nx { #1 } { { \exp_not:n { #2 } } { \semantex_data_tl_get:nn { #1 } { lowerleftslot } } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cupperleft:nn#1#2{ - \tl_if_blank:nF{#2} - { - \semantex_data_bool_get:nnTF { #1 } { nextupperleftwithsep } - { - \semantex_data_tl_put_left:nnn { #1 } { upperleft } { \exp_not:n { #2 } , } + { setkeysx }{ + \semantex_preprocess_keys_x:nN { #3 } #4 } - { - \semantex_data_tl_put_left:nnn { #1 } { upperleft } { \exp_not:n { #2 } } + { keyssetx }{ + \semantex_preprocess_keys_x:nN { #3 } #4 } - \semantex_data_bool_set_true:nn { #1 } { nextupperleftwithsep } - \semantex_data_int_incr:nn { #1 } { numberofupperleftindices } - } -} - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clowerleft:nn#1#2{ - \tl_if_blank:nF{#2} - { - \semantex_data_bool_get:nnTF { #1 } { nextlowerleftwithsep } - { - \semantex_data_tl_put_left:nnn { #1 } { lowerleft } { \exp_not:n { #2 } , } + { setargkeys }{ + \semantex_preprocess_arg_keys:nN { #3 } #4 } - { - \semantex_data_tl_put_left:nnn { #1 } { lowerleft } { \exp_not:n { #2 } } + { argkeysset }{ + \semantex_preprocess_arg_keys:nN { #3 } #4 } - \semantex_data_bool_set_true:nn { #1 } { nextlowerleftwithsep } - \semantex_data_int_incr:nn { #1 } { numberoflowerleftindices } - } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextupperleftwithsep:nn#1#2 -{ - \tl_if_eq:nnTF { #2 } { false } - { - \semantex_data_bool_set_false:nn { #1 } { nextupperleftwithsep } - } - { - \tl_if_eq:nnTF { #2 } { true } - { - \semantex_data_bool_set_true:nn { #1 } { nextupperleftwithsep } + { setargkeysx }{ + \semantex_preprocess_arg_keys_x:nN { #3 } #4 } - { - \semantex_error_output_format:nN { #1 } \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextupperleftwithsep_temp_tl - \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextupperleftwithsep_temp_tl } { ifnextupperleftwithsep } { #2 } + { argkeyssetx }{ + \semantex_preprocess_arg_keys_x:nN { #3 } #4 } - } -} - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextlowerleftwithsep:nn#1#2 -{ - \tl_if_eq:nnTF { #2 } { false } - { - \semantex_data_bool_set_false:nn { #1 } { nextlowerleftwithsep } - } - { - \tl_if_eq:nnTF { #2 } { true } - { - \semantex_data_bool_set_true:nn { #1 } { nextlowerleftwithsep } + { setargsinglekeys }{ + \semantex_preprocess_arg_singlekeys:nN { #3 } #4 } - { - semantex_error_output_format:nN { #1 } \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextlowerleftwithsep_temp_tl - \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextlowerleftwithsep_temp_tl } { ifnextlowerleftwithsep } { #2 } + { argsinglekeysset }{ + \semantex_preprocess_arg_singlekeys:nN { #3 } #4 } - } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setupperleftsep:nn#1#2 -{ - \semantex_data_tl_set:nnn { #1 } { upperleftsep } { \exp_not:n { #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setlowerleftsep:nn#1#2 -{ - \semantex_data_tl_set:nnn { #1 } { lowerleftsep } { \exp_not:n { #2 } } -} - -% Contrary to what you might think, the following commands ARE -% sometimes needed. - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextdwithsep:nn#1#2 % should be removed later -{ - % Tells whether the d (degree) is empty or not - \str_if_eq:nnTF { #2 } { true } - { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextupperwithsep:nn { #1 } { #2 } } - { \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextlowerwithsep:nn { #1 } { #2 } } - } - { - \str_if_eq:nnTF { #2 } { false } - { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextupperwithsep:nn { #1 } { #2 } } - { \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextlowerwithsep:nn { #1 } { #2 } } + { setargsinglekeysx }{ + \semantex_preprocess_arg_singlekeys_x:nN { #3 } #4 } - { - \semantex_error_output_format:nN { #1 } \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextdwithsep_temp_tl - \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextdwithsep_temp_tl } { ifnextdwithsep } { #2 } + { argsinglekeyssetx }{ + \semantex_preprocess_arg_singlekeys_x:nN { #3 } #4 } } -} - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextdegwithsep:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextdwithsep - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextdegreewithsep:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextdwithsep - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextiwithsep:nn#1#2 -{ - % Tells whether the i (index) is empty or not - \str_if_eq:nnTF { #2 } { true } - { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextlowerwithsep:nn { #1 } { #2 } } - { \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextupperwithsep:nn { #1 } { #2 } } - } { - \str_if_eq:nnTF { #2 } { false } - { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextlowerwithsep:nn { #1 } { #2 } } - { \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextupperwithsep:nn { #1 } { #2 } } - } + \tl_put_right:Nn#4 { - \semantex_error_output_format:nN { #1 } \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextiwithsep_temp_tl - \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextiwithsep_temp_tl } { ifnextiwithsep } { #2 } + \semantex_arg_valuekey:nnx { #1 } { #2 } { #3 } } } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextindexwithsep:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextiwithsep:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_d:nn#1#2 +\cs_new_protected:Npn\semantex_define_arg_valuekeys:nn#1#2 { - % adds to the d-index (upper by default) - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upper:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lower:nn { #1 } { #2 } + % Add new valuekeys + \clist_map_inline:nn { #2 }{ + \__semantex_arg_valuekey_format_auxiliary:nnn{#1}##1 } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_deg:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_d:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_degree:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_d:nn +\cs_generate_variant:Nn \l__semantex_auxiliary_preprocess_arg_keys_temp:n { o } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sd:nn#1#2 +\cs_new_protected:Npn\__semantex_arg_valuekey_format_auxiliary:nnn#1#2#3 { - % adds to the d-index (upper by default) - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_supper:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_slower:nn { #1 } { #2 } - } -} - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sdeg:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sd:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sdegree:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sd:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cd:nn#1#2{ %IM Maybe remove this. - % adds to the d-index (upper by default) - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cupper:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clower:nn { #1 } { #2 } - } -} - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sdeg:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cd:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sdegree:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cd:nn - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_i:nn#1#2{ - % adds to the i-index (lower by default) - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lower:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upper:nn { #1 } { #2 } - } -} - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_index:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_i:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_si:nn#1#2{ - % adds to the i-index (lower by default) - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_slower:nn { #1 } { #2 } - } + \cs_set:Npn\l__semantex_arg_valuekey_auxiliary_temp_cs:n##1 { #3 } + \tl_set:Nn \l__semantex_arg_valuekey_auxiliary_temp_tl {} + \semantex_preprocess_arg_keys:oN { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_supper:nn { #1 } { #2 } - } -} - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sindex:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_si:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ci:nn#1#2{ - % adds to the i-index (lower by default) - \semantex_data_bool_get:nnTF { #1 } { uppergrading } + \l__semantex_arg_valuekey_auxiliary_temp_cs:n { ##2 } + } \l__semantex_arg_valuekey_auxiliary_temp_tl + \cs_set_protected:cpo { __semantex_data_cs_custom_arg_valuekey_#1_\tl_trim_spaces:n{#2}:nn } ##1##2 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clower:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cupper:nn { #1 } { #2 } + \l__semantex_arg_valuekey_auxiliary_temp_tl } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cindex:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ci:nn - - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_dwithothersep:nn#1#2 +\cs_new_protected:Npn\semantex_remove_arg_valuekey:nn#1#2 { - % adds to the d-index (upper by default) - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperwithothersep:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerwithothersep:nn { #1 } { #2 } - } -} - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_degwithothersep:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_dwithothersep:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_degreewithothersep:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_dwithothersep:nn - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_iwithothersep:nn#1#2{ - % adds to the i-index (lower by default) - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerwithothersep:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperwithothersep:nn { #1 } { #2 } - } + \cs_undefine:c { __semantex_data_cs_custom_arg_valuekey_#1_\tl_trim_spaces:n{#2}:nn } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_indexwithothersep:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_iwithothersep:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setdsep:nn#1#2 +\cs_new_protected:Npn\semantex_define_arg_singlekeys:nn#1#2 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setuppersep:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setlowersep:nn { #1 } { #2 } + % Add keys taking no values + \clist_map_inline:nn { #2 }{ + \__semantex_arg_singlekey_format_auxiliary:nnn{#1}##1 } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setdegsep:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setdsep:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setdegreesep:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setdsep:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setisep:nn#1#2 -{ - \semantex_data_bool_get:nnTF { #1 } { uppergrading } +\cs_new_protected:Npn \__semantex_arg_singlekey_format_auxiliary:nnn#1#2#3{ + \cs_set:Npn\l__semantex_arg_singlekey_auxiliary_temp_cs: { #3 } + \tl_set:Nn \l__semantex_arg_singlekey_auxiliary_temp_tl {} + \semantex_preprocess_arg_keys:oN { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setlowersep:nn { #1 } { #2 } - } + \l__semantex_arg_singlekey_auxiliary_temp_cs: + } \l__semantex_arg_singlekey_auxiliary_temp_tl + \cs_set_protected:cpo { __semantex_data_cs_custom_arg_singlekey_#1_\tl_trim_spaces:n{#2}:n } ##1 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setuppersep:nn { #1 } { #2 } + \l__semantex_arg_singlekey_auxiliary_temp_tl } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setindexsep:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setisep:nn -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_pred:nn#1#2 +\cs_new_protected:Npn\semantex_remove_arg_singlekey:nn#1#2 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_preupper:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_prelower:nn { #1 } { #2 } - } + \cs_undefine:c { __semantex_data_cs_custom_arg_singlekey_#1_#2:n } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_predeg:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_pred:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_predegree:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_pred:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postd:nn#1#2 +\cs_new_protected:Npn\semantex_define_arg_two_valuekeys:nn#1#2 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postupper:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postlower:nn { #1 } { #2 } + % Add new argument valuekeys with 2 values + \clist_map_inline:nn { #2 }{ + \__semantex_arg_two_valuekey_format_auxiliary:nnn{#1}##1 } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postdeg:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postd:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postdegree:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postd:nn - - -\cs_set:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cleard:nn#1#2 +\cs_new_protected:Npn\__semantex_arg_two_valuekey_format_auxiliary:nnn#1#2#3 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } + \cs_set:Npn\l__semantex_arg_two_valuekey_auxiliary_temp_cs:nn##1##2 { #3 } + \tl_set:Nn\l__semantex_arg_two_valuekey_auxiliary_temp_tl{} + \semantex_preprocess_arg_keys:oN { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearupper:nn { #1 } { #2 } - } + \l__semantex_arg_two_valuekey_auxiliary_temp_cs:nn { ##2 } { ##3 } + } \l__semantex_arg_two_valuekey_auxiliary_temp_tl + \cs_set_protected:cpo { __semantex_data_cs_custom_arg_two_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnn } ##1##2##3 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearlower:nn { #1 } { #2 } - } -} - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cleardeg:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cleard:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cleardegree:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cleard:nn - - -\cs_set:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpred:nn#1#2 -{ - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpreupper:nn { #1 } { #2 } + \l__semantex_arg_two_valuekey_auxiliary_temp_tl } + \cs_set_protected:cpn { __semantex_data_cs_custom_arg_valuekey_#1_\tl_trim_spaces:n{#2}:nn } ##1##2 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearprelower:nn { #1 } { #2 } + \use:c { __semantex_data_cs_custom_arg_two_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnn } { ##1 } ##2 } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpredeg:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpred:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpredegree:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpred:nn - - -\cs_set:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpostd:nn#1#2 +\cs_new_protected:Npn\semantex_define_arg_three_valuekeys:nn#1#2 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpostupper:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpostlower:nn { #1 } { #2 } + % Add new argument valuekeys with 3 values + \clist_map_inline:nn { #2 }{ + \__semantex_three_arg_valuekey_format_auxiliary:nnn{#1}##1 } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpostdeg:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpostd:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpostdegree:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpostd:nn - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_prei:nn#1#2 +\cs_new_protected:Npn\__semantex_three_arg_valuekey_format_auxiliary:nnn#1#2#3 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } + \cs_set:Npn\l__semantex_arg_three_valuekey_auxiliary_temp_cs:nnn##1##2##3 { #3 } + \tl_set:Nn\l__semantex_arg_three_valuekey_auxiliary_temp_tl{} + \semantex_preprocess_arg_keys:oN { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_prelower:nn { #1 } { #2 } - } + \l__semantex_arg_three_valuekey_auxiliary_temp_cs:nnn { ##2 } { ##3 } { ##4 } + } \l__semantex_arg_three_valuekey_auxiliary_temp_tl + \cs_set_protected:cpo { __semantex_data_cs_custom_arg_three_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnn } ##1##2##3##4 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_preupper:nn { #1 } { #2 } - } -} - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_preindex:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_prei:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_posti:nn#1#2 -{ - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postlower:nn { #1 } { #2 } + \l__semantex_arg_three_valuekey_auxiliary_temp_tl } + \cs_set_protected:cpn { __semantex_data_cs_custom_arg_valuekey_#1_\tl_trim_spaces:n{#2}:nn } ##1##2 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postupper:nn { #1 } { #2 } + \use:c { __semantex_data_cs_custom_arg_three_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnn } { ##1 } ##2 } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_postindex:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_posti:nn - -\cs_set:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cleari:nn#1#2 +\cs_new:Npn\semantex_define_arg_four_valuekeys:nn#1#2 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearlower:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearupper:nn { #1 } { #2 } + % Add new argument valuekeys with 4 values + \clist_map_inline:nn { #2 }{ + \__semantex_four_arg_valuekey_format_auxiliary:nnn{#1}##1 } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearindex:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cleari:nn - -\cs_set:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearprei:nn#1#2 +\cs_new_protected:Npn\__semantex_four_arg_valuekey_format_auxiliary:nnn#1#2#3 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearprelower:nn { #1 } { #2 } - } + \cs_set:Npn\l__semantex_arg_four_valuekey_auxiliary_temp_cs:nnnn##1##2##3##4 { #3 } + \tl_set:Nn\l__semantex_arg_four_valuekey_auxiliary_temp_tl{} + \semantex_preprocess_arg_keys:oN { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpreupper:nn { #1 } { #2 } - } -} - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpreindex:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearprei:nn - -\cs_set:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearposti:nn#1#2 -{ - \semantex_data_bool_get:nnTF { #1 } { uppergrading } + \l__semantex_arg_four_valuekey_auxiliary_temp_cs:nnnn { ##2 } { ##3 } { ##4 } { ##5 } + } \l__semantex_arg_four_valuekey_auxiliary_temp_tl + \cs_set_protected:cpo { __semantex_data_cs_custom_arg_four_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnn } ##1##2##3##4##5 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpostlower:nn { #1 } { #2 } + \l__semantex_arg_four_valuekey_auxiliary_temp_tl } + \cs_set_protected:cpn { __semantex_data_cs_custom_arg_valuekey_#1_\tl_trim_spaces:n{#2}:nn } ##1##2 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpostupper:nn { #1 } { #2 } + \use:c { __semantex_data_cs_custom_arg_four_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnn } { ##1 } ##2 } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearpostindex:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clearposti:nn - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setddots:nn#1#2 +\cs_new_protected:Npn\semantex_define_arg_five_valuekeys:nn#1#2 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \semantex_data_tl_set:nnn { #1 } { upperdots } { \exp_not:n s{ #2 } } - } - { - \semantex_data_tl_set:nnn { #1 } { lowerdots } { \exp_not:n { #2 } } + % Add new argument valuekeys with 5 values + \clist_map_inline:nn { #2 }{ + \__semantex_five_arg_valuekey_format_auxiliary:nnn{#1}##1 } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setdegdots:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setddots:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setdegreedots:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setddots:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ddots:nn#1#2 +\cs_new_protected:Npn\__semantex_five_arg_valuekey_format_auxiliary:nnn#1#2#3 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } + \cs_set:Npn\l__semantex_arg_five_valuekey_auxiliary_temp_cs:nnnnn##1##2##3##4##5 { #3 } + \tl_set:Nn\l__semantex_arg_five_valuekey_auxiliary_temp_tl{} + \semantex_preprocess_arg_keys:oN { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperdots:nn { #1 } { #2 } - } + \l__semantex_arg_five_valuekey_auxiliary_temp_cs:nnnnn { ##2 } { ##3 } { ##4 } { ##5 } { ##6 } + } \l__semantex_arg_five_valuekey_auxiliary_temp_tl + \cs_set_protected:cpo { __semantex_data_cs_custom_arg_five_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnn } ##1##2##3##4##5##6 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerdots:nn { #1 } { #2 } - } -} - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_degdots:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ddots:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_degreedots:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ddots:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setdslot:nn#1#2 -{ - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setupperslot:nn { #1 } { #2 } + \l__semantex_arg_five_valuekey_auxiliary_temp_tl } + \cs_set_protected:cpn { __semantex_data_cs_custom_arg_valuekey_#1_\tl_trim_spaces:n{#2}:nn } ##1##2 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setlowerslot:nn { #1 } { #2 } + \use:c { __semantex_data_cs_custom_arg_five_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnn } { ##1 } ##2 } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setdegslot:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setdslot:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setdegreeslot:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setdslot:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_dslot:nn#1#2 +\cs_new_protected:Npn\semantex_define_arg_six_valuekeys:nn#1#2 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperslot:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerslot:nn { #1 } { #2 } + % Add new argument valuekeys with 6 values + \clist_map_inline:nn { #2 }{ + \__semantex_six_arg_valuekey_format_auxiliary:nnn{#1}##1 } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_degslot:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_dslot:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_degreeslot:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_dslot:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sddots:nn#1#2 +\cs_new_protected:Npn\__semantex_six_arg_valuekey_format_auxiliary:nnn#1#2#3 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } + \cs_set:Npn\l__semantex_arg_six_valuekey_auxiliary_temp_cs:nnnnnn##1##2##3##4##5##6 { #3 } + \tl_set:Nn\l__semantex_arg_six_valuekey_auxiliary_temp_tl{} + \semantex_preprocess_arg_keys:oN { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_supperdots:nn { #1 } { #2 } - } + \l__semantex_arg_six_valuekey_auxiliary_temp_cs:nnnnnn { ##2 } { ##3 } { ##4 } { ##5 } { ##6 } { ##7 } + } \l__semantex_arg_six_valuekey_auxiliary_temp_tl + \cs_set_protected:cpo { __semantex_data_cs_custom_arg_six_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnnn } ##1##2##3##4##5##6##7 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_slowerdots:nn { #1 } { #2 } - } -} - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sdegdots:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sddots:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sdegreedots:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sddots:nn - - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sdslot:nn#1#2 -{ - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_supperslot:nn { #1 } { #2 } + \l__semantex_arg_six_valuekey_auxiliary_temp_tl } + \cs_set_protected:cpn { __semantex_data_cs_custom_arg_valuekey_#1_\tl_trim_spaces:n{#2}:nn } ##1##2 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_slowerslot:nn { #1 } { #2 } + \use:c { __semantex_data_cs_custom_arg_six_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnnn } { ##1 } ##2 } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sdegslot:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sdslot:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sdegreeslot:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sdslot:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cddots:nn#1#2 +\cs_new_protected:Npn\semantex_define_arg_seven_valuekeys:nn#1#2 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cupperdots:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clowerdots:nn { #1 } { #2 } + % Add new argument valuekeys with 7 values + \clist_map_inline:nn { #2 }{ + \__semantex_seven_arg_valuekey_format_auxiliary:nnn{#1}##1 } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cdegdots:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cddots:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cdegreedots:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cddots:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cdslot:nn#1#2 +\cs_new_protected:Npn\__semantex_seven_arg_valuekey_format_auxiliary:nnn#1#2#3 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cupperslot:nn { #1 } { #2 } - } + \cs_set:Npn\l__semantex_arg_seven_valuekey_auxiliary_temp_cs:nnnnnnn##1##2##3##4##5##6##7 { #3 } + \tl_set:Nn\l__semantex_arg_seven_valuekey_auxiliary_temp_tl{} + \semantex_preprocess_arg_keys:oN { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clowerslot:nn { #1 } { #2 } - } -} - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cdegslot:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cdslot:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cdegreeslot:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cdslot:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ddotswithothersep:nn#1#2 -{ - \semantex_data_bool_get:nnTF { #1 } { uppergrading } + \l__semantex_arg_seven_valuekey_auxiliary_temp_cs:nnnnnnn { ##2 } { ##3 } { ##4 } { ##5 } { ##6 } { ##7 } { ##8 } + } \l__semantex_arg_seven_valuekey_auxiliary_temp_tl + \cs_set_protected:cpo { __semantex_data_cs_custom_arg_seven_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnnnn } ##1##2##3##4##5##6##7##8 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperdotswithothersep:nn { #1 } { #2 } + \l__semantex_arg_seven_valuekey_auxiliary_temp_tl } + \cs_set_protected:cpn { __semantex_data_cs_custom_arg_valuekey_#1_\tl_trim_spaces:n{#2}:nn } ##1##2 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerdotswithothersep:nn { #1 } { #2 } + \use:c { __semantex_data_cs_custom_arg_seven_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnnnn } { ##1 } ##2 } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_degdotswithothersep:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ddotswithothersep:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_degreedotswithothersep:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ddotswithothersep:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_dslotwithothersep:nn#1#2 +\cs_new_protected:Npn\semantex_define_arg_eight_valuekeys:nn#1#2 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperslotwithothersep:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerslotwithothersep:nn { #1 } { #2 } + % Add new argument valuekeys with 8 values + \clist_map_inline:nn { #2 }{ + \__semantex_eight_arg_valuekey_format_auxiliary:nnn{#1}##1 } } - - -%---------------------------------------------------------- - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setidots:nn#1#2 +\cs_new_protected:Npn\__semantex_eight_arg_valuekey_format_auxiliary:nnn#1#2#3 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } + \cs_set:Npn\l__semantex_arg_eight_valuekey_auxiliary_temp_cs:nnnnnnnn##1##2##3##4##5##6##7##8 { #3 } + \tl_set:Nn\l__semantex_arg_eight_valuekey_auxiliary_temp_tl{} + \semantex_preprocess_arg_keys:oN { - \semantex_data_tl_set:nnn { #1 } { lowerdots } { \exp_not:n { #2 } } - } + \l__semantex_arg_eight_valuekey_auxiliary_temp_cs:nnnnnnnn { ##2 } { ##3 } { ##4 } { ##5 } { ##6 } { ##7 } { ##8 } { ##9 } + } \l__semantex_arg_eight_valuekey_auxiliary_temp_tl + \cs_set_protected:cpo { __semantex_data_cs_custom_arg_eight_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnnnnn } ##1##2##3##4##5##6##7##8##9 { - \semantex_data_tl_set:nnn { #1 } { upperdots } { \exp_not:n { #2 } } + \l__semantex_arg_eight_valuekey_auxiliary_temp_tl } -} - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setindexdots:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setidots:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setdegreedots:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setidots:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_idots:nn#1#2 -{ - \semantex_data_bool_get:nnTF { #1 } { uppergrading } + \cs_set_protected:cpn { __semantex_data_cs_custom_arg_valuekey_#1_\tl_trim_spaces:n{#2}:nn } ##1##2 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerdots:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperdots:nn { #1 } { #2 } + \use:c { __semantex_data_cs_custom_arg_eight_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnnnnn } { ##1 } ##2 } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_indexdots:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_idots:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_degreedots:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_idots:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setislot:nn#1#2 +\cs_new_protected:Npn\semantex_define_arg_nine_valuekeys:nn#1#2 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setlowerslot:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setupperslot:nn { #1 } { #2 } + % Add new argument valuekeys with 9 values + \clist_map_inline:nn { #2 }{ + \__semantex_nine_arg_valuekey_format_auxiliary:nnn{#1}##1 } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setindexslot:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setislot:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setdegreeslot:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_setislot:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_islot:nn#1#2 +\cs_new_protected:Npn\__semantex_nine_arg_valuekey_format_auxiliary:nnn#1#2#3 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } + \cs_set:Npn\l__semantex_arg_nine_valuekey_auxiliary_temp_cs:nnnnnnnnn##1##2##3##4##5##6##7##8##9 { #3 } + \tl_set:Nn\l__semantex_arg_nine_valuekey_auxiliary_temp_tl{} + \cs_set:Npn\l__semantex_arg_nine_valuekey_auxiliary_singlekey_temp_cs:n##1 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerslot:nn { #1 } { #2 } + \__semantex_preprocess_arg_singlekey:nnN { \__semantex_arg_nine_valuekey_format_auxiliary_name_of_register_temp_tl } { ##1 } \l__semantex_arg_nine_valuekey_auxiliary_temp_tl } + \cs_set:Npn\l__semantex_arg_nine_valuekey_auxiliary_valuekey_temp_cs:nn##1##2 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperslot:nn { #1 } { #2 } + \__semantex_preprocess_arg_valuekey:nnnN { \__semantex_arg_nine_valuekey_format_auxiliary_name_of_register_temp_tl } { ##1 } { ##2 } \l__semantex_arg_nine_valuekey_auxiliary_temp_tl } -} - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_indexslot:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_islot:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_degreeslot:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_islot:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sidots:nn#1#2 -{ - \semantex_data_bool_get:nnTF { #1 } { uppergrading } + \semantex_keyval_parse:NNo + \l__semantex_arg_nine_valuekey_auxiliary_singlekey_temp_cs:n + \l__semantex_arg_nine_valuekey_auxiliary_valuekey_temp_cs:nn + { + \l__semantex_arg_nine_valuekey_auxiliary_temp_cs:nnnnnnnnn { ##1 } { ##2 } { ##3 } { ##4 } { ##5 } { ##6 } { ##7 } { ##8 } { ##9 } + } + \cs_set_protected:cpo { __semantex_data_cs_custom_arg_nine_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnnnnn } ##1##2##3##4##5##6##7##8##9 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_slowerdots:nn { #1 } { #2 } + \l__semantex_arg_nine_valuekey_auxiliary_temp_tl } + \cs_set_protected:cpn { __semantex_data_cs_custom_arg_valuekey_#1_\tl_trim_spaces:n{#2}:nn } ##1##2 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_supperdots:nn { #1 } { #2 } + \tl_set:Nn \__semantex_arg_nine_valuekey_format_auxiliary_name_of_register_temp_tl { ##1 } + \use:c { __semantex_data_cs_custom_arg_nine_valuekey_#1_\tl_trim_spaces:n{#2}_auxiliary:nnnnnnnnn } ##2 } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sindexdots:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sidots:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sdegreedots:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sidots:nn - +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% COMMANDS HANDLING THE PARSE ROUTINE +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sislot:nn#1#2 +\cs_new_protected:Npn\semantex_parse:n#1 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_slowerslot:nn { #1 } { #2 } - } + % This command runs all the keys that the user may have + % stored via the parseoptions key + \exp_args:NNx\cs_set_protected:Nn\l__semantex_parse_temp_cs:n + % \cs_set:Nx gave us ##1 where we wanted #1 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_supperslot:nn { #1 } { #2 } + \semantex_data_tl_get_exp_not:nn { #1 } { parseoptions } } + \l__semantex_parse_temp_cs:n { #1 } + \semantex_data_tl_clear:nn { #1 } { parseoptions } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sindexslot:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sislot:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sdegreeslot:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sislot:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cidots:nn#1#2 +\cs_new_protected:Npn\semantex_add_to_parse_options:nn#1#2 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clowerdots:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cupperdots:nn { #1 } { #2 } - } + \tl_set:Nn\l__semantex_parseoptions_auxiliary_temp_tl{} + \semantex_preprocess_keys:nN { #2 } \l__semantex_parseoptions_auxiliary_temp_tl + \semantex_add_raw_commands_to_parse_options:no { #1 } { \l__semantex_parseoptions_auxiliary_temp_tl } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cindexdots:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cidots:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cdegreedots:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cidots:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cislot:nn#1#2 +\cs_new_protected:Npn\semantex_add_raw_commands_to_parse_options:nn#1#2 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_clowerslot:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cupperslot:nn { #1 } { #2 } - } + \semantex_data_tl_put_right:nnn { #1 } { parseoptions } { #2 } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cindexslot:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cislot:nn +\cs_generate_variant:Nn \semantex_add_raw_commands_to_parse_options:nn { no } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cdegreeslot:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_cislot:nn +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% COMMANDS HANDLING OUTPUT OPTIONS +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_idotswithothersep:nn#1#2 +\cs_new_protected:Npn\semantex_set_output:nn#1#2 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } + % Tells what class the register is supposed to output + \semantex_class_if_exist:NTF #2 { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerdotswithothersep:nn { #1 } { #2 } + \semantex_data_tl_set:nnx { #1 } { output } { \semantex_class_to_register:N #2 } } { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperdotswithothersep:nn { #1 } { #2 } + \semantex_msg_error:nnnn { #1 } { class_not_found } { output } { #2 } } } -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_indexdotswithothersep:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_idotswithothersep:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_degreedotswithothersep:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_idotswithothersep:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_islotwithothersep:nn#1#2 +\cs_new_protected:Npn\semantex_add_to_output_options:nn#1#2 { - \semantex_data_bool_get:nnTF { #1 } { uppergrading } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_lowerslotwithothersep:nn { #1 } { #2 } - } - { - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_upperslotwithothersep:nn { #1 } { #2 } - } + \tl_set:Nn\l__semantex_output_options_auxiliary_temp_tl{} + \semantex_preprocess_keys:nN { #2 } \l__semantex_output_options_auxiliary_temp_tl + \semantex_add_raw_commands_to_output_options:no { #1 } { \l__semantex_output_options_auxiliary_temp_tl } } -%---------------------------------------------------------- - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_degslotwithothersep:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_dslotwithothersep:nn - -\cs_set_eq:NN\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_degreeslotwithothersep:nn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_dslotwithothersep:nn - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_par:nn#1#2{ - % Turns parentheses on, and sets their size - \semantex_data_tl_set:nnn { #1 } { parsize }{ \exp_not:n { #2 } } - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifpar:nn { #1 } { true } +\cs_new_protected:Npn\semantex_add_raw_commands_to_output_options:nn#1#2 +{ + \semantex_data_tl_put_right:nnn { #1 } { outputoptions } { #2 } } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_parsize:nn#1#2{ - % Sets the size of the parentheses - \semantex_data_tl_set:nnn { #1 } { parsize }{ \exp_not:n { #2 } } -} +\cs_generate_variant:Nn \semantex_add_raw_commands_to_output_options:nn { no } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_leftpar:nn#1#2{ - \semantex_data_tl_set:nnn { #1 } { leftpar }{ \exp_not:n { #2 } } -} -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_leftpar:nn { xn } +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% USER-LEVEL PROGRAMMING KEYS +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_rightpar:nn#1#2{ - \semantex_data_tl_set:nnn { #1 } { rightpar }{ \exp_not:n { #2 } } -} +\cs_generate_variant:Nn\str_if_eq:nnTF { xxTF } -\cs_generate_variant:Nn \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_rightpar:nn { xn } +\cs_generate_variant:Nn\str_if_eq:nnT { xxT } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifpar:nn#1#2{ %IMPLEMENT THIS - % tells whether to use the output class or not - \semantex_data_bool_provide:nn { #1 } { par } - \str_if_eq:nnTF { #2 } { true } - { - \semantex_data_bool_set_true:nn { #1 } { par } - \semantex_data_bool_set_false:nn { #1 } { flexpar } - } - { - \str_if_eq:nnTF { #2 } { never } - { - \semantex_data_bool_set_false:nn { #1 } { par } - \semantex_data_bool_set_false:nn { #1 } { flexpar } - } - { - \str_if_eq:nnTF { #2 } { false } - { - \semantex_data_bool_set_false:nn { #1 } { par } - \semantex_data_bool_set_true:nn { #1 } { flexpar } - } - { - \semantex_error_output_format:nN { #1 } \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifpar_temp_tl - \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifpar_temp_tl } { ifpar } { #2 } - } - } - } -} -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_spar:nn#1#2 -{ - % Abbreviation for "symbol parentheses" - % Adds parentheses around the current symbol - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_return:nn { #1 }{} - \semantex_data_tl_inherit:nn { #1 } { symbol } % Check if really necessary - \tl_if_blank:nTF { #2 } - { - \semantex_data_tl_get_store:nnN { #1 } { sparsize } \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_spar_sparsize_temp_tl - \__semantex_symbol_parentheses_store:nnnnN - { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_spar_sparsize_temp_tl } - { \semantex_data_tl_get:nn { #1 } { leftspar } } - { \semantex_data_tl_get:nn { #1 } { rightspar } } - { \semantex_data_tl_get_exp_not:nn { #1 } { symbol } } - \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_spar_temp_tl - \semantex_data_tl_set:nnx { #1 } { symbol } - { - \exp_not:V\l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_spar_temp_tl - } - } - { - \tl_set:Nn \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_spar_sparsize_temp_tl { \exp_not:n { #2 } } - \__semantex_symbol_parentheses_store:nnnnN - { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_spar_sparsize_temp_tl } - { \semantex_data_tl_get:nn { #1 } { leftspar } } - { \semantex_data_tl_get:nn { #1 } { rightspar } } - { \semantex_data_tl_get_exp_not:nn { #1 } { symbol } } - \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_spar_temp_tl - \semantex_data_tl_set:nnx { #1 } { symbol } - { - \exp_not:V\l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_spar_temp_tl - } - } -} +\cs_generate_variant:Nn\str_if_eq:nnF { xxF } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextargwithsep:nn#1#2 -{ - % Tells whether it is the first argument or not - \tl_if_eq:nnTF { #2 } { true } - { - \semantex_data_bool_set_true:nn { #1 } { nextargwithsep } - } - { - \tl_if_eq:nnTF { #2 } { false } - { - \semantex_data_bool_set_false:nn { #1 } { nextargwithsep } - } - { - \semantex_error_output_format:nN { #1 } \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextargwithsep_temp_tl - \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifnextargwithsep_temp_tl } { ifnextargwithsep } { #2 } - } - } -} +\cs_generate_variant:Nn\tl_if_blank:nTF { xTF, xT } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_otherspar:nn#1#2 -{ - % Uses the syntax otherspar={leftpar}{rightpar} - % Adds a new spar, but with these as parentheses - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_otherspar_auxiliary:nnn { #1 } #2 -} +\cs_generate_variant:Nn \tl_if_blank:nF { xF } -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_otherspar_auxiliary:nnn#1#2#3 -{ - \semantex_data_tl_inherit:nn { #1 } { sparsize } % This is necessary for unknown reasons -- otherwise, it will crash when inheriting sparsize - \semantex_data_tl_inherit:nn { #1 } { symbol } - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_return:nn { #1 }{} - \semantex_data_tl_get_store:nnN { #1 } { sparsize } \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_otherspar_sparsize_temp_tl - \__semantex_symbol_parentheses_store:nnnnN - { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_otherspar_sparsize_temp_tl } - { \exp_not:n { \exp_not:n { #2 } } } - { \exp_not:n { \exp_not:n { #3 } } } - { \semantex_data_tl_get_exp_not:nn { #1 } { symbol } } - \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_otherspar_temp_tl - \semantex_data_tl_set:nnx { #1 } { symbol } - { - \exp_not:V\l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_otherspar_temp_tl - } +\cs_generate_variant:Nn \semantex_keys_set:nn { on } + +\cs_generate_variant:Nn \semantex_keys_set_x:nn { on } + +\cs_new:Npn\semantex_this:{ + \msg_error:nn { semantex } { SemantexThis_in_input_stream } +} +\cs_new:Npn\SemantexThis{\semantex_this:} +\cs_new_protected:Npn\SemantexDataProvide#1{\semantex_data_tl_provide:nn{\semantex_this:}{\tl_trim_spaces:n{#1}}} +\cs_new_protected:Npn\SemantexDataSet#1#2{\semantex_data_tl_set:nnn{\semantex_this:}{\tl_trim_spaces:n{#1}}{#2}} +\cs_new_protected:Npn\SemantexDataSetx#1#2{\semantex_data_tl_set:nnx{\semantex_this:}{\tl_trim_spaces:n{#1}}{#2}} +\cs_new_protected:Npn\SemantexDataPutRight#1#2{\semantex_data_tl_put_right:nnn{\semantex_this:}{\tl_trim_spaces:n{#1}}{#2}} +\cs_new_protected:Npn\SemantexDataPutRightx#1#2{\semantex_data_tl_put_right:nnx{\semantex_this:}{\tl_trim_spaces:n{#1}}{#2}} +\cs_new_protected:Npn\SemantexDataPutLeft#1#2{\semantex_data_tl_put_left:nnn{\semantex_this:}{\tl_trim_spaces:n{#1}}{#2}} +\cs_new_protected:Npn\SemantexDataPutLeftx#1#2{\semantex_data_tl_put_left:nnx{\semantex_this:}{\tl_trim_spaces:n{#1}}{#2}} +\cs_new:Npn\SemantexDataGet#1{\semantex_data_tl_get:nn{\semantex_this:}{\tl_trim_spaces:n{#1}}} +\cs_new:Npn\SemantexDataGetExpNot#1{\semantex_data_tl_get_exp_not:nn{\semantex_this:}{\tl_trim_spaces:n{#1}}} +\cs_new_protected:Npn\SemantexDataClear#1{\semantex_data_tl_clear:nn{\semantex_this:}{\tl_trim_spaces:n{#1}}} +\cs_new_protected:Npn\SemantexSetKeys#1{\semantex_keys_set:on{\semantex_this:}{#1}} +\cs_new_protected:Npn\SemantexKeysSet#1{\semantex_keys_set:on{\semantex_this:}{#1}} +\cs_new_protected:Npn\SemantexSetKeysx#1{\semantex_keys_set_x:on{\semantex_this:}{#1}} +\cs_new_protected:Npn\SemantexKeysSetx#1{\semantex_keys_set_x:on{\semantex_this:}{#1}} +\cs_new_protected:Npn\SemantexSetArgKeys#1{\semantex_arg_keys_set:nn { \semantex_this: } { #1 }} +\cs_new_protected:Npn\SemantexArgKeysSet#1{\semantex_arg_keys_set:nn { \semantex_this: } { #1 }} +\cs_new_protected:Npn\SemantexSetArgKeysx#1{\semantex_arg_keys_set_x:nn { \semantex_this: } { #1 }} +\cs_new_protected:Npn\SemantexArgKeysSetx#1{\semantex_arg_keys_set_x:nn { \semantex_this: } { #1 }} +\cs_new_protected:Npn\SemantexSetArgSingleKeys#1{\semantex_arg_singlekeys_set:nn { \semantex_this: } { #1 } } +\cs_new_protected:Npn\SemantexArgSingleKeysSet#1{\semantex_arg_singlekeys_set:nn { \semantex_this: } { #1 } } +\cs_new_protected:Npn\SemantexSetArgSingleKeysx#1{\semantex_arg_singlekeys_set_x:nn { \semantex_this: } { #1 } } +\cs_new_protected:Npn\SemantexArgSingleKeysSetx#1{\semantex_arg_singlekeys_set_x:nn { \semantex_this: } { #1 } } +\cs_new_protected:Npn\SemantexSetOneArgSingleKey#1{\semantex_arg_singlekey:nn { \semantex_this: } { #1 } } +\cs_new_protected:Npn\SemantexOneSingleArgKeySet#1{\semantex_arg_singlekey:nn { \semantex_this: } { #1 } } +\cs_new_protected:Npn\SemantexSetOneArgSingleKeyx#1{\semantex_arg_singlekey_x:nn { \semantex_this: } { #1 } } +\cs_new_protected:Npn\SemantexOneSingleArgKeySetx#1{\semantex_arg_singlekey_x:nn { \semantex_this: } { #1 } } +\cs_new_protected:Npn\SemantexSetArgWithoutKeyval#1{\semantex_arg_without_keyval:nn { \semantex_this: } { #1 } } +\cs_new_protected:Npn\SemantexArgWithoutKeyvalSet#1{\semantex_arg_without_keyval:nn { \semantex_this: } { #1 } } +\cs_new_protected:Npn\SemantexSetArgWithoutKeyvalx#1{\semantex_arg_without_keyval:nx { \semantex_this: } { #1 } } +\cs_new_protected:Npn\SemantexArgWithoutKeyvalSetx#1{\semantex_arg_without_keyval:nx { \semantex_this: } { #1 } } +\cs_new_protected:Npn\SemantexStrIfEqTF#1#2#3#4{\str_if_eq:xxTF{#1}{#2}{#3}{#4}} +\cs_new_protected:Npn\SemantexStrIfEqT#1#2#3{\str_if_eq:xxT{#1}{#2}{#3}} +\cs_new_protected:Npn\SemantexStrIfEqF#1#2#3{\str_if_eq:xxF{#1}{#2}{#3}} +\cs_new_protected:Npn\SemantexIfBlankTF#1#2#3{\tl_if_blank:xTF{#1}{#2}{#3}} +\cs_new_protected:Npn\SemantexIfBlankT#1#2{\tl_if_blank:xT{#1}{#2}} +\cs_new_protected:Npn\SemantexIfBlankF#1#2{\tl_if_blank:xF{#1}{#2}} +\cs_new_protected:Npn\SemantexBoolProvide#1{\semantex_data_bool_provide:nn{\semantex_this:}{\tl_trim_spaces:n{#1}}} +\cs_new_protected:Npn\SemantexBoolSetTrue#1{\semantex_data_bool_set_true:nn{\semantex_this:}{\tl_trim_spaces:n{#1}}} +\cs_new_protected:Npn\SemantexBoolSetFalse#1{\semantex_data_bool_set_false:nn{\semantex_this:}{\tl_trim_spaces:n{#1}}} +\cs_new:Npn\SemantexBoolIfTF#1#2#3{\semantex_data_bool_get:nnTF{\semantex_this:}{\tl_trim_spaces:n{#1}}{#2}{#3}} +\cs_new:Npn\SemantexBoolIfT#1#2{\semantex_data_bool_get:nnTF{\semantex_this:}{\tl_trim_spaces:n{#1}}{#2}{}} +\cs_new:Npn\SemantexBoolIfF#1#2{\semantex_data_bool_get:nnTF{\semantex_this:}{\tl_trim_spaces:n{#1}}{}{#2}} +\cs_new_protected:Npn\SemantexIntProvide#1{\semantex_data_int_provide:nn{\semantex_this:}{\tl_trim_spaces:n{#1}}} +\cs_new:Npn\SemantexIntGet#1{\semantex_data_int_get:nn{\semantex_this:}{\tl_trim_spaces:n{#1}}} +\cs_new_protected:Npn\SemantexIntClear#1{\semantex_data_int_clear:nn{\semantex_this:}{\tl_trim_spaces:n{#1}}} +\cs_new_protected:Npn\SemantexIntIncr#1{\semantex_data_int_incr:nn{\semantex_this:}{\tl_trim_spaces:n{#1}}} +\cs_new_protected:Npn\SemantexIntSet#1#2{\semantex_data_int_set:nnn{\semantex_this:}{\tl_trim_spaces:n{#1}}{#2}} +\cs_new:Npn\SemantexIntIfGreaterTF#1#2#3#4 +{ + \int_compare:nNnTF + { #1 } + > + { #2 } + { #3 } + { #4 } } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_Otherspar:nn#1#2 +\cs_new:Npn\SemantexIntIfGreaterT#1#2#3 { - % Uses the syntax otherspar={leftpar}{rightpar}{size} - % Adds a new spar, but with these as parentheses and size - \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_Otherspar_auxiliary:nnnn { #1 } #2 + \int_compare:nNnTF + { #1 } + > + { #2 } + { #3 } + { } } - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_Otherspar_auxiliary:nnnn#1#2#3#4 +\cs_new:Npn\SemantexIntIfGreaterF#1#2#3 { - \tl_set:Nn\l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_Otherspar_sparsize_temp_tl - { \exp_not:n { #4 } } - \__semantex_symbol_parentheses_store:nnnnN - { \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_Otherspar_sparsize_temp_tl } - { \exp_not:n { \exp_not:n { #2 } } } - { \exp_not:n { \exp_not:n { #3 } } } - { \semantex_data_tl_get_exp_not:nn { #1 } { symbol } } - \l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_Otherspar_temp_tl - \semantex_data_tl_set:nnx { #1 } { symbol } - { - \exp_not:V\l__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_Otherspar_temp_tl - } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_sparsize:nn#1#2{ - % sets the size of the parentheses - \semantex_data_tl_set:nnn { #1 } { sparsize }{ \exp_not:n { #2 } } -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_leftspar:nn#1#2{ - \semantex_data_tl_set:nnn { #1 } { leftspar }{ \exp_not:n { \exp_not:n { #2 } } } - %IM Two \exp_not necessary for unknown reasons - %IM Doing the same at leftpar yields an error. -} - -\cs_new:Npn\__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_rightspar:nn#1#2{ - \semantex_data_tl_set:nnn { #1 } { rightspar }{ \exp_not:n { \exp_not:n { #2 } } } - %IM Two \exp_not necessary for unknown reasons - %IM Doing the same at leftpar yields an error. + \int_compare:nNnTF + { #1 } + > + { #2 } + { } + { #3 } } - -\cs_generate_variant:Nn \semantex_keys_set:nn { nx, no, nV } % Only the first one is currently being used - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% COMMANDS CONTROLLING THE ARGUMENT KEYVAL INTERFACE -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\cs_new:Npn \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_othersep:nn#1#2 +\cs_new:Npn\SemantexIntIfEqTF#1#2#3#4 { - % Uses syntax sep={separator}{argument}; adds an argument - % with the specified separator - \semantex_data_bool_get:nnTF { #1 } { nextargwithsep } - { - \semantex_data_tl_put_right:nnn { #1 } { arg } { - \exp_not:n { - \semantex_grab_first_argument_of_two:nn #2 - \semantex_grab_second_argument_of_two:nn #2 - } - } - } - { - \semantex_data_tl_put_right:nnn { #1 } { arg } { - \exp_not:n { - \semantex_grab_second_argument_of_two:nn #2 - } - } - %IM These do not use :x, unlike the ones below - } - \semantex_data_int_incr:nn { #1 } { numberofarguments } - \semantex_data_bool_set_true:nn { #1 } { nextargwithsep } + \int_compare:nNnTF + { #1 } + = + { #2 } + { #3 } + { #4 } } - -\cs_generate_variant:Nn \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_othersep:nn { nx } - -\cs_new:Npn \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_s:nn#1#2 +\cs_new:Npn\SemantexIntIfEqT#1#2#3 { - % Adds to the argument, with the standard separator - \semantex_data_bool_get:nnTF { #1 } { nextargwithsep } - { - \semantex_data_tl_put_right:nnx { #1 } { arg } { \exp_not:n { \semantex_data_tl_get:nn { #1 } { argsep } } } - \semantex_data_tl_put_right:nnn { #1 } { arg } {\exp_not:n { #2 } } - % As an experiment, I tried changing cx to cn, and it failed - % when changing the separator on the fly. - } - { - \semantex_data_tl_put_right:nnn { #1 } { arg } { \exp_not:n { #2 } } - %IM Recently corrected - % Previously, this was cx, but I didn’t see any point of this; - % this was mostly to create symmetry with the below case where - % cx is strictly necessary. - } -% \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifoutput:nn { #1 } { true } - \semantex_data_int_incr:nn { #1 } { numberofarguments } - \semantex_data_bool_set_true:nn { #1 } { nextargwithsep } + \int_compare:nNnTF + { #1 } + = + { #2 } + { #3 } + { } } - -\cs_generate_variant:Nn \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_s:nn { nx } - -\cs_new:Npn \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_c:nn#1#2 +\cs_new:Npn\SemantexIntIfEqF#1#2#3 { - % Adds to the argument, with the standard separator - \semantex_data_bool_get:nnTF { #1 } { nextargwithsep } - { - \semantex_data_tl_put_right:nnn { #1 } { arg } { , \exp_not:n { #2 } } - % As an experiment, I tried changing cx to cn, and it failed - % when changing the separator on the fly. - } - { - \semantex_data_tl_put_right:nnn { #1 } { arg } { \exp_not:n { #2 } } - %IM Recently corrected - % Previously, this was cx, but I didn’t see any point of this; - % this was mostly to create symmetry with the below case where - % cx is strictly necessary. - } -% \__semantex_data_cs_custom_valuekey_class_SemantexBaseObject_ifoutput:nn { #1 } { true } - \semantex_data_int_incr:nn { #1 } { numberofarguments } - \semantex_data_bool_set_true:nn { #1 } { nextargwithsep } + \int_compare:nNnTF + { #1 } + = + { #2 } + { } + { #3 } } - -\cs_generate_variant:Nn \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_c:nn { nx } - -\cs_new:Npn \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_dots:nn#1#2 +\cs_new:Npn\SemantexIntIfLessTF#1#2#3#4 { - % Writes dots in the argument - \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_s:nx { #1 } { \semantex_data_tl_get_exp_not:nn { #1 } { argdots } } + \int_compare:nNnTF + { #1 } + < + { #2 } + { #3 } + { #4 } } - -\cs_new:Npn \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_slot:nn#1#2 +\cs_new:Npn\SemantexIntIfLessT#1#2#3 { - % Writes the slot in teh argument - \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_s:nx { #1 } { \semantex_data_tl_get_exp_not:nn { #1 } { argslot } } + \int_compare:nNnTF + { #1 } + < + { #2 } + { #3 } + { } } - -\cs_new:Npn \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_cdots:nn#1#2 +\cs_new:Npn\SemantexIntIfLessF#1#2#3 { - % Writes dots in the argument - \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_c:nx { #1 } { \semantex_data_tl_get_exp_not:nn { #1 } { argdots } } + \int_compare:nNnTF + { #1 } + < + { #2 } + { } + { #3 } } - -\cs_new:Npn \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_cslot:nn#1#2 +\cs_new:Npn\SemantexExpNot#1{\exp_not:n{#1}} +\cs_new:Npn\SemantexERRORKeyValueNotFound#1#2 { - % Writes the slot in teh argument - \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_c:nx { #1 } { \semantex_data_tl_get_exp_not:nn { #1 } { argslot } } + \semantex_error_key_value_not_found:nnn { \semantex_this: } { #1 } { #2 } } -\cs_new:Npn \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_dotswithothersep:nn#1#2 +\cs_new:Npn\SemantexERRORArgKeyValueNotFound#1#2 { - % Writes dots in the argument - \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_othersep:nx { #1 } { { \exp_not:n { #2 } } { \semantex_data_tl_get_exp_not:nn { #1 } { argdots } } } + \semantex_error_arg_key_value_not_found:nnn { \semantex_this: } { #1 } { #2 } } -\cs_new:Npn \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_slotwithothersep:nn#1#2 +\cs_new:Npn\SemantexERROR#1 { - % Writes the slot in teh argument - \__semantex_data_cs_custom_arg_valuekey_class_SemantexBaseObject_othersep:nx { #1 } { { \exp_not:n { #2 } } { \semantex_data_tl_get_exp_not:nn { #1 } { argslot } } } + \semantex_error_generic:nn { \semantex_this: } { #1 } } - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% SETTING UP THE BASE CLASS SemantexBaseObject +% ERROR MESSAGES % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { output } - -\semantex_data_tl_set:nnn { class_SemantexBaseObject } { output } { class_SemantexBaseObject } - -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { upper } +\msg_new:nnnn { semantex } { semantex_setup_key_not_found } { Unknown~key~#1~passed~to~\SemantexSetup~on~line~\msg_line_number: } {} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { uppersep } +\msg_new:nnnn { semantex } { semantex_setup_key_value_not_found } { Unknown~value~#2~passed~to~key~#1~in~\SemantexSetup~on~line~\msg_line_number: } {} -\semantex_data_tl_set:nnn { class_SemantexBaseObject } { uppersep } { , } +\msg_new:nnnn { semantex } { valuekey_not_found } { Unknown~key~#2~passed~to~#1 on~line~\msg_line_number: } {} -%IM Also, need commands like forgetupperindex, reverting to the class standard +\msg_new:nnnn { semantex } { arg_valuekey_not_found } { Unknown~argument~key~#2~passed~to~#1on~line~\msg_line_number: } {} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { lower } +\msg_new:nnnn { semantex } { data_tl_not_found } { Unknown~data~#2~requested~from~#1 on~line~\msg_line_number: } {} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { lowersep } +\msg_new:nnnn { semantex } { data_int_not_found } { Unknown~integer~#2~requested~from~#1 on~line~\msg_line_number: } {} -\semantex_data_tl_set:nnn { class_SemantexBaseObject } { lowersep } { , } +\msg_new:nnnn { semantex } { data_bool_not_found } { Unknown~boolean~#2~requested~from~#1 on~line~\msg_line_number: } {} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { preupper } +\msg_new:nnnn { semantex } { data_cs_not_found } { Unknown~command~sequence~#2~requested~from~#1 on~line~\msg_line_number: } {} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { postupper } +\msg_new:nnnn { semantex } { data_prop_not_found } { Unknown~property~list~#2~requested~from~#1 on~line~\msg_line_number: } {} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { prelower } +\msg_new:nnnn { semantex } { key_value_not_found } { Unknown~value~#3~passed~to~key~#2~in~#1 on~line~\msg_line_number: } {} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { postlower } +\msg_new:nnnn { semantex } { arg_key_value_not_found } { Unknown~value~#3~passed~to~argument~key~#2~in~#1 on~line~\msg_line_number: } {} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { upperleft } +\msg_new:nnnn { semantex } { class_already_defined } { Class~#1 already~defined;~you~tried~defining~it~again~on~line~\msg_line_number: } {} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { upperleftsep } +\msg_new:nnnn { semantex } { object_already_defined } { Object~#1 already~defined;~you~tried~defining~it~again~on~line~\msg_line_number: } {} -\semantex_data_tl_set:nnn { class_SemantexBaseObject } { upperleftsep } { , } +\msg_new:nnnn { semantex } { class_not_found } { Unknown~class~#3 declared~as~#2~of~#1 on~line~\msg_line_number: } {} -%IM do the same with all the others, INCLUDING if_uppergrading and symbol -%IM Also, need commands like forgetupperindex, reverting to the class standard +\msg_new:nnnn { semantex } { object_not_found } { You~set~#1 as~#2~of~unknown~object~#3 on~line~\msg_line_number: } {} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { lowerleft } +\msg_new:nnnn { semantex } { created_object_of_unknown_class } { Unknown~class~#1 declared~as~class~of~#2 on~line~\msg_line_number: } {} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { lowerleftsep } +\msg_new:nnnn { semantex } { used_unknown_class } { Unknown~class~#1 received~by~\token_to_str:N\UseClassInCommand~on~line~\msg_line_number: } {} -\semantex_data_tl_set:nnn { class_SemantexBaseObject } { lowerleftsep } { , } +\msg_new:nnnn { semantex } { setup_unknown_class } { You~tried~setting~up~an~unknown~#1 on~line~\msg_line_number: } {} +\msg_new:nnnn { semantex } { setup_unknown_object } { You~tried~setting~up~an~unknown~#1 on~line~\msg_line_number: } {} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { preupperleft } +\msg_new:nnnn { semantex } { created_a_SemantexBaseObject } { Never~create~objects~of~class~\token_to_str:N\SemantexBaseObject;~create~a~new~class~yourself~instead.~You~created~the~object~#1 on~line~\msg_line_number: } {} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { postupperleft } +\msg_new:nnnn { semantex } { SemantexThis_in_input_stream } { The~command~\token_to_str:N\SemantexThis~was~found~outside~a~class~or~object~on~line~\msg_line_number:;~did~you~forget~to~use~setkeysx={...}? } {} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { prelowerleft } +\msg_new:nnnn { semantex } { generic_error } { #2~#1 on~line~\msg_line_number: } {} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { postlowerleft } - -\semantex_data_int_provide:nn { class_SemantexBaseObject } { numberofarguments } - -\semantex_data_bool_provide:nn { class_SemantexBaseObject } { nextargwithsep } - -\semantex_data_bool_provide:nn { class_SemantexBaseObject } { nextupperleftwithsep } -\semantex_data_bool_provide:nn { class_SemantexBaseObject } { nextlowerleftwithsep } - -\semantex_data_int_provide:nn { class_SemantexBaseObject } { numberofupperleftindices } -\semantex_data_int_provide:nn { class_SemantexBaseObject } { numberoflowerleftindices } - -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { prearg } - -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { postarg } - -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { arg } - -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { argsep } -\semantex_data_tl_set:nnn { class_SemantexBaseObject } { argsep } {,} - -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { argslot } -\semantex_data_tl_set:nnn { class_SemantexBaseObject } { argslot } { \SemantexSlot } - -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { argdots } -\semantex_data_tl_set:nnn { class_SemantexBaseObject } { argdots } {\dots} - -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { symbol } - -\semantex_data_seq_provide:nn { class_SemantexBaseObject } { commands_sequence } - -\semantex_data_bool_provide:nn { class_SemantexBaseObject } { uppergrading } -\semantex_data_bool_set_true:nn { class_SemantexBaseObject } { uppergrading } - -\semantex_data_bool_provide:nn { class_SemantexBaseObject } { output } - -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { outputoptions } +\cs_generate_variant:Nn \msg_error:nnnn { nnnx } -\semantex_data_bool_provide:nn { class_SemantexBaseObject } { nextupperwithsep } -\semantex_data_bool_provide:nn { class_SemantexBaseObject } { nextlowerwithsep } +\tl_new:N\l__semantex_error_output_format_temp -\semantex_data_int_provide:nn { class_SemantexBaseObject } { numberofupperindices } -\semantex_data_int_provide:nn { class_SemantexBaseObject } { numberoflowerindices } +\cs_new_protected:Npn\semantex_error_output_format:nN#1#2 +{ + \tl_set:Nn \l__semantex_error_output_format_temp { #1 } + \tl_replace_all:Nnn \l__semantex_error_output_format_temp { object_ } { object~\cs:w } + \tl_replace_all:Nnn \l__semantex_error_output_format_temp { class_ } { class~\cs:w } + \tl_put_right:Nn \l__semantex_error_output_format_temp { \cs_end: } + \tl_trim_spaces:N \l__semantex_error_output_format_temp + \tl_set_eq:NN #2 \l__semantex_error_output_format_temp +} -\semantex_data_bool_provide:nn { class_SemantexBaseObject } { par } -\semantex_data_bool_set_true:nn { class_SemantexBaseObject } { par } +\cs_generate_variant:Nn \semantex_error_output_format:nN { xN } -\semantex_data_bool_provide:nn { class_SemantexBaseObject } { flexpar } +\cs_generate_variant:Nn \msg_error:nnn { nnx } -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { parseoptions } +\cs_generate_variant:Nn \msg_error:nnnn { nnxn } -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { texclass } +\cs_generate_variant:Nn \msg_error:nnnnn { nnxnn } -\semantex_data_bool_provide:nn { class_SemantexBaseObject } { leftargument } +\cs_new_protected:Npn \semantex_msg_error:nn#1#2 +{ + \semantex_error_output_format:xN { #1 } \l__semantex_msg_error_nnn_temp_tl + \msg_error:nnx { semantex } { #2 } + { + \l__semantex_msg_error_nnn_temp_tl + } +} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { upperdots } -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { upperslot } +\cs_new_protected:Npn \semantex_msg_error:nnn#1#2#3 +{ + \semantex_error_output_format:xN { #1 } \l__semantex_msg_error_nnnn_temp_tl + \msg_error:nnxn { semantex } { #2 } + { + \l__semantex_msg_error_nnnn_temp_tl + } { #3 } +} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { lowerdots } -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { lowerslot } +\cs_new_protected:Npn \semantex_msg_error:nnnn#1#2#3#4 +{ + \semantex_error_output_format:xN { #1 } \l__semantex_msg_error_nnnnn_temp_tl + \msg_error:nnxnn { semantex } { #2 } + { + \l__semantex_msg_error_nnnnn_temp_tl + } { #3 } { #4 } +} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { upperleftdots } -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { upperleftslot } +\cs_new_protected:Npn\semantex_error_key_value_not_found:nnn#1#2#3 +{ + \semantex_msg_error:nnnn { #1 } { key_value_not_found } { #2 } { #3 } +} -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { lowerleftdots } -\semantex_data_tl_provide:nn { class_SemantexBaseObject } { lowerleftslot } +\cs_new_protected:Npn\semantex_error_arg_key_value_not_found:nnn#1#2#3 +{ + \semantex_msg_error:nnnn { #1 } { arg_key_value_not_found } { #2 } { #3 } +} -%\tl_set:Nn\g_objectmath_SemantexBaseObject_upper { hej } -%\tl_set:Nn \SemantexBaseObject_output { class_SemantexBaseObject } -%\bool_new:N \SemantexBaseObject_output_if_provided -%\bool_set_true:N \SemantexBaseObject_output_if_provided +\cs_new_protected:Npn\semantex_error_generic:nn#1#2 +{ + \semantex_msg_error:nnn { #1 } { generic_error } { #2 } +} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% SETTING UP THE BASE CLASS \SemantexBaseObject +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\semantex_new_plain_class:Nw \SemantexBaseObject [ - %parent=SemantexBaseObject, +\semantex_define_valuekeys:nn { \semantex_class_to_register:N \SemantexBaseObject } +{ + {definekeys[1]}{execute={ \semantex_define_valuekeys:nn { ##1 } { #1 } }}, +} + +\semantex_new_simple_class:Nw \SemantexBaseObject [ + definekeys[1]={ + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % + % THE MOST BASIC KEYS, INCLUDING PROGRAMMING KEYS + % + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + {execute}{ execute={#1} }, + % Yes, this really does make sense + % -- check how \semantex_define_valuekeys:nn was defined + % Keys for setting up the keyval interface + {definekeys}{ execute={ \semantex_define_singlekeys:nn { ##1 } { #1 } } }, + {definekeys[0]}{ execute={ \semantex_define_singlekeys:nn { ##1 } { #1 } } }, + {definekeys[{0}]}{ execute={ \semantex_define_singlekeys:nn { ##1 } { #1 } } }, + {definekeys[{1}]}{ execute={ \semantex_define_valuekeys:nn { ##1 } { #1 } } }, + {definekeys[2]}{ execute={ \semantex_define_two_valuekeys:nn { ##1 } { #1 } } }, + {definekeys[{2}]}{ execute={ \semantex_define_two_valuekeys:nn { ##1 } { #1 } } }, + {definekeys[3]}{ execute={ \semantex_define_three_valuekeys:nn { ##1 } { #1 } } }, + {definekeys[{3}]}{ execute={ \semantex_define_three_valuekeys:nn { ##1 } { #1 } } }, + {definekeys[4]}{ execute={ \semantex_define_four_valuekeys:nn { ##1 } { #1 } } }, + {definekeys[{4}]}{ execute={ \semantex_define_four_valuekeys:nn { ##1 } { #1 } } }, + {definekeys[5]}{ execute={ \semantex_define_five_valuekeys:nn { ##1 } { #1 } } }, + {definekeys[{5}]}{ execute={ \semantex_define_five_valuekeys:nn { ##1 } { #1 } } }, + {definekeys[6]}{ execute={ \semantex_define_six_valuekeys:nn { ##1 } { #1 } } }, + {definekeys[{6}]}{ execute={ \semantex_define_six_valuekeys:nn { ##1 } { #1 } } }, + {definekeys[7]}{ execute={ \semantex_define_seven_valuekeys:nn { ##1 } { #1 } } }, + {definekeys[{7}]}{ execute={ \semantex_define_seven_valuekeys:nn { ##1 } { #1 } } }, + {definekeys[8]}{ execute={ \semantex_define_eight_valuekeys:nn { ##1 } { #1 } } }, + {definekeys[{8}]}{ execute={ \semantex_define_eight_valuekeys:nn { ##1 } { #1 } } }, + {definekeys[9]}{ execute={ \semantex_define_nine_valuekeys:nn { ##1 } { #1 } } }, + {definekeys[{9}]}{ execute={ \semantex_define_nine_valuekeys:nn { ##1 } { #1 } } }, + {removekey}{ execute={ \semantex_remove_singlekey:nn { ##1 } { #1 } } }, + {removekey[0]}{ execute={ \semantex_remove_singlekey:nn { ##1 } { #1 } } }, + {removekey[{0}]}{ execute={ \semantex_remove_singlekey:nn { ##1 } { #1 } } }, + {removekey[1]}{ execute={ \semantex_remove_valuekey:nn { ##1 } { #1 } } }, + {removekey[{1}]}{ execute={ \semantex_remove_valuekey:nn { ##1 } { #1 } } }, + {removekey[2]}{ execute={ \semantex_remove_valuekey:nn { ##1 } { #1 } } }, + {removekey[{2}]}{ execute={ \semantex_remove_valuekey:nn { ##1 } { #1 } } }, + {removekey[3]}{ execute={ \semantex_remove_valuekey:nn { ##1 } { #1 } } }, + {removekey[{3}]}{ execute={ \semantex_remove_valuekey:nn { ##1 } { #1 } } }, + {removekey[4]}{ execute={ \semantex_remove_valuekey:nn { ##1 } { #1 } } }, + {removekey[{5}]}{ execute={ \semantex_remove_valuekey:nn { ##1 } { #1 } } }, + {removekey[6]}{ execute={ \semantex_remove_valuekey:nn { ##1 } { #1 } } }, + {removekey[{6}]}{ execute={ \semantex_remove_valuekey:nn { ##1 } { #1 } } }, + {removekey[7]}{ execute={ \semantex_remove_valuekey:nn { ##1 } { #1 } } }, + {removekey[{7}]}{ execute={ \semantex_remove_valuekey:nn { ##1 } { #1 } } }, + {removekey[8]}{ execute={ \semantex_remove_valuekey:nn { ##1 } { #1 } } }, + {removekey[{8}]}{ execute={ \semantex_remove_valuekey:nn { ##1 } { #1 } } }, + {removekey[9]}{ execute={ \semantex_remove_valuekey:nn { ##1 } { #1 } } }, + {removekey[{9}]}{ execute={ \semantex_remove_valuekey:nn { ##1 } { #1 } } }, + % Keys for setting up the argument keyval interface: + {defineargkeys}{ execute={ \semantex_define_arg_singlekeys:nn { ##1 } { #1 } } }, + {defineargkeys[0]}{ execute={ \semantex_define_arg_singlekeys:nn { ##1 } { #1 } } }, + {defineargkeys[{0}]}{ execute={ \semantex_define_arg_singlekeys:nn { ##1 } { #1 } } }, + {defineargkeys[1]}{ execute={ \semantex_define_arg_valuekeys:nn { ##1 } { #1 } } }, + {defineargkeys[{1}]}{ execute={ \semantex_define_arg_valuekeys:nn { ##1 } { #1 } } }, + {defineargkeys[2]}{ execute={ \semantex_define_arg_two_valuekeys:nn { ##1 } { #1 } } }, + {defineargkeys[{2}]}{ execute={ \semantex_define_arg_two_valuekeys:nn { ##1 } { #1 } } }, + {defineargkeys[3]}{ execute={ \semantex_define_arg_three_valuekeys:nn { ##1 } { #1 } } }, + {defineargkeys[{3}]}{ execute={ \semantex_define_arg_three_valuekeys:nn { ##1 } { #1 } } }, + {defineargkeys[4]}{ execute={ \semantex_define_arg_four_valuekeys:nn { ##1 } { #1 } } }, + {defineargkeys[{4}]}{ execute={ \semantex_define_arg_four_valuekeys:nn { ##1 } { #1 } } }, + {defineargkeys[5]}{ execute={ \semantex_define_arg_five_valuekeys:nn { ##1 } { #1 } } }, + {defineargkeys[{5}]}{ execute={ \semantex_define_arg_five_valuekeys:nn { ##1 } { #1 } } }, + {defineargkeys[6]}{ execute={ \semantex_define_arg_six_valuekeys:nn { ##1 } { #1 } } }, + {defineargkeys[{6}]}{ execute={ \semantex_define_arg_six_valuekeys:nn { ##1 } { #1 } } }, + {defineargkeys[7]}{ execute={ \semantex_define_arg_seven_valuekeys:nn { ##1 } { #1 } } }, + {defineargkeys[{7}]}{ execute={ \semantex_define_arg_seven_valuekeys:nn { ##1 } { #1 } } }, + {defineargkeys[8]}{ execute={ \semantex_define_arg_eight_valuekeys:nn { ##1 } { #1 } } }, + {defineargkeys[{8}]}{ execute={ \semantex_define_arg_eight_valuekeys:nn { ##1 } { #1 } } }, + {defineargkeys[9]}{ execute={ \semantex_define_arg_nine_valuekeys:nn { ##1 } { #1 } } }, + {defineargkeys[{9}]}{ execute={ \semantex_define_arg_nine_valuekeys:nn { ##1 } { #1 } } }, + {removeargkey}{ execute={ \semantex_remove_arg_singlekey:nn { ##1 } { #1 } } }, + {removeargkey[0]}{ execute={ \semantex_remove_arg_singlekey:nn { ##1 } { #1 } } }, + {removeargkey[{0}]}{ execute={ \semantex_remove_arg_singlekey:nn { ##1 } { #1 } } }, + {removeargkey[1]}{ execute={ \semantex_remove_arg_valuekey:nn { ##1 } { #1 } } }, + {removeargkey[{1}]}{ execute={ \semantex_remove_arg_valuekey:nn { ##1 } { #1 } } }, + {removeargkey[2]}{ execute={ \semantex_remove_arg_valuekey:nn { ##1 } { #1 } } }, + {removeargkey[{2}]}{ execute={ \semantex_remove_arg_valuekey:nn { ##1 } { #1 } } }, + {removeargkey[3]}{ execute={ \semantex_remove_arg_valuekey:nn { ##1 } { #1 } } }, + {removeargkey[{3}]}{ execute={ \semantex_remove_arg_valuekey:nn { ##1 } { #1 } } }, + {removeargkey[4]}{ execute={ \semantex_remove_arg_valuekey:nn { ##1 } { #1 } } }, + {removeargkey[{5}]}{ execute={ \semantex_remove_arg_valuekey:nn { ##1 } { #1 } } }, + {removeargkey[6]}{ execute={ \semantex_remove_arg_valuekey:nn { ##1 } { #1 } } }, + {removeargkey[{6}]}{ execute={ \semantex_remove_arg_valuekey:nn { ##1 } { #1 } } }, + {removeargkey[7]}{ execute={ \semantex_remove_arg_valuekey:nn { ##1 } { #1 } } }, + {removeargkey[{7}]}{ execute={ \semantex_remove_arg_valuekey:nn { ##1 } { #1 } } }, + {removeargkey[8]}{ execute={ \semantex_remove_arg_valuekey:nn { ##1 } { #1 } } }, + {removeargkey[{8}]}{ execute={ \semantex_remove_arg_valuekey:nn { ##1 } { #1 } } }, + {removeargkey[9]}{ execute={ \semantex_remove_arg_valuekey:nn { ##1 } { #1 } } }, + {removeargkey[{9}]}{ execute={ \semantex_remove_arg_valuekey:nn { ##1 } { #1 } } }, + % Keys for programming: + {dataprovide}{ execute={ \semantex_data_tl_provide:nn { ##1 } { \tl_trim_spaces:n { #1 } } } }, + {dataclear}{ + execute={ \semantex_data_tl_clear:nn { ##1 } { \tl_trim_spaces:n { #1 } } }, + }, + {keysset}{ execute={ \semantex_keys_set:nn { ##1 } { #1 } } }, + {setkeys}{ execute={ \semantex_keys_set:nn { ##1 } { #1 } } }, + {keyssetx}{ execute={ \semantex_keys_set_x:nn { ##1 } { #1 } } }, + {setkeysx}{ execute={ \semantex_keys_set_x:nn { ##1 } { #1 } } }, + {boolprovide}{ + execute={ + \semantex_data_bool_provide:nn { ##1 } { \tl_trim_spaces:n { #1 } } + }, + }, + {boolsettrue}{ + execute={ + \semantex_data_bool_set_true:nn { ##1 } { \tl_trim_spaces:n { #1 } } + }, + }, + {boolsetfalse}{ + execute={ + \semantex_data_bool_set_false:nn { ##1 } { \tl_trim_spaces:n { #1 } } + }, + }, + {intprovide}{ + execute={ + \semantex_data_int_provide:nn { ##1 } { \tl_trim_spaces:n { #1 } } + }, + }, + {intclear}{ + execute={ + \semantex_data_int_clear:nn { ##1 } { \tl_trim_spaces:n { #1 } } + }, + }, + {intincr}{ + execute={ + \semantex_data_int_incr:nn { ##1 } { \tl_trim_spaces:n { #1 } } + }, + }, + {ERROR}{ + execute={ + \semantex_error_generic:nn { ##1 } { #1 } + }, + }, + }, + definekeys[2]={ + {dataset}{ + execute={ + \semantex_data_tl_set:nnn { ##1 } { \tl_trim_spaces:n { #1 } } { #2 } + }, + }, + {datasetx}{ + execute={ + \semantex_data_tl_set:nnx { ##1 } { \tl_trim_spaces:n { #1 } } { #2 } + }, + }, + {dataputright}{ + execute={ + \semantex_data_tl_put_right:nnn { ##1 } { \tl_trim_spaces:n { #1 } } { #2 } + }, + }, + {dataputrightx}{ + execute={ + \semantex_data_tl_put_right:nnx { ##1 } { \tl_trim_spaces:n { #1 } } { #2 } + }, + }, + {dataputleft}{ + execute={ + \semantex_data_tl_put_left:nnn { ##1 } { \tl_trim_spaces:n { #1 } } { #2 } + }, + }, + {dataputleftx}{ + execute={ + \semantex_data_tl_put_left:nnx { ##1 } { \tl_trim_spaces:n { #1 } } { #2 } + }, + }, + {ifblankT}{ + execute={ + \tl_if_blank:xTF { #1 } + { \semantex_keys_set:nn { ##1 } { #2 } } + { } + }, + }, + {ifblankF}{ + execute={ + \tl_if_blank:xTF { #1 } + { } + { \semantex_keys_set:nn { ##1 } { #2 } } + }, + }, + {boolifT}{ + execute={ + \semantex_data_bool_get:nnTF { ##1 } + { \tl_trim_spaces:n { #1 } } + { \semantex_keys_set:nn { ##1 } { #2 } } + { } + }, + }, + {boolifF}{ + execute={ + \semantex_data_bool_get:nnTF { ##1 } + { \tl_trim_spaces:n { #1 } } + { } + { \semantex_keys_set:nn { ##1 } { #2 } } + }, + }, + {intset}{ + execute={ + \semantex_data_int_set:nnn { ##1 } { \tl_trim_spaces:n { #1 } } { #2 } + }, + }, + {ERRORkeyvaluenotfound}{ + execute={ + \semantex_error_key_value_not_found:nnn { ##1 } { #1 } { #2 } + }, + }, + {ERRORargkeyvaluenotfound}{ + execute={ + \semantex_error_arg_key_value_not_found:nnn { ##1 } { #1 } { #2 } + }, + }, + }, + definekeys[3]={ + {strifeqT}{ + execute={ + \str_if_eq:xxTF { #1 } { #2 } + { \semantex_keys_set:nn { ##1 } { #3 } } + { } + }, + }, + {strifeqF}{ + execute={ + \str_if_eq:xxTF { #1 } { #2 } + { } + { \semantex_keys_set:nn { ##1 } { #3 } } + }, + }, + {ifblankTF}{ + execute={ + \tl_if_blank:xTF { #1 } + { \semantex_keys_set:nn { ##1 } { #2 } } + { \semantex_keys_set:nn { ##1 } { #3 } } + }, + }, + {boolifTF}{ + execute={ + \semantex_data_bool_get:nnTF { ##1 } + { \tl_trim_spaces:n { #1 } } + { \semantex_keys_set:nn { ##1 } { #2 } } + { \semantex_keys_set:nn { ##1 } { #3 } } + }, + }, + {intifgreaterT}{ + execute={ + \int_compare:nNnTF { #1 } > { #2 } + { \semantex_keys_set:nn { ##1 } { #3 } } + { } + }, + }, + {intifgreaterF}{ + execute={ + \int_compare:nNnTF { #1 } > { #2 } + { } + { \semantex_keys_set:nn { ##1 } { #3 } } + }, + }, + {intifeqT}{ + execute={ + \int_compare:nNnTF { #1 } = { #2 } + { \semantex_keys_set:nn { ##1 } { #3 } } + { } + }, + }, + {intifeqF}{ + execute={ + \int_compare:nNnTF { #1 } = { #2 } + { } + { \semantex_keys_set:nn { ##1 } { #3 } } + }, + }, + {intiflessT}{ + execute={ + \int_compare:nNnTF { #1 } < { #2 } + { \semantex_keys_set:nn { ##1 } { #3 } } + { } + }, + }, + {intiflessF}{ + execute={ + \int_compare:nNnTF { #1 } < { #2 } + { } + { \semantex_keys_set:nn { ##1 } { #3 } } + }, + }, + }, + definekeys[4]={ + {strifeqTF}{ + execute={ + \str_if_eq:xxTF { #1 } { #2 } + { \semantex_keys_set:nn { ##1 } { #3 } } + { \semantex_keys_set:nn { ##1 } { #4 } } + }, + }, + {intifgreaterTF}{ + execute={ + \int_compare:nNnTF { #1 } > { #2 } + { \semantex_keys_set:nn { ##1 } { #3 } } + { \semantex_keys_set:nn { ##1 } { #4 } } + }, + }, + {intifeqTF}{ + execute={ + \int_compare:nNnTF { #1 } = { #2 } + { \semantex_keys_set:nn { ##1 } { #3 } } + { \semantex_keys_set:nn { ##1 } { #4 } } + }, + }, + {intiflessTF}{ + execute={ + \int_compare:nNnTF { #1 } < { #2 } + { \semantex_keys_set:nn { ##1 } { #3 } } + { \semantex_keys_set:nn { ##1 } { #4 } } + }, + }, + }, + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % + % THE COLLECTION OF SLIGHTLY LESS FUNDAMENTAL KEYS + % + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + dataprovide=symbol, + boolprovide=uppergrading, + boolsettrue=uppergrading, + boolprovide=output, + dataprovide=outputoptions, + boolprovide=par, + boolsettrue=par, + boolprovide=flexpar, + dataprovide=parseoptions, + dataprovide=texclass, + boolprovide=leftargument, + boolprovide=allowSemantexDelimiterSize, + boolsettrue=allowSemantexDelimiterSize, + dataprovide=heightphantom, + dataprovide=slantingphantom, + execute={ \semantex_data_seq_provide:nn { \semantex_this: } { commands_sequence } }, + definekeys[1]={ + {parent}{ execute={ \semantex_data_parent_set:nn { ##1 } { #1 } } }, + {class}{ execute={ \semantex_data_class_set:nn { ##1 } { #1 } } }, + {copy}{ execute={ \semantex_data_copy_object:nn { ##1 } { #1 } } }, + {clone}{ execute={ \semantex_data_clone_object:nn { ##1 } { #1 } } }, + {texclass}{ execute={ \semantex_data_tl_set:nnn { ##1 } { texclass } { #1 } } }, + {symbol}{ + execute={ + \semantex_data_tl_set:nnn { ##1 } { symbol } { #1 } + \semantex_data_tl_set:nnn { ##1 } { heightphantom } { #1 } + \semantex_data_tl_set:nnn { ##1 } { slantingphantom } { #1 } + } + }, + {symbolputright}{ execute={ \semantex_data_tl_put_right:nnn { ##1 } { symbol } { #1 } } }, + {symbolputleft}{ execute={ \semantex_data_tl_put_left:nnn { ##1 } { symbol } { #1 } } }, + {heightphantom}{ execute={ \semantex_data_tl_set:nnn { ##1 } { heightphantom } { #1 } } }, + {slantingphantom}{ execute={ \semantex_data_tl_set:nnn { ##1 } { slantingphantom } { #1 } } }, + {parseoptions}{ execute={ \semantex_add_to_parse_options:nn { ##1 } { #1 } } }, + {command}{ execute={ \semantex_data_seq_put_right:nnn { ##1 } { commands_sequence } { #1 } } }, + {output}{ execute={ \semantex_set_output:nn { ##1 } { #1 } } }, + {outputoptions}{ execute={ \semantex_add_to_output_options:nn { ##1 } { #1 } } }, + {dooutput}{ + strifeqTF={#1}{true} + { + boolsettrue={output}, + } + { + strifeqTF={#1}{false} + { + boolsetfalse={output}, + } + { + ERRORkeyvaluenotfound={dooutput}{#1}, + } + }, + }, + {gradingposition}{ + strifeqTF={#1}{upper} + { + boolsettrue={uppergrading}, + } + { + strifeqTF={#1}{lower} + { + boolsetfalse={uppergrading}, + } + { + ERRORkeyvaluenotfound={gradingposition}{#1}, + }, + }, + }, + {gradingpos}{ + strifeqTF={#1}{upper} + { + boolsettrue={uppergrading}, + } + { + strifeqTF={#1}{lower} + { + boolsetfalse={uppergrading}, + } + { + ERRORkeyvaluenotfound={gradingpos}{#1}, + }, + }, + }, + {allowSemantexDelimiterSize}{ + strifeqTF={#1}{true} + { + boolsettrue={allowSemantexDelimiterSize}, + } + { + strifeqTF={#1}{false} + { + boolsetfalse={allowSemantexDelimiterSize}, + } + { + ERRORkeyvaluenotfound={allowSemantexDelimiterSize}{#1}, + } + }, + }, + {default}{si={#1}}, + {degreedefault}{sd={#1}}, + {arg}{ execute={ \semantex_arg_singlekeys_set:nn { ##1 } { #1 } } }, + {*withothersep}{ + d*withothersep={#1}, + }, + {**withothersep}{ + d**withothersep={#1}, + }, + }, output=\SemantexBaseObject, - ifoutput=false, - symbol=, - gradingposition=upper, - %upper=, - %lower=, - leftpar=(, - rightpar=), - par=normal, + definekeys={ + {return}{ execute={ \semantex_return:n { ##1 } } }, + {innerreturn}{ execute={ \semantex_inner_return:n { ##1 } } }, + {rightreturn}{ execute={ \semantex_right_return:n { ##1 } } }, + {leftreturn}{ execute={ \semantex_left_return:n { ##1 } } }, + {parse}{ execute={ \semantex_parse:n { ##1 } } }, + {clearcommand}{ execute={ \semantex_data_seq_clear:nn { ##1 } { commands_sequence } } }, + {...}{sidots}, + {-}{sislot}, + {*}{sd*}, + {**}{sd**}, + }, + % The "spar" routine: + definekeys={ + {spar}{spar=}, + }, + definekeys[1]={ + {spar}{ execute={ \semantex_spar:nn { ##1 } { #1 } } }, + {sparsize}{ execute={ \semantex_data_tl_set:nnn { ##1 } { sparsize } { #1 } } }, + {leftspar}{ execute={ \semantex_data_tl_set:nnn { ##1 } { leftspar } { #1 } } }, + {rightspar}{ execute={ \semantex_data_tl_set:nnn { ##1 } { rightspar } { #1 } } }, + }, + definekeys[2]={ + {otherspar}{ execute={ \semantex_other_spar:nnn { ##1 } { #1 } { #2 } } }, + }, + definekeys[3]={ + {Otherspar}{ execute={ \semantex_other_spar_with_size:nnnn { ##1 } { #1 } { #2 } { #3 } } }, + }, leftspar=(, rightspar=), sparsize=normal, - %arg=, - setupperdots=\dots, - setlowerdots=\dots, - setupperslot=\g_semantex_bullet, - setlowerslot=\g_semantex_bullet, - setupperleftdots=\dots, - setlowerleftdots=\dots, - setupperleftslot=\g_semantex_bullet, - setlowerleftslot=\g_semantex_bullet, - singlekeys={ - {prime}{upper={\prime}}, - {'}{prime}, - {''}{prime,prime}, - {'''}{prime,prime,prime}, - {*}{sdegree=\g_semantex_bullet}, - {**}{sdegree=\g_semantex_double_bullet}, - {degree*}{degree=\g_semantex_bullet}, - {degree**}{degree=\g_semantex_double_bullet}, - {sdegree*}{sdegree=\g_semantex_bullet}, - {sdegree**}{sdegree=\g_semantex_double_bullet}, - {cdegree*}{cdegree=\g_semantex_bullet}, - {cdegree**}{cdegree=\g_semantex_double_bullet}, - {deg*}{deg=\g_semantex_bullet}, - {deg**}{deg=\g_semantex_double_bullet}, - {sdeg*}{sdeg=\g_semantex_bullet}, - {sdeg**}{sdeg=\g_semantex_double_bullet}, - {cdeg*}{cdeg=\g_semantex_bullet}, - {cdeg**}{cdeg=\g_semantex_double_bullet}, - {d*}{d=\g_semantex_bullet}, - {d**}{d=\g_semantex_double_bullet}, - {sd*}{sd=\g_semantex_bullet}, - {sd**}{sd=\g_semantex_double_bullet}, - {cd*}{cd=\g_semantex_bullet}, - {cd**}{cd=\g_semantex_double_bullet}, - {index*}{index=\g_semantex_bullet}, - {index**}{index=\g_semantex_double_bullet}, - {sindex*}{sindex=\g_semantex_bullet}, - {sindex**}{sindex=\g_semantex_double_bullet}, - {cindex*}{cindex=\g_semantex_bullet}, - {cindex**}{cindex=\g_semantex_double_bullet}, - {i*}{i=\g_semantex_bullet}, - {i**}{i=\g_semantex_double_bullet}, - {si*}{si=\g_semantex_bullet}, - {si**}{si=\g_semantex_double_bullet}, - {ci*}{ci=\g_semantex_bullet}, - {ci**}{ci=\g_semantex_double_bullet}, - {upper*}{upper=\g_semantex_bullet}, - {upper**}{upper=\g_semantex_double_bullet}, - {supper*}{supper=\g_semantex_bullet}, - {supper**}{supper=\g_semantex_double_bullet}, - {cupper*}{cupper=\g_semantex_bullet}, - {cupper**}{cupper=\g_semantex_double_bullet}, - {lower*}{lower=\g_semantex_bullet}, - {lower**}{lower=\g_semantex_double_bullet}, - {slower*}{slower=\g_semantex_bullet}, - {slower**}{slower=\g_semantex_double_bullet}, - {clower*}{clower=\g_semantex_bullet}, - {clower**}{clower=\g_semantex_double_bullet}, - {upperleft*}{upperleft=\g_semantex_bullet}, - {upperleft**}{upperleft=\g_semantex_double_bullet}, - {supperleft*}{supperleft=\g_semantex_bullet}, - {supperleft**}{supperleft=\g_semantex_double_bullet}, - {cupperleft*}{cupperleft=\g_semantex_bullet}, - {cupperleft**}{cupperleft=\g_semantex_double_bullet}, - {lowerleft*}{lowerleft=\g_semantex_bullet}, - {lowerleft**}{lowerleft=\g_semantex_double_bullet}, - {slowerleft*}{slowerleft=\g_semantex_bullet}, - {slowerleft**}{slowerleft=\g_semantex_double_bullet}, - {clowerleft*}{clowerleft=\g_semantex_bullet}, - {clowerleft**}{clowerleft=\g_semantex_double_bullet}, - {smash}{command=\smash}, - {tilde}{command=\tilde}, - {widetilde}{command=\widetilde}, - {overline}{command=\overline}, - {bar}{command=\bar}, - {bold}{command=\mathbf}, - {roman}{command=\mathrm}, - {mathord}{texclass=\mathord}, - {mathbin}{texclass=\mathbin}, - {mathop}{texclass=\mathop}, - {mathrel}{texclass=\mathrel}, - {leftreturn}{leftreturn=}, - {innerreturn}{innerreturn=}, - {rightreturn}{rightreturn=}, - {return}{return=}, - {spar}{spar=}, - {parse}{parse=}, - {par}{ifpar=true}, - {neverpar}{ifpar=never}, - {nopar}{ifpar=false}, - {clearupper}{clearupper=}, - {clearlower}{clearlower=}, - {clearupperleft}{clearupperleft=}, - {clearlowerleft}{clearlowerleft=}, - {clearcommand}{clearcommand=}, - {cleard}{cleard=}, - {cleardeg}{cleardeg=}, - {cleardegree}{cleardegree=}, - {cleari}{cleari=}, - {clearindex}{clearindex=}, - {upperdots}{upperdots=}, - {upper...}{upperdots=}, - {upperslot}{upperslot=}, - {upper-}{upperslot=}, - {lowerdots}{lowerdots=}, - {lower...}{lowerdots=}, - {lowerslot}{lowerslot=}, - {lower-}{lowerslot=}, - {upperleftdots}{upperleftdots=}, - {upperleft...}{upperleftdots=}, - {upperleftslot}{upperleftslot=}, - {upperleft-}{upperleftslot=}, - {lowerleftdots}{lowerleftdots=}, - {lowerleft...}{lowerleftdots=}, - {lowerleftslot}{lowerleftslot=}, - {lowerleft-}{lowerleftslot=}, - {idots}{idots=}, - {indexdots}{indexdots=}, - {islot}{islot=}, - {indexslot}{indexslot=}, - {i...}{idots=}, - {index...}{indexdots=}, - {i-}{islot=}, - {index-}{indexslot=}, - {ddots}{ddots=}, - {degdots}{degdots=}, - {degreedots}{degreedots=}, - {dslot}{dslot=}, - {degslot}{degslot=}, - {degreeslot}{degreeslot=}, - {d...}{ddots=}, - {deg...}{degdots=}, - {degree...}{degreedots=}, - {d-}{dslot=}, - {deg-}{degslot=}, - {degree-}{degreeslot=}, - {cupperdots}{cupperdots=}, - {cupper...}{cupperdots=}, - {cupperslot}{cupperslot=}, - {cupper-}{cupperslot=}, - {clowerdots}{clowerdots=}, - {clower...}{clowerdots=}, - {clowerslot}{clowerslot=}, - {clower-}{clowerslot=}, - {cupperleftdots}{cupperleftdots=}, - {cupperleft...}{cupperleftdots=}, - {cupperleftslot}{cupperleftslot=}, - {cupperleft-}{cupperleftslot=}, - {clowerleftdots}{clowerleftdots=}, - {clowerleft...}{clowerleftdots=}, - {clowerleftslot}{clowerleftslot=}, - {clowerleft-}{clowerleftslot=}, - {cidots}{cidots=}, - {cindexdots}{cindexdots=}, - {cislot}{cislot=}, - {cindexslot}{cindexslot=}, - {ci...}{cidots=}, - {cindex...}{cindexdots=}, - {ci-}{cislot=}, - {cindex-}{cindexslot=}, - {cddots}{cddots=}, - {cdegdots}{cdegdots=}, - {cdegreedots}{cdegreedots=}, - {cdslot}{cdslot=}, - {cdegslot}{cdegslot=}, - {cdegreeslot}{cdegreeslot=}, - {cd...}{cddots=}, - {cdeg...}{cdegdots=}, - {cdegree...}{cdegreedots=}, - {cd-}{cdslot=}, - {cdeg-}{cdegslot=}, - {cdegree-}{cdegreeslot=}, - {supperdots}{supperdots=}, - {supper...}{supperdots=}, - {supperslot}{supperslot=}, - {supper-}{supperslot=}, - {slowerdots}{slowerdots=}, - {slower...}{slowerdots=}, - {slowerslot}{slowerslot=}, - {slower-}{slowerslot=}, - {supperleftdots}{supperleftdots=}, - {supperleft...}{supperleftdots=}, - {supperleftslot}{supperleftslot=}, - {supperleft-}{supperleftslot=}, - {slowerleftdots}{slowerleftdots=}, - {slowerleft...}{slowerleftdots=}, - {slowerleftslot}{slowerleftslot=}, - {slowerleft-}{slowerleftslot=}, - {sidots}{sidots=}, - {sindexdots}{sindexdots=}, - {sislot}{sislot=}, - {sindexslot}{sindexslot=}, - {si...}{sidots=}, - {sindex...}{sindexdots=}, - {si-}{sislot=}, - {sindex-}{sindexslot=}, - {sddots}{sddots=}, - {sdegdots}{sdegdots=}, - {sdegreedots}{sdegreedots=}, - {sdslot}{sdslot=}, - {sdegslot}{sdegslot=}, - {sdegreeslot}{sdegreeslot=}, - {sd...}{sddots=}, - {sdeg...}{sdegdots=}, - {sdegree...}{sdegreedots=}, - {sd-}{sdslot=}, - {sdeg-}{sdegslot=}, - {sdegree-}{sdegreeslot=}, - {...}{sidots=}, - {-}{sislot=}, -% {argwithkeyval}{ -% valuekeys={ -% {arg}{argwithkeyval={####1}}, -% }, -% }, -% {argwithsinglekeys}{ -% valuekeys={ -% {arg}{argwithsinglekeys={####1}}, -% }, -% }, -% {argwithoutkeyval}{ -% valuekeys={ -% {arg}{argwithoutkeyval={####1}}, -% }, -% }, -% {argwithonesinglekey}{ -% valuekeys={ -% {arg}{argwithonesinglekey={####1}}, -% }, -% }, + % The argument: + dataprovide=arg, + boolprovide=nextargwithsep, + intprovide=numberofarguments, + dataprovide=prearg, + dataprovide=postarg, + definekeys={ + {argdots}{setargkeys={...}}, + {arg...}{setargkeys={dots}}, + {cargdots}{setargkeys={cdots}}, + {carg...}{setargkeys={c...}}, + {argslot}{setargkeys={slot}}, + {arg-}{setargkeys={-}}, + {cargslot}{setargkeys={cslot}}, + {carg-}{setargkeys={c-}}, + {cleararg}{ execute={ + \semantex_data_tl_clear:nn { ##1 } { arg } + \semantex_data_int_clear:nn { ##1 } { numberofarguments } + \semantex_data_bool_set_false:nn { ##1 } { nextargwithsep } + } + }, + {clearprearg}{ execute={ \semantex_data_tl_clear:nn { ##1 } { prearg } } }, + {clearpostarg}{ execute={ \semantex_data_tl_clear:nn { ##1 } { postarg } } }, }, - valuekeys={ - {default}{sindex={#1}}, - {arg}{argwithsinglekeys={#1}}, - {degreedefault}{sdegree={#1}}, - {*withothersep}{degreewithothersep={#1}{\g_semantex_bullet}}, - {**withothersep}{degreewithothersep={#1}{\g_semantex_double_bullet}}, - {degree*withothersep}{degreewithothersep={#1}{\g_semantex_bullet}}, - {degree**withothersep}{degreewithothersep={#1}{\g_semantex_double_bullet}}, - {deg*withothersep}{degwithothersep={#1}{\g_semantex_bullet}}, - {deg**withothersep}{degwithothersep={#1}{\g_semantex_double_bullet}}, - {d*withothersep}{dwithothersep={#1}{\g_semantex_bullet}}, - {d**withothersep}{dwithothersep={#1}{\g_semantex_double_bullet}}, - {index*withothersep}{indexwithothersep={#1}{\g_semantex_bullet}}, - {index**withothersep}{indexwithothersep={#1}{\g_semantex_double_bullet}}, - {i*withothersep}{iwithothersep={#1}{\g_semantex_bullet}}, - {i**withothersep}{iwithothersep={#1}{\g_semantex_double_bullet}}, - {upper*withothersep}{upperwithothersep={#1}{\g_semantex_bullet}}, - {upper**withothersep}{upperwithothersep={#1}{\g_semantex_double_bullet}}, - {lower*withothersep}{lowerwithothersep={#1}{\g_semantex_bullet}}, - {lower**withothersep}{lowerwithothersep={#1}{\g_semantex_double_bullet}}, - {upperleft*withothersep}{upperleftwithothersep={#1}{\g_semantex_bullet}}, - {upperleft**withothersep}{upperleftwithothersep={#1}{\g_semantex_double_bullet}}, - {lowerleft*withothersep}{lowerleftwithothersep={#1}{\g_semantex_bullet}}, - {lowerleft**withothersep}{lowerleftwithothersep={#1}{\g_semantex_double_bullet}}, - {sarg}{argwithkeyval={s={#1}}}, - {carg}{argwithkeyval={c={#1}}}, - {argwithothersep}{argwithkeyval={othersep={#1}}}, - {argdots}{argwithkeyval={...}}, - {arg...}{argwithkeyval={...}}, - {cargdots}{argwithkeyval={cdots=}}, - {carg...}{argwithkeyval={cdots=}}, - {argdotswithothersep}{argwithkeyval={dotswithothersep={#1}}}, - {arg...withothersep}{argwithkeyval={dotswithothersep={#1}}}, - {argdots}{argwithkeyval={-}}, - {arg-}{argwithkeyval={-}}, - {cargslot}{argwithkeyval={cslot=}}, - {carg-}{argwithkeyval={cslot=}}, - {argslotwithothersep}{argwithkeyval={slotwithothersep={#1}}}, - {arg-withothersep}{argwithkeyval={slotwithothersep={#1}}}, + definekeys[1]={ + {setargkeys}{ execute={ \semantex_arg_keys_set:nn { ##1 } { #1 } } }, + {argkeysset}{ execute={ \semantex_arg_keys_set:nn { ##1 } { #1 } } }, + {setargkeysx}{ execute={ \semantex_arg_keys_set_x:nn { ##1 } { #1 } } }, + {argkeyssetx}{ execute={ \semantex_arg_keys_set_x:nn { ##1 } { #1 } } }, + {setargsinglekeys}{ execute={ \semantex_arg_singlekeys_set:nn { ##1 } { #1 } } }, + {argsinglekeysset}{ execute={ \semantex_arg_singlekeys_set:nn { ##1 } { #1 } } }, + {setargsinglekeysx}{ execute={ \semantex_arg_singlekeys_set_x:nn { ##1 } { #1 } } }, + {argsinglekeyssetx}{ execute={ \semantex_arg_singlekeys_set_x:nn { ##1 } { #1 } } }, + {setoneargsinglekey}{ execute={ \semantex_arg_singlekey:nn { ##1 } { #1 } } }, + {oneargsinglekeyset}{ execute={ \semantex_arg_singlekey:nn { ##1 } { #1 } } }, + {setoneargsinglekeyx}{ execute={ \semantex_arg_singlekey_x:nn { ##1 } { #1 } } }, + {oneargsinglekeysetx}{ execute={ \semantex_arg_singlekey_x:nn { ##1 } { #1 } } }, + {setargwithoutkeyval}{ execute={ \semantex_arg_without_keyval:nn { ##1 } { #1 } } }, + {argwithoutkeyvalset}{ execute={ \semantex_arg_without_keyval:nn { ##1 } { #1 } } }, + {setargwithoutkeyvalx}{ execute={ \semantex_arg_without_keyval:nx { ##1 } { #1 } } }, + {argwithoutkeyvalsetx}{ execute={ \semantex_arg_without_keyval:nx { ##1 } { #1 } } }, + {prearg}{ execute={ \semantex_data_tl_put_left:nnn { ##1 } { prearg } { #1 } } }, + {postarg}{ execute={ \semantex_data_tl_put_left:nnn { ##1 } { postarg } { #1 } } }, + {setargsep}{ execute={ \semantex_data_tl_set:nnn { ##1 } { argsep } { #1 } } }, + {setargslot}{ execute={ \semantex_data_tl_set:nnn { ##1 } { argslot } { #1 } } }, + {setargdots}{ execute={ \semantex_data_tl_set:nnn { ##1 } { argdots } { #1 } } }, {argkeyval}{ - ifeqTF={#1}{true} + strifeqTF={#1}{true} { - valuekeys={ - {arg}{argwithkeyval={####1}}, + definekeys[1]={ + {arg}{execute={ \semantex_arg_keys_set:nn { ########1 } { ####1 } }}, }, } { - ifeqTF={#1}{false} + strifeqTF={#1}{false} { - valuekeys={ - {arg}{argwithoutkeyval={####1}}, + definekeys[1]={ + {arg}{ execute={ \semantex_arg_without_keyval:nn { ########1 } { ####1 } } }, }, } { - ifeqTF={#1}{singlekeys} + strifeqTF={#1}{singlekeys} { - valuekeys={ - {arg}{argwithsinglekeys={####1}}, + definekeys[1]={ + {arg}{ execute={ \semantex_arg_singlekeys_set:nn { ########1 } { ####1 } } }, }, } { - ifeqTF={#1}{onesinglekey} + strifeqTF={#1}{onesinglekey} { - valuekeys={ - {arg}{argwithonesinglekey={####1}}, + definekeys[1]={ + {arg}{ execute={ \semantex_arg_singlekey:nn { ########1 } { ####1 } } }, }, } { @@ -6399,29 +5684,1436 @@ }, }, }, + {argposition}{ + strifeqTF={#1}{left} + { + boolsettrue={leftargument}, + } + { + strifeqTF={#1}{right} + { + boolsetfalse={leftargument}, + } + { + ERRORkeyvaluenotfound={argposition}{#1}, + }, + }, + }, + {nextargwithsep}{ + strifeqTF={#1}{true} + { + boolsettrue={nextargwithsep}, + } + { + strifeqTF={#1}{false} + { + boolsetfalse={nextargwithsep}, + } + { + ERRORkeyvaluenotfound={nextargwithsep}{#1}, + }, + }, + }, + {sarg}{setargkeys={s={#1}}}, + {carg}{setargkeys={c={#1}}}, + {argdotswithothersep}{setargkeys={dotswithothersep={#1}}}, + {arg...withothersep}{setargkeys={dotswithothersep={#1}}}, + {argslotwithothersep}{setargkeys={slotwithothersep={#1}}}, + {arg-withothersep}{setargkeys={slotwithothersep={#1}}}, + }, + definekeys[2]={ + {argwithothersep}{setargkeys={othersep={#1}{#2}}}, + }, + setargsep={,}, + setargslot={ {-} }, + setargdots={ \dots }, + % Parentheses: + definekeys={ + {par}{usepar=true}, + {neverpar}{usepar=never}, + {nopar}{usepar=false}, + }, + definekeys[1]={ + {par}{ + execute={ + \semantex_data_tl_set:nnn { ##1 } { parsize } { #1 } + \semantex_data_bool_set_true:nn { ##1 } { par } + }, + }, + {parsize}{ + execute={ \semantex_data_tl_set:nnn { ##1 } { parsize } { #1 } }, + }, + {leftpar}{ + execute={ \semantex_data_tl_set:nnn { ##1 } { leftpar } { #1 } }, + }, + {rightpar}{ + execute={ \semantex_data_tl_set:nnn { ##1 } { rightpar } { #1 } }, + }, + {usepar}{ + strifeqTF={#1}{true} + { + boolsettrue={par}, + boolsetfalse={flexpar}, + } + { + strifeqTF={#1}{false} + { + boolsetfalse={par}, + boolsettrue={flexpar}, + } + { + strifeqTF={#1}{never} + { + boolsetfalse={par}, + boolsetfalse={flexpar}, + } + { + ERRORkeyvaluenotfound={usepar}{#1}, + }, + }, + }, + }, + }, + leftpar=(, + rightpar=), + par=normal, + % Accents, primes, bullets, etc.: + definekeys={ + {smash}{command=\smash}, + {prime}{upper={\prime}}, + {'}{prime}, + {''}{prime,prime}, + {'''}{prime,prime,prime}, + }, + % Upper indices: + dataprovide=upper, + boolprovide=nextupperwithsep, + intprovide=numberofupperindices, + dataprovide=preupper, + dataprovide=postupper, + definekeys={ + {upperslot}{ setkeysx={ upper=\semantex_data_tl_get_exp_not:nn { ##1 } { upperslot } } }, + {upper-}{upperslot}, + {supperslot}{ setkeysx={ supper=\semantex_data_tl_get_exp_not:nn { ##1 } { upperslot } } }, + {supper-}{supperslot}, + {cupperslot}{ setkeysx={ cupper=\semantex_data_tl_get_exp_not:nn { ##1 } { upperslot } } }, + {cupper-}{cupperslot}, + {upperdots}{ setkeysx={ upper=\semantex_data_tl_get_exp_not:nn { ##1 } { upperdots } } }, + {upper...}{upperdots}, + {supperdots}{ setkeysx={ supper=\semantex_data_tl_get_exp_not:nn { ##1 } { upperdots } } }, + {supper...}{supperdots}, + {cupperdots}{ setkeysx={ cupper=\semantex_data_tl_get_exp_not:nn { ##1 } { upperdots } } }, + {cupper...}{cupperdots}, + {clearupper}{ + execute={ + \semantex_data_tl_clear:nn { ##1 } { upper } + \semantex_data_bool_set_false:nn { ##1 } { nextupperwithsep } + \semantex_data_int_clear:nn { ##1 } { numberofupperindices } + }, + }, + {clearpreupper}{ + execute={ \semantex_data_tl_clear:nn { ##1 } { preupper } }, + }, + {clearpostupper}{ + execute={ \semantex_data_tl_clear:nn { ##1 } { postupper } }, + }, + {upper*}{upper=\SemantexBullet}, + {upper**}{upper=\SemantexDoubleBullet}, + {supper*}{supper=\SemantexBullet}, + {supper**}{supper=\SemantexDoubleBullet}, + {cupper*}{cupper=\SemantexBullet}, + {cupper**}{cupper=\SemantexDoubleBullet}, + }, + definekeys[1]={ + {upper}{ + execute={ + \tl_if_blank:nF { #1 } + { + \semantex_data_tl_put_right:nnn { ##1 } { upper } { #1 } + \semantex_data_bool_set_true:nn { ##1 } { nextupperwithsep } + \semantex_data_int_incr:nn { ##1 } { numberofupperindices } + } + }, + }, + {supper}{ + execute={ + \tl_if_blank:nF { #1 } + { + \semantex_data_bool_get:nnTF { ##1 } { nextupperwithsep } + { + \semantex_data_tl_put_right:nnx { ##1 } { upper } + { \semantex_data_tl_get_exp_not:nn { ##1 } { uppersep } } + \semantex_data_tl_put_right:nnn { ##1 } { upper } { #1 } + } + { + \semantex_data_tl_put_right:nnn { ##1 } { upper } { #1 } + } + \semantex_data_bool_set_true:nn { ##1 } { nextupperwithsep } + \semantex_data_int_incr:nn { ##1 } { numberofupperindices } + } + }, + }, + {cupper}{ + execute={ + \tl_if_blank:nF{#1} + { + \semantex_data_bool_get:nnTF { ##1 } { nextupperwithsep } + { + \semantex_data_tl_put_right:nnn { ##1 } { upper } { , #1 } + } + { + \semantex_data_tl_put_right:nnn { ##1 } { upper } { #1 } + } + \semantex_data_bool_set_true:nn { ##1 } { nextupperwithsep } + \semantex_data_int_incr:nn { ##1 } { numberofupperindices } + } + } + }, + {preupper}{ + execute={ + \semantex_data_tl_put_left:nnn { ##1 } { preupper } { #1 } + }, + }, + {postupper}{ + execute={ + \semantex_data_tl_put_right:nnn { ##1 } { postupper } { #1 } + }, + }, + {upperputleft}{ + execute={ + \tl_if_blank:nF { #1 } + { + \semantex_data_tl_put_left:nnn { ##1 } { upper } { #1 } + \semantex_data_bool_set_true:nn { ##1 } { nextupperwithsep } + \semantex_data_int_incr:nn { ##1 } { numberofupperindices } + } + }, + }, + {setupperslot}{ + execute={ \semantex_data_tl_set:nnn { ##1 } { upperslot } { #1 } }, + }, + {upperslotwithothersep}{ + execute={ + \semantex_valuekey:nnx { ##1 } { upperwithothersep } + { + { \exp_not:n { #1 } } + { \semantex_data_tl_get_exp_not:nn { ##1 } { upperslot } } + } + }, + }, + {upper-withothersep}{ + execute={ + \semantex_valuekey:nnx { ##1 } { upperwithothersep } + { + { \exp_not:n { #1 } } + { \semantex_data_tl_get_exp_not:nn { ##1 } { upperslot } } + } + }, + }, + {setupperdots}{ + execute={ \semantex_data_tl_set:nnn { ##1 } { upperdots } { #1 } }, + }, + {upperdotswithothersep}{ + execute={ + \semantex_valuekey:nnx { ##1 } { upperwithothersep } + { + { \exp_not:n { #1 } } + { \semantex_data_tl_get_exp_not:nn { ##1 } { upperdots } } + } + }, + }, + {upper...withothersep}{ + execute={ + \semantex_valuekey:nnx { ##1 } { upperwithothersep } + { + { \exp_not:n { #1 } } + { \semantex_data_tl_get_exp_not:nn { ##1 } { upperdots } } + } + }, + }, + {upper*withothersep}{upperwithothersep={#1}{\SemantexBullet}}, + {upper**withothersep}{upperwithothersep={#1}{\SemantexDoubleBullet}}, + {setuppersep}{ + execute={ \semantex_data_tl_set:nnn { ##1 } { uppersep } { #1 } }, + }, + {nextupperwithsep}{ + strifeqTF={#1}{false} + { + boolsetfalse={nextupperwithsep}, + } + { + strifeqTF={#1}{true} + { + boolsettrue={nextupperwithsep}, + } + { + ERRORkeyvaluenotfound={nextupperwithsep}{#1}, + }, + }, + }, + }, + definekeys[2]={ + {upperwithothersep}{ + execute={ + \semantex_data_bool_get:nnTF { ##1 } { nextupperwithsep } + { \semantex_data_tl_put_right:nnn { ##1 } { upper } { #1 #2 } } + { \semantex_data_tl_put_right:nnn { ##1 } { upper } { #2 } } + \semantex_data_bool_set_true:nn { ##1 } { nextupperwithsep } + \semantex_data_int_incr:nn { ##1 } { numberofupperindices } + }, + }, }, - argvaluekeys={ + setuppersep={ , }, + setupperdots={ \dots }, + setupperslot={ {-} }, + % Lower indices: + dataprovide=lower, + boolprovide=nextlowerwithsep, + intprovide=numberoflowerindices, + dataprovide=prelower, + dataprovide=postlower, + definekeys={ + {lowerslot}{ setkeysx={ lower=\semantex_data_tl_get_exp_not:nn { ##1 } { lowerslot } } }, + {lower-}{lowerslot}, + {slowerslot}{ setkeysx={ slower=\semantex_data_tl_get_exp_not:nn { ##1 } { lowerslot } } }, + {slower-}{slowerslot}, + {clowerslot}{ setkeysx={ clower=\semantex_data_tl_get_exp_not:nn { ##1 } { lowerslot } } }, + {clower-}{clowerslot}, + {lowerdots}{ setkeysx={ lower=\semantex_data_tl_get_exp_not:nn { ##1 } { lowerdots } } }, + {lower...}{lowerdots}, + {slowerdots}{ setkeysx={ slower=\semantex_data_tl_get_exp_not:nn { ##1 } { lowerdots } } }, + {slower...}{slowerdots}, + {clowerdots}{ setkeysx={ clower=\semantex_data_tl_get_exp_not:nn { ##1 } { lowerdots } } }, + {clower...}{clowerdots}, + {clearlower}{ + execute={ + \semantex_data_tl_clear:nn { ##1 } { lower } + \semantex_data_bool_set_false:nn { ##1 } { nextlowerwithsep } + \semantex_data_int_clear:nn { ##1 } { numberoflowerindices } + }, + }, + {clearprelower}{ + execute={ \semantex_data_tl_clear:nn { ##1 } { prelower } }, + }, + {clearpostlower}{ + execute={ \semantex_data_tl_clear:nn { ##1 } { postlower } }, + }, + {lower*}{lower=\SemantexBullet}, + {lower**}{lower=\SemantexDoubleBullet}, + {slower*}{slower=\SemantexBullet}, + {slower**}{slower=\SemantexDoubleBullet}, + {clower*}{clower=\SemantexBullet}, + {clower**}{clower=\SemantexDoubleBullet}, + }, + definekeys[1]={ + {lower}{ + execute={ + \tl_if_blank:nF{#1}{ + \semantex_data_tl_put_right:nnn { ##1 } { lower } { #1 } + \semantex_data_bool_set_true:nn { ##1 } { nextlowerwithsep } + \semantex_data_int_incr:nn { ##1 } { numberoflowerindices } + } + }, + }, + {slower}{ + execute={ + \tl_if_blank:nF { #1 } + { + \semantex_data_bool_get:nnTF { ##1 } { nextlowerwithsep } + { + \semantex_data_tl_put_right:nnx { ##1 } { lower } + { \semantex_data_tl_get_exp_not:nn { ##1 } { lowersep } } + \semantex_data_tl_put_right:nnn { ##1 } { lower } { #1 } + } + { + \semantex_data_tl_put_right:nnn { ##1 } { lower } { #1 } + } + \semantex_data_bool_set_true:nn { ##1 } { nextlowerwithsep } + \semantex_data_int_incr:nn { ##1 } { numberoflowerindices } + } + }, + }, + {clower}{ + execute={ + \tl_if_blank:nF{#1} + { + \semantex_data_bool_get:nnTF { ##1 } { nextlowerwithsep } + { + \semantex_data_tl_put_right:nnn { ##1 } { lower } { , #1 } + } + { + \semantex_data_tl_put_right:nnn { ##1 } { lower } { #1 } + } + \semantex_data_bool_set_true:nn { ##1 } { nextlowerwithsep } + \semantex_data_int_incr:nn { ##1 } { numberoflowerindices } + } + } + }, + {prelower}{ + execute={ + \semantex_data_tl_put_left:nnn { ##1 } { prelower } { #1 } + }, + }, + {postlower}{ + execute={ + \semantex_data_tl_put_right:nnn { ##1 } { postlower } { #1 } + }, + }, + {lowerputleft}{ + execute={ + \tl_if_blank:nF { #1 } + { + \semantex_data_tl_put_left:nnn { ##1 } { lower } { #1 } + \semantex_data_bool_set_true:nn { ##1 } { nextlowerwithsep } + \semantex_data_int_incr:nn { ##1 } { numberoflowerindices } + } + }, + }, + {setlowerslot}{ + execute={ \semantex_data_tl_set:nnn { ##1 } { lowerslot } { #1 } }, + }, + {lowerslotwithothersep}{ + execute={ + \semantex_valuekey:nnx { ##1 } { lowerwithothersep } + { + { \exp_not:n { #1 } } + { \semantex_data_tl_get_exp_not:nn { ##1 } { lowerslot } } + } + }, + }, + {lower-withothersep}{ + execute={ + \semantex_valuekey:nnx { ##1 } { lowerwithothersep } + { + { \exp_not:n { #1 } } + { \semantex_data_tl_get_exp_not:nn { ##1 } { lowerslot } } + } + }, + }, + {setlowerdots}{ + execute={ \semantex_data_tl_set:nnn { ##1 } { lowerdots } { #1 } }, + }, + {lowerdotswithothersep}{ + execute={ + \semantex_valuekey:nnx { ##1 } { lowerwithothersep } + { + { \exp_not:n { #1 } } + { \semantex_data_tl_get_exp_not:nn { ##1 } { lowerdots } } + } + }, + }, + {lower...withothersep}{ + execute={ + \semantex_valuekey:nnx { ##1 } { lowerwithothersep } + { + { \exp_not:n { #1 } } + { \semantex_data_tl_get_exp_not:nn { ##1 } { lowerdots } } + } + }, + }, + {lower*withothersep}{lowerwithothersep={#1}{\SemantexBullet}}, + {lower**withothersep}{lowerwithothersep={#1}{\SemantexDoubleBullet}}, + {setlowersep}{ + execute={ \semantex_data_tl_set:nnn { ##1 } { lowersep } { #1 } }, + }, + {nextlowerwithsep}{ + strifeqTF={#1}{false} + { + boolsetfalse={nextlowerwithsep}, + } + { + strifeqTF={#1}{true} + { + boolsettrue={nextlowerwithsep}, + } + { + ERRORkeyvaluenotfound={nextlowerwithsep}{#1}, + }, + }, + }, + }, + definekeys[2]={ + {lowerwithothersep}{ + execute={ + \semantex_data_bool_get:nnTF { ##1 } { nextlowerwithsep } + { \semantex_data_tl_put_right:nnn { ##1 } { lower } { #1 #2 } } + { \semantex_data_tl_put_right:nnn { ##1 } { lower } { #2 } } + \semantex_data_bool_set_true:nn { ##1 } { nextlowerwithsep } + \semantex_data_int_incr:nn { ##1 } { numberoflowerindices } + }, + }, + }, + setlowersep={ , }, + setlowerdots={ \dots }, + setlowerslot={ {-} }, + % Upper left indices: + dataprovide=upperleft, + intprovide=nextupperleftwithsep, + intprovide=numberofupperleftindices, + dataprovide=preupperleft, + dataprovide=postupperleft, + definekeys={ + {upperleftslot}{ setkeysx={ upperleft=\semantex_data_tl_get_exp_not:nn { ##1 } { upperleftslot } } }, + {upperleft-}{upperleftslot}, + {supperleftslot}{ setkeysx={ supperleft=\semantex_data_tl_get_exp_not:nn { ##1 } { upperleftslot } } }, + {supperleft-}{supperleftslot}, + {cupperleftslot}{ setkeysx={ cupperleft=\semantex_data_tl_get_exp_not:nn { ##1 } { upperleftslot } } }, + {cupperleft-}{cupperleftslot}, + {upperleftdots}{ setkeysx={ upperleft=\semantex_data_tl_get_exp_not:nn { ##1 } { upperleftdots } } }, + {upperleft...}{upperleftdots}, + {supperleftdots}{ setkeysx={ supperleft=\semantex_data_tl_get_exp_not:nn { ##1 } { upperleftdots } } }, + {supperleft...}{supperleftdots}, + {cupperleftdots}{ setkeysx={ cupperleft=\semantex_data_tl_get_exp_not:nn { ##1 } { upperleftdots } } }, + {cupperleft...}{cupperleftdots}, + {clearupperleft}{ + execute={ + \semantex_data_tl_clear:nn { ##1 } { upperleft } + \semantex_data_bool_set_false:nn { ##1 } { nextupperleftwithsep } + \semantex_data_int_clear:nn { ##1 } { numberofupperleftindices } + }, + }, + {clearpreupperleft}{ + execute={ \semantex_data_tl_clear:nn { ##1 } { preupperleft } }, + }, + {clearpostupperleft}{ + execute={ \semantex_data_tl_clear:nn { ##1 } { postupperleft } }, + }, + {upperleft*}{upperleft=\SemantexBullet}, + {upperleft**}{upperleft=\SemantexDoubleBullet}, + {supperleft*}{supperleft=\SemantexBullet}, + {supperleft**}{supperleft=\SemantexDoubleBullet}, + {cupperleft*}{cupperleft=\SemantexBullet}, + {cupperleft**}{cupperleft=\SemantexDoubleBullet}, + }, + definekeys[1]={ + {upperleft}{ + execute={ + \tl_if_blank:nF{#1}{ + \semantex_data_tl_put_left:nnn { ##1 } { upperleft } { #1 } + \semantex_data_bool_set_true:nn { ##1 } { nextupperleftwithsep } + \semantex_data_int_incr:nn { ##1 } { numberofupperleftindices } + } + }, + }, + {supperleft}{ + execute={ + \tl_if_blank:nF { #1 } + { + \semantex_data_bool_get:nnTF { ##1 } { nextupperleftwithsep } + { + \semantex_data_tl_put_left:nnx { ##1 } { upperleft } + { \semantex_data_tl_get_exp_not:nn { ##1 } { upperleftsep } } + \semantex_data_tl_put_left:nnn { ##1 } { upperleft } { #1 } + } + { + \semantex_data_tl_put_left:nnn { ##1 } { upperleft } { #1 } + } + \semantex_data_bool_set_true:nn { ##1 } { nextupperleftwithsep } + \semantex_data_int_incr:nn { ##1 } { numberofupperleftindices } + } + }, + }, + {cupperleft}{ + execute={ + \tl_if_blank:nF{#1} + { + \semantex_data_bool_get:nnTF { ##1 } { nextupperleftwithsep } + { + \semantex_data_tl_put_left:nnn { ##1 } { upperleft } { , #1 } + } + { + \semantex_data_tl_put_left:nnn { ##1 } { upperleft } { #1 } + } + \semantex_data_bool_set_true:nn { ##1 } { nextupperleftwithsep } + \semantex_data_int_incr:nn { ##1 } { numberofupperleftindices } + } + } + }, + {preupperleft}{ + execute={ + \semantex_data_tl_put_left:nnn { ##1 } { preupperleft } { #1 } + }, + }, + {postupperleft}{ + execute={ + \semantex_data_tl_put_right:nnn { ##1 } { postupperleft } { #1 } + }, + }, + {upperleftputright}{ + execute={ + \tl_if_blank:nF { #1 } + { + \semantex_data_tl_put_right:nnn { ##1 } { upperleft } { #1 } + \semantex_data_bool_set_true:nn { ##1 } { nextupperleftwithsep } + \semantex_data_int_incr:nn { ##1 } { numberofupperleftindices } + } + }, + }, + {setupperleftslot}{ + execute={ \semantex_data_tl_set:nnn { ##1 } { upperleftslot } { #1 } }, + }, + {upperleftslotwithothersep}{ + execute={ + \semantex_valuekey:nnx { ##1 } { upperleftwithothersep } + { + { \exp_not:n { #1 } } + { \semantex_data_tl_get_exp_not:nn { ##1 } { upperleftslot } } + } + }, + }, + {upperleft-withothersep}{ + execute={ + \semantex_valuekey:nnx { ##1 } { upperleftwithothersep } + { + { \exp_not:n { #1 } } + { \semantex_data_tl_get_exp_not:nn { ##1 } { upperleftslot } } + } + }, + }, + {setupperleftdots}{ + execute={ \semantex_data_tl_set:nnn { ##1 } { upperleftdots } { #1 } }, + }, + {upperleftdotswithothersep}{ + execute={ + \semantex_valuekey:nnx { upperleftwithothersep } + { + { \exp_not:n { #1 } } + { \semantex_data_tl_get_exp_not:nn { ##1 } { upperleftdots } } + } + }, + }, + {upperleft...withothersep}{ + execute={ + \semantex_valuekey:nnx { upperleftwithothersep } + { + { \exp_not:n { #1 } } + { \semantex_data_tl_get_exp_not:nn { ##1 } { upperleftdots } } + } + }, + }, + {upperleft*withothersep}{upperleftwithothersep={#1}{\SemantexBullet}}, + {upperleft**withothersep}{upperleftwithothersep={#1}{\SemantexDoubleBullet}}, + {setupperleftsep}{ + execute={ \semantex_data_tl_set:nnn { ##1 } { upperleftsep } { #1 } }, + }, + {nextupperleftwithsep}{ + strifeqTF={#1}{false} + { + boolsetfalse={nextupperleftwithsep}, + } + { + strifeqTF={#1}{true} + { + boolsettrue={nextupperleftwithsep}, + } + { + ERRORkeyvaluenotfound={nextupperleftwithsep}{#1}, + }, + }, + }, + }, + definekeys[2]={ + {upperleftwithothersep}{ + execute={ + \semantex_data_bool_get:nnTF { ##1 } { nextupperleftwithsep } + { \semantex_data_tl_put_left:nnn { ##1 } { upperleft } { #2 #1 } } + { \semantex_data_tl_put_left:nnn { ##1 } { upperleft } { #2 } } + \semantex_data_bool_set_true:nn { ##1 } { nextupperleftwithsep } + \semantex_data_int_incr:nn { ##1 } { numberofupperleftindices } + }, + }, + }, + setupperleftsep={ , }, + setupperleftdots={ \dots }, + setupperleftslot={ {-} }, + % Lower left indices: + dataprovide=lowerleft, + boolprovide=nextlowerleftwithsep, + intprovide=numberoflowerleftindices, + dataprovide=prelowerleft, + dataprovide=postlowerleft, + definekeys={ + {lowerleftslot}{ setkeysx={ lowerleft=\semantex_data_tl_get_exp_not:nn { ##1 } { lowerleftslot } } }, + {lowerleft-}{lowerleftslot}, + {slowerleftslot}{ setkeysx={ slowerleft=\semantex_data_tl_get_exp_not:nn { ##1 } { lowerleftslot } } }, + {slowerleft-}{slowerleftslot}, + {clowerleftslot}{ setkeysx={ clowerleft=\semantex_data_tl_get_exp_not:nn { ##1 } { lowerleftslot } } }, + {clowerleft-}{clowerleftslot}, + {lowerleftdots}{ setkeysx={ lowerleft=\semantex_data_tl_get_exp_not:nn { ##1 } { lowerleftdots } } }, + {lowerleft...}{lowerleftdots}, + {slowerleftdots}{ setkeysx={ slowerleft=\semantex_data_tl_get_exp_not:nn { ##1 } { lowerleftdots } } }, + {slowerleft...}{slowerleftdots}, + {clowerleftdots}{ setkeysx={ clowerleft=\semantex_data_tl_get_exp_not:nn { ##1 } { lowerleftdots } } }, + {clowerleft...}{clowerleftdots}, + {clearlowerleft}{ + execute={ + \semantex_data_tl_clear:nn { ##1 } { lowerleft } + \semantex_data_bool_set_false:nn { ##1 } { nextlowerleftwithsep } + \semantex_data_int_clear:nn { ##1 } { numberoflowerleftindices } + }, + }, + {clearprelowerleft}{ + execute={ \semantex_data_tl_clear:nn { ##1 } { prelowerleft } }, + }, + {clearpostlowerleft}{ + execute={ \semantex_data_tl_clear:nn { ##1 } { postlowerleft } }, + }, + {lowerleft*}{lowerleft=\SemantexBullet}, + {lowerleft**}{lowerleft=\SemantexDoubleBullet}, + {slowerleft*}{slowerleft=\SemantexBullet}, + {slowerleft**}{slowerleft=\SemantexDoubleBullet}, + {clowerleft*}{clowerleft=\SemantexBullet}, + {clowerleft**}{clowerleft=\SemantexDoubleBullet}, + }, + definekeys[1]={ + {lowerleft}{ + execute={ + \tl_if_blank:nF{#1}{ + \semantex_data_tl_put_left:nnn { ##1 } { lowerleft } { #1 } + \semantex_data_bool_set_true:nn { ##1 } { nextlowerleftwithsep } + \semantex_data_int_incr:nn { ##1 } { numberoflowerleftindices } + } + }, + }, + {slowerleft}{ + execute={ + \tl_if_blank:nF { #1 } + { + \semantex_data_bool_get:nnTF { ##1 } { nextlowerleftwithsep } + { + \semantex_data_tl_put_left:nnx { ##1 } { lowerleft } + { \semantex_data_tl_get_exp_not:nn { ##1 } { lowerleftsep } } + \semantex_data_tl_put_left:nnn { ##1 } { lowerleft } { #1 } + } + { + \semantex_data_tl_put_left:nnn { ##1 } { lowerleft } { #1 } + } + \semantex_data_bool_set_true:nn { ##1 } { nextlowerleftwithsep } + \semantex_data_int_incr:nn { ##1 } { numberoflowerleftindices } + } + }, + }, + {clowerleft}{ + execute={ + \tl_if_blank:nF{#1} + { + \semantex_data_bool_get:nnTF { ##1 } { nextlowerleftwithsep } + { + \semantex_data_tl_put_left:nnn { ##1 } { lowerleft } { , #1 } + } + { + \semantex_data_tl_put_left:nnn { ##1 } { lowerleft } { #1 } + } + \semantex_data_bool_set_true:nn { ##1 } { nextlowerleftwithsep } + \semantex_data_int_incr:nn { ##1 } { numberoflowerleftindices } + } + } + }, + {prelowerleft}{ + execute={ + \semantex_data_tl_put_left:nnn { ##1 } { prelowerleft } { #1 } + }, + }, + {postlowerleft}{ + execute={ + \semantex_data_tl_put_right:nnn { ##1 } { postlowerleft } { #1 } + }, + }, + {lowerleftputright}{ + execute={ + \tl_if_blank:nF { #1 } + { + \semantex_data_tl_put_right:nnn { ##1 } { lowerleft } { #1 } + \semantex_data_bool_set_true:nn { ##1 } { nextlowerleftwithsep } + \semantex_data_int_incr:nn { ##1 } { numberoflowerleftindices } + } + }, + }, + {setlowerleftslot}{ + execute={ \semantex_data_tl_set:nnn { ##1 } { lowerleftslot } { #1 } }, + }, + {lowerleftslotwithothersep}{ + execute={ + \semantex_valuekey:nnx { ##1 } { lowerleftwithothersep } + { + { \exp_not:n { #1 } } + { \semantex_data_tl_get_exp_not:nn { ##1 } { lowerleftslot } }, + } + }, + }, + {lowerleft-withothersep}{ + execute={ + \semantex_valuekey:nnx { ##1 } { lowerleftwithothersep } + { + { \exp_not:n { #1 } } + { \semantex_data_tl_get_exp_not:nn { ##1 } { lowerleftslot } }, + } + }, + }, + {setlowerleftdots}{ + execute={ \semantex_data_tl_set:nnn { ##1 } { lowerleftdots } { #1 } }, + }, + {lowerleftdotswithothersep}{ + execute={ + \semantex_valuekey:nnx { ##1 } { lowerleftwithothersep } + { + { \exp_not:n { #1 } } + { \semantex_data_tl_get_exp_not:nn { ##1 } { lowerleftdots } } + } + }, + }, + {lowerleft...withothersep}{ + execute={ + \semantex_valuekey:nnx { ##1 } { lowerleftwithothersep } + { + { \exp_not:n { #1 } } + { \semantex_data_tl_get_exp_not:nn { ##1 } { lowerleftdots } } + } + }, + }, + {lowerleft*withothersep}{lowerleftwithothersep={#1}{\SemantexBullet}}, + {lowerleft**withothersep}{lowerleftwithothersep={#1}{\SemantexDoubleBullet}}, + {setlowerleftsep}{ + execute={ \semantex_data_tl_set:nnn { ##1 } { lowerleftsep } { #1 } }, + }, + {nextlowerleftwithsep}{ + strifeqTF={#1}{false} + { + boolsetfalse={nextlowerleftwithsep}, + } + { + strifeqTF={#1}{true} + { + boolsettrue={nextlowerleftwithsep}, + } + { + ERRORkeyvaluenotfound={nextlowerleftwithsep}{#1}, + }, + }, + }, + }, + definekeys[2]={ + {lowerleftwithothersep}{ + execute={ + \semantex_data_bool_get:nnTF { ##1 } { nextlowerleftwithsep } + { \semantex_data_tl_put_left:nnn { ##1 } { lowerleft } { #2 #1 } } + { \semantex_data_tl_put_left:nnn { ##1 } { lowerleft } { #2 } } + \semantex_data_bool_set_true:nn { ##1 } { nextlowerleftwithsep } + \semantex_data_int_incr:nn { ##1 } { numberoflowerleftindices } + }, + }, + }, + setlowerleftsep={ , }, + setlowerleftdots={ \dots }, + setlowerleftslot={ {-} }, + % The "d" index: + definekeys={ + {dslot}{ + boolifTF={uppergrading} + { upperslot } + { lowerslot }, + }, + {d-}{dslot}, + {sdslot}{ + boolifTF={uppergrading} + { supperslot } + { slowerslot }, + }, + {sd-}{sdslot}, + {cdslot}{ + boolifTF={uppergrading} + { cupperslot } + { clowerslot }, + }, + {cd-}{cdslot}, + {ddots}{ + boolifTF={uppergrading} + { upperdots } + { lowerdots }, + }, + {d...}{ddots}, + {sddots}{ + boolifTF={uppergrading} + { supperdots } + { slowerdots }, + }, + {sd...}{sddots}, + {cddots}{ + boolifTF={uppergrading} + { cupperdots } + { clowerdots }, + }, + {cd...}{cddots}, + {cleard}{ + boolifTF={uppergrading} + { clearupper } + { clearlower }, + }, + {clearpred}{ + boolifTF={uppergrading} + { clearpreupper } + { clearprelower }, + }, + {clearpostd}{ + boolifTF={uppergrading} + { clearpostupper } + { clearpostlower }, + }, + {d*}{ + boolifTF={uppergrading} + { upper* } + { lower* }, + }, + {d**}{ + boolifTF={uppergrading} + { upper** } + { lower** }, + }, + {sd*}{ + boolifTF={uppergrading} + { supper* } + { slower* }, + }, + {sd**}{ + boolifTF={uppergrading} + { supper** } + { slower** }, + }, + {cd*}{ + boolifTF={uppergrading} + { cupper* } + { clower* }, + }, + {cd**}{ + boolifTF={uppergrading} + { cupper** } + { clower** }, + }, + }, + definekeys[1]={ + {d}{ + execute={ + \semantex_data_bool_get:nnTF { ##1 } { uppergrading } + { \semantex_valuekey:nnn { ##1 } { upper } { #1 } } + { \semantex_valuekey:nnn { ##1 } { lower } { #1 } } + }, + }, + {sd}{ + execute={ + \semantex_data_bool_get:nnTF { ##1 } { uppergrading } + { \semantex_valuekey:nnn { ##1 } { supper } { #1 } } + { \semantex_valuekey:nnn { ##1 } { slower } { #1 } } + }, + }, + {cd}{ + execute={ + \semantex_data_bool_get:nnTF { ##1 } { uppergrading } + { \semantex_valuekey:nnn { ##1 } { cupper } { #1 } } + { \semantex_valuekey:nnn { ##1 } { clower } { #1 } } + }, + }, + {pred}{ + boolifTF={uppergrading} + { + preupper={#1}, + } + { + prelower={#1}, + }, + }, + {postd}{ + boolifTF={uppergrading} + { + postupper={#1}, + } + { + postlower={#1}, + }, + }, + {dputleft}{ + boolifTF={uppergrading} + { + upperputleft={#1}, + } + { + lowerputleft={#1}, + }, + }, + {setdslot}{ + boolifTF={uppergrading} + { + setupperslot={#1}, + } + { + setlowerslot={#1}, + } + }, + {dslotwithothersep}{ + boolifTF={uppergrading} + { + upperslotwithothersep={#1}, + } + { + lowerslotwithothersep={#1}, + }, + }, + {d-withothersep}{ + dslotwithothersep={#1}, + }, + {setddots}{ + boolifTF={uppergrading} + { + setupperdots={#1}, + } + { + setlowerdots={#1}, + } + }, + {ddotswithothersep}{ + boolifTF={uppergrading} + { + upperdotswithothersep={#1}, + } + { + lowerdotswithothersep={#1}, + }, + }, + {d...withothersep}{ + ddotswithothersep={#1}, + }, + {d*withothersep}{ + boolifTF={uppergrading} + { upper*withothersep={#1} } + { lower*withothersep={#1} }, + }, + {d**withothersep}{ + boolifTF={uppergrading} + { upper**withothersep={#1} } + { lower**withothersep={#1} }, + }, + {setdsep}{ + boolifTF={uppergrading} + { + setuppersep={#1}, + } + { + setlowersep={#1}, + }, + }, + {nextdwithsep}{ + strifeqTF={#1}{true} + { + boolifTF={uppergrading} + { + nextupperwithsep=true, + } + { + nextlowerwithsep=true, + }, + } + { + strifeqTF={#1}{false} + { + boolifTF={uppergrading} + { + nextupperwithsep=false, + } + { + nextlowerwithsep=false, + }, + } + { + ERRORkeyvaluenotfound={nextdwithothersep}{#1}, + }, + }, + }, + }, + definekeys[2]={ + {dwithothersep}{ + boolifTF={uppergrading} + { + upperwithothersep={#1}{#2}, + } + { + lowerwithothersep={#1}{#2}, + }, + }, + }, + % The "i" index: + definekeys={ + {islot}{ + boolifTF={uppergrading} + { lowerslot } + { upperslot }, + }, + {i-}{islot}, + {sislot}{ + boolifTF={uppergrading} + { slowerslot } + { supperslot }, + }, + {si-}{sislot}, + {cislot}{ + boolifTF={uppergrading} + { clowerslot } + { cupperslot }, + }, + {ci-}{cislot}, + {idots}{ + boolifTF={uppergrading} + { lowerdots } + { upperdots }, + }, + {i...}{idots}, + {sidots}{ + boolifTF={uppergrading} + { slowerdots } + { supperdots }, + }, + {si...}{sidots}, + {cidots}{ + boolifTF={uppergrading} + { clowerdots } + { cupperdots }, + }, + {ci...}{cidots}, + {cleari}{ + boolifTF={uppergrading} + { clearlower } + { clearupper }, + }, + {clearprei}{ + boolifTF={uppergrading} + { clearprelower } + { clearpreupper }, + }, + {clearposti}{ + boolifTF={uppergrading} + { clearpostlower } + { clearpostupper }, + }, + {i*}{ + boolifTF={uppergrading} + { lower* } + { upper* }, + }, + {i**}{ + boolifTF={uppergrading} + { lower** } + { upper** }, + }, + {si*}{ + boolifTF={uppergrading} + { slower* } + { supper* }, + }, + {si**}{ + boolifTF={uppergrading} + { slower** } + { supper** }, + }, + {ci*}{ + boolifTF={uppergrading} + { clower* } + { cupper* }, + }, + {ci**}{ + boolifTF={uppergrading} + { clower** } + { cupper** }, + }, + }, + definekeys[1]={ + {i}{ + execute={ + \semantex_data_bool_get:nnTF { ##1 } { uppergrading } + { \semantex_valuekey:nnn { ##1 } { lower } { #1 } } + { \semantex_valuekey:nnn { ##1 } { upper } { #1 } } + }, + }, + {si}{ + execute={ + \semantex_data_bool_get:nnTF { ##1 } { uppergrading } + { \semantex_valuekey:nnn { ##1 } { slower } { #1 } } + { \semantex_valuekey:nnn { ##1 } { supper } { #1 } } + }, + }, + {ci}{ + execute={ + \semantex_data_bool_get:nnTF { ##1 } { uppergrading } + { \semantex_valuekey:nnn { ##1 } { clower } { #1 } } + { \semantex_valuekey:nnn { ##1 } { cupper } { #1 } } + }, + }, + {prei}{ + boolifTF={uppergrading} + { + prelower={#1}, + } + { + preupper={#1}, + }, + }, + {posti}{ + boolifTF={uppergrading} + { + postlower={#1}, + } + { + postupper={#1}, + }, + }, + {iputleft}{ + boolifTF={uppergrading} + { + lowerputleft={#1}, + }{ + upperputleft={#1}, + }, + }, + {setislot}{ + boolifTF={uppergrading} + { + setlowerslot={#1}, + } + { + setupperslot={#1}, + } + }, + {islotwithothersep}{ + boolifTF={uppergrading} + { + lowerslotwithothersep={#1}, + } + { + upperslotwithothersep={#1}, + }, + }, + {i-withothersep}{ + islotwithothersep={#1}, + }, + {setidots}{ + boolifTF={uppergrading} + { + setlowerdots={#1}, + } + { + setupperdots={#1}, + } + }, + {idotswithothersep}{ + boolifTF={uppergrading} + { + lowerdotswithothersep={#1}, + } + { + upperdotswithothersep={#1}, + }, + }, + {i...withothersep}{ + idotswithothersep={#1}, + }, + {i*withothersep}{ + boolifTF={uppergrading} + { lower*withothersep={#1} } + { upper*withothersep={#1} }, + }, + {i**withothersep}{ + boolifTF={uppergrading} + { lower**withothersep={#1} } + { upper**withothersep={#1} }, + }, + {setisep}{ + boolifTF={uppergrading} + { + setlowersep={#1}, + } + { + setuppersep={#1}, + }, + }, + {nextiwithsep}{ + strifeqTF={#1}{true} + { + boolifTF={uppergrading} + { + nextlowerwithsep={#1}, + } + { + nextupperwithsep={#1}, + }, + } + { + strifeqTF={#1}{false} + { + boolifTF={uppergrading} + { + nextupperwithsep={#1}, + } + { + nextlowerwithsep={#1}, + }, + } + { + ERRORkeyvaluenotfound={nextiwithothersep}{#1}, + }, + }, + }, + }, + definekeys[2]={ + {iwithothersep}{ + execute={ + \semantex_data_bool_get:nnTF { ##1 } { uppergrading } + { \semantex_valuekey:nnn { ##1 } { lowerwithothersep } { { #1 } { #2 } } } + { \semantex_valuekey:nnn { ##1 } { upperwithothersep } { { #1 } { #2 } } } + }, + }, + }, + % Argument keyval interface + defineargkeys[1]={ + {execute}{execute={#1}}, + {setkeys}{ execute={ \semantex_keys_set:nn { ##1 } { #1 } } }, + {keysset}{ execute={ \semantex_keys_set:nn { ##1 } { #1 } } }, + {setkeysx}{ execute={ \semantex_keys_set_x:nn { ##1 } { #1 } } }, + {keyssetx}{ execute={ \semantex_keys_set_x:nn { ##1 } { #1 } } }, + {setargkeys}{ execute={ \semantex_arg_keys_set:nn { ##1 } { #1 } } }, + {argkeysset}{ execute={ \semantex_arg_keys_set:nn { ##1 } { #1 } } }, + {setargkeysx}{ execute={ \semantex_arg_keys_set_x:nn { ##1 } { #1 } } }, + {argkeyssetx}{ execute={ \semantex_arg_keys_set_x:nn { ##1 } { #1 } } }, + {setargsinglekeys}{ execute={ \semantex_arg_singlekeys_set:nn { ##1 } { #1 } } }, + {argsinglekeysset}{ execute={ \semantex_arg_singlekeys_set:nn { ##1 } { #1 } } }, + {setargsinglekeysx}{ execute={ \semantex_arg_singlekeys_set_x:nn { ##1 } { #1 } } }, + {argsinglekeyssetx}{ execute={ \semantex_arg_singlekeys_set_x:nn { ##1 } { #1 } } }, + {setoneargsinglekey}{ execute={ \semantex_arg_singlekey:nn { ##1 } { #1 } } }, + {oneargsinglekeyset}{ execute={ \semantex_arg_singlekey:nn { ##1 } { #1 } } }, + {setoneargsinglekeyx}{ execute={ \semantex_arg_singlekey_x:nn { ##1 } { #1 } } }, + {oneargsinglekeysetx}{ execute={ \semantex_arg_singlekey_x:nn { ##1 } { #1 } } }, + {setargwithoutkeyval}{ execute={ \semantex_arg_without_keyval:nn { ##1 } { #1 } } }, + {argwithoutkeyvalset}{ execute={ \semantex_arg_without_keyval:nn { ##1 } { #1 } } }, + {setargwithoutkeyvalx}{ execute={ \semantex_arg_without_keyval:nx { ##1 } { #1 } } }, + {argwithoutkeyvalsetx}{ execute={ \semantex_arg_without_keyval:nx { ##1 } { #1 } } }, {default}{s={#1}}, {-withothersep}{slotwithothersep={#1}}, {...withothersep}{dotswithothersep={#1}}, + {s}{ + execute={ + \semantex_data_bool_get:nnTF { ##1 } { nextargwithsep } + { + \semantex_data_tl_put_right:nnx { ##1 } { arg } + { + \semantex_data_tl_get_exp_not:nn { ##1 } { argsep } + } + } + { + % do nothing + } + \semantex_data_tl_put_right:nnn { ##1 } { arg } { #1 } + \semantex_data_int_incr:nn { ##1 } { numberofarguments } + \semantex_data_bool_set_true:nn { ##1 } { nextargwithsep } + } + }, + {c}{ + execute={ + \semantex_data_bool_get:nnTF { ##1 } { nextargwithsep } + { + \semantex_data_tl_put_right:nnn { ##1 } { arg } { , #1 } + } + { + \semantex_data_tl_put_right:nnn { ##1 } { arg } { #1 } + } + \semantex_data_int_incr:nn { ##1 } { numberofarguments } + \semantex_data_bool_set_true:nn { ##1 } { nextargwithsep } + } + }, + {dotswithothersep}{ + execute={ + \semantex_arg_valuekey:nnx { ##1 } { othersep } + { + { \exp_not:n { #1 } } + { \semantex_data_tl_get_exp_not:nn { ##1 } { argdots } } + } + }, + }, + {slotwithothersep}{ + execute={ + \semantex_arg_valuekey:nnx { ##1 } { othersep } + { + { \exp_not:n { #1 } } + { \semantex_data_tl_get_exp_not:nn { ##1 } { argslot } } + } + }, + }, }, - argsinglekeys={ - {slot}{slot=}, - {-}{slot=}, - {cslot}{cslot=}, - {c-}{cslot=}, -% {*}{slot=}, % would be confusing since * does not correspond to slot in the indices - {dots}{dots=}, - {...}{dots=}, - {cdots}{cdots=}, - {c...}{cdots=}, + defineargkeys={ + {dots}{ + execute={ + \semantex_arg_valuekey:nnx { ##1 } { s } + { + \semantex_data_tl_get_exp_not:nn { ##1 } { argdots } + } + }, + }, + {...}{dots}, + {cdots}{ + execute={ + \semantex_arg_valuekey:nnx { ##1 } { c } + { + \semantex_data_tl_get_exp_not:nn { ##1 } { argdots } + } + }, + }, + {c...}{cdots}, + {slot}{ + execute={ + \semantex_arg_valuekey:nnx { ##1 } { s } + { + \semantex_data_tl_get_exp_not:nn { ##1 } { argslot } + } + }, + }, + {-}{slot}, + {cslot}{ + execute={ + \semantex_arg_valuekey:nnx { ##1 } { c } + { + \semantex_data_tl_get_exp_not:nn { ##1 } { argslot } + } + }, + }, + {c-}{cslot}, + }, + defineargkeys[2]={ + {othersep}{ + execute={ + \semantex_data_bool_get:nnTF { ##1 } { nextargwithsep } + { + \semantex_data_tl_put_right:nnn { ##1 } { arg } { #1 #2 } + } + { + \semantex_data_tl_put_right:nnn { ##1 } { arg } { #2 } + } + \semantex_data_int_incr:nn { ##1 } { numberofarguments } + \semantex_data_bool_set_true:nn { ##1 } { nextargwithsep } + }, + }, }, ] \cs_set_eq:NN\__semantex_old_version_of_semantex_new_object_of_class_SemantexBaseObject:Nw \__semantex_new_object_of_class_SemantexBaseObject:Nw -\cs_set:Npn \__semantex_new_object_of_class_SemantexBaseObject:Nw#1 +\cs_set_protected:Npn \__semantex_new_object_of_class_SemantexBaseObject:Nw#1 { \msg_error:nnn { semantex } { created_a_SemantexBaseObject } { #1 } \__semantex_old_version_of_semantex_new_object_of_class_SemantexBaseObject:Nw #1 -}
\ No newline at end of file +} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% PROCESSING PACKAGE KEYVAL SETUP +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\ProcessKeysOptions { semantex } + +% ... and they lived happily ever after.
\ No newline at end of file diff --git a/macros/latex/contrib/semantex/semantex.tex b/macros/latex/contrib/semantex/semantex.tex index f4cf279f0e..81064afc8e 100644 --- a/macros/latex/contrib/semantex/semantex.tex +++ b/macros/latex/contrib/semantex/semantex.tex @@ -23,6 +23,10 @@ \makeevenhead{headings}{\thepage}{}{\itshape\leftmark} %make headings italic instead of slanted (though we do not use headings right now) \makeoddhead{headings}{\itshape\rightmark}{}{\thepage} +\setlrmarginsandblock{4cm}{*}{*} +\setulmarginsandblock{4cm}{*}{*} +\checkandfixthelayout + \raggedbottomsectiontrue%less harse than \raggedbottom %\allowdisplaybreaks %long equations may break @@ -34,26 +38,67 @@ \usepackage[nameinlink]{cleveref} -\title{Seman\!\TeX: Semantic mathematics (v$0.3\alpha$)} +\title{Seman\!\TeX: semantic, keyval-based mathematics (v$0.4\beta$)} \date{\today} \author{Sebastian Ørsted (\href{mailto:sorsted@gmail.com}{sorsted@gmail.com})} \hypersetup{ pdfauthor={Sebastian Ørsted}, - pdftitle={SemanTeX: Object-oriented mathematics}, + pdftitle={SemanTeX: semantic, keyval-based mathematics}, %pdfsubject={}, %pdfkeywords={}, %pdfproducer={Latex with hyperref, or other system}, %pdfcreator={pdflatex, or other tool}, } +\usepackage{showexpl} +\lstset{% + language=[LaTeX]TeX, + basicstyle=\ttfamily\small, + commentstyle=\itshape\ttfamily\small, + alsoletter={\\}, + escapechar=@, + breaklines=true, + breakindent={0pt}, + captionpos=t, + pos=r, + tabsize=2, + %inputencoding=utf8, + explpreset={numbers=none,}, + texcl=false, + wide=false, + width=.45\textwidth, +} + +\newcommand\mylst{\lstinline[mathescape]} + +\def\<#1\>{\textrm{\textlangle\textit{#1}\textrangle}} + +\def\usercommand\<#1\>{\textrm{\textbackslash\textlangle\textit{#1}\textrangle}} + +\def\values\<#1\>{\textrm{\textlangle\textup{#1}\textrangle}} +\def\num#1{\textsubscript{\textup{#1}}} -% Settup up SemanTeX: +\newcommand\default[1]{\smash{\underline{\smash{#1}}}} + +\newcommand\commandname[1]{\textbackslash\texttt{#1}} + +\let\pack=\texttt + +\newcommand\semantex{Seman\!\TeX\xspace} + +\newcommand\stripsemantex{\texttt{stripsemantex}\xspace} + +\usepackage{hologo} + +% Setting up SemanTeX: \usepackage{semantex} +\usepackage{expkv} + \NewVariableClass\MyVar[ output=\MyVar, ] @@ -173,58 +218,38 @@ \NewObject\MyHomology\ho{H} -\usepackage{showexpl,newunicodechar} +\makeatother -\newunicodechar{⟨}{\textlangle} -\newunicodechar{⟩}{\textrangle} -\makeatother \begin{document} \maketitle -\lstset{% - language=[LaTeX]TeX, - basicstyle=\ttfamily\small, - commentstyle=\itshape\ttfamily\small, - extendedchars=true, - breaklines=true, - breakindent={0pt}, - captionpos=t, - pos=r, - tabsize=2, - inputencoding=utf8, - extendedchars=true, - explpreset={numbers=none,}, - literate={⟨}{\textlangle}1 {⟩}{\textrangle}1, -} - - - -\newcommand\mybs{$\backslash$} +\noindent +The \semantex package for \LaTeX\ delivers a more semantic, systematized way of writing mathematics, compared to the classical math syntax in~\LaTeX. +The system uses keyval syntax, and the user can define their own keys and customize the system down to the last detail. At the same time, care has been taken to make the syntax as simple, natural, practical, and lightweight as possible. -\newcommand\commandname[1]{\mybs\texttt{#1}} +Furthermore, the package has a companion package, +called \stripsemantex, which allows you to completely strip +your documents of \semantex markup to prepare them e.g.~for publication. -\let\pack=\texttt - -\newcommand\semantex{Seman\!\TeX\xspace} +The package is still in beta, but is considered feature-complete +and more or less stable, so using it at this point should be safe. +Still, suggestions, ideas, and bug reports are more than welcome! -\noindent -The \semantex package for \LaTeX\ delivers a more semantic, systematized way of writing mathematics, compared to the classical math syntax in~\LaTeX. -The system uses keyval syntax and is highly customizable. At the same time, care has been taken to make it the syntax as simple, natural, practical, and lightweight as possible. -\textbf{Note: \semantex is still in its alpha stage and cannot be considered stable at this point. You are more than welcome to report bugs and come with suggestions!} +\chapter{Introduction} \begingroup \SetupClass\MyVar{ - singlekeys={ - {conj}{overline}, + definekeys={ + {conj}{command=\overline}, {inv}{upper={-1}}, {inverseimage}{upper={-1},nopar}, }, - valuekeys={ + definekeys[1]={ {der}{upper={ (#1) } }, - {res}{ return ,symbolputright ={|}, lower ={#1} }, + {res}{ rightreturn ,symbolputright ={|}, lower ={#1} }, {stalk}{clower={#1}}, % "clower" means "comma lower", i.e. lower index % separated from any previous lower index by a comma @@ -301,17 +326,17 @@ $ \vh[inverseimage]{\sheafF}[spar,stalk=\vp] output=\MyVar, % This means that the output of an object % of class \MyVar is also of class \MyVar % We add a few keys for use with the class \MyVar: - singlekeys={ % keys taking no values + definekeys={ % we define a few keys {inv}{upper={-1}}, - {conj}{overline}, + {conj}{command=\overline}, % Applies \overline to the symbol {inverseimage}{upper={-1},nopar}, }, - valuekeys={ % keys taking a value + definekeys[1]={ % we define keys taking 1 value {der}{upper={(#1)}}, {stalk}{clower={#1}}, % "clower" means "comma lower", i.e. lower index % separated from any previous lower index by a comma - {res}{ return ,symbolputright ={|}, lower ={#1} }, + {res}{ rightreturn, symbolputright={|}, lower={#1} }, }, } @@ -341,7 +366,7 @@ You should think of this as a low-level class, the parent of all other classes. Instead, we create a new, more high-level variable class. We choose to call it \lstinline!\MyVar!. It is best to always start class names with uppercase letters to separate them from objects. -We could write \lstinline!\NewVariableClass\MyVar!, but we choose to +We could create this class by writing \lstinline!\NewVariableClass\MyVar!, but we choose to pass some options to it in~\lstinline![...]!: \begin{lstlisting} \NewVariableClass\MyVar[output=\MyVar] @@ -350,15 +375,15 @@ This \lstinline!output=\MyVar! option will be explained better below. Roughly speaking, it tells \semantex that everything a variable \emph{outputs} will also be a variable. For instance, if the function~\lstinline!\vf! (i.e.~\( \vf \)) is of class~\lstinline!\MyVar!, -then \lstinline!\vf{\vx}!~(i.e.~\( \vf{\vx} \))~will also of class~\lstinline!\MyVar!. +then \lstinline!\vf{\vx}!~(i.e.~\( \vf{\vx} \))~will also be of class~\lstinline!\MyVar!. Now we have a class, but we do not have any objects. To create the object~\lstinline!\vf! of class~\lstinline!\MyVar! with symbol~\( f \), we write~\lstinline!\NewObject\MyVar\vf{f}!. -In general, when you have class~\lstinline!\⟨Class⟩!, you +In general, when you have class~\usercommand\<Class\>, you can create objects of that class wtih the syntax \begin{lstlisting} -\NewObject\⟨Class⟩\⟨object⟩{⟨object symbol⟩}[⟨options⟩] +\NewObject@\usercommand\<Class\>\usercommand\<object\>@{@\<object symbol\>@}[@\<options\>@] \end{lstlisting} To distinguish objects from classes, it is a good idea to denote objects by lowercase letters.\footnote{We shall not follow this convention strictly, as we shall later create objects with names like~\commandname{Hom}; using lowercase letters for these would just look weird.} @@ -374,13 +399,14 @@ $\vf$, $\vx$ \end{LTXexample} Th general syntax of a variable-type object is \begin{lstlisting} -\⟨object⟩[⟨options⟩]{⟨argument⟩} +@\usercommand\<object\>@[@\<options\>@]{@\<argument\>@} \end{lstlisting} -Both \lstinline!⟨options⟩! and \lstinline!⟨argument⟩! are optional +Both \<options\> and \<argument\> are optional arguments (they can be left out if you do not need them). -The \lstinline!⟨options⟩! should consist of a list of options separated by commas, using keyval syntax. On the other hand, \lstinline!⟨argument⟩! is the actual argument of the function. -By design, \semantex does not distinguish between variables and functions, so all variables can take arguments. -This is a design choice to make the system easier to use; after all, it is fairly common in mathematics that something is first a variable and then a moment later takes an argument. +The \<options\> should consist of a list of options separated by commas, using keyval syntax. Naturally, \<argument\> is the actual argument of the function. + +By a design choice, \semantex does not distinguish between variables and functions, so all variables can take arguments. +This makes the system easier to use; after all, it is fairly common in mathematics that something is first a variable and then a moment later takes an argument. So we may write: \begin{LTXexample} $\vf{1}$, $\vf{\vx}$, @@ -388,20 +414,37 @@ $\vx{\vx}$ \end{LTXexample} So far, we do not have very many options to write in the -\lstinline!⟨options⟩! position, since we have not added any keys yet. However, we do have access +\<options\> position, since we have not added any keys yet. However, we do have access to the most important of all options: the \emph{index}. There is a simple shortcut for writing an index: You simply write the index itself in the options tag: \begin{LTXexample} $\vf[1]$, $\vf[\vf]$, $\vf[1,2,\vf]{2}$ \end{LTXexample} -As long as what you write in the options tag is not recognized as a predefined key, it will be printed as the index. +As long as what you write in the options tag is not recognized as a defined key, it will be printed as the index. Other than that, there are two important predefined keys: \lstinline!upper! and \lstinline!lower! which simply add something to the upper and lower index: \begin{LTXexample} $\vf[upper=2]$, $\vf[lower=3]$ \end{LTXexample} +In fact, there are quite a few keys for manipulating upper and lower indices. +Right now, apart from \lstinline!upper! and~\lstinline!lower!, +we shall only need a couple more: +\lstinline!supper! and~\lstinline!slower! mean +\enquote{separator~+~upper} and \enquote{separator~+~lower}\footnote{Yes, I have noticed that the words unfortunately have other meanings already. But the notation has to be brief and consistent, and I have decided convention that \mylst!s$\<anything\>$! means \<anything\>, possibly separated from previous \<anything\> by a separator.}. +These are like \lstinline!upper! and~\lstinline!lower!, +but if there already was an upper or lower index, +the new index will be separated from the old one by a separator. +By default, this separator is a comma. +There are also two more commands, +\lstinline!cupper! and~\lstinline!clower!, +which mean \enquote{comma~+~upper} and~\enquote{comma~+~lower}. +These will use a comma as separator, even if you have changed the +default separator. + +\section{Next step: Defining more variables} + We are soon going to need more variables than just \( \vf \) and~\( \vx \). In fact, I advise you to create a variable for each letter in the Latin and Greek alphabets, both uppercase and lowercase. @@ -516,7 +559,10 @@ $\vf[par=auto]{\frac{1}{2}}$ \end{LTXexample} Using \lstinline!par=auto! corresponds to using \lstinline!\left...\right!. Just as for ordinary math, I advice you to use manual scaling rather than automatic scaling, as \TeX\ has a tendency to scale things wrong. If you do not want parentheses at all, you can pass the key~\lstinline!nopar! (it will still print parentheses if there is more than one argument, though; to exclude this behaviour, run~\lstinline!neverpar! instead): \begin{LTXexample} -$\vf[nopar]{\vx}$ +$\vf[nopar]{\vx}$, +$\vf[nopar]{\vx,\vy}$, +$\vf[neverpar]{\vx}$, +$\vf[neverpar]{\vx,\vy}$ \end{LTXexample} Primes are added via the key~\lstinline!prime! or the keys~\lstinline!'!,~\lstinline!''! and~\lstinline!'''!: @@ -526,37 +572,101 @@ $\vf[''] = \vf[prime,prime]$ $\vf['''] = \vf[prime,prime,prime]$ \end{LTXexample} -So far, so good, but our variables cannot really do anything yet. For this, we need to assign \emph{keys} to them. The more pieces of math notation you need, the more keys you will have to define. -Keys are being added via two different keys: -\begin{center} - \lstinline!singlekeys! - \qquad\qquad and \qquad\qquad - \lstinline!valuekeys!. -\end{center} -In short, \lstinline!singlekeys! is for keys that do \emph{not} take a value (i.e.~keys using the syntax~\lstinline!\⟨object⟩[key]!), and \lstinline!valuekeys! is for keys that \emph{do} take a value -(i.e.~keys using the syntax~\lstinline!\⟨object⟩[key=value]!)). -We explain the syntax for using them in the next section where we show how to make keyval syntax for elementary calculus. - \begingroup\color{red}% For the rest of the manual, we assume that you have already defined a class~\lstinline!\MyVar! and the variables~\lstinline!\va!, \lstinline!\vA!, \lstinline!\vb!, \lstinline!\vB!, \ldots, as above. \endgroup -\chapter{Example: Elementary calculus} +\section{Defining keys} + +So far, so good, but our variables cannot really do anything yet. For this, we need to assign \emph{keys} to them. The more pieces of math notation you need, the more keys you will have to define. +To define keys, we use the command~\lstinline!\SetupClass! +(or~\lstinline!\SetupObject! if you want to define it for an individual object) +and the key~\lstinline!definekeys!. +The syntax is as follows: +\begin{lstlisting} +\SetupClass\MyVar{ + definekeys={ + {@\<key name\num{1}\>@}{ @\<keys to run\>@ }, + {@\<key name\num{2}\>@}{ @\<keys to run\>@ }, + {@\<key name\num{3}\>@}{ @\<keys to run\>@ }, + @\ldots,@ + }, +} +\end{lstlisting} +For instance, you can do +\begin{lstlisting} +\SetupClass\MyVar{ + definekeys={ + {key1}{ upper=3, lower=7 }, + {key2}{ lower=6, upper=4 }, + }, +} +\end{lstlisting} + +Quite often, we shall also need to define +keys that can \emph{take a value}. +A key can take up to~\( 9 \)~values. +To define a key taking \( n \)~values, +use~\mylst!definekeys[$n$]! +for~\( n = 0 , 1 , 2 , \ldots , 9 \). +The syntax is similar to~\lstinline!definekeys!, +except the values can be accessed +by writing~\lstinline!#1!, \lstinline!#2!, \ldots, \lstinline!#9!. +Except for a few special cases, you will probably only +ever need~\lstinline!definekeys[1]!. So you can do +\begin{lstlisting} +\SetupClass\MyVar{ + definekeys[1]={ + {key3}{ upper=\{#1\} }, + {key4}{ lower=(#1) }, + }, + definekeys[2]={ + {key5}{ upper=3+#1, lower=7-#2 }, + {key6}{ lower=6\cdot#1, upper=4/#2 }, + }, +} +\end{lstlisting} +\begingroup +\SetupClass\MyVar{ + definekeys={ + {key1}{ upper=3, slower=7 }, + {key2}{ lower=6, supper=4 }, + }, + definekeys[1]={ + {key3}{ supper=\{#1\} }, + {key4}{ slower=(#1) }, + }, + definekeys[2]={ + {key5}{ supper=3+#1, slower=7-#2 }, + {key6}{ slower=6\cdot#1, supper=4/#2 }, + }, +} +Let us see these rather ridiculous keys in action: + +\begin{LTXexample} +$ \vP[key1,key3=0,key5={3}{4}] $ +\end{LTXexample} + +\endgroup + +\chapter{Some examples} + +\section{Example: Elementary calculus} One thing we might want to do to a variable is \emph{invert} it. We therefore add a key~\lstinline!inv! that adds an upper index~\lstinline!-1! to the symbol. -We add this key using the key \lstinline!singlekeys!, -which is for keys that do not take a value: +We add this key using the key \lstinline!definekeys! +since there is no reason for this key to take a value: \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {inv}{ upper={-1} }, }, } \end{lstlisting} \SetupClass\MyVar{ -singlekeys={ +definekeys={ {inv}{ upper={-1} }, }, } @@ -569,25 +679,22 @@ $\vg[1,2,inv]$, $\vh[\va,\vb,inv]$ \end{LTXexample} -Other keys might need to take a value. -For defining such, we have the command~\lstinline!valuekeys!. -%There are two different keys for adding new keys -%to a class: \lstinline!singlekeys! and \lstinline!valuekeys!. -%The difference is that +Other keys might need to take one value. +For defining these, we use the key~\lstinline!definekeys[1]!. For instance, suppose we want a command for deriving a function \( n \)~times. For this, we add the key~\lstinline!der!: \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {inv}{ upper={-1} }, }, - valuekeys={ + definekeys[1]={ {der}{ upper={(#1)} }, }, } \end{lstlisting} \SetupClass\MyVar{ -valuekeys={ +definekeys[1]={ {der}{ upper={(#1)} }, }, } @@ -600,17 +707,17 @@ $\vf[der=\vn]{\vx}$ Maybe we also want a more elementary key~\lstinline!power! for raising a variable to a power: \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {inv}{ upper={-1} }, }, - valuekeys={ + definekeys[1]={ {der}{ upper={(#1)} }, {power}{ upper={#1} }, }, } \end{lstlisting} \SetupClass\MyVar{ - valuekeys={ + definekeys[1]={ {power}{ upper={#1} }, }, } @@ -624,26 +731,26 @@ Let us try doing something a bit more complicated: adding a key for restricting For this, we do the following: \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {inv}{ upper={-1} }, }, - valuekeys={ + definekeys[1]={ {der}{ upper={(#1)} }, {power}{ upper={#1} }, - {res}{ return,symbolputright={|}, lower={#1} }, + {res}{ rightreturn,symbolputright={|}, lower={#1} }, }, } \end{lstlisting} \SetupClass\MyVar{ - valuekeys={ - {res}{ return,symbolputright={|}, lower={#1} }, + definekeys[1]={ + {res}{ rightreturn,symbolputright={|}, lower={#1} }, }, } This adds a horizonal line~\enquote{$|$} to the right of the symbol followed by a lower index containing whatever you passed to the key (contained in the \mbox{command~\lstinline!#1!)}. -(There is also an extra key, \lstinline!return!, which is a bit more advanced and should be taken for granted for now. Roughly speaking, it is there to make sure that the restriction symbol is printed \emph{after} all indices that you might have added before. More details in \cref{ch:return}.) +(There is also an extra key, \lstinline!rightreturn!, which is a bit more advanced and should be taken for granted for now. Roughly speaking, it is there to make sure that the restriction symbol is printed \emph{after} all indices that you might have added before. More details in \cref{ch:return}.) Now we may write the following: \begin{LTXexample} $\vf[res=\vU]{\vx}$, @@ -661,15 +768,16 @@ $\vf[der=\vn]{\vx}{\vy}{\vz} Some people prefer to be able to scale the vertical line in the restriction notation. I rarely do that, but for this purpose, we could do the following: \begin{lstlisting} \SetupClass\MyVar{ - valuekeys={ - {bigres}{ return, symbolputright=\big\vert, lower={#1} }, - {Bigres}{ return, symbolputright=\Big\vert, lower={#1} }, - {biggres}{ return, symbolputright=\bigg\vert, lower={#1} }, - {Biggres}{ return, symbolputright=\Bigg\vert, lower={#1} }, - {autores}{ return, Otherspar={.}{\vert}{auto}, - lower={#1} }, - % This auto scales the vertical bar. See the chapter on the - % spar key for information about sparsize and Otherspar + definekeys[1]={ + {bigres}{ rightreturn, symbolputright=\big|, lower={#1} }, + {Bigres}{ rightreturn, symbolputright=\Big|, lower={#1} }, + {biggres}{ rightreturn, symbolputright=\bigg|, lower={#1} }, + {Biggres}{ rightreturn, symbolputright=\Bigg|, lower={#1} }, + {autores}{ Otherspar={.}{|}{auto}, lower={#1} }, + % The last key auto-scales the vertical bar. See @\textit{\cref{sec:spar}}@ + % for information about Otherspar. + % Note that Otherspar automatically invokes rightreturn, + % so no need to run that key twice. }, } \end{lstlisting} @@ -680,26 +788,25 @@ via \lstinline!\NewVariableClass! and then used \lstinline!\SetupClass! to add k \NewVariableClass\MyVar[ output=\MyVar, % This means that the output of an object % of class \MyVar is also of class \MyVar - singlekeys={ + definekeys={ {inv}{ upper={-1} }, }, - valuekeys={ + definekeys[1]={ {der}{ upper={(#1)} }, {power}{ upper={#1} }, - {res}{ rightreturn, symbolputright={|}, - lower={#1} }, + {res}{ rightreturn, symbolputright={|}, lower={#1} }, }, ] \end{lstlisting} As we proceed in this guide, we shall use \lstinline!\SetupClass! to add more and more keys to~\lstinline!\MyVar!. However, when you set up your own system, you may as well just add all of the keys at once like this when you create the class and then be done with it. -Let me add that it is possible to create subclasses of existing classes. You just write \lstinline!parent=\⟨Class⟩! in the class declaration to tell that \lstinline!\⟨Class⟩! is the parent class. \textbf{But a word of warning:} It is a natural idea to create different classes for different mathematical entities, each with their own keyval syntax that fits whatever class you are in; for instance, you could have one class for algebraic structures like rings and modules with keys for opposite rings and algebraic closure, and you could have another class for topological spaces with keys for closure and interior. However, as the reader can probably imagine, this becomes extremely cumbersome to work with in practice since an algebraic structure might very well also carry a topology. So at the end of the day, I advice you to use a single superclass \lstinline!\MyVar! that has all the keyval syntax and mainly use subclasses for further customization. We shall see examples of this below. +Let me add that it is possible to create subclasses of existing classes. You just write \mylst!parent=$\usercommand\<Class\>$! in the class declaration to tell that \usercommand\<Class\> is the parent class. \textbf{But a word of warning:} It is a natural idea to create different classes for different mathematical entities, each with their own keyval syntax that fits whatever class you are in; for instance, you could have one class for algebraic structures like rings and modules with keys for opposite rings and algebraic closure, and you could have another class for topological spaces with keys for closure and interior. However, as the reader can probably imagine, this becomes extremely cumbersome to work with in practice since an algebraic structure might very well also carry a topology. So at the end of the day, I advice you to use a single superclass \lstinline!\MyVar! that has all the keyval syntax and mainly use subclasses for further customization. We shall see examples of this below. -\chapter{Example: Elementary algebra} +\section{Example: Elementary algebra}\label{sec:algebra} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {poly}{ par, % This tells semantex to use parentheses around % the argument in the first place, in case this @@ -714,7 +821,7 @@ for doing algebra. As an algebraist, one of the first things you might want to do is to create polynomial rings~\( \vk[poly]{\vx,\vy,\vz} \). Since all variables can already be used as functions (this is a design choice we discussed earlier), all we need to do is find a way to change from using parentheses to square brackets. This can be done the following way: \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {poly}{ par, % This tells semantex to use parentheses around % the argument in the first place, in case this @@ -726,12 +833,12 @@ As an algebraist, one of the first things you might want to do is to create poly \end{lstlisting} Now we may write \begin{LTXexample} - $\vk[poly]{\vx,\vy,\vz}$ +$\vk[poly]{\vx,\vy,\vz}$ \end{LTXexample} It is straightforward how to do adjust this to instead write the \emph{field} generated by the variables~\( x, y, z \): \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {poly}{ par, % This tells semantex to use parentheses around % the argument in the first place, in case this @@ -746,7 +853,7 @@ It is straightforward how to do adjust this to instead write the \emph{field} ge } \end{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {field}{ par, leftpar=(,rightpar=), @@ -759,7 +866,7 @@ key would produce the same result with the current configuration of the class~\l Adding support for free algebras, power series, and Laurent series is almost as easy, but there is a catch: \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {poly}{ par, % This tells semantex to use parentheses around % the argument in the first place, in case this @@ -785,7 +892,8 @@ Adding support for free algebras, power series, and Laurent series is almost as leftpar=(, rightpar=), prearg={\!\!\SemantexDelimiterSize(}, postarg={\SemantexDelimiterSize)\!\!}, - % These are printed before and after the argument. + % The "prearg" and "postarg" are printed before after + % the argument, if the argument is non-empty. % The command "\SemantexDelimiterSize" is substituted % by \big, \Big, ..., or whatever size the % argument delimiters have @@ -794,7 +902,7 @@ Adding support for free algebras, power series, and Laurent series is almost as } \end{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {freealg}{ par, leftpar=\langle, @@ -828,51 +936,52 @@ $\vk[laurent]{\vz}$ Let us look at some other algebraic operations that we can control via \semantex: \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {op}{upper={\mathrm{op}}}, % opposite groups, rings, categories, etc. - {algclosure}{overline}, + {algclosure}{command=\overline}, % algebraic closure - {conj}{overline}, + {conj}{command=\overline}, % complex conjugation {dual}{upper=*}, % dual vector space {perp}{upper=\perp}, % orthogonal complement }, - valuekeys={ - {mod}{symbolputright={/#1}}, + definekeys[1]={ + {mod}{rightreturn,symbolputright={/#1}}, % for modulo notation like R/I - {dom}{symbolputleft={#1\backslash}}, + {dom}{leftreturn,symbolputleft={#1\backslash}}, % for left modulo notation like I\R % "dom" is "mod" spelled backwards {oplus}{upper={\oplus#1}}, % for notation like R^{\oplus n} {tens}{upper={\otimes#1}}, % for notation like R^{\otimes n} - {localize}{symbolputright={ \relax [#1^{-1}] }}, + {localize}{symbolputright={ \lbrack #1^{-1} \rbrack }}, % localization at a multiplicative subset; - % the \relax is necessary becauese, in some cases, - % the [...] can be interpreted as an optional argument - {localizeprime}{lower={#1}}, + % we use \lbrack and \rbrack rather than [ and ] since in some + % cases (using constructions like in @{\itshape\cref{ch:the_class_command}}@), + % the [...] might be interpreted as an optional argument. + {localizeprime}{slower={#1}}, % for localization at a prime ideal }, } \end{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {op}{upper={\mathrm{op}}}, % opposite groups, rings, categories, etc. - {algclosure}{overline}, + {algclosure}{command=\overline}, % algebraic closure - {conj}{overline}, + {conj}{command=\overline}, % complex conjugation {dual}{upper=*}, % dual vector space {perp}{upper=\perp}, % orthogonal complement }, - valuekeys={ + definekeys[1]={ {mod}{symbolputright={/#1}}, % for modulo notation like R/I {dom}{symbolputleft={#1\backslash}}, @@ -882,9 +991,9 @@ Let us look at some other algebraic operations that we can control via \semantex % for notatoin like R^{\oplus n} {tens}{upper={\otimes#1}}, % for notation like R^{\otimes n} - {localize}{symbolputright={ [#1^{-1}] }}, + {localize}{symbolputright={ \lbrack #1^{-1} \rbrack }}, % localization at a multiplicative subset - {localizeprime}{lower={#1}}, + {localizeprime}{slower={#1}}, % for localization at a prime ideal }, } @@ -901,7 +1010,35 @@ $\vk[freealg]{\vS}[op]$, $\vV[perp]$ \end{LTXexample} -\chapter{The \texttt{spar} key} +\section{GIT quotients} + +\SetupClass\MyVar{ + definekeys[2]={ + {projquotient}{ symbolputright={ /\!\!/ _ { #1 } #2 } }, + } +} + +We include a slightly more advanced example +to show the use of keys with more than one value. +Sometimes, a key with one value is simply not enough. For instance, if you +work in geometric invariant theory~(GIT), you will eventually have to take the proj +quotient~\( \vX[projquotient={\vchi}{\vG}] \) of~\( \vX \) with respect to the action of the group~\( \vG \) and the character~\( \vchi \). In other words, the proj quotient depends on two parameters, \( \vchi \) and~\( \vG \). For this purpose, we the the key~\lstinline!definekeys[2]!: +\begin{lstlisting} +\SetupClass\MyVar{ + definekeys[2]={ + {projquotient}{ symbolputright={ /\!\!/ _ { #1 } #2 } }, + } +} +\end{lstlisting} + +\begin{LTXexample} +$ \vX[projquotient={\vchi}{\vG}] $ +\end{LTXexample} + + +\chapter{Some more techniques} + +\section{The \texttt{spar} key}\label{sec:spar} The \lstinline!spar! key is one of the most important commands in \semantex at all. To understand why we need it, imagine you want to derive a function \( \vn \)~times and then invert it. Writing something like \begin{LTXexample} @@ -939,16 +1076,19 @@ Occassionally, it is useful to be able to input a particular kind of brackets ju without adjusting any settings. For this purpose, we have the \lstinline!otherspar! and~\lstinline!Otherspar!~keys. They use the syntax \begin{lstlisting} -otherspar={⟨opening bracket⟩}{⟨closing bracket⟩} -Otherspar={⟨opening bracket⟩}{⟨closing bracket⟩}{⟨size⟩} +otherspar={@\<opening bracket\>@}{@\<closing bracket\>@} +Otherspar={@\<opening bracket\>@}{@\<closing bracket\>@}{@\values\<normal|auto|*|{\textit{other}}\>@} \end{lstlisting} +The last argument in \lstinline!Otherspar! sets the size of the +parentheses. Let us see them in action: \begin{LTXexample} -$\vf[otherspar={[}{)},otherspar={\{}{\rangle}, +$\vf[otherspar={[}{)}, + otherspar={\{}{\rangle}, Otherspar={\langle}{\rangle}{\Bigg},spar]$ \end{LTXexample} -\chapter{The \texorpdfstring{\texttt{$\backslash$⟨Class⟩}}{Class} command} +\section{The \texorpdfstring{\texttt{$\backslash$\<Class\>}}{Class} command}\label{ch:the_class_command} So far, we have learned that every mathematical entity should be treated as an object of some class. However, then we run into issues the moment we @@ -960,27 +1100,74 @@ We do not want to have to define a new variable with symbol~\( \vf\circ\vg \) just to write something like this. Fortunately, once you have created the class~\lstinline!\MyVar!, you can actually use~\lstinline!\MyVar! as a command to create a quick instance of the class. -More precisely \lstinline!\MyVar{⟨symbol⟩}!~creates a variable on the spot with symbol~\lstinline!⟨symbol⟩!. +More precisely \mylst!\MyVar{$\<symbol\>$}!~creates a variable on the spot with symbol~\mylst!$\<symbol\>$!. So the above equation can be written \begin{LTXexample} -$\MyVar{\vf\circ\vg}[ - spar,der=\vn]{\vx}$ +$\MyVar{\vf\circ\vg}[spar, + der=\vn]{\vx}$ \end{LTXexample} -More generally, when you crate the class~\lstinline!\⟨Class⟩!, +More generally, when you crate the class~\usercommand\<Class\>, you can use it as a command with the following syntax: \begin{lstlisting} -\⟨Class⟩{⟨symbol⟩}[⟨options⟩]⟨usual syntax of class⟩ +@\usercommand\<Class\>@{@\<symbol\>@}[@\<options\>@]@\<usual syntax of class\>@ \end{lstlisting} -\chapter{The \texttt{return} keys}\label{ch:return} +\section{The \texttt{command} key} + +\begingroup +Above, we used the key~\lstinline!command! a couple of times: +\begin{LTXexample} +$\va[command=\overline]$, +$\vH[command=\widetilde]$ +\end{LTXexample} +This key applies the given command to the symbol. +Sometimes, it is useful to put these commands into +keys instead. So you can do stuff like +\begin{lstlisting} +\SetupClass\MyVar{ + definekeys={ + {tilde}{command=\tilde}, + {widetilde}{command=\widetilde}, + {bar}{command=\bar}, + {bold}{command=\mathbf}, + {roman}{command=\mathrm}, + }, +} +\end{lstlisting} +\SetupClass\MyVar{ + definekeys={ + {tilde}{command=\tilde}, + {widetilde}{command=\widetilde}, + {bar}{command=\bar}, + {bold}{command=\mathbf}, + {roman}{command=\mathrm}, + }, +} +Let us test: +\begin{LTXexample} +$\va[widetilde]$, +$\va[bold]$, +$\va[roman]$, +$\va[bar]$ +\end{LTXexample} +Note that there is a predefined key,~\lstinline!smash!, +which is equivalent to~\lstinline!command=\smash!. + +\endgroup + +\section{The \texttt{return} keys}\label{ch:return} + +Let us suppose in this section that we have +defined the key~\lstinline!conj! for complex conjugation, +like in the introduction. Suppose you want to take the complex conjugate of the variable~\( \vz[1] \). Then you might write something like \begin{LTXexample} $\vz[1,conj]$ \end{LTXexample} Notice that the bar has only been added over the~\( \vz \), as is standard mathematical typography; you normally do not write~\( \vz[1,return,conj] \). This reveals a design choice that has been made in \semantex: -When you add an index or a command via the \lstinline{command} key, +When you add an index or a command via the \lstinline!command! key, it is not immediately applied to the symbol. Rather, both commands and indices are added to a register and are then applied at the very last, right before the symbol is printed. This allows us to respect standard mathematical typography, as shown above. @@ -996,54 +1183,129 @@ $\vf[inv,return,conj]$ \end{LTXexample} In fact, \lstinline!return! is an umbrella key that invokes three different return routines: \lstinline!leftreturn!, \lstinline!innerreturn!, and \lstinline!rightreturn!. The command \lstinline!leftreturn! adds the left indices to the symbol (we have not discussed left indices yet, though). The command \lstinline!innerreturn! adds all commands to the symbol (those defined using the \lstinline!command!~key). Finally, \lstinline!rightreturn! adds all right indices and arguments to the symbol. -In general, the user should probably be satisfied with just using \lstinline!return!. +In general, most of the time, the user should probably be satisfied with just using \lstinline!return!. +\section{Keyval syntax conflicts} -\chapter{The \texttt{command} key} +You can pass anything you want as key values, including other objects. +But you quickly run into the following problem: +Imagine you try setting~\lstinline!\vx[1,power=2]! as the lower +index of a the object~\lstinline!\va!. If you try +\begin{lstlisting} +$ \va[lower=\vx[1,power=2]] $ +\end{lstlisting} +then the system will break. Indeed, the system will see the object~\lstinline!\va! +to which you have passed the two keys +\begin{center} + \lstinline!lower=\vx[1! + \qquad\text{and}\qquad + \lstinline!power=2]!. +\end{center} +To avoid this behaviour, you will have to enclose the key +value in braces: +\begin{LTXexample} +$ \va[lower={\vx[1,power=2]}] $ +\end{LTXexample} -Above, we used the key \lstinline!overline! a couple of times: +So far so good, but if you use our favourite shorthand notation +for lower indices (simply writing the index in the options, like~\lstinline!\va[1]!), +then it still goes wrong: +\begin{lstlisting} +$ \va[{\vx[1,power=2]}] $ +\end{lstlisting} +The reason is that in \LaTeX\ (really, the \pack{xparse} package from \LaTeX3) +interprets \lstinline![{...}]! more or less like~\lstinline![...]! +in this case. +To make up for this, you can use either of the following strategies: \begin{LTXexample} -$\va[overline]$, -$\vH[overline]$ +$ \va[ {\vx[1,power=2]} ] $, +$ \va[\vx[{1,power=2}]] $ \end{LTXexample} -This command applies the command \lstinline!\overline! -to the symbol. In fact, you can create similar commands yourself via -the \lstinline!command! key. -In fact, you could have defined the \lstinline!overline! yourself as follows: +There is a similar problem in the arguments, +since arguments also allow a kind of keyval syntax +(the keys that need equality signs are turned off by default, though; +more on that in \cref{ch:arg_keyval}). +But it will still react on commas and keys like~\lstinline!...!. +Therefore, in order to ensure the correct output, you will also have to enclose any argument containing commas with braces: +\begin{LTXexample} +$ \vf{ \vg[{upper=3,lower=2}] } $, +$ \vf{ {\vg[upper=3,lower=2]} } $ +\end{LTXexample} +As mentioned in \cref{ch:arg_keyval}, you \emph{can} +also turn keyval syntax in arguments completely off, +avoiding such issues. This can be done by setting \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ - {overline}{command=\overline}, - }, + argkeyval=false, } \end{lstlisting} -\SetupClass\MyVar{ - singlekeys={ - {overline}{command=\overline}, - }, -} -This is how the key \lstinline!overline! is defined internally, except it is defined on the level of the superclass \lstinline!\SemantexBaseObject! instead. -Here are some more examples of predefined keys that use the command key: + +\subsection{Cheating your way around keyval syntax conflicts} + +\begingroup +If you grow tired of having to deal with such issues all the time, there +are solutions to either partly or completely avoid this. +The first solution we present does not solve +the problem with~\lstinline!\va[\vx[1,power=2}]!, but +it does solve problems like \begin{lstlisting} -\SetupClass\MyVar{ % do not add these -- they are already predefined! - novalueskeys={ - {smash}{command=\smash}, - {tilde}{command=\tilde}, - {widetilde}{command=\widetilde}, - {bar}{command=\bar}, - {bold}{command=\mathbf}, - {roman}{command=\mathrm}, - }, +$ \va[lower=\vx[lower=3]] $ +\end{lstlisting} +Normally, this will not work, as the underlying keyval machinery +of \LaTeX3 does not allow key values to contain equality signs. +However, there is another keyval package that does: +the excellent package \pack{expkv}. +To switch to the keyval parser of this package, we do + +\begin{lstlisting} +\usepackage{expkv} +\SemantexSetup{ + keyvalparser=\ekvparse, } \end{lstlisting} -Let us test: +\SemantexSetup{ + keyvalparser=\ekvparse, +} +Now you can do \begin{LTXexample} -$\va[widetilde]$, -$\va[bold]$, -$\va[roman]$, -$\va[bar]$ +$ \va[lower=\vx[lower=3]] $ \end{LTXexample} +In general, +using the key +\mylst!keyvalparser={$\<command\>$}! +sets the keyval parser function to be the command~\<command\>. +The \<command\> must take three arguments: +\mylst!$\<command\>\<function\num{1}\>\<function\num{2}\>${$\<key-value list\>$}!. +The \<function\num{1}\> must take one argument, while \<function\num{2}\>~must take two. +For a key-value list, \<function\num{1}\>~will be applied to single keys taking no values, +while \<function\num{2}\>~will be applied to keys taking a value. By default, this key has been set to the command \lstinline!\keyval_parse:NNn! from~\LaTeX3. +Changing this key will only affect keys for objects and classes, +\emph{not} keys for use inside~\lstinline!\SemantexSetup!. + +\endgroup + +A more drastic solution is to use the package~\pack{stricttex}, +which has been developed mainly as a companion package to~\semantex. +Unfortunately, it only works in~\hologo{LuaTeX}. +If you don't know what \hologo{LuaTeX} is, that means that you are not +using \hologo{LuaTeX}, and you should note that switching is a rather drastic affair +since your existing font settings might very well not work +with LuaTeX. Also, \semantex does not exactly make your document faster, +and \hologo{LuaTeX} makes it even slower, so think carefully before you make the switch just for this. + +In any case, with \pack{stricttex}, you will be able to make brackets \enquote{strict}, which means that any \lstinline![! will be replaced +by a~\lstinline![{!, and that any~\lstinline!]! will be replaced +by a~\lstinline!}]!. This will make all of the above work just fine: +\begin{lstlisting} +\StrictBracketsOn +$ \va[lower=\vx[lower=3]] $ +$ \va[\vx[1,power=2]] $ +$ \vf{ \vg[upper=3,lower=2] } $ +\StrictBracketsOff +\end{lstlisting} +There is no demonstration on the right since this manual +has not been typeset using \hologo{LuaTeX}, so it would not work. \chapter{Example: Algebraic geometry} @@ -1051,7 +1313,7 @@ Let us discuss how to typeset sheaves and operations on morphisms in algebraic g First of all, adding commands for sheaves is not a big deal: \begin{lstlisting} \NewObject\MyVar\sheafF{\mathcal{F}} -\NewObject\MyVar\sheafG}{\mathcal{G}} +\NewObject\MyVar\sheafG{\mathcal{G}} \NewObject\MyVar\sheafH{\mathcal{H}} \NewObject\MyVar\sheafreg{\mathcal{O}} % sheaf of regular functions @@ -1063,7 +1325,7 @@ Next, for morphisms of schemes~\( \vf \colon \vX \to \vY \), we need to be able to typeset comorphisms as well as the one hundred thousand different pullback and pushforward operations. For this, we add some keys to the \lstinline!\MyVar! key: \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {comorphism}{upper=\#}, % comorphisms, i.e. f^{\#} {inverseimage}{upper={-1},nopar}, @@ -1080,7 +1342,7 @@ we need to be able to typeset comorphisms as well as the one hundred thousand di } \end{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {comorphism}{upper=\#}, % comorphisms, i.e. f^{\#} {inverseimage}{upper={-1},nopar}, @@ -1105,7 +1367,7 @@ comorphism~$ \vf[comorphism] and for a sheaf~$ \sheafF $ on~$ \vY $, we can define the pullback~$ \vf[sheafpull]{ \sheafF} $ by letting~$ -\vf[sheafpull]{ \sheafF}{\vU} = \cdots $ and the $ ! $-pullback by letting~$ +\vf[sheafpull]{\sheafF}{\vU} = \cdots $ and the $ ! $-pullback by letting~$ \vf[sheaf!pull]{\sheafF}{\vU} = \cdots $. \end{LTXexample} Maybe some people would write \lstinline!pull!, \lstinline!push!, etc.~instead, but there are many different kinds of pullbacks in mathematics, so I prefer to use the \lstinline!sheaf!~prefix to show that this is for sheaves. @@ -1116,33 +1378,30 @@ There are a number of other operations we might want to do for sheaves. We alrea However, we might need to stalk, sheafify, take dual sheaves, and twist sheaves. Let us define keys for this: \begin{lstlisting} \SetupClass\MyVar{ - valuekeys={ + definekeys[1]={ {stalk}{clower={#1}}, % "clower" means "comma lower", i.e. lower index % separated from any previous lower index by a comma {sheaftwist}{return,symbolputright={(#1)}}, }, - singlekeys={ + definekeys={ {sheafify}{upper=+}, {sheafdual}{upper=\vee}, }, } \end{lstlisting} \SetupClass\MyVar{ - valuekeys={ + definekeys[1]={ {stalk}{clower={#1}}, % "clower" means "comma lower", i.e. lower index % separated from any previous lower index by a comma {sheaftwist}{return,symbolputright={(#1)}}, }, - singlekeys={ + definekeys={ {sheafify}{upper=+}, {sheafdual}{upper=\vee}, }, } -The key \lstinline!clower! stands for \enquote{comma lower}. -It is like \lstinline!lower!, except that it checks whether the index -is already non-empty, and if so, it separates the new index from the previous index by a comma. There is, of course, a \lstinline!cupper!~key that does the same with the upper index. \begin{LTXexample} $\sheafF[res=\vU,stalk=\vp]$, $\sheafF[res=\vU,spar,stalk= @@ -1150,7 +1409,7 @@ $\sheafF[res=\vU,spar,stalk= $\sheafreg[\vX,stalk=\vp]$, $\sheafG[sheafify]$, $\vf[inverseimage]{\sheafreg[ -\vY]}[spar,stalk=\vx]$ +\vY]}[spar,stalk=\vx]$, $\sheafG[sheafdual]$, $\sheafreg[\vX][sheaftwist=-1]$, $\sheafreg[sheaftwist=1,sheafdual]$ @@ -1174,25 +1433,27 @@ $\Hom[\vA]{\vM,\vN}$, $\Ext[\vA]{\vM,\vN}$ \end{LTXexample} \SetupClass\MyVar{ -valuekeys={ - {shift}{ return,symbolputright={ \relax [ {#1} ] } }, - % \relax is necessary since otherwise [...] can - % occasionally be interpreted as an optional argument +definekeys[1]={ + {shift}{ rightreturn,symbolputright={ \relax [ {#1} ] } }, + % we use \lbrack and \rbrack rather than [ and ] since in some + % cases (using constructions like in @{\itshape\cref{ch:the_class_command}}@), + % the [...] might be interpreted as an optional argument. }, } You will probably need several keyval interfaces, some of which will be covered below. But right now, we shall implement a shift operation~\( \vX\mapsto\vX[shift=\vn] \): \begin{lstlisting} \SetupClass\MyVar{ - valuekeys={ - {shift}{ return,symbolputright={ \relax [ {#1} ] } }, - % \relax is necessary since otherwise [...] can - % occasionally be interpreted as an optional argument + definekeys[1]={ + {shift}{ rightreturn,symbolputright={ \lbrack #1 \rbrack } }, + % we use \lbrack and \rbrack rather than [ and ] since in some + % cases (using constructions like in @{\itshape\cref{ch:the_class_command}}@), + % the [...] might be interpreted as an optional argument. }, } \end{lstlisting} Let us see that it works: \begin{LTXexample} -$\vX\mapsto\vX[shift=\vn]$ +$\vX \mapsto \vX[shift=\vn]$ \end{LTXexample} Finally, let us define a command for the differential (in the homolgoical algebra sense): \begin{lstlisting} @@ -1203,38 +1464,37 @@ Finally, let us define a command for the differential (in the homolgoical algebr $\dif{\vx} = 0$ \end{LTXexample} -\section{The keys \texttt{i = index} and \texttt{d = deg = degree}} +\section{The \texttt{d}-index and the \texttt{i}-index} -Homological algebra is a place where people -have very different opinions about the positions of the gradings. +In branches of mathematics such as homological algebra, +people have very different opinions about the positions of the gradings. As an algebraist, I am used to \emph{upper} gradings (\enquote{cohomological} grading), whereas many topologists prefer \emph{lower} gradings (\enquote{homological} grading). The \semantex system -supports both, but the default is upper gradings (the package author has the privilege to decide). +supports both, but the default is upper gradings. You can adjust this by writing \lstinline!gradingposition=upper! or~\lstinline!gradingposition=lower!. -We already learned about the keys \lstinline!upper! and~\lstinline!lower!. -There are two more, \enquote{relative} keys that print the index either as an upper index or as a lower index, depending on your preference for cohomological or homological grading. They are called +We already learned about the keys \lstinline!upper! and~\lstinline!lower!, +as well as their friends \lstinline!supper!, \lstinline!slower!, \lstinline!cupper!, \lstinline!clower!, etc. +There also exist \enquote{relative} versions of these keys that print the index either as an upper index or as a lower index, depending on your preference for cohomological or homological grading. They are called \begin{center} - \lstinline!index! + \lstinline!d! \qquad\qquad and\qquad\qquad - \lstinline!degree! + \lstinline!i! \end{center} -The \lstinline!degree! is the actual grading in the homological algebra -sense. The \lstinline!index! is an additional index where you can put extra information that you might need. +and consequently, we shall refer to the indices +they correspond to as the \enquote{\lstinline!d!-index} and the \enquote{\lstinline!i!-index}. +The \lstinline!d! stands for \enquote{degree} and corresponds to +the grading. The~\lstinline!i! stands for \enquote{index} +and corresponds to the \enquote{other} index where you may store +additional information.\footnote{These names are not perfect; you might object that the degree is also an index, but feel free to come up with a more satisfactory naming principle, and I shall be happy to consider it.} + To understand the difference, keep the following two examples -in mind: the hom complex~\( \Hom[*,index=\vA] \) and the simplicial homology~\( \ho[*,index=\vDelta] \) (we will define the command~\lstinline!\ho! for homology in the next section): +in mind: the hom complex~\( \Hom[*,i=\vA] \) and the simplicial homology~\( \ho[*,i=\vDelta] \) (we will define the command~\lstinline!\ho! for homology in the next section): \begin{LTXexample} -$\Hom[index=\vA,degree=0]$, -$\ho[index=\vDelta,degree=1]$ +$\Hom[i=\vA,d=0]$, +$\ho[i=\vDelta,d=1]$ \end{LTXexample} -These names are not perfect; many people would say that the degree is also -an index, but feel free to come up with a more satisfactory naming principle, and I shall be happy to consider it. These names probably become a bit too heavy to write in the long run, so both keys have abbreviated equivalents: -\begin{center} - \lstinline!i! = \lstinline!index! - \qquad\qquad and\qquad\qquad - \lstinline!d! = \lstinline!deg! = \lstinline!degree! -\end{center} Let us see them in action: \begingroup\begin{LTXexample} $ \vX[d=3,i=\vk] $ @@ -1245,7 +1505,7 @@ $ \vX[d=3,i=\vk] $ $ \vX[d=3,i=\vk] $ \end{LTXexample}\endgroup -\noindent (We haven't seen the command \lstinline!\SetupObject! before, but I imagine you can guess what it does). +\noindent If you want to print a bullet as the degree, there is the predefined key~\lstinline!*! for this: \begingroup\begin{LTXexample} $ \vX[*] $ @@ -1257,7 +1517,7 @@ $ \vX[*] $ $ \vX[*] $ \end{LTXexample}\endgroup -I guess it is also time to reveal that the previously mentioned shorthand notation~\lstinline!\vx[1]! for indices always prints the~\lstinline!1! on the \lstinline{index} position. So changing the grading position changes the position of the index: +I guess it is also time to reveal that the previously mentioned shorthand notation~\lstinline!\vx[1]! for indices always prints the~\lstinline!1! in the \lstinline!i!-index. So changing the grading position changes the position of the index: \begingroup\begin{LTXexample} $ \vX[1] $ @@ -1267,7 +1527,7 @@ $ \vX[1] $ $ \vX[1] $ \end{LTXexample}\endgroup -In other words, in the first example above, we could have written +\noindent In other words, in the first example above, we could have written \begin{LTXexample} $\Hom[\vA,d=0]$, $\ho[\vDelta,d=1]$ @@ -1281,9 +1541,9 @@ $\vf[i]$, $\vf[i=]$, $\vf[d]$, $\vf[d=]$ \end{LTXexample} As we see, it is only when a \lstinline!d! or~\lstinline!i! key is followed by an equality sign~\lstinline!=! -that the routines of these keys are invoked. -In fact, \semantex carefully separates -\lstinline!valuekeys! from \lstinline!singlekeys!. +that the actions of these keys are invoked. +In fact, \semantex carefully separates keys taking +a value from keys taking no values. \section{The \texorpdfstring{\texttt{Cohomology}}{Cohomology} class type} @@ -1308,12 +1568,14 @@ Let us try to use it: \NewObject\MyHomology\ho{H} \end{lstlisting} -The cohomology command~\lstinline!\co! in general works very much +The cohomology command~\lstinline!\co! we just created works very much like a command of \lstinline!Variable! type. However, the input syntax is a bit different: \begin{lstlisting} -\co[⟨options⟩]{⟨degree⟩}{⟨argument⟩} +\co[@\<options\>@]{@\<degree\>@}{@\<argument\>@} \end{lstlisting} -All three arguments are optional. Let us see it in practice: +All three arguments are optional. The~\<degree\> is printed +in the \lstinline!d!-index. +Let us see it in practice: \begin{LTXexample} $\co{0}$, $\co{*}$, $\co{\vi}{\vX}$, @@ -1335,15 +1597,15 @@ You might also want to implement feature like reduced cohomology, \v{C}ech cohom and hypercohomology. This is quite easy with the \lstinline!command! key: \begin{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {reduced}{command=\widetilde}, {cech}{command=\check}, - {hyper{command=\mathbb}, + {hyper}{command=\mathbb}, }, } \end{lstlisting} \SetupClass\MyVar{ - singlekeys={ + definekeys={ {reduced}{command=\widetilde}, {cech}{command=\check}, {hyper}{command=\mathbb}, @@ -1375,7 +1637,7 @@ on the level of the function itself (\( \vf \)~in this case). This can be done the following way: \begin{lstlisting} \SetupClass\MyVar{ - valuekeys={ + definekeys[1]={ {Lder} { innerreturn,leftreturn, symbolputleft=\mathbb{L}^{#1}, @@ -1385,7 +1647,7 @@ This can be done the following way: symbolputleft=\mathbb{R}^{#1}, }, }, - singlekeys={ + definekeys={ {Lder} { innerreturn,leftreturn, symbolputleft=\mathbb{L}, @@ -1398,7 +1660,7 @@ This can be done the following way: } \end{lstlisting} \SetupClass\MyVar{ - valuekeys={ + definekeys[1]={ {Lder} { innerreturn,leftreturn, symbolputleft=\mathbb{L}^{#1}, @@ -1408,7 +1670,7 @@ This can be done the following way: symbolputleft=\mathbb{R}^{#1}, }, }, - singlekeys={ + definekeys={ {Lder} { innerreturn,leftreturn, symbolputleft=\mathbb{L}, @@ -1438,19 +1700,17 @@ except it allows you to inherit the settings from an \emph{object} rather than a $\RHom{\vX,\vY}$ \end{LTXexample} -\chapter{Keyval syntax in arguments (Example: Cohomology with coefficients)} +\chapter{Keyval syntax in arguments (Example: Cohomology with coefficients)}\label{ch:arg_keyval} \SetupClass\MyVar{ - argvaluekeys={ + defineargkeys[1]={ {coef}{ othersep={;}{#1} }, }, } \SetupObject\co{ - valuekeys={ - {arg}{argwithkeyval={#1}}, - }, -}% + argkeyval=true, +} Imagine we want to do cohomology with coefficients in some ring~\( \vR \). It is common to write this as~\( \co{*}{\vX,coef=\vR} \) @@ -1459,17 +1719,19 @@ with a semicolon instead of a comma. This can be implemented, too, with the synt $\co{*}{\vX,coef=\vR}$ \end{LTXexample} This shows that arguments of functions also support keyval syntax. -In order to customize this, there are two extra keys: -\begin{center} -\lstinline!argsinglekeys! -\qquad\qquad\text{and}\qquad\qquad -\lstinline!argvaluekeys! -\end{center} -These work exactly like \lstinline!singlekeys! and~\lstinline!valuekeys!. +To define argument keys, +we use the key~\lstinline!defineargkeys!, +or~\mylst!defineargkeys[$n$]! if you want it to be +able to take $n$~values for~$n=0,1,2,\ldots,9$. The syntax for these is +just like the syntax for the keys~\lstinline!definekeys! +and~\mbox{\mylst!definekeys[$n$]!}. +However, for reasons we shall see in a moment, argument +keys (at least those taking values) are actually turned off +by default, so we shall have to turn them on first: \begin{lstlisting} \SetupClass\MyVar{ argkeyval=true, % this turns keyval syntax in arguments on - argvaluekeys={ + defineargkeys[1]={ {coef}{ othersep={;}{#1} }, }, } @@ -1477,10 +1739,12 @@ These work exactly like \lstinline!singlekeys! and~\lstinline!valuekeys!. The key \lstinline!othersep! is a key that controls the separator between the current argument and the previous argument (it will only be printed if there was a previous argument). By default, this separator is a comma. So in the syntax~\lstinline!\co{*}{\vX,coef=\vR}!, there are two arguments, \lstinline!\vX! and~\lstinline!\vR!, and the separator is a semicolon. +We shall later (see~\cref{ch:parse_coho_coef}) +see another, possibly more natural way to write cohomology with coefficients, and which avoids turning on keyval syntax in the argument. -As you see above, we had to turn keyval syntax on in order for it to work. -By default, only singlekeys are turned on in the argument, not valuekeys. -The reason is that valuekeys in arguments are only useful in very rare cases, like cohomology with coefficients. If such keys were turned on in general, it would mess up +As mentioned, we had to turn keyval syntax on in order for it to work. +By default, only keys taking no values are turned on in the argument. +The reason is that argument keys taking values are only useful in very rare cases, such as cohomology with coefficients. If such keys were turned on in general, it would mess up every occurrence of an equality sign in arguments, and the following would not work: \begin{LTXexample} @@ -1490,97 +1754,142 @@ $\Hom[\sheafreg[\vU]]{ }$ \end{LTXexample} -The key~\lstinline!argkeyval! can take four arguments: \lstinline!true! (as above), -\lstinline!false! (no singlekeys or valuekeys allowed), \lstinline!singlekeys! (the default behaviour where only singlekeys are turned on), and \lstinline!onesinglekey! (only allows one singlekey). +The key~\lstinline!argkeyval! can take four arguments: \lstinline!true! (which we used above, keyval syntax is completely on), +\lstinline!false! (no keys allowed), \lstinline!singlekeys! (the default behaviour where only keys taking no values are allowed), and \lstinline!onesinglekey! (only allows one key, taking no value). It should be noted that there are several predefined -singlekeys which are defined on the level -of the class \lstinline!\SemantexBaseObject!. The full list is:\fxfatal{Finish this} +argument keys on the level +of the class \lstinline!\SemantexBaseObject!. +The full list can be found in \cref{sec:predefined_arg_keys}. -\begin{itemize} - \item slot, \ldots -\end{itemize} +\chapter{Left indices} -We should also talk about the \lstinline!arg! key. +Left indices are a recurring problem in all \TeX-based systems +since \TeX\ only has metrics for the positioning of right indices, none for left indices. And it seems that even the later \TeX\ engines are making no attempts at correcting this. So most packages for left indices +use variations of the following approach: +\begin{LTXexample} +$ {}^{*} f $ +\end{LTXexample} +Notice the large space between the star and the~\( f \). +To tackle this problem, the author has written +the \pack{leftindex} package which at least attempts to improve +this situation: +\begin{LTXexample} +$ \leftindex^{*} {f} $ +\end{LTXexample} +Roughly, what it does is to use a \enquote{height phantom} +and a \enquote{slanting phantom} to position the left superscript. +The vertical positions of the left indices will be calculated using +the height phantom, and the indentation of the left superscript will be calculated +using the slanting phantom. More precisely, it will copy the metrics for the positioning of right indices from the slanting phantom and use that to position the left superscript. By default, both phantoms are set to be equal to the symbol, which goes fine sometimes, and at other times, another slanting phantom has to be specified. Below, the~\lstinline!I!~is the specified, custom slanting phantom: +\begin{LTXexample} +$ \leftindex^{*} {\Gamma} $, +$ \leftindex[I]^* {\Gamma} $, +$ \leftindex^* {A} $, +$ \leftindex[P]^* {A} $ +\end{LTXexample} +We refer to the manual of the package \pack{leftindex} for details, +see~\url{https://ctan.org/pkg/leftindex}. -\chapter{Multi-value keys} +Our solution for left indices in \semantex is based directly on the one +from \pack{leftindex}. However, it works much better if you use \semantex +than if you just used \pack{leftindex} alone, due to the ability to centrally control all your notation. This allows you to choose height and slanting phantoms once and for all in the preamble and never have to worry about it in your document body. -\SetupClass\MyVar{ - 2valuekeys={ - {projquotient}{ symbolputright={ /\!\!/ _ { #1 } #2 } }, - } -} +Just like we have keys like \lstinline!upper!, \lstinline!lower!, \lstinline!supper!, \lstinline!slower!, \lstinline!cupper!, \lstinline!clower!, +etc., we have a similar collection of keys for the left +indices: +\lstinline!upperleft!, \lstinline!lowerleft!, \lstinline!supperleft!, \lstinline!slowerleft!, \lstinline!cupperleft!, \lstinline!clowerleft!: +\begin{LTXexample} +$ \vf[upperleft=*] $, +$ \vGamma[upperleft=*] $, +$ \vA[upperleft=*] $ +\end{LTXexample} +When you create a new object in \semantex, the height and slanting phantoms +will automatically be set to be equal to the symbol. However, as we see +above, we sometimes need to change them. +This can be done using the keys \lstinline!heightphantom! +and~\lstinline!slantingphantom!: +\begin{LTXexample} +\SetupObject\vGamma{ + slantingphantom=I} +\SetupObject\vA{slantingphantom=P} +$ \vf[upperleft=*] $, +$ \vGamma[upperleft=*] $, +$ \vA[upperleft=*] $ +\end{LTXexample} -Sometimes, a key with one value is simply not enough. For instance, if you -work in~GIT, you will eventually have to take the proj -quotient~\( \vX[projquotient={\vchi}{\vG}] \) of~\( \vX \) with respect to the action of the group~\( \vG \) and the character~\( \vchi \). In other words, the proj quotient depends on two parameters, \( \vchi \) and~\( \vG \). For this purpose, we have the key~\lstinline!2valuekeys!. It works exactly like \lstinline!valuekeys!, except you get to use two arguments instead of one: -\begin{lstlisting} -\SetupClass\MyVar{ - 2valuekeys={ - {projquotient}{ symbolputright={ /\!\!/ _ { #1 } #2 } }, - } +Sometimes, changing the slanting phantom is not quite enough. +In the previous example, the star is still not quite close enough +to the~\( \vA \), and there is no slanting phantom that is quite slanted enough to correct this. We solve this using +the key~\lstinline!postupperleft!. What you add using this key +will be printed after the upper left index, provided the upper left index +is non-empty and hence will be printed in the first place. +There is also a \lstinline!preupperleft!, and there are similarly \lstinline!prelowerleft!, \lstinline!postlowerleft!, \lstinline!preupper!, \lstinline!postupper!, \lstinline!prelower!, and~\lstinline!postlower!. +Let us see it in action: +\begin{LTXexample} +\SetupObject\vA{ + slantingphantom=P, + postupperleft=\!, } -\end{lstlisting} - +$ \vA[upperleft=*] $ +\end{LTXexample} +Note that \semantex at least does its best to try to guess +new height and slanting phantoms when you use operations on objects: \begin{LTXexample} -$\vX[projquotient={\vchi}{\vG}] $ +$ \vA[spar=\Bigg,upperleft=*] $, +$ \vP[command=\overline,return, + upperleft=*] $ \end{LTXexample} -There are also commands \lstinline!3valuekeys!, \lstinline!4valuekeys!, \ldots, \lstinline!9valuekeys!. The syntax for these is completely analoguous. -There are also commands \lstinline!arg2valuekeys!, \lstinline!arg3valuekeys!, \ldots, \lstinline!arg9valuekeys! for keys in arguments with multiple values. +\chapter{The \texorpdfstring{\texttt{Symbol}}{Symbol} class type (Example: Derived tensor products and fibre products)} -\chapter{The \texttt{Simple} class type (Example: Derived tensor products and fibre products)} - -\NewSimpleClass\MyBinaryOperator[ - singlekeys={ +\NewSymbolClass\MyBinaryOperator[ + definekeys={ {Lder}{upper=L}, {Rder}{upper=R}, }, - mathbin, % this makes sure that the output is wrapped in \mathbin ] \NewObject\MyBinaryOperator\tensor{\otimes}[ - singlekeys={ + definekeys={ {der}{Lder}, }, ] \NewObject\MyBinaryOperator\fibre{\times}[ % Americans are free to call it \fiber instead - singlekeys={ + definekeys={ {der}{Rder}, }, ] -The \semantex system has facilities for printing tensor products~\( \tensor \) as well as derived tensor products~\( \tensor[der] \). -For this, we need the \lstinline!Simple! class type. +\semantex has facilities for printing tensor products~\( \tensor \) as well as derived tensor products~\( \tensor[der] \). +For this, we need the \lstinline!Symbol! class type. This has exactly the same syntax as the \lstinline!Variable! class type, except that it cannot take an argument. In other words, its syntax is \begin{lstlisting} -\⟨object⟩[⟨options⟩] +@\usercommand\<object\>@[@\<options\>@] \end{lstlisting} -(You should normally only use it for special constructions like binary operators and not for e.g.\ variables -- the ability to add arguments to variables comes in handy much more often than one might imagine.) +You should normally only use it for special constructions like binary operators and not for e.g.\ variables -- the ability to add arguments to variables comes in handy much more often than one might think. Let us try to use it to define tensor products and fibre products: \begin{lstlisting} -\NewSimpleClass\MyBinaryOperator[ - singlekeys={ +\NewSymbolClass\MyBinaryOperator[ + definekeys={ {Lder}{upper=L}, {Rder}{upper=R}, }, - mathbin, - % this makes sure that the output is wrapped in \mathbin ] \NewObject\MyBinaryOperator\tensor{\otimes}[ - singlekeys={ + definekeys={ {der}{Lder}, }, ] \NewObject\MyBinaryOperator\fibre{\times}[ % Americans are free to call it \fiber instead - singlekeys={ + definekeys={ {der}{Rder}, }, ] @@ -1596,83 +1905,6 @@ $\vk \tensor[\vA,der] \vk$, $\vX \fibre[\vY,der] \vX$ \end{LTXexample} -\chapter{Class types} - -The \semantex system uses several different \emph{class types}. -We have been almost exclusively using the \lstinline!Variable! class type (which is by far the most important one), but in the last chpaters, we were introduced to the \lstinline!Cohomology! and the \lstinline!Simple! class types. - -In fact, all class types are identical internally; the low-level machinery of \semantex does not \enquote{know} what type a class has. -The only difference between the class types is the \emph{input syntax}. -In other words, it determines which arguments an object of that class -can take. The syntax for creating new objects -also varies. - -The current implementation has the following -class types: - -\begin{itemize} - \item \lstinline!Variable!: - A new class is declared with the - syntax - \begin{lstlisting} - \NewVariableClass{\⟨Class⟩}[⟨options⟩] - \end{lstlisting} - A new object is declared by - \begin{lstlisting} - \NewObject\⟨Class⟩\⟨object⟩{⟨symbol⟩}[⟨options⟩] - \end{lstlisting} - The syntax for this object is - \begin{lstlisting} - \⟨object⟩[⟨options⟩]{⟨argument⟩} - \end{lstlisting} - \item \lstinline!Cohomology!: - A new class is declared with the - syntax - \begin{lstlisting} - \NewCohomologyClass\⟨Class⟩[⟨options⟩] - \end{lstlisting} - A new object is declared by - \begin{lstlisting} - \NewObject\⟨Class⟩\⟨object⟩{⟨symbol⟩}[⟨options⟩] - \end{lstlisting} - The syntax for this object is - \begin{lstlisting} - \⟨object⟩[⟨options⟩]{⟨degree⟩}{⟨argument⟩} - \end{lstlisting} - \item \lstinline!Simple!: - A new class is declared with the - syntax - \begin{lstlisting} - \NewSimpleClass\⟨Class⟩[⟨options⟩] - \end{lstlisting} - A new object is declared by - \begin{lstlisting} - \NewObject\⟨Class⟩\⟨object⟩{⟨symbol⟩}[⟨options⟩] - \end{lstlisting} - The syntax for this object is - \begin{lstlisting} - \⟨object⟩[⟨options⟩]{⟨argument⟩} - \end{lstlisting} - \item \lstinline!Delimiter!: - A new class is declared with the syntax - \begin{lstlisting} - \NewDelimiterClass\⟨Class⟩[⟨options⟩] - \end{lstlisting} - A new object is declared by - \begin{lstlisting} - \NewObject\⟨Class⟩\⟨object⟩{⟨left bracket⟩}{⟨right bracket⟩}[⟨options⟩] - \end{lstlisting} - The syntax for this object is - \begin{lstlisting} - \⟨object⟩[⟨options⟩]{⟨argument⟩} - \end{lstlisting} -\end{itemize} - -Let me add that \semantex uses a very clear separation between the input syntax and the underlying machinery. Because of this, if the user needs a different kind of class type, it is not very hard to create one. You must simply open the source code of \semantex, find the class you want to modify, and then copy the definition of the command~\lstinline!\New⟨Class type⟩Class! and modify it in whatever way you want. - -There is another class type, called the \lstinline!plain! class type, which is the class -type of the class~\lstinline!\SemantexBaseObject!. This class is pretty useless as all it does is print its symbol, without allowing any keyval syntax, so don't use it. - \chapter{The \texorpdfstring{\texttt{Delimiter}}{Delimiter} class type} \NewDelimiterClass\MyDelim[parent=\MyVar] @@ -1686,7 +1918,7 @@ that are defined using brackets only. Let us define a class of type \lstinline!D \end{lstlisting} Now we can create instances of the class~\lstinline!\MyDelim! with the following syntax: \begin{lstlisting} -\NewObject\MyDelim\⟨object⟩{⟨left bracket⟩}{⟨right bracket⟩}[⟨options⟩ +\NewObject\MyDelim@\usercommand\<object\>@{@\<left bracket\>@}{@\<right bracket\>@}[@\<options\>@] \end{lstlisting} Now we can do the following: \begin{lstlisting} @@ -1712,11 +1944,9 @@ The following is inspired from the \pack{mathtools} package where a similar cons \NewObject\MyDelim\Set{\lbrace}{\rbrace}[ prearg={\,},postarg={\,}, - % adds \, inside {...}, as recommended by D. Knuth - valuekeys={ - {arg}{argwithoutkeyval={#1}}, + % adds \, inside {...}, as recommended by D. Knuth + argkeyval=false, % this turns off all keyval syntax in the argument - } ] \end{lstlisting} \newcommand\where{ @@ -1729,25 +1959,28 @@ The following is inspired from the \pack{mathtools} package where a similar cons \NewObject\MyDelim\Set{\lbrace}{\rbrace}[ prearg={\,},postarg={\,}, - % adds \, inside {...}, as recommended by D. Knuth - valuekeys={ - {arg}{argwithoutkeyval={#1}}, + % adds \, inside {...}, as recommended by D. Knuth + argkeyval=false, % this turns off all keyval syntax in the argument - } ] +As we briefly mentioned previously, +\lstinline!\SemantexDelimiterSize!~is a command +that returns the size of the delimiters in the +argument. Now you can use \begin{LTXexample} -$\Set{ \vx \in \vY \where -\vx \ge 0 }$ +$\Set{ \vx\in\vY \where \vx\ge0 }$, +$\Set[par=\big]{ \vx\in\vY \where \vx\ge0 }$ \end{LTXexample} -Don't forget that anything created with \semantex -outputs as a variable-type object. So you can do stuff like +Don't forget that, since the class~\lstinline!\MyDelim! inherits from~\lstinline!\MyVar!, +the output of any of these commands has class~\lstinline!\MyVar!. +So you can do stuff like \begin{LTXexample} $\Set{ \vx \in \vY[\vi] \where \vx \ge 0 -}[conj,\vi\in\vI]$ +}[command=\overline,\vi\in\vI]$ \end{LTXexample} @@ -1772,14 +2005,15 @@ $\tup{\va,\vb,...,\vz}$, $\pcoor{\va,\vb,...,\vz}$ \end{LTXexample} -One can also use tuples for other, less obvious purposes, like calculus differentials: +One can also use delimiters for other, less obvious purposes, like calculus differentials: \begin{lstlisting} \NewDelimiterClass\CalculusDifferential[ parent=\MyVar, - argvaluekeys={ + defineargkeys[1]={ {default}{s={d\!#1}}, % default is the key that is automatically applied by the - % system to anything you write in the argument. The s key + % system to anything you write in the argument that is + % not recognized as an argument key. The s key % is a key that prints the value of the key with the % standard argument separator in front. }, @@ -1790,14 +2024,25 @@ One can also use tuples for other, less obvious purposes, like calculus differen % -- neverpar does not even print parentheses in this case ] -\NewObject\CalculusDifferential\intD{(}{)}[setargsep={\,},iffirstarg=false] +\NewObject\CalculusDifferential\intD{(}{)}[ + setargsep={\,}, + nextargwithsep=true, + % because of this, even the first argument will + % receive a separator, which in this case + % is a small space +] \NewObject\CalculusDifferential\wedgeD{(}{)}[setargsep=\wedge] \end{lstlisting} \NewDelimiterClass\CalculusDifferential[ parent=\MyVar, - argvaluekeys={ + defineargkeys[1]={ {default}{s={d\!#1}}, + % default is the key that is automatically applied by the + % system to anything you write in the argument that is + % not recognized as an argument key. The s key + % is a key that prints the value of the key with the + % standard argument separator in front. }, setargdots=\cdots, neverpar, @@ -1806,7 +2051,7 @@ One can also use tuples for other, less obvious purposes, like calculus differen % -- neverpar does not even print parentheses in this case ] -\NewObject\CalculusDifferential\intD{(}{)}[setargsep={\,},ifnextargwithsep=false] +\NewObject\CalculusDifferential\intD{(}{)}[setargsep={\,},nextargwithsep=true] \NewObject\CalculusDifferential\wedgeD{(}{)}[setargsep=\wedge] @@ -1818,35 +2063,218 @@ $\int \vf \wedgeD{\vx[1], \vx[2],...,\vx[n]}$ \end{LTXexample} -\chapter{The \texttt{parse} routine} +\chapter{Using \texorpdfstring{Seman\!\TeX}{SemanTeX} in other commands using \texorpdfstring{\texttt{\textbackslash UseClassInCommand}}{\UseClassInCommand}}\label{sec:UseClassInCommand} -As you can see above, \semantex has a \enquote{waterfall-like} behaviour. It runs keys in the order it receives them. This works fine most of the time, but for some more complicated constructions, it is useful to be able to provide a data set in any order and have them printed in a fixed order. For this purpose, we have the \lstinline!parse! routine. +\SemantexRecordObject{\Frac} +\newcommand\Frac[2]{ + \SemantexRecordSource{\Frac{#1}{#2}} + \UseClassInCommand\MyVar{ \frac{#1}{#2} } +} +Sometimes, it is useful to create other commands based on \semantex +classes. For instance, if you grow tired of +writing~\lstinline!\MyVar{ \frac{...}{...} }! whenever you +want to apply keys to a fraction, it could make sense to create +a command~\lstinline!\Frac! which automatically wraps +the fraction in~\lstinline!\MyVar!. The first guess how to +do that would be something like +\begin{lstlisting} +\newcommand\Frac[2]{ \MyVar{ \frac{#1}{#2} } } +\end{lstlisting} +\begin{LTXexample} +\[ + \Frac{1}{2}[spar=\Big,power=2] +\] +\end{LTXexample} +Indeed, this will work fine for most people. +In fact, the only case where this might cause issues +is if you want to use the \pack{stripsemantex} algorithm to strip +your document of \semantex markup. But in order to prepare yourself for this possibility, I recommend getting used from the start to doing it +in a slightly more cumbersome way: +\begin{lstlisting} +\SemantexRecordObject{\Frac} +\newcommand\Frac[2]{ + \SemantexRecordSource{\Frac{#1}{#2}} + \UseClassInCommand\MyVar{ \frac{#1}{#2} } +} +\end{lstlisting} +\begin{LTXexample} +\[ + \Frac{1}{2}[spar=\Big,power=2] +\] +\end{LTXexample} +First things first: We used the following command in front +of~\lstinline!\MyVar!: +\begin{lstlisting} +\UseClassInCommand@\usercommand\<Class\>@[@\<options\>@]{@\<symbol\>@}@\<usual syntax of the class\>@ +\end{lstlisting} +So the first advantage to writing~\lstinline!\UseClassInCommand\MyVar! +instead of just~\lstinline!\MyVar! +is that you can pass an additional set of options +to the class first. However, there is a more important +difference, namely that this solution makes the command +compatible with the \pack{stripsemantex} algorithm. + +The reason the first solution was not compatible +with \pack{stripsemantex} is that, in this case, the algorithm +will desperately look through your document for +the code~\lstinline!\MyVar{ \frac{1}{2} }[spar=\Big,power=2]! +in order to strip it from your document. +But it will find it nowhere, as this code is hidden away +in the \lstinline!\Frac!~command. +Therefore, we do three things: +\begin{itemize} + \item We register the command~\lstinline!\Frac! + as a \semantex command using the + line + \begin{lstlisting} +\SemantexRecordObject{\Frac} + \end{lstlisting} + After this, \semantex \enquote{knows} + that \lstinline!\Frac!~is part of the + family of \semantex markup. + \item We use the command~\lstinline!\SemantexRecordSource! + to \enquote{record} the source of the command internally. + This way, \pack{stripsemantex} will know what to look for + when it moves through the document, trying to strip + it of \semantex markup. + It is therefore important that you record + the source exactly like it will be written in + the source. + (You need not worry about missing braces, though; + even if you write~\lstinline!\Frac12! in your document, + \pack{stripsemantex} will still recognize the code + and strip it as expected.) + \item We write~\lstinline!\UseClassInCommand\MyVar! + instead of just~\lstinline!\MyVar! + in order to correctly record the output code internally. Roughly speaking, when you use the command~\lstinline!\UseClassInCommand!, + \semantex \enquote{knows} that the class~\lstinline!\MyVar! + is now used as part of some greater construction. +\end{itemize} + +\section{Example: Category theory} + +\newcommand\categoryformat[1]{\textsf{#1}} + % This means that we write categories with sans-serif fonts; + % -- but you can change this to your own liking + % We use \textsf rather than \mathsf in order + % to allow syntax like $R$-mod + +\NewVariableClass{\Category}[parent=\MyVar,command=\categoryformat] + +\NewObject\Category\catset{Set} +\NewObject\Category\cattop{Top} +\NewObject\Category\catvect{Vect} + +\SemantexRecordObject{\catxmod} +\newcommand\catxmod[1]{ + \SemantexRecordSource{\catxmod{#1}} + \UseClassInCommand\Category{$#1$-mod} +} + +\SemantexRecordObject{\catmodx} +\newcommand\catmodx[1]{ + \SemantexRecordSource{\catmodx{#1}} + \UseClassInCommand\Category{mod-$#1$} +} + +\SemantexRecordObject{\catxmody} +\newcommand\catxmody[2]{ + \SemantexRecordSource{\catxmody{#1}{#2}} + \UseClassInCommand\Category{$#1$-mod-$#2$} +} + +\SemantexRecordObject{\catxmodx} +\newcommand\catxmodx[1]{ + \SemantexRecordSource{\catxmodx{#1}} + \UseClassInCommand\Category{$#1$-mod-$#1$} +} + +The above method can be used to create commands +for typing categories. First and foremost, +it is easy to create a class for categories +and write simple categories like~\( \catset \), \( \cattop \)~and \( \catvect \): +\begin{lstlisting} +\newcommand\categoryformat[1]{\textsf{#1}} + % This means that we write categories with sans-serif fonts; + % -- but you can change this to your own liking. + % We use \textsf rather than \mathsf in order + % to allow syntax like $R$-mod + +\NewVariableClass{\Category}[parent=\MyVar,command=\categoryformat] + +\NewObject\Category\catset{Set} +\NewObject\Category\cattop{Top} +\NewObject\Category\catvect{Vect} +\end{lstlisting} +\begin{LTXexample} +$ \catset $, +$ \cattop $, +$ \catvect{\vk} $. +\end{LTXexample} +However, we run into issues with categories like~\( \catxmod{\vR} \) +where we shall constantly have to change the ring~\( \vR \). +For this, we use the constructions we learned at the introduction +to this chapter: +\begin{lstlisting} +\SemantexRecordObject{\catxmod} +\newcommand\catxmod[1]{ + \SemantexRecordSource{\catxmod{#1}} + \UseClassInCommand\Category{$#1$-mod} +} +\end{lstlisting} +\begin{LTXexample} +$ \catxmod{\vR} $, +$ \catxmod{\vS} $, +$ \catxmod{\vA}[spar,op] $ +\end{LTXexample} +(here, we used the key~\lstinline!op! +which we defined in \cref{sec:algebra}). +You can, of course, extend it to all sorts +of other situations, like +\( \catmodx{\vR} \) or~\( \catxmody{\vR}{\vS} \): +\begin{lstlisting} +\SemantexRecordObject{\catmodx} +\newcommand\catmodx[1]{ + \SemantexRecordSource{\catmodx{#1}} + \UseClassInCommand\Category{mod-$#1$} +} + +\SemantexRecordObject{\catxmody} +\newcommand\catxmody[2]{ + \SemantexRecordSource{\catxmody{#1}{#2}} + \UseClassInCommand\Category{$#1$-mod-$#2$} +} + +\SemantexRecordObject{\catxmodx} +\newcommand\catxmodx[1]{ + \SemantexRecordSource{\catxmodx{#1}} + \UseClassInCommand\Category{$#1$-mod-$#1$} +} +\end{lstlisting} + +\chapter{The \texorpdfstring{\texttt{parse}}{parse} routine} -Suppose we want to be able to write the set of \( \vn \times \vm \)-matrices with entries in~\( \vk \) as~\( \MyVar{\operatorname{Mat}}[\vn\times\vm]{\vk} \). We can in principle do the following: -\begingroup\begin{LTXexample} -\NewObject\MyVar\Mat{ - \operatorname{Mat}} -$ \Mat[\vn\times\vm]{\vk} $. -\end{LTXexample}\endgroup% \NewObject\MyVar\Mat{\operatorname{Mat}}[ % We provide data sets "rows" and "columns" to % be set up by the user later dataprovide={rows}, dataprovide={columns}, - valuekeys={ + dataprovide={field}, + definekeys[1]={ {rows}{ dataset={rows}{#1} }, % set the rows data set {columns}{ dataset={columns}{#1} }, % set the columns data set + {field}{ dataset={field}{#1} }, % set the underlying field + {arg}{ field={#1} }, + % this way, setting the argument becomes equivalent + % to specifying the underlying field }, parseoptions={ % Here we add code to the parse routine % We check whether columns = rows. If so, we only write % the number once - ifeqTF={\SemantexDataGetExpNot{columns}}{\SemantexDataGetExpNot{rows}} + strifeqTF={\SemantexDataGetExpNot{columns}}{\SemantexDataGetExpNot{rows}} { - % We use a very weird key called "setkeysx" -- this - % fully executes the content of the keys before - % setting them setkeysx={ lower={\SemantexDataGetExpNot{columns}}, }, @@ -1860,35 +2288,190 @@ $ \Mat[\vn\times\vm]{\vk} $. }, }, }, + ifblankF={\SemantexDataGetExpNot{field}} + { + setargkeysx={ + s={\SemantexDataGetExpNot{field}}, + }, + }, + }, +] + + +\NewObject\MyVar\GL{\operatorname{GL}}[ + % We provide a few data sets: + dataprovide=order, % The "order" will be the number n in GL_n(k) + dataprovide=field, % The "field" is of course the k in GL_n(k) + definekeys[1]={ + {order}{ dataset={order}{#1} }, % Sets the order + {field}{ dataset={field}{#1} }, % Sets the field + {arg}{ field={#1} }, + % This way, setting the argument becomes equivalent + % to setting the field }, -]% -\noindent However, this is not quite as systematic and semantic as we might have wanted. Indeed, what if later you would like to change the notation to~\( \MyVar{\operatorname{Mat}}[\vn,\vm]{\vk} \)? (In this case, you could use multi-value keys, though.) -In this chapter, we show how to eanble a syntax like the following instead: + parseoptions={ + setkeysx={ + % This means set the keys, but fully expand their values first + lower={\SemantexDataGetExpNot{order}}, + }, + ifblankF={\SemantexDataGetExpNot{field}} + { + setargkeysx={ + % Set the argument keys, but fully expand their values first + s={\SemantexDataGetExpNot{field}}, + }, + }, + }, +] + +\SetupObject\co{ + dataprovide=coefficient, + dataprovide=space, + definekeys[1]={ + {coef}{ dataset={coefficient}{#1} }, + {space}{ dataset={space}{#1} }, + {arg}{ space={#1} }, + }, + parseoptions={ + ifblankF={\SemantexDataGetExpNot{space}} + { + setargkeysx={ + s=\SemantexDataGetExpNot{space}, + }, + }, + ifblankF={\SemantexDataGetExpNot{coefficient}} + { + setargkeysx={ + othersep={;}{ \SemantexDataGetExpNot{coefficient} }, + }, + }, + }, +} + +As you can see above, \semantex has a \enquote{waterfall-like} behaviour. It runs keys in the order it receives them. This works fine most of the time, but for some more complicated constructions, it is useful to be able to provide a collection of data in any order, +and have the system take care of printing them in the right places, +according to how you program the object in the preamble. +For this purpose, we have the \lstinline!parse!~routine. +Using the \lstinline!parse! routine allows for a comfortable, +HTML-like syntax, e.g.: \begin{LTXexample} -$ \Mat[rows=\vn,columns=\vm]{\vk} $, $ \Mat[rows=\vn,columns=\vn]{\vk} $ +$ \GL[order=\vn,field=\vk] $, +$ \Mat[rows=\vm,columns=\vn, + field=\vk] $, +$ \co[d=0,coef=\vR,space=\vX] $ \end{LTXexample} +The \lstinline!parse! routine is a collection of code which is +executed right before +an object (or class) is being rendered (but before it outputs). +By default, the parse routine contains no code. +However, you can add code to it using the +key~\mylst!parseoptions={$\<keys\>$}!. + +\section{Example: Matrix sets and groups} + +Suppose we want to be able to write the group of invertible \( \vn \times \vn \)-matrices with entries in~\( \vk \) +as~\( + \GL[order=\vn,field=\vk] +\). +We can in principle do the following: +\begingroup +\SetupObject\GL{ + dataclear=parseoptions, + definekeys[1]={ + {arg}{ setargkeys={s=#1} } + }, +} +\begin{lstlisting} +\NewObject\MyVar\GL{\operatorname{GL}} +\end{lstlisting} +\begin{LTXexample} +$ \GL[\vn]{\vk} $. +\end{LTXexample}% +However, this is not quite as systematic and semantic as we might have wanted. Indeed, what if later we would like to change the notation +to~\( + \GL{\vn,\vk} +\)? +We could in principle use a key with 2~values for this. +However, in this section, +we show how to use the \lstinline!parse!~routine +to enable the syntax from the introduction to this chapter. + +\endgroup + +As mentioned there, we need to add code via the \lstinline!parse!~routine. +However, to make proper use of it, we need some programming keys +and programming commands. +You can find an overview of these in~\cref{sec:programming_keys,sec:programming_commands}. + +To set up the notation from above, we do the following: +\begin{lstlisting} +\NewObject\MyVar\GL{\operatorname{GL}}[ + % We provide a few data sets: + dataprovide=order, % The "order" will be the number n in GL_n(k) + dataprovide=field, % The "field" is of course the k in GL_n(k) + definekeys[1]={ + {order}{ dataset={order}{#1} }, % Sets the order + {field}{ dataset={field}{#1} }, % Sets the field + {arg}{ field={#1} }, + % This way, setting the argument becomes equivalent + % to setting the field + }, + parseoptions={ + setkeysx={ + % This means set the keys, but fully expand their values first + lower={\SemantexDataGetExpNot{order}}, + }, + ifblankF={\SemantexDataGetExpNot{field}} + { + setargkeysx={ + % Set the argument keys, but fully expand their values first + s={\SemantexDataGetExpNot{field}}, + }, + }, + }, +] +\end{lstlisting} + +Notice that we changed the \lstinline!arg!~key. +This means that specifying the argument becomes equivalent to setting the field. +This is what makes the first two pieces of syntax below equivalent: + +\begin{LTXexample} +$ \GL[order=\vn,field=\vk] $, +$ \GL[order=\vn]{\vk} $, +$ \GL[order=\vn] $. +\end{LTXexample} + +Let us look at a more complicated example: +The set~\( \Mat[rows=\vn,columns=\vm,field=\vk] \) +of \( \vn \times \vm \)-matrices with entries in~\( \vk \). +What makes this example more complicated is not only that we have +an additional piece of data, but that we require +that if the number of rows and columns are equal, +we want it to print~\( \Mat[rows=\vn,columns=\vn,field=\vk] \) +rather than~\( \Mat[rows=\vn,columns={}\vn,field=\vk] \). +We accomplish this by the following: -The important ingredient here is the \lstinline!parse! routine. This routine is executed right before the function is being rendered, and you can add code to it via the -key~\lstinline!parseoptions!. However, we need a bit more programming keys to make it work. Let us see it in action and explain the syntax below: \begin{lstlisting} \NewObject\MyVar\Mat{\operatorname{Mat}}[ % We provide data sets "rows" and "columns" to % be set up by the user later dataprovide={rows}, dataprovide={columns}, - valuekeys={ + dataprovide={field}, + definekeys[1]={ {rows}{ dataset={rows}{#1} }, % set the rows data set {columns}{ dataset={columns}{#1} }, % set the columns data set + {field}{ dataset={field}{#1} }, % set the underlying field + {arg}{ field={#1} }, + % this way, setting the argument becomes equivalent + % to specifying the underlying field }, parseoptions={ % Here we add code to the parse routine % We check whether columns = rows. If so, we only write % the number once - ifeqTF={\SemantexDataGetExpNot{columns}} - {\SemantexDataGetExpNot{rows}} + strifeqTF={\SemantexDataGetExpNot{columns}}{\SemantexDataGetExpNot{rows}} { - % We use a very weird key called "setkeysx" -- this - % fully executes the content of the keys before - % setting them setkeysx={ lower={\SemantexDataGetExpNot{columns}}, }, @@ -1902,102 +2485,62 @@ key~\lstinline!parseoptions!. However, we need a bit more programming keys to ma }, }, }, + ifblankF={\SemantexDataGetExpNot{field}} + { + setargkeysx={ + s={\SemantexDataGetExpNot{field}}, + }, + }, }, ] \end{lstlisting} -Here we used a lot of programmking keys. Let us see the full list of them. -(An important notice: For some of these keys, such as \lstinline!boolifTF!, you currently cannot use spaces in the \lstinline!⟨bool⟩! argument, so e.g. \lstinline!boolifTF{ mybool } { ... } { ... }! will not work; you have to write \lstinline!boolifTF{mybool}!. I am trying to solve this problem, but have not yet been able to do so.) - -\begin{lstlisting} -dataprovide={⟨data⟩}, % provides data -dataset={⟨data⟩}{⟨value⟩}, % sets data -datasetx={⟨data⟩}{⟨value⟩}, % sets data after expanding it -dataputright={⟨data⟩}{⟨value⟩}, % adds to the right of data -dataputrightx={⟨data⟩}{⟨value⟩}, % adds to the right of data after expanding it -dataputleft={⟨data⟩}{⟨value⟩}, % adds to the left of data -dataputleftx={⟨data⟩}{⟨value⟩}, % adds to the left of data after expanding it -dataclear={⟨data⟩,} % clears a piece of data -setkeys={⟨keys⟩}, % sets the keys in question, which is rather useless since you could have just written those keys directly instead -keysset={⟨keys⟩}, % equivalent to setkeys -setkeysx={⟨keys⟩}, % executes the keys in question after expanding them -keysset={⟨keys⟩}, % equivalent to setkeysx -ifeqTF={⟨str1⟩}{⟨str2⟩}{⟨if true⟩}{⟨if false⟩}, % checks if strings are equal -ifeqT={⟨str1⟩}{⟨str2⟩}{⟨if true⟩}, -ifeqF={⟨str1⟩}{⟨str2⟩}{⟨if false⟩}, -ifblankTF={⟨str⟩}{⟨if true⟩}{⟨if false⟩}, % checks if string is blank -ifblankT={⟨str⟩}{⟨if true⟩}, -ifblankF={⟨str⟩}{⟨if false⟩}, -boolprovide={⟨bool⟩}, % provides a boolean -boolsettrue={⟨bool⟩}, % sets the boolean to true -boolsetfalse={⟨bool⟩}, % sets the boolean to false -boolifTF={⟨bool⟩}{⟨if true⟩}{⟨if false⟩}, % checks if boolean is true -boolifT={⟨bool⟩}{⟨if true⟩}, -boolifF={⟨bool⟩}{⟨if false⟩, -intprovide={⟨int⟩}, % provides an integer -intclear={⟨int⟩}, % sets the integer to 0 -intincr={⟨int⟩}, % adds 1 to the integer -intset={⟨int⟩}{⟨value⟩}, % sts the integer -intifgreaterthanTF={⟨num1⟩}{num2⟩}{⟨if true⟩}{⟨if false⟩}, % checks which number of greater -intifgreaterthanT={⟨num1⟩}⟨{num2⟩}{⟨if true⟩}, -intifgreaterthanF={⟨num1⟩}{⟨num2⟩}{⟨if false⟩}, -intifequalTF={⟨num1⟩}{num2⟩}{⟨if true⟩}{⟨if false⟩}, % checks if the numbers are equal -intifequalT={⟨num1⟩}⟨{num2⟩}{⟨if true⟩}, -intifequalF={⟨num1⟩}{⟨num2⟩}{⟨if false⟩}, -intiflessthanTF={⟨num1⟩}{num2⟩}{⟨if true⟩}{⟨if false⟩}, % checks which number of less -intiflessthanT={⟨num1⟩}⟨{num2⟩}{⟨if true⟩}, -intiflessthanF={⟨num1⟩}{⟨num2⟩}{⟨if false⟩}, -ERRORkeyvaluenotfound={⟨key⟩}{⟨value⟩}, % throws an error saying that the key has been set to an unkonwn value -ERROR={⟨error text⟩}, % throws a general error with the provided error test -execute={⟨error text⟩}, % executes the code in question -\end{lstlisting} - -When using these keys (including inside the key~\lstinline!execute!), you can use a number of commands that provide and manipulate data. Most of them are just command versions of the keys above, and for now, I leave it to the reader to guess what they do based on the above picture: - -\begin{lstlisting} -\SemantexDataProvide -\SemantexDataSet -\SemantexDataSetx -\SemantexDataPutRight -\SemantexDataPutRightx -\SemantexDataPutLeft -\SemantexDataPutLeftx -\SemantexDataGet -\SemantexDataGetExpNot -\SemantexDataClear -\SemantexKeysSet -\SemantexKeysSetx -\SemantexStrIfEqTF -\SemantexStrIfEqT -\SemantexStrIfEqF -\SemantexIfBlankTF -\SemantexIfBlankT -\SemantexIfBlankF -\SemantexBoolProvide -\SemantexBoolSetTrue -\SemantexBoolSetFalse -\SemantexBoolIfTF -\SemantexBoolIfT -\SemantexBoolIfF -\SemantexIntProvide -\SemantexIntGet -\SemantexIntClear -\SemantexIntIncr -\SemantexIntSet -\SemantexIntIfGreaterThanTF -\SemantexIntIfGreaterThanT -\SemantexIntIfGreaterThanF -\SemantexIntIfEqualTF -\SemantexIntIfEqualT -\SemantexIntIfEqualF -\SemantexIntIfLessThanTF -\SemantexIntIfLessThanT -\SemantexIntIfLessThanF -\SemantexExpNot##1 -\SemantexERRORKeyValueNotFound -\SemantexERROR +\begin{LTXexample} +$ \Mat[rows=\vm,columns=\vn, + field=\vk] $, +$ \Mat[rows=\vn,columns=\vn, + field=\vk] $. +\end{LTXexample} + +\section{Example: Cohomology with coefficients, revisited}\label{ch:parse_coho_coef} + +As promised previously, we revisit cohomology with coefficients +and show how to set up a syntax like the below: + +\begin{lstlisting} +\SetupObject\co{ + dataprovide=coefficient, + dataprovide=space, + definekeys[1]={ + {coef}{ dataset={coefficient}{#1} }, + {space}{ dataset={space}{#1} }, + {arg}{ space={#1} }, + }, + parseoptions={ + ifblankF={\SemantexDataGetExpNot{space}} + { + setargkeysx={ + s=\SemantexDataGetExpNot{space}, + }, + }, + ifblankF={\SemantexDataGetExpNot{coefficient}} + { + setargkeysx={ + othersep={;}{ \SemantexDataGetExpNot{coefficient} }, + }, + }, + }, +} \end{lstlisting} +\begin{LTXexample} +$\co[d=0]$, +$\co[d=0,space=\vX]$, +$\co[d=0,space=\vX,coef=\vR]$ +\end{LTXexample} + +\section{Example: Partial derivatives} + Let us look at a more complicated example: Let us create a command for partial derivatives: \NewObject\MyVar\partialdif[ @@ -2006,17 +2549,17 @@ Let us look at a more complicated example: Let us create a command for partial d boolsettrue={raisefunction}, setidots=\cdots, setisep=\,, - valuekeys={ + definekeys[1]={ {default}{ si={\partial #1}, }, {raise}{ - ifeqTF={#1}{true} + strifeqTF={#1}{true} { boolsettrue={raisefunction}, } { - ifeqTF={#1}{false} + strifeqTF={#1}{false} { boolsetfalse={raisefunction}, } @@ -2027,22 +2570,22 @@ Let us look at a more complicated example: Let us create a command for partial d }, }, parseoptions={ - ifblankTF={ \SemantexDataGet{upper} } + ifblankTF={ \SemantexDataGetExpNot{upper} } { - intifgreaterthanTF={ \SemantexIntGet{numberoflowerindices} } { 1 } + intifgreaterTF={ \SemantexIntGet{numberoflowerindices} } { 1 } { setkeysx={ symbol={ - \frac + \SemantexExpNot\frac { \partial ^ { \SemantexIntGet{numberoflowerindices} } \SemantexBoolIfT{raisefunction} { - \SemantexDataGet{arg} + \SemantexDataGetExpNot{arg} } } { - \SemantexDataGet{lower} + \SemantexDataGetExpNot{lower} } }, }, @@ -2050,16 +2593,16 @@ Let us look at a more complicated example: Let us create a command for partial d { setkeysx={ symbol={ - \frac + \SemantexExpNot\frac { \partial \SemantexBoolIfT{raisefunction} { - \SemantexDataGet{arg} + \SemantexDataGetExpNot{arg} } } { - \SemantexDataGet{lower} + \SemantexDataGetExpNot{lower} } }, } @@ -2068,16 +2611,16 @@ Let us look at a more complicated example: Let us create a command for partial d { setkeysx={ symbol={ - \frac + \SemantexExpNot\frac { - \partial ^ { \SemantexDataGet{upper} } + \partial ^ { \SemantexDataGetExpNot{upper} } \SemantexBoolIfT{raisefunction} { - \SemantexDataGet{arg} + \SemantexDataGetExpNot{arg} } } { - \SemantexDataGet{lower} + \SemantexDataGetExpNot{lower} } }, }, @@ -2087,7 +2630,7 @@ Let us look at a more complicated example: Let us create a command for partial d boolifT={raisefunction} { dataclear={arg}, - dataclear={numberofarguments}, + intclear={numberofarguments}, }, }, ] @@ -2099,17 +2642,17 @@ Let us look at a more complicated example: Let us create a command for partial d boolsettrue={raisefunction}, setidots=\cdots, setisep=\,, - valuekeys={ + definekeys[1]={ {default}{ si={\partial #1}, }, {raise}{ - ifeqTF={#1}{true} + strifeqTF={#1}{true} { boolsettrue={raisefunction}, } { - ifeqTF={#1}{false} + strifeqTF={#1}{false} { boolsetfalse={raisefunction}, } @@ -2120,22 +2663,22 @@ Let us look at a more complicated example: Let us create a command for partial d }, }, parseoptions={ - ifblankTF={ \SemantexDataGet{upper} } + ifblankTF={ \SemantexDataGetExpNot{upper} } { - intifgreaterthanTF={ \SemantexIntGet{numberoflowerindices} } { 1 } + intifgreaterTF={ \SemantexIntGet{numberoflowerindices} } { 1 } { setkeysx={ symbol={ - \frac + \SemantexExpNot\frac { \partial ^ { \SemantexIntGet{numberoflowerindices} } \SemantexBoolIfT{raisefunction} { - \SemantexDataGet{arg} + \SemantexDataGetExpNot{arg} } } { - \SemantexDataGet{lower} + \SemantexDataGetExpNot{lower} } }, }, @@ -2143,16 +2686,16 @@ Let us look at a more complicated example: Let us create a command for partial d { setkeysx={ symbol={ - \frac + \SemantexExpNot\frac { \partial \SemantexBoolIfT{raisefunction} { - \SemantexDataGet{arg} + \SemantexDataGetExpNot{arg} } } { - \SemantexDataGet{lower} + \SemantexDataGetExpNot{lower} } }, } @@ -2161,16 +2704,16 @@ Let us look at a more complicated example: Let us create a command for partial d { setkeysx={ symbol={ - \frac + \SemantexExpNot\frac { - \partial ^ { \SemantexDataGet{upper} } + \partial ^ { \SemantexDataGetExpNot{upper} } \SemantexBoolIfT{raisefunction} { - \SemantexDataGet{arg} + \SemantexDataGetExpNot{arg} } } { - \SemantexDataGet{lower} + \SemantexDataGetExpNot{lower} } }, }, @@ -2180,7 +2723,7 @@ Let us look at a more complicated example: Let us create a command for partial d boolifT={raisefunction} { dataclear={arg}, - dataclear={numberofarguments}, + intclear={numberofarguments}, }, }, ] @@ -2218,14 +2761,3108 @@ As you see, we use the \lstinline!d!~key to tell the command what superscript it \] \end{LTXexample} -\chapter{Bugs} +\chapter{\texorpdfstring{\texttt{stripsemantex}}{stripsemantex} -- stripping your document of \texorpdfstring{\semantex}{SemanTeX} markup} + +\semantex is a big, heavy package, and it might raise eyebrows if you try using it in submissions to journals. On top of that, \url{arXiv.org} +is using \TeX~Live~2016 at the time of writing this, and it has +an old version of \LaTeX3 that seems unable to run \semantex. +To address this issue, \semantex has a companion package, +called \pack{stripsemantex}, which allows you to strip the +\semantex markup from your document and replace it with raw \LaTeX~code. +While no such algorithm will ever be perfect, it generally works +very well, even for quite complicated constructions, +as long as you use the package in the \enquote{normal} +and supported way. +(If you want proof, have a look at my +recent paper which was stripped using +the algorithm: \url{https://arxiv.org/abs/2008.04794}.) + +The system has the following limitations: + +\begin{itemize} + \item It is currently only able to strip the \semantex markup from your main document (so it will ignore anything in \lstinline!\input{...}! and~\lstinline!\include{...}!). So prior to running \pack{stripsemantex}, + you should include your entire document body in your + main \texttt{.tex}~file. + \item As mentioned, as long as you do normal, supported things, + everything should work fine. Non-normal, non-supported + things are tings like + \begin{lstlisting} +\va[execute={\vb}] + \end{lstlisting} + \item Occasionally, you will have to run the stripping algorithm + multiple times. This happens e.g.~if you have + a key that does stuff like \lstinline!symbolputleft=\vH[d=0]!, + i.e.~keys that are defined using other objects. When you run + \pack{stripsemantex}, such objects will remain in the text until you run it again. + \item Partly because of the previous point, no attempt is made to remove + the \emph{setup} of \semantex, + so commands like \lstinline!\NewObject!, \lstinline!\SetupObject!, and~\lstinline!\SetupClass! + will remain in the document body. + You will then have to remove these yourself afterwards. + But the \semantex markup itself should be stripped completely from your document + (possibly after more than one run of the algorithm). + \item Things might go wrong if you define new keys + between \lstinline!\begin{document}! and~\lstinline!\end{document}! + whose definitions make use of \semantex objects or classes, + since the algorithm will try to strip these from the definitions. + For instance, don't do stuff like this + after~\lstinline!\begin{document}!: + \begin{lstlisting} +\SetupObject\va{ + definekeys[1]={ + {weirdkey}{ upper=\vb[ {#1} ] } + }, +} + \end{lstlisting} + If you do, the algorithm will then try and strip this + occurrence of~\lstinline!\vb! from the key definition. + To avoid such issues, only ever define keys in your preamble, + as the algorithm will ignore everything + before \lstinline!\begin{document}!. + \item When the document has just been stripped, + it will load a small package called \pack{semtex}, + which contains a couple of commands that the output will need + in order to run. You should be able to replace most (often all) of these commands + by other commands and then render the package \pack{semtex} + unnecessary. More on this in \cref{sec:semtex_package}. +\end{itemize} + +As a small proof of concept, this is what the example in the introduction +would look like when stripped of \semantex markup: + +\begin{lstlisting} +% Same preamble as before. + +\begin{document} + +$ \overline{f}^{(n)} $ + +$ g^{-1}|_{U} (x) $ + +$ (h^{-1} \mathcal{F})_{p} + = \mathcal{F}_{h(p)} $ + +\end{document} +\end{lstlisting} + +Yes, I know, this was a very simple, unconvincing example. +If you want a less trivial example, as mentioned before, +you can have a look at my latest paper, which was stripped with +(a previous alpha version of) \pack{stripsemantex}: + +\begin{center} + \url{https://arxiv.org/abs/2008.04794} +\end{center} + +\section{The \texttt{semtex} package}\label{sec:semtex_package} + +When you have stripped your document and removed all \semantex package setup, it should be safe to remove +the loading of \semantex from your preamble. +However, the stripping algorithm will automatically +add the following right before~\lstinline!\begin{document}!: +\begin{lstlisting} +% The following was added by "stripsemantex" + +\usepackage{semtex,leftindex,graphicx} + +\providecommand\SemantexLeft{% + \mathopen{}\mathclose\bgroup\left +} + +\providecommand\SemantexRight{% + \aftergroup\egroup\right +} + +\providecommand\SemantexBullet{% + \raisebox{-0.25ex}{\scalebox{1.2}{$\cdot$}}% +} +\providecommand\SemantexDoubleBullet{% + \SemantexBullet\SemantexBullet +} +\end{lstlisting} +The package \pack{leftindex} is loaded to take care of any +possible left indices. The package~\pack{graphicx} +is loaded to provide the command~\lstinline!\scalebox!. +This package~\pack{semtex} is a small package whose sole purpose +is to be loaded by stripped \semantex documents. +It contains a couple of simple commands that the document +needs immediately after the stripping. +Depending on your document, +you should be able to completely replace these commands +by commands from other packages, or define them yourself, rendering the package~\pack{semtex} +unnecessary. +And actually, four of those commands are the commands +\lstinline!\SemantexLeft!, \lstinline!\SemantexRight!, +\lstinline!\SemantexBullet!, and~\lstinline!\SemantexDoubleBullet! +which are provided right below, making it even faster to just remove~\pack{semtex}. + +In total, the package~\pack{semtex} adds the following commands: + +\begin{itemize} + \item + \mylst!\SemantexBullet!, + \mylst!\SemantexDoubleBullet! + + The commands that contain the bullets we use in \semantex, + i.e.~the superscript in~\( \co{*} \). + These bullets are smaller (and prettier, in my opinion) + than the standard \lstinline!\bullet! command from~\LaTeX. + + \item + \mylst!\SemantexLeft!, + \mylst!\SemantexRight! + + Like \lstinline!\left...\right!, but fixing some spacing issues + around these. + They are completely equivalent to~\lstinline!\mleft! and~\lstinline!\mright! + from the package~\pack{mleftright}, so it is safe to just load that package + and replace the above commands by \lstinline!\mleft...\mright! instead, + or use the redefinitions mentioned above. + + \item + \mylst!\SemantexParentheses{$\values\<normal|auto|*|{\textit{other}}\>$}{$\<left parenthesis\>$}!\\ + \mbox{\qquad}\mylst!{$\<right parenthesis\>$}{$\<content\>$}!, + + This one writes \<content\> enclosed in the pair of parentheses + and with the size given by the first argument. + Here,~\lstinline!normal! means normal size + parentheses, + and + \lstinline!auto! and~\lstinline!*! + mean auto-scaled parentheses using the commands~\lstinline!\SemantexLeft...\SemantexRight!. + If another value is received, that value + is used for the parenthesis size, + so the intended values are~\lstinline!\big!, \lstinline!\Big!, + \lstinline!\bigg!,~\lstinline!\Bigg!. + The important property of this command is that + inside the~\<content\>, you can access the delimiter size + at any point using the command~\lstinline!\SemantexDelimiterSize!. In other words, when + no~\lstinline!\SemantexDelimiterSize! is found inside the~\<content\>, + the command is completely redundant. We shall see + in a moment how to make sure it does not appear in your output + unless absolutely necessary. + + \item + \mylst!\SemantexNoParentheses{$\<content\>$}! + + This command prints the content with no parentheses, but importantly, it also resets + the command \lstinline!\SemantexDelimiterSize! + to~\lstinline!{}!, i.e.~blank. + As with the command~\lstinline!\SemantexParentheses!, + we shall see in a moment how to make this + command not appear in your output + unless absolutely necessary. +\end{itemize} + +As you see, most of these commands can be removed completely +or replaced by commands from other packages. The one +issue is with the annoying +commands \lstinline!\SemantexParentheses! +and~\lstinline!\SemantexNoParentheses!. +These exist solely for the purpose of allowing the use of +the command~\lstinline!\SemantexDelimiterSize! in the content. +However, there are very few cases, such as set constructions, where +\lstinline!\SemantexDelimiterSize! is even necessary. Therefore, +\textbf{it is possible to turns the use of these commands off}. +More precisely, there is a key that can be +activated for any object or class: +\begin{center} + \mylst!allowSemantexDelimiterSize=$\values\<\default{true}|false\>$! +\end{center} +When this is set to false, \semantex will not use the +commands~\lstinline!\SemantexParentheses! +and~\lstinline!\SemantexNoParentheses! internally, +and consequently, \lstinline!\SemantexDelimiterSize! will not work in that class or object. +Instead, it will simply print the parentheses as raw code, +and this is what will appear in your stripped document instead. +The natural thing to do is to turn it off by default and +only turn it back on for the few cases where you really need it: + +\begin{lstlisting} +\SetupClass\MyVar{allowSemantexDelimiterSize=false} + +% We turn it back on for the set constructions +% as defined above. +\SetupObject\Set{allowSemantexDelimiterSize=true} +\end{lstlisting} + +\section{The \texttt{stripsemantex} algorithm} + +The stripping algorithm works like this. +It will work in any \TeX\ engine (\hologo{pdfTeX}, \hologo{XeTeX}, \hologo{LuaTeX}, etc.), but along +the way, you will have to create a small, +separate document and compile it with \hologo{LuaTeX}. +Suppose in the following that you \TeX\ document is called~\texttt{mydoc.tex}. + +\begin{enumerate}[(1)] + \item Make sure to collect all of the \semantex markup you want + stripped in the main document,~\texttt{mydoc.tex}. + Also make sure to follow the recommendations + in \cref{sec:UseClassInCommand}, in case you have created keys + of the form described there. + \item Set~\lstinline!allowSemantexDelimiterSize=false! + for your main class~\lstinline!\MyVar!, and only + turn it back on in the few cases where you need it, + i.e.~when you need to use the command~\lstinline!\SemantexDelimiterSize!. + \item Put the following somewhere in your preamble, after + the loading of \semantex: + \begin{lstlisting} +\SemantexSetup{ + semtexfile=true, +} + \end{lstlisting} + \item Compile your document \texttt{mydoc.tex} using your preferred \TeX\ engine (\hologo{pdfTeX}, \hologo{XeTeX}, \hologo{LuaTeX}, or whatever). + Because of the previous step, there + will now be a new file, \texttt{mydoc.semtex}, + in your folder, where the raw output + of each \semantex command is stored. In a moment, + \pack{stripsemantex} will use this information to replace + each command by the raw code it outputs. + \item Create another \TeX\ document in the same folder + as \texttt{mydoc.tex}, and call it \texttt{stripdoc.tex} + (or whatever you want). Put the following into it: + \begin{lstlisting} +\documentclass{article} + +\usepackage{stripsemantex} + +\begin{document} + +\StripSemantexCopyFile{mydoc} + +%\StripSemantexStripFile{mydoc} + +\end{document} + \end{lstlisting} + Then compile it \textbf{with \hologo{LuaTeX}}. + \item After the previous step, another document will have been created in the same + folder, called~\lstinline!mydoc_prestripped.tex!. It will look just like \texttt{mydoc.tex}, + but in the document body, each \semantex markup command will now + have a command \mylst!\SemantexIDcommand{$\<a unique ID\>$}! + preceding it. Compile this new document \lstinline!mydoc_prestripped.tex! using the same \TeX\ engine as the one you used + for \texttt{mydoc.tex}. + \item\label{pt:strip_point} Edit~\texttt{stripdoc.tex}, commenting out the line~\lstinline!\StripSemantexCopyFile{mydoc}!, and + uncommentng the next one, so that the file now looks like this: + \begin{lstlisting} +\documentclass{article} + +\usepackage{stripsemantex} + +\begin{document} + +%\StripSemantexCopyFile{mydoc} + +\StripSemantexStripFile{mydoc} + +\end{document} + \end{lstlisting} + Then compile this document again, this time also \textbf{using \hologo{LuaTeX}}. + This will create a document called \lstinline!mydoc_stripped.tex!, which should (hopefully) + be completely stripped of \semantex markup in the document body. + Occasionally, as mentioned above, a few such commands may remain, in which case you will simply + have to repeat the above steps, this time with the document~\texttt{mydoc.tex} + replaced by~\lstinline!mydoc_stripped.tex!. + Note again that your \semantex \textbf{setup} + will not be removed, so there + will still be commands like \lstinline!\NewObject!, + \lstinline!\SetupObject!, \lstinline!\SetupClass!,~etc. + left. You will then have to remove these few commands from your document manually. +\end{enumerate} + +There is also another command in the \pack{stripsemantex} package, +called simply \mylst!\StripSemantex!, which will +run either the command \mylst!\StripSemantexCopyFile! or the command \mylst!\StripSemantexStripFile!, +depending on which of the files \lstinline!mydoc.semtex! +and~\mylst!mydoc_prestripped.semtex! is newer. +This will allow you to not have to edit +the file \texttt{stripdoc.tex} +at point~\ref{pt:strip_point}. +Unfortunately, due to a bug in \LaTeX3, +this command does not work right now (in~\hologo{LuaTeX}). This bug has been reported +and has hopefully already been fixed by the time you read this. + +\chapter{Known bugs} + +If you write e.g.~\lstinline!Otherspar={[}{]}{\Bigg}! +in a heading, your command will fail for some reason. +It can be solved by omitting the braces around~\lstinline!\Bigg!, +i.e.~by replacing it by~\lstinline!Otherspar={[}{]}\Bigg!. + +\chapter{The predefined keys, commands, and data} + +In this chapter, we give a complete list of the predefined keys. +Firstly, +the keys that can be used inside the command~\lstinline!\SemantexSetup! are: + +\begin{itemize} + \item \mylst!keyvalparser={$\<command\>$}! + + Sets the keyval parser function to~\<command\>. + The \<command\> must take three arguments: + \mylst!$\<command\>\<function\num{1}\>\<function\num{2}\>${$\<key-value list\>$}!. + The \<function\num{1}\> must take one argument, while \<function\num{2}\>~must take two. + For a key-value list, \<function\num{1}\>~will be applied to single keys taking no values, + while \<function\num{2}\>~will be applied to keys taking a value. By default, this key has been set to the \LaTeX3 command~\mylst!\keyval_parse:NNn!. + Another interesting possibility is the command~\lstinline!\ekvparse! from the package~\lstinline!expkv!. This choice will only affect keys for objects and classes, + \emph{not} keys for use inside~\lstinline!\SemantexSetup!. + + \item \mylst!semtexfile={$\values\<true|\default{false}\>$}! + + When turned on, a \lstinline!.semtex! file will be created while processing the document. + This is mainly relevant when using \lstinline!stripsemantex!. +\end{itemize} + +Apart from this, \semantex has a large collection of keys that are predefined for the class \lstinline!\SemantexBaseObject!. +In the following sections, we include the full list. + +\section{Keys for defining and removing keys} + +\begin{itemize} + \item + \mylst!definekeys={$\<key definitions\>$}! + + Defines keys taking no values. + The syntax is + \begin{lstlisting} + definekeys={ + {key1}{ upper=3, lower=7 }, + {key2}{ lower=6, upper=4 }, + }, + \end{lstlisting} + + \item + \mylst!definekeys[$n$]={$\<key definitions\>$}! + + Defines keys taking $n$~values, where $n=0,1,2,\ldots,9$. + The values are accessed by + writing + \lstinline!#1!,~\lstinline!#2!, \ldots,~\lstinline!#9!. + The syntax is + \begin{lstlisting} + definekeys[2]={ + {key1}{ upper=3+#1, lower=7-#2 }, + {key2}{ lower=6\cdot#1, upper=4/#2 }, + }, + \end{lstlisting} + + \item + \mylst!removekey=$\<key name\>$! + + Removes the key~\<key name\> taking no values. + + \item + \mylst!removekey[$n$]=$\<key name\>$! + + Removes the key~\<key name\> taking $n$~values, where $n=0,1,2,\ldots,9$. + + \item + \mylst!defineargkeys={$\<key definitions\>$}! + + Defines argument keys taking no values. + The syntax is similar to the one for~\lstinline!definekeys!. + + \item + \mylst!defineargkeys[$n$]={$\<key definitions\>$}! + + Defines argument keys taking $n$~values, where $n=0,1,2,\ldots,9$. + The syntax is similar to the one for~\mylst!definekeys[$n$]!. + + \item + \mylst!removeargkey=$\<key name\>$! + + Removes the argument key~\<key name\> taking no values. + + \item + \mylst!removeargkey[$n$]=$\<key name\>$! + + Removes the argument key~\<key name\> taking $n$~values, where $n=0,1,2,\ldots,9$. +\end{itemize} + +\section{Programming keys}\label{sec:programming_keys} + +\begin{itemize} + \item + \mylst!execute={$\<\TeX\ code\>$}! + + Executes the \<\TeX\ code\> on the spot. + + \item + \mylst!setkeys={$\<keys\>$}!, + \mylst!keysset={$\<keys\>$}! + + Sets the keys \<keys\>. + + \item + \mylst!setkeysx={$\<keys\>$}!, + \mylst!keyssetx={$\<keys\>$}! + + Sets the keys \<keys\>, but fully expands their values. + + \item + \mylst!dataprovide={$\<data\>$}! + + Provides a new piece of data consisting of a token list. + + \item + \mylst!dataset={$\<data\>$}{$\<value\>$}! + + Sets the \<data\> to \<value\>. + + \item + \mylst!datasetx={$\<data\>$}{$\<value\>$}! + + Sets the \<data\> to \<value\>, but fully expands the \<value\> first. + + \item + \mylst!dataputleft={$\<data\>$}{$\<value\>$}! + + Adds the \<value\> to the left of \<data\>. + + \item + \mylst!dataputleftx={$\<data\>$}{$\<value\>$}! + + Adds the \<value\> to the left of \<data\>, but fully expands the \<value\> first. + + \item + \mylst!dataputright={$\<data\>$}{$\<value\>$}! + + Adds the \<value\> to the right of \<data\>. + + \item + \mylst!dataputrightx={$\<data\>$}{$\<value\>$}! + + Adds the \<value\> to the right of \<data\>, but fully expands the \<value\> first. + + \item + \mylst!dataclear={$\<data\>$}! + + Clears the piece of data~\<data\>. + + \item + \mylst!boolprovide={$\<boolean\>$}! + + Provides a new piece of data consisting of a boolean. + + \item + \mylst!boolsettrue={$\<boolean\>$}! + + Sets the \<boolean\> to true. + + \item + \mylst!boolsettrue={$\<boolean\>$}! + + Sets the \<boolean\> to false. + + \item + \mylst!boolifTF={$\<boolean\>$}{$\<if true\>$}{$\<if false\>$}!, \\ + \mylst!boolifT={$\<boolean\>$}{$\<if true\>$}!, \\ + \mylst!boolifTF={$\<boolean\>$}{$\<if false\>$}! + + Runs \<if~true\> or \<if~false\>, depending on the value of \<boolean\>. + + \item + \mylst!intprovide={$\<integer\>$}! + + Provides a new piece of data consisting of an integer. + + \item + \mylst!intset={$\<integer\>$}{$\<value\>$}! + + Sets the \<integer\> to \<value\>. + + \item + \mylst!intincr={$\<integer\>$}! + + Increases the \<integer\> by~\( 1 \). + + \item + \mylst!intifeqTF={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\ + \mylst!intifeqT={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}!, \\ + \mylst!intifeqF={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if false\>$}! + + Checks whether the integers \<integer\num{1}\> and \<integer\num{2}\> are equal, + and runs \<if~true\> or \<if~false\> accordingly. + + \item + \mylst!intifgreaterTF={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\ + \mylst!intifgreaterT={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}!, \\ + \mylst!intifgreaterF={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if false\>$}! + + Checks whether the integer \<integer\num{1}\> is greater than~\<integer\num{2}\>, + and runs \<if~true\> or \<if~false\> accordingly. + + \item + \mylst!intiflessTF={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\ + \mylst!intiflessT={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}!, \\ + \mylst!intiflessF={$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if false\>$}! + + Checks whether the integer \<integer\num{1}\> is less than~\<integer\num{2}\>, + and runs \<if~true\> or \<if~false\> accordingly. + + \item + \mylst!intclear={$\<integer\>$}! + + Clears the \<integer\>. + + \item + \mylst!ifblankTF={$\<tokens\>$}{$\<if true\>$}{$\<if false\>$}!,\\ + \mylst!ifblankT={$\<tokens\>$}{$\<if true\>$}!,\\ + \mylst!ifblankF={$\<tokens\>$}{$\<if false\>$}! + + Fully expands the \<tokens\> and checks if it is blank, + and runs \<if true\> or \<if false\> according to this. + + \item + \mylst!strifeqTF={$\<string\num{1}\>$}{$\<string\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\ + \mylst!strifeqT={$\<string\num{1}\>$}{$\<string\num{2}\>$}{$\<if true\>$}!, \\ + \mylst!strifeqF={$\<string\num{1}\>$}{$\<string\num{2}\>$}{$\<if false\>$}! + + Checks whether the strings \<string\num{1}\> and \<string\num{2}\> are equal, + and runs \<if~true\> or \<if~false\> accordingly. + + \item + \mylst!ERROR={$\<error message\>$}! + + Issues an generic error message. At the end of the message, it automatically adds \enquote{object~\usercommand\<object name\> on line~\<line number\>} + or \enquote{class~\usercommand\<Class name\> on line~\<line number\>}. + + \item + \mylst!ERRORkeyvaluenotfound={$\<key\>$}{$\<value\>$}! + + Issues an error, saying that the key~\<key\> was set to the unknown value~\<value\>. + + \item + \mylst!ERRORargkeyvaluenotfound={$\<key\>$}{$\<value\>$}! + + Issues an error, saying that the argument key~\<key\> was set to the unknown value~\<value\>. +\end{itemize} + +\section{Fundamental keys for class/object information} + +\begin{itemize} + \item + \mylst!parent={$\<Class\>$}! + + Sets the class to have parent~\<Class\>. + + \item + \mylst!class={$\<Class\>$}! + + Sets the object to have class~\<Class\>. + + \item + \mylst!copy={$\<object\>$}!, + \mylst!clone={$\<object\>$}! + + Sets the object to be a copy (also known as a clone) + of~\<object\>. + Then \<object\> works as a \enquote{parent object}, and all information + will be inherited from~\<object\> unless modified for the current object. + + \item + \mylst!symbol={$\<value\>$}! + + Sets the symbol to~\<value\>. At the same time, + the height phantom and the slanting phantom are set to the same value. + + \item + \mylst!symbolputleft={$\<value\>$}! + + Adds \<value\> to the left of the symbol. No change is made to the height + phantom or the slanting phantom. + + \item + \mylst!symbolputright={$\<value\>$}! + + Adds \<value\> to the right of the symbol. No change is made to the height + phantom or the slanting phantom. + + \item + \mylst!heightphantom={$\<value\>$}! + + Sets the height phantom to~\<value\>. + + \item + \mylst!slantingphantom={$\<value\>$}! + + Sets the slanting phantom to~\<value\>. + + \item + \mylst!gradingposition={$\values\<\default{upper}|lower\>$}!, \\ + \mylst!gradingpos={$\values\<\default{upper}|lower\>$}! + + Sets whether to use upper (\enquote{cohomological}) + or lower (\enquote{homological}) grading. + The default is~\lstinline!upper!. + + \item + \mylst!command={$\<command\>$}! + + Applies the \<command\> to the symbol. + + \item + \mylst!clearcommand! + + Clears the list of commands to be applied to the symbol. + + \item + \mylst!return! + + Invokes the return routine. + + \item + \mylst!leftreturn! + + Invokes the left return routine. + + \item + \mylst!rightreturn! + + Invokes the right return routine. + + \item + \mylst!innerreturn! + + Invokes the inner return routine. + + \item + \mylst!output={$\<Class\>$}! + + Sets the output class to~\<Class\>. + + \item + \mylst!dooutput={$\values\<true|\default{false}\>$}! + + Sets whether the current object/class should output or not. + The default is false, but the system will automatically + change this when needed. \emph{Never} set this to + \lstinline!true! by default, as this will + cause an infinite loop. + + \item + \mylst!outputoptions={$\<keys\>$}! + + Adds the \<keys\> to the output options, + i.e.\ those options passed to the output class. + + \item + \mylst!parseoptions={$\<keys\>$}! + + Adds the \<keys\> to the parse options. + + \item + \mylst!parse! + + Invokes the parse routine. + + \item + \mylst!texclass={$\<command\>$}! + + Sets the \TeX\ character class to be~\<command\>. + The intended values are \lstinline!\mathord!, \lstinline!\mathop!, \lstinline!\mathbin!, \lstinline!\mathrel!, \lstinline!\mathopen!, \lstinline!\mathclose!, and~\lstinline!\mathpunct!. + + \item + \mylst!allowSemantexDelimiterSize={$\values\<\default{true}|false\>$}! + + Sets whether to allow the command \lstinline!\SemantexDelimiterSize! + inside the argument. + The default is~\lstinline!true!. + The only real reason to turn this off is if you are using + \lstinline!stripsemantex! to strip the document of \semantex markup. + For if it is set to false, the system will not + add \lstinline!\SemantexParentheses! and \lstinline!\SemantexNoParentheses! + all over the place to set the value of \lstinline!\SemantexDelimiterSize!, + and this probably looks better in the outputted code. + + \item + \mylst!default={$\<value\>$}! + + This is the key that is applied whenever the + user writes something in the options which is not a key, + e.g.~the~\lstinline!1! in~\lstinline!\vf[1]!. + By default, this keys has been set to be equal to~\lstinline!si!, + but it is meant to be changeable by the user. + + \item + \mylst!degreedefault={$\<value\>$}! + + This is the key where the grading goes. + It is the one used by \lstinline!Cohomology! class types. + By default, this key has been set to be equal to~\lstinline!sd!, + but it is meant to be changable by the user. + + \item + \mylst!*! + + Adds a bullet to the \lstinline!d!-index. + + \item + \mylst!**! + + Adds a double bullet to the \lstinline!d!-index. + + \item + \mylst!-! + + Adds a slot to the \lstinline!i!-index. + + \item + \mylst!...! + + Adds three dots to the \lstinline!i!-index. + + \item + \mylst!*withothersep={$\<separator\>$}! + + Adds a bullet to the \lstinline!d!-index, + separated by the \<separator\> + from any previous \lstinline!d!-indices. + + \item + \mylst!**withothersep={$\<separator\>$}! + + Adds a double bullet to the \lstinline!d!-index, + separated by the \<separator\> + from any previous \lstinline!d!-indices. + + \item + \mylst!arg={$\<value\>$}! + + The key that is applied whenever the user adds + an argument via the standard syntax, e.g.~\lstinline!\vf{\vx}!. + By default, it is set to be equal to \lstinline!setargsinglekeys!, + but it is meant to be changable by the user. + + \item + \mylst!smash! + + Applies the command~\lstinline!\smash! to the symbol. + Equivalent to~\lstinline!command=\smash!. + + \item + \mylst!prime!, \mylst!'!, \mylst!''!, \mylst!'''! + + Adds one or more primes to the symbol in the upper index. + Equivalent to \lstinline!upper={\prime}!, \lstinline!upper={\prime\prime}!, + etc. +\end{itemize} + +\section{Keys for the argument parentheses} -The biggest unsolved problem I know of is how to correctly strip spaces in programming keys such as \lstinline!boolifTF!. Similarly, I would also like to allow keys to be defined using the -syntax~\lstinline!{ inv } { upper=-1 }! rather than~\lstinline!{inv}{ upper=-1 }!. This will hopefully be solved soon. +\begin{itemize} + \item + \mylst!par! + + Turns parentheses on. Equivalent to \lstinline!usepar=true!. + + \item + \mylst!nopar! + + Turns parentheses off, but still prints them if more + than one argument is received. + Equivalent to \lstinline!usepar=false!. + + \item + \mylst!neverpar! + + Turns parentheses completely off, even if more than one argument + is received. (This is ugly and should only be used for special constructions.) + Equivalent to \lstinline!usepar=never!. + + \item + \mylst!usepar={$\values\<\default{true}|false|never\>$}! + + Sets whether or not to use parentheses. + If~\lstinline!true!, turns parentheses on (this is the default behaviour). + If~\lstinline!false!, turns parentheses off, but still prints them if more + than one argument is received. + If~\lstinline!never!, turns parentheses completely off, even if more than one argument + is received. (This is ugly and should only be used for special constructions.) + The default value is~\lstinline!true!. + + \item + \mylst!parsize={$\values\<\default{normal}|auto|*|{\textit{other}}\>$}! + + Sets the parentheses size. + Here,~\lstinline!normal! means normal size + parentheses, + \lstinline!auto! and~\lstinline!*! + mean auto-scaled parentheses using~\lstinline!\left...\right!. + If another value is received, that value + is used for the parenthesis size, + so the intended values are~\lstinline!\big!, \lstinline!\Big!, + \lstinline!\bigg!,~\lstinline!\Bigg!. + + \item + \mylst!leftpar={$\<parenthesis\>$}! + + Sets the left parenthesis. + The default value is~\lstinline!(!. + + \item + \mylst!rightpar={$\<parenthesis\>$}! + + Sets the right parenthesis. + The default value is~\lstinline!)!. +\end{itemize} + +\section{Keys for the \texttt{spar} routine} + +\begin{itemize} + \item + \mylst!spar! + + Invokes the \lstinline!spar! routine. + + \item + \mylst!spar={$\values\<normal|auto|*|\textit{other}\>$}! + + Invokes the \lstinline!spar! routine, with + the specified parenthesis size. + Here,~\lstinline!normal! means normal size + parentheses, + \lstinline!auto! and~\lstinline!*! + mean auto-scaled parentheses using~\lstinline!\left...\right!. + If another value is received, that value + is used for the parenthesis size, + so the intended values are~\lstinline!\big!, \lstinline!\Big!, + \lstinline!\bigg!,~\lstinline!\Bigg!. + + \item + \mylst!sparsize={$\values\<\default{normal}|auto|*|{\textit{other}}\>$}! + + Sets the \lstinline!spar! parenthesis size. + Here,~\lstinline!normal! means normal size + parentheses, + \lstinline!auto! and~\lstinline!*! + mean auto-scaled parentheses using~\lstinline!\left...\right!. + If another value is received, that value + is used for the parenthesis size, + so the intended values are~\lstinline!\big!, \lstinline!\Big!, + \lstinline!\bigg!,~\lstinline!\Bigg!. + + \item + \mylst!leftspar={$\<parenthesis\>$}! + + Sets the left parenthesis for the \lstinline!spar! routine. + The default value is~\lstinline!(!. + + \item + \mylst!rightspar={$\<parenthesis\>$}! + + Sets the right parenthesis for the \lstinline!spar! routine. + The default value is~\lstinline!)!. + + \item + \mylst!otherspar={$\<left parenthesis\>$}{$\<right parenthesis\>$}! + + Invokes the \lstinline!spar! routine, but with the assigned parentheses. + + \item + \mylst!Otherspar={$\<left parenthesis\>$}{$\<right parenthesis\>$}{$\values\<normal|auto|*|{\textit{other}}\>$}! + + Invokes the \lstinline!spar! routine, but with the assigned parentheses and size. + Here,~\lstinline!normal! means normal size + parentheses, + \lstinline!auto! and~\lstinline!*! + mean auto-scaled parentheses using~\lstinline!\left...\right!. + If another value is received, that value + is used for the parenthesis size, + so the intended values are~\lstinline!\big!, \lstinline!\Big!, + \lstinline!\bigg!,~\lstinline!\Bigg!. +\end{itemize} + +\section{Keys for setting the argument} + +\begin{itemize} + \item + \mylst!setargkeys={$\<keys\>$}!, + \mylst!argkeysset={$\<keys\>$}! + + Sets the argument keys \<keys\>. + + \item + \mylst!setargkeysx={$\<keys\>$}!, + \mylst!argkeyssetx={$\<keys\>$}! + + Sets the argynebt keys \<keys\>, but fully expands their values. + + \item + \mylst!setargsinglekeys={$\<keys\>$}!, + \mylst!argsinglekeysset={$\<keys\>$}! + + Sets the argument keys \<keys\>, + but only supports keys taking no values. + This allows the arguments to contain equality + signs without causing issues. + + \item + \mylst!setargsinglekeysx={$\<keys\>$}!, + \mylst!argsinglekeyssetx={$\<keys\>$}! + + Sets the argument keys \<keys\>, + but only supports keys taking no values. + If a key is not found, the value + is fully expanded and printed. + This allows the arguments to contain equality + signs without causing issues. + + \item + \mylst!setoneargsinglekey={$\<key\>$}!, + \mylst!oneargsinglekeyset={$\<key\>$}! + + Sets one single argument key taking no values. + This allows the argument to contain + equality signs and commas without cuasing issues. + + \item + \mylst!setoneargsinglekeyx={$\<key\>$}!, + \mylst!oneargsinglekeysetx={$\<key\>$}! + + Sets one single argument key taking no values, + If the key is not found, the value + is fully expanded and printed. + This allows the argument to contain + equality signs and commas without cuasing issues. + + \item + \mylst!setargwithoutkeyval={$\<value\>$}!, + \mylst!argwithoutkeyvalset={$\<value\>$}! + + Sets the argument, allowing no keyval syntax. + + \item + \mylst!setargwithoutkeyvalx={$\<value\>$}!, + \mylst!argwithoutkeyvalsetx={$\<value\>$}! + + Sets the argument, fully expanding its value, + and allowing no keyval syntax. + + \item + \mylst!prearg={$\<value\>$}! + + Sets the pre-argument. + + \item + \mylst!postarg={$\<value\>$}! + + Sets the post-argument. + + \item + \mylst!setargsep={$\<value\>$}! + + Sets the argument separator. + The default value is a comma. + + \item + \mylst!setargslot={$\<value\>$}! + + Sets the argument slot. + The default value is~\lstinline!{-}!. + + \item + \mylst!setargdots={$\<value\>$}! + + Sets the argument dots. + The default value is~\lstinline!\dots!. + + \item + \mylst!argkeyval={$\values\<true|false|\default{singlekeys}|onesinglekey\>$}! + + Sets whether to use argument keyval syntax or not. + If \lstinline!true!, \lstinline!arg! is set equal to~\lstinline!setargkeys!. + If \lstinline!false!, it is set to~\lstinline!setargwithoutkeyval!. + If \lstinline!singlekeys!, it is set to~\lstinline!setargsinglekeys!. + If \lstinline!onesinglekey!, it is set to~\lstinline!setoneargsinglekey!. + The default value is~\lstinline!singlekeys!. + + \item + \mylst!argposition={$\values\<left|\default{right}\>$}! + + Sets the position of the argument. + The default is~\lstinline!right!, so the argument + will be printed to the right of the symbol. + + \item + \mylst!nextargwithsep={$\values\<true|\default{false}\>$}! + + Sets whether the next argument should be + separated from the current one with a + separator or not. + The default is \lstinline!false!, but the + system will automatically change this when needed. + + \item + \mylst!sarg={$\<value\>$}! + + Adds \<value\> to the argument, separated from any previous + argument by the default argument separator. + + \item + \mylst!carg={$\<value\>$}! + + Adds \<value\> to the argument, separated from any previous + argument by a comma. + + \item + \mylst!argwithothersep={$\<separator\>$}{$\<value\>$}! + + Adds \<value\> to the argument, separated from any previous + argument by \<separator\>. + + \item + \mylst!arg...withothersep={$\<separator\>$}!, + \mylst!argdotswithothersep={$\<separator\>$}! + + Adds three dots to the argument, separated from any previous + argument by the \<separator\>. + + \item + \mylst!arg-withothersep={$\<separator\>$}!, + \mylst!argslotwithothersep={$\<separator\>$}! + + Adds a slot to the argument, separated from any previous + argument by the \<separator\>. + + \item + \mylst!argdots!, \mylst!arg...! + + Adds three dots to the argument, + separated from any previous arguments + by the standard separator. + + \item + \mylst!cargdots!, \mylst!carg...! + + Adds three dots to the argument, + separated from any previous arguments + by a comma. + + \item + \mylst!argslot!, \mylst!arg-! + + Adds a slot to the argument, + separated from any previous arguments + by the standard separator. + + \item + \mylst!cargslot!, \mylst!carg-! + + Adds a slot to the argument, + separated from any previous arguments + by a comma. + + \item + \mylst!cleararg! + + Clears the argument. + + \item + \mylst!clearprearg! + + Clears the pre-argument. + + \item + \mylst!clearpostarg! + + Clears the post-argument. +\end{itemize} + + +\section{Keys for the upper index} + +\begin{itemize} + \item + \mylst!upper={$\<value\>$}! + + Adds to the upper index, + with no separator from any previous upper index. + + \item + \mylst!supper={$\<value\>$}! + + Adds to the upper index, + separated from any previous upper + index by the default separator. + + \item + \mylst!cupper={$\<value\>$}! + + Adds to the upper index, + separated from any previous upper + index by a comma. + + \item + \mylst!preupper={$\<value\>$}! + + Sets the pre-upper index. + + \item + \mylst!postupper={$\<value\>$}! + + Sets the post-upper index. + + \item + \mylst!upperputleft={$\<value\>$}! + + Adds something to the left of the upper index. + As with keys like~\lstinline!upper!, this + will also increase the number of registered + upper indices by~\( 1 \), and + it will + set \lstinline!nextupperwithsep=true!. + + \item + \mylst!setuppersep={$\<value\>$}! + + Sets the upper index separator to~\<value\>. + By default, this is a comma. + + \item + \mylst!nextupperwithsep={$\values\<true|\default{false}\>$}! + + Sets whether the next upper index should + be separated from the current one by a separator. + + \item + \mylst!upperwithothersep={$\<separator\>$}{$\<value\>$}! + + Adds \<value\> to the upper index, separated from + any prevous upper index by~\<separator\>. + + \item + \mylst!upper-!, \mylst!upperslot! + + Adds a slot to the upper index, + with no separator from any previous upper index. + + \item + \mylst!supper-!, \mylst!supperslot! + + Adds a slot to the upper index, + separated from any previous upper + index by the default separator. + + \item + \mylst!cupper-!, \mylst!cupperslot! + + Adds a slot to the upper index, + separated from any previous upper + index by a comma. + + \item + \mylst!setupperslot={$\<value\>$}! + + Sets the slot for the upper index. + By default, this is~\lstinline!{-}!. + + \item + \mylst!upper-withothersep={$\<separator\>$}!, + \mylst!upperslotwithothersep={$\<separator\>$}! + + + Adds a slot to the upper index, separated + from any previous upper index by~\<separator\>. + + \item + \mylst!upper...!, \mylst!upperdots! + + Adds three dots to the upper index, + with no separator from any previous upper index. + + \item + \mylst!supper...!, \mylst!supperdots! + + Adds three dots to the upper index, + separated from any previous upper + index by the default separator. + + \item + \mylst!cupper...!, \mylst!cupperdots! + + Adds three dots to the upper index, + separated from any previous upper + index by a comma. + + \item + \mylst!setupperdots={$\<value\>$}! + + Sets the dots for the upper index. + By default, this is~\lstinline!\dots!. + + \item + \mylst!upper...withothersep={$\<separator\>$}!, + \mylst!upperdotswithothersep={$\<separator\>$}! + + Adds three dots to the upper index, + separated from any previous upper index + by~\<separator\>. + + \item + \mylst!upper*! + + Adds a bullet to the upper index, + with no separator from any previous upper index. + + \item + \mylst!upper**! + + Adds a double bullet to the upper index, + with no separator from any previous upper index. + + \item + \mylst!supper*! + + Adds a bullet to the upper index, + separated from any previous upper + index by the default separator. + + \item + \mylst!supper**! + + Adds a double bullet to the upper index, + separated from any previous upper + index by the default separator. + + \item + \mylst!cupper*! + + Adds a bullet to the upper index, + separated from any previous upper + index by a comma. + + \item + \mylst!cupper**! + + Adds a double bullet to the upper index, + separated from any previous upper + index by a comma. + + \item + \mylst!upper*withothersep={$\<separator\>$}! + + Adds a bullet to the upper index, + separated from any previous upper index + by~\<separator\>. + + \item + \mylst!upper**withothersep={$\<separator\>$}! + + Adds a double bullet to the upper index, + separated from any previous upper index + by~\<separator\>. + + \item + \mylst!clearupper! + + Clears the upper index. + + \item + \mylst!clearpreupper! + + Clears the pre-upper index. + + \item + \mylst!clearpostupper! + + Clears the post-upper index. +\end{itemize} + +\section{Keys for the lower index} + +\begin{itemize} + \item + \mylst!lower={$\<value\>$}! + + Adds to the lower index, + with no separator from any previous lower index. + + \item + \mylst!slower={$\<value\>$}! + + Adds to the lower index, + separated from any previous lower + index by the default separator. + + \item + \mylst!clower={$\<value\>$}! + + Adds to the lower index, + separated from any previous lower + index by a comma. + + \item + \mylst!prelower={$\<value\>$}! + + Sets the pre-lower index. + + \item + \mylst!postlower={$\<value\>$}! + + Sets the post-lower index. + + \item + \mylst!lowerputleft={$\<value\>$}! + + Adds something to the left of the lower index. + As with keys like~\lstinline!lower!, this + will also increase the number of registered + lower indices by~\( 1 \), and + it will + set \lstinline!nextlowerwithsep=true!. + + \item + \mylst!setlowersep={$\<value\>$}! + + Sets the lower index separator to~\<value\>. + By default, this is a comma. + + \item + \mylst!nextlowerwithsep={$\values\<true|\default{false}\>$}! + + Sets whether the next lower index should + be separated from the current one by a separator. + + \item + \mylst!lowerwithothersep={$\<separator\>$}{$\<value\>$}! + + Adds \<value\> to the lower index, separated from + any prevous lower index by~\<separator\>. + + \item + \mylst!lower-!, \mylst!lowerslot! + + Adds a slot to the lower index, + with no separator from any previous lower index. + + \item + \mylst!slower-!, \mylst!slowerslot! + + Adds a slot to the lower index, + separated from any previous lower + index by the default separator. + + \item + \mylst!clower-!, \mylst!clowerslot! + + Adds a slot to the lower index, + separated from any previous lower + index by a comma. + + \item + \mylst!setlowerslot={$\<value\>$}! + + Sets the slot for the lower index. + By default, this is~\lstinline!{-}!. + + \item + \mylst!lower-withothersep={$\<separator\>$}!, + \mylst!lowerslotwithothersep={$\<separator\>$}! + + + Adds a slot to the lower index, separated + from any previous lower index by~\<separator\>. + + \item + \mylst!lower...!, \mylst!lowerdots! + + Adds three dots to the lower index, + with no separator from any previous lower index. + + \item + \mylst!slower...!, \mylst!slowerdots! + + Adds three dots to the lower index, + separated from any previous lower + index by the default separator. + + \item + \mylst!clower...!, \mylst!clowerdots! + + Adds three dots to the lower index, + separated from any previous lower + index by a comma. + + \item + \mylst!setlowerdots={$\<value\>$}! + + Sets the dots for the lower index. + By default, this is~\lstinline!\dots!. + + \item + \mylst!lower...withothersep={$\<separator\>$}!, + \mylst!lowerdotswithothersep={$\<separator\>$}! + + Adds three dots to the lower index, + separated from any previous lower index + by~\<separator\>. + + \item + \mylst!lower*! + + Adds a bullet to the lower index, + with no separator from any previous lower index. + + \item + \mylst!lower**! + + Adds a double bullet to the lower index, + with no separator from any previous lower index. + + \item + \mylst!slower*! + + Adds a bullet to the lower index, + separated from any previous lower + index by the default separator. + + \item + \mylst!slower**! + + Adds a double bullet to the lower index, + separated from any previous lower + index by the default separator. + + \item + \mylst!clower*! + + Adds a bullet to the lower index, + separated from any previous lower + index by a comma. + + \item + \mylst!clower**! + + Adds a double bullet to the lower index, + separated from any previous lower + index by a comma. + + \item + \mylst!lower*withothersep={$\<separator\>$}! + + Adds a bullet to the lower index, + separated from any previous lower index + by~\<separator\>. + + \item + \mylst!lower**withothersep={$\<separator\>$}! + + Adds a double bullet to the lower index, + separated from any previous lower index + by~\<separator\>. + + \item + \mylst!clearlower! + + Clears the lower index. + + \item + \mylst!clearprelower! + + Clears the pre-lower index. + + \item + \mylst!clearpostlower! + + Clears the post-lower index. +\end{itemize} + +\section{Keys for the upper left index} + +\begin{itemize} + \item + \mylst!upperleft={$\<value\>$}! + + Adds to the upper left index, + with no separator from any previous upper left index. + + \item + \mylst!supperleft={$\<value\>$}! + + Adds to the upper left index, + separated from any previous upper left + index by the default separator. + + \item + \mylst!cupperleft={$\<value\>$}! + + Adds to the upper left index, + separated from any previous upper left + index by a comma. + + \item + \mylst!preupperleft={$\<value\>$}! + + Sets the pre-upper left index. + + \item + \mylst!postupperleft={$\<value\>$}! + + Sets the post-upper left index. + + \item + \mylst!upperleftputleft={$\<value\>$}! + + Adds something to the left of the upper left index. + As with keys like~\lstinline!upperleft!, this + will also increase the number of registered + upper left indices by~\( 1 \), and + it will + set \lstinline!nextupperleftwithsep=true!. + + \item + \mylst!setupperleftsep={$\<value\>$}! + + Sets the upper left index separator to~\<value\>. + By default, this is a comma. + + \item + \mylst!nextupperleftwithsep={$\values\<true|\default{false}\>$}! + + Sets whether the next upper left index should + be separated from the current one by a separator. + + \item + \mylst!upperleftwithothersep={$\<separator\>$}{$\<value\>$}! + + Adds \<value\> to the upper left index, separated from + any prevous upper left index by~\<separator\>. + + \item + \mylst!upperleft-!, \mylst!upperleftslot! + + Adds a slot to the upper left index, + with no separator from any previous upper left index. + + \item + \mylst!supperleft-!, \mylst!supperleftslot! + + Adds a slot to the upper left index, + separated from any previous upper left + index by the default separator. + + \item + \mylst!cupperleft-!, \mylst!cupperleftslot! + + Adds a slot to the upper left index, + separated from any previous upper left + index by a comma. + + \item + \mylst!setupperleftslot={$\<value\>$}! + + Sets the slot for the upper left index. + By default, this is~\lstinline!{-}!. + + \item + \mylst!upperleft-withothersep={$\<separator\>$}!, + \mylst!upperleftslotwithothersep={$\<separator\>$}! + + + Adds a slot to the upper left index, separated + from any previous upper left index by~\<separator\>. + + \item + \mylst!upperleft...!, \mylst!upperleftdots! + + Adds three dots to the upper left index, + with no separator from any previous upper left index. + + \item + \mylst!supperleft...!, \mylst!supperleftdots! + + Adds three dots to the upper left index, + separated from any previous upper left + index by the default separator. + + \item + \mylst!cupperleft...!, \mylst!cupperleftdots! + + Adds three dots to the upper left index, + separated from any previous upper left + index by a comma. + + \item + \mylst!setupperleftdots={$\<value\>$}! + + Sets the dots for the upper left index. + By default, this is~\lstinline!\dots!. + + \item + \mylst!upperleft...withothersep={$\<separator\>$}!, + \mylst!upperleftdotswithothersep={$\<separator\>$}! + + Adds three dots to the upper left index, + separated from any previous upper left index + by~\<separator\>. + + \item + \mylst!upperleft*! + + Adds a bullet to the upper left index, + with no separator from any previous upper left index. + + \item + \mylst!upperleft**! + + Adds a double bullet to the upper left index, + with no separator from any previous upper left index. + + \item + \mylst!supperleft*! + + Adds a bullet to the upper left index, + separated from any previous upper left + index by the default separator. + + \item + \mylst!supperleft**! + + Adds a double bullet to the upper left index, + separated from any previous upper left + index by the default separator. + + \item + \mylst!cupperleft*! + + Adds a bullet to the upper left index, + separated from any previous upper left + index by a comma. + + \item + \mylst!cupperleft**! + + Adds a double bullet to the upper left index, + separated from any previous upper left + index by a comma. + + \item + \mylst!upperleft*withothersep={$\<separator\>$}! + + Adds a bullet to the upper left index, + separated from any previous upper left index + by~\<separator\>. + + \item + \mylst!upperleft**withothersep={$\<separator\>$}! + + Adds a double bullet to the upper left index, + separated from any previous upper left index + by~\<separator\>. + + \item + \mylst!clearupperleft! + + Clears the upper left index. + + \item + \mylst!clearpreupperleft! + + Clears the pre-upper left index. + + \item + \mylst!clearpostupperleft! + + Clears the post-upper left index. +\end{itemize} + +\section{Keys for the lower left index} + +\begin{itemize} + \item + \mylst!lowerleft={$\<value\>$}! + + Adds to the lower left index, + with no separator from any previous lower left index. + + \item + \mylst!slowerleft={$\<value\>$}! + + Adds to the lower left index, + separated from any previous lower left + index by the default separator. + + \item + \mylst!clowerleft={$\<value\>$}! + + Adds to the lower left index, + separated from any previous lower left + index by a comma. + + \item + \mylst!prelowerleft={$\<value\>$}! + + Sets the pre-lower left index. + + \item + \mylst!postlowerleft={$\<value\>$}! + + Sets the post-lower left index. + + \item + \mylst!lowerleftputleft={$\<value\>$}! + + Adds something to the left of the lower left index. + As with keys like~\lstinline!lowerleft!, this + will also increase the number of registered + lower left indices by~\( 1 \), and + it will + set \lstinline!nextlowerleftwithsep=true!. + + \item + \mylst!setlowerleftsep={$\<value\>$}! + + Sets the lower left index separator to~\<value\>. + By default, this is a comma. + + \item + \mylst!nextlowerleftwithsep={$\values\<true|\default{false}\>$}! + + Sets whether the next lower left index should + be separated from the current one by a separator. + + \item + \mylst!lowerleftwithothersep={$\<separator\>$}{$\<value\>$}! + + Adds \<value\> to the lower left index, separated from + any prevous lower left index by~\<separator\>. + + \item + \mylst!lowerleft-!, \mylst!lowerleftslot! + + Adds a slot to the lower left index, + with no separator from any previous lower left index. + + \item + \mylst!slowerleft-!, \mylst!slowerleftslot! + + Adds a slot to the lower left index, + separated from any previous lower left + index by the default separator. + + \item + \mylst!clowerleft-!, \mylst!clowerleftslot! + + Adds a slot to the lower left index, + separated from any previous lower left + index by a comma. + + \item + \mylst!setlowerleftslot={$\<value\>$}! + + Sets the slot for the lower left index. + By default, this is~\lstinline!{-}!. + + \item + \mylst!lowerleft-withothersep={$\<separator\>$}!, + \mylst!lowerleftslotwithothersep={$\<separator\>$}! + + + Adds a slot to the lower left index, separated + from any previous lower left index by~\<separator\>. + + \item + \mylst!lowerleft...!, \mylst!lowerleftdots! + + Adds three dots to the lower left index, + with no separator from any previous lower left index. + + \item + \mylst!slowerleft...!, \mylst!slowerleftdots! + + Adds three dots to the lower left index, + separated from any previous lower left + index by the default separator. + + \item + \mylst!clowerleft...!, \mylst!clowerleftdots! + + Adds three dots to the lower left index, + separated from any previous lower left + index by a comma. + + \item + \mylst!setlowerleftdots={$\<value\>$}! + + Sets the dots for the lower left index. + By default, this is~\lstinline!\dots!. + + \item + \mylst!lowerleft...withothersep={$\<separator\>$}!, + \mylst!lowerleftdotswithothersep={$\<separator\>$}! + + Adds three dots to the lower left index, + separated from any previous lower left index + by~\<separator\>. + + \item + \mylst!lowerleft*! + + Adds a bullet to the lower left index, + with no separator from any previous lower left index. + + \item + \mylst!lowerleft**! + + Adds a double bullet to the lower left index, + with no separator from any previous lower left index. + + \item + \mylst!slowerleft*! + + Adds a bullet to the lower left index, + separated from any previous lower left + index by the default separator. + + \item + \mylst!slowerleft**! + + Adds a double bullet to the lower left index, + separated from any previous lower left + index by the default separator. + + \item + \mylst!clowerleft*! + + Adds a bullet to the lower left index, + separated from any previous lower left + index by a comma. + + \item + \mylst!clowerleft**! + + Adds a double bullet to the lower left index, + separated from any previous lower left + index by a comma. + + \item + \mylst!lowerleft*withothersep={$\<separator\>$}! + + Adds a bullet to the lower left index, + separated from any previous lower left index + by~\<separator\>. + + \item + \mylst!lowerleft**withothersep={$\<separator\>$}! + + Adds a double bullet to the lower left index, + separated from any previous lower left index + by~\<separator\>. + + \item + \mylst!clearlowerleft! + + Clears the lower left index. + + \item + \mylst!clearprelowerleft! + + Clears the pre-lower left index. + + \item + \mylst!clearpostlowerleft! + + Clears the post-lower left index. +\end{itemize} + +\section{Keys for the \texttt{d}-index} + +\begin{itemize} + \item + \mylst!d={$\<value\>$}! + + Adds to the \lstinline!d!-index, + with no separator from any previous \lstinline!d!-index. + + \item + \mylst!sd={$\<value\>$}! + + Adds to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by the default separator. + + \item + \mylst!cd={$\<value\>$}! + + Adds to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by a comma. + + \item + \mylst!pred={$\<value\>$}! + + Sets the pre-\lstinline!d!-index. + + \item + \mylst!postd={$\<value\>$}! + + Sets the post-\lstinline!d!-index. + + \item + \mylst!dputleft={$\<value\>$}! + + Adds something to the left of the \lstinline!d!-index. + As with keys like~\lstinline!d!, this + will also increase the number of registered + \lstinline!d!-indices by~\( 1 \), and + it will + set \lstinline!nextdwithsep=true!. + + \item + \mylst!setdsep={$\<value\>$}! + + Sets the \lstinline!d!-index separator to~\<value\>. + By default, this is a comma. + + \item + \mylst!nextdwithsep={$\values\<true|\default{false}\>$}! + + Sets whether the next \lstinline!d!-index should + be separated from the current one by a separator. + + \item + \mylst!dwithothersep={$\<separator\>$}{$\<value\>$}! + + Adds \<value\> to the \lstinline!d!-index, separated from + any prevous \lstinline!d!-index by~\<separator\>. + + \item + \mylst!d-!, \mylst!dslot! + + Adds a slot to the \lstinline!d!-index, + with no separator from any previous \lstinline!d!-index. + + \item + \mylst!sd-!, \mylst!sdslot! + + Adds a slot to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by the default separator. + + \item + \mylst!cd-!, \mylst!cdslot! + + Adds a slot to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by a comma. + + \item + \mylst!setdslot={$\<value\>$}! + + Sets the slot for the \lstinline!d!-index. + By default, this is~\lstinline!{-}!. + + \item + \mylst!d-withothersep={$\<separator\>$}!, + \mylst!dslotwithothersep={$\<separator\>$}! + + + Adds a slot to the \lstinline!d!-index, separated + from any previous \lstinline!d!-index by~\<separator\>. + + \item + \mylst!d...!, \mylst!ddots! + + Adds three dots to the \lstinline!d!-index, + with no separator from any previous \lstinline!d!-index. + + \item + \mylst!sd...!, \mylst!sddots! + + Adds three dots to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by the default separator. + + \item + \mylst!cd...!, \mylst!cddots! + + Adds three dots to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by a comma. + + \item + \mylst!setddots={$\<value\>$}! + + Sets the dots for the \lstinline!d!-index. + By default, this is~\lstinline!\dots!. + + \item + \mylst!d...withothersep={$\<separator\>$}!, + \mylst!ddotswithothersep={$\<separator\>$}! + + Adds three dots to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by~\<separator\>. + + \item + \mylst!d*! + + Adds a bullet to the \lstinline!d!-index, + with no separator from any previous \lstinline!d!-index. + + \item + \mylst!d**! + + Adds a double bullet to the \lstinline!d!-index, + with no separator from any previous \lstinline!d!-index. + + \item + \mylst!sd*! + + Adds a bullet to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by the default separator. + + \item + \mylst!sd**! + + Adds a double bullet to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by the default separator. + + \item + \mylst!cd*! + + Adds a bullet to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by a comma. + + \item + \mylst!cd**! + + Adds a double bullet to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by a comma. + + \item + \mylst!d*withothersep={$\<separator\>$}! + + Adds a bullet to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by~\<separator\>. + + \item + \mylst!d**withothersep={$\<separator\>$}! + + Adds a double bullet to the \lstinline!d!-index, + separated from any previous \lstinline!d!-index + by~\<separator\>. + + \item + \mylst!cleard! + + Clears the \lstinline!d!-index. + + \item + \mylst!clearpred! + + Clears the pre-\lstinline!d!-index. + + \item + \mylst!clearpostd! + + Clears the post-\lstinline!d!-index. +\end{itemize} + +\section{Keys for the \texttt{i}-index} + +\begin{itemize} + \item + \mylst!i={$\<value\>$}! + + Adds to the \lstinline!i!-index, + with no separator from any previous \lstinline!i!-index. + + \item + \mylst!si={$\<value\>$}! + + Adds to the \lstinline!i!-index, + separated from any previous + \lstinline!i!-index by the default separator. + + \item + \mylst!ci={$\<value\>$}! + + Adds to the \lstinline!i!-index, + separated from any previous + \lstinline!i!-index by a comma. + + \item + \mylst!prei={$\<value\>$}! + + Sets the pre-\lstinline!i!-index. + + \item + \mylst!posti={$\<value\>$}! + + Sets the post-\lstinline!i!-index. + + \item + \mylst!iputleft={$\<value\>$}! + + Adds something to the left of the \lstinline!i!-index. + As with keys like~\lstinline!i!, this + will also increase the number of registered + \lstinline!i!-indices by~\( 1 \), and + it will + set \lstinline!nextiwithsep=true!. + + \item + \mylst!setisep={$\<value\>$}! + + Sets the \lstinline!i!-index separator to~\<value\>. + By default, this is a comma. + + \item + \mylst!nextiwithsep={$\values\<true|\default{false}\>$}! + + Sets whether the next \lstinline!i!-index should + be separated from the current one by a separator. + + \item + \mylst!iwithothersep={$\<separator\>$}{$\<value\>$}! + + Adds \<value\> to the \lstinline!i!-index, separated from + any prevous \lstinline!i!-index by~\<separator\>. + + \item + \mylst!i-!, \mylst!islot! + + Adds a slot to the \lstinline!i!-index, + with no separator from any previous \lstinline!i!-index. + + \item + \mylst!si-!, \mylst!sislot! + + Adds a slot to the \lstinline!i!-index, + separated from any previous \lstinline!i!-index + by the default separator. + + \item + \mylst!ci-!, \mylst!cislot! + + Adds a slot to the \lstinline!i!-index, + separated from any previous \lstinline!i!-index + by a comma. + + \item + \mylst!setislot={$\<value\>$}! + + Sets the slot for the \lstinline!i!-index. + By default, this is~\lstinline!{-}!. + + \item + \mylst!i-withothersep={$\<separator\>$}!, + \mylst!islotwithothersep={$\<separator\>$}! + + + Adds a slot to the \lstinline!i!-index, separated + from any previous \lstinline!i!-index by~\<separator\>. + + \item + \mylst!i...!, \mylst!idots! + + Adds three dots to the \lstinline!i!-index, + with no separator from any previous \lstinline!i!-index. + + \item + \mylst!si...!, \mylst!sidots! + + Adds three dots to the \lstinline!i!-index, + separated from any previous \lstinline!i!-index + by the default separator. + + \item + \mylst!ci...!, \mylst!cidots! + + Adds three dots to the \lstinline!i!-index, + separated from any previous \lstinline!i!-index + by a comma. + + \item + \mylst!setidots={$\<value\>$}! + + Sets the dots for the \lstinline!i!-index. + By default, this is~\lstinline!\dots!. + + \item + \mylst!i...withothersep={$\<separator\>$}!, + \mylst!idotswithothersep={$\<separator\>$}! + + Adds three dots to the \lstinline!i!-index, + separated from any previous \lstinline!i!-index + by~\<separator\>. + + \item + \mylst!i*! + + Adds a bullet to the \lstinline!i!-index, + with no separator from any previous \lstinline!i!-index. + + \item + \mylst!i**! + + Adds a double bullet to the \lstinline!i!-index, + with no separator from any previous \lstinline!i!-index. + + \item + \mylst!si*! + + Adds a bullet to the \lstinline!i!-index, + separated from any previous + \lstinline!i!-index by the default separator. + + \item + \mylst!si**! + + Adds a double bullet to the \lstinline!i!-index, + separated from any previous + \lstinline!i!-index by the default separator. + + \item + \mylst!ci*! + + Adds a bullet to the \lstinline!i!-index, + separated from any previous + \lstinline!i!-index by a comma. + + \item + \mylst!ci**! + + Adds a double bullet to the \lstinline!i!-index, + separated from any previous + \lstinline!i!-index by a comma. + + \item + \mylst!i*withothersep={$\<separator\>$}! + + Adds a bullet to the \lstinline!i!-index, + separated from any previous \lstinline!i!-index + by~\<separator\>. + + \item + \mylst!i**withothersep={$\<separator\>$}! + + Adds a double bullet to the \lstinline!i!-index, + separated from any previous \lstinline!i!-index + by~\<separator\>. + + \item + \mylst!cleari! + + Clears the \lstinline!i!-index. + + \item + \mylst!clearprei! + + Clears the pre-\lstinline!i!-index. + + \item + \mylst!clearposti! + + Clears the post-\lstinline!i!-index. +\end{itemize} + +\section{The predefined argument keys}\label{sec:predefined_arg_keys} + +These are the predefined keys that work inside the argument. + +\begin{itemize} + \item + \mylst!execute={$\<code\>$}! + + Executes the \<code\> on the spot. + This is not strictly speaking a logic key, + but this allows you to perform logical + operations that are not allowed + by the other logic keys. + + \item + \mylst!setkeys={$\<keys\>$}!, + \mylst!keysset={$\<keys\>$}! + + Sets the keys \<keys\>. + + \item + \mylst!setkeysx={$\<keys\>$}!, + \mylst!keyssetx={$\<keys\>$}! + + Sets the keys \<keys\>, but fully expands their values. + + \item + \mylst!setargkeys={$\<keys\>$}!, + \mylst!argkeysset={$\<keys\>$}! + + Sets the argument keys \<keys\>. + + \item + \mylst!setargkeysx={$\<keys\>$}!, + \mylst!argkeyssetx={$\<keys\>$}! + + Sets the argynebt keys \<keys\>, but fully expands their values. + + \item + \mylst!setargsinglekeys={$\<keys\>$}!, + \mylst!argsinglekeysset={$\<keys\>$}! + + Sets the argument keys \<keys\>, + but only supports keys taking no values. + This allows the arguments to contain equality + signs without causing issues. + + \item + \mylst!setargsinglekeysx={$\<keys\>$}!, + \mylst!argsinglekeyssetx={$\<keys\>$}! + + Sets the argument keys \<keys\>, + but only supports keys taking no values. + If a key is not found, the value + is fully expanded and printed. + This allows the arguments to contain equality + signs without causing issues. + + \item + \mylst!setoneargsinglekey={$\<key\>$}!, + \mylst!oneargsinglekeyset={$\<key\>$}! + + Sets one single argument key taking no values. + This allows the argument to contain + equality signs and commas without cuasing issues. + + \item + \mylst!setoneargsinglekeyx={$\<key\>$}!, + \mylst!oneargsinglekeysetx={$\<key\>$}! + + Sets one single argument key taking no values, + If the key is not found, the value + is fully expanded and printed. + This allows the argument to contain + equality signs and commas without cuasing issues. + + \item + \mylst!setargwithoutkeyval={$\<value\>$}!, + \mylst!argwithoutkeyvalset={$\<value\>$}! + + Sets the argument, allowing no keyval syntax. + + \item + \mylst!setargwithoutkeyvalx={$\<value\>$}!, + \mylst!argwithoutkeyvalsetx={$\<value\>$}! + + Sets the argument, fully expanding its value, + and allowing no keyval syntax. + + \item + \mylst!default={$\<value\>$}! + + This is the value that is applied whenever + a value is passed to the argument that is not + recognized as a key, e.g.~the~\lstinline!\vx! + in~\lstinline!\vf{\vx}!. + By default, this is set to be equivalent + to~\lstinline!s!. + + \item + \mylst!s={$\<value\>$}! + + Adds the \<value\> to the argument, + separated from any previous argument + by the default separator. + + \item + \mylst!c={$\<value\>$}! + + Adds the \<value\> to the argument, + separated from any previous argument + by a comma. + + \item + \mylst!-!, \mylst!slot! + + Adds a slot to the argument, + separated from any previous argument + by the default separator. + + \item + \mylst!c-!, \mylst!cslot! + + Adds a slot to the argument, + separated from any previous argument + by a comma. + + \item + \mylst!...!, \mylst!dots! + + Adds three dots to the argument, + separated from any previous argument + by the default separator. + + \item + \mylst!c...!, \mylst!cdots! + + Adds three dots to the argument, + separated from any previous argument + by a comma. + + \item + \mylst!othersep={$\<separator\>$}{$\<value\>$}! + + Adds \<value\> to the argument, + separated from any previous argument + by~\<separator\>. + + \item + \mylst!-withothersep={$\<separator\>$}! , + \mylst!slotwithothersep={$\<separator\>$}! + + Adds a slot to the argument, separated + from any previous argument by \<separator\>. + + \item + \mylst!...withothersep={$\<separator\>$}! , + \mylst!dotswithothersep={$\<separator\>$}! + + Adds three dots to the argument, separated + from any previous argument by~\<separator\>. +\end{itemize} + +\section{The programming commands}\label{sec:programming_commands} + +The following commands are available for programming inside \lstinline!execute={...}!: + +\begin{itemize} + \item + \mylst!\SemantexThis! + + Returns the name of the current class or object. The name is stored in the form \mylst!object_$\<name of object without backslash\>$! + or~\mylst!class_$\<name of class without backslash\>$!, + which is the way the names are stored internally. + + \item + \mylst!\SemantexSetKeys{$\<keys\>$}!, + \mylst!\SemantexKeysSet{$\<keys\>$}! + + Sets the \<keys\>. + + \item + \mylst!\SemantexSetKeysx{$\<keys\>$}!, + \mylst!\SemantexKeysSetx{$\<keys\>$}! + + Sets the \<keys\>, but fully expands their values. + + \item + \mylst!\SemantexSetArgKeys{$\<keys\>$}!, + \mylst!\SemantexArgKeysSet{$\<keys\>$}! + + Sets the argument \<keys\>. + + \item + \mylst!\SemantexSetArgKeysx{$\<keys\>$}!, + \mylst!\SemantexArgKeysSetx{$\<keys\>$}! + + Sets the argument \<keys\>, but fully expands their values. + + \item + \mylst!\SemantexSetArgSingleKeys{$\<keys\>$}!, + \mylst!\SemantexArgSingleKeysSet{$\<keys\>$}! + + Sets the argument keys \<keys\>, + but only supports keys taking no values. + This allows the arguments to contain equality + signs without causing issues. + + \item + \mylst!\SemantexSetArgSingleKeysx{$\<keys\>$}!, + \mylst!\SemantexArgSingleKeysSetx{$\<keys\>$}! + + Sets the argument keys \<keys\>, + but only supports keys taking no values. + If a key is not found, the value + is fully expanded and printed. + This allows the arguments to contain equality + signs without causing issues. + + \item + \mylst!\SemantexSetOneArgSingleKey{$\<keys\>$}!, + \mylst!\SemantexOneSingleArgKeySet{$\<keys\>$}! + + Sets one single argument key taking no values. + This allows the argument to contain + equality signs and commas without cuasing issues. + + \item + \mylst!\SemantexSetOneArgSingleKeyx{$\<keys\>$}!, + \mylst!\SemantexOneSingleArgKeySetx{$\<keys\>$}! + + Sets one single argument key taking no values, + If the key is not found, the value + is fully expanded and printed. + This allows the argument to contain + equality signs and commas without cuasing issues. + + \item + \mylst!\SemantexSetArgWithoutKeyval{$\<value\>$}!, + \mylst!\SemantexArgWithoutKeyvalSet{$\<value\>$}! + + Sets the argument, allowing no keyval syntax. + + \item + \mylst!\SemantexSetArgWithoutKeyval{$\<value\>$}!, + \mylst!\SemantexArgWithoutKeyvalSet{$\<value\>$}! + + Sets the argument, fully expanding its value, + and allowing no keyval syntax. + + \item + \mylst!\SemantexDataProvide{$\<data\>$}! + + Provides a new piece of data consisting of a token list. + + \item + \mylst!\SemantexDataSet{$\<data\>$}{$\<value\>$}! + + Sets the \<data\> to \<value\>. + + \item + \mylst!\SemantexDataSetx{$\<data\>$}{$\<value\>$}! + + Sets the \<data\> to \<value\>, but fully expands the \<value\> first. + + \item + \mylst!\SemantexDataPutLeft{$\<data\>$}{$\<value\>$}! + + Adds the \<value\> to the left of \<data\>. + + \item + \mylst!\SemantexDataPutLeftx{$\<data\>$}{$\<value\>$}! + + Adds the \<value\> to the left of \<data\>, but fully expands the \<value\> first. + + \item + \mylst!\SemantexDataPutRight{$\<data\>$}{$\<value\>$}! + + Adds the \<value\> to the right of \<data\>. + + \item + \mylst!\SemantexDataPutRightx{$\<data\>$}{$\<value\>$}! + + Adds the \<value\> to the right of \<data\>, but fully expands the \<value\> first. + + \item + \mylst!\SemantexDataGet{$\<data\>$}! + + Returns the value of \<data\>. + + \item + \mylst!\SemantexDataGetExpNot{$\<data\>$}! + + Returns the value of \<data\>, + enclosed in \lstinline!\unexpanded! + so that it can be used within an \lstinline!x!-type + expansion. + + \item + \mylst!\SemantexDataClear{$\<data\>$}! + + Clears the piece of data~\<data\>. + + \item + \mylst!\SemantexBoolProvide{$\<boolean\>$}! + + Provides a new piece of data consisting of a boolean. + + \item + \mylst!\SemantexBoolSetTrue{$\<boolean\>$}! + + Sets the \<boolean\> to true. + + \item + \mylst!\SemantexBoolSetFalse{$\<boolean\>$}! + + Sets the \<boolean\> to false. + + \item + \mylst!\SemantexBoolIfTF{$\<boolean\>$}{$\<if true\>$}{$\<if false\>$}!,\\ + \mylst!\SemantexBoolIfT{$\<boolean\>$}{$\<if true\>$}!,\\ + \mylst!\SemantexBoolIfF{$\<boolean\>$}{$\<if false\>$}! + + Runs \<if~true\> or \<if~false\>, depending on the value of \<boolean\>. + + \item + \mylst!\SemantexIntProvide{$\<integer\>$}! + + Provides a new piece of data consisting of an integer. + + \item + \mylst!\SemantexIntGet{$\<integer\>$}! + + Returns the value of the \<integer\>. + + \item + \mylst!\SemantexIntSet{$\<integer\>$}{$\<value\>$}! + + Sets the \<integer\> to \<value\>. + + \item + \mylst!\SemantexIntIncr{$\<integer\>$}! + + Increases the \<integer\> by~\( 1 \). + + \item + \mylst!\SemantexIntIfEqTF{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\ + \mylst!\SemantexIntIfEqT$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}!, \\ + \mylst!\SemantexIntIfEqF{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if false\>$}! + + Checks whether the integers \<integer\num{1}\> and \<integer\num{2}\> are equal, + and runs \<if~true\> or \<if~false\> accordingly. + + \item + \mylst!\SemantexIntIfGreaterTF{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\ + \mylst!\SemantexIntIfGreaterT{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}!, \\ + \mylst!\SemantexIntIfGreaterF{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if false\>$}! + + Checks whether the integer \<integer\num{1}\> is greater than~\<integer\num{2}\>, + and runs \<if~true\> or \<if~false\> accordingly. + + \item + \mylst!\SemantexIntIfLessTF{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\ + \mylst!\SemantexIntIfLessT{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if true\>$}!, \\ + \mylst!\SemantexIntIfLessF{$\<integer\num{1}\>$}{$\<integer\num{2}\>$}{$\<if false\>$}! + + Checks whether the integer \<integer\num{1}\> is less than~\<integer\num{2}\>, + and runs \<if~true\> or \<if~false\> accordingly. + + \item + \mylst!\SemantexIntClear{$\<integer\>$}! + + Clears the \<integer\>. + + \item + \mylst!\SemantexIfBlankTF{$\<tokens\>$}{$\<if true\>$}{$\<if false\>$}!,\\ + \mylst!\SemantexIfBlankT{$\<tokens\>$}{$\<if true\>$}!,\\ + \mylst!\SemantexIfBlankF{$\<tokens\>$}{$\<if false\>$}! + + Fully expands the \<tokens\> and checks if it is blank, + and runs \<if true\> or \<if false\> according to this. + + \item + \mylst!\SemantexStrIfEqTF{$\<string\num{1}\>$}{$\<string\num{2}\>$}{$\<if true\>$}{$\<if false\>$}!, \\ + \mylst!\SemantexStrIfEqT{$\<string\num{1}\>$}{$\<string\num{2}\>$}{$\<if true\>$}!, \\ + \mylst!\SemantexStrIfEqF{$\<string\num{1}\>$}{$\<string\num{2}\>$}{$\<if false\>$}! + + Checks whether the strings \<string\num{1}\> and \<string\num{2}\> are equal, + and runs \<if~true\> or \<if~false\> accordingly. + + \item + \mylst!\SemantexERROR{$\<error message\>$}! + + Issues an generic error message. At the end of the message, it automatically adds \enquote{object~\usercommand\<object name\> on line~\<line number\>} + or \enquote{class~\usercommand\<Class name\> on line~\<line number\>}. + + \item + \mylst!\SemantexERRORKeyValueNotFound{$\<key\>$}{$\<value\>$}! + + Issues an error, saying that the key~\<key\> was set to the unknown value~\<value\>. -For now, the system seems to work fine as long as you do \enquote{normal} things. The only real bug that I currently know of occurs if you use the key~\lstinline!Otherspar! in a heading. Then it all dies painfully. -Then again, why the heck would you do that in the first place? Who scales parentheses in headings? + \item + \mylst!\SemantexERRORArgKeyValueNotFound{$\<key\>$}{$\<value\>$}! + + Issues an error, saying that the argument key~\<key\> was set to the unknown value~\<value\>. -%\input{testground} + \item + \mylst!\SemantexExpNot{$\<value\>$}! + + An alias for \lstinline!\unexpanded! (also known as \lstinline!\exp_not:N! in~\LaTeX3). +\end{itemize} + +\section{The class types} + +The \semantex system uses several different \emph{class types}. +In fact, all class types are identical internally; the low-level machinery of \semantex does not \enquote{know} what type a class has. +The only difference between the class types is the \emph{input syntax}. +In other words, it determines which arguments an object of that class +can take. The syntax for creating new objects +also varies. + +The current implementation has the following +class types: + +\begin{itemize} + \item \lstinline!Variable!: + A new class is declared with the + syntax + \begin{lstlisting} + \NewVariableClass{@\usercommand\<Class\>@}[@\<options\>@] + \end{lstlisting} + A new object is declared by + \begin{lstlisting} + \NewObject@\usercommand\<Class\>@@\usercommand\<object\>@{@\<symbol\>@}[@\<options\>@] + \end{lstlisting} + The syntax for this object is + \begin{lstlisting} + @\usercommand\<object\>@[@\<options\>@]{@\<argument\>@} + \end{lstlisting} + \item \lstinline!Cohomology!: + A new class is declared with the + syntax + \begin{lstlisting} + \NewCohomologyClass@\usercommand\<Class\>@[@\<options\>@] + \end{lstlisting} + A new object is declared by + \begin{lstlisting} + \NewObject@\usercommand\<Class\>@@\usercommand\<object\>@{@\<symbol\>@}[@\<options\>@] + \end{lstlisting} + The syntax for this object is + \begin{lstlisting} + @\usercommand\<object\>@[@\<options\>@]{@\<degree\>@}{@\<argument\>@} + \end{lstlisting} + \item \lstinline!Symbol!: + A new class is declared with the + syntax + \begin{lstlisting} + \NewSimpleClass@\usercommand\<Class\>@[@\<options\>@] + \end{lstlisting} + A new object is declared by + \begin{lstlisting} + \NewObject@\usercommand\<Class\>@@\usercommand\<object\>@{@\<symbol\>@}[@\<options\>@] + \end{lstlisting} + The syntax for this object is + \begin{lstlisting} + @\usercommand\<object\>@[@\<options\>@] + \end{lstlisting} + \item \lstinline!Delimiter!: + A new class is declared with the syntax + \begin{lstlisting} + \NewDelimiterClass@\usercommand\<Class\>@[@\<options\>@] + \end{lstlisting} + A new object is declared by + \begin{lstlisting} + \NewObject@\usercommand\<Class\>@@\usercommand\<object\>@{@\<left bracket\>@}{@\<right bracket\>@}[@\<options\>@] + \end{lstlisting} + The syntax for this object is + \begin{lstlisting} + @\usercommand\<object\>@[@\<options\>@]{@\<argument\>@} + \end{lstlisting} + \item \lstinline!Simple!: + A new class is declared with the + syntax + \begin{lstlisting} + \NewSimpleClass@\usercommand\<Class\>@[@\<options\>@] + \end{lstlisting} + A new object is declared by + \begin{lstlisting} + \NewObject@\usercommand\<Class\>@@\usercommand\<object\>@{@\<symbol\>@}[@\<options\>@] + \end{lstlisting} + The syntax for this object is + \begin{lstlisting} + @\usercommand\<object\>@ + \end{lstlisting} +\end{itemize} + +Let me add that \semantex uses a very clear separation between the input syntax and the underlying machinery. Because of this, if the user needs a different kind of class type, it is not very hard to create one. You must simply open the source code of \semantex, find the class you want to modify, and then copy the definition of the command~\mylst!\New$\<Class type\>$Class! and modify it in whatever way you want. + +The last class type, called \lstinline!Simple!, +is the class type of the class~\lstinline!\SemantexBaseObject!. This class is pretty useless as all it does is print its symbol, without allowing any keyval syntax. So you simply should not use it. + +\section{The predefined data} + +By default, the following data are defined for each class or object and are accessible via +the programming keys and commands: + +\begin{itemize} + \item + \mylst!symbol! + (token list): + the symbol. + \item + \mylst!output! + (token list): + the name of the output class. + \item + \mylst!outputoptions! + (token list): + the output options, i.e.~the options to be passed to the output class. + \item + \mylst!parseoptions! + (token list): + the parse options, i.e.~the options that are invoked + during the parse routine. + \item + \mylst!texclass! + (token list): + the \TeX\ character class command that the final output + is evnetually wrapped around; + the intended use of this is the \TeX\ commands + \lstinline!\mathord!, \lstinline!\mathop!, \lstinline!\mathbin!, \lstinline!\mathrel!, \lstinline!\mathopen!, \lstinline!\mathclose!, and~\lstinline!\mathpunct!. + \item + \lstinline!heightphantom! + (token list): + the height phantom that is used + for calculating the height of left indices. + \item + \lstinline!slantingphantom! + (token list): + the slanting phantom that is used for + calculating the slanting of left indices. + \item + \lstinline!parsize! + (token list): + the size of the argument parentheses. + Here, the value~\lstinline!normal! means normal size + parentheses, + \lstinline!auto! and~\lstinline!*! + mean auto-scaled parentheses using~\lstinline!\left...\right!. + If another value is received, that value + is used for the parenthesis size, + so the intended values are~\lstinline!\big!, \lstinline!\Big!, + \lstinline!\bigg!,~\lstinline!\Bigg!. + The default value is \lstinline!normal!. + \item + \lstinline!leftpar! + (token list): + the left argument parenthesis; + the default value is~\lstinline!(!. + \item + \lstinline!rightpar! + (token list): + the right argument parenthesis; + the default value is~\lstinline!)!. + \item + \lstinline!sparsize! + (token list): + the size of the symbol parentheses (for use with the \lstinline!spar!~routine). + Here, the value~\lstinline!normal! means normal size + parentheses, + \lstinline!auto! and~\lstinline!*! + mean auto-scaled parentheses using~\lstinline!\left...\right!. + If another value is received, that value + is used for the parenthesis size, + so the intended values are~\lstinline!\big!, \lstinline!\Big!, + \lstinline!\bigg!,~\lstinline!\Bigg!. + The default value is \lstinline!normal!. + \item + \lstinline!leftspar! + (token list): + the left symbol parenthesis (for use with the \lstinline!spar!~routine); + the default value is~\lstinline!(!. + \item + \lstinline!rightspar! + (token list): + the right symbol parenthesis (for use with the \lstinline!spar!~routine); + the default value is~\lstinline!)!. + \item + \lstinline!arg! + (token list): + the argument. + \item + \lstinline!prearg! + (token list): + to be printed in front of the argument, if the argument is non-empty. + \item + \lstinline!postarg! + (token list): + to be printed after the argument, if the argument is non-empty. + \item + \lstinline!argsep! + (token list): + the argument separator; + comma by default. + \item + \lstinline!argslot! + (token list): + the argument slot; + \lstinline!{-}!~by default. + \item + \lstinline!argdots! + (token list): + the argument dots; + \lstinline!\dots!~by default. + % Upper index: + \item + \lstinline!upper! + (token list): + the upper index. + \item + \lstinline!preupper! + (token list): + the pre-upper index, to be printed in front of the upper index, + if the upper index is non-empty. + \item + \mylst!postupper! + (token list) + the post-upper index, to be printed after the upper index, + if the upper index is non-empty. + \item + \mylst!uppersep! + (token list): + the upper index separator; + comma by default. + \item + \mylst!upperdots! + (token list): + the upper dots; \lstinline!\dots!~by default. + \item + \mylst!upperslot! + (token list): + the upper slot; \lstinline!{-}!~by default. + % Lower index: + \item + \lstinline!lower! + (token list): + the lower index. + \item + \lstinline!prelower! + (token list): + the pre-lower index, to be printed in front of the lower index, + if the lower index is non-empty. + \item + \mylst!postlower! + (token list) + the post-lower index, to be printed after the lower index, + if the lower index is non-empty. + \item + \mylst!lowersep! + (token list): + the lower index separator; + comma by default. + \item + \mylst!lowerdots! + (token list): + the lower dots; \lstinline!\dots!~by default. + \item + \mylst!lowerslot! + (token list): + the lower slot; \lstinline!{-}!~by default. + % Upper left index: + \item + \lstinline!upperleft! + (token list): + the upper left index. + \item + \lstinline!preupperleft! + (token list): + the pre-upper left index, to be printed in front of the upper left index, + if the upper left index is non-empty. + \item + \mylst!postupperleft! + (token list) + the post-upper left index, to be printed after the upper left index, + if the upper left index is non-empty. + \item + \mylst!upperleftsep! + (token list): + the upper left index separator; + comma by default. + \item + \mylst!upperleftdots! + (token list): + the upper left dots; \lstinline!\dots!~by default. + \item + \mylst!upperleftslot! + (token list): + the upper left slot; \lstinline!{-}!~by default. + % Lower left index: + \item + \lstinline!lowerleft! + (token list): + the lower left index. + \item + \lstinline!prelowerleft! + (token list): + the pre-lower left index, to be printed in front of the lower left index, + if the lower left index is non-empty. + \item + \mylst!postlowerleft! + (token list) + the post-lower left index, to be printed after the lower left index, + if the lower left index is non-empty. + \item + \mylst!lowerleftsep! + (token list): + the lower left index separator; + comma by default. + \item + \mylst!lowerleftdots! + (token list): + the lower left dots; \lstinline!\dots!~by default. + \item + \mylst!lowerleftslot! + (token list): + the lower left slot; \lstinline!{-}!~by default. + \item + \mylst!uppergrading! + (boolean): + whether or not to use + upper (cohomological) grading; true by default. + \item + \mylst!par! + (boolean): + whether or not to use parentheses; true by default. + \item + \mylst!flexpar! + (boolean): + if \mylst!par! is set to false, setting \mylst!flexpar! to true + will still print a pair of parentheses when there is more than one argument; + false by default. + \item + \mylst!leftargument! + (boolean): + if true, the argument (and parentheses) + will be printed to the \emph{left} of the symbol; + false by default. + \item + \mylst!nextargwithsep! + (boolean): + if true, the next argument will have a separator printed in front of it. + \item + \mylst!nextupperwithsep! + (boolean): + If true, the next upper index will have a separator printed in front of it. + \item + \mylst!nextlowerwithsep! + (boolean): + If true, the next lower index will have a separator printed in front of it. + \item + \mylst!nextupperleftwithsep! + (boolean): + If true, the next upper left index will have a separator printed in front of it. + \item + \mylst!nextlowerleftwithsep! + (boolean): + If true, the next lower upper index will have a separator printed in front of it. + \item + \mylst!allowSemantexDelimiterSize! + (boolean): + if true, the argument will + allow the command \lstinline!\SemantexDelimiterSize! + inside the argument; + the default is~\lstinline!true!. + The only real reason to turn this off is if you are using + \lstinline!stripsemantex! to strip the document of \semantex markup. + For if it is set to false, the system will not + add \lstinline!\SemantexParentheses! and \lstinline!\SemantexNoParentheses! + all over the place to set the value of \lstinline!\SemantexDelimiterSize!, + and this probably looks better in the outputted code. + \item + \mylst!numberofarguments! + (integer): + the number of arguments. + \item + \mylst!numberofupperindices! + (integer): + the number of upper indices. + \item + \mylst!numberoflowerindices! + (integer): + the number of lower indices. + \item + \mylst!numberofupperleftindices! + (integer): + the number of upper left indices. + \item + \mylst!numberoflowerindices! + (integer): + the number of lower left indices. +\end{itemize} \end{document}
\ No newline at end of file diff --git a/macros/latex/contrib/semantex/stripsemantex.lua b/macros/latex/contrib/semantex/stripsemantex.lua new file mode 100644 index 0000000000..769d5b0551 --- /dev/null +++ b/macros/latex/contrib/semantex/stripsemantex.lua @@ -0,0 +1,212 @@ +-- aliases for protected environments +local assert, io_open + = assert, io.open + +-- load the ltn12 module +local ltn12 = require("ltn12") + +-- No more global accesses after this point +if _VERSION == "Lua 5.2" then _ENV = nil end + +-- copy a file +copy_file = function(path_src, path_dst) + ltn12.pump.all( + ltn12.source.file(assert(io_open(path_src, "rb"))), + ltn12.sink.file(assert(io_open(path_dst, "wb"))) + ) +end + +openFile = function(file) + f = io.open(file, "r") + filecontent = f:read("*all") + local beginDocPosition = filecontent:find('\\begin{document}') + if not beginDocPosition then + tex.sprint( [[\begingroup\ExplSyntaxOn + \msg_fatal:nnn { stripsemantex } { begin_document_not_found } { ]] .. file .. [[ } + \endgroup]] ) + return + end + precontent = filecontent:sub(1,beginDocPosition-1) + content = filecontent:sub(beginDocPosition,-1) + f:close() +end + +closeFile = function(file) + f = io.open(file, "w") + f:write(precontent .. content) + f:close() +end + +removeStricttexFormatting = function(str) + -- We do this in case the package "stricttex" was used + str = str:gsub('numberZERO','0') + str = str:gsub('numberONE','1') + str = str:gsub('numberTWO','2') + str = str:gsub('numberTHREE','3') + str = str:gsub('numberFOUR','4') + str = str:gsub('numberFIVE','5') + str = str:gsub('numberSIX','6') + str = str:gsub('numberSEVEN','7') + str = str:gsub('numberEIGHT','8') + str = str:gsub('numberNINE','9') + str = str:gsub('symbolPRIME','\'') + return str +end + +addIDsToRegisters = function(str) + str = removeStricttexFormatting(str) + content = content:gsub('\\' .. str .. '%f[^%a]' ,'\\SemantexIDcommand{}\\' .. str) +end + +removeSuperfluousIDs = function() + content = content:gsub('parent(%s*)=(%s*)\\SemantexIDcommand{}','parent%1=%2') + content = content:gsub('class(%s*)=(%s*)\\SemantexIDcommand{}','class%1=%2') + content = content:gsub('clone(%s*)=(%s*)\\SemantexIDcommand{}','clone%1=%2') + content = content:gsub('copy(%s*)=(%s*)\\SemantexIDcommand{}','copy%1=%2') + content = content:gsub('\\New(%w+)Class(%s*{?)\\SemantexIDcommand{}','\\New%1Class%2') + content = content:gsub('\\NewObject(%s*{?%s*)\\SemantexIDcommand{}(\\%w+%s*}?%s*{?%s*)\\SemantexIDcommand{}', '\\NewObject%1%2') + content = content:gsub('\\SetupClass(%s*{?%s*)\\SemantexIDcommand{}', '\\SetupClass%1') + content = content:gsub('\\SetupObject(%s*{?%s*)\\SemantexIDcommand{}', '\\SetupObject%1') +end + +addNumbersToIDs = function() + local n = 1 + local p,q = string.find(content,'\\SemantexIDcommand{}') + while q do + content = content:sub(1,q-1) .. n .. content:sub(q,-1) + p, q = string.find(content,'\\SemantexIDcommand{}') + n = n + 1 + end +end + +semantexIDluacommand = function(id, source, output) + local p, q = string.find(content, '\\SemantexIDcommand{' .. id .. '}') + + while p do + content = content:sub(1,p-1) .. content:sub(q+1,-1) + + source = source:gsub('%s+', '') + + -- We do this in case the package "stricttex" was used + source = removeStricttexFormatting(source) + + -- This is because #1's in the code becomes ##1 + -- in the .semtex file. + source = source:gsub('#(%d)', '%1') + + local length = source:len() + + local i = 1 + + local s + + while i <= length do + s = content:sub(p,p) + if s == source:sub(i,i) then + content = content:sub(1 , p-1) .. content:sub(p+1, -1) + i = i + 1 + elseif s:match('%s') then + content = content:sub(1, p-1) .. content:sub (p+1, -1) + elseif s == '%' then + content = content:sub(1 , p-1) .. content:sub(p,-1):gsub('%%.-\n','',1) + elseif s == '{' then + -- In this case, we remove the corresponding right brace, + -- once we find it + local netto = 1 -- The current brace group level + local q = 0 -- The position we have moved forward so far + while netto > 0 do + q = q + 1 + local e = content:sub(p+q,p+q) + if e == '}' then + netto = netto - 1 + elseif e == '{' then + netto = netto + 1 + elseif e == '\\' then + q = q + 1 + end + end + content = content:sub(1,p-1) .. content:sub(p+1,p+q-1) .. content:sub(p+q+1,-1) + else + tex.sprint( [[\begingroup\ExplSyntaxOn + \msg_fatal:nnnn { stripsemantex } { source_not_expected } { ]] .. source:sub(i,i) .. [[ } { ]] .. s .. [[ } + \endgroup]] ) + break + end + end + + + output = output:gsub('%s*\\sp {', '^{') + output = output:gsub('%s*\\sb {', '_{') + output = output:gsub('\\mathopen \\big ', '\\bigl') + output = output:gsub('\\mathclose \\big ', '\\bigr') + output = output:gsub('\\mathopen \\Big ', '\\Bigl') + output = output:gsub('\\mathclose \\Big ', '\\Bigr') + output = output:gsub('\\mathopen \\bigg ', '\\biggl') + output = output:gsub('\\mathclose \\bigg ', '\\biggr') + output = output:gsub('\\mathopen \\Bigg ', '\\Biggl') + output = output:gsub('\\mathclose \\Bigg ', '\\Biggr') + output = output:gsub('\\mathopen %(', '(') + output = output:gsub('\\mathclose %)', ')') + output = output:gsub('\\mathopen %[', '[') + output = output:gsub('\\mathclose %]', ']') + output = output:gsub('\\mathopen \\{', '\\{') + output = output:gsub('\\mathclose \\}', '\\}') + output = output:gsub('\\mathopen \\lbrace', '\\lbrace') + output = output:gsub('\\mathclose \\rbrace', '\\rbrace') + output = output:gsub('\\mathopen \\lbrack', '\\rbrack') + output = output:gsub('\\mathclose \\rbrack', '\\rbrack') + output = output:gsub('\\mathopen \\langle', '\\langle') + output = output:gsub('\\mathclose \\rangle', '\\rangle') + output = output:gsub('\\mathopen \\lvert', '\\rvert') + output = output:gsub('\\mathclose \\rvert', '\\rvert') + output = output:gsub('\\mathopen \\lVert', '\\rVert') + output = output:gsub('\\mathclose \\rVert', '\\rVert') + + output = output:gsub('%s+%f[{}%[%]%(%)%$,]','') + output = output:gsub('([}%]%)])%f[\\%w%+%-%(%[=]', '%1 ') + output = output:gsub(',',', ') + output = output:gsub('%s+$', '') + + + -- We now check whether the string we add will follow right + -- after a control sequence, causing it to be interpreted + -- as part of that control sequence. + -- Because we want to allow the user to use stricttex, we + -- check for alphanumerical control sequences rather than + -- just alphabetic ones. This could add spaces that + -- the user might not have intended, but it's a minor issue. + if output:sub(1,1):match('%w') and content:sub(1, p-1):match('\\%w+$') then + content = content:sub(1,p-1) .. ' ' .. output .. content:sub(p,-1) + else + content = content:sub(1,p-1) .. output .. content:sub(p,-1) + end + p, q = string.find(content, '\\SemantexIDcommand{' .. id .. '}') + end +end + +stripRemainingSemantexIDs = function() + content = content:gsub('\\SemantexIDcommand{%d+}', '') +end + +addSemtexPackageToFile = function() + content = [[% The following was added by "stripsemantex" + +\usepackage{semtex,leftindex,graphicx} + +\providecommand\SemantexLeft{% + \mathopen{}\mathclose\bgroup\left +} + +\providecommand\SemantexRight{% + \aftergroup\egroup\right +} + +\providecommand\SemantexBullet{% + \raisebox{-0.25ex}{\scalebox{1.2}{$\cdot$}}% +} +\providecommand\SemantexDoubleBullet{% + \SemantexBullet\SemantexBullet +} + +]] .. content +end
\ No newline at end of file diff --git a/macros/latex/contrib/semantex/stripsemantex.sty b/macros/latex/contrib/semantex/stripsemantex.sty new file mode 100644 index 0000000000..eba5638624 --- /dev/null +++ b/macros/latex/contrib/semantex/stripsemantex.sty @@ -0,0 +1,114 @@ +\ProvidesExplPackage{stripsemantex}{2020/09/07}{0.1alpha}{} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% stripSemanTeX -- strip the document of SemanTeX markup % +% https://ctan.org/pkg/semantex % +% (C) 2020 Sebastian Ørsted % +% sorsted@gmail.com % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\msg_new:nnn { stripsemantex } { not_luatex } { This~package~only~works~with~LuaTeX;~the~current~TeX~run~has~been~terminated. } + +\msg_new:nnn { stripsemantex } { source_not_expected } { The~source~code~in~the~file~did~not~fit~the~code~in~the~.semtex~file.~We~expected~#1~but~got~#2.~This~is~not~supposed~to~happen.~Please~report~this~bug~ASAP. } + +\msg_new:nnn { stripsemantex } { no_semtex_file } { The~file~#1.semtex~was~not~found.~Did~you~remember~to~do \\ \token_to_str:N\SemantexSetup{semtexfile=true}? } + +\msg_new:nnn { stripsemantex } { begin_document_not_found } { No~\token_to_str:N\begin{document}~found~in~the~file~#1;~it~has~to~be~in~the~main~document. } + +\sys_if_engine_luatex:F { \msg_fatal:nn { stripsemantex } { not_luatex } } + +\lua_now:n { require('stripsemantex.lua') } + +\cs_new_protected:Npn\stripsemantex_create_prestripped_file:n#1 +{ + \file_if_exist:nF { #1.semtex } + { + \msg_fatal:nnn { stripsemantex } { no_semtex_file } { #1 } + } + + \lua_now:e { + copy_file('\lua_escape:e{#1}.tex', '\lua_escape:e{#1}_prestripped.tex') + openFile('\lua_escape:e{#1}_prestripped.tex') + } + + \cs_set:Npn\DeclareObject##1 + { + \lua_now:e { addIDsToRegisters ( '\cs_to_str:N ##1' ) } + } + + \cs_set:Npn\DeclareClass##1{ + \lua_now:e { addIDsToRegisters ( '\cs_to_str:N ##1' ) } + } + + \cs_set:Npn\BeginSource##1\EndSource\BeginOutput##2\EndOutput{} + + \file_input:n { #1.semtex } + + \lua_now:e + { + removeSuperfluousIDs() + addNumbersToIDs() + closeFile('\lua_escape:e{#1}_prestripped.tex') + } +} + +\cs_new_protected:Npn\stripsemantex_create_stripped_file:n#1 +{ + \file_if_exist:nF { #1_prestripped.semtex } + { + \msg_fatal:nnn { stripsemantex } { no_semtex_file } { #1_prestripped } + } + + \lua_now:e { + copy_file('\lua_escape:e{#1}_prestripped.tex', '\lua_escape:e{#1}_stripped.tex') + openFile('\lua_escape:e{#1}_stripped.tex') + } + + \cs_set:Npn\SemantexID##1\BeginSource##2\EndSource\BeginOutput##3\EndOutput + { + \lua_now:e + { + semantexIDluacommand( '\lua_escape:e{\tl_trim_spaces:n{##1}}' , '\lua_escape:e{\exp_not:n{##2}}' , '\lua_escape:e{\exp_not:n{##3}}' ) + } + } + + \cs_set:Npn\DeclareObject##1{} + + \cs_set:Npn\DeclareClass##1{} + + \cs_set:Npn\BeginSource##1\EndSource\BeginOutput##2\EndOutput{} + + \file_input:n { #1_prestripped.semtex } + + \lua_now:e + { + stripRemainingSemantexIDs() + addSemtexPackageToFile() + closeFile('\lua_escape:e{#1}_stripped.tex') + } +} + +\cs_set_eq:NN\StripSemantexCopyFile\stripsemantex_create_prestripped_file:n + +\cs_new_protected:Npn\StripSemantexStripFile#1 +{ + \begingroup + \ExplSyntaxOn + \stripsemantex_create_stripped_file:n { #1 } +% \ExplSyntaxOff + \endgroup +} + +\cs_new_protected:Npn\StripSemantex#1 +{ + % This will only work after a bug has been corrected in expl3 + \file_compare_timestamp:nNnTF { #1.semtex } < { #1_prestripped.semtex } + { + \StripSemantexStripFile { #1 } + } + { + \StripSemantexCopyFile { #1 } + } +}
\ No newline at end of file diff --git a/macros/latex/contrib/semtex/README.md b/macros/latex/contrib/semtex/README.md new file mode 100644 index 0000000000..d74f5f9f5c --- /dev/null +++ b/macros/latex/contrib/semtex/README.md @@ -0,0 +1,37 @@ +semtex -- For stripped SemanTeX documents +-------------------------------------- + +The package semtex is a small LaTeX package that adds a collection +of simple macros for parentheses and bullets. It exists for +one purpose only: To be loaded by documents which were +originally typeset using the package SemanTeX, but which have +been stripped of SemanTeX markup using the package stripsemantex. +Therefore, unless your document is one of those, +simply **don't use this package**. + +And even if your document *is* one of those, there is a good +chance you will not have to load it after all. In most cases, +you will be able to replace the macros it provides by macros +from other packages. + +---------------------------------------------------------------- +semtex -- For stripped SemanTeX documents +Maintained by Sebastian Ørsted +E-mail: sorsted@gmail.com +Released under the LaTeX Project Public License v1.3c or later +See http://www.latex-project.org/lppl.txt +---------------------------------------------------------------- + +Copyright (C) 2020 by Sebastian Ørsted <sorsted@gmail.com> + +The package is loaded via \usepackage{semantex} + +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 +Sebastian Ørsted.
\ No newline at end of file diff --git a/macros/latex/contrib/semtex/semtex.pdf b/macros/latex/contrib/semtex/semtex.pdf Binary files differnew file mode 100644 index 0000000000..5ac49589d8 --- /dev/null +++ b/macros/latex/contrib/semtex/semtex.pdf diff --git a/macros/latex/contrib/semtex/semtex.sty b/macros/latex/contrib/semtex/semtex.sty new file mode 100644 index 0000000000..1824d0389c --- /dev/null +++ b/macros/latex/contrib/semtex/semtex.sty @@ -0,0 +1,83 @@ +\RequirePackage{xparse} +\ProvidesExplPackage{semtex}{2020/09/07}{0.1beta}{} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% semtex -- for documents stripped of SemanTeX markup % +% https://ctan.org/pkg/semantex % +% (C) 2020 Sebastian Ørsted % +% sorsted@gmail.com % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Bullets: + +\box_new:N \g__semantex_bullet_box +\hbox_set:Nn \g__semantex_bullet_box { $\cdot$ } +\box_scale:Nnn \g__semantex_bullet_box {1.2} {1.2} +\tl_set:Nn\g_semantex_bullet +{ + \box_move_up:nn{-0.25ex}{\box_use:N \g__semantex_bullet_box} +} + +\tl_set:Nn\g_semantex_double_bullet{\g_semantex_bullet \g_semantex_bullet} + +\tl_set_eq:NN\SemantexBullet \g_semantex_bullet + +\tl_set_eq:NN \SemantexDoubleBullet \g_semantex_double_bullet + + +% Parentheses: + +\cs_new:Npn\SemantexLeft { \mathopen{}\mathclose\bgroup\left } + +\cs_new:Npn\SemantexRight { \aftergroup\egroup\right } + +\tl_new:N\SemantexDelimiterSize + +\DeclareDocumentCommand\SemantexParentheses { mmmm } +{ + \str_case:nnF { #1 } % This is where \big,\Big, etc. go. + { + { normal } { + \group_begin: + \tl_clear:N \SemantexDelimiterSize + \str_if_eq:nnF { #2 } { . } { \mathopen #2 } + #4 + \str_if_eq:nnF { #3 } { . } { \mathclose #3 } + \group_end: + } + { auto } { + \group_begin: + \tl_set_eq:NN \SemantexDelimiterSize \middle + \SemantexLeft #2 + #4 + \SemantexRight #3 + \group_end: + } + { * } { + \group_begin: + \tl_set_eq:NN \SemantexDelimiterSize \middle + \SemantexLeft #2 + #4 + \SemantexRight #3 + \group_end: + } + } + { + \group_begin: + \tl_set_eq:NN\SemantexDelimiterSize #1 + \mathopen #1 #2 + #4 + \mathclose #1 #3 + \group_end: + } +} + +\DeclareDocumentCommand\SemantexNoParentheses { m } +{ + \group_begin: + \tl_clear:N\SemantexDelimiterSize + #1 + \group_end: +}
\ No newline at end of file diff --git a/macros/latex/contrib/semtex/semtex.tex b/macros/latex/contrib/semtex/semtex.tex new file mode 100644 index 0000000000..10805c37bd --- /dev/null +++ b/macros/latex/contrib/semtex/semtex.tex @@ -0,0 +1,229 @@ +\documentclass[a4paper,article,oneside,english,10pt]{memoir} + +\makeatletter + +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +\usepackage{babel} +\usepackage[noDcommand,slantedGreeks]{kpfonts} + +\frenchspacing + +\usepackage{mathtools,etoolbox, microtype,xspace,color} + +\usepackage[shortlabels]{enumitem}%control lists + +\usepackage[draft]{fixme} + +%Setup of memoir: +\pagestyle{plain} %change to heading for running headings +\nouppercaseheads %running heads should not be capitalized +\captionnamefont{\small} %captions with small font +\captiontitlefont{\small} +\makeevenhead{headings}{\thepage}{}{\itshape\leftmark} %make headings italic instead of slanted (though we do not use headings right now) +\makeoddhead{headings}{\itshape\rightmark}{}{\thepage} + +\setlrmarginsandblock{4cm}{*}{*} +\setulmarginsandblock{4cm}{*}{*} +\checkandfixthelayout + +\raggedbottomsectiontrue%less harse than \raggedbottom +%\allowdisplaybreaks %long equations may break + +\g@addto@macro\bfseries{\boldmath} %make math in bold text automatically bold + +\usepackage[english=american]{csquotes} + +\usepackage[hidelinks]{hyperref} + +\usepackage[nameinlink]{cleveref} + +\title{\texttt{semtex}: For stripped Seman\!\TeX\ documents (v$0.1\beta$)} +\date{\today} +\author{Sebastian Ørsted (\href{mailto:sorsted@gmail.com}{sorsted@gmail.com})} + +\hypersetup{ + pdfauthor={Sebastian Ørsted}, + pdftitle={semtex: For stripped SemanTeX documents}, + %pdfsubject={}, + %pdfkeywords={}, + %pdfproducer={Latex with hyperref, or other system}, + %pdfcreator={pdflatex, or other tool}, +} + +\usepackage{showexpl} + +\lstset{% + language=[LaTeX]TeX, + basicstyle=\ttfamily\small, + commentstyle=\itshape\ttfamily\small, + alsoletter={\\}, + escapechar=@, + breaklines=true, + breakindent={0pt}, + captionpos=t, + pos=r, + tabsize=2, + %inputencoding=utf8, + explpreset={numbers=none,}, + texcl=false, + wide=false, + width=.45\textwidth, +} + +\newcommand\mylst{\lstinline[mathescape]} + +\def\<#1\>{\textrm{\textlangle\textit{#1}\textrangle}} + +\def\usercommand\<#1\>{\textrm{\textbackslash\textlangle\textit{#1}\textrangle}} + +\def\values\<#1\>{\textrm{\textlangle\textup{#1}\textrangle}} + +\def\num#1{\textsubscript{\textup{#1}}} + +\newcommand\default[1]{\smash{\underline{\smash{#1}}}} + +\newcommand\commandname[1]{\textbackslash\texttt{#1}} + +\let\pack=\texttt + +\newcommand\semantex{Seman\!\TeX\xspace} + +\newcommand\stripsemantex{\texttt{stripsemantex}\xspace} + +\usepackage{hologo} + +% Setting up SemanTeX: + +\usepackage{semtex} + +\makeatother + +\begin{document} + +\maketitle + +\noindent +The package~\pack{semtex} is a small package +that adds a collection of simple macros for parentheses +and bullets. +It exists for one purpose only: +To be loaded by documents which were originally typeset +using the package \semantex, but which have been stripped +of \semantex markup using the package~\pack{stripsemantex}. +Therefore, unless your document is one of those, +simply \textbf{don't use this package}. + + +And even if your document \emph{is} one of those, there is a good chance +you will not have to load it after all. In most cases, you will be able to replace +the macros it provides by macros from other packages. + +\chapter*{Bullet commands} + +The package provides the commands \mylst!\SemantexBullet! and \mylst!\SemantexDoubleBullet!. +These commands print bullets which are smaller (and prettier, in my opinion) +than the standard \lstinline!\bullet! command from~\LaTeX: +\begin{LTXexample} +$ H^{\SemantexBullet} $, +$ H^{\SemantexDoubleBullet} $ +(compare to $H^{\bullet}$) +\end{LTXexample} +You can recreate them yourself as follows, rendering +the package \pack{semtex} unnecessary for this purpose: +\begin{lstlisting} +\newcommand\SemantexBullet{% + \raisebox{-0.25ex}{\scalebox{1.2}{$\cdot$}}% +} +\newcommand\SemantexDoubleBullet{% + \SemantexBullet\SemantexBullet +} +\end{lstlisting} + +\chapter*{Replacements for \texorpdfstring{\textbackslash\texttt{left} and~\textbackslash\texttt{right}}{\left and \right}} + +The package provides the commands \mylst!\SemantexLeft! +and~\mylst!\SemantexRight! +These work just like \lstinline!\left...\right!, but fix some spacing issues +around these: +\begin{LTXexample} +\[ + \SemantexLeft( + \frac{1}{2} + \SemantexRight] +\] +\end{LTXexample} +They are completely equivalent to~\lstinline!\mleft! and~\lstinline!\mright! +from the package~\pack{mleftright}, so it is safe to just load that package +and replace the above commands by \lstinline!\mleft...\mright! instead. +Alternatively, you can recreate them yourself by +\begin{lstlisting} +\newcommand\SemantexLeft{% + \mathopen{}\mathclose\bgroup\left +} + +\newcommand\SemantexRight{% + \aftergroup\egroup\right +} +\end{lstlisting} + +\chapter*{Commands for scaled delimiters} + +First and foremost, the package provides the command +\begin{lstlisting} +\SemantexParentheses{@\values\<normal|auto|*|{\textit{other}}\>@}{@\<left parenthesis\>@}!\\ + {@\<right parenthesis\>@}{@\<content\>@} +\end{lstlisting} +This one writes \<content\> enclosed in the pair of parentheses +and with the size given by the first argument. +Here,~\lstinline!normal! means normal size +parentheses, +and \lstinline!auto! and~\lstinline!*! +mean auto-scaled parentheses using~\lstinline!\SemantexLeft...\SemantexRight!. +If another value is received, that value +is used for the parenthesis size, +so the intended values are~\lstinline!\big!, \lstinline!\Big!, +\lstinline!\bigg!,~\lstinline!\Bigg!: +\begin{LTXexample} +$\SemantexParentheses{normal}{(}{ + )}{\frac{a}{b}}$, +$\SemantexParentheses{auto}{[}{]}{ + \frac{a}{b}}$, +$\SemantexParentheses{\big}{ + \langle}{\rangle}{\frac{a}{b}}$, +$\SemantexParentheses{\Bigg}{\{}{ + \}}{\frac{a}{b}}$, +\end{LTXexample} +The important property of this command +is that inside the~\<content\>, you can access +the delimiter size at any point using +the command~\lstinline!\SemantexDelimiterSize!: +\begin{LTXexample} +$\SemantexParentheses{\Bigg}{\{}{\}}{ + \frac{a}{b} + \SemantexDelimiterSize| + \frac{u}{v} +}$ +\end{LTXexample} + +Secondly, the package provides the command +\begin{lstlisting} +\SemantexNoParentheses{@\<content\>@} +\end{lstlisting} +This command prints the content with no parentheses, but importantly, it also resets +the command \lstinline!\SemantexDelimiterSize! +to~\lstinline!{}!, i.e.~blank. +This makes the following work: +\begin{LTXexample} +$\SemantexParentheses{\Bigg}{\{}{\}}{ + \frac{a}{b} + \SemantexDelimiterSize| + \SemantexNoParentheses{ + a + \SemantexDelimiterSize| + b + } +}$ +\end{LTXexample} + +\end{document}
\ No newline at end of file diff --git a/macros/latex/contrib/subfiles/subfiles.dtx b/macros/latex/contrib/subfiles/subfiles.dtx index 1e81e488db..1a510c59b1 100644 --- a/macros/latex/contrib/subfiles/subfiles.dtx +++ b/macros/latex/contrib/subfiles/subfiles.dtx @@ -23,12 +23,12 @@ % %<*driver> % \fi -\ProvidesFile{subfiles.dtx}[2020/02/14 v1.6 Multi-file projects] +\ProvidesFile{subfiles.dtx}[2020/09/07 v2.0 Multi-file projects] % \iffalse \documentclass{ltxdoc} \GetFileInfo{subfiles.dtx} \title{A Document Class and a Package\\for Handling Multi-File Projects} -\date{2020/02/14 v1.6} +\date{2020/09/07 v2.0} \author{Federico Garcia, Gernot Salzer} \usepackage{hyperref} \begin{document} @@ -38,13 +38,13 @@ %</driver> % \fi % \begin{abstract} -% The |subfiles| package allows authors to split a document into one main file and one and more subsidiary files (subfiles) akin to the |\input| command, with the added benefit of making the subfiles compilable by themselves. +% The |subfiles| package allows authors to split a document into one main file and several subsidiary files (subfiles) akin to the |\input| command, with the added benefit of making the subfiles compilable on their own. % This is achieved by reusing the preamble of the main file also for the subfiles. % \end{abstract} % \tableofcontents % \section{Introduction} % The \LaTeX\ commands |\include| and |\input| allow the user to split the \TeX\ source of a document into several input files. -% This is useful when creating documents with many chapters, but also for handling large tables, figures, and code samples, which require a considerable amount of trial-and-errors. +% This is useful when creating documents with many chapters, but also for handling large tables, figures and code samples, which require a considerable amount of trial-and-errors. % % In this process the rest of the document is of little use, and can even interfere. % For example, error messages may indicate not only the wrong line number, but may point to the wrong file. @@ -63,9 +63,10 @@ % \section{Basic usage} % % \DescribeMacro{subfiles.sty} -% The main file, i.e., the file with the preamble to be shared with the subfiles, has to load the package |subfiles| \emph{at the end of the preamble}: +% The main file, i.e., the file with the preamble to be shared with the subfiles, has to load the package |subfiles|: % \begin{center} % \begin{tabular}{l} +% |\documentclass[...]{...}|\\ % |\usepackage{subfiles}|\\ % |\begin{document}| % \end{tabular} @@ -83,7 +84,7 @@ % which loads the class |subfiles|. % Its only `option', which is actually mandatory, gives the name of the main file. % This name follows \TeX\ conventions: |.tex| is the default extension, the path has to be provided if the main file is in a different directory, and directories in the path have to be separated by |/| (not |\|). -% Thus, we have the following structure: +% Thus, we have the following structure. % \begin{center}\small % \begin{tabular}[t]{l} % \multicolumn{1}{c}{main file} \\ @@ -113,15 +114,117 @@ % \begin{itemize} % \item If \LaTeX\ is run on the subfile, the line |\documentclass[..]{subfiles}| is replaced by the preamble of the main file (including its |\documentclass| command). % The rest of the subfile is processed normally. -% \item If \LaTeX\ is run on the main file, the subfile is loaded like with an |\input| command, except that the three lines |\documentclass[..]{subfiles}|, |\begin{document}|, and |\end{document}| are ignored. +% \item If \LaTeX\ is run on the main file, the subfile is loaded like with an |\input| command, except that the preamble of the subfile up to |\begin{document}| as well as |\end{document}| and the lines following it are ignored. % \end{itemize} % % \section{Advanced usage} % +% \subsection{Including files instead of inputting them} +% +% \DescribeMacro{\subfileinclude} +% In plain \LaTeX, you can use either |\input| or |\include| to load a file. +% In most cases the first is appropriate, but sometimes there are reasons to prefer the latter. +% Internally, the |\subfile| command uses |\input|. +% For those cases where you need |\include|, the package provides the command +% \begin{center} +% |\subfileinclude{|\meta{subfile\_name}|}| +% \end{center} +% +% \subsection{Fixing pathes} +% +% \DescribeMacro{\subfix} +% Whenever an error message of \LaTeX\ or an external program indicates that a file cannot be found, the reason may be that the missing file has to be addressed by varying pathes, depending on which file is typeset. +% In such a case, it may help to apply the command |\subfix| to the file or path names. +% Examples: +% \begin{center} +% \begin{tabular}{ll} +% package & command when used with |subfiles| \\ +% \hline +% |biblatex| & |\addbibresource{\subfix{|\meta{file}|}}| \\ +% |bibunits| & |\putbib[\subfix{|\meta{file1}|},\subfix{|\meta{file2}|},|\dots|]|\\ +% & |\defaultbibliography{\subfix{|\meta{file1}|},|\dots|}| +% \end{tabular} +% \end{center} +% \DescribeMacro{\bibliography} +% \DescribeMacro{\graphicspath} +% Some commands already apply the fix on the fly. +% At the moment these are the standard \LaTeX\ command |\bibliography| and |\graphicspath| from the |graphics|/|graphicx| package. +% +% \subsection{Conditional execution of commands} +% +% \DescribeMacro{\ifSubfilesClassLoaded} +% The command |\ifSubfilesClassLoaded| is useful to execute commands conditionally, depending on whether the main file is typeset or a subfile. +% \begin{center} +% \begin{tabular}{l} +% |\ifSubfilesClassLoaded{% then branch|\\ +% \quad \dots\ commands executed when the subfile is typeset \dots\\ +% |}{% else branch|\\ +% \quad \dots\ commands executed when the main file is typeset \dots\\ +% |}| +% \end{tabular} +% \end{center} +% As an example, this can be used to add the bibliography to the main document or to the subdocument, whichever is typeset: +% \begin{center}\small +% \begin{tabular}[t]{l} +% \multicolumn{1}{c}{main file} \\ +% \hline +% |\documentclass[...]{...}| \\ +% |\usepackage{subfiles}|\\ +% |\bibliographystyle{alpha}|\\ +% |\begin{document}| \\ +% \dots \\ +% |\subfile{|\meta{subfile\_name}|}| \\ +% \dots \\ +% |\bibliography{bibfile}|\\ +% |\end{document}| \\ +% \hline +% \end{tabular} +% \hfill +% \begin{tabular}[t]{l} +% \multicolumn{1}{c}{subfile} \\ +% \hline +% |\documentclass[|\meta{main\_file\_name}|]{subfiles}| \\ +% |\begin{document}| \\ +% \dots \\ +% |\ifSubfilesClassLoaded{%|\\ +% \quad|\bibliography{bibfile}%|\\ +% |}{}|\\ +% |\end{document}| \\ +% \hline +% \end{tabular} +% \end{center} +% +% \subsection{Unusual locations for placing definitions and text} +% +% Starting with version 2.0, the |subfiles| package treats sub-preambles and text after |\end{document}| as one would expect: +% The preamble of subfiles is skipped when loaded with |\subfile|, and everything after |\end{document}| is ignored. +% In most cases this is what you want. +% +% \DescribeMacro{v1} +% For reasons of compatibility, the option |v1| restores the behaviour of older versons: +% \begin{center} +% |\usepackage[v1]{subfiles}| +% \end{center} +% This will have three effects. +% +% \emph{Code after the end of the main document} is added to the preamble of the subfiles, but is ignored when typesetting the main file. +% Here one can add commands that are to be processed as part of the preamble when the subfiles are typeset on their one. +% But this also means that any syntax error after |\end{document}| will ruin the \LaTeX ing of the subfile(s). +% +% \emph{Code in the preamble of a subfile} is processed as part of the text when typesetting the main file, but as part of the preamble when typesetting the subfile. +% This means that with the option |v1|, the preamble of a subfile can only contain stuff that is acceptable for both, the preamble and the text area. +% One should also keep in mind that each subfile is input within a group, so definitions made here may not work outside. +% +% \emph{Code after \texttt{\textbackslash end\{document\}} in a subfile} is treated like the code preceding it when the subfile is loaded from the main file, but is ignored when typesetting the subfile. +% The code after |\end{document}| behaves as if following the |\subfile| command in the main file, except that it is still part of the group enclosing the subfile. +% As a consequence, empty lines at the end of the subfile lead to a new paragraph in the main document, even if the |\subfile| command is immediately followed by text. +% +% \section{Use cases} +% % \subsection{Hierarchy of directories} % -% Sometimes it is desirable to put a subfile together with its images and further files into its own directory. -% The difficulty now is that these additional files have to be addressed by different pathes depending on whether the main files or the subfile is typeset. +% Sometimes it is desirable to put a subfile together with its images and supplementary files into its own directory. +% The difficulty now is that these additional files have to be addressed by different pathes depending on whether the main file or the subfile is typeset. % As of version 1.3, the |subfiles| package handles this problem by using the |import| package. % % As an example, consider the following hierarchy of files: @@ -176,73 +279,12 @@ % \end{center} % Then each of the three files can be typeset individually in its respective directory, where \LaTeX\ is able to locate all included text files and images. % -% \subsection{Including files instead of inputting them} -% -% \DescribeMacro{\subfileinclude} -% In plain \LaTeX, you can use either |\input| or |\include| to load a file. -% In most cases the first is appropriate, but sometimes there are reasons to prefer the latter. -% Internally, the |\subfile| command uses |\input|. -% For those cases where you need |\include|, the package provides the command -% \begin{center} -% |\subfileinclude{|\meta{subfile\_name}|}| -% \end{center} -% -% \subsection{Bibliographies} -% -% Manual bibliographies with the |thebibliography| environment work as usual. -% Problems may arise if external programs like |bibtex| or |biber| are used to generate the bibliography. -% Here are some hints on how to make it work. -% \begin{itemize} -% \item -% \DescribeMacro{\bibliography} -% Make sure the command |\bibliography| is executed after loading the |subfiles| package. -% Put the command between |\usepackage{subfiles}| and |\begin{document}| or somewhere into the text part. -% \item When you use the package |biblatex|, and programs like |biber| complain about not being able to find the bibliography files, use |\bibliography| instead of |\addbibresource| (see above), or the command |\subfix| (see below). -% \item -% \DescribeMacro{\subfix} -% Whenever an external program complains that a file specified in the \LaTeX\ document cannot be found, wrap the command |\subfix| around the filename. -% Here are some examples. -% \begin{center} -% \begin{tabular}{ll} -% package & command when used with |subfiles| \\ -% \hline -% |biblatex| & |\addbibresource{\subfix{|\meta{file}|}}| \\ -% |bibunits| & |\putbib[\subfix{|\meta{file1}|},\subfix{|\meta{file2}|},|\dots|]|\\ -% & |\defaultbibliography{\subfix{|\meta{file1}|},|\dots|}| -% \end{tabular} -% \end{center} -% -% \end{itemize} -% The |subfiles| package has been tested with the packages |biblatex|, |bibunits|, and |chapterbib| as well as with the external programs |bibtex| and |biber|. -% -% \subsection{Unusual locations for placing definitions and text} -% -% Usually all definitions and packages required by the subfiles should go into the preamble of the main file. -% There are some further locations, though, where one might consider adding definitions and text. -% Put negatively, apparently irrelevant stuff in these locations may become unexpectedly visible in the document or cause errors. -% -% \paragraph{Code after the end of the main document} is added to the preamble of the subfiles, but is ignored when typesetting the main file. -% This happens because a subfile typeset by itself does not really take the preamble of the main file, but \emph{everything outside} of |\begin{document}| and |\end{document}|. -% This has two consequences: \emph{a)}~the user can add some commands that are to be processed as part of the preamble only when the subfiles are typeset by themselves; but also \emph{b)}~the user has to be careful even \emph{after} |\end{document}| in the main file, for any syntax error there will ruin the \LaTeX ing of the subfile(s). -% \bigskip -% -% Similarly, when typesetting the main document, the |\subfile| command does not really load the stuff within the |document| environment, but \emph{everything except} the three commands |\documentclass[...]{...}|, |\begin{document}|, and |\end{document}|. -% This has the following consequences. -% -% \paragraph{Code in the preamble of a subfile} is processed as part of the text when typesetting the main file, but as part of the preamble when typesetting the subfile. -% This means that the preamble of a subfile can only contain stuff that is acceptable for both, the preamble and the text area. -% One should also keep in mind that each subfile is input within a group, so definitions made within may not work outside. -% -% \paragraph{Code after \texttt{\textbackslash end\{document\}} in a subfile} is treated like the code preceding it when the subfile is loaded from the main file, but is ignored when typesetting the subfile. -% The code after |\end{document}| behaves as if following the |\subfile| command in the main file, except that it is still part of the group enclosing the subfile. -% As a consequence, empty lines at the end of the subfile lead to a new paragraph in the main document, even if the |\subfile| command is immediately followed by text. % % \subsection{Avoiding extra spaces} % % Sometimes you may want to load the contents of a subfile without white space separating it from the contents of the main file. -% In this respect |\subfile| behaves similar to |\input|. +% In this respect, |\subfile| behaves similar to |\input|. % Any space or newline before and after the |\subfile| command will appear in the typeset document, as will any white space between the last character of the subfile and |\end{document}|. -% Moreover, any stuff after |\end{document}| will end up in the main document, including spurious empty lines, which may lead to a new paragraph. % Therefore, to load the contents of a subfile without intervening spaces, you have either to add comment signs: % \begin{center} % \begin{tabular}[t]{l} @@ -262,7 +304,6 @@ % |\begin{document}|\\ % |contents of subfile%|\\ % |\end{document}|\\ -% |% No empty lines after \end{document}!|\\ % \hline % \end{tabular} % \end{center} @@ -280,29 +321,25 @@ % \item % Make sure to use the most recent version of the |subfiles| package, available from CTAN\footnote{\url{https://ctan.org/pkg/subfiles}} and Github\footnote{\url{https://github.com/gsalzer/subfiles}}. % \item -% Make sure that |\usepackage{subfiles}| comes last in the preamble -% of the main document. -% \item -% If some external program that cooperates with \TeX, like |bibtex| or |biber|, complains about not being able to find a file, locate the name of the file in the \LaTeX\ source and replace \meta{filename} by |\subfix{|\meta{filename}|}|. +% Make sure that |\usepackage{subfiles}| appears near the end of the main preamble. % \item -% Make sure that there is no stuff after |\end{document}|, neither in the main file nor in the subfiles. +% Make sure that the strings |\begin{document}| and |\end{document}| appear on lines of their own and that there are no additional characters preceding or trailing them. % \item -% If there is anything in the preambles of the subfiles, make sure that it is admissible for both, the preamble and the document area. +% If some external program that cooperates with \TeX, like |bibtex| or |biber|, complains about not being able to find a file, locate the name of the file in the \LaTeX\ source and replace \meta{filename} by |\subfix{|\meta{filename}|}|. % \item -% If nothing of the above helps and you are stuck, ask the people on tex.stackexchange\footnote{\url{https://tex.stackexchange.com/}}. +% If nothing of the above helps, ask the nice people on tex.stackexchange\footnote{\url{https://tex.stackexchange.com/}}. % \end{enumerate} % % \section{Dependencies} % -% The |subfiles| package requires the |verbatim| package, whose |comment| environment is used to ignore the text area of the main file when typesetting subfiles separately. -% Moreover, the |import| package is needed to load subfiles and their auxiliary files from different directories. -% Both packages are part of the standard \TeX\ distributions. +% The |subfiles| package uses the |import| package by Donald Arsenau to load subfiles from different directories. +% |import.sty| is part of the standard \TeX\ distribution. % % \section{Version history} % % \begin{description} % \item[v1.1:] -% Initial version by Federico Garcia. Further versions by Gernot Salzer. +% Initial version by Federico Garcia. Subsequent versions by Gernot Salzer. % \item[v1.2:] \mbox{} % \begin{itemize} % \item Incompatibility with classes and packages removed that modify the |\document| command, like the class |revtex4|. @@ -332,6 +369,19 @@ % \item Incompatibility with |standalone| class removed. % \item The options of the main class are now also processed when typesetting a subfile; before they were ignored. Thanks to J\'an Kl'uka for analysing the problem. % \end{itemize} +% \item[v2.0:] \mbox{} +% \begin{itemize} +% \item Incompatibility with \LaTeX\ Oct.~2020 removed. +% Thanks to Ulrike \mbox{Fischer} from the \LaTeX~3 team for the warning in time. +% \item By default, text after |\end{document}| as well as the preamble of subfiles, when loaded with |\subfile|, are ignored now. +% The old behaviour is available via the new package option |v1|. +% \item Command |\ifSubfilesClassLoaded| added and documentation regarding the use of the |\bibliography| command corrected. +% Thanks to Github user |alan-isaac| for reporting the issue. +% \item Subfiles now can have the same name as the main file. +% Thanks to Github user |June-6th| for reporting the issue. +% \item Problem with the search path for images resolved. +% Thanks to Github user |maxnick| for reporting the issue. +% \end{itemize} % \end{description} % %\section{The Implementation} @@ -339,148 +389,179 @@ % \begin{macrocode} %<*class> \NeedsTeXFormat{LaTeX2e} -\ProvidesClass{subfiles}[2020/02/14 v1.6 Multi-file projects (class)] -\DeclareOption*{\typeout{Preamble taken from file `\CurrentOption'}% - \let\preamble@file\CurrentOption} +\ProvidesClass{subfiles}[2020/09/07 v2.0 Multi-file projects (class)] +\DeclareOption*{% + \typeout{Preamble taken from file `\CurrentOption'}% + \let\preamble@file\CurrentOption +} \ProcessOptions % \end{macrocode} +% % After processing the option of the |subfiles| class, we reset |\@classoptionslist| such that the options in the main file will be processed. % % \begin{macrocode} \let\@classoptionslist\relax % \end{macrocode} -% Then we save the original definition of |\documentclass| to be able to reset it later to this definition: +% +% To handle subfiles in separate directories, we use the |import| package. +% We load it now, since it resets the macro |\import@path|. +% \begin{macrocode} +\RequirePackage{import} +% \end{macrocode} +% +% We redefine |\documentclass| to load the class of the main document. % % \begin{macrocode} \let\subfiles@documentclass\documentclass +\def\documentclass{% + \let\documentclass\subfiles@documentclass + \LoadClass +} % \end{macrocode} % -% Now |\documentclass| is set equal to |\LoadClass| such that the class and the options of the main file will be loaded as usual. -% +% In earlier versions, we used |\subimport| to load the preamble of the main file, which has the unwanted effect of undoing changes to the graphics path. +% Therefore we use |\input| and initialize |\import@path| and |\input@path| to the path of the main file. +% We use the internal \LaTeX\ macro |\filename@parse| to obtain this path. % \begin{macrocode} -\let\documentclass\LoadClass\relax +\filename@parse{\preamble@file} +\edef\import@path{\filename@area} +\edef\input@path{{\filename@area}} +\input{\preamble@file} % \end{macrocode} % -% When typesetting a subfile, we have to skip the |document| environment of the main file. -% This is done with the commands |\comment| and |\endcomment| from the |verbatim| package. -% Now there is a problem: -% If we load |verbatim| here, the definition of the commands may be overwritten if the user loads e.g.\ the |comment| package. -% Loading |verbatim| in |subfiles.sty| at the latest possible moment is not reliable, either. -% On the one hand we may overwrite macros required later by the user, on the other hand the |memoir| class contains a copy of |verbatim|, so a later |\RequirePackage| refuses to reload the package. -% Thus, in the case of a document loading the |memoir| class and the |comment| package, we end up with the wrong definition of |\comment| in any case. +% After loading the preamble of the main file, we reset |\import@path{}|. +% Since the preamble may have changed the catcode of the |@| sign, we make it (again) a letter. Better safe than sorry. % -% Therefore we load the |verbatim| package here and save the contents of the crucial commands |\comment| and |\endcomment| under a different name. % \begin{macrocode} -\RequirePackage{verbatim} -\let\subfiles@comment\comment -\let\subfiles@endcomment\endcomment +{\makeatletter + \gdef\import@path{} +} +%</class> % \end{macrocode} -% -% To handle subfiles in separate directories, we load the |import| package. -% +% +% +% \subsection{The package} % \begin{macrocode} -\RequirePackage{import} +%<*package> +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{subfiles}[2020/09/07 v2.0 Multi-file projects (package)] % \end{macrocode} % -% The |\subimport| command requires path and filename as separate arguments, so we have to split file locations into these two components. -% The internal \LaTeX\ command |\filename@parse| almost fits the bill, except that it additionally splits the filename into basename and extension. -% Unfortunately, concatenating basename and extension to recover the filename is not clean: -% Under Unix/Linux, the filenames |base| and |base.| denote different entities, but after |\filename@parse| both have the same basename and an empty extension. -% Therefore we redefine the command |\filename@simple| temporarily; it is responsible for this unwanted split. -% +% The package has one option, |v1|, which affects the way how the text after |\end{document}| and in the preamble of subfiles is handled. +% With this option, |subfiles| behaves like in version 1.x. +% To implement the retro behaviour, we need a few definitions. +% +% First, we define three macros containing the strings |\begin{document}|, |\end{document}| and |document|. +% We need them later to detect these strings in the input. % \begin{macrocode} -\def\subfiles@split#1{% - \let\subfiles@filename@simple\filename@simple - \def\filename@simple##1.\\{\edef\filename@base{##1}}% - \filename@parse{#1}% - \let\filename@simple\subfiles@filename@simple +\def\subfiles@DOCUMENT{document} +{\escapechar=-1\relax + \xdef\subfiles@BEGINDOCUMENT{\string\\begin\string\{document\string\}}% + \xdef\subfiles@ENDDOCUMENT{\string\\end\string\{document\string\}}% } % \end{macrocode} % -% E.g., after executing |\subfiles@split{../dir1/dir2/file.tex}| the macros |\filename@area| and |\filename@base| expand to |../dir1/dir2/| and |file.tex|, respectively. -% -% Now we split the name of the main file that has been provided as optional argument of the document class, and |\subimport| the main file. +% The macro |\subfiles@skipDocument| skips everything until it encounters the string |\end{document}|. +% In earlier versions of the package, this was accomplished by redefining the |document| environment to the |comment| environment of the |verbatim| package. +% This clashes with the \LaTeX\ format published in October 2020, so we copy and adapt the code from the |verbatim| package (see the definition of |\subfiles@skiplines| below). % % \begin{macrocode} -\subfiles@split{\preamble@file} -\subimport{\filename@area}{\filename@base} +\def\subfiles@skipDocument{% + \let\subfiles@skiplinescont\ignorespaces + \let\subfiles@skiplinesend\subfiles@ENDDOCUMENT + \subfiles@skiplines +} % \end{macrocode} % -% The main file loads the package |subfiles| as part of the preamble, which saves the contents of |\document| and |\enddocument| as |\subfiles@document| and |\subfiles@enddocument|, respectively. -% We use these macors now to restore the original values of |\document|, |\enddocument|, and |\documentclass|. -% The backup commands are |\undefined| to save memory. -% That's it. +% To skip |\documentclass| the old way, we redefine it to do nothing except restoring its original definition. % % \begin{macrocode} -{\catcode`\@=11 -\global\let\document\subfiles@document -\global\let\enddocument\subfiles@enddocument -\global\let\documentclass\subfiles@documentclass -\global\let\subfiles@document\undefined -\global\let\subfiles@enddocument\undefined -\global\let\subfiles@documentclass\undefined +\def\subfiles@skipDocumentclass{% + \renewcommand\documentclass[2][]{% + \let\documentclass\subfiles@documentclass + \ignorespaces + }% } -%</class> % \end{macrocode} % -% It may not be obvious why |@| has to be catcoded to a letter, since we are in a style file anyway. -% However, the |\preamble@file| occasionally contains |\usepackage| commands that make |@| a non-letter. -% This is why the part after loading the main preamble needs a |\catcode| command, grouping, and |\global|'s. -% -% -% \subsection{The package} -% -% Any option will be ignored. -% +% To ignore the preamble of a subfile, we redefine |\documentclass| to skip everything until the string |\begin{document}| is encountered. % \begin{macrocode} -%<*package> -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{subfiles}[2020/02/14 v1.6 Multi-file projects (package)] -\DeclareOption*{\PackageWarning{\CurrentOption ignored}} -\ProcessOptions +\def\subfiles@skipPreamble{% + \def\documentclass{% + \let\documentclass\subfiles@documentclass + \def\subfiles@skiplinescont{\begin{document}}% + \let\subfiles@skiplinesend\subfiles@BEGINDOCUMENT + \subfiles@skiplines + }% +} % \end{macrocode} % -% If the initial document class was |subfiles|, then the main file is loaded as part of a subfile. -% In this case anything between |\begin{document}| and |\end{document}| has to be skipped, while the contents of the commands |\document| and |\enddocument| has to be retained for later use in the subfile. -% Therefore we save the contents of the two commands as |\subfiles@document| and |\subfiles@enddocument|, respectively. -% Now the |document| environment is redefined to become the saved |comment| environment from the |verbatim| package. -% Consequently, the body of the main file is ignored by \LaTeX, and only the preamble is read (as well as anything that comes after |\end{document}|!). -% +% Now we set the default behaviour of the subfiles package: +% When loading the main preamble in a subfile, everything after the preamble is ignored. +% Moreover, when reading a subfile, its preamble as well as everything after |\end{document}| is ignored. % \begin{macrocode} -\@ifclassloaded{subfiles}{% - \let\subfiles@document\document - \let\subfiles@enddocument\enddocument - \let\document\subfiles@comment - \let\enddocument\subfiles@endcomment +\let\subfiles@handleMain\endinput +\let\subfiles@handleSubpreamble\subfiles@skipPreamble +\let\subfiles@handleTextAfterSubdocument\endinput % \end{macrocode} % -% By loading the |subfiles| package immediately before |\begin{document}| we ensure that |\subfiles@document| and |\subfiles@enddocument| contain all modifications that the class and the preamble of the main file may have applied to the |document| environment. -% This happens e.g.\ with the class |revtex4| and the package |pythontex|. +% The option |v1| restores the behaviour of the old |subfiles| package: When loading the main preamble in a subfile, only the contents of the |document| environent is ignored, but not the stuff following it. Moreover, when reading a subfile, only the |\documentclass| command and the lines |\begin{document}| and |\end{document}| are ignored, but the subfile preamble as well as everything after |\end{document}| is retained. +% \begin{macrocode} +\DeclareOption{v1}{% + \let\subfiles@handleMain\subfiles@skipDocument + \let\subfiles@handleSubpreamble\subfiles@skipDocumentclass + \let\subfiles@handleTextAfterSubdocument\relax +} +\DeclareOption*{\PackageWarning{subfiles}{Option '\CurrentOption' ignored}} +\ProcessOptions\relax +% \end{macrocode} +% +% To skip everything until a specific string is read, we adapt code from the |verbatim| package. +% The skipping of lines is controlled by two macros that have to be set before calling |\subfiles@skiplines|. +% |\subfiles@skiplinesend| is the string that marks the end of the skipped area; it has to appear on a line of its own, as the only content of this line. +% |\subfiles@skiplinescont| contains the code to be executed after skipping has ended. +% +% \begin{macrocode} +\def\subfiles@skiplines{% + \begingroup + \let\do\@makeother\dospecials + \@makeother\^^L% + \endlinechar`\^^M\relax \catcode`\^^M=12\relax \subfiles@skipline} +{\catcode`\^^M=12 \endlinechar=-1 % + \gdef\subfiles@skipline#1^^M{\def\subfiles@tmp{#1}% + \ifx\subfiles@tmp\subfiles@skiplinesend + \def\subfiles@tmp{\endgroup\subfiles@skiplinescont}% + \else\let\subfiles@tmp\subfiles@skipline + \fi \subfiles@tmp} +} +% \end{macrocode} % -% We use the |import| package to handle subfiles in separate directories. +% To handle subfiles in separate directories, we use the |import| package. +% If it has already been loaded, e.g.\ by the |subfiles| class, this line does nothing. +% \begin{macrocode} +\RequirePackage{import} +% \end{macrocode} +% % The |\subimport| command requires path and filename as separate arguments, so we have to split file locations into these two components. % The internal \LaTeX\ command |\filename@parse| almost fits the bill, except that it additionally splits the filename into basename and extension. % Unfortunately, concatenating basename and extension to recover the filename is not clean: % Under Unix/Linux, the filenames |base| and |base.| denote different entities, but after |\filename@parse| both have the same basename and an empty extension. % Therefore we redefine the command |\filename@simple| temporarily; it is responsible for this unwanted split. -% Both things, loading the package and defining the command, are also done in |subfiles.cls|, so we have to execute this code only if we are typesetting the main file. -% +% % \begin{macrocode} -}{% subfiles class not loaded, we typeset the main document - \RequirePackage{import} - \def\subfiles@split#1{% - \let\subfiles@filename@simple\filename@simple - \def\filename@simple##1.\\{\edef\filename@base{##1}}% - \filename@parse{#1}% - \let\filename@simple\subfiles@filename@simple - } -} +\def\subfiles@split#1{% + \let\subfiles@filename@simple\filename@simple + \def\filename@simple##1.\\{\edef\filename@base{##1}}% + \filename@parse{#1}% + \let\filename@simple\subfiles@filename@simple +}% % \end{macrocode} % % E.g., after executing |\subfiles@split{../dir1/dir2/file.tex}| the macros |\filename@area| and |\filename@base| expand to |../dir1/dir2/| and |file.tex|, respectively. % % \DescribeMacro{\subfile} % The command |\subfile| specifies the command |\subimport| for |\input|ing the subfile, and then calls |\subfiles@subfile|. +% % \begin{macrocode} \newcommand\subfile{% \let\subfiles@loadfile\subimport @@ -490,6 +571,7 @@ % % \DescribeMacro{\subfileinclude} % The command |\subfileinclude| specifies the command |\subincludefrom| for |\include|ing the subfile, and then calls |\subfiles@subfile|. +% % \begin{macrocode} \newcommand\subfileinclude{% \let\subfiles@loadfile\subincludefrom @@ -497,7 +579,7 @@ } % \end{macrocode} % -% The main functionality of the two |\subfile| commands is implemented in |\subfiles@subfile|. +% The main functionality of the two commands is implemented in |\subfiles@subfile|. % It redefines |\documentclass| and the |document| environment to do nothing but reverting these command to their original meaning and avoiding spurious spaces. % Reverting |\documentclass| and |\document| to their original definition is important for being compatible with classes like |standalone| or packages like |bibentry|, which rely on this definition. % @@ -507,18 +589,17 @@ \let\subfiles@documentclass\documentclass \let\subfiles@document\document \let\subfiles@enddocument\enddocument - \renewcommand\documentclass[2][subfiles]{% - \let\documentclass\subfiles@documentclass - \ignorespaces - }% + \subfiles@handleSubpreamble \renewenvironment{document}{% \let\document\subfiles@document \ignorespaces }{% \let\enddocument\subfiles@enddocument \@ignoretrue + \subfiles@handleTextAfterSubdocument }% % \end{macrocode} +% % Now we split the file name into path and base name and load the file. % % \begin{macrocode} @@ -528,36 +609,87 @@ } % \end{macrocode} % -% To let external programs find files, we have to add the |\import@path| to file names. -% This is accomplished with the command |\subfiles@addimportpath|. +% \DescribeMacro{\subfix} +% If some package provides a command that takes a filename as argument, then it has to be prefixed with the current |\import@path|. +% This is what the |\subfix| command tries to do. +% In order to succeed, the filename has to be expanded immediately, such that the current value of |\import@path| is used. +% +% \begin{macrocode} +\def\subfix#1{\import@path#1} +% \end{macrocode} +% +% For patching a list of file or path names, we define two auxiliary macros, one iterating over a comma-separated list of names and one processing a sequence of names enclosed in braces. +% % \begin{macrocode} -\def\subfiles@addimportpath#1{% - \def\subfiles@filelist{}% +\def\subfiles@fixfilelist#1{% + \def\subfiles@list{}% \def\subfiles@sep{}% - \@for\subfiles@filename:=#1\do{% - \edef\subfiles@filelist{% - \subfiles@filelist - \subfiles@sep - \import@path - \subfiles@filename - }% + \@for\subfiles@tmp:=#1\do{% + \edef\subfiles@list{\subfiles@list\subfiles@sep\subfix{\subfiles@tmp}}% \def\subfiles@sep{,}% - } + }% +} +\def\subfiles@fixpathlist#1{% + \def\subfiles@list{}% + \@tfor\subfiles@tmp:=#1\do{% + \edef\subfiles@list{\subfiles@list{\subfix\subfiles@tmp}}% + }% } % \end{macrocode} % % \DescribeMacro{\bibliography} -% We redefine the |\bibliography| command such that the import path is added to the file names before the original command is called. +% \DescribeMacro{\graphicspath} +% We patch |\bibliography| and |\graphicspath| (from the |graphics|/|graphicx| package) such that users don't have to worry about adding |\subfix|. +% % \begin{macrocode} \let\subfiles@bibliography\bibliography \renewcommand\bibliography[1]{% - \subfiles@addimportpath{#1}% - \expandafter\subfiles@bibliography\expandafter{\subfiles@filelist}% + \subfiles@fixfilelist{#1}% + \expandafter\subfiles@bibliography\expandafter{\subfiles@list}% } +\@ifpackageloaded{graphics}{% + \let\subfiles@graphicspath\graphicspath + \renewcommand\graphicspath[1]{% + \subfiles@fixpathlist{#1}% + \edef\subfiles@list{{\subfix{}}\subfiles@list}% + \expandafter\subfiles@graphicspath\expandafter{\subfiles@list}% + }% +}{} % \end{macrocode} % -% \DescribeMacro{\subfix} -% Instead of adding further fixes for other packages that write filenames to external files (like |bibunits|), we provide a command for adding the |\import@path| to a filename. +% \DescribeMacro{\ifSubfilesClassLoaded} +% To add code or text conditionally, depending on whether the main document or a subfile is typeset, we provide the command |\ifSubfilesClassLoaded|. +% % \begin{macrocode} -\def\subfix#1{\import@path#1} +\newcommand\ifSubfilesClassLoaded{% + \expandafter\ifx\csname ver@subfiles.cls\endcsname\relax + \expandafter\@secondoftwo + \else + \expandafter\@firstoftwo + \fi +} +% \end{macrocode} +% +% The |subfiles| package is loaded near the end of the main preamble. +% If it is loaded from a subfile, i.e., if |subfiles.cls| has been loaded, then we have to prepare for skipping the main document. +% We do this be redefining the |\begin| command. +% Normally, the first |\begin| after the |subfiles| package starts the main document. +% To allow for the case that some other environment occurs before (does it really happen?) we test whether we are dealing with |\begin{document}|. +% If not, we execute the original definition of |\begin|; otherwise we skip the main document as specified by |\subfiles@handleMain|. +% +% \begin{macrocode} +\ifSubfilesClassLoaded{% + \let\subfiles@begin\begin + \def\begin#1{% + \def\subfiles@tmp{#1}% + \ifx\subfiles@tmp\subfiles@DOCUMENT + \let\begin\subfiles@begin + \let\subfiles@tmp\subfiles@handleMain + \else + \def\subfiles@tmp{\subfiles@begin{#1}}% + \fi + \subfiles@tmp + }% +}{} +%</package> % \end{macrocode} diff --git a/macros/latex/contrib/subfiles/subfiles.ins b/macros/latex/contrib/subfiles/subfiles.ins index 95380c1670..6e4a5ed00b 100644 --- a/macros/latex/contrib/subfiles/subfiles.ins +++ b/macros/latex/contrib/subfiles/subfiles.ins @@ -1,6 +1,6 @@ % subfiles - class and package for multi-file projects in LaTeX % Copyright 2002, 2012 Federico Garcia (feg8@pitt.edu, fedegarcia@hotmail.com) -% Copyright 2018, 2019 Gernot Salzer (salzer@logic.at) +% Copyright 2018-2020 Gernot Salzer (salzer@logic.at) % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -23,7 +23,7 @@ This is a generated file. -Copyright 2002, 2012 Federico Garcia; 2018, 2019 Gernot Salzer +Copyright 2002, 2012 Federico Garcia; 2018-2020 Gernot Salzer This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 diff --git a/macros/latex/contrib/subfiles/subfiles.pdf b/macros/latex/contrib/subfiles/subfiles.pdf Binary files differindex 0925cb83b9..ae8b02f6af 100644 --- a/macros/latex/contrib/subfiles/subfiles.pdf +++ b/macros/latex/contrib/subfiles/subfiles.pdf |