diff options
author | Karl Berry <karl@freefriends.org> | 2020-07-06 21:01:04 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-07-06 21:01:04 +0000 |
commit | 4276266e93418f66445b562181f1cef714668101 (patch) | |
tree | 555c5ed71124f8ce62ab47f933faafbb61a42894 | |
parent | a70ec2d590f8207103990ea059fecf8fa145b441 (diff) |
semantex (6jul20)
git-svn-id: svn://tug.org/texlive/trunk@55765 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/semantex/README.md | 5 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/semantex/semantex.pdf | bin | 221498 -> 234442 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/semantex/semantex.tex | 1800 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/semantex/semantex.sty | 5107 |
4 files changed, 4672 insertions, 2240 deletions
diff --git a/Master/texmf-dist/doc/latex/semantex/README.md b/Master/texmf-dist/doc/latex/semantex/README.md index 31c5e7f5633..9b7c6e4617f 100644 --- a/Master/texmf-dist/doc/latex/semantex/README.md +++ b/Master/texmf-dist/doc/latex/semantex/README.md @@ -3,9 +3,8 @@ SemanTeX - object-oriented mathematics The SemanTeX package for LaTeX delivers a more semantic, systematized way of writing mathematics compared to the ordinary math syntax. The system is object-oriented and uses keyval syntax, and everything is highly -customizable. At the same time, care has been taken to make it -intuitive, natural, practical, and with an easy-to-use and lightweight -syntax. +customizable. At the same time, care has been taken to make it the syntax as +intuitive, natural, practical, and lightweight as possible. ---------------------------------------------------------------- SemanTeX --- object-oriented mathematics diff --git a/Master/texmf-dist/doc/latex/semantex/semantex.pdf b/Master/texmf-dist/doc/latex/semantex/semantex.pdf Binary files differindex e8a02eae884..4f4e3b00c91 100644 --- a/Master/texmf-dist/doc/latex/semantex/semantex.pdf +++ b/Master/texmf-dist/doc/latex/semantex/semantex.pdf diff --git a/Master/texmf-dist/doc/latex/semantex/semantex.tex b/Master/texmf-dist/doc/latex/semantex/semantex.tex index da8cfd390b0..c273d1dcecf 100644 --- a/Master/texmf-dist/doc/latex/semantex/semantex.tex +++ b/Master/texmf-dist/doc/latex/semantex/semantex.tex @@ -9,9 +9,7 @@ \frenchspacing -\usepackage{mathtools,etoolbox, microtype,xspace} - - +\usepackage{mathtools,etoolbox, microtype,xspace,color} \usepackage[shortlabels]{enumitem}%control lists @@ -36,7 +34,7 @@ \usepackage[nameinlink]{cleveref} -\title{Seman\!\TeX: Object-oriented mathematics (v$0.1\alpha$)} +\title{Seman\!\TeX: Semantic mathematics (v$0.2\alpha$)} \date{\today} \author{Sebastian Ørsted (\href{mailto:sorsted@gmail.com}{sorsted@gmail.com})} @@ -56,139 +54,129 @@ \usepackage{semantex} -\newvariableclass{var}[ - output=var, +\NewVariableClass\MyVar[ + output=\MyVar, ] -\newvar\va{a} -\newvar\vb{b} -\newvar\vc{c} -\newvar\vd{d} -\newvar\ve{e} -\newvar\vf{f} -\newvar\vg{g} -\newvar\vh{h} -\newvar\vi{i} -\newvar\vj{j} -\newvar\vk{k} -\newvar\vl{l} -\newvar\vm{m} -\newvar\vn{n} -\newvar\vo{o} -\newvar\vp{p} -\newvar\vq{q} -\newvar\vr{r} -\newvar\vs{s} -\newvar\vt{t} -\newvar\vu{u} -\newvar\vv{v} -\newvar\vw{w} -\newvar\vx{x} -\newvar\vy{y} -\newvar\vz{z} - -\newvar\vA{A} -\newvar\vB{B} -\newvar\vC{C} -\newvar\vD{D} -\newvar\vE{E} -\newvar\vF{F} -\newvar\vG{G} -\newvar\vH{H} -\newvar\vI{I} -\newvar\vJ{J} -\newvar\vK{K} -\newvar\vL{L} -\newvar\vM{M} -\newvar\vN{N} -\newvar\vO{O} -\newvar\vP{P} -\newvar\vQ{Q} -\newvar\vR{R} -\newvar\vS{S} -\newvar\vT{T} -\newvar\vU{U} -\newvar\vV{V} -\newvar\vW{W} -\newvar\vX{X} -\newvar\vY{Y} -\newvar\vZ{Z} - -\newvar\valpha{\alpha} -\newvar\vvaralpha{\varalpha} -\newvar\vbeta{\beta} -\newvar\vgamma{\gamma} -\newvar\vdelta{\delta} -\newvar\vepsilon{\epsilon} -\newvar\vvarepsilon{\varepsilon} -\newvar\vzeta{\zeta} -\newvar\veta{\eta} -\newvar\vtheta{\theta} -\newvar\viota{\iota} -\newvar\vkappa{\kappa} -\newvar\vlambda{\lambda} -\newvar\vmu{\mu} -\newvar\vnu{\nu} -\newvar\vxi{\xi} -\newvar\vpi{\pi} -\newvar\vvarpi{\varpi} -\newvar\vrho{\rho} -\newvar\vsigma{\sigma} -\newvar\vtau{\tau} -\newvar\vupsilon{\upsilon} -\newvar\vphi{\phi} -\newvar\vvarphi{\varphi} -\newvar\vchi{\chi} -\newvar\vpsi{\psi} -\newvar\vomega{\omega} - -\newvar\vGamma{\Gamma} -\newvar\vDelta{\Delta} -\newvar\vTheta{\Theta} -\newvar\vLambda{\Lambda} -\newvar\vXi{\Xi} -\newvar\vPi{\Pi} -\newvar\vSigma{\Sigma} -\newvar\vUpsilon{\Upsilon} -\newvar\vPhi{\Phi} -\newvar\vPsi{\Psi} -\newvar\vOmega{\Omega} - -\newvar\sheafF{\mathcal{F}} -\newvar\sheafG{\mathcal{G}} -\newvar\sheafO{\mathcal{O}} -\newvar\sheafHom{\mathcal{H}\!\!om} - -\newvar\Hom{\operatorname{Hom}} - -\usepackage{showexpl,newunicodechar} - -\newunicodechar{⟨}{\textlangle} -\newunicodechar{⟩}{\textrangle} - - -\setupclass{var}{ - novaluekeys={ - {inverseimage}{upper={-1},nopar}, - }, -} - -\newcohomologyclass{cohomology}[ - parent=var, - valuekeys={ - {arg}{argwithkeyval={#1}}, - }, - gradingpos=upper, +\NewObject\MyVar\va{a} +\NewObject\MyVar\vb{b} +\NewObject\MyVar\vc{c} +\NewObject\MyVar\vd{d} +\NewObject\MyVar\ve{e} +\NewObject\MyVar\vf{f} +\NewObject\MyVar\vg{g} +\NewObject\MyVar\vh{h} +\NewObject\MyVar\vi{i} +\NewObject\MyVar\vj{j} +\NewObject\MyVar\vk{k} +\NewObject\MyVar\vl{l} +\NewObject\MyVar\vm{m} +\NewObject\MyVar\vn{n} +\NewObject\MyVar\vo{o} +\NewObject\MyVar\vp{p} +\NewObject\MyVar\vq{q} +\NewObject\MyVar\vr{r} +\NewObject\MyVar\vs{s} +\NewObject\MyVar\vt{t} +\NewObject\MyVar\vu{u} +\NewObject\MyVar\vv{v} +\NewObject\MyVar\vw{w} +\NewObject\MyVar\vx{x} +\NewObject\MyVar\vy{y} +\NewObject\MyVar\vz{z} + +\NewObject\MyVar\vA{A} +\NewObject\MyVar\vB{B} +\NewObject\MyVar\vC{C} +\NewObject\MyVar\vD{D} +\NewObject\MyVar\vE{E} +\NewObject\MyVar\vF{F} +\NewObject\MyVar\vG{G} +\NewObject\MyVar\vH{H} +\NewObject\MyVar\vI{I} +\NewObject\MyVar\vJ{J} +\NewObject\MyVar\vK{K} +\NewObject\MyVar\vL{L} +\NewObject\MyVar\vM{M} +\NewObject\MyVar\vN{N} +\NewObject\MyVar\vO{O} +\NewObject\MyVar\vP{P} +\NewObject\MyVar\vQ{Q} +\NewObject\MyVar\vR{R} +\NewObject\MyVar\vS{S} +\NewObject\MyVar\vT{T} +\NewObject\MyVar\vU{U} +\NewObject\MyVar\vV{V} +\NewObject\MyVar\vW{W} +\NewObject\MyVar\vX{X} +\NewObject\MyVar\vY{Y} +\NewObject\MyVar\vZ{Z} + +\NewObject\MyVar\valpha{\alpha} +\NewObject\MyVar\vvaralpha{\varalpha} +\NewObject\MyVar\vbeta{\beta} +\NewObject\MyVar\vgamma{\gamma} +\NewObject\MyVar\vdelta{\delta} +\NewObject\MyVar\vepsilon{\epsilon} +\NewObject\MyVar\vvarepsilon{\varepsilon} +\NewObject\MyVar\vzeta{\zeta} +\NewObject\MyVar\veta{\eta} +\NewObject\MyVar\vtheta{\theta} +\NewObject\MyVar\viota{\iota} +\NewObject\MyVar\vkappa{\kappa} +\NewObject\MyVar\vlambda{\lambda} +\NewObject\MyVar\vmu{\mu} +\NewObject\MyVar\vnu{\nu} +\NewObject\MyVar\vxi{\xi} +\NewObject\MyVar\vpi{\pi} +\NewObject\MyVar\vvarpi{\varpi} +\NewObject\MyVar\vrho{\rho} +\NewObject\MyVar\vsigma{\sigma} +\NewObject\MyVar\vtau{\tau} +\NewObject\MyVar\vupsilon{\upsilon} +\NewObject\MyVar\vphi{\phi} +\NewObject\MyVar\vvarphi{\varphi} +\NewObject\MyVar\vchi{\chi} +\NewObject\MyVar\vpsi{\psi} +\NewObject\MyVar\vomega{\omega} + +\NewObject\MyVar\vGamma{\Gamma} +\NewObject\MyVar\vDelta{\Delta} +\NewObject\MyVar\vTheta{\Theta} +\NewObject\MyVar\vLambda{\Lambda} +\NewObject\MyVar\vXi{\Xi} +\NewObject\MyVar\vPi{\Pi} +\NewObject\MyVar\vSigma{\Sigma} +\NewObject\MyVar\vUpsilon{\Upsilon} +\NewObject\MyVar\vPhi{\Phi} +\NewObject\MyVar\vPsi{\Psi} +\NewObject\MyVar\vOmega{\Omega} + +\NewObject\MyVar\sheafF{\mathcal{F}} +\NewObject\MyVar\sheafG{\mathcal{G}} +\NewObject\MyVar\sheafreg{\mathcal{O}} +\NewObject\MyVar\sheafHom{\mathop{\mathcal{H}om}} + +\NewObject\MyVar\Hom{\operatorname{Hom}} + +\NewCohomologyClass\MyCohomology[ + parent=\MyVar, + gradingposition=upper, ] -\newcohomologyclass{homology}[ - parent=cohomology, - gradingpos=lower, +\NewCohomologyClass\MyHomology[ + parent=\MyCohomology, + gradingposition=lower, ] -\newcohomology\co{H} +\NewObject\MyCohomology\co{H} -\newhomology\ho{H} +\NewObject\MyHomology\ho{H} + +\usepackage{showexpl,newunicodechar} + +\newunicodechar{⟨}{\textlangle} +\newunicodechar{⟩}{\textrangle} \makeatother @@ -214,100 +202,200 @@ -\newcommand*\mybs{$\backslash$} +\newcommand\mybs{$\backslash$} -\newcommand*\commandname[1]{\mybs\texttt{#1}} +\newcommand\commandname[1]{\mybs\texttt{#1}} \let\pack=\texttt \newcommand\semantex{Seman\!\TeX\xspace} \noindent -The \semantex package for \LaTeX\ delivers a more semantic, systematized way of writing mathematics, compared to the ordinary math syntax. The system is object-oriented and uses keyval syntax, and everything is highly customizable. At the same time, care has been taken to make it intuitive, natural, practical, and with an easy-to-use and lightweight syntax. +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!} \begingroup - \setupclass{var}{ - novaluekeys={ + \SetupClass\MyVar{ + singlekeys={ + {conj}{overline}, + {inv}{upper={-1}}, {inverseimage}{upper={-1},nopar}, }, valuekeys={ - {stalk}{lower=#1}, - {res}{ return,symbolputright={|}, lower={#1} }, - }, - argvaluekeys={ - {coef}{sep={;}{#1}}, + {der}{upper={ (#1) } }, + {res}{ return ,symbolputright ={|}, lower ={#1} }, + {stalk}{clower={#1}}, + % "clower" means "comma lower", i.e. lower index + % separated from any previous lower index by a comma }, } - Traditional math notation in \TeX\ is not particularly semantic -- you usually type the raw \emph{notation} rather than the underlying - \emph{meaning} of your math. - Take, for instance, the following equations from algebraic geometry: - \begin{align*} - \vf[inverseimage]{\sheafF}[spar,stalk=\vp] - &= - \sheafF[stalk=\vf{\vp}] , - \\ - \sheafO[\vU] - &= - \sheafO[\vX,res=\vU] , - \\ - \sheafHom{ \sheafF , \sheafG }{\vU} - &= - \Hom[\sheafO[\vU]]{ \sheafF[res=\vU] , \sheafG[res=\vU] } , - \\ - \co{0}{\vU,coef=\sheafO[\vX]} &= \sheafO[\vX]{\vU} - . - \end{align*} - Here, \( \sheafF \) and~\( \sheafG \) - are sheaves on some scheme~\( \vX \), - \( \sheafO[\vX] \)~is the structure sheaf, - and~\( \vU \subset \vX \) an open subset. - In traditional \TeX, you would probably define a collection of commands \lstinline!\sheafF!, \lstinline!\sheafG!, \lstinline!\sheafO!, and~\lstinline!\sheafHom! for~\( \sheafF \),~\( \sheafG \), \( \sheafO \), and~\( \sheafHom \) and then proceed - something like - \begin{lstlisting} -(f^{-1}\sheafF)_{p}=\sheafF_{f(p)}, -\sheafO_{U} = \sheafO_{X}|_{U}, -\sheafHom( \sheafF , \sheafG)(U) - = \Hom_{\sheafO_{X} ( \sheafF|_{U} , \sheafG|_{V} ), - H^{0}(U;\sheafF) = \sheafF(U). - \end{lstlisting} - For more than~90~\% of all mathematicians, this solution will be completely satisfactory; it prints what it is supposed to, and that's that. - If this is how you feel, there is absolutely no reason for you to continue reading. This package is for the remaining less than~10~\% who would prefer to write - something like the following instead: - \begin{lstlisting} -\vf[inverseimage]{ \sheafF }[spar,stalk=\vp] - = \sheafF[ stalk=\vf{\vp} ] , -\sheafO[\vU] = \sheafO[ \vX, res=\vU ], -\sheafHom{ \sheafF , \sheafG }{\vU} - = \Hom[\sheafO[\vU]]{ \sheafF[res=\vU], \sheafG[res=\vU] }, -\co{0}{ \vU, coef=\sheafO[\vX] } = \sheafO[\vX]{\vU}. - \end{lstlisting} - A lot of comments are in order. - The whole syntax will be explained in later chapters, but let us take a moment to look at these examples and understand the logic. - First of all, what is up with all the~\lstinline!v!'s in the command names \lstinline!\vf!, \lstinline!\vX!, \lstinline!\vU!? The~\lstinline!v!~stands for \textquote{variable}, and it is the prefix I recommend using for all standard variables. So for all letters in the alphabet, uppercase and lowercase, as well as the Greek ones, there will be a command: \lstinline!\va!, \lstinline!\vA!, \lstinline!\vb!, \lstinline!\vB!,~etc. - It is not always necessary to use them; for instance, in the above example, both \lstinline!\vX! and \lstinline!\vU! could have been replaced by simply~\lstinline!X!,~\lstinline!U! without changing anything. This is because we did not apply any arguments to these symbols. However, for the sake of consistency, I prefer to switch completely to using commands instead of writing the symbols directly. - How \emph{you} use the system is completely up to you. + Let us take an example from elementary analysis + to demonstrate the idea of the package: + Suppose we want to take the complex conjugate of a function~\( \vf \) + and then derive it \( \vn \)~times, i.e.~take~\( \smash{ \vf[conj,der=\vn] } \). + \semantex allows you to typeset this something like this: +\begin{LTXexample} +$ \vf[conj,der=\vn] $ +\end{LTXexample} + I shall explain the syntax in detail below, but some immediate comments are in order: First and foremost, the~\lstinline!v! + in the command names \lstinline!\vf! and~\lstinline!\vn! stands for~\enquote{variable}, so these commands are the + variables \( \vf \) and~\( \vn \). + In \semantex, it is usually best to create + commands \lstinline!\va!, \lstinline!\vA!, \lstinline!\vb!, \lstinline!\vB!, \ldots + for each variable you are using, upper- and lowercase. + However, it is completely up to the user how to do that and what to call them. + Note also that all of the keys + \lstinline!inv!,~\lstinline!res!,~etc.\ are defined by the + \emph{user}, and they can be modified and adjusted for all sorts of situations in any kinds of mathematics. + In other words, for the most part, you get to choose your own syntax. - In \semantex, all entries are being built up from the inside and out. - The basic syntax layout for most \semantex commands is - \begin{lstlisting} -\command[options]{argument} - \end{lstlisting} - Let us try focusing on the first example from above: - \begin{LTXexample} -$\vf[inverseimage]{\sheafF}[spar,stalk=\vp]$ - \end{LTXexample} - You always start with a central piece: a \emph{symbol}. - In the case of~\lstinline!\vf!, the symbol is~\( f \). After the symbol follows the options we apply to it, written in brackets~\lstinline![...]!. In this case, we the option~\lstinline!inverseimage!. This tells \semantex that we want the inverse image functor~\( \vf[inverseimage] \), so it adds a superscript~\lstinline!-1! to the symbol. After this, we apply the function~\lstinline!\vf[inverseimage]! to something, namely the sheaf~{$\sheafF$}. This is done by enclosing them in braces~\lstinline!{...}!.\footnote{You should be aware that this argument in braces~\texttt{\{...\}} is \emph{optional}. You can simply write~\texttt{$\backslash$vf[inverseimage]} if you want, and it will produce~\smash{\( \vf[inverseimage] \)}.} + Next, suppose we want to invert a function~\( \vg \) and restrict it to a subset~\( \vU \), and then apply it to~\( \vx \), + i.e.~take~\( \vg[inv,res=\vU]{\vx} \). This can be done by writing +\begin{LTXexample} +$ \vg[inv,res=\vU]{\vx} $ +\end{LTXexample} + Next, let us take an example from algebraic geometry: + Suppose \( \sheafF \)~is a sheaf and \( \vh \)~a~map, + and that we want to typeset the + equation~\( \smash{ + \vh[inverseimage]{\sheafF}[ + spar,stalk=\vp] + = + \sheafF[stalk=\vh{\vp}] + } \), + saying that the stalk of the inverse image~\( \vh[inverseimage]{\sheafF} \) + at the point~\( \vp \) is~\( \smash{ \sheafF[stalk=\vh{\vp}] } \). + This can be accomplished by typing +\begin{LTXexample} +$ \vh[inverseimage]{\sheafF}[spar,stalk=\vp] += +\sheafF[stalk=\vh{\vp}] $ +\end{LTXexample} + Here, \lstinline!spar! (an abbreviation for~\enquote{symbol parentheses}) + is the key that adds the parentheses around~\( \vh[inverseimage]{\sheafF} \). - Next, we want to take the stalk of this sheaf at the point~\( \vp \). If we simply wrote~\lstinline!\vf[inverseimage]{\sheafF}[stalk=\vp]!, we would get~\smash{\( \vf[inverseimage]{\sheafF}[stalk=\vp] \)}, which looks confusing. So we want to enclose~\smash{\( \vf[inverseimage]{\sheafF} \)} in parentheses before taking the stalk. This is done with the key~\lstinline!spar! (an abbreviation for \textquote{symbol parentheses}). - This key takes whatever has been typed so far, symbol and indices, and adds parentheses around it (of course, type and size is adjustable). - This~\lstinline!spar! is a key you fill find yourself using a lot. + Let us see how you could set up all the above notation: +\begin{lstlisting} +\documentclass{article} + +\usepackage{amsmath,semantex} + +\NewVariableClass\MyVar % creates a new class of variables, called "\MyVar" + +% Now we create a couple of variables of the class \MyVar: +\NewObject\MyVar\vf{f} +\NewObject\MyVarr\vg{g} +\NewObject\MyVar\vh{h} +\NewObject\MyVar\sheafF{\mathcal{F}} + +% Now we set up the class \MyVar: +\SetupClass\MyVar{ + 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 + {inv}{upper={-1}}, + {conj}{overline}, + {inverseimage}{upper={-1},nopar}, + }, + valuekeys={ % keys taking a 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} }, + }, +} +\end{lstlisting} \endgroup +%\begingroup +% \SetupClass\MyVar{ +% singlekeys={ +% {inverseimage}{upper={-1},nopar}, +% }, +% valuekeys={ +% {stalk}{lower=#1}, +% {res}{ return,symbolputright={|}, lower={#1} }, +% }, +% argvaluekeys={ +% {coef}{othersep={;}{#1}}, +% }, +% } +% +% Traditional math notation in \TeX\ is not particularly semantic -- you usually type the raw \emph{notation} rather than the underlying +% \emph{meaning} of your math. +% Take, for instance, the following equations from algebraic geometry: +% \begin{align*} +% \vf[inverseimage]{\sheafF}[spar,stalk=\vp] +% &= +% \sheafF[stalk=\vf{\vp}] , +% \\ +% \sheafreg[\vU] +% &= +% \sheafreg[\vX,res=\vU] , +% \\ +% \sheafHom{ \sheafF , \sheafG }{\vU} +% &= +% \Hom[\sheafreg[\vU]]{ \sheafF[res=\vU] , \sheafG[res=\vU] } , +% \\ +% \co{0}{\vU,coef=\sheafreg[\vX]} +% &= \sheafreg[\vX]{\vU} +% . +% \end{align*} +% Here, \( \sheafF \) and~\( \sheafG \) +% are sheaves on some scheme~\( \vX \), +% \( \sheafreg[\vX] \)~is the structure sheaf, +% and~\( \vU \subset \vX \) an open subset. +% In traditional \TeX, you would probably define a collection of commands \lstinline!\sheafF!, \lstinline!\sheafG!, \lstinline!\sheafreg!, and~\lstinline!\sheafHom! for~\( \sheafF \),~\( \sheafG \), \( \sheafreg \), and~\( \sheafHom \) and then proceed +% something like +% \begin{lstlisting} +%(f^{-1}\sheafF)_{p}=\sheafF_{f(p)}, +%\sheafreg_{U} = \sheafreg_{X}|_{U}, +%\sheafHom( \sheafF , \sheafG)(U) +% = \Hom_{\sheafreg_{X} ( \sheafF|_{U} , \sheafG|_{V} ), +% H^{0}(U;\sheafF) = \sheafF(U). +% \end{lstlisting} +% For more than~90~\% of all mathematicians, this solution will be completely satisfactory; it prints what it is supposed to, and that's that. +% If this is how you feel, there is absolutely no reason for you to continue reading. This package is for the remaining less than~10~\% who would prefer to write +% something like the following instead: +% \begin{lstlisting} +%\vf[inverseimage]{ \sheafF }[spar,stalk=\vp] +% = \sheafF[ stalk=\vf{\vp} ] , +%\sheafreg[\vU] = \sheafreg[ \vX, res=\vU ], +%\sheafHom{ \sheafF , \sheafG }{\vU} +% = \Hom[\sheafreg[\vU]]{ \sheafF[res=\vU], \sheafG[res=\vU] }, +%\co{0}{ \vU, coef=\sheafreg[\vX] } = \sheafreg[\vX]{\vU}. +% \end{lstlisting} +% +% A lot of comments are in order. +% The whole syntax will be explained in later chapters, but let us take a moment to look at these examples and understand the logic. +% First of all, what is up with all the~\lstinline!v!'s in the command names \lstinline!\vf!, \lstinline!\vX!, \lstinline!\vU!? The~\lstinline!v!~stands for \textquote{variable}, and it is the prefix I recommend using for all standard variables. So for all letters in the alphabet, uppercase and lowercase, as well as the Greek ones, there will be a command: \lstinline!\va!, \lstinline!\vA!, \lstinline!\vb!, \lstinline!\vB!,~etc. +% It is not always necessary to use them; for instance, in the above example, both \lstinline!\vX! and \lstinline!\vU! could have been replaced by simply~\lstinline!X!,~\lstinline!U! without changing anything. This is because we did not apply any arguments to these symbols. However, for the sake of consistency, I prefer to switch completely to using commands instead of writing the symbols directly. +% How \emph{you} use the system is completely up to you. +% +% In \semantex, all entries are being built up from the inside and out. +% The basic syntax layout for most \semantex commands is +% \begin{lstlisting} +%\⟨object⟩[⟨options⟩]{⟨argument⟩} +% \end{lstlisting} +% Let us try focusing on the first example from above: +% \begin{LTXexample} +%$\vf[inverseimage]{\sheafF}[spar,stalk=\vp]$ +% \end{LTXexample} +% You always start with a central piece: a \emph{⟨symbol⟩}. +% In the case of~\lstinline!\vf!, the symbol is~\( f \). After the symbol follows the options we apply to it, written in brackets~\lstinline![...]!. In this case, we the option~\lstinline!inverseimage!. This tells \semantex that we want the inverse image functor~\( \vf[inverseimage] \), so it adds a superscript~\lstinline!-1! to the symbol. After this, we apply the function~\lstinline!\vf[inverseimage]! to something, namely the sheaf~{$\sheafF$}. This is done by enclosing them in braces~\lstinline!{...}!.\footnote{You should be aware that this argument in braces~\texttt{\{...\}} is \emph{optional}. You can simply write~\texttt{$\backslash$vf[inverseimage]} if you want, and it will produce~\smash{\( \vf[inverseimage] \)}.} +% +% +% Next, we want to take the stalk of this sheaf at the point~\( \vp \). If we simply wrote~\lstinline!\vf[inverseimage]{\sheafF}[stalk=\vp]!, we would get~\smash{\( \vf[inverseimage]{\sheafF}[stalk=\vp] \)}, which looks confusing. So we want to enclose~\smash{\( \vf[inverseimage]{\sheafF} \)} in parentheses before taking the stalk. This is done with the key~\lstinline!spar! (an abbreviation for \textquote{symbol parentheses}). +% This key takes whatever has been typed so far, symbol and indices, and adds parentheses around it (of course, type and size is adjustable). +% This~\lstinline!spar! is a key you fill find yourself using a lot. +%\endgroup + \chapter{Getting started} To get started using \semantex, load down the package @@ -316,54 +404,59 @@ with \usepackage{semantex} \end{lstlisting} The \semantex system is object-oriented; all entities are objects of some class. When you load the package, there -is only one class by default, which is simply called \lstinline!semantexvariable!. +is only one class by default, which is simply called \lstinline!\SemantexVariable!. You should think of this as a low-level class, the parent of all other classes. Therefore, I highly advice against using it directly or modifying it. Instead, we create a new, more high-level variable class. -To make notations brief, we call it \lstinline!var!. -We could write \lstinline!\newvariableclass{var}!, but we choose to +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 pass some options to it in~\lstinline![...]!: \begin{lstlisting} -\newvariableclass{var}[output=var] +\NewVariableClass\MyVar[output=\MyVar] \end{lstlisting} -This \lstinline!output=var! option will be explained better below. +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!var!, -then \lstinline!\vf{\vx}!~(i.e.~\( \vf{\vx} \))~will also of class~\lstinline!var!. +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!. Now we have a class, but we do not have any objects. -When we create the class~\lstinline!var!, the system -automatically defines the command \lstinline!\newvar! -that creates a new object of class~\lstinline!var!. The syntax is +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 +can create objects of that class wtih the syntax \begin{lstlisting} -\newvar\⟨variable name⟩{⟨variable symbol⟩}[options] +\NewObject\⟨Class⟩\⟨object⟩{⟨object symbol⟩}[⟨options⟩] \end{lstlisting} -For instance, we may write +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.} +So after writing, \begin{lstlisting} -\newvar\vf{f} -\newvar\vx{x} +\NewObject\MyVar\vf{f} +\NewObject\MyVar\vx{x} \end{lstlisting} -to get two variables \lstinline!\vf! and~\lstinline!\vx! with symbols \( f \) resp.~\( x \). +we get two variables \lstinline!\vf! and~\lstinline!\vx! with symbols \( f \) resp.~\( x \). Let us perform a stupid test to see if the variables work: \begin{LTXexample} $\vf$, $\vx$ \end{LTXexample} -Th general syntax of a variable-type command is +Th general syntax of a variable-type object is \begin{lstlisting} -\command[options]{argument} +\⟨object⟩[⟨options⟩]{⟨argument⟩} \end{lstlisting} -Both \lstinline!options! and \lstinline!argument! are optional +Both \lstinline!⟨options⟩! and \lstinline!⟨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. +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. So we may write: \begin{LTXexample} -$\vf{1}$, $\vf{\vx}$ +$\vf{1}$, $\vf{\vx}$, +$\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 +\lstinline!⟨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} @@ -382,99 +475,99 @@ 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. This is pretty time-consuming, so I did it for you already: \begin{lstlisting} -\newvar\va{a} -\newvar\vb{b} -\newvar\vc{c} -\newvar\vd{d} -\newvar\ve{e} -\newvar\vf{f} -\newvar\vg{g} -\newvar\vh{h} -\newvar\vi{i} -\newvar\vj{j} -\newvar\vk{k} -\newvar\vl{l} -\newvar\vm{m} -\newvar\vn{n} -\newvar\vo{o} -\newvar\vp{p} -\newvar\vq{q} -\newvar\vr{r} -\newvar\vs{s} -\newvar\vt{t} -\newvar\vu{u} -\newvar\vv{v} -\newvar\vw{w} -\newvar\vx{x} -\newvar\vy{y} -\newvar\vz{z} - -\newvar\vA{A} -\newvar\vB{B} -\newvar\vC{C} -\newvar\vD{D} -\newvar\vE{E} -\newvar\vF{F} -\newvar\vG{G} -\newvar\vH{H} -\newvar\vI{I} -\newvar\vJ{J} -\newvar\vK{K} -\newvar\vL{L} -\newvar\vM{M} -\newvar\vN{N} -\newvar\vO{O} -\newvar\vP{P} -\newvar\vQ{Q} -\newvar\vR{R} -\newvar\vS{S} -\newvar\vT{T} -\newvar\vU{U} -\newvar\vV{V} -\newvar\vW{W} -\newvar\vX{X} -\newvar\vY{Y} -\newvar\vZ{Z} - -\newvar\valpha{\alpha} -\newvar\vvaralpha{\varalpha} -\newvar\vbeta{\beta} -\newvar\vgamma{\gamma} -\newvar\vdelta{\delta} -\newvar\vepsilon{\epsilon} -\newvar\vvarepsilon{\varepsilon} -\newvar\vzeta{\zeta} -\newvar\veta{\eta} -\newvar\vtheta{\theta} -\newvar\viota{\iota} -\newvar\vkappa{\kappa} -\newvar\vlambda{\lambda} -\newvar\vmu{\mu} -\newvar\vnu{\nu} -\newvar\vxi{\xi} -\newvar\vpi{\pi} -\newvar\vvarpi{\varpi} -\newvar\vrho{\rho} -\newvar\vsigma{\sigma} -\newvar\vtau{\tau} -\newvar\vupsilon{\upsilon} -\newvar\vphi{\phi} -\newvar\vvarphi{\varphi} -\newvar\vchi{\chi} -\newvar\vpsi{\psi} -\newvar\vomega{\omega} - -\newvar\vGamma{\Gamma} -\newvar\vDelta{\Delta} -\newvar\vTheta{\Theta} -\newvar\vLambda{\Lambda} -\newvar\vXi{\Xi} -\newvar\vPi{\Pi} -\newvar\vSigma{\Sigma} -\newvar\vUpsilon{\Upsilon} -\newvar\vPhi{\Phi} -\newvar\vPsi{\Psi} -\newvar\vOmega{\Omega} +\NewObject\MyVar\va{a} +\NewObject\MyVar\vb{b} +\NewObject\MyVar\vc{c} +\NewObject\MyVar\vd{d} +\NewObject\MyVar\ve{e} +\NewObject\MyVar\vf{f} +\NewObject\MyVar\vg{g} +\NewObject\MyVar\vh{h} +\NewObject\MyVar\vi{i} +\NewObject\MyVar\vj{j} +\NewObject\MyVar\vk{k} +\NewObject\MyVar\vl{l} +\NewObject\MyVar\vm{m} +\NewObject\MyVar\vn{n} +\NewObject\MyVar\vo{o} +\NewObject\MyVar\vp{p} +\NewObject\MyVar\vq{q} +\NewObject\MyVar\vr{r} +\NewObject\MyVar\vs{s} +\NewObject\MyVar\vt{t} +\NewObject\MyVar\vu{u} +\NewObject\MyVar\vv{v} +\NewObject\MyVar\vw{w} +\NewObject\MyVar\vx{x} +\NewObject\MyVar\vy{y} +\NewObject\MyVar\vz{z} + +\NewObject\MyVar\vA{A} +\NewObject\MyVar\vB{B} +\NewObject\MyVar\vC{C} +\NewObject\MyVar\vD{D} +\NewObject\MyVar\vE{E} +\NewObject\MyVar\vF{F} +\NewObject\MyVar\vG{G} +\NewObject\MyVar\vH{H} +\NewObject\MyVar\vI{I} +\NewObject\MyVar\vJ{J} +\NewObject\MyVar\vK{K} +\NewObject\MyVar\vL{L} +\NewObject\MyVar\vM{M} +\NewObject\MyVar\vN{N} +\NewObject\MyVar\vO{O} +\NewObject\MyVar\vP{P} +\NewObject\MyVar\vQ{Q} +\NewObject\MyVar\vR{R} +\NewObject\MyVar\vS{S} +\NewObject\MyVar\vT{T} +\NewObject\MyVar\vU{U} +\NewObject\MyVar\vV{V} +\NewObject\MyVar\vW{W} +\NewObject\MyVar\vX{X} +\NewObject\MyVar\vY{Y} +\NewObject\MyVar\vZ{Z} + +\NewObject\MyVar\valpha{\alpha} +\NewObject\MyVar\vvaralpha{\varalpha} +\NewObject\MyVar\vbeta{\beta} +\NewObject\MyVar\vgamma{\gamma} +\NewObject\MyVar\vdelta{\delta} +\NewObject\MyVar\vepsilon{\epsilon} +\NewObject\MyVar\vvarepsilon{\varepsilon} +\NewObject\MyVar\vzeta{\zeta} +\NewObject\MyVar\veta{\eta} +\NewObject\MyVar\vtheta{\theta} +\NewObject\MyVar\viota{\iota} +\NewObject\MyVar\vkappa{\kappa} +\NewObject\MyVar\vlambda{\lambda} +\NewObject\MyVar\vmu{\mu} +\NewObject\MyVar\vnu{\nu} +\NewObject\MyVar\vxi{\xi} +\NewObject\MyVar\vpi{\pi} +\NewObject\MyVar\vvarpi{\varpi} +\NewObject\MyVar\vrho{\rho} +\NewObject\MyVar\vsigma{\sigma} +\NewObject\MyVar\vtau{\tau} +\NewObject\MyVar\vupsilon{\upsilon} +\NewObject\MyVar\vphi{\phi} +\NewObject\MyVar\vvarphi{\varphi} +\NewObject\MyVar\vchi{\chi} +\NewObject\MyVar\vpsi{\psi} +\NewObject\MyVar\vomega{\omega} + +\NewObject\MyVar\vGamma{\Gamma} +\NewObject\MyVar\vDelta{\Delta} +\NewObject\MyVar\vTheta{\Theta} +\NewObject\MyVar\vLambda{\Lambda} +\NewObject\MyVar\vXi{\Xi} +\NewObject\MyVar\vPi{\Pi} +\NewObject\MyVar\vSigma{\Sigma} +\NewObject\MyVar\vUpsilon{\Upsilon} +\NewObject\MyVar\vPhi{\Phi} +\NewObject\MyVar\vPsi{\Psi} +\NewObject\MyVar\vOmega{\Omega} \end{lstlisting} Just like~\lstinline!\vf!, these can all be regarded as functions, so~\lstinline!\va{\vb}!~produces~\( \va{\vb} \). @@ -489,7 +582,7 @@ $\vf[par=\bigg]{\vx}$, $\vf[par=\Bigg]{\vx}$, $\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!: +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}$ \end{LTXexample} @@ -504,29 +597,34 @@ $\vf['''] = \vf[prime,prime,prime]$ 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!novaluekeys! + \lstinline!singlekeys! \qquad\qquad and \qquad\qquad \lstinline!valuekeys!. \end{center} -In short, \lstinline!novaluekeys! is for keys that do \emph{not} take a value (i.e.~keys using the syntax~\lstinline!\command[key]!), and \lstinline!valuekeys! is for keys that \emph{do} take a value -(i.e.~keys using the syntax~\lstinline!\command[key=value]!)). +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} 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!novaluekeys!: +We add this key using the key \lstinline!singlekeys!, +which is for keys that do not take a value: \begin{lstlisting} -\setupclass{var}{ - novaluekeys={ +\SetupClass\MyVar{ + singlekeys={ {inv}{ upper={-1} }, }, } \end{lstlisting} -\setupclass{var}{ -novaluekeys={ +\SetupClass\MyVar{ +singlekeys={ {inv}{ upper={-1} }, }, } @@ -538,19 +636,17 @@ $\va[inv]$, $\vf[inv]$, $\vg[1,2,inv]$, $\vh[\va,\vb,inv]$ \end{LTXexample} -The key \lstinline!novaluekeys! is for keys that take no value, -like \lstinline!inv!. 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!novaluekeys! and \lstinline!valuekeys!. +%to a class: \lstinline!singlekeys! and \lstinline!valuekeys!. %The difference is that For instance, suppose we want a command for deriving a function \( n \)~times. -For this, we add the following extra keyval key~\lstinline!der!: +For this, we add the key~\lstinline!der!: \begin{lstlisting} -\setupclass{var}{ - novaluekeys={ +\SetupClass\MyVar{ + singlekeys={ {inv}{ upper={-1} }, }, valuekeys={ @@ -558,58 +654,55 @@ For this, we add the following extra keyval key~\lstinline!der!: }, } \end{lstlisting} -\setupclass{var}{ +\SetupClass\MyVar{ valuekeys={ {der}{ upper={(#1)} }, }, } The~\lstinline!#1! will contain whatever the -user added as the value of the key. +user wrote as the value of the key. Now we can write: \begin{LTXexample} $\vf[der=\vn]{\vx}$ \end{LTXexample} -Maybe we also want a more elementary operation: -raising a variable to some \emph{power}. -We could have called the key \lstinline!power!, but this is long and cumbersome, so let us simply call it \lstinline!to!: +Maybe we also want a more elementary key~\lstinline!power! for raising a variable to a power: \begin{lstlisting} -\setupclass{var}{ - novaluekeys={ +\SetupClass\MyVar{ + singlekeys={ {inv}{ upper={-1} }, }, valuekeys={ {der}{ upper={(#1)} }, - {to}{ upper={#1} }, + {power}{ upper={#1} }, }, } \end{lstlisting} -\setupclass{var}{ +\SetupClass\MyVar{ valuekeys={ - {to}{ upper={#1} }, + {power}{ upper={#1} }, }, } This allows us to write \begin{LTXexample} -$\vx[to=2]$, -$\vy[1,to=2] + \vy[2,to=2]$ +$\vx[power=2]$, +$\vy[1,power=2] + \vy[2,power=2]$ \end{LTXexample} -In the long run, you might want to define a command~\lstinline!squared! or~\lstinline!sq! and make it equivalent to~\lstinline!to=2!. -Let us try doing something a bit more complicated: Adding a key for restricting a function to a smaller subset. +Let us try doing something a bit more complicated: adding a key for restricting a function to a smaller subset. For this, we do the following: \begin{lstlisting} -\setupclass{var}{ - novaluekeys={ +\SetupClass\MyVar{ + singlekeys={ {inv}{ upper={-1} }, }, valuekeys={ {der}{ upper={(#1)} }, - {to}{ upper={#1} }, + {power}{ upper={#1} }, {res}{ return,symbolputright={|}, lower={#1} }, }, } \end{lstlisting} -\setupclass{var}{ +\SetupClass\MyVar{ valuekeys={ {res}{ return,symbolputright={|}, lower={#1} }, }, @@ -626,54 +719,56 @@ $\vg[1,res=\vY]{\vy}$, $\vh[inv,res=\vT]{\vz}$ \end{LTXexample} -If the reader starts playing around with the \semantex functions, they will discover that whenever you apply a function to something, the result becomes a new function that can take an argument itself. This behaviour is both useful and extremely necessary in order for the package to be useful in practice. For instance, you may write +If the reader starts playing around with the \semantex functions, they will discover that whenever you apply a function to something, the result becomes a new function that can take an argument itself (this is why we wrote~\lstinline!output=\MyVar! in the definition of the class~\lstinline!\MyVar!). This behaviour is both useful and extremely necessary in order for the package to be useful in practice. For instance, you may write \begin{LTXexample} $\vf[der=\vn]{\vx}{\vy}{\vz} =\vg{\vu,\vv,\vw}[3]{ - \vx[1],\vx[2]}[8,1,der=2]{\vt}$ + \vx[1],\vx[2]}[8,1,der=2]{ + \vt}$ \end{LTXexample} -Some people prefer to be able to scale the restriction -line. I rarely do that, but for that purpose, we could do the following: +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{var}{ +\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, sparsize=auto, otherspar=.\vert, - sparsize=normal, lower={#1} }, - % This auto scales the vertical bar. See the chapter on the spar - % key for information about sparsize and otherspar + {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 }, } \end{lstlisting} -So to sum up, we first defined a class~\lstinline!var! -via \lstinline!\newvariableclass! and then used \lstinline!\setupclass! to add keys to it. In fact, we could have done it all at once by passing these options directly to \lstinline!\newvariableclass!: +So to sum up, we first defined a class~\lstinline!\MyVar! +via \lstinline!\NewVariableClass! and then used \lstinline!\SetupClass! to add keys to it. In fact, we could have done it all at once by passing these options directly to \lstinline!\NewVariableClass!: \begin{lstlisting} - \newvariableclass{var}[ - output=var, - novaluekeys={ - {inv}{ upper={-1} }, - }, - valuekeys={ - {der}{ upper={(#1)} }, - {to}{ upper={#1} }, - {res}{ rightreturn, symbolputright={|}, - lower={#1} }, - }, - ] +\NewVariableClass\MyVar[ + output=\MyVar, % This means that the output of an object + % of class \MyVar is also of class \MyVar + singlekeys={ + {inv}{ upper={-1} }, + }, + valuekeys={ + {der}{ upper={(#1)} }, + {power}{ upper={#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!var!. However, when you set up your own system, you may as well just add all of the keys like this when you create the class and then be done with it. +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 \lstinline!parent=myclass! in the class declaration to tell that \lstinline!myclass! 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!var! that has all the keyval syntax and only use subclasses for further \emph{customization}. We shall see examples of this below. \chapter{Example: Elementary algebra} -\setupclass{var}{ - novaluekeys={ - {pol}{ +\SetupClass\MyVar{ + singlekeys={ + {poly}{ par, % This tells semantex to use parentheses around % the argument in the first place, in case this % had been turned off @@ -682,13 +777,13 @@ Let me add that it is possible to create subclasses of existing classes. You jus }, } -Let us try to use the \semantex system to build some commands +Let us try to use \semantex to build some commands for doing algebra. -As an algebraist, one of the first things you might want to do is to create polynomial rings~\( \vk[pol]{\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: +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{var}{ - novaluekeys={ - {pol}{ +\SetupClass\MyVar{ + singlekeys={ + {poly}{ par, % This tells semantex to use parentheses around % the argument in the first place, in case this % had been turned off @@ -699,13 +794,13 @@ 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[pol]{\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{var}{ - novaluekeys={ - {pol}{ +\SetupClass\MyVar{ + singlekeys={ + {poly}{ par, % This tells semantex to use parentheses around % the argument in the first place, in case this % had been turned off @@ -718,8 +813,8 @@ It is straightforward how to do adjust this to instead write the \emph{field} ge }, } \end{lstlisting} -\setupclass{var}{ - novaluekeys={ +\SetupClass\MyVar{ + singlekeys={ {field}{ par, leftpar=(,rightpar=), @@ -727,13 +822,13 @@ It is straightforward how to do adjust this to instead write the \emph{field} ge }, } Now \lstinline!\vk[field]{\vx,\vy,\vz}! produces~\( \vk[field]{\vx,\vy,\vz} \). Of course, leaving out the \lstinline!field! -key would produce the same result with the current configuration of~\lstinline!var!. However, it is still best to use a key for this, both because this makes the semantics more clear, but also because you might later change some settings that would cause the default behaviour to be different. +key would produce the same result with the current configuration of the class~\lstinline!\MyVar!. However, it is still best to use a key for this, both because this makes the semantics more clear, but also because you might later change some settings that would cause the default behaviour to be different. -Adding support for free algebras and fields is almost as easy, but there is a catch: +Adding support for free algebras, power series, and Laurent series is almost as easy, but there is a catch: \begin{lstlisting} -\setupclass{var}{ - novaluekeys={ - {pol}{ +\SetupClass\MyVar{ + singlekeys={ + {poly}{ par, % This tells semantex to use parentheses around % the argument in the first place, in case this % had been turned off @@ -756,18 +851,18 @@ Adding support for free algebras and fields is almost as easy, but there is a ca {laurent}{ par, leftpar=(, rightpar=), - prearg={\!\!\noexpand\semantexdelimsize(}, - postarg={\noexpand\semantexdelimsize)\!\!}, + prearg={\!\!\noexpand\SemantexDelimiterSize(}, + postarg={\noexpand\SemantexDelimiterSize)\!\!}, % These are printed before and after the argument. - % The command "\semantexdelimsize" is substituted + % The command "\SemantexDelimiterSize" is substituted % by \big, \Big, ..., or whatever size the % argument delimiters have }, }, } \end{lstlisting} -\setupclass{var}{ - novaluekeys={ +\SetupClass\MyVar{ + singlekeys={ {freealg}{ par, leftpar=\noexpand\langle, @@ -781,10 +876,10 @@ Adding support for free algebras and fields is almost as easy, but there is a ca {laurent}{ par, leftpar=(, rightpar=), - prearg={\!\!\noexpand\semantexdelimsize(}, - postarg={\noexpand\semantexdelimsize)\!\!}, + prearg={\!\!\noexpand\SemantexDelimiterSize(}, + postarg={\noexpand\SemantexDelimiterSize)\!\!}, % These are printed before and after the argument. - % The command "\semantexdelimsize" is substituted + % The command "\SemantexDelimiterSize" is substituted % by \big, \Big, ..., or whatever size the % argument delimiters have }, @@ -803,8 +898,8 @@ $\vk[laurent]{\vz}$ Let us look at some other algebraic operations that we can control via \semantex: \begin{lstlisting} -\setupclass{var}{ - novaluekeys={ +\SetupClass\MyVar{ + singlekeys={ {op}{upper={\noexpand\mathrm{op}}}, % opposite groups, rings, categories, etc. {algclosure}{overline}, @@ -835,8 +930,8 @@ Let us look at some other algebraic operations that we can control via \semantex }, } \end{lstlisting} -\setupclass{var}{ - novaluekeys={ +\SetupClass\MyVar{ + singlekeys={ {op}{upper={\noexpand\mathrm{op}}}, % opposite groups, rings, categories, etc. {algclosure}{overline}, @@ -887,7 +982,7 @@ does not yield a satisfactory result. However, the \lstinline!spar! key saves th \begin{LTXexample} $\vf[der=\vn,spar,inv]$ \end{LTXexample} -So \lstinline!spar! simply adds a pair of parentheses around the current symbol, complete with all indices that you may have added to it so for. The name \lstinline!spar! stands for \enquote{symbol parentheses}. You can add as many as you like: +So \lstinline!spar! simply adds a pair of parentheses around the current symbol, complete with all indices that you may have added to it so far. The name \lstinline!spar! stands for \enquote{symbol parentheses}. You can add as many as you like: \begin{LTXexample} $ \vf[1,res=\vV,spar,conj,op,spar,0,inv,spar,mod=\vI,spar,dual]{\vx} $ \end{LTXexample} @@ -907,18 +1002,73 @@ So returning to the above example, we can write \begin{LTXexample} $\vf[1,res=\vV,spar,conj,op,spar=\big,0,inv,spar=\Big,mod=\vI,spar=\bigg,dual]{\vx}$ \end{LTXexample} -To adjust the type of parentheses, use the \lstinline!leftspar! and \lstinline!rightspar! keys: +To adjust the type of brackets, use the \lstinline!leftspar! and \lstinline!rightspar! keys: \begin{LTXexample} $\vf[leftspar={[},rightspar={\}},spar,spar=\Bigg]$ \end{LTXexample} -Occassionally, it is useful to be able to input a particular kind of parentheses just once, -without adjusting any settings. For this purpose, we have the (previously mentioned) -\lstinline!otherspar!~key. It uses the syntax~\lstinline!otherspar={opening parenthesis}{closing parenthesis}!: +Occassionally, it is useful to be able to input a particular kind of brackets just once, +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⟩} +\end{lstlisting} +Let us see them in action: \begin{LTXexample} $\vf[otherspar={[}{)},otherspar={\{}{\rangle}, - spar]$ + Otherspar={\langle}{\rangle}{\Bigg},spar]$ \end{LTXexample} +\chapter{The \texorpdfstring{\texttt{$\backslash$⟨Class⟩}}{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 +want to write expressions like +\[ + \MyVar{\vf\circ\vg}[spar,der=\vn]{\vx}. +\] +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⟩!. +So the above equation can be written +\begin{LTXexample} +$\MyVar{\vf\circ\vg}[ + spar,der=\vn]{\vx}$ +\end{LTXexample} +More generally, when you crate the class~\lstinline!\⟨Class⟩!, +you can use it as a command with the following syntax: +\begin{lstlisting} +\⟨Class⟩{⟨symbol⟩}[⟨options⟩]⟨usual syntax of class⟩ +\end{lstlisting} + +\chapter{The \texttt{return} keys}\label{ch:return} + +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, +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. + +However, there are other times when this behaviour is not what you want. +For instance, if you want to comjugate the inverse of a function, the following looks wrong: +\begin{LTXexample} +$\vf[inv,conj]$ +\end{LTXexample} +Therefore, there is a command \lstinline!return! that can be applied at any point to invoke the routine of adding all indices and commands to the symbol. Let us try it out: +\begin{LTXexample} +$\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!. + \chapter{The \texttt{command} key} @@ -932,21 +1082,21 @@ 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: \begin{lstlisting} -\setupclass{var}{ - novaluekeys={ +\SetupClass\MyVar{ + singlekeys={ {overline}{command=\noexpand\overline}, }, } \end{lstlisting} -\setupclass{var}{ - novaluekeys={ +\SetupClass\MyVar{ + singlekeys={ {overline}{command=\noexpand\overline}, }, } -This is how the key \lstinline!overline! is defined internally, except it is defined on the level of the superclass \lstinline!automathvariable! instead. We need the key \lstinline!\noexpand! in order for everything to expand properly. This is only necessary for some commands, and to tell the truth, I haven't quite figured out the system of which commands need it and which ones do not. However, as usual, if something does not work, try throwing in some \lstinline!\noexpand!'s and see if it solves the problem. +This is how the key \lstinline!overline! is defined internally, except it is defined on the level of the superclass \lstinline!\SemantexVariable! instead. We need the key \lstinline!\noexpand! in order for everything to expand properly. This is only necessary for some commands, and to tell the truth, I haven't quite figured out the system of which commands need it and which ones do not. However, as usual, if something does not work, try throwing in some \lstinline!\noexpand!'s and see if it solves the problem. Here are some more examples of predefined keys that use the command key: \begin{lstlisting} -\setupclass{var}{ % do not add these -- they are already predefined! +\SetupClass\MyVar{ % do not add these -- they are already predefined! novalueskeys={ {smash}{command=\noexpand\smash}, {tilde}{command=\noexpand\tilde}, @@ -965,141 +1115,116 @@ $\va[roman]$, $\va[bar]$ \end{LTXexample} -\chapter{The \texttt{return} keys}\label{ch:return} - -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 do not normally 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, -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. - -However, there are other times when this behaviour is not what you want. -For instance, if you want to comjugate the inverse of a function, the following looks wrong: -\begin{LTXexample} -$\vf[inv,conj]$ -\end{LTXexample} -Therefore, there is a command \lstinline!return! that can be applied at any point to invoke the routine of adding all indices and commands to the symbol. Let us try it out: -\begin{LTXexample} -$\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!. \chapter{Example: Algebraic geometry} Let us discuss how to typeset sheaves and operations on morphisms in algebraic geometry. First of all, adding commands for sheaves is not a big deal: \begin{lstlisting} -\newvar\sheafF{\mathcal{F}} -\newvar\sheafG}{\mathcal{G}} -\newvar\sheafH{\mathcal{H}} -\newvar\sheafO{\mathcal{O}} -\newvar\sheafHom{\mathcal{H}\!\!om} +\NewObject\MyVar\sheafF{\mathcal{F}} +\NewObject\MyVar\sheafG}{\mathcal{G}} +\NewObject\MyVar\sheafH{\mathcal{H}} +\NewObject\MyVar\sheafreg{\mathcal{O}} + % sheaf of regular functions +\NewObject\MyVar\sheafHom{\mathop{\mathcal{H}om}} \end{lstlisting} You can of course add as many sheaf commands as you need. -Also, to make notations shorter, you could consider -calling the commands~\lstinline!\shF!, \lstinline!\shG!, \lstinline!\shH!, \lstinline!\shO!, and~\lstinline!\shHom! instead, as I usually do. -You may also want to have a separate command~\lstinline!shreg! -for the sheaf~\( \sheafO \) -of regular functions. 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!var! key: +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{var}{ - novaluekeys={ - {comor}{upper=\#}, +\SetupClass\MyVar{ + singlekeys={ + {comorphism}{upper=\#}, % comorphisms, i.e. f^{\#} {inverseimage}{upper={-1},nopar}, % inverse image of sheaves - {shpull}{upper=*,nopar}, + {sheafpull}{upper=*,nopar}, % sheaf *-pullback - {shpush}{lower=*,nopar}, + {sheafpush}{lower=*,nopar}, % sheaf *-pushforward - {sh!pull}{upper=!,nopar}, + {sheaf!pull}{upper=!,nopar}, % sheaf !-pullback - {sh!push}{lower=!,nopar}, + {sheaf!push}{lower=!,nopar}, % sheaf !-pushforward }, } \end{lstlisting} -\setupclass{var}{ - novaluekeys={ - {comor}{upper=\#}, +\SetupClass\MyVar{ + singlekeys={ + {comorphism}{upper=\#}, % comorphisms, i.e. f^{\#} {inverseimage}{upper={-1},nopar}, % inverse image of sheaves - {shpull}{upper=*,nopar}, + {sheafpull}{upper=*,nopar}, % sheaf *-pullback - {shpush}{lower=*,nopar}, + {sheafpush}{lower=*,nopar}, % sheaf *-pushforward - {sh!pull}{upper=!,nopar}, + {sheaf!pull}{upper=!,nopar}, % sheaf !-pullback - {sh!push}{lower=!,nopar}, + {sheaf!push}{lower=!,nopar}, % sheaf !-pushforward }, } -We have added the command \lstinline!nopar! to all pullback and pushforward commands since it is custom to write, say,~\( \vf[shpull]{\sheafF} \) rather than~\( \vf[shpull,par]{\sheafF} \). Of course, you can decide that for yourself, and in any case, you can write~\lstinline!\vf[shpull,par]{\shF}! if you want to force it to use parentheses in a particular case. Of course, since all \semantex variables can be used as functions, so can whatever these pullback and pushforward operations output. So we may write: +We have added the command \lstinline!nopar! to all pullback and pushforward commands since it is custom to write, say,~\( \vf[sheafpull]{\sheafF} \) rather than~\( \vf[sheafpull,par]{\sheafF} \). Of course, you can decide that for yourself, and in any case, you can write~\lstinline!\vf[sheafpull,par]{\sheafF}! if you want to force it to use parentheses in a particular case. Of course, since all \semantex variables can be used as functions, so can whatever these pullback and pushforward operations output. So we may write: \begin{LTXexample} For a morphism~$ \vf \colon \vX \to \vY $ with -comorphism~$ \vf[comor] -\colon \sheafO[\vY] \to -\vf[shpush]{\sheafO[\vX]} $, +comorphism~$ \vf[comorphism] +\colon \sheafreg[\vY] \to +\vf[sheafpush]{\sheafreg[\vX]} $, and for a sheaf~$ \sheafF $ on~$ \vY $, we can define the -pullback~$ \vf[shpull]{ +pullback~$ \vf[sheafpull]{ \sheafF} $ by letting~$ -\vf[shpull]{ \sheafF}{\vU} = \cdots $ and the $ ! $-pullback by letting~$ -\vf[sh!pull]{\sheafF}{\vU} = \cdots $. +\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 other things in math called pullbacks, so I prefer to use the \lstinline!sh!~prefix to show that this is for sheaves. +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. Probably, in the long run, an algebraic geometer might also want to abbreviate~\lstinline!inverseimage! to~\lstinline!invim!. There are a number of other operations we might want to do for sheaves. We already defined the key~\lstinline!res! for restriction, so there is no need to define this again. However, we might need to stalk, sheafify, take dual sheaves, and twist sheaves. Let us define keys for this: \begin{lstlisting} -\setupclass{var}{ +\SetupClass\MyVar{ valuekeys={ {stalk}{clower={#1}}, - {twist}{return,symbolputright={(#1)}}, + % "clower" means "comma lower", i.e. lower index + % separated from any previous lower index by a comma + {sheaftwist}{return,symbolputright={(#1)}}, }, - novaluekeys={ + singlekeys={ {sheafify}{upper=+}, - {shdual}{upper=\vee}, + {sheafdual}{upper=\vee}, }, } \end{lstlisting} -\setupclass{var}{ +\SetupClass\MyVar{ valuekeys={ {stalk}{clower={#1}}, - {twist}{return,symbolputright={(#1)}}, + % "clower" means "comma lower", i.e. lower index + % separated from any previous lower index by a comma + {sheaftwist}{return,symbolputright={(#1)}}, }, - novaluekeys={ + singlekeys={ {sheafify}{upper=+}, - {shdual}{upper=\vee}, + {sheafdual}{upper=\vee}, }, } -The key \lstinline!clower! stands for \enquote{comma-lower}. +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= \vp]$, -$\sheafO[\vX,stalk=\vp]$, +$\sheafreg[\vX,stalk=\vp]$, $\sheafG[sheafify]$, -$\vf[inverseimage]{\sheafO[ +$\vf[inverseimage]{\sheafreg[ \vY]}[spar,stalk=\vx]$ -$\sheafG[shdual]$, -$\sheafO[\vX][twist=-1]$, -$\sheafO[twist=1,shdual]$ +$\sheafG[sheafdual]$, +$\sheafreg[\vX][sheaftwist=-1]$, +$\sheafreg[sheaftwist=1,sheafdual]$ \end{LTXexample} \chapter{Example: Homological algebra} @@ -1108,18 +1233,18 @@ Before you venture into homological algebra, you should probably define some keys for the standard constructions: \begin{lstlisting} -\newvar\Hom{\operatorname{Hom}} -\newvar\Ext{\operatorname{Ext}} -\newvar\Tor{\operatorname{Tor}} +\NewObject\MyVar\Hom{\operatorname{Hom}} +\NewObject\MyVar\Ext{\operatorname{Ext}} +\NewObject\MyVar\Tor{\operatorname{Tor}} \end{lstlisting} -\newvar\Ext{\operatorname{Ext}} -\newvar\Tor{\operatorname{Tor}} +\NewObject\MyVar\Ext{\operatorname{Ext}} +\NewObject\MyVar\Tor{\operatorname{Tor}} Now the ability to easily print indices via the options key will come in handy: \begin{LTXexample} $\Hom[\vA]{\vM,\vN}$, $\Ext[\vA]{\vM,\vN}$ \end{LTXexample} -\setupclass{var}{ +\SetupClass\MyVar{ valuekeys={ {shift}{ return,symbolputright={ \relax [ {#1} ] } }, % \relax is necessary since otherwise [...] can @@ -1128,7 +1253,7 @@ valuekeys={ } 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{var}{ +\SetupClass\MyVar{ valuekeys={ {shift}{ return,symbolputright={ \relax [ {#1} ] } }, % \relax is necessary since otherwise [...] can @@ -1140,6 +1265,14 @@ Let us see that it works: \begin{LTXexample} $\vX\mapsto\vX[shift=\vn]$ \end{LTXexample} +Finally, let us define a command for the differential (in the homolgoical algebra sense): +\begin{lstlisting} +\NewObject\MyVar\dif{d}[nopar] +\end{lstlisting}% +\NewObject\MyVar\dif{d}[nopar]% +\begin{LTXexample} +$\dif{\vx} = 0$ +\end{LTXexample} \section{The keys \texttt{i = index} and \texttt{d = deg = degree}} @@ -1148,7 +1281,7 @@ 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). You can adjust this by writing -\lstinline!gradingpos=upper! or~\lstinline!gradingpos=lower!. +\lstinline!gradingposition=upper! or~\lstinline!gradingposition=lower!. We already learned about the keys \lstinline!upper! and~\lstinline!lower!. @@ -1167,29 +1300,29 @@ $\Hom[index=\vA,degree=0]$, $\ho[index=\vDelta,degree=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 heave to write in the long run, so both keys have abbreviated equivalents: +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} + \lstinline!d! = \lstinline!deg! = \lstinline!degree! \end{center} Let us see them in action: \begingroup\begin{LTXexample} $ \vX[d=3,i=\vk] $ -\setupobject\vX{ - gradingpos=lower +\SetupObject\vX{ + gradingposition=lower } $ \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 (We haven't seen the command \lstinline!\SetupObject! before, but I imagine you can guess what it does). If you want to print a bullet as the degree, there is the predefined key~\lstinline!*! for this: \begingroup\begin{LTXexample} $ \vX[*] $ -\setupobject\vX{ - gradingpos=lower +\SetupObject\vX{ + gradingposition=lower } $ \vX[*] $ @@ -1199,8 +1332,8 @@ I guess it is also time to reveal that the previously mentioned shorthand notati \begingroup\begin{LTXexample} $ \vX[1] $ -\setupobject\vX{ - gradingpos=lower +\SetupObject\vX{ + gradingposition=lower } $ \vX[1] $ @@ -1212,8 +1345,8 @@ $\ho[\vDelta,d=1]$ \end{LTXexample} -Note that the use of the short notations \lstinline!d! and~\lstinline!i! does not mean you cannot write e.g. \lstinline!\vx[d]! and~\lstinline!\vx[i]!. -In fact, this is not the case: +Note that the use of the short notations \lstinline!d! and~\lstinline!i! does not prevent you from writing \lstinline!\vx[d]! and~\lstinline!\vx[i]!. +This still works fine: \begin{LTXexample} $\vf[i]$, $\vf[i=]$, $\vf[d]$, $\vf[d=]$ @@ -1221,31 +1354,35 @@ $\vf[d]$, $\vf[d=]$ 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!novaluekeys!. +\lstinline!valuekeys! from \lstinline!singlekeys!. -\section{The \texttt{cohomology} class type} +\section{The \texorpdfstring{\texttt{Cohomology}}{Cohomology} class type} Now homological algebra is hard unless we can do \emph{cohomology} and \emph{homology}. In principle, this is not hard to do, as we can write e.g.~\lstinline!\vH[d=0]{\vX}! to get~\( \vH[d=0]{\vX} \). However, some people might find it cumbersome to have to write~\lstinline!d=! every time you want to print an index. This is probably the right time to reveal that \semantex supports multiple class \emph{types}. -So far, we have been exclusively using the \lstinline!variable! -class type, but there are several others. -The first one we shall need is the \lstinline!cohomology! class type, which has a different input syntax that fits cohomology. +So far, we have been exclusively using the \lstinline!Variable! +class type, which is what you create when you apply the command~\lstinline!\NewVariableClass!. +The first other class type we shall need is the \lstinline!Cohomology! class type, which has a different input syntax that fits cohomology. Let us try to use it: \begin{lstlisting} -\newcohomologyclass{cohomology}[parent=var,gradingpos=upper] +\NewCohomologyClass\MyCohomology[ + parent=\MyVar,gradingposition=upper +] -\newcohomology\co{H} +\NewObject\MyCohomology\co{H} -\newcohomologyclass{homology}[parent=cohomology,gradingpos=lower] +\NewCohomologyClass\MyHomology[ + parent=\MyCohomology,gradingposition=lower +] -\newhomology\ho{H} +\NewObject\MyHomology\ho{H} \end{lstlisting} The cohomology command~\lstinline!\co! in general works very much -like a command of variable type. However, the input syntax is a bit different: +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: \begin{LTXexample} @@ -1268,16 +1405,16 @@ Of course, you can define similar commands for cocycles, coboundaries, and all s You might also want to implement feature like reduced cohomology, \v{C}ech cohomology, and hypercohomology. This is quite easy with the \lstinline!command! key: \begin{lstlisting} -\setupclass{var}{ - novaluekeys={ +\SetupClass\MyVar{ + singlekeys={ {reduced}{command=\widetilde}, {cech}{command=\noexpand\check}, {hyper{command=\noexpand\mathbb}, }, } \end{lstlisting} -\setupclass{var}{ - novaluekeys={ +\SetupClass\MyVar{ + singlekeys={ {reduced}{command=\widetilde}, {cech}{command=\noexpand\check}, {hyper}{command=\noexpand\mathbb}, @@ -1290,14 +1427,14 @@ $\co[cech]{*}$, $\co[hyper,cech]{0}{\vX}$ \end{LTXexample} -The cohomology class also provides a nice way +The \lstinline!Cohomology! class type also provides a nice way to implement derived functors: \begin{lstlisting} -\newcohomology\Lder{\mathbb{L}}[nopar] -\newcohomology\Rder{\mathbb{R}}[nopar] +\NewObject\MyCohomology\Lder{\mathbb{L}}[nopar] +\NewObject\MyCohomology\Rder{\mathbb{R}}[nopar] \end{lstlisting} -\newcohomology\Lder{\mathbb{L}}[nopar] -\newcohomology\Rder{\mathbb{R}}[nopar] +\NewObject\MyCohomology\Lder{\mathbb{L}}[nopar] +\NewObject\MyCohomology\Rder{\mathbb{R}}[nopar] For instance, we can write \begin{LTXexample} $\Lder{\vi}{\vf}$, @@ -1308,7 +1445,7 @@ Alternatively, the user might prefer to use keyval syntax on the level of the function itself (\( \vf \)~in this case). This can be done the following way: \begin{lstlisting} -\setupclass{var}{ +\SetupClass\MyVar{ valuekeys={ {Lder} { innerreturn,leftreturn, @@ -1319,7 +1456,7 @@ This can be done the following way: symbolputleft=\noexpand\mathbb{R}^{#1}, }, }, - novaluekeys={ + singlekeys={ {Lder} { innerreturn,leftreturn, symbolputleft=\noexpand\mathbb{L}, @@ -1331,7 +1468,7 @@ This can be done the following way: }, } \end{lstlisting} -\setupclass{var}{ +\SetupClass\MyVar{ valuekeys={ {Lder} { innerreturn,leftreturn, @@ -1342,7 +1479,7 @@ This can be done the following way: symbolputleft=\noexpand\mathbb{R}^{#1}, }, }, - novaluekeys={ + singlekeys={ {Lder} { innerreturn,leftreturn, symbolputleft=\noexpand\mathbb{L}, @@ -1363,23 +1500,29 @@ $\Hom[Rder]{\vX,\vY}$ If you get tired of having to write \lstinline!\Hom[Rder]! all the time, you can create a shortcut: \begin{lstlisting} -\newvar\RHom[copy=\Hom,Rder] +\NewObject\MyVar\RHom[clone=\Hom,Rder] \end{lstlisting} -\newvar\RHom[copy=\Hom,Rder] -The \lstinline!copy! key is like the \lstinline!parent! key, +\NewObject\MyVar\RHom[clone=\Hom,Rder] +The \lstinline!clone! key is like the \lstinline!parent! key, except it allows you to inherit the settings from an \emph{object} rather than a \emph{class}. Notice that we did not specify a symbol; the symbol argument is optional, and in this case, it was unnecessary, as the symbol was inherited from~\lstinline!\Hom!. Let us see it in action: \begin{LTXexample} $\RHom{\vX,\vY}$ \end{LTXexample} -\section{Keyval syntax in arguments (Example: Cohomology with coefficients)} +\chapter{Keyval syntax in arguments (Example: Cohomology with coefficients)} -\setupclass{var}{ +\SetupClass\MyVar{ argvaluekeys={ - {coef}{ sep={;}{#1} }, + {coef}{ othersep={;}{#1} }, }, } +\SetupObject\co{ + valuekeys={ + {arg}{argwithkeyval={#1}}, + }, +}% + Imagine we want to do cohomology with coefficients in some ring~\( \vR \). It is common to write this as~\( \co{*}{\vX,coef=\vR} \) with a semicolon instead of a comma. This can be implemented, too, with the syntax @@ -1389,20 +1532,20 @@ $\co{*}{\vX,coef=\vR}$ This shows that arguments of functions also support keyval syntax. In order to customize this, there are two extra keys: \begin{center} -\lstinline!argnovaluekeys! +\lstinline!argsinglekeys! \qquad\qquad\text{and}\qquad\qquad \lstinline!argvaluekeys! \end{center} -These work exactly like \lstinline!novaluekeys! and~\lstinline!valuekeys!. +These work exactly like \lstinline!singlekeys! and~\lstinline!valuekeys!. \begin{lstlisting} -\setupclass{var}{ +\SetupClass\MyVar{ argvaluekeys={ - {coef}{ sep={;}{#1} }, + {coef}{ othersep={;}{#1} }, }, } \end{lstlisting} (But it will not quite work yet -- stay tuned for a moment!) -The key \lstinline!sep! is a key that controls the separator +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. @@ -1410,7 +1553,7 @@ However, even with the above setup, the notation \lstinline!\co{*}{\vX,coef=\vR} just yet. For the keys you define using \lstinline!argvaluekeys! are turned off by default. To turn them on for the object~\lstinline!\co!, run the following code: \begin{lstlisting} -\setupobject\co{ +\SetupObject\co{ valuekeys={ {arg}{argwithkeyval={#1}}, }, @@ -1420,15 +1563,15 @@ The reason the keys are turned off by default is that keys in arguments that sup every occurrence of an equality sign in arguments, and the following would not work: \begin{LTXexample} -$\Hom[\sheafO[\vU]]{ +$\Hom[\sheafreg[\vU]]{ \sheafF[res=\vU], \sheafG[res=\vU] }$ \end{LTXexample} It should be noted that there are several predefined -keys (of type \mbox{\lstinline!novaluekey!)} which are defined on the level -of the class \lstinline!semantexvariable!. The full list is:\fxfatal{Finish this} +keys (of type \mbox{\lstinline!singlekey!)} which are defined on the level +of the class \lstinline!\SemantexVariable!. The full list is:\fxfatal{Finish this} \begin{itemize} \item slot, \ldots @@ -1436,41 +1579,68 @@ of the class \lstinline!semantexvariable!. The full list is:\fxfatal{Finish this We should also talk about the \lstinline!arg! key. -\section{The \texttt{binary} class type (Example: Derived tensor products and fibre products)} +\chapter{Multi-value keys} + +\SetupClass\MyVar{ + 2valuekeys={ + {projquotient}{ symbolputright={ /\!\!/ _ { #1 } #2 } }, + } +} -\newbinaryclass{binaryoperator}[ - novaluekeys={ +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 } }, + } +} +\end{lstlisting} + +\begin{LTXexample} +$\vX[projquotient={\vchi}{\vG}] $ +\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 \texttt{Simple} class type (Example: Derived tensor products and fibre products)} + +\NewSimpleClass\MyBinaryOperator[ + singlekeys={ {Lder}{upper=L}, {Rder}{upper=R}, }, mathbin, % this makes sure that the output is wrapped in \mathbin ] -\newbinaryoperator\tens{\otimes}[ - novaluekeys={ +\NewObject\MyBinaryOperator\tensor{\otimes}[ + singlekeys={ {der}{Lder}, }, ] -\newbinaryoperator\fibre{\times}[ +\NewObject\MyBinaryOperator\fibre{\times}[ % Americans are free to call it \fiber instead - novaluekeys={ + singlekeys={ {der}{Rder}, }, ] -The \semantex system has facilities for printing tensor products~\( \tens \) as well as derived tensor products~\( \tens[der] \). -For this, we need the \lstinline!binary! 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 +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. +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} -\command[options] +\⟨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.) Let us try to use it to define tensor products and fibre products: \begin{lstlisting} -\newbinaryclass{binaryoperator}[ - novaluekeys={ +\NewSimpleClass\MyBinaryOperator[ + singlekeys={ {Lder}{upper=L}, {Rder}{upper=R}, }, @@ -1478,64 +1648,34 @@ Let us try to use it to define tensor products and fibre products: % this makes sure that the output is wrapped in \mathbin ] -\newbinaryoperator\tens{\otimes}[ - novaluekeys={ +\NewObject\MyBinaryOperator\tensor{\otimes}[ + singlekeys={ {der}{Lder}, }, ] -\newbinaryoperator\fibre{\times}[ +\NewObject\MyBinaryOperator\fibre{\times}[ % Americans are free to call it \fiber instead - novaluekeys={ + singlekeys={ {der}{Rder}, }, ] \end{lstlisting} As you see, this is one of the few cases where I recommend adding keyval -syntax on the level of subclasses. Also, notice that it does not have any~\lstinline!parent=var!, as I do not really see any reason to inherit all the keyval syntax from the \lstinline!var!~class. -Now we first define keys \lstinline!Lder! and~\lstinline!Rder! for left and right derived binary operators. Next, we build in a shortcut in both \lstinline!\tens! and~\lstinline!\fibre! +syntax to other classes than your superclass~\lstinline!\MyVar!. Also, notice that it does not have any~\lstinline!parent=\MyVar!, as I do not really see any reason to inherit all the keyval syntax from the \lstinline!\MyVar!~class. +Now we first define keys \lstinline!Lder! and~\lstinline!Rder! for left and right derived binary operators. Next, we build in a shortcut in both \lstinline!\tensor! and~\lstinline!\fibre! so that we can write simply~\lstinline!der! and get the correct notion of derived functor. Let us see it in action: \begin{LTXexample} -$\vA \tens \vB$, -$\vX[*] \tens[\vR] \vY[*]$ -$\vk \tens[\vA,der] \vk$, +$\vA \tensor \vB$, +$\vX[*] \tensor[\vR] \vY[*]$ +$\vk \tensor[\vA,der] \vk$, $\vX \fibre[\vY,der] \vX$ \end{LTXexample} -\chapter{The \texorpdfstring{\texttt{$\backslash$⟨classname⟩}}{classname} 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 -want to write expressions like -\[ - \var{\vf\circ\vg}[spar,der=\vn]{\vx}. -\] -We do not want to have to define a new variable -with symbol~\( \vf\circ\vg \) in order to write something like this. -Fortunately, once you have created the class~\lstinline!var!, -you get an extra command~\lstinline!\var! that has the following syntax -\begin{lstlisting} -\var{symbol}[options]{argument} -\end{lstlisting} -In other words, it allows you to create a variable on the spot and give in an arbitrary symbol. So the above equation can be written -\begin{LTXexample} -$\var{\vf\circ\vg}[ - spar,der=\vn]{\vx}$ -\end{LTXexample} -More generally, whenever you create a class with name \lstinline!⟨classname⟩!, you automatically get a command -named~\lstinline!\⟨classname⟩!. -It has the same input syntax as the class in question, -except that, as above, the first argument is the symbol: -\begin{lstlisting} -\⟨classname⟩{symbol}⟨usual syntax of class⟩ -\end{lstlisting} - -Actually, now might be the right time to reveal that the low-level machinery in \semantex does not actually see the difference between an object and a class. Yep, this is how it has been implemented, and there are probably some object-oriented purists who will say that this goes against some general programming philosophy nonsense. So when you create the class \lstinline!⟨classname⟩!, you really create the above object which has a special syntax. And now all other objects of that class simply inherit from this object. (As we saw from above, you can actually inherit from any object; you just write~\lstinline!copy=\objectname! instead of using \lstinline!parent!.) - \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 section, we were introduced to the \lstinline!cohomology! and the \lstinline!binary! 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}. @@ -1547,84 +1687,84 @@ The current implementation has the following class types: \begin{itemize} - \item \lstinline!variable!: + \item \lstinline!Variable!: A new class is declared with the syntax \begin{lstlisting} - \newvariableclass{⟨classname⟩}[options] + \NewVariableClass{\⟨Class⟩}[⟨options⟩] \end{lstlisting} A new object is declared by \begin{lstlisting} - \new⟨classname⟩\⟨objectname⟩{symbol}[options] + \NewObject\⟨Class⟩\⟨object⟩{⟨symbol⟩}[⟨options⟩] \end{lstlisting} The syntax for this object is \begin{lstlisting} - \⟨objectname⟩[options]{argument} + \⟨object⟩[⟨options⟩]{⟨argument⟩} \end{lstlisting} - \item \lstinline!cohomology!: + \item \lstinline!Cohomology!: A new class is declared with the syntax \begin{lstlisting} - \newcohomologyclassclass{⟨classname⟩}[options] + \NewCohomologyClass\⟨Class⟩[⟨options⟩] \end{lstlisting} A new object is declared by \begin{lstlisting} - \new⟨classname⟩\⟨objectname⟩{symbol}[options] + \NewObject\⟨Class⟩\⟨object⟩{⟨symbol⟩}[⟨options⟩] \end{lstlisting} The syntax for this object is \begin{lstlisting} - \⟨objectname⟩[options]{degree}{argument} + \⟨object⟩[⟨options⟩]{⟨degree⟩}{⟨argument⟩} \end{lstlisting} - \item \lstinline!binary!: + \item \lstinline!Simple!: A new class is declared with the syntax \begin{lstlisting} - \newdelimiterclass{⟨classname⟩}[options] + \NewSimpleClass\⟨Class⟩[⟨options⟩] \end{lstlisting} A new object is declared by \begin{lstlisting} - \new⟨classname⟩\⟨objectname⟩{left bracket}{right bracket}[options] + \NewObject\⟨Class⟩\⟨object⟩{⟨symbol⟩}[⟨options⟩] \end{lstlisting} The syntax for this object is \begin{lstlisting} - \⟨objectname⟩[options]{argument} + \⟨object⟩[⟨options⟩]{⟨argument⟩} \end{lstlisting} - \item \lstinline!delimiter!: + \item \lstinline!Delimiter!: A new class is declared with the syntax \begin{lstlisting} - \newtupleclass{⟨classname⟩}[options] + \NewDelimiterClass\⟨Class⟩[⟨options⟩] \end{lstlisting} A new object is declared by \begin{lstlisting} - \new⟨classname⟩\⟨objectname⟩{left bracket}{right bracket}[options] + \NewObject\⟨Class⟩\⟨object⟩{⟨left bracket⟩}{⟨right bracket⟩}[⟨options⟩] \end{lstlisting} The syntax for this object is \begin{lstlisting} - \⟨objectname⟩[options]{argument} + \⟨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. +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. -\chapter{The \texorpdfstring{\texttt{delimiter}}{delimiter} class type} +\chapter{The \texorpdfstring{\texttt{Delimiter}}{Delimiter} class type} -\newdelimiterclass{delim}[parent=var] -\newdelim\norm{\lVert}{\rVert} -\newdelim\inner{\langle}{\rangle} +\NewDelimiterClass\MyDelim[parent=\MyVar] +\NewObject\MyDelim\norm{\lVert}{\rVert} +\NewObject\MyDelim\inner{\langle}{\rangle} Delimiters are what they sound like: functions like \( \norm{slot} \) and~\( \inner{slot,slot} \) -that are defined using brackets only. Let us define a class of type delimiter: +that are defined using brackets only. Let us define a class of type \lstinline!Delimiter!: \begin{lstlisting} -\newdelimiterclass{delim}[parent=var] +\NewDelimiterClass\MyDelim[parent=\MyVar] \end{lstlisting} -Now we get a command \lstinline!\newdelim! with the following syntax: +Now we can create instances of the class~\lstinline!\MyDelim! with the following syntax: \begin{lstlisting} -\newdelim\⟨objectname⟩{left bracket}{right bracket}[options] +\NewObject\MyDelim\⟨object⟩{⟨left bracket⟩}{⟨right bracket⟩}[⟨options⟩ \end{lstlisting} Now we can do the following: \begin{lstlisting} -\newdelim\norm{\lVert}{\rVert} -\newdelim\inner{\langle}{\rangle} +\NewObject\MyDelim\norm{\lVert}{\rVert} +\NewObject\MyDelim\inner{\langle}{\rangle} \end{lstlisting} Indeed: \begin{LTXexample} @@ -1633,16 +1773,17 @@ $\inner{\va,\vb}$, $\inner{slot,slot}$ \end{LTXexample} We can also use it for more complicated constructions, like sets. +The following is inspired from the \pack{mathtools} package where a similar construction is created using the commands from that package. My impression is that Lars Madsen is the main mastermind behind the code I use for the \lstinline!\where!~command: \begin{lstlisting} \newcommand\where{ \nonscript\: - \semantexdelimsize\vert + \SemantexDelimiterSize\vert \allowbreak \nonscript\: \mathopen{} } -\newdelim\Set{\lbrace}{\rbrace}[ +\NewObject\MyDelim\Set{\lbrace}{\rbrace}[ prearg={\,},postarg={\,}, % adds \, inside {...}, as recommended by D. Knuth valuekeys={ @@ -1653,13 +1794,13 @@ We can also use it for more complicated constructions, like sets. \end{lstlisting} \newcommand\where{ \nonscript\: - \semantexdelimsize\vert + \SemantexDelimiterSize\vert \allowbreak \nonscript\: \mathopen{} } -\newdelim\Set{\lbrace}{\rbrace}[ +\NewObject\MyDelim\Set{\lbrace}{\rbrace}[ prearg={\,},postarg={\,}, % adds \, inside {...}, as recommended by D. Knuth valuekeys={ @@ -1685,16 +1826,18 @@ $\Set{ Tuple-like commands are also possible: \begin{lstlisting} -\newdelim\tup{(}{)} % tuples -\newdelim\pcoor{[}{]}[ % projective coordinates - argsep=\mathpunct{:}, % changes the argument separator to : - argdots=\cdots, % changes what is inserted if you write "..." +\NewObject\MyDelim\tup{(}{)} % tuples +\NewObject\MyDelim\pcoor{[}{]}[ % projective coordinates + setargsep=\mathpunct{:}, + % changes the argument separator to colon + setargdots=\cdots, + % changes what is inserted if you write "..." ] \end{lstlisting} -\newdelim\tup{(}{)} % tuples -\newdelim\pcoor{[}{]}[ % projective coordinates - argsep=\mathpunct{:}, % changes the argument separator to : - argdots=\cdots, % changes what is inserted if you write "..." +\NewObject\MyDelim\tup{(}{)} % tuples +\NewObject\MyDelim\pcoor{[}{]}[ % projective coordinates + setargsep=\mathpunct{:}, % changes the argument separator to : + setargdots=\cdots, % changes what is inserted if you write "..." ] Let us see them in action: \begin{LTXexample} @@ -1704,178 +1847,381 @@ $\pcoor{\va,\vb,...,\vz}$ One can also use tuples for other, less obvious purposes, like calculus differentials: \begin{lstlisting} -\newdelimiterclass{calculusdifferential}[ - parent=var, +\NewDelimiterClass\CalculusDifferential[ + parent=\MyVar, argvaluekeys={ - {default}{standardsep={d\!#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 + % is a key that prints the value of the key with the + % standard argument separator in front. }, - argdots=\cdots, - ifpar=false, + setargdots=\cdots, + neverpar, + % neverpar is like nopar, except nopar will still print + % parentheses when there is more than one argument + % -- neverpar does not even print parentheses in this case ] -\newcalculusdifferential\intD{(}{)}[argsep={\,},iffirstarg=false] +\NewObject\CalculusDifferential\intD{(}{)}[setargsep={\,},iffirstarg=false] -\newcalculusdifferential\wedgeD{(}{)}[argsep=\wedge] +\NewObject\CalculusDifferential\wedgeD{(}{)}[setargsep=\wedge] \end{lstlisting} -\newdelimiterclass{calculusdifferential}[ - parent=var, +\NewDelimiterClass\CalculusDifferential[ + parent=\MyVar, argvaluekeys={ - {default}{standardsep={d\!#1}}, + {default}{s={d\!#1}}, }, - argdots=\cdots, - ifpar=false, + setargdots=\cdots, + neverpar, + % neverpar is like nopar, except nopar will still print + % parentheses when there is more than one argument + % -- neverpar does not even print parentheses in this case ] -\newcalculusdifferential\intD{(}{)}[argsep={\,},iffirstarg=false] +\NewObject\CalculusDifferential\intD{(}{)}[setargsep={\,},ifnextargwithsep=false] -\newcalculusdifferential\wedgeD{(}{)}[argsep=\wedge] +\NewObject\CalculusDifferential\wedgeD{(}{)}[setargsep=\wedge] \begin{LTXexample} -$\int \vf \intD{\vx[1],\vx[2],...,\vx[n]}$, +$\int \vf \intD{\vx[1], + \vx[2],...,\vx[n]}$, -$\int \vf \wedgeD{\vx[1],\vx[2],...,\vx[n]}$ +$\int \vf \wedgeD{\vx[1], + \vx[2],...,\vx[n]}$ \end{LTXexample} -\chapter{The \texttt{execute} and \texttt{parseoptions} keys} +\chapter{The \texttt{parse} routine} -As you can see above, \semantex has a ``waterfall-like'' behaviour. It parses 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!execute! and \lstinline!parseoptions!~keys. +As you can see above, \semantex has a ``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. -\newvar\Mat{\operatorname{Mat}}[ + + +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% +\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} \)? +Therefore, we do something like the following instead (we explain the notation below): +\begin{lstlisting} +\NewObject\MyVar\Mat{\operatorname{Mat}}[ execute={ - \semantexdataprovide{rows} - \semantexdataprovide{columns} + \SemantexDataProvide{rows} + \SemantexDataProvide{columns} + % provides data sets for number of rows and columns + % for this object }, valuekeys={ {rows}{ execute={ - \semantexdataset{rows}{#1} + \SemantexDataSet{rows}{#1} }, }, {columns}{ execute={ - \semantexdataset{columns}{#1} + \SemantexDataSet{columns}{#1} }, }, }, parseoptions={ execute={ - \semantexstrifeq{\semantexdatagetexpnot{columns}}{\semantexdatagetexpnot{rows}} + \SemantexStrIfEqTF{\SemantexDataGetExpNot{columns}} + {\SemantexDataGetExpNot{rows}} + % tests if rows = columns { - \semantexsetkeysx{ + \SemantexKeysSetx{ lower={ - \semantexdatagetexpnot{columns} + \SemantexDataGetExpNot{columns} } } } { - \semantexsetkeysx{ + \SemantexKeysSetx{ lower={ - \semantexdatagetexpnot{rows} + \SemantexDataGetExpNot{rows} \times - \semantexdatagetexpnot{columns} + \SemantexDataGetExpNot{columns} } } } }, }, ] - -Suppose we want to be able to write the set of \( \vn \times \vm \)-matrices with entries in~\( \vk \) as~\( \Mat[rows=\vn,columns=\vm]{\vk} \). We can in principle do the following: -\begin{LTXexample} -$ \Mat[\vn\times\vm]{\vk} $. -\end{LTXexample} -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~\( \Mat[\vn,\vm]{\vk} \)? -Therefore, we do something like the following instead (we explain the notation below): -\begin{lstlisting} -\newvar\Mat{\operatorname{Mat}}[ +\end{lstlisting}% +\NewObject\MyVar\Mat{\operatorname{Mat}}[ execute={ - \semantexdataprovide{rows} - \semantexdataprovide{columns} - % provides data sets for number of rows and columns - % for this object + \SemantexDataProvide{rows} + \SemantexDataProvide{columns} }, valuekeys={ {rows}{ execute={ - \semantexdataset{rows}{#1} + \SemantexDataSet{rows}{#1} }, }, {columns}{ execute={ - \semantexdataset{columns}{#1} + \SemantexDataSet{columns}{#1} }, }, }, parseoptions={ execute={ - \semantexstrifeq{\semantexdatagetexpnot{columns}} - {\semantexdatagetexpnot{rows}} - % tests if rows = columns + \SemantexStrIfEqTF{\SemantexDataGetExpNot{columns}}{\SemantexDataGetExpNot{rows}} { - \semantexsetkeysx{ + \SemantexKeysSetx{ lower={ - \semantexdatagetexpnot{columns} + \SemantexDataGetExpNot{columns} } } } { - \semantexsetkeysx{ + \SemantexKeysSetx{ lower={ - \semantexdatagetexpnot{rows} + \SemantexDataGetExpNot{rows} \times - \semantexdatagetexpnot{colums} + \SemantexDataGetExpNot{columns} } } } }, }, -] -\end{lstlisting} +]% Now we can do the following: \begin{LTXexample} $ \Mat[rows=\vn,columns=\vm]{\vk} $, $ \Mat[rows=\vn,columns=\vn]{\vk} $ \end{LTXexample} -The key~\lstinline!execute! is a key that basically just executes code. You can in principle write any \TeX\ code there, and it will be applied right at the spot. However, inside the \lstinline!execute!~key, you can also use the following locally defined commands. These can be used to handle the data that is associated with the object in question: +The key~\lstinline!execute! is a key that basically just executes code. You can in principle write any \TeX\ code there, and it will be applied right at the spot. However, inside the \lstinline!execute!~key, you can also use the following locally defined commands. These can be used to handle the data that is associated with the object in question. I don't have time to document them right now, so you'll have to guess what they do from the name for now, or you can find their definition in the source code of the package. \begin{lstlisting} -\semantexdataprovide{name} % provides a data set with this name -\semantexdataset{name}{value} % sets the data set -\semantexdatasetx{name}{value} % sets the data set, but fully expands the argument -\semantexdataputright{name}{value} % adds something to the right of the data set -\semantexdataputrightx{name}{value} % the same, but fully expands first -\semantexdataputleft{name}{value} % adds something to the left of the data set -\semantexdataputleftx{name}{value} % the same, but fully expands first -\semantexdataget{name}{value} % outputs the data set -\semantexdatagetexpnot{name}{value} % outputs the data set wrapped in a \noexpand -\semantexdataclear{name} % clears the data set -\semantexsetkeys{keys} % sets keys -\semantexsetkeysx{keys} % sets keys after expanding -\semantexstrifeq{str1}{str2}{if true}{if false} % tests if str1 = str2 -\semantexboolprovide{name} % provides a boolean -\semantexboolsettrue{name} % sets the boolean to true -\semantexboolsetfalse{name} % sets the boolean to false -\semantexboolif{name}{if true}{if false} % tests the boolean +\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 +\SemantexIntIfPositiveTF +\SemantexIntIfPositiveT +\SemantexIntIfPositiveF +\SemantexIntIfGreaterThanOneTF +\SemantexIntIfGreaterThanOneT +\SemantexIntIfGreaterThanOneF +\SemantexExpNot \end{lstlisting} -The key~\lstinline!parseoptions! is a key that is executed right before rendering the object. This is where you write whatever the system is supposed to \emph{do} with the data sets you provide. +The key~\lstinline!parseoptions! is a key that is executed right before rendering the object. This is where you write whatever the system is supposed to \emph{do} with the data sets you provide. You can also force it to be applied at any point by using the \lstinline!parse!~key. -\chapter{Bugs} +Let us look at a more complicated example: Let us create a command for partial derivatives: + +\NewObject\MyVar\partialdif[ + nopar, + execute={ + \SemantexBoolProvide{raisedfunction} + \SemantexBoolSetTrue{raisedfunction} + }, + setidots=\cdots, + setisep=\,, + valuekeys={ + {default}{ + si={\partial #1}, + }, + }, + singlekeys={ + {raisedfunction}{ + execute={ + \SemantexBoolSetTrue{raisedfunction} + }, + }, + {noraisedfunction}{ + execute={ + \SemantexBoolSetFalse{raisedfunction} + }, + }, + }, + parseoptions={ + execute={ + \SemantexIfBlankTF{ \SemantexDataGet{upper} } + { + \SemantexKeysSetx{ + symbol={ + \frac + { + \partial ^ { \SemantexIntGet{numberoflowerindices} } + \SemantexBoolIfT{raisedfunction} + { + \SemantexDataGetExpNot{arg} + } + } + { + \SemantexDataGetExpNot{lower} + } + }, + } + } + { + \SemantexKeysSetx{ + symbol={ + \frac + { + \partial ^ { \SemantexDataGet{upper} } + \SemantexBoolIfT{raisedfunction} + { + \SemantexDataGetExpNot{arg} + } + } + { + \SemantexDataGetExpNot{lower} + } + }, + } + } + \SemantexDataClear{lower} + \SemantexDataClear{upper} + \SemantexBoolIfT{raisedfunction} + { + \SemantexDataClear{arg} + \SemantexIntClear{numberofarguments} + } + }, + }, +] -The most important current (known) bug happens if you create a variable whose symbol is a mathematical operator. For instance, write \begin{lstlisting} -\newvar\Int{\int} +\NewObject\MyVar\partialdif[ + nopar, + execute={ + \SemantexBoolProvide{raisedfunction} + \SemantexBoolSetTrue{raisedfunction} + }, + setidots=\cdots, + setisep=\,, + valuekeys={ + {default}{ + si={\partial #1}, + }, + }, + singlekeys={ + {raisedfunction}{ + execute={ + \SemantexBoolSetTrue{raisedfunction} + }, + }, + {noraisedfunction}{ + execute={ + \SemantexBoolSetFalse{raisedfunction} + }, + }, + }, + parseoptions={ + execute={ + \SemantexIfBlankTF{ \SemantexDataGet{upper} } + { + \SemantexKeysSetx{ + symbol={ + \frac + { + \partial ^ { \SemantexIntGet{numberoflowerindices} } + \SemantexBoolIfT{raisedfunction} + { + \SemantexDataGetExpNot{arg} + } + } + { + \SemantexDataGetExpNot{lower} + } + }, + } + } + { + \SemantexKeysSetx{ + symbol={ + \frac + { + \partial ^ { \SemantexDataGet{upper} } + \SemantexBoolIfT{raisedfunction} + { + \SemantexDataGetExpNot{arg} + } + } + { + \SemantexDataGetExpNot{lower} + } + }, + } + } + \SemantexDataClear{lower} + \SemantexDataClear{upper} + \SemantexBoolIfT{raisedfunction} + { + \SemantexDataClear{arg} + \SemantexIntClear{numberofarguments} + } + }, + }, +] \end{lstlisting} -\newvar\Int{\int} - +Let us see it in action: \begin{LTXexample} -$\int$ \\ -$\Int$ \\ -See the difference: \rlap{$\int$}$\Int$ +\[ + \partialdif[\vx,\vy,\vz]{ + \vf } , + \partialdif[\vu^2,\vv^2, + d=4]{ \vf }, + \partialdif[\vx[1], + \vx[2],...,\vx[\vn], + d=\vn]{ \vf } +\] +\[ + \partialdif[\vx,\vy,\vz,noraisedfunction]{ \vf } , + \partialdif[\vu^2,\vv^2, + d=4,noraisedfunction]{ + \vf }, + \partialdif[\vx[1], + \vx[2],...,\vx[\vn], + d=\vn,noraisedfunction]{ + \vf } +\] \end{LTXexample} -It turns out to be equivalent to the difference between -\lstinline!$\int$! and~\lstinline!${}\int$!. In other words, this~\lstinline!{}! -affects the spacing a tiny bit. -I more or less know where this bug appears, but cannot really solve it without breaking the expansion somewhere else. Suggestions and advice are more than welcome! Then again, even if it affects the spacing a little bit, it still looks fine, only a bit different. +As you see, we use the \lstinline!d!~key to tell the command what superscript it should put on the~\( \partial \) in the enumerator. If it does not receive a~\lstinline!d!, it counts the number of variables you wrote and prints that. That is why the following would give the wrong result: +\begin{LTXexample} +\[ + \partialdif[\vu^2,\vv^2]{ + \vf }, + \partialdif[\vx[1], + \vx[2],...,\vx[\vn]]{ + \vf } +\] +\end{LTXexample} + +\chapter{Bugs} + +Lots of things can be improved in the system, including the order in which things are being expanded internally. I am not going to explain this is detail for now, but hope to correct this in the future. For now, the system seems to work fine as long as you do \enquote{normal} things and insert~\lstinline!\noexpand!'s whenever something goes wrong. The only real bug that I currently know of occurs if you use the key~\lstinline!Othersep! 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? %\input{testground} diff --git a/Master/texmf-dist/tex/latex/semantex/semantex.sty b/Master/texmf-dist/tex/latex/semantex/semantex.sty index 8e8361c8dc7..3ed17fb64ae 100644 --- a/Master/texmf-dist/tex/latex/semantex/semantex.sty +++ b/Master/texmf-dist/tex/latex/semantex/semantex.sty @@ -1,98 +1,118 @@ \RequirePackage{expl3,xparse} -\ProvidesExplPackage{semantex}{2020/05/30}{0.1alpha}{} -% IMPORTANT: +\ProvidesExplPackage{semantex}{2020/07/06}{0.2alpha}{} -% Because of the definition of \semantexnormalscaling, the package now requires amsmath +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% ERROR MESSAGES +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Think about changing “upper” etc. into “supper”, whereas what is now -% “upper” could be called “uppernosep” or something similar. -% Fix left sub- and superscripts, e.g. the right spacing +\msg_new:nnnn { semantex } { valuekey_not_found } { Unknown~key~#2~passed~to~#1~on~line~\msg_line_number: } {} -% Allow “.” (nothing) as delimiter, even in the case of normal or \big etc +\msg_new:nnnn { semantex } { arg_valuekey_not_found } { Unknown~argument~key~#2~passed~to~#1~on~line~\msg_line_number: } {} -% Instead of checking if you are equal to semantexvarible when doing -% inheritance, check if you are your own parent. This allows multiple -% “primitive” classes. -% Also remove commands like \newsemantexvariable etc. -% in order to force people to create their own classes +\msg_new:nnnn { semantex } { data_tl_not_found } { Unknown~data~#2~requested~from~#1~on~line~\msg_line_number: } {} -% Create 2valuekeys, 3valuekeys etc. +\msg_new:nnnn { semantex } { data_int_not_found } { Unknown~integer~#2~requested~from~#1~on~line~\msg_line_number: } {} -% Test if \exp_not:n can be removed in #1 (=\keyvalue) if -% another \exp_not:n is added in the data manipulation commands. +\msg_new:nnnn { semantex } { data_bool_not_found } { Unknown~boolean~#2~requested~from~#1~on~line~\msg_line_number: } {} -% Build groups and \ext_args:NV around the definition of -% \l_semantex_key_value_temp in order to only -% define this command locally. +\msg_new:nnnn { semantex } { data_cs_not_found } { Unknown~command~sequence~#2~requested~from~#1~on~line~\msg_line_number: } {} -% Allow two keys, nopar and absolutelynopar. The difference is that -% nopar becomes par if there is more than one argument +\msg_new:nnnn { semantex } { data_prop_not_found } { Unknown~property~list~#2~requested~from~#1~on~line~\msg_line_number: } {} -% Allow left arguments! +\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: } {} -% LIST OF BUGS: +\msg_new:nnnn { semantex } { object_already_defined } { Object~#1~already~defined;~you~tried~defining~it~again~on~line~\msg_line_number: } {} -%IM A change has been made in catlimits. It shows the existence of a -%IM kind of bug in semantex +\msg_new:nnnn { semantex } { class_not_found } { Unknown~class~#3~declared~as~#2~of~#1~on~line~\msg_line_number: } {} -%IM Removed \!\!\!\! in catlimits +\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~object~#2~on~line~\msg_line_number: } {} -\msg_new:nnnn { semantex } { keyval_not_found } { Unknown~key~#1~passed~to~object~#2~on~input~line~\msg_line_number: } {} +\msg_new:nnnn { semantex } { created_a_SemantexVariable } { Never~create~objects~of~class~\SemantexVariable;~create~a~new~class~yourself~instead.~You~created~the~object~#1~on~line~\msg_line_number: } {} -\msg_new:nnnn { semantex } { arg_valuekey_not_found } { Unknown~argument~key~#1~passed~to~object~#2~on~input~line~\msg_line_number: } {} +\cs_generate_variant:Nn \msg_error:nnnn { nnnx } -\msg_new:nnnn { semantex } { tl_not_found } { Unknown~data~#1~passed~to~object~#2~on~input~line~\msg_line_number: } {} -%IM should be changed so that this is passed to the actual object, not -%IM the parent object, e.g., by having a third argument containing the -%IM actual object in \g_semantex_data_tl_get:nn +\tl_new:N\l__semantex_error_output_format_temp +\cs_new: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 +} -\msg_new:nnnn { semantex } { parent_not_found } { Unknown~class~#1~set~as~parent~of~object~#2~on~input~line~\msg_line_number: } {} +\cs_generate_variant:Nn \msg_error:nnnnn { nnxnn } -\msg_new:nnnn { semantex } { data_tl_not_found } { Unknown~data~#1~passed~to~object~#2~on~input~line~\msg_line_number: } {} +\cs_generate_variant:Nn \msg_error:nnnn { nnxn } -% Extra cs variants we need: +\cs_generate_variant:Nn \msg_error:nnn { nnx } + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% COMMANDS FOR BULLETS AND SLOTS +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\cs_generate_variant:Nn \keyval_parse:NNn { cco } -\cs_generate_variant:Nn \tl_if_blank:nTF { vTF } -\tl_set:Nn \semantexbullet {\raisebox{-0.25ex}{\scalebox{1.2}{$\cdot$}}} -\tl_set:Nn \semantexdoublebullet {\semantexbullet\semantexbullet} +\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 +{ + \box_move_up:nn{-0.25ex}{\box_use:N \l__semantex_bullet_box} +} -\tl_set:Nn \semantexslot { \mathord{-} } +\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 +\tl_set:Nn \g_semantex_slot { \mathord{-} } +\tl_set_eq:NN \SemantexSlot \g_semantex_slot -\DeclareDocumentCommand\newbinaryclass{mO{}} % new binary-type class +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% USER COMMANDS FOR CREATING NEW CLASSES +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +\DeclareDocumentCommand\semantex_new_simple_class:Nw{mO{}} % new simple-type class { % #1 = class name % #2 = options - \semantexnewclass { #1 } { #2 } - \exp_args:Nc\DeclareDocumentCommand{#1}{mo}{ + \semantex_new_class:Nn { #1 } { #2 } + \DeclareDocumentCommand{#1}{mo}{ % the actual \#1 command \IfValueTF{##2} { - \semantexrenderclass { #1 } { ifoutput=true, symbol = { ##1 }, ##2 } + \semantex_render_class:Nn #1 { ifoutput=true, symbol = { ##1 }, ##2 } } { - \semantexrenderclass { #1 } { symbol = { ##1 } } + \semantex_render_class:Nn #1 { symbol = { ##1 } } } } - \exp_args:Nc\DeclareDocumentCommand{#1withoptions}{mmo}{ + \exp_args:Nc\DeclareDocumentCommand{__semantex_make_object_of_class_\cs_to_str:N #1_with_options:nnw}{mmo}{ \IfValueTF{##3} { - \semantexrenderclass { #1 } { ifoutput=true, symbol = { ##2 }, ##1, ##3 } + \semantex_render_class:Nn #1 { ifoutput=true, symbol = { ##2 }, ##1, ##3 } } { - \semantexrenderclass { #1 } { symbol = { ##2 }, ##1 } + \semantex_render_class:Nn #1 { symbol = { ##2 }, ##1 } } } - \exp_args:Nc\DeclareDocumentCommand{new#1}{mgO{}} + \exp_args:Nc\DeclareDocumentCommand{__semantex_new_object_of_class_\cs_to_str:N #1:Nw}{mgO{}} { % the command for creating a new object of class #1 % ##1 = command name, with backslash @@ -100,75 +120,77 @@ % ##3 = options \IfValueTF{##2} { - \semantexnewobject { #1 } ##1 { parent = #1, symbol = { ##2 }, ##3 } + \semantex_new_object:NNn { #1 } ##1 { symbol = { ##2 }, ##3 } } { - \semantexnewobject { #1 } ##1 { parent = #1, ##3 } + \semantex_new_object:NNn { #1 } ##1 { ##3 } } % create the object with name ##1 \DeclareDocumentCommand{##1}{o}{ % the actual \##1 command \IfValueTF { ####1 } { - \semantexrenderobject { ##1 } { ifoutput=true,####1 } + \semantex_render_object:Nn ##1 { ifoutput=true,####1 } } { - \semantexrenderobject { ##1 } { } + \semantex_render_object:Nn ##1 { } } } } } +\tl_set_eq:NN\NewSimpleClass\semantex_new_simple_class:Nw + %IM Consider using \semantexIfNoValueOrDotTF on the argument -\DeclareDocumentCommand\newvariableclass{mO{}} % new variable-type class +\DeclareDocumentCommand\semantex_new_variable_class:Nw{mO{}} % new variable-type class { % #1 = class name % #2 = options - \semantexnewclass { #1 } { #2 } - \exp_args:Nc\DeclareDocumentCommand{#1}{mog}{ + \semantex_new_class:Nn { #1 } { #2 } + \DeclareDocumentCommand{#1}{mog}{ % the actual \#1 command \IfValueTF { ##2 } { \IfValueTF { ##3 } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##1},##2,arg={##3} } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##1},##2,arg={##3} } } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##1},##2} + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##1},##2} } } { \IfValueTF { ##3 } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##1},arg={##3} } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##1},arg={##3} } } { - \semantexrenderclass { #1 } { symbol={##1} } + \semantex_render_class:Nn #1 { symbol={##1} } } } } - \exp_args:Nc\DeclareDocumentCommand{#1withoptions}{mmog}{ + \exp_args:Nc\DeclareDocumentCommand{__semantex_make_object_of_class_\cs_to_str:N #1_with_options:nnw}{mmog}{ \IfValueTF { ##3 } { \IfValueTF { ##4 }{ - \semantexrenderclass { #1 } { ifoutput=true,symbol={##2}, ##1, ##3,arg={##4} } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##2}, ##1, ##3,arg={##4} } } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##2}, ##1, ##3 } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##2}, ##1, ##3 } } } { \IfValueTF { ##4 } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##2}, ##1,arg={##4} } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##2}, ##1,arg={##4} } } { - \semantexrenderclass { #1 } { symbol={##2}, ##1 } + \semantex_render_class:Nn #1 { symbol={##2}, ##1 } } } } - \exp_args:Nc\DeclareDocumentCommand{new#1}{mgO{}} + \exp_args:Nc\DeclareDocumentCommand{__semantex_new_object_of_class_\cs_to_str:N #1:Nw}{mgO{}} { % the command for creating a new object of class #1 % ##1 = command name, with backslash @@ -176,10 +198,10 @@ % ##3 = options \IfValueTF{##2} { - \semantexnewobject { #1 } ##1 { parent = #1, symbol = { ##2 }, ##3 } + \semantex_new_object:NNn { #1 } ##1 { symbol = { ##2 }, ##3 } } { - \semantexnewobject { #1 } ##1 { parent = #1, ##3 } + \semantex_new_object:NNn { #1 } ##1 { ##3 } } % creates the object with name ##1 \DeclareDocumentCommand{##1}{og}{ @@ -187,66 +209,66 @@ \IfValueTF{####1}{ \IfValueTF{####2} { - \semantexrenderobject { ##1 } { ifoutput=true,####1, arg={####2} } + \semantex_render_object:Nn ##1 { ifoutput=true,####1, arg={####2} } } { - \semantexrenderobject { ##1 } { ifoutput=true,####1} + \semantex_render_object:Nn ##1 { ifoutput=true,####1} } } { \IfValueTF{####2} { - \semantexrenderobject { ##1 } { ifoutput=true,arg={####2} } + \semantex_render_object:Nn ##1 { ifoutput=true,arg={####2} } } { - \semantexrenderobject { ##1 } {} + \semantex_render_object:Nn ##1 {} } } } } } -\DeclareDocumentCommand\newcohomologyclass{mO{}} % new cohomology-type class -% The intention is to phase this out; use variable type instead, -%for the sake of consistency in notation. +\cs_set_eq:NN\NewVariableClass\semantex_new_variable_class:Nw + +\DeclareDocumentCommand\semantex_new_cohomology_class:Nw{mO{}} % new cohomology-type class { % #1 = class name % #2 = options - \semantexnewclass { #1 } { #2 } - \exp_args:Nc\DeclareDocumentCommand{#1}{mogg}{ + \semantex_new_class:Nn { #1 } { #2 } + \DeclareDocumentCommand{#1}{mogg}{ % the actual \#1 command \IfValueTF{##2} { \IfValueTF { ##3 } { - \semantexifeqTF { ##3 }{ * } + \tl_if_eq:nnTF { ##3 }{ * } { \IfValueTF { ##4 } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##1}, ##2, *, arg={##4} } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##1}, ##2, *, arg={##4} } } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##1}, ##2, * } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##1}, ##2, * } } } { - \semantexifeqTF { ##3 }{ ** } + \tl_if_eq:nnTF { ##3 }{ ** } { \IfValueTF { ##4 } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##1}, ##2, **, arg={##4} } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##1}, ##2, **, arg={##4} } } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##1}, ##2, ** } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##1}, ##2, ** } } } { \IfValueTF { ##4 } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##1}, ##2, degreedefault={##3}, arg={##4} } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##1}, ##2, degreedefault={##3}, arg={##4} } } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##1}, ##2, degreedefault={##3} } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##1}, ##2, degreedefault={##3} } } } } @@ -254,44 +276,44 @@ { \IfValueTF { ##4 } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##1}, ##2, arg={##4} } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##1}, ##2, arg={##4} } } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##1}, ##2 } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##1}, ##2 } } } } { \IfValueTF { ##3 } { - \semantexifeqTF { ##3 }{ * } + \tl_if_eq:nnTF { ##3 }{ * } { \IfValueTF { ##4 } { - \semantexrenderclass { #1 } { ifoutput=true, symbol={##1}, *, arg={##4} } + \semantex_render_class:Nn #1 { ifoutput=true, symbol={##1}, *, arg={##4} } } { - \semantexrenderclass { #1 } { ifoutput=true, symbol={##1}, *} + \semantex_render_class:Nn #1 { ifoutput=true, symbol={##1}, *} } } { - \semantexifeqTF { ##3 }{ ** } + \tl_if_eq:nnTF { ##3 }{ ** } { \IfValueTF { ##4 } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##1}, **, arg={##4} } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##1}, **, arg={##4} } } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##1}, ** } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##1}, ** } } } { \IfValueTF { ##4 } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##1}, degreedefault={##3}, arg={##4} } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##1}, degreedefault={##3}, arg={##4} } } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##1}, degreedefault={##3} } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##1}, degreedefault={##3} } } } } @@ -299,47 +321,47 @@ { \IfValueTF { ##4 } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##1}, arg={##4} } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##1}, arg={##4} } } { - \semantexrenderclass { #1 } { symbol={##1}, arg={##4} } + \semantex_render_class:Nn #1 { symbol={##1}, arg={##4} } } } } } - \exp_args:Nc\DeclareDocumentCommand{#1withoptions}{mmogg}{ + \exp_args:Nc\DeclareDocumentCommand{__semantex_make_object_of_class_\cs_to_str:N #1_with_options:nnw}{mmogg}{ \IfValueTF{##3} { \IfValueTF { ##4 } { - \semantexifeqTF { ##4 }{ * } + \tl_if_eq:nnTF { ##4 }{ * } { \IfValueTF { ##5 } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##2}, ##1, ##3, *, arg={##5} } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##2}, ##1, ##3, *, arg={##5} } } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##2}, ##1, ##3, * } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##2}, ##1, ##3, * } } } { - \semantexifeqTF { ##4 }{ ** } + \tl_if_eq:nnTF { ##4 }{ ** } { \IfValueTF { ##5 } { - \semantexrenderclass { #1 } {ifoutput=true, symbol={##2}, ##1, ##3, **, arg={##5} } + \semantex_render_class:Nn #1 {ifoutput=true, symbol={##2}, ##1, ##3, **, arg={##5} } } { - \semantexrenderclass { #1 } {ifoutput=true, symbol={##2}, ##1, ##3, ** } + \semantex_render_class:Nn #1 {ifoutput=true, symbol={##2}, ##1, ##3, ** } } } { \IfValueTF { ##5 } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##2}, ##1,##3, degreedefault={##4}, arg={##5} } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##2}, ##1,##3, degreedefault={##4}, arg={##5} } } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##2}, ##1,##3, degreedefault={##4} } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##2}, ##1,##3, degreedefault={##4} } } } } @@ -347,44 +369,44 @@ { \IfValueTF { ##5 } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##2}, ##1, ##3, arg={##5} } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##2}, ##1, ##3, arg={##5} } } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##2}, ##1, ##3 } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##2}, ##1, ##3 } } } } { \IfValueTF { ##4 } { - \semantexifeqTF { ##4 }{ * } + \tl_if_eq:nnTF { ##4 }{ * } { \IfValueTF { ##5 } { - \semantexrenderclass { #1 } { ifoutput=true, symbol={##2} ,##1, *, arg={##5} } + \semantex_render_class:Nn #1 { ifoutput=true, symbol={##2} ,##1, *, arg={##5} } } { - \semantexrenderclass { #1 } { ifoutput=true, symbol={##2} ,##1, *} + \semantex_render_class:Nn #1 { ifoutput=true, symbol={##2} ,##1, *} } } { - \semantexifeqTF { ##4 }{ ** } + \tl_if_eq:nnTF { ##4 }{ ** } { \IfValueTF { ##5 } { - \semantexrenderclass { #1 } { ifoutput=true, symbol={##2} , ##1, **, arg={##5} } + \semantex_render_class:Nn #1 { ifoutput=true, symbol={##2} , ##1, **, arg={##5} } } { - \semantexrenderclass { #1 } { ifoutput=true, symbol={##2} , ##1, ** } + \semantex_render_class:Nn #1 { ifoutput=true, symbol={##2} , ##1, ** } } } { \IfValueTF { ##5 } { - \semantexrenderclass { #1 } { ifoutput=true, symbol={##2}, ##1, degreedefault={##4}, arg={##5} } + \semantex_render_class:Nn #1 { ifoutput=true, symbol={##2}, ##1, degreedefault={##4}, arg={##5} } } { - \semantexrenderclass { #1 } { ifoutput=true, symbol={##2}, ##1, degreedefault={##4} } + \semantex_render_class:Nn #1 { ifoutput=true, symbol={##2}, ##1, degreedefault={##4} } } } } @@ -392,15 +414,15 @@ { \IfValueTF { ##5 } { - \semantexrenderclass { #1 } { ifoutput=true,symbol={##2}, ##1, arg={##5} } + \semantex_render_class:Nn #1 { ifoutput=true,symbol={##2}, ##1, arg={##5} } } { - \semantexrenderclass { #1 } { symbol={##2}, ##1 } + \semantex_render_class:Nn #1 { symbol={##2}, ##1 } } } } } - \exp_args:Nc\DeclareDocumentCommand{new#1}{mgO{}} + \exp_args:Nc\DeclareDocumentCommand{__semantex_new_object_of_class_\cs_to_str:N #1:Nw}{mgO{}} { % the command for creating a new object of class #1 % ##1 = command name, with backslash @@ -408,10 +430,10 @@ % ##3 = options \IfValueTF{##2} { - \semantexnewobject { #1 } { ##1 }{ parent = #1, symbol = { ##2 }, ##3 } + \semantex_new_object:NNn { #1 } { ##1 }{ symbol = { ##2 }, ##3 } } { - \semantexnewobject { #1 } { ##1 }{ parent = #1, ##3 } + \semantex_new_object:NNn { #1 } { ##1 }{ ##3 } } % creates the object with name ##1 \DeclareDocumentCommand{##1}{ogg}{ @@ -420,34 +442,34 @@ { \IfValueTF{####2} { - \semantexifeqTF { ####2 } { * } + \tl_if_eq:nnTF { ####2 } { * } { \IfValueTF{####3} { - \semantexrenderobject { ##1 } { ifoutput=true,####1, *, arg={ ####3 } } + \semantex_render_object:Nn ##1 { ifoutput=true,####1, *, arg={ ####3 } } } { - \semantexrenderobject { ##1 } { ifoutput=true,####1, * } + \semantex_render_object:Nn ##1 { ifoutput=true,####1, * } } } { - \semantexifeqTF { ####2 } { ** } + \tl_if_eq:nnTF { ####2 } { ** } { \IfValueTF{####3} { - \semantexrenderobject { ##1 } { ifoutput=true, ####1, **, arg={ ####3 } } + \semantex_render_object:Nn ##1 { ifoutput=true, ####1, **, arg={ ####3 } } } { - \semantexrenderobject { ##1 } { ifoutput=true, ####1, ** } + \semantex_render_object:Nn ##1 { ifoutput=true, ####1, ** } } } { \IfValueTF{####3} { - \semantexrenderobject { ##1 } { ifoutput=true,####1, degreedefault={ ####2 }, arg={ ####3 } } + \semantex_render_object:Nn ##1 { ifoutput=true,####1, degreedefault={ ####2 }, arg={ ####3 } } } { - \semantexrenderobject { ##1 } { ifoutput=true,####1, degreedefault={ ####2 } } + \semantex_render_object:Nn ##1 { ifoutput=true,####1, degreedefault={ ####2 } } } } } @@ -455,44 +477,44 @@ { \IfValueTF{####3} { - \semantexrenderobject { ##1 } { ifoutput=true,####1, arg={ ####3 } } + \semantex_render_object:Nn ##1 { ifoutput=true,####1, arg={ ####3 } } } { - \semantexrenderobject { ##1 } { ifoutput=true,####1 } + \semantex_render_object:Nn ##1 { ifoutput=true,####1 } } } } { \IfValueTF{####2} { - \semantexifeqTF { ####2 } { * } + \tl_if_eq:nnTF { ####2 } { * } { \IfValueTF{####3} { - \semantexrenderobject { ##1 } { ifoutput=true, *, arg={ ####3 } } + \semantex_render_object:Nn ##1 { ifoutput=true, *, arg={ ####3 } } } { - \semantexrenderobject { ##1 } { ifoutput=true, * } + \semantex_render_object:Nn ##1 { ifoutput=true, * } } } { - \semantexifeqTF { ####2 } { ** } + \tl_if_eq:nnTF { ####2 } { ** } { \IfValueTF{####3} { - \semantexrenderobject { ##1 } { ifoutput=true,**, arg={ ####3 } } + \semantex_render_object:Nn ##1 { ifoutput=true,**, arg={ ####3 } } } { - \semantexrenderobject { ##1 } { ifoutput=true,** } + \semantex_render_object:Nn ##1 { ifoutput=true,** } } } { \IfValueTF{####3} { - \semantexrenderobject { ##1 } { ifoutput=true,degreedefault={ ####2 }, arg={ ####3 } } + \semantex_render_object:Nn ##1 { ifoutput=true,degreedefault={ ####2 }, arg={ ####3 } } } { - \semantexrenderobject { ##1 } { ifoutput=true,degreedefault={ ####2 } } + \semantex_render_object:Nn ##1 { ifoutput=true,degreedefault={ ####2 } } } } } @@ -500,10 +522,10 @@ { \IfValueTF{####3} { - \semantexrenderobject { ##1 } { ifoutput=true, arg={ ####3 } } + \semantex_render_object:Nn ##1 { ifoutput=true, arg={ ####3 } } } { - \semantexrenderobject { ##1 } { } + \semantex_render_object:Nn ##1 { } } } } @@ -511,153 +533,67 @@ } } +\cs_set_eq:NN\NewCohomologyClass\semantex_new_cohomology_class:Nw -%\DeclareDocumentCommand\newtupleclass{mO{}} % new tuple-type class -%{ -% % #1 = class name -% % #2 = options -% \semantexnewclass { #1 } { #2 } -% \exp_args:Nc\DeclareDocumentCommand{#1}{mog}{ -% % the actual \#1 command -% % (maybe this does not even make sense for tuples) -% \IfValueTF { ##2 } -% { -% \IfValueTF { ##3 } -% { -% \semantexrenderclass { #1 }{ ifoutput=true,symbol = { ##1 },##2, arg = { ##3 } } -% } -% { -% \semantexrenderclass { #1 }{ ifoutput=true,symbol = { ##1 },##2 } -% } -% } -% { -% \IfValueTF { ##3 } -% { -% \semantexrenderclass { #1 }{ ifoutput=true,symbol = { ##1 }, arg = { ##3 } } -% } -% { -% \semantexrenderclass { #1 }{ symbol = { ##1 } } -% } -% } -% } -% \exp_args:Nc\DeclareDocumentCommand{#1withoptions}{mmog}{ -% \IfValueTF { ##3 } -% { -% \IfValueTF { ##4 } -% { -% \semantexrenderclass { #1 }{ ifoutput=true, symbol = { ##2 }, ##1, ##3, arg = { ##4 } } -% } -% { -% \semantexrenderclass { #1 }{ ifoutput=true, symbol = { ##2 }, ##1, ##3 } -% } -% } -% { -% \IfValueTF { ##4 } -% { -% \semantexrenderclass { #1 }{ ifoutput=true, symbol = { ##2 }, ##1, arg = { ##4 } } -% } -% { -% \semantexrenderclass { #1 }{ symbol = { ##2 }, ##1 } -% } -% } -% } -% \exp_args:Nc\DeclareDocumentCommand{new#1}{mmmmmO{}} -% { -% % the command for creating a new object of class #1 -% % ##1 = command name, with backslash -% % ##2 = symbol -% % ##3 = options -% \semantexnewobject { #1 } { ##1 } % creates the object with name ##1 -% { parent = #1, leftpar = { ##2 }, argsep = { ##3 }, rightpar = { ##4 }, argdots = { ##5 }, ##6 } -% \DeclareDocumentCommand{##1}{og}{ -% % the actual \##1 command -% \IfValueTF{####1} -% { -% \IfValueTF { ####2 } -% { -% \semantexrenderobject { ##1 } { ifoutput=true,####1, arg = { ####2 } } -% } -% { -% \semantexrenderobject { ##1 } { ifoutput=true,####1 } -% } -% } -% { -% \IfValueTF { ####2 } -% { -% \semantexrenderobject { ##1 } { ifoutput=true, arg = { ####2 } } -% } -% { -% \semantexrenderobject { ##1 } { } -% } -% } -% } -% } -%} - -\DeclareDocumentCommand\newdelimiterclass{mO{}} % new delimiter-type class +\DeclareDocumentCommand\semantex_new_delimiter_class:Nw{mO{}} % new delimiter-type class { % #1 = class name % #2 = options - \semantexnewclass { #1 } { -% valuekeys={ -% {arg}{argwithoutkeyval={\l_semantex_key_value_temp}}, -% %Currently, using no braces around \l_semantex_key_value_temp is necessary for \semantexdelimsize to work -% % with par=auto -% }, + \semantex_new_class:Nn { #1 } { #2 } - \exp_args:Nc\DeclareDocumentCommand{#1}{mog} % maybe this does not even make sense for delimiters + \DeclareDocumentCommand{#1}{mog} % maybe this does not even make sense for delimiters { \IfValueTF { ##2 } { \IfValueTF { ##3 } { - \semantexrenderclass { #1 } { ifoutput=true, symbol = { ##1 }, ##2, arg = { ##3 } } + \semantex_render_class:Nn #1 { ifoutput=true, symbol = { ##1 }, ##2, arg = { ##3 } } } { - \semantexrenderclass { #1 } { ifoutput=true, symbol = { ##1 }, ##2 } + \semantex_render_class:Nn #1 { ifoutput=true, symbol = { ##1 }, ##2 } } } { \IfValueTF { ##3 } { - \semantexrenderclass { #1 } { ifoutput=true, symbol = { ##1 }, arg = { ##3 } } + \semantex_render_class:Nn #1 { ifoutput=true, symbol = { ##1 }, arg = { ##3 } } } { - \semantexrenderclass { #1 } { symbol = { ##1 } } + \semantex_render_class:Nn #1 { symbol = { ##1 } } } } } % the actual \#1 command - \exp_args:Nc\DeclareDocumentCommand{#1withoptions}{mmog} + \exp_args:Nc\DeclareDocumentCommand{__semantex_make_object_of_class_\cs_to_str:N #1_with_options:nnw}{mmog} { \IfValueTF { ##3 } { \IfValueTF { ##4 } { - \semantexrenderclass { #1 } { ifoutput=true, symbol = { ##2 }, ##1, ##3, arg = { ##4 } } + \semantex_render_class:Nn #1 { ifoutput=true, symbol = { ##2 }, ##1, ##3, arg = { ##4 } } } { - \semantexrenderclass { #1 } { ifoutput=true, symbol = { ##2 }, ##1, ##3 } + \semantex_render_class:Nn #1 { ifoutput=true, symbol = { ##2 }, ##1, ##3 } } } { \IfValueTF { ##4 } { - \semantexrenderclass { #1 } { ifoutput=true, symbol = { ##2 }, ##1, arg = { ##4 } } + \semantex_render_class:Nn #1 { ifoutput=true, symbol = { ##2 }, ##1, arg = { ##4 } } } { - \semantexrenderclass { #1 } { symbol = { ##2 }, ##1 } + \semantex_render_class:Nn #1 { symbol = { ##2 }, ##1 } } } } - \exp_args:Nc\DeclareDocumentCommand{new#1}{mmmO{}} + \exp_args:Nc\DeclareDocumentCommand{__semantex_new_object_of_class_\cs_to_str:N #1:Nw}{mmmO{}} { % the command for creating a new object of class #1 % ##1 = command name, with backslash % ##2 = symbol % ##3 = options - \semantexnewobject { #1 } { ##1 }{ parent = #1, leftpar = { ##2 }, rightpar = { ##3 }, ##4 } + \semantex_new_object:NNn { #1 } { ##1 }{ leftpar = { ##2 }, rightpar = { ##3 }, ##4 } % creates the object with name ##1 \DeclareDocumentCommand{##1}{og}{ % the actual \##1 command @@ -665,192 +601,196 @@ { \IfValueTF { ####2 } { - \semantexrenderobject { ##1 } { ifoutput=true,####1, arg = { ####2 } } + \semantex_render_object:Nn ##1 { ifoutput=true,####1, arg = { ####2 } } } { - \semantexrenderobject { ##1 } { ifoutput=true,####1 } + \semantex_render_object:Nn ##1 { ifoutput=true,####1 } } } { \IfValueTF { ####2 } { - \semantexrenderobject { ##1 } { ifoutput=true, arg = { ####2 } } + \semantex_render_object:Nn ##1 { ifoutput=true, arg = { ####2 } } } { - \semantexrenderobject { ##1 } { } + \semantex_render_object:Nn ##1 { } } } } } } -\cs_generate_variant:Nn \tl_if_eq:nnTF { xnTF } - -\cs_generate_variant:Nn \tl_if_eq:nnF { xnF } - -\cs_generate_variant:Nn \tl_if_eq:nnT { xnT } +\cs_set_eq:NN\NewDelimiterClass\semantex_new_delimiter_class:Nw -\DeclareDocumentCommand{\semantexifblankordotTF}{mmm} -{ - \tl_if_blank:nTF { #1 } - { #2 } - { - \tl_if_eq:xnTF { \tl_trim_spaces:n { #1 } } { . } { #2 } { #3 } - } -} - -\DeclareDocumentCommand{\semantexifblankordotT}{mm} -{ - \tl_if_blank:nTF { #1 } - { #2 } - { - \tl_if_eq:xnT { \tl_trim_spaces:n { #1 } } { . } { #2 } - } -} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% COMMANDS FOR CREATING AND HANDLING CLASSES AND OJBECTS +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\DeclareDocumentCommand{\semantexifblankordotF}{mm} +\cs_new:Npn\NewObject#1 { - \tl_if_blank:nF { #1 } + \cs_if_exist_use:cF { __semantex_new_object_of_class_\cs_to_str:N#1:Nw } { - \tl_if_eq:xnF { \tl_trim_spaces:n { #1 } } { . } { #2 } - } -} - -\cs_set_eq:NN\semantexifeqTF\tl_if_eq:nnTF - -\cs_set_eq:NN\semantexifeqT\tl_if_eq:nnT - -\cs_set_eq:NN\semantexifeqF\tl_if_eq:nnF - - - -\cs_new:Npn \g_semantex_new_class:nn#1#2{ - % create a new class - % #1 = name of class - % #2 = standard keyval setup; the parent class by default is semantexvariable - \g_semantex_new_object:nnn { semantexvariable } { #1 } { #2 } + \msg_error:nnnn { semantex } { created_object_of_unknown_class } { #1 } + } } -\cs_set_eq:NN\semantexnewclass\g_semantex_new_class:nn - -\seq_new:N \semantex_all_objects_seq -\seq_put_right:Nn \semantex_all_objects_seq { semantexvariable } +%\cs_new:Npn\MakeObject#1{ \use:c { __semantex_make_object_of_class_#1:nw } } - -\cs_new:Npn \g_semantex_new_object:nnn#1#2#3{ +\cs_new:Npn \__semantex_new_class_or_object:nn#1#2{ % create new object - % #1 = class of command - % #2 = name of command, without backslash - % #3 = standard keyval setup + % #1 = name of command, without backslash + % #2 = standard keyval setup - \g_semantex_data_tl_provide:nn { #2 } { parent } + \semantex_data_tl_provide:nn { #1 } { parent } - \g_semantex_data_tl_set:nnn {#2 } { parent } { semantexvariable } + \semantex_data_tl_set:nnn { #1 } { parent } { class_SemantexVariable } - \cs_set:cpn { g_semantex_data_cs_#2_valuekey:nn } ##1##2 % command controlling valuekeys - { \g_semantex_valuekey:nnn { ##2 } { ##1 } { #2 } } + \cs_set:cpn { __semantex_data_cs_#1_valuekey:nn } ##1##2 % command controlling valuekeys + { \semantex_valuekey:nnn { ##2 } { ##1 } { #1 } } - \cs_set:cpn { g_semantex_data_cs_#2_novaluekey:n } ##1 % command controlling novaluekeys - { \g_semantex_novaluekey:nn { ##1 } { #2 } } + \cs_set:cpn { __semantex_data_cs_#1_singlekey:n } ##1 % command controlling singlekeys + { \semantex_singlekey:nn { ##1 } { #1 } } % Now a similar collection of keyval commands for the *argument* - \cs_set:cpn { g_semantex_data_cs_#2_arg_valuekey:nn } ##1##2 - { \g_semantex_arg_valuekey:nnn { ##2 } { ##1 }{ #2 } } + \cs_set:cpn { __semantex_data_cs_#1_arg_valuekey:nn } ##1##2 + { \semantex_arg_valuekey:nnn { ##2 } { ##1 }{ #1 } } - \cs_set:cpn { g_semantex_data_cs_#2_arg_novaluekey:n } ##1 - { \g_semantex_arg_novaluekey:nn { ##1 } { #2 } } - + \cs_set:cpn { __semantex_data_cs_#1_arg_singlekey:n } ##1 + { \semantex_arg_singlekey:nn { ##1 } { #1 } } % initially sets up the keyval interface of the object - \g_semantex_keys_set:nn { #2 } { parent=#1, #3 } + \semantex_keys_set:nn { #1 } { #2 } - \seq_put_right:Nx \semantex_all_objects_seq { #2 } +% \seq_put_right:Nx \g__semantex_all_objects_seq { #1 } } +\cs_generate_variant:Nn \__semantex_new_class_or_object:nn { xn } + +\cs_new: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 SemantexVariable + \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 } + } +} + +\cs_set:Npn \semantex_new_object:NNn#1#2#3 +{ + \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 } + } +} -\cs_generate_variant:Nn \g_semantex_new_object:nnn { nxn } +\seq_new:N \g__semantex_all_classes_seq % a register for all objects created -\cs_set:Npn \semantexnewobject#1#2#3 -{ \g_semantex_new_object:nxn { #1 }{ \cs_to_str:N #2 } { #3 } } +\cs_new:Npn\semantex_class_register:N#1 +{ + \seq_put_right:Nx\g__semantex_all_classes_seq { class_\cs_to_str:N #1 } +} +\cs_new: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_new:N \g__semantex_all_objects_seq % a register for all objects created +\cs_new:Npn\semantex_object_register:N#1 +{ + \seq_put_right:Nx\g__semantex_all_objects_seq { object_\cs_to_str:N #1 } +} -%------------------------------- +\cs_new: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 } +} -% Commands for rendering: +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% COMMANDS FOR RENDERING OBJECTS AND CLASSES +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\tl_new:N\l__semantex_symbol_temp +\cs_generate_variant:Nn\tl_if_blank:nTF { xTF } -\cs_new_protected:Npn \g_semantex_render:nn#1#2 +\cs_new_protected:Npn \__semantex_render:nn#1#2 { - % the main command for rendering an object + % the main command for rendering a class/object % #1 = name of object % #2 = options \group_begin: - \g_semantex_data_tl_inherit:nn { #1 } { symbol } - \g_semantex_keys_set:nn { #1 } { #2 } - \g_semantex_primitive_valuekey_parse:nn { #1 } { } % not the right place to run this? - \g_semantex_data_bool_get:nnTF { #1 } { output } + \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 + \semantex_primitive_valuekey_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 { - \g_semantex_primitive_valuekey_innerreturn:nn { #1 }{} - \g_semantex_data_bool_get:nnTF { #1 } { rightreturnbeforerender } + \semantex_primitive_valuekey_innerreturn:nn { #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 { - \g_semantex_primitive_valuekey_rightreturn:nn { #1 }{} + \semantex_data_bool_get:nnTF { #1 } { leftargument } % Checks if left or right argument + { + \semantex_primitive_valuekey_leftreturn:nn { #1 }{} + } + { + \semantex_primitive_valuekey_rightreturn:nn { #1 }{} + } } { % do nothing } - \tl_set:Nx\l__semantex_render_symbol_temp { \g_semantex_data_tl_get:nn { #1 } { symbol } } %IM chang to "store" solution - \g_semantex_data_tl_get_store:nnN { #1 } { upper_index } \l__semantex_render_upper_index_temp - \g_semantex_data_tl_get_store:nnN { #1 } { lower_index } \l__semantex_render_lower_index_temp - \g_semantex_data_tl_get_store:nnN { #1 } { upper_left_index } \l__semantex_render_upper_left_index_temp - \g_semantex_data_tl_get_store:nnN { #1 } { lower_left_index } \l__semantex_render_lower_left_index_temp - \g_semantex_data_tl_get_store:nnN { #1 } { preupper } \l__semantex_render_preupper_temp - \g_semantex_data_tl_get_store:nnN { #1 } { postupper } \l__semantex_render_postupper_temp - \g_semantex_data_tl_get_store:nnN { #1 } { prelower } \l__semantex_render_prelower_temp - \g_semantex_data_tl_get_store:nnN { #1 } { postlower } \l__semantex_render_postlower_temp - \g_semantex_data_tl_get_store:nnN { #1 } { preupperleft } \l__semantex_render_preupperleft_temp - \g_semantex_data_tl_get_store:nnN { #1 } { postupperleft } \l__semantex_render_postupperleft_temp - \g_semantex_data_tl_get_store:nnN { #1 } { prelowerleft } \l__semantex_render_prelowerleft_temp - \g_semantex_data_tl_get_store:nnN { #1 } { postlowerleft } \l__semantex_render_postlowerleft_temp - \g_semantex_data_tl_get_store:nnN { #1 } { texclass } \l__semantex_render_texclass_temp + \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 { \exp_not:c { - \g_semantex_data_tl_get:nn { #1 } { output }withoptions - } + __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 { - upperaddleft={\exp_not:V\l__semantex_render_upper_index_temp}, - loweraddleft={\exp_not:V\l__semantex_render_lower_index_temp}, - upperleftaddright={\exp_not:V\l__semantex_render_upper_left_index_temp}, - lowerleftaddright={\exp_not:V\l__semantex_render_lower_left_index_temp}, - preupper={\exp_not:V\l__semantex_render_preupper_temp}, - postupper={\exp_not:V\l__semantex_render_postupper_temp}, - prelower={\exp_not:V\l__semantex_render_prelower_temp}, - postlower={\exp_not:V\l__semantex_render_postlower_temp}, - preupperleft={\exp_not:V\l__semantex_render_preupperleft_temp}, - postupperleft={\exp_not:V\l__semantex_render_postupperleft_temp}, - prelowerleft={\exp_not:V\l__semantex_render_prelowerleft_temp}, - postlowerleft={\exp_not:V\l__semantex_render_postlowerleft_temp}, - texclass={\l__semantex_render_texclass_temp}, - \g_semantex_data_tl_get_exp_not:nn { #1 } { output_options }, + upperputleft={\semantex_data_tl_get_exp_not:nn { #1 } { upper }}, + lowerputleft={\semantex_data_tl_get_exp_not:nn { #1 } { lower }}, + upperleftputright={\semantex_data_tl_get_exp_not:nn { #1 } { upperleft }}, + lowerleftputright={\semantex_data_tl_get_exp_not:nn { #1 } { lowerleft }}, + preupper={\semantex_data_tl_get_exp_not:nn { #1 } { preupper }}, + postupper={\semantex_data_tl_get_exp_not:nn { #1 } { postupper }}, + prelower={\semantex_data_tl_get_exp_not:nn { #1 } { prelower }}, + postlower={\semantex_data_tl_get_exp_not:nn { #1 } { postlower }}, + preupperleft={\semantex_data_tl_get_exp_not:nn { #1 } { preupperleft }}, + postupperleft={\semantex_data_tl_get_exp_not:nn { #1 } { postupperleft }}, + prelowerleft={\semantex_data_tl_get_exp_not:nn { #1 } { prelowerleft }}, + postlowerleft={\semantex_data_tl_get_exp_not:nn { #1 } { postlowerleft }}, + texclass={\semantex_data_tl_get:nn { #1 } { texclass }}, + \semantex_data_tl_get_exp_not:nn { #1 } { outputoptions }, + % These are the options we parse to our object -- this is all + % information that we pass on to the output class so that it + % can eventually render it } { \exp_not:V \l__semantex_render_symbol_temp } } } { - \g_semantex_primitive_valuekey_return:nn { #1 }{} -% \tl_set:Nx \l__semantex_render_temp { \exp_not:V \l__semantex_symbol_temp } -% \tl_set:Nx\l__semantex_render_temp { \g_semantex_data_tl_get:nn { #1 } { symbol } } % this is the ordinary solution that generally just works - %\tl_set:Nx\l__semantex_render_temp { \exp_not:n{\exp_not:v { semantex_data_tl_#1_symbol } }} -% \g_semantex_data_tl_get_store:nnN { #1 } { symbol } \l__semantex_render_symbol_temp - \tl_if_blank:xTF { \g_semantex_data_tl_get:nn { #1 } { texclass } }{ - \tl_set:Nx\l__semantex_render_symbol_temp { \g_semantex_data_tl_get:nn { #1 } { symbol } } + \semantex_primitive_valuekey_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 } } + % 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_symbol_temp { \g_semantex_data_tl_get:nn { #1 } { texclass } { \g_semantex_data_tl_get: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 @@ -858,234 +798,423 @@ } \exp_last_unbraced:NV \group_end: - \l__semantex_render_temp + \l__semantex_render_temp % This neat trick allows outputting to different classes to work as expected } -\cs_set_eq:NN\semantexrenderclass\g_semantex_render:nn % a front-end command +\cs_generate_variant:Nn \__semantex_render:nn { xn } -\cs_set:Npn\semantexrenderobject#1#2 +\cs_set:Npn\semantex_render_class:Nn#1#2 % a front-end command { - \g_semantex_render:nn { \cs_to_str:N #1 } { #2 } + \__semantex_render:xn { class_\cs_to_str:N #1 } { #2 } } +\cs_set: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 +} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% COMMANDS FOR HANDLING PARENTHESES +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\cs_generate_variant:Nn\tl_if_blank:nTF { xTF } -\cs_new:Npn \g_semantex_right_indices:nnnnnn#1#2#3#4#5#6 +\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 { - \tl_if_blank:nF { #2 } { \sp{#1 #2 #3} } - \tl_if_blank:nF { #5 } { \sb{#4 #5 #6} } - % Using x here was the source of a very long - % debugging; inputting underbrace in the index - % caused problems + \group_begin: + %\semantexnormalscalingl#2 #4 #5 #6 \semantexnormalscalingr#3 + \mathopen#1 #3 \mathclose#2 + \group_end: } -\cs_new:Npn \g_semantex_left_indices:nnnnnn#1#2#3#4#5#6 +\cs_new:Npn \__semantex_parentheses_auto:nnn#1#2#3 { - \tl_if_blank:nTF { #2 } { - \tl_if_blank:nF { #5 } { {}\sb{#4 #5 #6} } - } - { - {} \sp{#1 #2 #3} - \tl_if_blank:nF { #5 } { \sb{#4 #5 #6} } - } + \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_new:Npn \__semantex_parentheses_other:nnnn#1#2#3#4 +{ + \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: +} -\tl_new:N\semantexdelimsize - -%So far, this is experimental: -%\makeatletter %this part requires amsmath -\newcommand{\semantexnormalscaling}{\bBigg@{0.8}} -\newcommand{\semantexnormalscalingl}{\mathopen\semantexnormalscaling} -\newcommand{\semantexnormalscalingr}{\mathclose\semantexnormalscaling} -\newcommand{\semantexnormalscalingm}{\mathrel\semantexnormalscaling} -%\makeatother +\cs_generate_variant:Nn \str_case:nnF { xnF } -\cs_new:Npn \g_semantex_parentheses:nnnnnn#1#2#3#4#5#6 +\cs_new:Npn \__semantex_parentheses_store:nnnnN#1#2#3#4#5 +% The central command handling the rendering of argument parentheses { - \tl_if_blank:nF { #5 } + \tl_set:Nx#5 { - \str_case:nnF { #1 } - { - { normal } { - \group_begin: - %\semantexnormalscalingl#2 #4 #5 #6 \semantexnormalscalingr#3 - \mathopen#2 #4 #5 #6 \mathclose#3 - \group_end: + { #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 + { + { normal } { + \tl_put_left:Nn#5 + { + \exp_not:N + \__semantex_parentheses_normal:nnn } - { auto } { - \group_begin: - \tl_set:Nn\semantexdelimsize{\middle} - %\tl_set_eq:NN\semantexdelimsize\middle - \mathopen{}\mathclose\bgroup\left#2 - #4 #5 #6 - \aftergroup\egroup\right#3 - \group_end: + } + { auto } { + \tl_put_left:Nn#5 + { + \exp_not:N + \__semantex_parentheses_auto:nnn } - { * } { - \group_begin: - \tl_set:Nn\semantexdelimsize{\middle} - %\tl_set_eq:NN\semantexdelimsize\middle - \mathopen{}\mathclose\bgroup\left#2 - #4 #5 #6 - \aftergroup\egroup\right#3 - \group_end: + } + { * } { + \tl_put_left:Nn#5 + { + \exp_not:N + \__semantex_parentheses_auto:nnn } -% { \big } { -% \group_begin: -% \tl_set_eq:NN\semantexdelimsize\big -% \mathopen\big#2 #4 \mathclose\big#3 -% \group_end: -% } -% { \Big } { -% \group_begin: -% \tl_set_eq:NN\semantexdelimsize\Big -% \mathopen\Big#2 #4 \mathclose\Big#3 -% \group_end: -% } -% { \bigg } { -% \group_begin: -% \tl_set_eq:NN\semantexdelimsize\bigg -% \mathopen\bigg#2 #4 \mathclose\bigg#3 -% \group_end: -% } -% { \Bigg } { -% \group_begin: -% \tl_set_eq:NN\semantexdelimsize\Bigg -% \mathopen\Bigg#2 #4 \mathclose\Bigg#3 -% \group_end: -% } } + } + { + \tl_put_right:Nx#5 + { + { \exp_not:V #1 } + } + \tl_put_left:Nn#5 { - \group_begin: - \tl_set_eq:NN\semantexdelimsize#1 - %\tl_set:Nx\semantexdelimsize{\exp_not:N#1} - \mathopen#1#2 #4 #5 #6 \mathclose#1#3 - \group_end: + \exp_not:N + \__semantex_parentheses_other:nnnn } } } -\cs_new:Npn \g_semantex_no_parentheses:nnn#1#2#3 +\cs_new:Npn \__semantex_no_parentheses:n#1 { - \tl_if_blank:nF { #2 } - { \group_begin: - \tl_clear:N\semantexdelimsize - #1 #2 #3 + \tl_clear:N\SemantexDelimiterSize + #1 \group_end: +} + +\cs_new:Npn \__semantex_no_parentheses_store:nN#1#2 +% The central command for handling the rendering of arguments with no parentheses around +{ + \tl_set:Nx#2 + { + { #1 } } + \tl_put_left:Nn#2 + { + \exp_not:N + \__semantex_no_parentheses:n + } +} + +\cs_new:Npn \__semantex_symbol_parentheses_normal:nnn#1#2#3 +{ + \mathopen#1 #3 \mathclose#2 } -\cs_new:Npn \g_semantex_symbol_parentheses:nnnn#1#2#3#4 +\cs_new:Npn \__semantex_symbol_parentheses_auto:nnn#1#2#3 { - \tl_if_blank:nF { #4 } + \mathopen{}\mathclose\bgroup\left#1 + #3 + \aftergroup\egroup\right#2 +} + + +\cs_new:Npn \__semantex_symbol_parentheses_other:nnnn#1#2#3#4 +{ + \mathopen#4#1 #3 \mathclose#4#2 +} + + +\cs_new: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 } + { normal } { + \tl_put_left:Nn#5 + { + \exp_not:N + \__semantex_symbol_parentheses_normal:nnn + } + } + { auto } { + \tl_put_left:Nn#5 + { + \exp_not:N + \__semantex_symbol_parentheses_auto:nnn + } + } + { * } { + \tl_put_left:Nn#5 + { + \exp_not:N + \__semantex_symbol_parentheses_auto:nnn + } + } + } + { + \tl_put_right:Nx#5 { - { normal } { \mathopen#2 #4 \mathclose#3 } - { auto } { \mathopen{}\mathclose\bgroup\left#2 #4 \aftergroup\egroup\right#3 } - { * } { \mathopen{}\mathclose\bgroup\left#2 #4 \aftergroup\egroup\right#3 } + { \exp_not:V #1 } + } + \tl_put_left:Nn#5 + { + \exp_not:N + \__semantex_symbol_parentheses_other:nnnn } - { \mathopen#1#2 #4 \mathclose#1#3 } } } +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% COMMANDS FOR MODIFYING AND OBTAINING DATA +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %-------------------------------------------- % Commands to modify and obtain data -\cs_generate_variant:Nn \str_if_eq:nnTF { fnTF , onTF } - -%\cs_new:Npn \g_semantex_data_tl_get_proto:nnn#1#2#3 +%\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 { semantex_data_tl_#1_#2 } +% \tl_if_exist:cTF { g__semantex_data_tl_#1_#2 } % { -% \use:c { semantex_data_tl_#1_#2 } +% \use:c { g__semantex_data_tl_#1_#2 } % } % { -% \tl_if_eq:nnTF { #1 } { semantexvariable } +% \tl_if_eq:nnTF { #1 } { SemantexVariable } % { % \msg_error:nnnn { semantex } { data_tl_not_found } { #2 } { #3 } % } % { -% \g_semantex_data_tl_get_proto:nnn { \g_semantex_data_tl_get:nn { #1 } { parent } } { #2 } { #1 } +% \semantex_data_tl_get_proto:nnn { \semantex_data_tl_get:nn { #1 } { parent } } { #2 } { #1 } % } % } %} % -%\cs_new:Npn \g_semantex_data_tl_get:nn#1#2 +%\cs_new:Npn \semantex_data_tl_get:nn#1#2 %{ -% \g_semantex_data_tl_get_proto:nnn { #1 } { #2 } { #1 } +% \semantex_data_tl_get_proto:nnn { #1 } { #2 } { #1 } %} -\cs_new:Npn \g_semantex_data_tl_get:nn#1#2 + + +% 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 +{ + \semantex_class_if_exist:NTF { #2 } + { + \tl_set:cx { g__semantex_data_tl_#1_parent } { class_\cs_to_str:N#2 } + } + { + \semantex_error_output_format:nN { #1 } \l__semantex_data_parent_set_temp + \msg_error:nnxnn { semantex } { class_not_found } { \l__semantex_data_parent_set_temp } { parent } { #2 } + } +} + +\cs_new:Npn \semantex_data_class_set:nn#1#2 +{ + \semantex_class_if_exist:NTF { #2 } + { + \tl_set:cx { g__semantex_data_tl_#1_parent } { class_\cs_to_str:N#2 } + } + { + \semantex_error_output_format:nN { #1 } \l__semantex_data_class_set_temp + \msg_error:nnxnn { semantex } { class_not_found } { \l__semantex_data_class_set_temp } { class } { #2 } + } +} + +\cs_new:Npn \semantex_data_copy_object:nn#1#2 +{ + \semantex_object_if_exist:NTF { #2 } + { + \tl_set:cx { g__semantex_data_tl_#1_parent } { object_\cs_to_str:N#2 } + } + { + \semantex_error_output_format:nN { #1 } \l__semantex_data_copy_object_temp + \msg_error:nnxnn { semantex } { object_not_found } { \l__semantex_data_copy_object_temp } { copy } { #2 } + } +} + +\cs_new:Npn \semantex_data_clone_object:nn#1#2 +{ + \semantex_object_if_exist:NTF { #2 } + { + \tl_set:cx { g__semantex_data_tl_#1_parent } { object_\cs_to_str:N#2 } + } + { + \semantex_error_output_format:nN { #1 } \l__semantex_data_clone_object_temp + \msg_error:nnxnn { semantex } { object_not_found } { \l__semantex_data_clone_object_temp } { clone } { #2 } + } +} + +% COMMANDS FOR HANDLING DATA CONSISTING OF TOKEN LISTS + +\cs_new:Npn \semantex_data_tl_get:nn#1#2 { % #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 { semantex_data_tl_#1_#2 } + \__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 + % #2 = the data to get + % #3 = the original class/object, used for error messaging + \tl_if_exist:cTF { g__semantex_data_tl_#1_#2 } { - \use:c { semantex_data_tl_#1_#2 } + \use:c { g__semantex_data_tl_#1_#2 } } { - \g_semantex_data_tl_get:nn { \g_semantex_data_tl_get:nn { #1 } { parent } } { #2 } + \str_if_eq:nnTF { #1 } { class_SemantexVariable } % Apparently, f-type expansion seemed to work here for once + { + \semantex_error_output_format:nN { #3 } \__semantex_data_tl_get_auxiliary_temp + \msg_error:nnxn { semantex } { data_tl_not_found } { \__semantex_data_tl_get_auxiliary_temp } { #2 } + } + { + \__semantex_data_tl_get_auxiliary:fnn { \semantex_data_parent_get:n { #1 } } { #2 } { #3 } + } } } -\cs_new:Npn \g_semantex_data_tl_get_exp_not:nn#1#2 +\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 % #2 = the data to get - \tl_if_exist:cTF { semantex_data_tl_#1_#2 } + \__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 + % #2 = the data to get + % #3 = the original class/object, used for error messaging + \tl_if_exist:cTF { g__semantex_data_tl_#1_#2 } { - \exp_not:v { semantex_data_tl_#1_#2 } + \exp_not:v { g__semantex_data_tl_#1_#2 } } { - \g_semantex_data_tl_get:nn { \g_semantex_data_tl_get:nn { #1 } { parent } } { #2 } + \str_if_eq:nnTF { #1 } { class_SemantexVariable } % Apparently, f-type expansion seemed to work here for once + { + \semantex_error_output_format:nN { #3 } \l__semantex_data_tl_get_exp_not_auxiliary_temp + \msg_error:nnxn { semantex } { data_tl_not_found } { \l__semantex_data_tl_get_exp_not_auxiliary_temp } { #2 } + } + { + \__semantex_data_tl_get_exp_not_auxiliary:fnn { \semantex_data_parent_get:n { #1 } } { #2 } { #3 } + } } } -%\cs_generate_variant:Nn \g_semantex_data_tl_get:nn { cn } +\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?? +{ + % #1 = name of object + % #2 = the data to get + % #3 = where to store it + \__semantex_data_tl_get_store_auxiliary:nnNn { #1 } { #2 } #3 { #1 } +} -\cs_new:Npn \g_semantex_data_tl_get_store:nnN#1#2#3% maybe should be PROTECTED?? +\cs_new:Npn \__semantex_data_tl_get_store_auxiliary:nnNn#1#2#3#4% maybe should be PROTECTED?? { % #1 = name of object % #2 = the data to get % #3 = where to store it - \tl_if_exist:cTF { semantex_data_tl_#1_#2 } + \tl_if_exist:cTF { g__semantex_data_tl_#1_#2 } { - \tl_set_eq:Nc #3 { semantex_data_tl_#1_#2 } + \tl_set_eq:Nc #3 { g__semantex_data_tl_#1_#2 } } { - \g_semantex_data_tl_get_store:nnN { \g_semantex_data_tl_get:nn { #1 } { parent } } { #2 } #3 + \str_if_eq:nnTF { #1 } { class_SemantexVariable } + { + \semantex_error_output_format:nN { #4 } \l__semantex_data_tl_get_store_auxiliary_temp + \msg_error:nnxn { semantex } { data_tl_not_found } { \l__semantex_data_tl_get_store_auxiliary_temp } { #2 } + } + { + \__semantex_data_tl_get_store_auxiliary:fnNn { \semantex_data_parent_get:n { #1 } } { #2 } #3 { #4 } + } } } -\cs_generate_variant:Nn \g_semantex_data_tl_get_store:nnN { nnc } +\cs_generate_variant:Nn \__semantex_data_tl_get_store_auxiliary:nnNn { fnNn } -\cs_new:Npn\g_semantex_data_tl_provide:nn#1#2 +\cs_generate_variant:Nn \semantex_data_tl_get_store:nnN { nnc } + +\cs_new:Npn\semantex_data_tl_provide:nn#1#2 { - \tl_if_exist:cF { semantex_data_tl_#1_#2 } + \tl_if_exist:cF { g__semantex_data_tl_#1_#2 } { - \tl_set:cn { semantex_data_tl_#1_#2 } {} + \tl_set:cn { g__semantex_data_tl_#1_#2 } {} } } -\cs_new:Npn\g_semantex_data_tl_inherit:nn#1#2 +\cs_new:Npn\semantex_data_tl_inherit:nn#1#2 { % #1 = object % #2 = piece of token list data @@ -1093,1756 +1222,3531 @@ % to the object #1. After this, no more inheritance is taking place % from the parent, and the data can be changed locally on the level % of #1. - \tl_if_exist:cF { semantex_data_tl_#1_#2 } - { - \g_semantex_data_tl_get_store:nnc { \g_semantex_data_tl_get:nn { #1 } { parent } } { #2 } { semantex_data_tl_#1_#2 } - } + \tl_if_exist:cF { g__semantex_data_tl_#1_#2 } { - \g_semantex_data_tl_get_store:nnc { \g_semantex_data_tl_get:nn { #1 } { parent } } { #2 } { semantex_data_tl_#1_#2 } - %IM could be replaced by simply { #1 } { #2 } once the check is made - %IM based on "if_provided" + \semantex_data_tl_get_store:nnc { \semantex_data_parent_get:n { #1 } } { #2 } { g__semantex_data_tl_#1_#2 } } } -\cs_new:Npn\g_semantex_data_tl_inherit_x:nn#1#2 -{ +\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. - \tl_if_exist:cF { semantex_data_tl_#1_#2 } + + +\cs_new: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 } + +\cs_new: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 } +} + +\cs_generate_variant:Nn \semantex_data_tl_put_right:nnn { nnx } + +\cs_new: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 } +} + +\cs_generate_variant:Nn \semantex_data_tl_put_left:nnn { nnx } + +\cs_new:Npn \semantex_data_tl_clear:nn#1#2 +{ + \semantex_data_tl_provide:nn { #1 } { #2 } + \tl_clear:c { g__semantex_data_tl_#1_#2 } +} + +% DATA OF TYPE INTEGER: + +\cs_new:Npn\semantex_data_int_provide:nn#1#2 +{ + \bool_if_exist:cTF { g__semantex_data_int_#1_#2_bool_if_provided } { - \g_semantex_data_tl_get_store:nnc { \g_semantex_data_tl_get:nn { #1 } { parent } } { #2 } { semantex_data_tl_#1_#2 } + \bool_if:cF { g__semantex_data_int_#1_#2_bool_if_provided } + { + \bool_set_true:c { g__semantex_data_int_#1_#2_bool_if_provided } + } } { - \g_semantex_data_tl_get_store:nnc { \g_semantex_data_tl_get:nn { #1 } { parent } } { #2 } { semantex_data_tl_#1_#2 } - %IM could be replaced by simply { #1 } { #2 } once the check is made - %IM based on "if_provided" + \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 } } } -\cs_new:Npn \g_semantex_data_tl_set:nnn#1#2#3 +\cs_new:Npn\semantex_data_int_inherit:nn#1#2 { - %\g_semantex_data_tl_provide:nn { #1 } { #2 } - \tl_set:cn { semantex_data_tl_#1_#2 } { #3 } + \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 } + \bool_set_true:c { g__semantex_data_int_#1_#2_bool_if_provided } + } + } + { + \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 } + } } -\cs_generate_variant:Nn \g_semantex_data_tl_set:nnn { nnx } +\cs_new:Npn \semantex_data_int_get:nn#1#2{% maybe should be PROTECTED?? + % #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 \g_semantex_data_tl_put_right:nnn#1#2#3 +\cs_new:Npn \__semantex_data_int_get_auxiliary:nnn#1#2#3{% maybe should be PROTECTED?? + % #1 = name of object + % #2 = the intuence to get + % #3 = the command to store it in + \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 } + { + \int_use:c { g__semantex_data_int_#1_#2 } + } + { + \str_if_eq:nnTF { #1 } { class_SemantexVariable } + { + \semantex_error_output_format:nN { #3 } \__semantex_data_int_get_auxiliary_temp + \msg_error:nnxn { semantex } { data_int_not_found } { \__semantex_data_int_get_auxiliary_temp } { #2 } + } + { + \__semantex_data_int_get_auxiliary:fnn { \semantex_data_parent_get:n { #1 } } { #2 } { #3 } + } + } + } + { + \str_if_eq:nnTF { #1 } { class_SemantexVariable } + { + \semantex_error_output_format:nN { #3 } \__semantex_data_int_get_auxiliary_temp + \msg_error:nnxn { semantex } { data_int_not_found } { \__semantex_data_int_get_auxiliary_temp } { #2 } + } + { + \__semantex_data_int_get_auxiliary:fnn { \semantex_data_parent_get:n { #1 } } { #2 } { #3 } + } + } +} + +\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?? + % #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?? + % #1 = name of object + % #2 = the intuence to get + % #3 = the command to store it in + \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 } + { + \int_set_eq:Nc#3 { g__semantex_data_int_#1_#2 } + } + { + \str_if_eq:nnTF { #1 } { class_SemantexVariable } + { + \semantex_error_output_format:nN { #4 } \l__semantex_data_int_get_store_auxiliary_temp + \msg_error:nnxn { semantex } { data_int_not_found } { \l__semantex_data_int_get_store_auxiliary_temp } { #2 } + } + { + \__semantex_data_int_get_store_auxiliary:fnNn { \semantex_data_parent_get:n { #1 } } { #2 } #3 { #4 } + } + } + } + { + \str_if_eq:nnTF { #1 } { class_SemantexVariable } + { + \semantex_error_output_format:nN { #4 } \l__semantex_data_int_get_store_auxiliary_temp + \msg_error:nnxn { semantex } { data_int_not_found } { \l__semantex_data_int_get_store_auxiliary_temp } { #2 } + } + { + \__semantex_data_int_get_store_auxiliary:fnNn { \semantex_data_parent_get:n { #1 } } { #2 } #3 { #4 } + } + } +} + +\cs_generate_variant:Nn \__semantex_data_int_get_store_auxiliary:nnNn { fnNn } + +\cs_generate_variant:Nn \semantex_data_int_get_store:nnN { nnc } + +\cs_new:Npn\semantex_data_int_incr:nn#1#2 { - \g_semantex_data_tl_inherit:nn { #1 } { #2 } - \tl_put_right:cn { semantex_data_tl_#1_#2 } { #3 } + \semantex_data_int_inherit:nn { #1 } { #2 } + \int_incr:c { g__semantex_data_int_#1_#2 } } -\cs_generate_variant:Nn \g_semantex_data_tl_put_right:nnn { nnx } +\cs_new: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 \g_semantex_data_tl_put_left:nnn#1#2#3 +\cs_new:Npn\semantex_data_int_if_positive:nnTF#1#2#3#4 { - \g_semantex_data_tl_inherit:nn { #1 } { #2 } - \tl_put_left:cn { semantex_data_tl_#1_#2 } { #3 } +% \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 \g_semantex_data_tl_put_left:nnn { nnx } +\cs_generate_variant:Nn\semantex_data_int_if_positive:nnTF { nnT } -\cs_new:Npn \g_semantex_data_tl_clear:nn#1#2 +\cs_new:Npn\semantex_data_int_if_positive:nnF#1#2#3 { - \g_semantex_data_tl_provide:nn { #1 } { #2 } - \tl_clear:c { semantex_data_tl_#1_#2 } + \semantex_data_int_if_positive:nnTF { #1 } { #2 } { } { #3 } } -\cs_new:Npn \g_semantex_data_seq_get_store:nnN#1#2#3{% maybe should be PROTECTED?? +\cs_new: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_clear:nn#1#2 +{ + \semantex_data_int_provide:nn { #1 } { #2 } + \int_zero:c { g__semantex_data_int_#1_#2 } +} + +% COMMANDS FOR HANDLING DATA OF SEQUENCE TYPE + +\cs_new:Npn \semantex_data_seq_get_store:nnN#1#2#3{% maybe should be PROTECTED?? % #1 = name of object % #2 = the sequence to get % #3 = the command to store it in - \bool_if_exist:cTF { semantex_data_seq_#1_#2_bool_if_provided } + \bool_if_exist:cTF { g__semantex_data_seq_#1_#2_bool_if_provided } { - \bool_if:cTF { semantex_data_seq_#1_#2_bool_if_provided } - { \seq_set_eq:Nc#3 { semantex_data_seq_#1_#2 } } - { \g_semantex_data_seq_get_store:vnN{ semantex_data_tl_#1_parent }{#2}#3 } + \bool_if:cTF { g__semantex_data_seq_#1_#2_bool_if_provided } + { + \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 + } } { - \g_semantex_data_seq_get_store:nnN{ \g_semantex_data_tl_get:nn { #1 } { parent } }{#2}#3% + \semantex_data_seq_get_store:nnN{ \semantex_data_parent_get:n { #1 } }{#2}#3% } } -\cs_generate_variant:Nn \g_semantex_data_seq_get_store:nnN { vnN, nnc, vnc } +\cs_generate_variant:Nn \semantex_data_seq_get_store:nnN { vnN, nnc, vnc } % Remove these later -\cs_new:Npn\g_semantex_data_seq_provide:nn#1#2 +\cs_new:Npn\semantex_data_seq_provide:nn#1#2 { - \bool_if_exist:cTF { semantex_data_seq_#1_#2_bool_if_provided } + \bool_if_exist:cTF { g__semantex_data_seq_#1_#2_bool_if_provided } { - \bool_if:cF { semantex_data_seq_#1_#2_bool_if_provided } + \bool_if:cF { g__semantex_data_seq_#1_#2_bool_if_provided } { - \seq_new:c { semantex_data_seq_#1_#2 } - \bool_set_true:c { semantex_data_seq_#1_#2_bool_if_provided } + \bool_set_true:c { g__semantex_data_seq_#1_#2_bool_if_provided } } } { - \bool_new:c { semantex_data_seq_#1_#2_bool_if_provided } - \bool_set_true:c { semantex_data_seq_#1_#2_bool_if_provided } - \seq_if_exist:cF { semantex_data_seq_#1_#2 } { - \seq_new:c { semantex_data_seq_#1_#2 } - } + \seq_new:c { 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 } } } -\cs_new:Npn\g_semantex_data_seq_inherit:nn#1#2 +\cs_new:Npn\semantex_data_seq_inherit:nn#1#2 { - \bool_if_exist:cTF { semantex_data_seq_#1_#2_bool_if_provided } + \bool_if_exist:cTF { g__semantex_data_seq_#1_#2_bool_if_provided } { - \bool_if:cF { semantex_data_seq_#1_#2_bool_if_provided } + \bool_if:cF { g__semantex_data_seq_#1_#2_bool_if_provided } { - \g_semantex_data_seq_get_store:vnc { semantex_data_tl_#1_parent } { #2 } { semantex_data_seq_#1_#2 } - \bool_set_true:c { semantex_data_seq_#1_#2_bool_if_provided } + \semantex_data_seq_get_store:nnc { \semantex_data_parent_get:n { #1 } } { #2 } { g__semantex_data_seq_#1_#2 } + \bool_set_true:c { g__semantex_data_seq_#1_#2_bool_if_provided } } } { - \bool_new:c { semantex_data_seq_#1_#2_bool_if_provided } - \bool_set_true:c { semantex_data_seq_#1_#2_bool_if_provided } - \seq_if_exist:cF { semantex_data_seq_#1_#2 } { \seq_new:c { semantex_data_seq_#1_#2 } } - \g_semantex_data_seq_get_store:vnc { semantex_data_tl_#1_parent } { #2 } { semantex_data_seq_#1_#2 } + \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 } } } } -\cs_new:Npn\g_semantex_data_seq_put_right:nnn#1#2#3 +\cs_new: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 { - \g_semantex_data_seq_inherit:nn { #1 } { #2 } - \seq_put_right:cn { semantex_data_seq_#1_#2 } { #3 } + \semantex_data_seq_provide:nn { #1 } { #2 } + \seq_clear:c { g__semantex_data_seq_#1_#2 } } -\cs_new:Npn \g_semantex_data_prop_provide:nn#1#2 +% COMMANDS FOR HANDLING DATA OF TYPE PROPERTY LIST: + +\cs_new:Npn \semantex_data_prop_provide:nn#1#2 { % #1 = name of the object % #2 = name of the prop - \prop_if_exist:cF { semantex_data_prop_#1_#2 } { \prop_new:c { semantex_data_prop_#1_#2 } } + \prop_if_exist:cF { g__semantex_data_prop_#1_#2 } { \prop_new:c { g__semantex_data_prop_#1_#2 } } } -\cs_new:Npn \g_semantex_data_prop_put:nnnn#1#2#3#4 +\cs_new:Npn \semantex_data_prop_put:nnnn#1#2#3#4 { - \prop_put:cnn { semantex_data_prop_#1_#2 } { #3 } { #4 } + \semantex_data_prop_provide:nn { #1 } { #2 } % important that we do not inherit! This is crucial for getting the right inheritance for key interfaces + \prop_put:cnn { g__semantex_data_prop_#1_#2 } { #3 } { #4 } +} + +\cs_new:Npn\semantex_data_prop_remove:nnn#1#2#3 +{ + \prop_if_exist:cT { g__semantex_data_prop_#1_#2 } + { + \prop_remove:cn { g__semantex_data_prop_#1_#2 } { #3 } + } } -\cs_new:Npn \g_semantex_valuekey_get:nnNTF#1#2#3#4#5{% +\cs_new:Npn \semantex_valuekey_get:nnNTF#1#2#3#4#5{% % #1 = name of the object % #2 = keyval data to get % #3 = command to store possible data in % #4 = if true (not to be used) % #5 = if false - \prop_get:cnNTF { semantex_data_prop_#1_custom_valuekeys } { #2 }#3%\l_semantex_valuekey_get_temp - { #4 } + \prop_get:cnNTF { g__semantex_data_prop_#1_custom_valuekeys } { #2 } #3 { - \tl_if_eq:nnTF { #1 } { semantexvariable } - { #5 } + #4 + } + { + \str_if_eq:nnTF { #1 } { class_SemantexVariable } + { + #5 + } { - \g_semantex_valuekey_get:xnNTF { \g_semantex_data_tl_get:nn { #1 } { parent } } { #2 } #3 { #4 } { #5 } + \semantex_valuekey_get:fnNTF { \semantex_data_parent_get:n { #1 } } { #2 } #3 { #4 } { #5 } } } } -\cs_generate_variant:Nn \g_semantex_valuekey_get:nnNTF { vnNTF, xnNTF } +\cs_new:Npn\semantex_valuekey_remove:nn#1#2 +{ + \semantex_data_prop_remove:nnn { #1 } { custom_valuekeys } { #2 } +} -\cs_new:Npn \g_semantex_novaluekey_get:nnNTF#1#2#3#4#5{% +\cs_generate_variant:Nn \semantex_valuekey_get:nnNTF { fnNTF, vnNTF, xnNTF } + +\cs_new:Npn \semantex_singlekey_get:nnNTF#1#2#3#4#5{% % #1 = name of the object % #2 = singlekey data to get % #3 = command to store possible data in % #4 = if true (not to be used) % #5 = if false - \prop_get:cnNTF { semantex_data_prop_#1_custom_novaluekeys } { #2 } #3 - { #4 } + \prop_get:cnNTF { g__semantex_data_prop_#1_custom_singlekeys } { #2 } #3 + { + #4 + } { - \tl_if_eq:nnTF { #1 } { semantexvariable } - { #5 } + \str_if_eq:nnTF { #1 } { class_SemantexVariable } + { + #5 + } { - \g_semantex_novaluekey_get:xnNTF { \g_semantex_data_tl_get:nn { #1 } { parent } } { #2 } #3 { #4 } { #5 } + \semantex_singlekey_get:fnNTF { \semantex_data_parent_get:n { #1 } } { #2 } #3 { #4 } { #5 } } } } -\cs_generate_variant:Nn \g_semantex_novaluekey_get:nnNTF { vnNTF, xnNTF } +\cs_new:Npn\semantex_singlekey_remove:nn#1#2 +{ + \semantex_data_prop_remove:nnn { #1 } { custom_singlekeys } { #2 } +} -%\cs_new:N\l_semantex_arg_valuekey_get_parent_temp +\cs_generate_variant:Nn \semantex_singlekey_get:nnNTF { fnNTF, vnNTF, xnNTF } -\cs_new:Npn \g_semantex_arg_valuekey_get:nnNTF#1#2#3#4#5{% +\cs_new:Npn \semantex_arg_valuekey_get:nnNTF#1#2#3#4#5{% % #1 = name of the object % #2 = keyval data to get % #3 = command to store possible data in % #4 = if true (not to be used) % #5 = if false - \prop_get:cnNTF { semantex_data_prop_#1_custom_arg_valuekeys } { #2 }#3%\l_semantex_valuekey_get_temp - { #4 } + \prop_get:cnNTF { g__semantex_data_prop_#1_custom_arg_valuekeys } { #2 }#3%\l_semantex_valuekey_get_temp + { + #4 + } { - \tl_if_eq:nnTF { #1 } { semantexvariable } - { #5 } + \str_if_eq:nnTF { #1 } { class_SemantexVariable } + { + #5 + } { - \g_semantex_arg_valuekey_get:xnNTF { \g_semantex_data_tl_get:nn { #1 } { parent } } { #2 } #3 { #4 } { #5 } + \semantex_arg_valuekey_get:fnNTF { \semantex_data_parent_get:n { #1 } } { #2 } #3 { #4 } { #5 } } } } -\cs_generate_variant:Nn \g_semantex_arg_valuekey_get:nnNTF { vnNTF, xnNTF } +\cs_generate_variant:Nn \semantex_arg_valuekey_get:nnNTF { fnNTF, vnNTF, xnNTF } + +\cs_new:Npn\semantex_arg_valuekey_remove:nn#1#2 +{ + \semantex_data_prop_remove:nnn { #1 } { custom_arg_valuekeys } { #2 } +} -\prop_new:N\l_semantex_arg_valuekey_get_temp -\cs_new:Npn \g_semantex_arg_novaluekey_get:nnNTF#1#2#3#4#5{% +\cs_new:Npn \semantex_arg_singlekey_get:nnNTF#1#2#3#4#5{% % #1 = name of the object % #2 = singlekey data to get % #3 = command to store possible data in % #4 = if true (not to be used) % #5 = if false - \prop_get:cnNTF { semantex_data_prop_#1_custom_arg_novaluekeys } { #2 } #3 - { #4 } + \prop_get:cnNTF { g__semantex_data_prop_#1_custom_arg_singlekeys } { #2 } #3 { - \tl_if_eq:nnTF { #1 } { semantexvariable } - { #5 } { \g_semantex_arg_novaluekey_get:xnNTF { \g_semantex_data_tl_get:nn { #1 } { parent } } { #2 } #3 { #4 } { #5 } } + #4 } + { + \str_if_eq:nnTF { #1 } { class_SemantexVariable } + { + #5 + } + { + \semantex_arg_singlekey_get:fnNTF { \semantex_data_parent_get:n { #1 } } { #2 } #3 { #4 } { #5 } + } + } +} + +\cs_generate_variant:Nn \semantex_arg_singlekey_get:nnNTF { fnNTF, vnNTF, xnNTF } + +\cs_new:Npn\semantex_arg_singlekey_remove:nn#1#2 +{ + \semantex_data_prop_remove:nnn { #1 } { custom_arg_singlekeys } { #2 } } -\cs_generate_variant:Nn \g_semantex_arg_novaluekey_get:nnNTF { vnNTF, xnNTF } +% COMMANDS FOR HANDLING DATA OF TYPE BOOLEAN: -\cs_new:Npn\g_semantex_data_bool_get:nnTF#1#2#3#4 +\cs_new:Npn\semantex_data_bool_get:nnTF#1#2#3#4 { % #1 = name of the object % #2 = boolean to get % #3 = if true % #4 = if false - \bool_if_exist:cTF { semantex_data_bool_#1_if_#2_bool_if_provided } + \bool_if_exist:cTF { g__semantex_data_bool_#1_if_#2_bool_if_provided } { - \bool_if:cTF { semantex_data_bool_#1_if_#2_bool_if_provided } + \bool_if:cTF { g__semantex_data_bool_#1_if_#2_bool_if_provided } { - \bool_if:cTF { semantex_data_bool_#1_if_#2 } { #3 } { #4 } + \bool_if:cTF { g__semantex_data_bool_#1_if_#2 } { #3 } { #4 } } { - \tl_if_eq:nnTF { #1 } { semantexvariable } - { #4 } { \g_semantex_data_bool_get:xnTF { \g_semantex_data_tl_get:nn { #1 } { parent } } { #2 } { #3 } { #4 } } + \str_if_eq:nnTF { #1 } { class_SemantexVariable } + { + #4 + } + { + \semantex_data_bool_get:fnTF { \semantex_data_parent_get:n { #1 } } { #2 } { #3 } { #4 } + } } } { - \tl_if_eq:nnTF { #1 } { semantexvariable } - { #4 } { \g_semantex_data_bool_get:xnTF { \g_semantex_data_tl_get:nn { #1 } { parent } } { #2 } { #3 } { #4 } } + \str_if_eq:nnTF { #1 } { class_SemantexVariable } + { + #4 + } + { + \semantex_data_bool_get:fnTF { \semantex_data_parent_get:n { #1 } } { #2 } { #3 } { #4 } + } } } -\cs_generate_variant:Nn \g_semantex_data_bool_get:nnTF { xnTF, vnTF } +\cs_generate_variant:Nn \semantex_data_bool_get:nnTF { onTF, fnTF, xnTF, vnTF, nnT } -\cs_new:Npn\g_semantex_data_bool_provide:nn#1#2 +\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 { % #1 = name of the object % #2 = boolean to provide - \bool_if_exist:cTF { semantex_data_bool_#1_if_#2_bool_if_provided } + \bool_if_exist:cTF { g__semantex_data_bool_#1_if_#2_bool_if_provided } { - \bool_if:cF { semantex_data_bool_#1_if_#2_bool_if_provided } - { \bool_set_true:c { semantex_data_bool_#1_if_#2_bool_if_provided } } + \bool_if:cF { g__semantex_data_bool_#1_if_#2_bool_if_provided } + { + \bool_set_true:c { g__semantex_data_bool_#1_if_#2_bool_if_provided } + } } { - \bool_new:c { semantex_data_bool_#1_if_#2 } - \bool_new:c { semantex_data_bool_#1_if_#2_bool_if_provided } - \bool_set_true:c { semantex_data_bool_#1_if_#2_bool_if_provided } + \bool_new:c { g__semantex_data_bool_#1_if_#2 } + \bool_new:c { g__semantex_data_bool_#1_if_#2_bool_if_provided } + \bool_set_true:c { g__semantex_data_bool_#1_if_#2_bool_if_provided } } } -\cs_new:Npn\g_semantex_data_bool_set_true:nn#1#2 +\cs_new:Npn\semantex_data_bool_set_true:nn#1#2 { % #1 = name of the object % #2 = boolean to provide - \g_semantex_data_bool_provide:nn { #1 } { #2 } - \bool_set_true:c { semantex_data_bool_#1_if_#2 } + \semantex_data_bool_provide:nn { #1 } { #2 } + \bool_set_true:c { g__semantex_data_bool_#1_if_#2 } } -\cs_new:Npn\g_semantex_data_bool_set_false:nn#1#2 +\cs_new:Npn\semantex_data_bool_set_false:nn#1#2 { % #1 = name of the object % #2 = boolean to provide - \g_semantex_data_bool_provide:nn { #1 } { #2 } - \bool_set_false:c { semantex_data_bool_#1_if_#2 } + \semantex_data_bool_provide:nn { #1 } { #2 } + \bool_set_false:c { g__semantex_data_bool_#1_if_#2 } } -\cs_new:Npn\g_semantex_data_cs_get:nnn#1#2#3 +% COMMANDS FOR HANDLING COMMAND SEQUENCE DATA AND KEYVAL SYNTAX: + +\cs_new:Npn\semantex_data_cs_get:nnn#1#2#3 { % #1 = name of the object % #2 = command sequence to get % #3 = what to apply said command sequence to - \cs_if_exist:cTF { g_semantex_data_cs_#1_#2:n } - { \use:c { g_semantex_data_cs_#1_#2:n } { #3 } } + \cs_if_exist:cTF { __semantex_data_cs_#1_#2:n } + { + \use:c { __semantex_data_cs_#1_#2:n } { #3 } + } { - \tl_if_eq:nnTF { #1 } { semantexvariable } + \str_if_eq:nnTF { #1 } { class_SemantexVariable } { % should probably throw an error by now, but later! } { - \g_semantex_data_cs_get:xnn { \g_semantex_data_tl_get:nn{#1}{parent} } { #2 } { #3 } + \semantex_data_cs_get:xnn { \semantex_data_parent_get:n {#1} } { #2 } { #3 } } } } -\cs_generate_variant:Nn \g_semantex_data_cs_get:nnn { xnn } +\cs_generate_variant:Nn \semantex_data_cs_get:nnn { xnn } + +\cs_generate_variant:Nn \keyval_parse:NNn { cco } -\cs_new:Npn \g_semantex_keys_set:nn#1#2 +\cs_new:Npn \semantex_keys_set:nn#1#2 { + % The central command for doing keyval setup % #1 = object % #2 = keys - \keyval_parse:cco %IM think about wthether o-type is really necessary. - { g_semantex_data_cs_#1_novaluekey:n } - { g_semantex_data_cs_#1_valuekey:nn } + \keyval_parse:cco % Could be nice to get rid of o-type expansion, but so far has not been possible + { __semantex_data_cs_#1_singlekey:n } + { __semantex_data_cs_#1_valuekey:nn } { #2 } } -\cs_new:Npn \g_semantex_arg_keys_set:nn#1#2 +\cs_new:Npn \semantex_arg_keys_set:nn#1#2 { + % The central command for doing keyval setup for the argument % #1 = object % #2 = keys - \keyval_parse:cco %IM -||- - { g_semantex_data_cs_#1_arg_novaluekey:n } - { g_semantex_data_cs_#1_arg_valuekey:nn } + \keyval_parse:cco % See last command + { __semantex_data_cs_#1_arg_singlekey:n } + { __semantex_data_cs_#1_arg_valuekey:nn } { #2 } } \cs_generate_variant:Nn \clist_map_function:nN { nc } -\cs_new:Npn \g_semantex_arg_novaluekeys_set:nn#1#2 +\cs_new:Npn \semantex_arg_singlekeys_set:nn#1#2 { - \clist_map_function:nc {#2} { g_semantex_data_cs_#1_arg_novaluekey:n } + % 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 + \clist_map_function:nc {#2} { __semantex_data_cs_#1_arg_singlekey:n } } -\DeclareDocumentCommand\setupclass{mm}{ % a user-level command for setting up the object +\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 - %\exp_args:Nx - \g_semantex_keys_set:nn { #1 }{ #2 } + \semantex_keys_set:xn { class_\cs_to_str:N #1 }{ #2 } } -\DeclareDocumentCommand\setupobject{mm}{% +\DeclareDocumentCommand\SetupObject{mm}{% % #1 = object % #2 = setup - \g_semantex_keys_set:nn { \cs_to_str:N #1 } { #2 } + \semantex_keys_set:xn { object_\cs_to_str:N #1 } { #2 } } +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% THE PRIMITIVE VALUEKEYS +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Now for the commands that are the basis of the keyval interface. +% This basis consists of a collection of so-called "primitive" +% valuekeys, which all use the syntax +% \semantex_primitive_<nameOfValuekey>:nn +% These are like primitive TeX commands -- they are not defined in +% terms of other keys, and all other keys have to defined in terms +% of these, one way or another. + +% For all of them, #1 = name of the class/object, and #2 = value of +% the key. To keep the system as simple as possible, I chose only to +% make primitive valuekeys, so there is no such thing as a primitive +% singlekey. Therefore, for instance, the singlekey "return" is +% defined as "return=", where return is a primitive valuekey that +% does not use the value of the key for anything. + +% 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} -% Now for the commands that implement the keyval interface. -% These commands are used by the command \g_semantex_data_cs_#1_keys_set, see -% above. -% There is a fixed collection of primitive commands. -% Furthermore, the user has the option to create a collection -% of new commands, which are all stored in the property list -% called \semantex_data_prop_#1_custom_valuekeys -% These valuekeys contain code that must be executable by other keys -% (e.g., primitive ones) -% The key value is accessible to the user via the temporary command -% \l_semantex_key_value_temp - -\providecommand\semantexdataprovide{} -\providecommand\semantexdataset{} -\providecommand\semantexdatasetx{} -\providecommand\semantexdataputright{} -\providecommand\semantexdataputrightx{} -\providecommand\semantexdataputleft{} -\providecommand\semantexdataputleftx{} -\providecommand\semantexdataget{} -\providecommand\semantexdatagetexpnot{} -\providecommand\semantexdataclear{} -\providecommand\semantexsetkeys{} -\providecommand\semantexsetkeysx{} -\providecommand\semantexstrifeq{} -\providecommand\semantexboolprovide{} -\providecommand\semantexboolsettrue{} -\providecommand\semantexboolsetfalse{} -\providecommand\semantexboolif{} - -% CHANGE TO CAMEL CASE! +\cs_generate_variant:Nn\str_if_eq:nnF {xxF, ooF} +\cs_generate_variant:Nn\tl_if_blank:nTF { xTF, xT } -\cs_generate_variant:Nn\str_if_eq:nnTF {xxTF,ooTF} +\cs_generate_variant:Nn \tl_if_blank:nF { xF } -\cs_new:Npn\g_semantex_primitive_valuekey_execute:nn#1#2 -{ - \renewcommand\semantexdataprovide[1]{\g_semantex_data_tl_provide:nn{#1}{##1}} - \renewcommand\semantexdataset[2]{\g_semantex_data_tl_set:nnn{#1}{##1}{##2}} - \renewcommand\semantexdatasetx[2]{\g_semantex_data_tl_set:nnx{#1}{##1}{##2}} - \renewcommand\semantexdataputright[2]{\g_semantex_data_tl_put_right:nnn{#1}{##1}{##2}} - \renewcommand\semantexdataputrightx[2]{\g_semantex_data_tl_put_right:nnx{#1}{##1}{##2}} - \renewcommand\semantexdataputleft[2]{\g_semantex_data_tl_put_left:nnn{#1}{##1}{##2}} - \renewcommand\semantexdataputleftx[2]{\g_semantex_data_tl_put_left:nnx{#1}{##1}{##2}} - \renewcommand\semantexdataget[1]{\g_semantex_data_tl_get:nn{#1}{##1}} - \renewcommand\semantexdatagetexpnot[1]{\g_semantex_data_tl_get_exp_not:nn{#1}{##1}} - \renewcommand\semantexdataclear[1]{\g_semantex_data_tl_clear:nn{#1}{##1}} - \renewcommand\semantexsetkeys[1]{\g_semantex_keys_set:nn{#1}{##1}} - \renewcommand\semantexsetkeysx[1]{\g_semantex_keys_set:nx{#1}{##1}} - \renewcommand\semantexstrifeq[4]{\str_if_eq:xxTF{##1}{##2}{##3}{##4}} - \renewcommand\semantexboolprovide[1]{\g_semantex_data_bool_provide:nn{#1}{##1}} - \renewcommand\semantexboolsettrue[1]{\g_semantex_data_bool_set_true:nn{#1}{##1}} - \renewcommand\semantexboolsetfalse[1]{\g_semantex_data_bool_set_false:nn{#1}{##1}} - \renewcommand\semantexboolif[3]{\g_semantex_data_bool_get:nnTF{#1}{##1}{##2}{##3}} +\cs_new:Npn\semantex_primitive_valuekey_execute:nn#1#2 +{ + % 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}{##1}} + \cs_set:Npn\SemantexDataSet##1##2{\semantex_data_tl_set:nnn{#1}{##1}{##2}} + \cs_set:Npn\SemantexDataSetx##1##2{\semantex_data_tl_set:nnx{#1}{##1}{##2}} + \cs_set:Npn\SemantexDataPutRight##1##2{\semantex_data_tl_put_right:nnn{#1}{##1}{##2}} + \cs_set:Npn\SemantexDataPutRightx##1##2{\semantex_data_tl_put_right:nnx{#1}{##1}{##2}} + \cs_set:Npn\SemantexDataPutLeft##1##2{\semantex_data_tl_put_left:nnn{#1}{##1}{##2}} + \cs_set:Npn\SemantexDataPutLeftx##1##2{\semantex_data_tl_put_left:nnx{#1}{##1}{##2}} + \cs_set:Npn\SemantexDataGet##1{\semantex_data_tl_get:nn{#1}{##1}} + \cs_set:Npn\SemantexDataGetExpNot##1{\semantex_data_tl_get_exp_not:nn{#1}{##1}} + \cs_set:Npn\SemantexDataClear##1{\semantex_data_tl_clear:nn{#1}{##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}{##1}} + \cs_set:Npn\SemantexBoolSetTrue##1{\semantex_data_bool_set_true:nn{#1}{##1}} + \cs_set:Npn\SemantexBoolSetFalse##1{\semantex_data_bool_set_false:nn{#1}{##1}} + \cs_set:Npn\SemantexBoolIfTF##1##2##3{\semantex_data_bool_get:nnTF{#1}{##1}{##2}{##3}} + \cs_set:Npn\SemantexBoolIfT##1##2{\semantex_data_bool_get:nnTF{#1}{##1}{##2}{}} + \cs_set:Npn\SemantexBoolIfF##1##2{\semantex_data_bool_get:nnTF{#1}{##1}{}{##2}} + \cs_set:Npn\SemantexIntProvide##1{\semantex_data_int_provide:nn{#1}{##1}} + \cs_set:Npn\SemantexIntGet##1{\semantex_data_int_get:nn{#1}{##1}} + \cs_set:Npn\SemantexIntClear##1{\semantex_data_int_clear:nn{#1}{##1}} + \cs_set:Npn\SemantexIntIncr##1{\semantex_data_int_incr:nn{#1}{##1}} + \cs_set:Npn\SemantexIntSet##1##2{\semantex_data_int_set:nnn{#1}{##1}{##2}} + \cs_set:Npn\SemantexIntIfPositiveTF##1##2##3{\semantex_data_int_if_positive:nnTF{#1}{##1}{##2}{##3}} + \cs_set:Npn\SemantexIntIfPositiveT##1##2{\semantex_data_int_if_positive:nnT{#1}{##1}{##2}} + \cs_set:Npn\SemantexIntIfPositiveF##1##2{\semantex_data_int_if_positive:nnF{#1}{##1}{##2}} + \cs_set:Npn\SemantexIntIfGreaterThanOneTF##1##2##3{\semantex_data_int_if_greater_than_one:nnTF{#1}{##1}{##2}{##3}} + \cs_set:Npn\SemantexIntIfGreaterThanOneT##1##2{\semantex_data_int_if_greater_than_one:nnT{#1}{##1}{##2}} + \cs_set:Npn\SemantexIntIfGreaterThanOneF##1##2{\semantex_data_int_if_greater_than_one:nnF{#1}{##1}{##2}} + \cs_set:Npn\SemantexExpNot##1{\exp_not:n{##1}} %\exp_not:n{#2} - % how about erase and forget? + % how about forget? #2 } -\cs_new:Npn\g_semantex_primitive_valuekey_parse:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_parse:nn#1#2 { - \g_semantex_data_tl_inherit:nn { #1 } { parseoptions } - % But we need to also reset this, plus all data variables that - % it used; nope, not necessary - \g_semantex_keys_set:nx { #1 } { - \g_semantex_data_tl_get_exp_not:nn { #1 } { parseoptions } + % 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 } -\cs_new:Npn\g_semantex_primitive_valuekey_parseoptions:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_parseoptions:nn#1#2 { - \g_semantex_data_tl_put_right:nnn { #1 } { parseoptions } { #2 } + % This adds keys to the parseoptions token list + \semantex_data_tl_put_right:nnn { #1 } { parseoptions } { #2 } } -\cs_new:Npn\g_semantex_primitive_valuekey_return:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_return:nn#1#2 { - \g_semantex_primitive_valuekey_innerreturn:nn { #1 }{} - \g_semantex_primitive_valuekey_rightreturn:nn { #1 }{} - \g_semantex_primitive_valuekey_leftreturn:nn { #1 }{} + % This is an umbrella key that runs all of the three + % return routines, innerreturn, rightreturn, and leftreturn + \semantex_primitive_valuekey_innerreturn:nn { #1 }{} + \semantex_primitive_valuekey_rightreturn:nn { #1 }{} + \semantex_primitive_valuekey_leftreturn:nn { #1 }{} } -\cs_new:Npn\g_semantex_primitive_valuekey_innerreturn:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_innerreturn:nn#1#2 { - \g_semantex_data_tl_inherit:nn { #1 } { symbol } - \g_semantex_data_seq_inherit:nn { #1 } { commands_sequence } - \g_semantex_data_seq_get_store:nnN { #1 } { commands_sequence } \l__semantex_data_seq_commands_sequence_temp - %\seq_map_inline:cn { semantex_data_seq_#1_commands_sequence } + % 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 { - \g_semantex_data_tl_set:nnx { #1 } { symbol } + \semantex_data_tl_set:nnx { #1 } { symbol } { \exp_not:n {\exp_not:N ##1} { - \g_semantex_data_tl_get_exp_not:nn { #1 } { symbol } + \semantex_data_tl_get_exp_not:nn { #1 } { symbol } } % This was the solution that happened to solve % the expansion issues best } } - \seq_clear:c { semantex_data_seq_#1_commands_sequence } -} - -\tl_new:N\l__semantex_rightreturn_par_temp - -\tl_new:N\l__semantex_rightreturn_nopar_temp - -\cs_generate_variant:Nn \g_semantex_keys_set:nn { nx , no } - -\cs_new:Npn\g_semantex_primitive_valuekey_rightreturn:nn#1#2 -{ - \g_semantex_data_tl_inherit_x:nn { #1 } { upper_index } - \g_semantex_data_tl_inherit_x:nn { #1 } { lower_index } - \g_semantex_data_tl_inherit_x:nn { #1 } { preupper } - \g_semantex_data_tl_inherit_x:nn { #1 } { postupper } - \g_semantex_data_tl_inherit_x:nn { #1 } { prelower } - \g_semantex_data_tl_inherit_x:nn { #1 } { postlower } - \g_semantex_data_tl_inherit_x:nn { #1 } { arg } - \g_semantex_data_tl_get_store:nnN { #1 } { upper_index } \l__semantex_rightreturn_upper_index_temp - \g_semantex_data_tl_get_store:nnN { #1 } { lower_index } \l__semantex_rightreturn_lower_index_temp - \g_semantex_data_tl_get_store:nnN { #1 } { symbol } \l__semantex_rightreturn_symbol_temp - \g_semantex_data_tl_get_store:nnN { #1 } { preupper } - \l__semantex_rightreturn_preupper_temp - \g_semantex_data_tl_get_store:nnN { #1 } { postupper } - \l__semantex_rightreturn_postupper_temp - \g_semantex_data_tl_get_store:nnN { #1 } { prelower } - \l__semantex_rightreturn_prelower_temp - \g_semantex_data_tl_get_store:nnN { #1 } { postlower } - \l__semantex_rightreturn_postlower_temp - \g_semantex_data_tl_set:nnx { #1 } { symbol } - { - \exp_not:V \l__semantex_rightreturn_symbol_temp - % Setup indices: - \exp_not:N\g_semantex_right_indices:nnnnnn - { \exp_not:V \l__semantex_rightreturn_preupper_temp } - { \exp_not:V \l__semantex_rightreturn_upper_index_temp } - { \exp_not:V \l__semantex_rightreturn_postupper_temp } - { \exp_not:V \l__semantex_rightreturn_prelower_temp } - { \exp_not:V \l__semantex_rightreturn_lower_index_temp } - { \exp_not:V \l__semantex_rightreturn_postlower_temp } - } - \g_semantex_data_bool_get:nnTF { #1 } { par } - { - \g_semantex_data_tl_get_store:nnN { #1 } { par_size } - \l__semantex_rightreturn_par_size_temp - \g_semantex_data_tl_get_store:nnN { #1 } { par_open } \l__semantex_rightreturn_par_open_temp - \g_semantex_data_tl_get_store:nnN { #1 } { par_close } \l__semantex_rightreturn_par_close_temp - \g_semantex_data_tl_get_store:nnN { #1 } { arg } \l__semantex_rightreturn_arg_temp - \g_semantex_data_tl_get_store:nnN { #1 } { prearg } \l_semantex_rightreturn_prearg_temp - \g_semantex_data_tl_get_store:nnN { #1 } { postarg } \l_semantex_rightreturn_postarg_temp - \tl_set:Nx\l__semantex_rightreturn_par_temp - { - { \exp_not:V \l__semantex_rightreturn_par_size_temp } - { \exp_not:V \l__semantex_rightreturn_par_open_temp } - { \exp_not:V \l__semantex_rightreturn_par_close_temp } - { \exp_not:V \l_semantex_rightreturn_prearg_temp } - { \exp_not:V \l__semantex_rightreturn_arg_temp } - { \exp_not:V \l_semantex_rightreturn_postarg_temp } - } - \tl_put_left:Nn\l__semantex_rightreturn_par_temp + \semantex_data_seq_clear:nn { #1 } { commands_sequence } +} + +\cs_generate_variant:Nn \semantex_keys_set:nn { nx , no } + +\cs_new:Npn\semantex_primitive_valuekey_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:N - \g_semantex_parentheses:nnnnnn + \exp_not:V\l_semantex_rightreturn_arg_temp } - \g_semantex_data_tl_put_right:nnx { #1 } { symbol } + } +} + + +\cs_new:Npn\semantex_primitive_valuekey_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_rightreturn_par_temp + \exp_not:V\l_semantex_leftreturn_arg_temp } } { - \tl_set:Nx\l__semantex_rightreturn_nopar_temp + % 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 } { - { \g_semantex_data_tl_get_exp_not:nn { #1 } { prearg } } - { \g_semantex_data_tl_get_exp_not:nn { #1 } { arg } } - { \g_semantex_data_tl_get_exp_not:nn { #1 } { postarg } } + \tl_put_right:Nx#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 } + } + \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_left:Nn\l__semantex_rightreturn_nopar_temp { - \exp_not:N - \g_semantex_no_parentheses:nnn + \tl_put_right:Nx#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 } + } + } + } + } + { + \semantex_data_int_if_positive:nnTF { #1 } { numberoflowerleftindices } + { + \tl_put_right:Nx#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 } + } + } } - \g_semantex_data_tl_put_right:nnx { #1 } { symbol } { - \exp_not:V\l__semantex_rightreturn_nopar_temp + % do nothing } } - \g_semantex_data_tl_clear:nn { #1 } { upper_index } - \g_semantex_data_bool_provide:nn { #1 } { first_upper } - \g_semantex_data_bool_set_true:nn { #1 } { first_upper } - \g_semantex_data_tl_clear:nn { #1 } { lower_index } - \g_semantex_data_bool_provide:nn { #1 } { first_lower } - \g_semantex_data_bool_set_true:nn { #1 } { first_lower } - \g_semantex_data_tl_clear:nn { #1 } { arg } - \g_semantex_data_bool_provide:nn { #1 } { first_arg } - \g_semantex_data_bool_set_true:nn { #1 } { first_arg } - \g_semantex_data_tl_clear:nn { #1 } { preupper } - \g_semantex_data_tl_clear:nn { #1 } { postupper } - \g_semantex_data_tl_clear:nn { #1 } { prelower } - \g_semantex_data_tl_clear:nn { #1 } { postlower } - %IM maybe one should enclose the new symbol in another group - %IM Maybe should also reset stuff like par size - %IM reset leftpar, rightpar, parsize etc. also + \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\g_semantex_primitive_valuekey_leftreturn:nn#1#2 +\cs_new:Npn \semantex_arg_return_store:nN#1#2 { - \g_semantex_data_tl_inherit_x:nn { #1 } { upper_left_index } - \g_semantex_data_tl_inherit_x:nn { #1 } { lower_left_index } - \g_semantex_data_tl_inherit_x:nn { #1 } { preupperleft } - \g_semantex_data_tl_inherit_x:nn { #1 } { postupperleft } - \g_semantex_data_tl_inherit_x:nn { #1 } { prelowerleft } - \g_semantex_data_tl_inherit_x:nn { #1 } { postlowerleft } - %IMPLEMENT THIS!!! - % Clean up the following names - \g_semantex_data_tl_get_store:nnN { #1 } { upper_left_index } \l__semantex_leftreturn_upper_left_index_temp - \g_semantex_data_tl_get_store:nnN { #1 } { lower_left_index } \l__semantex_leftreturn_lower_left_index_temp - \g_semantex_data_tl_get_store:nnN { #1 } { symbol } \l__semantex_leftreturn_symbol_temp - \g_semantex_data_tl_get_store:nnN { #1 } { preupperleft } \l__semantex_leftreturn_preupperleft_temp - \g_semantex_data_tl_get_store:nnN { #1 } { postupperleft } \l__semantex_leftreturn_postupperleft_temp - \g_semantex_data_tl_get_store:nnN { #1 } { prelowerleft } \l__semantex_leftreturn_prelowerleft_temp - \g_semantex_data_tl_get_store:nnN { #1 } { postlowerleft } \l__semantex_leftreturn_postlowerleft_temp - \g_semantex_data_tl_set:nnx { #1 } { symbol } + \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__semantex_primitive_valuekey_rightreturn_parsize_temp + \semantex_data_bool_get:nnTF { #1 } { par } { - % Setup indices: - \exp_not:N\g_semantex_left_indices:nnnnnn + \semantex_data_int_if_positive:nnTF { #1 } { numberofarguments } { - \exp_not:V \l__semantex_leftreturn_preupperleft_temp + \__semantex_parentheses_store:nnnnN + { \l__semantex_primitive_valuekey_rightreturn_parsize_temp } + { \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 } + } + #2 } { - \exp_not:V \l__semantex_leftreturn_upper_left_index_temp + \tl_set:Nn#2{} } + } + { + \semantex_data_bool_get:nnTF { #1 } { flexpar } { - \exp_not:V \l__semantex_leftreturn_postupperleft_temp + \semantex_data_int_if_greater_than_one:nnTF { #1 } { numberofarguments } + { + \__semantex_parentheses_store:nnnnN + { \l__semantex_primitive_valuekey_rightreturn_parsize_temp } + { \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 } + } + #2 + } + { + \semantex_data_int_if_positive:nnTF { #1 } { numberofarguments } + { + \__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 + } + { + \tl_set:Nn#2{} + } + } } { - \exp_not:V \l__semantex_leftreturn_prelowerleft_temp + \semantex_data_int_if_positive:nnTF { #1 } { numberofarguments } + { + \__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 + } + { + \tl_set:Nn#2{} + } } + } + \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 { - \exp_not:V \l__semantex_leftreturn_lower_left_index_temp + \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 + } + \semantex_data_int_if_positive:nnTF { #1 } { numberoflowerindices } + { + \tl_put_right:Nx#2 { - \exp_not:V \l__semantex_leftreturn_postlowerleft_temp + \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 } + } } - \exp_not:V \l__semantex_leftreturn_symbol_temp } - \g_semantex_data_tl_clear:nn { #1 } { upper_left_index } - \g_semantex_data_bool_provide:nn { #1 } { first_upper_left } - \g_semantex_data_bool_set_true:nn { #1 } { first_upper_left } - \g_semantex_data_tl_clear:nn { #1 } { lower_left_index } - \g_semantex_data_bool_provide:nn { #1 } { first_lower_left } - \g_semantex_data_bool_set_true:nn { #1 } { first_lower_left } - \g_semantex_data_tl_clear:nn { #1 } { preupperleft } - \g_semantex_data_tl_clear:nn { #1 } { postupperleft } - \g_semantex_data_tl_clear:nn { #1 } { prelowerleft } - \g_semantex_data_tl_clear:nn { #1 } { postlowerleft } + { + % 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\g_semantex_primitive_valuekey_parent:nn#1#2{ + +\cs_new:Npn\semantex_primitive_valuekey_parent:nn#1#2{ % Must inherit everything from the parent class - %\tl_clear_new:c { semantex_data_tl_#1_parent } - %\g_semantex_data_tl_provide:nn { #1 } { parent } - %IM This should always be declared, so no need for if_provided checks - %IM This does not work, for unknown reasons: -% \seq_if_in:NxTF \semantex_all_objects_seq { #2 } -% { \tl_set:cn { semantex_data_tl_#1_parent } { #2 } } -% { \msg_error:nnnn { semantex } { parent_not_found } { #2 } { #1 } } - %IM control if exists! - %\tl_set:cn { semantex_data_tl_#1_parent } { #2 } - \g_semantex_data_tl_set:nnn { #1 } { parent } { #2 } + \semantex_data_parent_set:nn { #1 } { #2 } } -\cs_set_eq:NN\g_semantex_primitive_valuekey_class:nn\g_semantex_primitive_valuekey_parent:nn +\cs_new:Npn\semantex_primitive_valuekey_class:nn#1#2{ + % Must inherit everything from the parent class + \semantex_data_class_set:nn { #1 } { #2 } +} +\cs_new:Npn\semantex_primitive_valuekey_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_primitive_valuekey_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\g_semantex_primitive_valuekey_copy:nn#1#2{ - % Must inherit everything from the parent class - \g_semantex_primitive_valuekey_parent:nn{#1}{ \cs_to_str:N #2 } +\cs_new:Npn\semantex_primitive_valuekey_valuekeys:nn#1#2{ + % Add new valuekeys + \semantex_data_prop_provide:nn { #1 } { custom_valuekeys } + \clist_map_inline:nn { #2 }{ + \__semantex_valuekey_equality_format_auxiliary:nnn{#1}##1 + } } -\cs_new:Npn\g_semantex_primitive_valuekey_valuekeys:nn#1#2{ - % Add new valuekeys via the interface - % valuekeys={ - % {key1}{do something with \l_semantex_key_value_temp}, - % {key2}{g=\l_semantex_key_value_temp,i=\l_semantex_key_value_temp}, - % } - \g_semantex_data_prop_provide:nn { #1 } { custom_valuekeys } +\cs_generate_variant:Nn\semantex_data_prop_put:nnnn {nnno} + +\cs_new:Npn\__semantex_valuekey_equality_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_valuekey_equality_format_auxiliary_temp:n##1{#3} + \semantex_data_prop_put:nnno {#1} {custom_valuekeys} {#2} + { + \l__semantex_valuekey_equality_format_auxiliary_temp:n + { + \l__semantex_key_value_temp + } + } + %IM Remove spaces in #2 +} + +\cs_new:Npn\semantex_primitive_valuekey_removevaluekey:nn#1#2 +{ + \semantex_valuekey_remove:nn { #1 } { #2 } +} + +\cs_set_eq:cN { semantex_primitive_valuekey_1valuekeys:nn } \semantex_primitive_valuekey_valuekeys:nn + +\cs_new:cpn { semantex_primitive_valuekey_2valuekeys:nn }#1#2{ + % Add new valuekeys + \semantex_data_prop_provide:nn { #1 } { custom_valuekeys } \clist_map_inline:nn { #2 }{ - \g_semantex_valuekey_equality_format:nnn{#1}##1 + \__semantex_two_valuekey_equality_format_auxiliary:nnn{#1}##1 } } -\cs_generate_variant:Nn\g_semantex_data_prop_put:nnnn {nnno} +\cs_new:Npn\__semantex_two_valuekey_equality_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_two_valuekey_equality_format_auxiliary_temp:nn##1##2{#3} + \semantex_data_prop_put:nnno {#1} {custom_valuekeys} {#2} + { + \l__semantex_two_valuekey_equality_format_auxiliary_temp:nn + { + \exp_not:N\semantex_grab_first_argument_of_two:nn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_second_argument_of_two:nn\l__semantex_key_value_temp + } + } + %IM Remove spaces in #2 +} -\cs_new:Npn \g_semantex_valuekey_equality_format:nnn#1#2#3 +\cs_new:cpn { semantex_primitive_valuekey_3valuekeys:nn }#1#2{ + % Add new valuekeys + \semantex_data_prop_provide:nn { #1 } { custom_valuekeys } + \clist_map_inline:nn { #2 }{ + \__semantex_three_valuekey_equality_format_auxiliary:nnn{#1}##1 + } +} + +\cs_new:Npn\__semantex_three_valuekey_equality_format_auxiliary:nnn#1#2#3 { - \cs_set:Npn\l__semantex_valuekey_equality_format_temp:n##1{#3} - \g_semantex_data_prop_put:nnno {#1} {custom_valuekeys} {#2} {\l__semantex_valuekey_equality_format_temp:n{\l_semantex_key_value_temp}} + \cs_set:Npn\l__semantex_three_valuekey_equality_format_auxiliary_temp:nnn##1##2##3{#3} + \semantex_data_prop_put:nnno {#1} {custom_valuekeys} {#2} + { + \l__semantex_three_valuekey_equality_format_auxiliary_temp:nnn + { + \exp_not:N\semantex_grab_first_argument_of_three:nnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_second_argument_of_three:nnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_third_argument_of_three:nnn\l__semantex_key_value_temp + } + } %IM Remove spaces in #2 } -\cs_new:Npn\g_semantex_primitive_valuekey_novaluekeys:nn#1#2{ - % Add sinple keys, taking no values, via the - % interface - % novaluekeys={ - % {key1}{print something}, - % {key2}{d=42,i=42}, - % } - \g_semantex_data_prop_provide:nn { #1 } { custom_novaluekeys } +\cs_new:cpn { semantex_primitive_valuekey_4valuekeys:nn }#1#2{ + % Add new valuekeys + \semantex_data_prop_provide:nn { #1 } { custom_valuekeys } \clist_map_inline:nn { #2 }{ - \g_semantex_valuekey_noequality_format:nnn{#1}##1 + \__semantex_four_valuekey_equality_format_auxiliary:nnn{#1}##1 } } -\cs_new:Npn \g_semantex_valuekey_noequality_format:nnn#1#2#3{ - %\prop_put:cnn { semantex_data_prop_#1_custom_novaluekeys }{#2}{#3} - \g_semantex_data_prop_put:nnnn {#1} {custom_novaluekeys} {#2} {#3} +\cs_new:Npn\__semantex_four_valuekey_equality_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_four_valuekey_equality_format_auxiliary_temp:nnnn##1##2##3##4{#3} + \semantex_data_prop_put:nnno {#1} {custom_valuekeys} {#2} + { + \l__semantex_four_valuekey_equality_format_auxiliary_temp:nnnn + { + \exp_not:N\semantex_grab_first_argument_of_four:nnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_second_argument_of_four:nnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_third_argument_of_four:nnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_fourth_argument_of_four:nnnn\l__semantex_key_value_temp + } + } + %IM Remove spaces in #2 } -\cs_new:Npn\g_semantex_primitive_valuekey_argvaluekeys:nn#1#2{ - % Add new valuekeys via the interface - % valuekeys={ - % {key1}{do something with \l_semantex_key_value_temp}, - % {key2}{g=\l_semantex_key_value_temp,i=\l_semantex_key_value_temp}, - % } - \g_semantex_data_prop_provide:nn { #1 } { custom_arg_valuekeys } +\cs_new:cpn { semantex_primitive_valuekey_5valuekeys:nn }#1#2{ + % Add new valuekeys + \semantex_data_prop_provide:nn { #1 } { custom_valuekeys } \clist_map_inline:nn { #2 }{ - \g_semantex_arg_valuekey_equality_format:nnn{#1}##1 + \__semantex_five_valuekey_equality_format_auxiliary:nnn{#1}##1 } } -\cs_new:Npn \g_semantex_arg_valuekey_equality_format:nnn#1#2#3{ - %\prop_put:cnn { semantex_data_prop_#1_custom_arg_valuekeys }{#2}{#3} - \cs_set:Npn\l__semantex_arg_valuekey_equality_format_temp:n##1{#3} - \g_semantex_data_prop_put:nnno {#1} {custom_arg_valuekeys} {#2} {\l__semantex_arg_valuekey_equality_format_temp:n{\l_semantex_arg_key_value_temp}} +\cs_new:Npn\__semantex_five_valuekey_equality_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_five_valuekey_equality_format_auxiliary_temp:nnnnn##1##2##3##4##5{#3} + \semantex_data_prop_put:nnno {#1} {custom_valuekeys} {#2} + { + \l__semantex_five_valuekey_equality_format_auxiliary_temp:nnnnn + { + \exp_not:N\semantex_grab_first_argument_of_five:nnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_second_argument_of_five:nnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_third_argument_of_five:nnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_fourth_argument_of_five:nnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_fifth_argument_of_five:nnnnn\l__semantex_key_value_temp + } + } + %IM Remove spaces in #2 } -\cs_new:Npn\g_semantex_primitive_valuekey_argnovaluekeys:nn#1#2{ - % Add sinple keys, taking no values, via the - % interface - % novaluekeys={ - % {key1}{print something}, - % {key2}{g=42,i=42}, - % } - \g_semantex_data_prop_provide:nn { #1 } { custom_arg_novaluekeys } +\cs_new:cpn { semantex_primitive_valuekey_6valuekeys:nn }#1#2{ + % Add new valuekeys + \semantex_data_prop_provide:nn { #1 } { custom_valuekeys } \clist_map_inline:nn { #2 }{ - \g_semantex_arg_valuekey_noequality_format:nnn{#1}##1 + \__semantex_six_valuekey_equality_format_auxiliary:nnn{#1}##1 } } -\cs_new:Npn \g_semantex_arg_valuekey_noequality_format:nnn#1#2#3{ - \g_semantex_data_prop_put:nnnn {#1} {custom_arg_novaluekeys} {#2} {#3} +\cs_new:Npn\__semantex_six_valuekey_equality_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_six_valuekey_equality_format_auxiliary_temp:nnnnnn##1##2##3##4##5##6{#3} + \semantex_data_prop_put:nnno {#1} {custom_valuekeys} {#2} + { + \l__semantex_six_valuekey_equality_format_auxiliary_temp:nnnnnn + { + \exp_not:N\semantex_grab_first_argument_of_six:nnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_second_argument_of_six:nnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_third_argument_of_six:nnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_fourth_argument_of_six:nnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_fifth_argument_of_six:nnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_sixth_argument_of_six:nnnnnn\l__semantex_key_value_temp + } + } + %IM Remove spaces in #2 } -\cs_new:Npn\g_semantex_primitive_valuekey_symbol:nn#1#2{ - % Sets the value of the symbol - \g_semantex_data_tl_set:nnn { #1 } { symbol } { \exp_not:n { #2 } } +\cs_new:cpn { semantex_primitive_valuekey_7valuekeys:nn }#1#2{ + % Add new valuekeys + \semantex_data_prop_provide:nn { #1 } { custom_valuekeys } + \clist_map_inline:nn { #2 }{ + \__semantex_seven_valuekey_equality_format_auxiliary:nnn{#1}##1 + } } -\cs_new:Npn\g_semantex_primitive_valuekey_texclass:nn#1#2{ - % Sets the value of the symbol - \g_semantex_data_tl_set:nnn { #1 } { texclass } { \exp_not:n { #2 } } +\cs_new:Npn\__semantex_seven_valuekey_equality_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_seven_valuekey_equality_format_auxiliary_temp:nnnnnnn##1##2##3##4##5##6##7{#3} + \semantex_data_prop_put:nnno {#1} {custom_valuekeys} {#2} + { + \l__semantex_seven_valuekey_equality_format_auxiliary_temp:nnnnnnn + { + \exp_not:N\semantex_grab_first_argument_of_seven:nnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_second_argument_of_seven:nnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_third_argument_of_seven:nnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_fourth_argument_of_seven:nnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_fifth_argument_of_seven:nnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_sixth_argument_of_seven:nnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_seventh_argument_of_seven:nnnnnnn\l__semantex_key_value_temp + } + } + %IM Remove spaces in #2 +} + +\cs_new:cpn { semantex_primitive_valuekey_8valuekeys:nn }#1#2{ + % Add new valuekeys + \semantex_data_prop_provide:nn { #1 } { custom_valuekeys } + \clist_map_inline:nn { #2 }{ + \__semantex_eight_valuekey_equality_format_auxiliary:nnn{#1}##1 + } +} + +\cs_new:Npn\__semantex_eight_valuekey_equality_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_eight_valuekey_equality_format_auxiliary_temp:nnnnnnnn##1##2##3##4##5##6##7##8{#3} + \semantex_data_prop_put:nnno {#1} {custom_valuekeys} {#2} + { + \l__semantex_eight_valuekey_equality_format_auxiliary_temp:nnnnnnnn + { + \exp_not:N\semantex_grab_first_argument_of_eight:nnnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_second_argument_of_eight:nnnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_third_argument_of_eight:nnnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_fourth_argument_of_eight:nnnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_fifth_argument_of_eight:nnnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_sixth_argument_of_eight:nnnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_seventh_argument_of_eight:nnnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_eighth_argument_of_eight:nnnnnnnn\l__semantex_key_value_temp + } + } + %IM Remove spaces in #2 +} + +\cs_new:cpn { semantex_primitive_valuekey_9valuekeys:nn }#1#2{ + % Add new valuekeys + \semantex_data_prop_provide:nn { #1 } { custom_valuekeys } + \clist_map_inline:nn { #2 }{ + \__semantex_nine_valuekey_equality_format_auxiliary:nnn{#1}##1 + } +} + +\cs_new:Npn\__semantex_nine_valuekey_equality_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_nine_valuekey_equality_format_auxiliary_temp:nnnnnnnnn##1##2##3##4##5##6##7##8##9{#3} + \semantex_data_prop_put:nnno {#1} {custom_valuekeys} {#2} + { + \l__semantex_nine_valuekey_equality_format_auxiliary_temp:nnnnnnnnn + { + \exp_not:N\semantex_grab_first_argument_of_nine:nnnnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_second_argument_of_nine:nnnnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_third_argument_of_nine:nnnnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_fourth_argument_of_nine:nnnnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_fifth_argument_of_nine:nnnnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_sixth_argument_of_nine:nnnnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_seventh_argument_of_nine:nnnnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_eighth_argument_of_nine:nnnnnnnnn\l__semantex_key_value_temp + } + { + \exp_not:N\semantex_grab_ninth_argument_of_nine:nnnnnnnnn\l__semantex_key_value_temp + } + } + %IM Remove spaces in #2 +} + +\cs_new:Npn\semantex_primitive_valuekey_singlekeys:nn#1#2{ + % Add keys taking no values + \semantex_data_prop_provide:nn { #1 } { custom_singlekeys } + \clist_map_inline:nn { #2 }{ + \__semantex_singlekeys_noequality_format_auxiliary:nnn{#1}##1 + } +} + +\cs_new:Npn \__semantex_singlekeys_noequality_format_auxiliary:nnn#1#2#3{ + \semantex_data_prop_put:nnnn {#1} {custom_singlekeys} {#2} {#3} +} + +\cs_set_eq:NN\semantex_primitive_valuekey_novaluekeys:nn\semantex_primitive_valuekey_singlekeys:nn % Previously, "singlekeys" was called "novaluekeys", so I am keeping this alias for backwards compatibility + +\cs_set_eq:cN { semantex_primitive_valuekey_0valuekeys:nn } \semantex_primitive_valuekey_singlekeys:nn + +\cs_new:Npn\semantex_primitive_valuekey_removesinglekey:nn#1#2 +{ + \semantex_singlekey_remove:nn { #1 } { #2 } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_removenovaluekey:nn\semantex_primitive_valuekey_removesinglekey:nn % Previously, "singlekeys" was called "novaluekeys", so I am keeping this alias for backwards compatibility + +\cs_set_eq:cN { semantex_primitive_valuekey_remove0valuekey:nn } \semantex_primitive_valuekey_removesinglekey:nn + +% KEYS FOR SETTING UP THE ARGUMENT KEYVAL INTERFACE: + +\cs_new:Npn\semantex_primitive_valuekey_argvaluekeys:nn#1#2{ + % Add argument valuekeys + \semantex_data_prop_provide:nn { #1 } { custom_arg_valuekeys } + \clist_map_inline:nn { #2 }{ + \__semantex_arg_valuekey_equality_format_auxiliary:nnn{#1}##1 + } +} + +\cs_new:Npn \__semantex_arg_valuekey_equality_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_arg_valuekey_equality_format_auxiliary_temp:n##1{#3} + \semantex_data_prop_put:nnno {#1} {custom_arg_valuekeys} {#2} + { + \l__semantex_arg_valuekey_equality_format_auxiliary_temp:n{ + \l__semantex_arg_key_value_temp + } + } +} + +\cs_new:Npn\semantex_primitive_valuekey_removeargvaluekey:nn#1#2 +{ + \semantex_arg_valuekey_remove:nn { #1 } { #2 } +} + +\cs_set_eq:cN { semantex_primitive_valuekey_arg1valuekeys:nn } \semantex_primitive_arg_valuekey_arg_valuekeys:nn + +\cs_new:cpn { semantex_primitive_valuekey_arg2valuekeys:nn }#1#2{ + % Add new valuekeys + \semantex_data_prop_provide:nn { #1 } { custom_arg_valuekeys } + \clist_map_inline:nn { #2 }{ + \__semantex_two_arg_valuekey_equality_format_auxiliary:nnn{#1}##1 + } +} + +\cs_new:Npn\__semantex_two_arg_valuekey_equality_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_two_arg_valuekey_equality_format_auxiliary_temp:nn##1##2{#3} + \semantex_data_prop_put:nnno {#1} {custom_arg_valuekeys} {#2} + { + \l__semantex_two_arg_valuekey_equality_format_auxiliary_temp:nn + { + \exp_not:N\semantex_grab_first_argument_of_two:nn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_second_argument_of_two:nn\l__semantex_arg_key_value_temp + } + } + %IM Remove spaces in #2 +} + +\cs_new:cpn { semantex_primitive_valuekey_arg3valuekeys:nn }#1#2{ + % Add new valuekeys + \semantex_data_prop_provide:nn { #1 } { custom_arg_valuekeys } + \clist_map_inline:nn { #2 }{ + \__semantex_three_arg_valuekey_equality_format_auxiliary:nnn{#1}##1 + } +} + +\cs_new:Npn\__semantex_three_arg_valuekey_equality_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_three_arg_valuekey_equality_format_auxiliary_temp:nnn##1##2##3{#3} + \semantex_data_prop_put:nnno {#1} {custom_arg_valuekeys} {#2} + { + \l__semantex_three_arg_valuekey_equality_format_auxiliary_temp:nnn + { + \exp_not:N\semantex_grab_first_argument_of_three:nnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_second_argument_of_three:nnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_third_argument_of_three:nnn\l__semantex_arg_key_value_temp + } + } + %IM Remove spaces in #2 +} + +\cs_new:cpn { semantex_primitive_valuekey_arg4valuekeys:nn }#1#2{ + % Add new valuekeys + \semantex_data_prop_provide:nn { #1 } { custom_arg_valuekeys } + \clist_map_inline:nn { #2 }{ + \__semantex_four_arg_valuekey_equality_format_auxiliary:nnn{#1}##1 + } +} + +\cs_new:Npn\__semantex_four_arg_valuekey_equality_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_four_arg_valuekey_equality_format_auxiliary_temp:nnnn##1##2##3##4{#3} + \semantex_data_prop_put:nnno {#1} {custom_arg_valuekeys} {#2} + { + \l__semantex_four_arg_valuekey_equality_format_auxiliary_temp:nnnn + { + \exp_not:N\semantex_grab_first_argument_of_four:nnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_second_argument_of_four:nnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_third_argument_of_four:nnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_fourth_argument_of_four:nnnn\l__semantex_arg_key_value_temp + } + } + %IM Remove spaces in #2 +} + +\cs_new:cpn { semantex_primitive_valuekey_arg5valuekeys:nn }#1#2{ + % Add new valuekeys + \semantex_data_prop_provide:nn { #1 } { custom_arg_valuekeys } + \clist_map_inline:nn { #2 }{ + \__semantex_five_arg_valuekey_equality_format_auxiliary:nnn{#1}##1 + } +} + +\cs_new:Npn\__semantex_five_arg_valuekey_equality_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_five_arg_valuekey_equality_format_auxiliary_temp:nnnnn##1##2##3##4##5{#3} + \semantex_data_prop_put:nnno {#1} {custom_arg_valuekeys} {#2} + { + \l__semantex_five_arg_valuekey_equality_format_auxiliary_temp:nnnnn + { + \exp_not:N\semantex_grab_first_argument_of_five:nnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_second_argument_of_five:nnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_third_argument_of_five:nnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_fourth_argument_of_five:nnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_fifth_argument_of_five:nnnnn\l__semantex_arg_key_value_temp + } + } + %IM Remove spaces in #2 +} + +\cs_new:cpn { semantex_primitive_valuekey_arg6valuekeys:nn }#1#2{ + % Add new valuekeys + \semantex_data_prop_provide:nn { #1 } { custom_arg_valuekeys } + \clist_map_inline:nn { #2 }{ + \__semantex_six_arg_valuekey_equality_format_auxiliary:nnn{#1}##1 + } +} + +\cs_new:Npn\__semantex_six_arg_valuekey_equality_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_six_arg_valuekey_equality_format_auxiliary_temp:nnnnnn##1##2##3##4##5##6{#3} + \semantex_data_prop_put:nnno {#1} {custom_arg_valuekeys} {#2} + { + \l__semantex_six_arg_valuekey_equality_format_auxiliary_temp:nnnnnn + { + \exp_not:N\semantex_grab_first_argument_of_six:nnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_second_argument_of_six:nnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_third_argument_of_six:nnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_fourth_argument_of_six:nnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_fifth_argument_of_six:nnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_sixth_argument_of_six:nnnnnn\l__semantex_arg_key_value_temp + } + } + %IM Remove spaces in #2 +} + +\cs_new:cpn { semantex_primitive_valuekey_arg7valuekeys:nn }#1#2{ + % Add new valuekeys + \semantex_data_prop_provide:nn { #1 } { custom_arg_valuekeys } + \clist_map_inline:nn { #2 }{ + \__semantex_seven_arg_valuekey_equality_format_auxiliary:nnn{#1}##1 + } +} + +\cs_new:Npn\__semantex_seven_arg_valuekey_equality_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_seven_arg_valuekey_equality_format_auxiliary_temp:nnnnnnn##1##2##3##4##5##6##7{#3} + \semantex_data_prop_put:nnno {#1} {custom_arg_valuekeys} {#2} + { + \l__semantex_seven_arg_valuekey_equality_format_auxiliary_temp:nnnnnnn + { + \exp_not:N\semantex_grab_first_argument_of_seven:nnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_second_argument_of_seven:nnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_third_argument_of_seven:nnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_fourth_argument_of_seven:nnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_fifth_argument_of_seven:nnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_sixth_argument_of_seven:nnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_seventh_argument_of_seven:nnnnnnn\l__semantex_arg_key_value_temp + } + } + %IM Remove spaces in #2 +} + +\cs_new:cpn { semantex_primitive_valuekey_arg8valuekeys:nn }#1#2{ + % Add new valuekeys + \semantex_data_prop_provide:nn { #1 } { custom_arg_valuekeys } + \clist_map_inline:nn { #2 }{ + \__semantex_eight_arg_valuekey_equality_format_auxiliary:nnn{#1}##1 + } +} + +\cs_new:Npn\__semantex_eight_arg_valuekey_equality_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_eight_arg_valuekey_equality_format_auxiliary_temp:nnnnnnnn##1##2##3##4##5##6##7##8{#3} + \semantex_data_prop_put:nnno {#1} {custom_arg_valuekeys} {#2} + { + \l__semantex_eight_arg_valuekey_equality_format_auxiliary_temp:nnnnnnnn + { + \exp_not:N\semantex_grab_first_argument_of_eight:nnnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_second_argument_of_eight:nnnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_third_argument_of_eight:nnnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_fourth_argument_of_eight:nnnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_fifth_argument_of_eight:nnnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_sixth_argument_of_eight:nnnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_seventh_argument_of_eight:nnnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_eighth_argument_of_eight:nnnnnnnn\l__semantex_arg_key_value_temp + } + } + %IM Remove spaces in #2 +} + +\cs_new:cpn { semantex_primitive_valuekey_arg9valuekeys:nn }#1#2{ + % Add new valuekeys + \semantex_data_prop_provide:nn { #1 } { custom_arg_valuekeys } + \clist_map_inline:nn { #2 }{ + \__semantex_nine_arg_valuekey_equality_format_auxiliary:nnn{#1}##1 + } } -\cs_new:Npn\g_semantex_primitive_valuekey_slot:nn#1#2{ +\cs_new:Npn\__semantex_nine_arg_valuekey_equality_format_auxiliary:nnn#1#2#3 +{ + \cs_set:Npn\l__semantex_nine_arg_valuekey_equality_format_auxiliary_temp:nnnnnnnnn##1##2##3##4##5##6##7##8##9{#3} + \semantex_data_prop_put:nnno {#1} {custom_arg_valuekeys} {#2} + { + \l__semantex_nine_arg_valuekey_equality_format_auxiliary_temp:nnnnnnnnn + { + \exp_not:N\semantex_grab_first_argument_of_nine:nnnnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_second_argument_of_nine:nnnnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_third_argument_of_nine:nnnnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_fourth_argument_of_nine:nnnnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_fifth_argument_of_nine:nnnnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_sixth_argument_of_nine:nnnnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_seventh_argument_of_nine:nnnnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_eighth_argument_of_nine:nnnnnnnnn\l__semantex_arg_key_value_temp + } + { + \exp_not:N\semantex_grab_ninth_argument_of_nine:nnnnnnnnn\l__semantex_arg_key_value_temp + } + } + %IM Remove spaces in #2 +} + +\cs_new:Npn\semantex_primitive_valuekey_argsinglekeys:nn#1#2{ + % Add argument keys taking no values + \semantex_data_prop_provide:nn { #1 } { custom_arg_singlekeys } + \clist_map_inline:nn { #2 }{ + \__semantex_arg_singlekeys_noequality_format_auxiliary:nnn{#1}##1 + } +} + +\cs_new:Npn \__semantex_arg_singlekeys_noequality_format_auxiliary:nnn#1#2#3{ + \semantex_data_prop_put:nnnn {#1} {custom_arg_singlekeys} {#2} {#3} +} + +\cs_set_eq:NN\semantex_primitive_valuekey_argnovaluekeys:nn\semantex_primitive_valuekey_argsinglekeys:nn % Previously, "singlekeys" was called "novaluekeys", so I am keeping this alias for backwards compatibility + +\cs_new:Npn\semantex_primitive_valuekey_removeargsinglekey:nn#1#2 +{ + \semantex_arg_singlekey_remove:nn { #1 } { #2 } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_removeargnovaluekey:nn\semantex_primitive_valuekey_removeargsinglekey:nn % Previously, "singlekeys" was called "novaluekeys", so I am keeping this alias for backwards compatibility + +\cs_set_eq:cN { semantex_primitive_valuekey_removearg0valuekey:nn } \semantex_primitive_valuekey_removeargsinglekey:nn + +% THESE ARE REALLY THE COMMANDS MANIPULATING DATA: + +\cs_new:Npn\semantex_primitive_valuekey_symbol:nn#1#2{ % Sets the value of the symbol - \g_semantex_data_tl_set:nnn { #1 } { slot } { \exp_not:n { #2 } } + \semantex_data_tl_set:nnn { #1 } { symbol } { \exp_not:n { #2 } } +} + +\cs_new:Npn\semantex_primitive_valuekey_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_primitive_valuekey_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\g_semantex_primitive_valuekey_symbolputright:nn#1#2{ - \g_semantex_data_tl_put_right:nnn { #1 } { symbol } { \exp_not:n { #2 } } +\cs_new:Npn\semantex_primitive_valuekey_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\g_semantex_primitive_valuekey_symbolputleft:nn#1#2{ - \g_semantex_data_tl_put_left:nnn { #1 } { symbol } { \exp_not:n { #2 } } +\cs_new:Npn\semantex_primitive_valuekey_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\g_semantex_primitive_valuekey_command:nn#1#2{ +\cs_new:Npn\semantex_primitive_valuekey_command:nn#1#2{ % Adds one entry on the left of the command % sequence to be applied to the symbol - \g_semantex_data_seq_put_right:nnn { #1 } { commands_sequence } { #2 } %IM maybe \exp_not:n { #2 }? + \semantex_data_seq_put_right:nnn { #1 } { commands_sequence } { #2 } %IM maybe \exp_not:n { #2 }? } -\cs_new:Npn\g_semantex_primitive_valuekey_argwithkeyval:nn#1#2{ - % Sets the argument (printed in parentheses - % after the symbol) - \g_semantex_arg_keys_set:nn { #1 } {{{ #2 }}} - %IM for unknown reasons, one needs these extra braces. - %IM This should be moved to the arg valuekeys themselves - %IM where ifoutput=true is also declared +\cs_new:Npn\semantex_primitive_valuekey_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\g_semantex_primitive_valuekey_argwithnovaluekeys:nn#1#2{ - % Sets the argument (printed in parentheses - % after the symbol) - \g_semantex_arg_novaluekeys_set:nn { #1 } { #2 } +\cs_new:Npn\semantex_primitive_valuekey_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\g_semantex_primitive_valuekey_argwithonenovaluekey:nn#1#2{ - % Sets the argument (printed in parentheses - % after the symbol) - \use:c { g_semantex_data_cs_#1_arg_novaluekey:n } {{{{ #2 }}}} +\cs_new:Npn\semantex_primitive_valuekey_argwithsinglekeys:nn#1#2{ + % Sets the argument (only allows singlekeys) + \semantex_arg_singlekeys_set:nn { #1 } { #2 } } -\cs_new:Npn\g_semantex_primitive_valuekey_argwithoutkeyval:nn#1#2{ - \g_semantex_data_tl_put_right:nnn { #1 } { arg } { \exp_not:n { #2 } } - \g_semantex_primitive_valuekey_ifrightreturnbeforerender:nn{#1}{true} +\cs_new:Npn\semantex_primitive_valuekey_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_primitive_valuekey_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\g_semantex_primitive_valuekey_useargwithkeyval:nn#1#2 -%{ -%% \g_semantex_primitive_valuekey_valuekeys:nn { #1 } -%% { -%% {arg} { argwithkeyval={ \l_semantex_key_value_temp } }, -%% } -% \g_semantex_keys_set:nn { #1 }{ -% \exp_not:n{valuekeys={ -% {arg}{ argwithkeyval={\l_semantex_key_value_temp} }, -% },} -% } -%} +\cs_new:Npn\semantex_primitive_valuekey_setargsep:nn#1#2 +{ + % Sets the argument separator + \semantex_data_tl_set:nnn { #1 } { argsep } { \exp_not:n { #2 } } +} -\cs_new:Npn\g_semantex_primitive_valuekey_argsep:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_setargdots:nn#1#2 { - %\g_semantex_data_tl_provide:nn { #1 } { argsep } - \g_semantex_data_tl_set:nnn { #1 } { argsep } { \exp_not:n { #2 } } + % Sets the argument dot command + \semantex_data_tl_set:nnn { #1 } { argdots } { \exp_not:n { #2 } } } -\cs_new:Npn\g_semantex_primitive_valuekey_argdots:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_setargslot:nn#1#2 { -% \g_semantex_data_tl_provide:nn { #1 } { argdots } - \g_semantex_data_tl_set:nnn { #1 } { argdots } { \exp_not:n { #2 } } + % Sets the argument dot command + \semantex_data_tl_set:nnn { #1 } { argslot } { \exp_not:n { #2 } } } -\cs_new:Npn\g_semantex_primitive_valuekey_prearg:nn#1#2{ +\cs_new:Npn\semantex_primitive_valuekey_prearg:nn#1#2{ + % Sets something to write before the argument \tl_if_blank:nF{#2} { - \g_semantex_data_tl_put_left:nnn { #1 } { prearg } { \exp_not:n { #2 } } + \semantex_data_tl_put_left:nnn { #1 } { prearg } { \exp_not:n { #2 } } } } -\cs_new:Npn\g_semantex_primitive_valuekey_postarg:nn#1#2{ +\cs_new:Npn\semantex_primitive_valuekey_clearprearg:nn#1#2 +{ + \semantex_data_tl_clear:nn { #1 } { prearg } +} + +\cs_new:Npn\semantex_primitive_valuekey_postarg:nn#1#2{ + % Sets something to write after the argument \tl_if_blank:nF{#2} { - \g_semantex_data_tl_put_right:nnn { #1 } { postarg } { \exp_not:n{ #2 } } + \semantex_data_tl_put_right:nnn { #1 } { postarg } { \exp_not:n{ #2 } } } } +\cs_new:Npn\semantex_primitive_valuekey_clearpostarg:nn#1#2 +{ + \semantex_data_tl_clear:nn { #1 } { postarg } +} -\cs_new:Npn\g_semantex_primitive_valuekey_output:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_output:nn#1#2 { - \g_semantex_data_tl_set:nnn { #1 } { output } { #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 } \__semantex_primitive_valuekey_output_temp + \msg_error:nnxnn { semantex } { class_not_found } { \__semantex_primitive_valuekey_output_temp } { output } { #2 } + } % Maybe allow output=self } -\cs_new:Npn\g_semantex_primitive_valuekey_outputoptions:nn#1#2{ - \g_semantex_data_tl_put_right:nnn { #1 } { output_options } { #2, } +\cs_new:Npn\semantex_primitive_valuekey_outputoptions:nn#1#2{ + % Sets possible options to pass to the output class + \semantex_data_tl_put_right:nnn { #1 } { outputoptions } { ,#2, } } -\cs_new:Npn\g_semantex_primitive_valuekey_ifrightreturnbeforerender:nn#1#2{ - % tells whether to use the output class or not +\cs_new:Npn\semantex_primitive_valuekey_ifleftargument:nn#1#2{ + % Tells whether to rightreturn before rendering the output. \str_if_eq:nnTF { #2 } { true } { - \g_semantex_data_bool_set_true:nn { #1 } { rightreturnbeforerender } + \semantex_data_bool_set_true:nn { #1 } { leftargument } } { \str_if_eq:nnTF { #2 } { false } { - \g_semantex_data_bool_set_false:nn { #1 } { rightreturnbeforerender } + \semantex_data_bool_set_false:nn { #1 } { leftargument } } { - %IM do nothing right now, but should - %IM probably throw an error + \semantex_error_output_format:nN { #1 } \l__semantex_primitive_valuekey_ifleftargumen_temp + \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_primitive_valuekey_ifleftargumen_temp } { ifleftargument } { #2 } } } } -\cs_new:Npn\g_semantex_primitive_valuekey_ifoutput:nn#1#2{ %IMPLEMENT THIS - % tells whether to output or not +\cs_new:Npn\semantex_primitive_valuekey_ifoutput:nn#1#2{ %IMPLEMENT THIS + % Tells whether to output or not \str_if_eq:nnTF { #2 } { true } { - \g_semantex_data_bool_set_true:nn { #1 } { output } + \semantex_data_bool_set_true:nn { #1 } { output } } { \str_if_eq:nnTF { #2 } { false } { - \g_semantex_data_bool_set_false:nn { #1 } { output } + \semantex_data_bool_set_false:nn { #1 } { output } } { - %IM do nothing right now, but should - %IM probably throw an error + \semantex_error_output_format:nN { #1 } \l__semantex_primitive_valuekey_ifoutput_temp + \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_primitive_valuekey_ifoutput_temp } { ifoutput } { #2 } } } } -\cs_new:Npn\g_semantex_primitive_valuekey_gradingpos:nn#1#2{ - % tells whether to use upper or lower indices - \g_semantex_data_bool_provide:nn { #1 } { upper_grading } - \str_case:nnTF { #2 } +\cs_new:Npn\semantex_primitive_valuekey_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 } { - { upper } + \semantex_data_bool_set_true:nn { #1 } { uppergrading } + } + { + \str_if_eq:nnTF { #2 } { lower } { - \g_semantex_data_bool_set_true:nn { #1 } { upper_grading } + \semantex_data_bool_set_false:nn { #1 } { uppergrading } } - { lower } { - \g_semantex_data_bool_set_false:nn { #1 } { upper_grading } + \semantex_error_output_format:nN { #1 } \l__semantex_primitive_valuekey_gradingposition_temp + \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_primitive_valuekey_gradingposition_temp } { gradingposition } { #2 } } } - { - % do nohting - } - { - % do nothing at the moment, but should probably throw an error - } } -\cs_set_eq:NN \g_semantex_primitive_valuekey_gradingposition:nn \g_semantex_primitive_valuekey_gradingpos:nn +\cs_set_eq:NN \semantex_primitive_valuekey_gradingpos:nn \semantex_primitive_valuekey_gradingposition:nn % Upper and lower right indices: -\cs_new:Npn\g_semantex_primitive_valuekey_upper:nn#1#2{ +\cs_new:Npn\semantex_primitive_valuekey_upper:nn#1#2{ % adds to the upper index \tl_if_blank:nF{#2}{ - \g_semantex_data_tl_put_right:nnn { #1 } { upper_index } { \exp_not:n{ #2 } } - % For a long time, when using x type expansions when checking - % if indices were empty, two \exp_not:n's were necessary here. - % Thankfully, I can now happily remove them again, it seems. - %\g_semantex_data_bool_provide:nn { #1 } { first_upper } - \g_semantex_data_bool_set_false:nn { #1 } { first_upper } + \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\g_semantex_primitive_valuekey_supper:nn#1#2{ - % adds to the upper index, with a separator +\cs_new:Npn\semantex_primitive_valuekey_supper:nn#1#2{ + % Adds to the upper index, with a separator \tl_if_blank:nF{#2} { - \g_semantex_data_bool_get:nnTF { #1 } { first_upper } + \semantex_data_bool_get:nnTF { #1 } { nextupperwithsep } { - \g_semantex_data_tl_put_right:nnn { #1 } { upper_index } { \exp_not:n { #2 } } + \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 } } } { - \g_semantex_data_tl_put_right:nnx { #1 } { upper_index } - { \exp_not:n { \g_semantex_data_tl_get:nn { #1 } { uppersep } } } - \g_semantex_data_tl_put_right:nnn { #1 } { upper_index } { \exp_not:n { #2 } } + \semantex_data_tl_put_right:nnn { #1 } { upper } { \exp_not:n { #2 } } } - \g_semantex_data_bool_set_false:nn { #1 } { first_upper } + \semantex_data_bool_set_true:nn { #1 } { nextupperwithsep } + \semantex_data_int_incr:nn { #1 } { numberofupperindices } } } -\cs_new:Npn\g_semantex_primitive_valuekey_upperaddleft:nn#1#2{ - % adds to the upper index +\cs_new:Npn\semantex_primitive_valuekey_upperputleft:nn#1#2{ + % Adds to the left of the upper index \tl_if_blank:nF{#2}{ - \g_semantex_data_tl_put_left:nnn { #1 } { upper_index } { \exp_not:n{ #2 } } - \g_semantex_data_bool_set_false:nn { #1 } { first_upper } + \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 } } } -\cs_new:Npn\g_semantex_primitive_valuekey_preupper:nn#1#2{ +\cs_new:Npn\semantex_primitive_valuekey_preupper:nn#1#2{ + % Sets what to write before upper \tl_if_blank:nF{#2} { - \g_semantex_data_tl_put_left:cn { #1 } { preupper } { \exp_not:n{ #2 } } + \semantex_data_tl_put_left:cn { #1 } { preupper } { \exp_not:n{ #2 } } } } - -\cs_new:Npn\g_semantex_primitive_valuekey_postupper:nn#1#2{ +\cs_new:Npn\semantex_primitive_valuekey_postupper:nn#1#2{ + % Sets what to write after upper \tl_if_blank:nF{#2} { - \g_semantex_data_tl_put_right:nnn { #1 } { postupper } { \exp_not:n{ #2 } } + \semantex_data_tl_put_right:nnn { #1 } { postupper } { \exp_not:n{ #2 } } } } -\cs_new:Npn\g_semantex_primitive_valuekey_lower:nn#1#2{ - % adds to the lower index +\cs_new:Npn\semantex_primitive_valuekey_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_primitive_valuekey_clearpreupper:nn#1#2{ + \semantex_data_tl_clear:nn { #1 } { preupper } +} + +\cs_new:Npn\semantex_primitive_valuekey_clearpostupper:nn#1#2{ + \semantex_data_tl_clear:nn { #1 } { postupper } +} + +\cs_new:Npn\semantex_primitive_valuekey_setupperdots:nn#1#2 +{ + \semantex_data_tl_set:nnn { #1 } { upperdots } { \exp_not:n { #2 } } +} + +\cs_generate_variant:Nn\semantex_primitive_valuekey_upper:nn { nx } + +\cs_new:Npn\semantex_primitive_valuekey_upperdots:nn#1#2 +{ + \semantex_primitive_valuekey_upper:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperdots } } +} + +\cs_new:Npn\semantex_primitive_valuekey_setupperslot:nn#1#2 +{ + \semantex_data_tl_set:nnn { #1 } { upperslot } { \exp_not:n { #2 } } +} + +\cs_new:Npn\semantex_primitive_valuekey_upperslot:nn#1#2 +{ + \semantex_primitive_valuekey_upper:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperslot } } +} + +\cs_generate_variant:Nn \semantex_primitive_valuekey_supper:nn { nx } + +\cs_new:Npn\semantex_primitive_valuekey_supperdots:nn#1#2 +{ + \semantex_primitive_valuekey_supper:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperdots } } +} + +\cs_new:Npn\semantex_primitive_valuekey_supperslot:nn#1#2 +{ + \semantex_primitive_valuekey_supper:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperslot } } +} + +\cs_generate_variant:Nn \semantex_primitive_valuekey_cupper:nn { nx } + +\cs_new:Npn\semantex_primitive_valuekey_cupperdots:nn#1#2 +{ + \semantex_primitive_valuekey_cupper:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperdots } } +} + +\cs_new:Npn\semantex_primitive_valuekey_cupperslot:nn#1#2 +{ + \semantex_primitive_valuekey_cupper:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperslot } } +} + +\cs_generate_variant:Nn \semantex_primitive_valuekey_upperwithothersep:nn { nx } + +\cs_new:Npn\semantex_primitive_valuekey_upperdotswithothersep:nn#1#2 +{ + \semantex_primitive_valuekey_upperwithothersep:nx { #1 } { { \exp_not:n { #2 } } { \semantex_data_tl_get:nn { #1 } { upperdots } } } +} + +\cs_new:Npn\semantex_primitive_valuekey_upperslotwithothersep:nn#1#2 +{ + \semantex_primitive_valuekey_upperwithothersep:nx { #1 } { { \exp_not:n { #2 } } { \semantex_data_tl_get:nn { #1 } { upperslot } } } +} + +\cs_new:Npn\semantex_primitive_valuekey_lower:nn#1#2{ + % Adds to the lower index \tl_if_blank:nF{#2} { - \g_semantex_data_tl_put_right:nnn { #1 } { lower_index } { \exp_not:n { #2 } } - \g_semantex_data_bool_set_false:nn { #1 } { first_lower } + \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\g_semantex_primitive_valuekey_slower:nn#1#2{ - % adds to the lower index, with a separator +\cs_new:Npn\semantex_primitive_valuekey_slower:nn#1#2{ + % Adds to the lower index, with a separator \tl_if_blank:nF{#2} { - \g_semantex_data_bool_get:nnTF { #1 } { first_lower } + \semantex_data_bool_get:nnTF { #1 } { nextlowerwithsep } { - \g_semantex_data_tl_put_right:nnn { #1 } { lower_index } { \exp_not:n { #2 } } + \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 } } } { - \g_semantex_data_tl_put_right:nnx { #1 } { lower_index } - { \exp_not:n { \g_semantex_data_tl_get:nn { #1 } { lowersep } } } - \g_semantex_data_tl_put_right:nnn { #1 } { lower_index } { \exp_not:n { #2 } } + \semantex_data_tl_put_right:nnn { #1 } { lower } { \exp_not:n { #2 } } } - \g_semantex_data_bool_set_false:nn { #1 } { first_lower } + \semantex_data_bool_set_true:nn { #1 } { nextlowerwithsep } + \semantex_data_int_incr:nn { #1 } { numberoflowerindices } } } -\cs_new:Npn\g_semantex_primitive_valuekey_loweraddleft:nn#1#2{ - % adds to the lower index +\cs_new:Npn\semantex_primitive_valuekey_lowerputleft:nn#1#2{ + % Adds to the lower index \tl_if_blank:nF{#2} { - \g_semantex_data_tl_put_left:nnn { #1 } { lower_index } { \exp_not:n { #2 } } - \g_semantex_data_bool_set_false:nn { #1 } { first_lower } + \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 } } } -\cs_new:Npn\g_semantex_primitive_valuekey_prelower:nn#1#2{ - % adds to the lower index +\cs_new:Npn\semantex_primitive_valuekey_prelower:nn#1#2{ + % Sets what to write before the lower index \tl_if_blank:nF{#2} { - \g_semantex_data_tl_put_left:nnn { #1 } { prelower } { \exp_not:n { #2 } } + \semantex_data_tl_put_left:nnn { #1 } { prelower } { \exp_not:n { #2 } } } } -\cs_new:Npn\g_semantex_primitive_valuekey_postlower:nn#1#2{ - % adds to the lower index +\cs_new:Npn\semantex_primitive_valuekey_postlower:nn#1#2{ + % Sets what to write after the lower index \tl_if_blank:nF{#2} { - \g_semantex_data_tl_put_right:nnn { #1 } { postlower } { \exp_not:n{ #2 } } + \semantex_data_tl_put_right:nnn { #1 } { postlower } { \exp_not:n{ #2 } } } } -\cs_generate_variant:Nn \tl_if_blank:nTF { vTF } +\cs_new:Npn\semantex_primitive_valuekey_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_primitive_valuekey_clearprelower:nn#1#2{ + \semantex_data_tl_clear:nn { #1 } { prelower } +} + +\cs_new:Npn\semantex_primitive_valuekey_clearpostlower:nn#1#2{ + \semantex_data_tl_clear:nn { #1 } { postlower } +} + +\cs_new:Npn\semantex_primitive_valuekey_setlowerdots:nn#1#2 +{ + \semantex_data_tl_set:nnn { #1 } { lowerdots } { \exp_not:n { #2 } } +} + +\cs_generate_variant:Nn \semantex_primitive_valuekey_lower:nn { nx } + +\cs_new:Npn\semantex_primitive_valuekey_lowerdots:nn#1#2 +{ + \semantex_primitive_valuekey_lower:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerdots } } +} + +\cs_new:Npn\semantex_primitive_valuekey_setlowerslot:nn#1#2 +{ + \semantex_data_tl_set:nnn { #1 } { lowerslot } { \exp_not:n { #2 } } +} + +\cs_new:Npn\semantex_primitive_valuekey_lowerslot:nn#1#2 +{ + \semantex_primitive_valuekey_lower:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerslot } } +} + +\cs_generate_variant:Nn \semantex_primitive_valuekey_slower:nn { nx } + +\cs_new:Npn\semantex_primitive_valuekey_slowerdots:nn#1#2 +{ + \semantex_primitive_valuekey_slower:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerdots } } +} + +\cs_new:Npn\semantex_primitive_valuekey_slowerslot:nn#1#2 +{ + \semantex_primitive_valuekey_slower:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerslot } } +} + +\cs_generate_variant:Nn \semantex_primitive_valuekey_clower:nn { nx } + +\cs_new:Npn\semantex_primitive_valuekey_clowerdots:nn#1#2 +{ + \semantex_primitive_valuekey_clower:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerdots } } +} -\cs_new:Npn \g_semantex_primitive_upper_lower_auxiliary_first_arg:nn#1#2 { #1 } +\cs_new:Npn\semantex_primitive_valuekey_clowerslot:nn#1#2 +{ + \semantex_primitive_valuekey_clower:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerslot } } +} -\cs_new:Npn \g_semantex_primitive_upper_lower_auxiliary_second_arg:nn#1#2 { #2 } +\cs_generate_variant:Nn \semantex_primitive_valuekey_lowerwithothersep:nn { nx } -\cs_new:Npn\g_semantex_primitive_valuekey_uppersep:nn#1#2{ - % uppersep={separator}{contents} adds contents to the upper index +\cs_new:Npn\semantex_primitive_valuekey_lowerdotswithothersep:nn#1#2 +{ + \semantex_primitive_valuekey_lowerwithothersep:nx { #1 } { { \exp_not:n { #2 } } { \semantex_data_tl_get:nn { #1 } { lowerdots } } } +} + +\cs_new:Npn\semantex_primitive_valuekey_lowerslotwithothersep:nn#1#2 +{ + \semantex_primitive_valuekey_lowerwithothersep:nx { #1 } { { \exp_not:n { #2 } } { \semantex_data_tl_get:nn { #1 } { lowerslot } } } +} + +\cs_new:Npn\semantex_primitive_valuekey_upperwithothersep:nn#1#2{ + % upperwithsep={separator}{contents} adds contents to the upper index % with the appropriate index separator - \g_semantex_data_bool_inherit:nn { #1 } { first_upper } - \g_semantex_data_bool_get:nnTF { #1 } { first_upper } + \semantex_data_bool_get:nnTF { #1 } { nextupperwithsep } { - \g_semantex_data_tl_put_right:nnn { #1 } { upper_index } { + \semantex_data_tl_put_right:nnn { #1 } { upper } { \exp_not:n { - \g_semantex_primitive_upper_lower_auxiliary_second_arg:nn #2 + \semantex_grab_first_argument_of_two:nn #2 + \semantex_grab_second_argument_of_two:nn #2 } } } { - \g_semantex_data_tl_put_right:nnn { #1 } { upper_index } { + \semantex_data_tl_put_right:nnn { #1 } { upper } { \exp_not:n { - \g_semantex_primitive_upper_lower_auxiliary_first_arg:nn #2 - \g_semantex_primitive_upper_lower_auxiliary_second_arg:nn #2 + \semantex_grab_second_argument_of_two:nn #2 } } } - \g_semantex_data_bool_set_false:nn { #1 } { first_upper } + \semantex_data_bool_set_true:nn { #1 } { nextupperwithsep } + \semantex_data_int_incr:nn { #1 } { numberofupperindices } } -\cs_new:Npn\g_semantex_primitive_valuekey_lowersep:nn#1#2{ - % lowersep={separator}{contents} adds contents to the lower index +\cs_new:Npn\semantex_primitive_valuekey_lowerwithothersep:nn#1#2{ + % lowerwithsep={separator}{contents} adds contents to the lower index % with the appropriate index separator - \g_semantex_data_bool_get:nnTF { #1 } { first_lower } + \semantex_data_bool_get:nnTF { #1 } { nextlowerwithsep } { - \g_semantex_data_tl_put_right:nnn { #1 } { lower_index } { + \semantex_data_tl_put_right:nnn { #1 } { lower } { \exp_not:n { - \g_semantex_primitive_upper_lower_auxiliary_second_arg:nn #2 + \semantex_grab_first_argument_of_two:nn #2 + \semantex_grab_second_argument_of_two:nn #2 } } } { - \g_semantex_data_tl_put_right:nnn { #1 } { lower_index } { - \exp_not:n { \g_semantex_primitive_upper_lower_auxiliary_first_arg:nn #2 \g_semantex_primitive_upper_lower_auxiliary_second_arg:nn #2 + \semantex_data_tl_put_right:nnn { #1 } { lower } { + \exp_not:n { + \semantex_grab_second_argument_of_two:nn #2 } } } - \g_semantex_data_bool_set_false:nn { #1 } { first_lower } + \semantex_data_bool_set_true:nn { #1 } { nextlowerwithsep } + \semantex_data_int_incr:nn { #1 } { numberofupperindices } } -\cs_new:Npn\g_semantex_primitive_valuekey_cupper:nn#1#2{ - % adds to the upper index, with a comma as separator +\cs_new:Npn\semantex_primitive_valuekey_cupper:nn#1#2{ + % Adds to the upper index, with a comma as separator \tl_if_blank:nF{#2} { - \g_semantex_data_bool_get:nnTF { #1 } { first_upper } + \semantex_data_bool_get:nnTF { #1 } { nextupperwithsep } { - \g_semantex_data_tl_put_right:nnn { #1 } { upper_index } { \exp_not:n { #2 } } + \semantex_data_tl_put_right:nnn { #1 } { upper } { , \exp_not:n { #2 } } } { - \g_semantex_data_tl_put_right:nnn { #1 } { upper_index } { , \exp_not:n { #2 } } + \semantex_data_tl_put_right:nnn { #1 } { upper } { \exp_not:n { #2 } } } - \g_semantex_data_bool_set_false:nn { #1 } { first_upper } + \semantex_data_bool_set_true:nn { #1 } { nextupperwithsep } + \semantex_data_int_incr:nn { #1 } { numberofupperindices } } } -\cs_new:Npn\g_semantex_primitive_valuekey_clower:nn#1#2{ - % adds to the lower index, with a comma as separator +\cs_new:Npn\semantex_primitive_valuekey_clower:nn#1#2{ + % Adds to the lower index, with a comma as separator \tl_if_blank:nF{#2} { - \g_semantex_data_bool_get:nnTF { #1 } { first_lower } + \semantex_data_bool_get:nnTF { #1 } { nextlowerwithsep } { - \g_semantex_data_tl_put_right:nnn { #1 } { lower_index } { \exp_not:n { #2 } } + \semantex_data_tl_put_right:nnn { #1 } { lower } { , \exp_not:n { #2 } } } { - \g_semantex_data_tl_put_right:nnn { #1 } { lower_index } { , \exp_not:n { #2 } } + \semantex_data_tl_put_right:nnn { #1 } { lower } { \exp_not:n { #2 } } } - \g_semantex_data_bool_set_false:nn { #1 } { first_lower } + \semantex_data_bool_set_true:nn { #1 } { nextlowerwithsep } + \semantex_data_int_incr:nn { #1 } { numberoflowerindices } } } -\cs_new:Npn\g_semantex_primitive_valuekey_iffirstupper:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_ifnextupperwithsep:nn#1#2 { - \tl_if_eq:nnTF { #2 } { true } + % Tells whether the upper index is the first one + \tl_if_eq:nnTF { #2 } { false } { - \g_semantex_data_bool_set_true:nn { #1 } { first_upper } + \semantex_data_bool_set_false:nn { #1 } { nextupperwithsep } } { - \tl_if_eq:nnTF { #2 } { false } + \tl_if_eq:nnTF { #2 } { true } { - \g_semantex_data_bool_set_false:nn { #1 } { first_upper } + \semantex_data_bool_set_true:nn { #1 } { nextupperwithsep } } { - %IM Throw error later + \semantex_error_output_format:nN { #1 } \l__semantex_primitive_valuekey_ifnextupperwithsep_temp + \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_primitive_valuekey_ifnextupperwithsep_temp } { ifnextupperwithsep } { #2 } } } } -\cs_new:Npn\g_semantex_primitive_valuekey_iffirstlower:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_ifnextlowerwithsep:nn#1#2 % should be removed later { - \tl_if_eq:nnTF { #2 } { true } + % Tells whether the lower index is the first one + \tl_if_eq:nnTF { #2 } { false } { - \g_semantex_data_bool_set_true:nn { #1 } { first_lower } + \semantex_data_bool_set_false:nn { #1 } { nextlowerwithsep } } { - \tl_if_eq:nnTF { #2 } { false } + \tl_if_eq:nnTF { #2 } { true } { - \g_semantex_data_bool_set_false:nn { #1 } { first_lower } + \semantex_data_bool_set_true:nn { #1 } { nextlowerwithsep } } { - %IM Throw error later + \semantex_error_output_format:nN { #1 } \l__semantex_primitive_valuekey_ifnextlowerwithsep_temp + \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_primitive_valuekey_ifnextlowerwithsep_temp } { ifnextlowerwithsep } { #2 } } } } -\cs_new:Npn\g_semantex_primitive_valuekey_setuppersep:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_setuppersep:nn#1#2 { - \g_semantex_data_tl_set:nnn { #1 } { uppersep } { \exp_not:n { #2 }} + % Sets the separator for the upper index + \semantex_data_tl_set:nnn { #1 } { uppersep } { \exp_not:n { #2 }} } -\cs_new:Npn\g_semantex_primitive_valuekey_setlowersep:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_setlowersep:nn#1#2 { - \g_semantex_data_tl_set:nnn { #1 } { lowersep } { \exp_not:n { #2 }} + % Sets the separator for the lower index + \semantex_data_tl_set:nnn { #1 } { lowersep } { \exp_not:n { #2 }} } -%--------------- Left indices: +%--------------- Left indices: (I don't repeat all of the documentation) -\cs_new:Npn\g_semantex_primitive_valuekey_upperleft:nn#1#2{ +\cs_new:Npn\semantex_primitive_valuekey_upperleft:nn#1#2{ % adds to the upper left index \tl_if_blank:nF{#2}{ - \g_semantex_data_tl_put_left:nnn { #1 } { upper_left_index } { \exp_not:n{ #2 } } - \g_semantex_data_bool_set_false:nn { #1 } { first_upper_left } + \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\g_semantex_primitive_valuekey_supperleft:nn#1#2{ +\cs_new:Npn\semantex_primitive_valuekey_supperleft:nn#1#2{ \tl_if_blank:nF{#2} { - \g_semantex_data_bool_get:nnTF { #1 } { first_upper_left } + \semantex_data_bool_get:nnTF { #1 } { nextupperwithsep } { - \g_semantex_data_tl_put_left:nnn { #1 } { upper_left_index } { \exp_not:n { #2 } } + \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 } } } { - \g_semantex_data_tl_put_left:nnn { #1 } { upper_left_index } { \exp_not:n { #2 } } - \g_semantex_data_tl_put_left:nnx { #1 } { upper_left_index } - { \exp_not:n { \g_semantex_data_tl_get:nn { #1 } { uppersep } } } + \semantex_data_tl_put_left:nnn { #1 } { upperleft } { \exp_not:n { #2 } } } - \g_semantex_data_bool_set_false:nn { #1 } { first_upper_left } + \semantex_data_bool_set_true:nn { #1 } { nextupperleftwithsep } + \semantex_data_int_incr:nn { #1 } { numberofupperleftindices } } } -\cs_new:Npn\g_semantex_primitive_valuekey_upperleftaddright:nn#1#2{ - % adds to the upper index +\cs_new:Npn\semantex_primitive_valuekey_upperleftputright:nn#1#2{ \tl_if_blank:nF{#2}{ - \g_semantex_data_tl_put_right:nnn { #1 } { upper_left_index } { \exp_not:n{ #2 } } - \g_semantex_data_bool_set_false:nn { #1 } { first_upper_left } + \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\g_semantex_primitive_valuekey_preupperleft:nn#1#2{ - % adds to the lower index +\cs_new:Npn\semantex_primitive_valuekey_preupperleft:nn#1#2{ \tl_if_blank:nF{#2} { - \g_semantex_data_tl_put_left:nnn { #1 } { preupperleft } { \exp_not:n{ #2 } } + \semantex_data_tl_put_left:nnn { #1 } { preupperleft } { \exp_not:n{ #2 } } } } -\cs_new:Npn\g_semantex_primitive_valuekey_postupperleft:nn#1#2{ +\cs_new:Npn\semantex_primitive_valuekey_postupperleft:nn#1#2{ % adds to the lower index \tl_if_blank:nF{#2} { - \g_semantex_data_tl_put_right:nnn { #1 } { postupperleft } { \exp_not:n{ #2 } } + \semantex_data_tl_put_right:nnn { #1 } { postupperleft } { \exp_not:n{ #2 } } } } -\cs_new:Npn\g_semantex_primitive_valuekey_lowerleft:nn#1#2{ - % adds to the lower left index +\cs_new:Npn\semantex_primitive_valuekey_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_primitive_valuekey_clearpreupperleft:nn#1#2{ + \semantex_data_tl_clear:nn { #1 } { preupperleft } +} + +\cs_new:Npn\semantex_primitive_valuekey_clearpostupperleft:nn#1#2{ + \semantex_data_tl_clear:nn { #1 } { preupperleft } +} + +\cs_new:Npn\semantex_primitive_valuekey_setupperleftdots:nn#1#2 +{ + \semantex_data_tl_set:nnn { #1 } { upperleftdots } { \exp_not:n { #2 } } +} + +\cs_generate_variant:Nn \semantex_primitive_valuekey_upperleft:nn { nx } + +\cs_new:Npn\semantex_primitive_valuekey_upperleftdots:nn#1#2 +{ + \semantex_primitive_valuekey_upperleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperleftdots } } +} + +\cs_new:Npn\semantex_primitive_valuekey_setupperleftslot:nn#1#2 +{ + \semantex_data_tl_set:nnn { #1 } { upperleftslot } { \exp_not:n { #2 } } +} + +\cs_new:Npn\semantex_primitive_valuekey_upperleftslot:nn#1#2 +{ + \semantex_primitive_valuekey_upperleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperleftslot } } +} + +\cs_generate_variant:Nn \semantex_primitive_valuekey_supperleft:nn { nx } + +\cs_new:Npn\semantex_primitive_valuekey_supperleftdots:nn#1#2 +{ + \semantex_primitive_valuekey_supperleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperleftdots } } +} + +\cs_new:Npn\semantex_primitive_valuekey_supperleftslot:nn#1#2 +{ + \semantex_primitive_valuekey_supperleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperleftslot } } +} + +\cs_generate_variant:Nn \semantex_primitive_valuekey_cupperleft:nn { nx } + +\cs_new:Npn\semantex_primitive_valuekey_cupperleftdots:nn#1#2 +{ + \semantex_primitive_valuekey_cupperleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperleftdots } } +} + +\cs_new:Npn\semantex_primitive_valuekey_cupperleftslot:nn#1#2 +{ + \semantex_primitive_valuekey_cupperleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { upperleftslot } } +} + +\cs_generate_variant:Nn \semantex_primitive_valuekey_upperleftwithothersep:nn { nx } + +\cs_new:Npn\semantex_primitive_valuekey_upperleftdotswithothersep:nn#1#2 +{ + \semantex_primitive_valuekey_upperleftwithothersep:nx { #1 } { { \exp_not:n { #2 } } { \semantex_data_tl_get:nn { #1 } { upperleftdots } } } +} + +\cs_new:Npn\semantex_primitive_valuekey_upperleftslotwithothersep:nn#1#2 +{ + \semantex_primitive_valuekey_upperleftwithothersep:nx { #1 } { { \exp_not:n { #2 } } { \semantex_data_tl_get:nn { #1 } { upperleftslot } } } +} + +\cs_new:Npn\semantex_primitive_valuekey_lowerleft:nn#1#2{ \tl_if_blank:nF{#2} { - \g_semantex_data_tl_put_left:nnn { #1 } { lower_left_index } { \exp_not:n{ #2 } } - \g_semantex_data_bool_set_false:nn { #1 } { first_lower_left } + \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 } } } -\cs_new:Npn\g_semantex_primitive_valuekey_slowerleft:nn#1#2{ - % adds to the lower index +\cs_new:Npn\semantex_primitive_valuekey_slowerleft:nn#1#2{ \tl_if_blank:nF{#2} { - \g_semantex_data_bool_get:nnTF { #1 } { first_lower_left } + \semantex_data_bool_get:nnTF { #1 } { nextlowerleftwithsep } { - \g_semantex_data_tl_put_left:nnn { #1 } { lower_left_index } { \exp_not:n { #2 } } + \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 } } } { - \g_semantex_data_tl_put_left:nnn { #1 } { lower_left_index } { \exp_not:n { #2 } } - \g_semantex_data_tl_put_left:nnx { #1 } { lower_left_index } - { \exp_not:n { \g_semantex_data_tl_get:nn { #1 } { lowerleftsep } } } + \semantex_data_tl_put_left:nnn { #1 } { lowerleft } { \exp_not:n { #2 } } } - \g_semantex_data_bool_set_false:nn { #1 } { first_lower_left } + \semantex_data_bool_set_true:nn { #1 } { nextlowerleftwithsep } + \semantex_data_int_incr:nn { #1 } { numberoflowerleftindices } } } -\cs_new:Npn\g_semantex_primitive_valuekey_lowerleftaddright:nn#1#2{ - % adds to the lower index +\cs_new:Npn\semantex_primitive_valuekey_lowerleftputright:nn#1#2{ \tl_if_blank:nF{#2} %This test really shouldn’t be made. { - \g_semantex_data_tl_put_right:nnn { #1 } { lower_left_index } { \exp_not:n{ #2 } } - \g_semantex_data_bool_set_false:nn { #1 } { first_lower_left } + \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 } } } -\cs_new:Npn\g_semantex_primitive_valuekey_prelowerleft:nn#1#2{ - % adds to the lower index +\cs_new:Npn\semantex_primitive_valuekey_prelowerleft:nn#1#2{ \tl_if_blank:nF{#2} { - \g_semantex_data_tl_put_left:nnn { #1 } { prelowerleft } { \exp_not:n{ #2 } } + \semantex_data_tl_put_left:nnn { #1 } { prelowerleft } { \exp_not:n{ #2 } } } } -\cs_new:Npn\g_semantex_primitive_valuekey_postlowerleft:nn#1#2{ - % adds to the lower index +\cs_new:Npn\semantex_primitive_valuekey_postlowerleft:nn#1#2{ \tl_if_blank:nF{#2} { - \g_semantex_data_tl_put_right:nnn { #1 } { postlowerleft } { \exp_not:n{ #2 } } + \semantex_data_tl_put_right:nnn { #1 } { postlowerleft } { \exp_not:n{ #2 } } } } -\cs_new:Npn\g_semantex_primitive_valuekey_upperleftsep:nn#1#2{ - % adds to the upper index - \g_semantex_data_bool_get:nnTF { #1 } { first_left_upper } +\cs_new:Npn\semantex_primitive_valuekey_upperleftwithothersep:nn#1#2{ + \semantex_data_bool_get:nnTF { #1 } { nextupperleftwithsep } { - \g_semantex_data_tl_put_left:nnn { #1 } { upper_left_index } { - \exp_not:n { \g_semantex_primitive_upper_lower_auxiliary_second_arg:nn #2 } + \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 } } } { - \g_semantex_data_tl_put_left:nnn { #1 } { upper_left_index } { - \exp_not:n { \g_semantex_primitive_upper_lower_auxiliary_second_arg:nn #2 \g_semantex_primitive_upper_lower_auxiliary_first_arg:nn #2 } + \semantex_data_tl_put_left:nnn { #1 } { upperleft } { + \exp_not:n { \semantex_grab_second_argument_of_two:nn #2 } } } - \g_semantex_data_bool_set_false:nn { #1 } { first_left_upper } + \semantex_data_bool_set_true:nn { #1 } { nextupperleftwithsep } + \semantex_data_int_incr:nn { #1 } { numberofupperleftindices } } -\cs_new:Npn\g_semantex_primitive_valuekey_lowerleftsep:nn#1#2{ - % adds to the lower index - \g_semantex_data_bool_get:nnTF { #1 } { first_lower_left } +\cs_new:Npn\semantex_primitive_valuekey_lowerleftwithothersep:nn#1#2{ + \semantex_data_bool_get:nnTF { #1 } { nextlowerleftwithsep } { - \g_semantex_data_tl_put_left:nnn { #1 } { lower_left_index } { - \exp_not:n { \g_semantex_primitive_upper_lower_auxiliary_second_arg:nn #2 } + \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 } } } { - \g_semantex_data_tl_put_left:nnn { #1 } { lower_left_index } { - \exp_not:n { \g_semantex_primitive_upper_lower_auxiliary_second_arg:nn #2 \g_semantex_primitive_upper_lower_auxiliary_first_arg:nn #2 } + \semantex_data_tl_put_left:nnn { #1 } { lowerleft } { + \exp_not:n { \semantex_grab_second_argument_of_two:nn #2 } } } - \g_semantex_data_bool_set_false:nn { #1 } { first_lower_left } + \semantex_data_bool_set_true:nn { #1 } { nextlowerleftwithsep } + \semantex_data_int_incr:nn { #1 } { numberoflowerleftindices } } -\cs_new:Npn\g_semantex_primitive_valuekey_cupperleft:nn#1#2{ - % adds to the upper index +\cs_new:Npn\semantex_primitive_valuekey_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_primitive_valuekey_clearprelowerleft:nn#1#2{ + \semantex_data_tl_clear:nn { #1 } { prelowerleft } +} + +\cs_new:Npn\semantex_primitive_valuekey_clearpostlowerleft:nn#1#2{ + \semantex_data_tl_clear:nn { #1 } { prelowerleft } +} + +\cs_new:Npn\semantex_primitive_valuekey_setlowerleftdots:nn#1#2 +{ + \semantex_data_tl_set:nnn { #1 } { lowerleftdots } { \exp_not:n { #2 } } +} + +\cs_generate_variant:Nn \semantex_primitive_valuekey_lowerleft:nn { nx } + +\cs_new:Npn\semantex_primitive_valuekey_lowerleftdots:nn#1#2 +{ + \semantex_primitive_valuekey_lowerleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerleftdots } } +} + +\cs_new:Npn\semantex_primitive_valuekey_setlowerleftslot:nn#1#2 +{ + \semantex_data_tl_set:nnn { #1 } { lowerleftslot } { \exp_not:n { #2 } } +} + +\cs_new:Npn\semantex_primitive_valuekey_lowerleftslot:nn#1#2 +{ + \semantex_primitive_valuekey_lowerleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerleftslot } } +} + +\cs_generate_variant:Nn \semantex_primitive_valuekey_slowerleft:nn { nx } + +\cs_new:Npn\semantex_primitive_valuekey_slowerleftdots:nn#1#2 +{ + \semantex_primitive_valuekey_slowerleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerleftdots } } +} + +\cs_new:Npn\semantex_primitive_valuekey_slowerleftslot:nn#1#2 +{ + \semantex_primitive_valuekey_slowerleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerleftslot } } +} + +\cs_generate_variant:Nn \semantex_primitive_valuekey_clowerleft:nn { nx } + +\cs_new:Npn\semantex_primitive_valuekey_clowerleftdots:nn#1#2 +{ + \semantex_primitive_valuekey_clowerleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerleftdots } } +} + +\cs_new:Npn\semantex_primitive_valuekey_clowerleftslot:nn#1#2 +{ + \semantex_primitive_valuekey_clowerleft:nx { #1 } { \semantex_data_tl_get:nn { #1 } { lowerleftslot } } +} + +\cs_generate_variant:Nn \semantex_primitive_valuekey_lowerleftwithothersep:nn { nx } + +\cs_new:Npn\semantex_primitive_valuekey_lowerleftdotswithothersep:nn#1#2 +{ + \semantex_primitive_valuekey_lowerleftwithothersep:nx { #1 } { { \exp_not:n { #2 } } { \semantex_data_tl_get:nn { #1 } { lowerleftdots } } } +} + +\cs_new:Npn\semantex_primitive_valuekey_lowerleftslotwithothersep:nn#1#2 +{ + \semantex_primitive_valuekey_lowerleftwithothersep:nx { #1 } { { \exp_not:n { #2 } } { \semantex_data_tl_get:nn { #1 } { lowerleftslot } } } +} + +\cs_new:Npn\semantex_primitive_valuekey_cupperleft:nn#1#2{ \tl_if_blank:nF{#2} { - \g_semantex_data_bool_get:nnTF { #1 } { first_upper_left } + \semantex_data_bool_get:nnTF { #1 } { nextupperleftwithsep } { - \g_semantex_data_tl_put_left:nnn { #1 } { upper_left_index } { \exp_not:n { #2 } } + \semantex_data_tl_put_left:nnn { #1 } { upperleft } { \exp_not:n { #2 } , } } { - \g_semantex_data_tl_put_left:nnn { #1 } { upper_left_index } { \exp_not:n { #2 } , } + \semantex_data_tl_put_left:nnn { #1 } { upperleft } { \exp_not:n { #2 } } } - \g_semantex_data_bool_set_false:nn { #1 } { first_upper_left } + \semantex_data_bool_set_true:nn { #1 } { nextupperleftwithsep } + \semantex_data_int_incr:nn { #1 } { numberofupperleftindices } } } -\cs_new:Npn\g_semantex_primitive_valuekey_clowerleft:nn#1#2{ - % adds to the lower index +\cs_new:Npn\semantex_primitive_valuekey_clowerleft:nn#1#2{ \tl_if_blank:nF{#2} { - \g_semantex_data_bool_get:nnTF { #1 } { first_lower_left } + \semantex_data_bool_get:nnTF { #1 } { nextlowerleftwithsep } { - \g_semantex_data_tl_put_left:nnn { #1 } { lower_left_index } { \exp_not:n { #2 } } + \semantex_data_tl_put_left:nnn { #1 } { lowerleft } { \exp_not:n { #2 } , } } { - \g_semantex_data_tl_put_left:nnn { #1 } { lower_left_index } { \exp_not:n { #2 } , } + \semantex_data_tl_put_left:nnn { #1 } { lowerleft } { \exp_not:n { #2 } } } - \g_semantex_data_bool_set_false:nn { #1 } { first_lower_left } + \semantex_data_bool_set_true:nn { #1 } { nextlowerleftwithsep } + \semantex_data_int_incr:nn { #1 } { numberoflowerleftindices } } } - -\cs_new:Npn\g_semantex_primitive_valuekey_iffirstupperleft:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_ifnextupperleftwithsep:nn#1#2 { - \tl_if_eq:nnTF { #2 } { true } + \tl_if_eq:nnTF { #2 } { false } { - \g_semantex_data_bool_set_true:nn { #1 } { first_upper_left } + \semantex_data_bool_set_false:nn { #1 } { nextupperleftwithsep } } { - \tl_if_eq:nnTF { #2 } { false } + \tl_if_eq:nnTF { #2 } { true } { - \g_semantex_data_bool_set_false:nn { #1 } { first_upper_left } + \semantex_data_bool_set_true:nn { #1 } { nextupperleftwithsep } } { - %IM Throw error later + \semantex_error_output_format:nN { #1 } \l__semantex_primitive_valuekey_ifnextupperleftwithsep_temp + \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_primitive_valuekey_ifnextupperleftwithsep_temp } { ifnextupperleftwithsep } { #2 } } } } -\cs_new:Npn\g_semantex_primitive_valuekey_iffirstlowerleft:nn#1#2 + +\cs_new:Npn\semantex_primitive_valuekey_ifnextlowerleftwithsep:nn#1#2 { - \tl_if_eq:nnTF { #2 } { true } + \tl_if_eq:nnTF { #2 } { false } { - \g_semantex_data_bool_set_true:nn { #1 } { first_lower_left } + \semantex_data_bool_set_false:nn { #1 } { nextlowerleftwithsep } } { - \tl_if_eq:nnTF { #2 } { false } + \tl_if_eq:nnTF { #2 } { true } { - \g_semantex_data_bool_set_false:nn { #1 } { first_lower_left } + \semantex_data_bool_set_true:nn { #1 } { nextlowerleftwithsep } } { - %IM Throw error later + semantex_error_output_format:nN { #1 } \l__semantex_primitive_valuekey_ifnextlowerleftwithsep_temp + \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_primitive_valuekey_ifnextlowerleftwithsep_temp } { ifnextlowerleftwithsep } { #2 } } } } -\cs_new:Npn\g_semantex_primitive_valuekey_setupperleftsep:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_setupperleftsep:nn#1#2 { - \g_semantex_data_tl_set:nnn { #1 } { upperleftsep } { \exp_not:n { #2 } } + \semantex_data_tl_set:nnn { #1 } { upperleftsep } { \exp_not:n { #2 } } } -\cs_new:Npn\g_semantex_primitive_valuekey_setlowerleftsep:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_setlowerleftsep:nn#1#2 { - \g_semantex_data_tl_set:nnn { #1 } { lowerleftsep } { \exp_not:n { #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\g_semantex_primitive_valuekey_iffirstd:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_ifnextdwithsep:nn#1#2 % should be removed later { - \g_semantex_data_bool_get:nnTF { #1 } { upper_grading } - { \g_semantex_primitive_valuekey_iffirstupper:nn { #1 } { #2 } } - { \g_semantex_primitive_valuekey_iffirstlower:nn { #1 } { #2 } } + % Tells whether the d (degree) is empty or not + \str_if_eq:nnTF { #2 } { true } + { + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { \semantex_primitive_valuekey_ifnextupperwithsep:nn { #1 } { #2 } } + { \semantex_primitive_valuekey_ifnextlowerwithsep:nn { #1 } { #2 } } + } + { + \str_if_eq:nnTF { #2 } { false } + { + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { \semantex_primitive_valuekey_ifnextupperwithsep:nn { #1 } { #2 } } + { \semantex_primitive_valuekey_ifnextlowerwithsep:nn { #1 } { #2 } } + } + { + \semantex_error_output_format:nN { #1 } \l__semantex_primitive_valuekey_ifnextdwithsep_temp + \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_primitive_valuekey_ifnextdwithsep_temp } { ifnextdwithsep } { #2 } + } + } } -\cs_set_eq:NN\g_semantex_primitive_valuekey_iffirstdeg:nn\g_semantex_primitive_valuekey_iffirstd:nn +\cs_set_eq:NN\semantex_primitive_valuekey_ifnextdegwithsep:nn\semantex_primitive_valuekey_ifnextdwithsep -\cs_set_eq:NN\g_semantex_primitive_valuekey_iffirstdegree:nn\g_semantex_primitive_valuekey_iffirstd:nn +\cs_set_eq:NN\semantex_primitive_valuekey_ifnextdegreewithsep:nn\semantex_primitive_valuekey_ifnextdwithsep -\cs_new:Npn\g_semantex_primitive_valuekey_iffirsti:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_ifnextiwithsep:nn#1#2 { - \g_semantex_data_bool_get:nnTF { #1 } { upper_grading } - { \g_semantex_primitive_valuekey_iffirstlower:nn { #1 } { #2 } } - { \g_semantex_primitive_valuekey_iffirstupper: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_primitive_valuekey_ifnextlowerwithsep:nn { #1 } { #2 } } + { \semantex_primitive_valuekey_ifnextupperwithsep:nn { #1 } { #2 } } + } + { + \str_if_eq:nnTF { #2 } { false } + { + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { \semantex_primitive_valuekey_ifnextlowerwithsep:nn { #1 } { #2 } } + { \semantex_primitive_valuekey_ifnextupperwithsep:nn { #1 } { #2 } } + } + { + \semantex_error_output_format:nN { #1 } \l__semantex_primitive_valuekey_ifnextiwithsep_temp + \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_primitive_valuekey_ifnextiwithsep_temp } { ifnextiwithsep } { #2 } + } + } } -\cs_set_eq:NN\g_semantex_primitive_valuekey_iffirstindex:nn\g_semantex_primitive_valuekey_iffirsti:nn +\cs_set_eq:NN\semantex_primitive_valuekey_ifnextindexwithsep:nn\semantex_primitive_valuekey_ifnextiwithsep:nn -\cs_new:Npn\g_semantex_primitive_valuekey_d:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_d:nn#1#2 { % adds to the d-index (upper by default) - % I added an \exp_not:n here and in similar commands to - % take care of \underbrace expansion issues. However, - % I am puzzled as to why it was necessary. - %\bool_if:cTF { semantex_data_bool_#1_if_upper_grading } - \g_semantex_data_bool_get:nnTF { #1 } { upper_grading } + \semantex_data_bool_get:nnTF { #1 } { uppergrading } { - \g_semantex_primitive_valuekey_upper:nn { #1 } { #2 } + \semantex_primitive_valuekey_upper:nn { #1 } { #2 } } { - \g_semantex_primitive_valuekey_lower:nn { #1 } { #2 } + \semantex_primitive_valuekey_lower:nn { #1 } { #2 } } } -\cs_set_eq:NN\g_semantex_primitive_valuekey_deg:nn\g_semantex_primitive_valuekey_d:nn +\cs_set_eq:NN\semantex_primitive_valuekey_deg:nn\semantex_primitive_valuekey_d:nn -\cs_set_eq:NN\g_semantex_primitive_valuekey_degree:nn\g_semantex_primitive_valuekey_d:nn +\cs_set_eq:NN\semantex_primitive_valuekey_degree:nn\semantex_primitive_valuekey_d:nn -\cs_new:Npn\g_semantex_primitive_valuekey_sd:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_sd:nn#1#2 { % adds to the d-index (upper by default) - \g_semantex_data_bool_get:nnTF { #1 } { upper_grading } + \semantex_data_bool_get:nnTF { #1 } { uppergrading } { - \g_semantex_primitive_valuekey_supper:nn { #1 } { #2 } + \semantex_primitive_valuekey_supper:nn { #1 } { #2 } } { - \g_semantex_primitive_valuekey_slower:nn { #1 } { #2 } + \semantex_primitive_valuekey_slower:nn { #1 } { #2 } } } -\cs_set_eq:NN\g_semantex_primitive_valuekey_sdeg:nn\g_semantex_primitive_valuekey_sd:nn +\cs_set_eq:NN\semantex_primitive_valuekey_sdeg:nn\semantex_primitive_valuekey_sd:nn -\cs_set_eq:NN\g_semantex_primitive_valuekey_sdegree:nn\g_semantex_primitive_valuekey_sd:nn +\cs_set_eq:NN\semantex_primitive_valuekey_sdegree:nn\semantex_primitive_valuekey_sd:nn -\cs_new:Npn\g_semantex_primitive_valuekey_cd:nn#1#2{ %IM Maybe remove this. +\cs_new:Npn\semantex_primitive_valuekey_cd:nn#1#2{ %IM Maybe remove this. % adds to the d-index (upper by default) - \g_semantex_data_bool_get:nnTF { #1 } { upper_grading } - { - \g_semantex_primitive_valuekey_cupper:nn { #1 } { #2 } + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_cupper:nn { #1 } { #2 } } { - \g_semantex_primitive_valuekey_clower:nn { #1 } { #2 } + \semantex_primitive_valuekey_clower:nn { #1 } { #2 } } } +\cs_set_eq:NN\semantex_primitive_valuekey_sdeg:nn\semantex_primitive_valuekey_cd:nn +\cs_set_eq:NN\semantex_primitive_valuekey_sdegree:nn\semantex_primitive_valuekey_cd:nn -\cs_set_eq:NN\g_semantex_primitive_valuekey_cdeg:nn\g_semantex_primitive_valuekey_cd:nn - -\cs_set_eq:NN\g_semantex_primitive_valuekey_cdegree:nn\g_semantex_primitive_valuekey_cd:nn +\cs_new:Npn\semantex_primitive_valuekey_i:nn#1#2{ + % adds to the i-index (lower by default) + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_lower:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_upper:nn { #1 } { #2 } + } +} +\cs_set_eq:NN\semantex_primitive_valuekey_index:nn\semantex_primitive_valuekey_i:nn -\cs_new:Npn\g_semantex_primitive_valuekey_i:nn#1#2{ +\cs_new:Npn\semantex_primitive_valuekey_si:nn#1#2{ % adds to the i-index (lower by default) - %\bool_if:cTF { semantex_data_bool_#1_if_upper_grading } - \g_semantex_data_bool_get:nnTF { #1 } { upper_grading } - { - \g_semantex_primitive_valuekey_lower:nn { #1 } { #2 } + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_slower:nn { #1 } { #2 } } { - \g_semantex_primitive_valuekey_upper:nn { #1 } { #2 } + \semantex_primitive_valuekey_supper:nn { #1 } { #2 } } } -\cs_set_eq:NN\g_semantex_primitive_valuekey_index:nn\g_semantex_primitive_valuekey_i:nn +\cs_set_eq:NN\semantex_primitive_valuekey_sindex:nn\semantex_primitive_valuekey_si:nn -\cs_new:Npn\g_semantex_primitive_valuekey_si:nn#1#2{ +\cs_new:Npn\semantex_primitive_valuekey_ci:nn#1#2{ % adds to the i-index (lower by default) - \g_semantex_data_bool_get:nnTF { #1 } { upper_grading } + \semantex_data_bool_get:nnTF { #1 } { uppergrading } { - \g_semantex_primitive_valuekey_slower:nn { #1 } { #2 } + \semantex_primitive_valuekey_clower:nn { #1 } { #2 } } { - \g_semantex_primitive_valuekey_supper:nn { #1 } { #2 } + \semantex_primitive_valuekey_cupper:nn { #1 } { #2 } } } -\cs_set_eq:NN\g_semantex_primitive_valuekey_sindex:nn\g_semantex_primitive_valuekey_si:nn +\cs_set_eq:NN\semantex_primitive_valuekey_cindex:nn\semantex_primitive_valuekey_ci:nn + -\cs_new:Npn\g_semantex_primitive_valuekey_ci:nn#1#2{ + +\cs_new:Npn\semantex_primitive_valuekey_dwithothersep:nn#1#2 +{ + % adds to the d-index (upper by default) + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_upperwithothersep:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_lowerwithothersep:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_degwithothersep:nn\semantex_primitive_valuekey_dwithothersep:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_degreewithothersep:nn\semantex_primitive_valuekey_dwithothersep:nn + + +\cs_new:Npn\semantex_primitive_valuekey_iwithothersep:nn#1#2{ % adds to the i-index (lower by default) - %\bool_if:cTF { semantex_data_bool_#1_if_upper_grading } - \g_semantex_data_bool_get:nnTF { #1 } { upper_grading } + \semantex_data_bool_get:nnTF { #1 } { uppergrading } { - \g_semantex_primitive_valuekey_clower:nn { #1 } { #2 } + \semantex_primitive_valuekey_lowerwithothersep:nn { #1 } { #2 } } { - \g_semantex_primitive_valuekey_cupper:nn { #1 } { #2 } + \semantex_primitive_valuekey_upperwithothersep:nn { #1 } { #2 } } } -\cs_set_eq:NN\g_semantex_primitive_valuekey_cindex:nn\g_semantex_primitive_valuekey_ci:nn +\cs_set_eq:NN\semantex_primitive_valuekey_indexwithothersep:nn\semantex_primitive_valuekey_iwithothersep:nn + +\cs_new:Npn\semantex_primitive_valuekey_setdsep:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_setuppersep:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_setlowersep:nn { #1 } { #2 } + } +} +\cs_set_eq:NN\semantex_primitive_valuekey_setdegsep:nn\semantex_primitive_valuekey_setdsep:nn -\cs_new:Npn\g_semantex_primitive_valuekey_par:nn#1#2{ - % sets the size of the parentheses - \g_semantex_data_tl_set:nnn { #1 } { par_size }{ \exp_not:n { #2 } } - \g_semantex_primitive_valuekey_ifpar:nn { #1 } { true } +\cs_set_eq:NN\semantex_primitive_valuekey_setdegreesep:nn\semantex_primitive_valuekey_setdsep:nn + +\cs_new:Npn\semantex_primitive_valuekey_setisep:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_setlowersep:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_setuppersep:nn { #1 } { #2 } + } } +\cs_set_eq:NN\semantex_primitive_valuekey_setindexsep:nn\semantex_primitive_valuekey_setisep:nn -\cs_new:Npn\g_semantex_primitive_valuekey_parsize:nn#1#2{ - % sets the size of the parentheses - \g_semantex_data_tl_set:nnn { #1 } { par_size }{ \exp_not:n { #2 } } +\cs_new:Npn\semantex_primitive_valuekey_pred:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_preupper:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_prelower:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_predeg:nn\semantex_primitive_valuekey_pred:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_predegree:nn\semantex_primitive_valuekey_pred:nn + +\cs_new:Npn\semantex_primitive_valuekey_postd:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_postupper:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_postlower:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_postdeg:nn\semantex_primitive_valuekey_postd:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_postdegree:nn\semantex_primitive_valuekey_postd:nn + + +\cs_set:Npn\semantex_primitive_valuekey_cleard:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_clearupper:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_clearlower:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_cleardeg:nn\semantex_primitive_valuekey_cleard:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_cleardegree:nn\semantex_primitive_valuekey_cleard:nn + + +\cs_set:Npn\semantex_primitive_valuekey_clearpred:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_clearpreupper:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_clearprelower:nn { #1 } { #2 } + } } +\cs_set_eq:NN\semantex_primitive_valuekey_clearpredeg:nn\semantex_primitive_valuekey_clearpred:nn +\cs_set_eq:NN\semantex_primitive_valuekey_clearpredegree:nn\semantex_primitive_valuekey_clearpred:nn -\cs_new:Npn\g_semantex_primitive_valuekey_leftpar:nn#1#2{ -% \g_semantex_data_tl_set:nnn { #1 } { par_open }{ \exp_not:n { #2 } } - \tl_set:cn { semantex_data_tl_#1_par_open }{ \exp_not:n { #2 } } +\cs_set:Npn\semantex_primitive_valuekey_clearpostd:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_clearpostupper:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_clearpostlower:nn { #1 } { #2 } + } } +\cs_set_eq:NN\semantex_primitive_valuekey_clearpostdeg:nn\semantex_primitive_valuekey_clearpostd:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_clearpostdegree:nn\semantex_primitive_valuekey_clearpostd:nn + + +\cs_new:Npn\semantex_primitive_valuekey_prei:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_prelower:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_preupper:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_preindex:nn\semantex_primitive_valuekey_prei:nn + +\cs_new:Npn\semantex_primitive_valuekey_posti:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_postlower:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_postupper:nn { #1 } { #2 } + } +} +\cs_set_eq:NN\semantex_primitive_valuekey_postindex:nn\semantex_primitive_valuekey_posti:nn +\cs_set:Npn\semantex_primitive_valuekey_cleari:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_clearlower:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_clearupper:nn { #1 } { #2 } + } +} +\cs_set_eq:NN\semantex_primitive_valuekey_clearindex:nn\semantex_primitive_valuekey_cleari:nn -\cs_new:Npn\g_semantex_primitive_valuekey_rightpar:nn#1#2{ - \g_semantex_data_tl_set:nnn { #1 } { par_close }{ \exp_not:n { #2 } } +\cs_set:Npn\semantex_primitive_valuekey_clearprei:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_clearprelower:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_clearpreupper:nn { #1 } { #2 } + } } +\cs_set_eq:NN\semantex_primitive_valuekey_clearpreindex:nn\semantex_primitive_valuekey_clearprei:nn -\cs_new:Npn\g_semantex_primitive_valuekey_ifpar:nn#1#2{ %IMPLEMENT THIS +\cs_set:Npn\semantex_primitive_valuekey_clearposti:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_clearpostlower:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_clearpostupper:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_clearpostindex:nn\semantex_primitive_valuekey_clearposti:nn + + +\cs_new:Npn\semantex_primitive_valuekey_setddots: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 } } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_setdegdots:nn\semantex_primitive_valuekey_setddots:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_setdegreedots:nn\semantex_primitive_valuekey_setddots:nn + +\cs_new:Npn\semantex_primitive_valuekey_ddots:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_upperdots:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_lowerdots:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_degdots:nn\semantex_primitive_valuekey_ddots:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_degreedots:nn\semantex_primitive_valuekey_ddots:nn + +\cs_new:Npn\semantex_primitive_valuekey_setdslot:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_setupperslot:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_setlowerslot:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_setdegslot:nn\semantex_primitive_valuekey_setdslot:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_setdegreeslot:nn\semantex_primitive_valuekey_setdslot:nn + +\cs_new:Npn\semantex_primitive_valuekey_dslot:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_upperslot:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_lowerslot:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_degslot:nn\semantex_primitive_valuekey_dslot:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_degreeslot:nn\semantex_primitive_valuekey_dslot:nn + +\cs_new:Npn\semantex_primitive_valuekey_sddots:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_supperdots:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_slowerdots:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_sdegdots:nn\semantex_primitive_valuekey_sddots:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_sdegreedots:nn\semantex_primitive_valuekey_sddots:nn + + +\cs_new:Npn\semantex_primitive_valuekey_sdslot:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_supperslot:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_slowerslot:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_sdegslot:nn\semantex_primitive_valuekey_sdslot:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_sdegreeslot:nn\semantex_primitive_valuekey_sdslot:nn + +\cs_new:Npn\semantex_primitive_valuekey_cddots:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_cupperdots:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_clowerdots:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_cdegdots:nn\semantex_primitive_valuekey_cddots:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_cdegreedots:nn\semantex_primitive_valuekey_cddots:nn + +\cs_new:Npn\semantex_primitive_valuekey_cdslot:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_cupperslot:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_clowerslot:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_cdegslot:nn\semantex_primitive_valuekey_cdslot:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_cdegreeslot:nn\semantex_primitive_valuekey_cdslot:nn + +\cs_new:Npn\semantex_primitive_valuekey_ddotswithothersep:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_upperdotswithothersep:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_lowerdotswithothersep:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_degdotswithothersep:nn\semantex_primitive_valuekey_ddotswithothersep:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_degreedotswithothersep:nn\semantex_primitive_valuekey_ddotswithothersep:nn + +\cs_new:Npn\semantex_primitive_valuekey_dslotwithothersep:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_upperslotwithothersep:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_lowerslotwithothersep:nn { #1 } { #2 } + } +} + + + +%---------------------------------------------------------- + +\cs_new:Npn\semantex_primitive_valuekey_setidots:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_data_tl_set:nnn { #1 } { lowerdots } { \exp_not:n { #2 } } + } + { + \semantex_data_tl_set:nnn { #1 } { upperdots } { \exp_not:n { #2 } } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_setindexdots:nn\semantex_primitive_valuekey_setidots:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_setdegreedots:nn\semantex_primitive_valuekey_setidots:nn + +\cs_new:Npn\semantex_primitive_valuekey_idots:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_lowerdots:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_upperdots:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_indexdots:nn\semantex_primitive_valuekey_idots:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_degreedots:nn\semantex_primitive_valuekey_idots:nn + +\cs_new:Npn\semantex_primitive_valuekey_setislot:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_setlowerslot:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_setupperslot:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_setindexslot:nn\semantex_primitive_valuekey_setislot:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_setdegreeslot:nn\semantex_primitive_valuekey_setislot:nn + +\cs_new:Npn\semantex_primitive_valuekey_islot:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_lowerslot:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_upperslot:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_indexslot:nn\semantex_primitive_valuekey_islot:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_degreeslot:nn\semantex_primitive_valuekey_islot:nn + +\cs_new:Npn\semantex_primitive_valuekey_sidots:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_slowerdots:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_supperdots:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_sindexdots:nn\semantex_primitive_valuekey_sidots:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_sdegreedots:nn\semantex_primitive_valuekey_sidots:nn + + +\cs_new:Npn\semantex_primitive_valuekey_sislot:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_slowerslot:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_supperslot:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_sindexslot:nn\semantex_primitive_valuekey_sislot:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_sdegreeslot:nn\semantex_primitive_valuekey_sislot:nn + +\cs_new:Npn\semantex_primitive_valuekey_cidots:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_clowerdots:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_cupperdots:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_cindexdots:nn\semantex_primitive_valuekey_cidots:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_cdegreedots:nn\semantex_primitive_valuekey_cidots:nn + +\cs_new:Npn\semantex_primitive_valuekey_cislot:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_clowerslot:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_cupperslot:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_cindexslot:nn\semantex_primitive_valuekey_cislot:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_cdegreeslot:nn\semantex_primitive_valuekey_cislot:nn + +\cs_new:Npn\semantex_primitive_valuekey_idotswithothersep:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_lowerdotswithothersep:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_upperdotswithothersep:nn { #1 } { #2 } + } +} + +\cs_set_eq:NN\semantex_primitive_valuekey_indexdotswithothersep:nn\semantex_primitive_valuekey_idotswithothersep:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_degreedotswithothersep:nn\semantex_primitive_valuekey_idotswithothersep:nn + +\cs_new:Npn\semantex_primitive_valuekey_islotwithothersep:nn#1#2 +{ + \semantex_data_bool_get:nnTF { #1 } { uppergrading } + { + \semantex_primitive_valuekey_lowerslotwithothersep:nn { #1 } { #2 } + } + { + \semantex_primitive_valuekey_upperslotwithothersep:nn { #1 } { #2 } + } +} + +%---------------------------------------------------------- + +\cs_set_eq:NN\semantex_primitive_valuekey_degslotwithothersep:nn\semantex_primitive_valuekey_dslotwithothersep:nn + +\cs_set_eq:NN\semantex_primitive_valuekey_degreeslotwithothersep:nn\semantex_primitive_valuekey_dslotwithothersep:nn + +\cs_new:Npn\semantex_primitive_valuekey_par:nn#1#2{ + % Turns parentheses on, and sets their size + \semantex_data_tl_set:nnn { #1 } { parsize }{ \exp_not:n { #2 } } + \semantex_primitive_valuekey_ifpar:nn { #1 } { true } +} + +\cs_new:Npn\semantex_primitive_valuekey_parsize:nn#1#2{ + % Sets the size of the parentheses + \semantex_data_tl_set:nnn { #1 } { parsize }{ \exp_not:n { #2 } } +} + +\cs_new:Npn\semantex_primitive_valuekey_leftpar:nn#1#2{ + \semantex_data_tl_set:nnn { #1 } { leftpar }{ \exp_not:n { #2 } } +} + +\cs_new:Npn\semantex_primitive_valuekey_rightpar:nn#1#2{ + \semantex_data_tl_set:nnn { #1 } { rightpar }{ \exp_not:n { #2 } } +} + +\cs_new:Npn\semantex_primitive_valuekey_ifpar:nn#1#2{ %IMPLEMENT THIS % tells whether to use the output class or not - \g_semantex_data_bool_provide:nn { #1 } { par } + \semantex_data_bool_provide:nn { #1 } { par } \str_if_eq:nnTF { #2 } { true } { - \g_semantex_data_bool_set_true:nn { #1 } { par } + \semantex_data_bool_set_true:nn { #1 } { par } + \semantex_data_bool_set_false:nn { #1 } { flexpar } } { - \str_if_eq:nnTF { #2 } { false } + \str_if_eq:nnTF { #2 } { never } { - \g_semantex_data_bool_set_false:nn { #1 } { par } + \semantex_data_bool_set_false:nn { #1 } { par } + \semantex_data_bool_set_false:nn { #1 } { flexpar } } { - %IM do nothing right now, but should - %IM probably throw an error + \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_primitive_valuekey_ifpar_temp + \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_primitive_valuekey_ifpar_temp } { ifpar } { #2 } + } } } } - - -\cs_new:Npn\g_semantex_primitive_valuekey_spar:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_spar:nn#1#2 { + % Abbreviation for "symbol parentheses" + % Adds parentheses around the current symbol + \semantex_primitive_valuekey_return:nn { #1 }{} + \semantex_data_tl_inherit:nn { #1 } { symbol } % Check if really necessary \tl_if_blank:nTF { #2 } { - \g_semantex_primitive_valuekey_return:nn { #1 }{} - \g_semantex_data_tl_set:nnx { #1 } { symbol } + \semantex_data_tl_get_store:nnN { #1 } { sparsize } \l__semantex_primitive_valuekey_spar_sparsize_temp + \__semantex_symbol_parentheses_store:nnnnN + { \l__semantex_primitive_valuekey_spar_sparsize_temp } + { \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_primitive_valuekey_spar_temp + \semantex_data_tl_set:nnx { #1 } { symbol } { - { \g_semantex_data_tl_get_exp_not:nn { #1 } { spar_size } } - %IM like in _return - { \g_semantex_data_tl_get:nn { #1 } { spar_open } } - { \g_semantex_data_tl_get:nn { #1 } { spar_close } } - { \g_semantex_data_tl_get_exp_not:nn { #1 } { symbol } } -% { \l__semantex_spar_symbol_temp } - } - \g_semantex_data_tl_put_left:nnn { #1 } { symbol } - { - \exp_not:N - \g_semantex_symbol_parentheses:nnnn + \exp_not:V\l__semantex_primitive_valuekey_spar_temp } } { - \g_semantex_data_tl_inherit:nn { #1 } { symbol } - \g_semantex_primitive_valuekey_return:nn { #1 }{} - \g_semantex_data_tl_set:nnx { #1 } { symbol } + \tl_set:Nn \l__semantex_primitive_valuekey_spar_sparsize_temp { \exp_not:n { #2 } } + \__semantex_symbol_parentheses_store:nnnnN + { \l__semantex_primitive_valuekey_spar_sparsize_temp } + { \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_primitive_valuekey_spar_temp + \semantex_data_tl_set:nnx { #1 } { symbol } { - { \exp_not:n { \exp_not:n { #2 } } } - { \g_semantex_data_tl_get:nn { #1 } { spar_open } } - { \g_semantex_data_tl_get:nn { #1 } { spar_close } } - { \g_semantex_data_tl_get_exp_not:nn { #1 } { symbol } } - } - \g_semantex_data_tl_put_left:nnn { #1 } { symbol } - { - \exp_not:N - \g_semantex_symbol_parentheses:nnnn + \exp_not:V\l__semantex_primitive_valuekey_spar_temp } } } -\cs_new:Npn\g_semantex_primitive_valuekey_iffirstarg:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_ifnextargwithsep:nn#1#2 { + % Tells whether it is the first argument or not \tl_if_eq:nnTF { #2 } { true } { - \g_semantex_data_bool_set_true:nn { #1 } { first_arg } + \semantex_data_bool_set_true:nn { #1 } { nextargwithsep } } { \tl_if_eq:nnTF { #2 } { false } { - \g_semantex_data_bool_set_false:nn { #1 } { first_arg } + \semantex_data_bool_set_false:nn { #1 } { nextargwithsep } } { - %IM Throw error later + \semantex_error_output_format:nN { #1 } \l__semantex_primitive_valuekey_ifnextargwithsep_temp + \msg_error:nnxnn { semantex } { key_value_not_found } { \l__semantex_primitive_valuekey_ifnextargwithsep_temp } { ifnextargwithsep } { #2 } } } } -\cs_new:Npn\g_semantex_auxiliary_first_arg:nn#1#2 { #1 } -\cs_new:Npn\g_semantex_auxiliary_second_arg:nn#1#2 { #2 } - -%\cs_new:Npn\g_semantex_primitive_valuekey_otherspar:nn#1#2 -%{ -% \g_semantex_data_tl_inherit:nn { #1 } { spar_size } -% \g_semantex_data_tl_inherit:nn { #1 } { symbol } -% \g_semantex_primitive_novaluekey_return:n { #1 } -%% \tl_set:Nn\l__semantex_spar_temp -%% { -%% \exp_not:N -%% \g_semantex_symbol_parentheses:nnnn -%% } -%% \tl_put_right:Nx\l__semantex_spar_temp -%% { -%% { \exp_not:v { semantex_data_tl_#1_spar_size } } -%% { \g_semantex_auxiliary_first_arg:nn#2 } -%% { \g_semantex_auxiliary_second_arg:nn#2 } -%% { \exp_not:v { semantex_data_tl_#1_symbol } } -%% } -%% \tl_set:cx { semantex_data_tl_#1_symbol } { \exp_not:V\l__semantex_spar_temp } -% \tl_set:cx { semantex_data_tl_#1_symbol } -% { -% %{ \exp_not:c { semantex_data_tl_#1_spar_size } } -% { \exp_not:n { \use:c { semantex_data_tl_#1_spar_size } } } -% { \g_semantex_auxiliary_first_arg:nn #2 } -% { \g_semantex_auxiliary_second_arg:nn #2 } -% { \exp_not:v { semantex_data_tl_#1_symbol } } -% } -% \tl_put_left:cn { semantex_data_tl_#1_symbol } -% { -% \exp_not:N -% \g_semantex_symbol_parentheses:nnnn -% } -%} - -\cs_new:Npn\g_semantex_primitive_valuekey_otherspar:nn#1#2 +\cs_new:Npn\semantex_primitive_valuekey_otherspar:nn#1#2 { - \g_semantex_primitive_valuekey_otherspar_auxiliary:nnn { #1 } #2 + % Uses the syntax otherspar={leftpar}{rightpar} + % Adds a new spar, but with these as parentheses + \__semantex_primitive_valuekey_otherspar_auxiliary:nnn { #1 } #2 } -\cs_new:Npn\g_semantex_primitive_valuekey_otherspar_auxiliary:nnn#1#2#3 +\cs_new:Npn\__semantex_primitive_valuekey_otherspar_auxiliary:nnn#1#2#3 { - %IM DOES NOT WORK!!!!! - \g_semantex_data_tl_inherit:nn { #1 } { spar_size } - \g_semantex_data_tl_get_store:nnN { #1 } { spar_size } \l__semantex_otherspar_spar_size_temp - \g_semantex_data_tl_inherit:nn { #1 } { symbol } - \g_semantex_primitive_valuekey_return:nn { #1 }{} -% \tl_set:Nn\l__semantex_spar_temp -% { -% \exp_not:N -% \g_semantex_symbol_parentheses:nnnn -% } -% \tl_put_right:Nx\l__semantex_spar_temp -% { -% { \exp_not:v { semantex_data_tl_#1_spar_size } } -% { \g_semantex_auxiliary_first_arg:nn#2 } -% { \g_semantex_auxiliary_second_arg:nn#2 } -% { \exp_not:v { semantex_data_tl_#1_symbol } } -% } -% \tl_set:cx { semantex_data_tl_#1_symbol } { \exp_not:V\l__semantex_spar_temp } - \g_semantex_data_tl_set:nnx { #1 } { symbol } + \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_primitive_valuekey_return:nn { #1 }{} + \semantex_data_tl_get_store:nnN { #1 } { sparsize } \l__semantex_primitive_valuekey_otherspar_sparsize_temp + \__semantex_symbol_parentheses_store:nnnnN + { \l__semantex_primitive_valuekey_otherspar_sparsize_temp } + { \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_primitive_valuekey_otherspar_temp + \semantex_data_tl_set:nnx { #1 } { symbol } { - %{ \exp_not:c { semantex_data_tl_#1_spar_size } } - %{ \exp_not:n { \use:c { semantex_data_tl_#1_spar_size } } } - %{ normal } - %{ \exp_not:n { \exp_not:v { semantex_data_tl_#1_spar_size } } } - { \exp_not:V \l__semantex_otherspar_spar_size_temp } - { \exp_not:n { \exp_not:n { #2 } } } - { \exp_not:n { \exp_not:n { #3 } } } - { \g_semantex_data_tl_get_exp_not:nn { #1 } { symbol } } + \exp_not:V\l__semantex_primitive_valuekey_otherspar_temp } - \g_semantex_data_tl_put_left:nnn { #1 } { symbol } +} + +\cs_new:Npn\semantex_primitive_valuekey_Otherspar:nn#1#2 +{ + % Uses the syntax otherspar={leftpar}{rightpar}{size} + % Adds a new spar, but with these as parentheses and size + \__semantex_primitive_valuekey_Otherspar_auxiliary:nnnn { #1 } #2 +} + +\cs_new:Npn\__semantex_primitive_valuekey_Otherspar_auxiliary:nnnn#1#2#3#4 +{ + \tl_set:Nn\l__semantex_primitive_valuekey_Otherspar_sparsize_temp + { \exp_not:n { #4 } } + \__semantex_symbol_parentheses_store:nnnnN + { \l__semantex_primitive_valuekey_Otherspar_sparsize_temp } + { \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_primitive_valuekey_Otherspar_temp + \semantex_data_tl_set:nnx { #1 } { symbol } { - \exp_not:N - \g_semantex_symbol_parentheses:nnnn + \exp_not:V\l__semantex_primitive_valuekey_Otherspar_temp } -% \tl_put_left:cx { g_auomath_#1_symbol } -% { -% \exp_not:N -% \g_semantex_symbol_parentheses:nnnn -% } - %\tl_put_left:cn { semantex_data_tl_#1_symbol } - %{ - % \exp_not:N - % \g_semantex_symbol_parentheses:nnnn - %} } -\cs_new:Npn\g_semantex_primitive_valuekey_sparsize:nn#1#2{ +\cs_new:Npn\semantex_primitive_valuekey_sparsize:nn#1#2{ % sets the size of the parentheses - \g_semantex_data_tl_set:nnn { #1 } { spar_size }{ \exp_not:n { #2 } } + \semantex_data_tl_set:nnn { #1 } { sparsize }{ \exp_not:n { #2 } } } -\cs_new:Npn\g_semantex_primitive_valuekey_leftspar:nn#1#2{ - \g_semantex_data_tl_set:nnn { #1 } { spar_open }{ \exp_not:n { \exp_not:n { #2 } } } +\cs_new:Npn\semantex_primitive_valuekey_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\g_semantex_primitive_valuekey_rightspar:nn#1#2{ - \g_semantex_data_tl_set:nnn { #1 } { spar_close }{ \exp_not:n { \exp_not:n { #2 } } } +\cs_new:Npn\semantex_primitive_valuekey_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. } +\cs_generate_variant:Nn \semantex_keys_set:nn { nx, no, nV } % Only the first one is currently being used - - - - -%\msg_new:nnnn { semantex } { singlekey_not_found } { Unknown~key~#1~passed~to~object~#2~on~input~line~\msg_line_number: } {} - -\cs_generate_variant:Nn \g_semantex_keys_set:nn { nx, no, nV } - -\cs_generate_variant:Nn \exp_args:Nnx { cnx } - -\cs_new:Npn \g_semantex_valuekey:nnn#1#2#3{ - % Takes care of valuekeys, keys with a value +\cs_new:Npn \semantex_valuekey:nnn#1#2#3{ + % Takes care of valuekeys, keys taking a value % For the sake of implementation, the arguments % come in a strange order % #1 = value of key % #2 = name of the key % #3 = object - %\tl_set:Nn\l_semantex_key_value_temp{#1} - \tl_set:Nn\l_semantex_key_value_temp{\exp_not:n{#1}} - %\tl_set:Nx\l_semantex_key_value_temp{\exp_not:n{\exp_not:n{#1}}} % stores the content of the key in the temporary command \l_semantex_key_value_temp - %\tl_set:Nn\l_semantex_key_value_temp{#1} - %\tl_set:No\l_semantex_key_value_temp{\exp_not:n{#1}} % stores the content of the key in the temporary command \l_semantex_key_value_temp + \tl_set:Nn\l__semantex_key_value_temp{\exp_not:n{#1}} %IM think about using extra {...} to avoid interference with keyval str - \g_semantex_valuekey_get:nnNTF { #3 } { #2 } \l_semantex_custom_valuekey_temp + \semantex_valuekey_get:nnNTF { #3 } { #2 } \l__semantex_custom_valuekey_temp { - \g_semantex_keys_set:nx { #3 } - { \l_semantex_custom_valuekey_temp } + \semantex_keys_set:nx { #3 } + { \l__semantex_custom_valuekey_temp } } { - \cs_if_exist:cTF { g_semantex_primitive_valuekey_#2:nn } + \cs_if_exist:cTF { semantex_primitive_valuekey_#2:nn } { - \use:c { g_semantex_primitive_valuekey_#2:nn }{ #3 }{ #1 } + \use:c { semantex_primitive_valuekey_#2:nn }{ #3 }{ #1 } } { - \msg_error:nnnn { semantex } { keyval_not_found } { #2 } { #3 } + \semantex_error_output_format:nN { #3 } \__semantex_valuekey_unknown_key_temp + \msg_error:nnxn { semantex } { valuekey_not_found } { \__semantex_valuekey_unknown_key_temp } { #2 } } } } -\cs_generate_variant:Nn \g_semantex_keys_set:nn { nx } - -\cs_new:Npn \g_semantex_novaluekey:nn#1#2 +\cs_new:Npn \semantex_singlekey:nn#1#2 { % #1 = name of the key % #2 = object -% % takes care of single keys, keys without a value - \g_semantex_novaluekey_get:nnNTF { #2 } { #1 } \l_semantex_custom_novaluekey_temp +% Takes care of single keys, keys without a value + \semantex_singlekey_get:nnNTF { #2 } { #1 } \l__semantex_custom_singlekey_temp { - \g_semantex_keys_set:nx { #2 } + \semantex_keys_set:nx { #2 } { - \l_semantex_custom_novaluekey_temp + \l__semantex_custom_singlekey_temp } } { - \g_semantex_keys_set:nn { #2 } { default = { #1 } } + \semantex_keys_set:nn { #2 } { default = { #1 } } } } -%IMplement the same thing for upper, lower?? Probably not. - -\cs_new:Npn \g_semantex_arg_primitive_valuekey_sep_auxiliary_function_withsep:nn#1#2 -{ - #1#2 -} - -\cs_new:Npn \g_semantex_arg_primitive_valuekey_sep_auxiliary_function_withoutsep:nn#1#2 -{ - #2 -} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% COMMANDS CONTROLLING THE ARGUMENT KEYVAL INTERFACE +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\cs_new:Npn \g_semantex_primitive_arg_valuekey_sep:nn#1#2 +\cs_new:Npn \semantex_primitive_arg_valuekey_othersep:nn#1#2 { - \g_semantex_data_bool_get:nnTF { #1 } { first_arg } + % Uses syntax sep={separator}{argument}; adds an argument + % with the specified separator + \semantex_data_bool_get:nnTF { #1 } { nextargwithsep } { - \g_semantex_data_tl_put_right:nnn { #1 } { arg } { - \exp_not:n { \g_semantex_arg_primitive_valuekey_sep_auxiliary_function_withoutsep:nn #2 } + \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 + } } - %IM These do not use :x, unlike the ones below } { - \g_semantex_data_tl_put_right:nnn { #1 } { arg } { \exp_not:n { \g_semantex_arg_primitive_valuekey_sep_auxiliary_function_withsep: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 } - \g_semantex_primitive_valuekey_ifrightreturnbeforerender:nn{#1}{true} - \g_semantex_data_bool_set_false:nn { #1 } { first_arg } + \semantex_data_int_incr:nn { #1 } { numberofarguments } + \semantex_data_bool_set_true:nn { #1 } { nextargwithsep } } -\cs_new:Npn \g_semantex_primitive_arg_valuekey_standardsep:nn#1#2 +\cs_new:Npn \semantex_primitive_arg_valuekey_s:nn#1#2 { - \g_semantex_data_bool_get:nnTF { #1 } { first_arg } + % Adds to the argument, with the standard separator + \semantex_data_bool_get:nnTF { #1 } { nextargwithsep } { - \g_semantex_data_tl_put_right:nnn { #1 } { arg } { \exp_not:n { #2 } } + \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. } - { - \g_semantex_data_tl_put_right:nnx { #1 } { arg } { \exp_not:n { \g_semantex_data_tl_get:nn { #1 } { argsep } } } - \g_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. - } -% \g_semantex_primitive_valuekey_ifoutput:nn { #1 } { true } - \g_semantex_primitive_valuekey_ifrightreturnbeforerender:nn{#1}{true} - \g_semantex_data_bool_set_false:nn { #1 } { first_arg } +% \semantex_primitive_valuekey_ifoutput:nn { #1 } { true } + \semantex_data_int_incr:nn { #1 } { numberofarguments } + \semantex_data_bool_set_true:nn { #1 } { nextargwithsep } } -\cs_new:Npn \g_semantex_primitive_arg_valuekey_dots:nn#1#2 +\cs_generate_variant:Nn \semantex_primitive_arg_valuekey_s:nn { nx } + +\cs_new:Npn \semantex_primitive_arg_valuekey_dots:nn#1#2 { - \g_semantex_primitive_arg_valuekey_standardsep:nn { #1 } { \g_semantex_data_tl_get:nn { #1 } { argdots } } + % Writes dots in the argument + \semantex_primitive_arg_valuekey_s:nx { #1 } { \semantex_data_tl_get_exp_not:nn { #1 } { argdots } } } -\cs_new:Npn \g_semantex_primitive_arg_valuekey_slot:nn#1#2 +\cs_new:Npn \semantex_primitive_arg_valuekey_slot:nn#1#2 { - \g_semantex_primitive_arg_valuekey_standardsep:nn { #1 } { \g_semantex_data_tl_get:nn { #1 } { slot } } + % Writes the slot in teh argument + \semantex_primitive_arg_valuekey_s:nx { #1 } { \semantex_data_tl_get_exp_not:nn { #1 } { argslot } } } -\cs_generate_variant:Nn \g_semantex_arg_keys_set:nn { nx } +\cs_generate_variant:Nn \semantex_arg_keys_set:nn { nx } -\cs_new:Npn \g_semantex_arg_valuekey:nnn#1#2#3 +\cs_new:Npn \semantex_arg_valuekey:nnn#1#2#3 { % Takes care of valuekeys, keys with a value % For the sake of implementation, the arguments @@ -2850,164 +4754,181 @@ % #1 = value of key % #2 = name of the key % #3 = object - \tl_set:Nn\l_semantex_arg_key_value_temp{\exp_not:n{#1}} % stores the content of the key in the temporary command \l_semantex_key_value_temp - \g_semantex_arg_valuekey_get:nnNTF { #3 } { #2 } \l_semantex_custom_arg_valuekey_temp + \tl_set:Nn\l__semantex_arg_key_value_temp{\exp_not:n{#1}} % stores the content of the key in the temporary command \l__semantex_key_value_temp + \semantex_arg_valuekey_get:nnNTF { #3 } { #2 } \l__semantex_custom_arg_valuekey_temp { - \g_semantex_arg_keys_set:nx { #3 } { \l_semantex_custom_arg_valuekey_temp } + \semantex_arg_keys_set:nx { #3 } { \l__semantex_custom_arg_valuekey_temp } } { - \cs_if_exist:cTF { g_semantex_primitive_arg_valuekey_#2:nn } + \cs_if_exist:cTF { semantex_primitive_arg_valuekey_#2:nn } { - \use:c { g_semantex_primitive_arg_valuekey_#2:nn }{ #3 }{ #1 }% + \use:c { semantex_primitive_arg_valuekey_#2:nn }{ #3 }{ #1 } } { - \msg_error:nnnn { semantex } { arg_valuekey_not_found } { #2 } { #3 } +% \msg_error:nnnn { semantex } { arg_valuekey_not_found } { #2 } { #3 } + \semantex_error_output_format:nN { #3 } \__semantex_arg_valuekey_unknown_key_temp + \msg_error:nnxn { semantex } { arg_valuekey_not_found } { \__semantex_arg_valuekey_unknown_key_temp } { #2 } } } } -\cs_new:Npn \g_semantex_arg_novaluekey:nn#1#2 +\cs_new:Npn \semantex_arg_singlekey:nn#1#2 { % #1 = name of the key % #2 = object % % takes care of single keys, keys without a value % the class key is not actually necessary - \g_semantex_arg_novaluekey_get:nnNTF { #2 } { #1 } \l_semantex_custom_arg_novaluekey_temp + \semantex_arg_singlekey_get:nnNTF { #2 } { #1 } \l__semantex_custom_arg_singlekey_temp { %\exp_args:NNno %\exp_args:Nno - %\use:c { g_semantex_data_cs_#3_arg:n } - \g_semantex_arg_keys_set:nx { #2 } + \semantex_arg_keys_set:nx { #2 } { - \l_semantex_custom_arg_novaluekey_temp + \l__semantex_custom_arg_singlekey_temp } } { - \g_semantex_data_tl_inherit_x:nn { #2 } { arg } - \g_semantex_arg_keys_set:nn { #2 } { default={\exp_not:n { #1 } }} - %\g_semantex_arg_keys_set:nn { #3 } { default={#1}} + \semantex_data_tl_inherit_x:nn { #2 } { arg } + \semantex_arg_keys_set:nn { #2 } { default={\exp_not:n { #1 } }} %IM THis \exp_not:n was added late, might be needed elsewhere, too. } } +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% SETTING UP THE BASE CLASS SemantexVariable +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + -\g_semantex_data_tl_provide:nn { semantexvariable } { output } +\semantex_data_tl_provide:nn { class_SemantexVariable } { output } -\g_semantex_data_tl_set:nnn { semantexvariable } { output } { semantexvariable } +\semantex_data_tl_set:nnn { class_SemantexVariable } { output } { class_SemantexVariable } -\g_semantex_data_tl_provide:nn { semantexvariable } { upper_index } +\semantex_data_tl_provide:nn { class_SemantexVariable } { upper } -\g_semantex_data_tl_provide:nn { semantexvariable } { uppersep } +\semantex_data_tl_provide:nn { class_SemantexVariable } { uppersep } -\g_semantex_data_tl_set:nnn { semantexvariable } { uppersep } { , } +\semantex_data_tl_set:nnn { class_SemantexVariable } { uppersep } { , } %IM Also, need commands like forgetupperindex, reverting to the class standard -\g_semantex_data_tl_provide:nn { semantexvariable } { lower_index } +\semantex_data_tl_provide:nn { class_SemantexVariable } { lower } -\g_semantex_data_tl_provide:nn { semantexvariable } { lowersep } +\semantex_data_tl_provide:nn { class_SemantexVariable } { lowersep } -\g_semantex_data_tl_set:nnn { semantexvariable } { lowersep } { , } +\semantex_data_tl_set:nnn { class_SemantexVariable } { lowersep } { , } -\g_semantex_data_tl_provide:nn { semantexvariable } { preupper } +\semantex_data_tl_provide:nn { class_SemantexVariable } { preupper } -\g_semantex_data_tl_provide:nn { semantexvariable } { postupper } +\semantex_data_tl_provide:nn { class_SemantexVariable } { postupper } -\g_semantex_data_tl_provide:nn { semantexvariable } { prelower } +\semantex_data_tl_provide:nn { class_SemantexVariable } { prelower } -\g_semantex_data_tl_provide:nn { semantexvariable } { postlower } +\semantex_data_tl_provide:nn { class_SemantexVariable } { postlower } -\g_semantex_data_tl_provide:nn { semantexvariable } { upper_left_index } +\semantex_data_tl_provide:nn { class_SemantexVariable } { upperleft } -\g_semantex_data_tl_provide:nn { semantexvariable } { upperleftsep } +\semantex_data_tl_provide:nn { class_SemantexVariable } { upperleftsep } -\g_semantex_data_tl_set:nnn { semantexvariable } { upperleftsep } { , } +\semantex_data_tl_set:nnn { class_SemantexVariable } { upperleftsep } { , } -%IM do the same with all the others, INCLUDING if_upper_grading and symbol +%IM do the same with all the others, INCLUDING if_uppergrading and symbol %IM Also, need commands like forgetupperindex, reverting to the class standard -\g_semantex_data_tl_provide:nn { semantexvariable } { lower_left_index } +\semantex_data_tl_provide:nn { class_SemantexVariable } { lowerleft } + +\semantex_data_tl_provide:nn { class_SemantexVariable } { lowerleftsep } -\g_semantex_data_tl_provide:nn { semantexvariable } { lowerleftsep } +\semantex_data_tl_set:nnn { class_SemantexVariable } { lowerleftsep } { , } -\g_semantex_data_tl_set:nnn { semantexvariable } { lowerleftsep } { , } +\semantex_data_tl_provide:nn { class_SemantexVariable } { preupperleft } -\g_semantex_data_tl_provide:nn { semantexvariable } { preupperleft } +\semantex_data_tl_provide:nn { class_SemantexVariable } { postupperleft } -\g_semantex_data_tl_provide:nn { semantexvariable } { postupperleft } +\semantex_data_tl_provide:nn { class_SemantexVariable } { prelowerleft } -\g_semantex_data_tl_provide:nn { semantexvariable } { prelowerleft } +\semantex_data_tl_provide:nn { class_SemantexVariable } { postlowerleft } -\g_semantex_data_tl_provide:nn { semantexvariable } { postlowerleft } +\semantex_data_int_provide:nn { class_SemantexVariable } { numberofarguments } +\semantex_data_bool_provide:nn { class_SemantexVariable } { nextargwithsep } -\g_semantex_data_bool_provide:nn { semantexvariable } { first_upper_left } -\g_semantex_data_bool_set_true:nn { semantexvariable } { first_upper_left } +\semantex_data_bool_provide:nn { class_SemantexVariable } { nextupperleftwithsep } +\semantex_data_bool_provide:nn { class_SemantexVariable } { nextlowerleftwithsep } -\g_semantex_data_bool_provide:nn { semantexvariable } { first_lower_left } -\g_semantex_data_bool_set_true:nn { semantexvariable } { first_lower_left } +\semantex_data_int_provide:nn { class_SemantexVariable } { numberofupperleftindices } +\semantex_data_int_provide:nn { class_SemantexVariable } { numberoflowerleftindices } +\semantex_data_tl_provide:nn { class_SemantexVariable } { prearg } +\semantex_data_tl_provide:nn { class_SemantexVariable } { postarg } -\g_semantex_data_tl_provide:nn { semantexvariable } { prearg } +\semantex_data_tl_provide:nn { class_SemantexVariable } { arg } -\g_semantex_data_tl_provide:nn { semantexvariable } { postarg } -%IMplement these later +\semantex_data_tl_provide:nn { class_SemantexVariable } { argsep } +\semantex_data_tl_set:nnn { class_SemantexVariable } { argsep } {,} -\g_semantex_data_tl_provide:nn { semantexvariable } { arg } +\semantex_data_tl_provide:nn { class_SemantexVariable } { argslot } +\semantex_data_tl_set:nnn { class_SemantexVariable } { argslot } { \SemantexSlot } -\g_semantex_data_tl_provide:nn { semantexvariable } { argsep } -\g_semantex_data_tl_set:nnn { semantexvariable } { argsep } {,} +\semantex_data_tl_provide:nn { class_SemantexVariable } { argdots } +\semantex_data_tl_set:nnn { class_SemantexVariable } { argdots } {\dots} -\g_semantex_data_tl_provide:nn { semantexvariable } { slot } -\g_semantex_data_tl_set:nnn { semantexvariable } { slot } { \semantexslot } +\semantex_data_tl_provide:nn { class_SemantexVariable } { symbol } -\g_semantex_data_tl_provide:nn { semantexvariable } { argdots } -\g_semantex_data_tl_set:nnn { semantexvariable } { argdots } {\dots} +\semantex_data_seq_provide:nn { class_SemantexVariable } { commands_sequence } -\g_semantex_data_tl_provide:nn { semantexvariable } { symbol } +\semantex_data_bool_provide:nn { class_SemantexVariable } { uppergrading } +\semantex_data_bool_set_true:nn { class_SemantexVariable } { uppergrading } -\g_semantex_data_seq_provide:nn { semantexvariable } { commands_sequence } +\semantex_data_bool_provide:nn { class_SemantexVariable } { output } +\semantex_data_tl_provide:nn { class_SemantexVariable } { outputoptions } -\g_semantex_data_bool_provide:nn { semantexvariable } { upper_grading } -\g_semantex_data_bool_set_true:nn { semantexvariable } { upper_grading } +\semantex_data_bool_provide:nn { class_SemantexVariable } { nextupperwithsep } +\semantex_data_bool_provide:nn { class_SemantexVariable } { nextlowerwithsep } -\g_semantex_data_bool_provide:nn { semantexvariable } { output } +\semantex_data_int_provide:nn { class_SemantexVariable } { numberofupperindices } +\semantex_data_int_provide:nn { class_SemantexVariable } { numberoflowerindices } -\g_semantex_data_tl_provide:nn { semantexvariable } { output_options } +\semantex_data_bool_provide:nn { class_SemantexVariable } { par } +\semantex_data_bool_set_true:nn { class_SemantexVariable } { par } -\g_semantex_data_bool_provide:nn { semantexvariable } { first_arg } -\g_semantex_data_bool_set_true:nn { semantexvariable } { first_arg } +\semantex_data_bool_provide:nn { class_SemantexVariable } { flexpar } -\g_semantex_data_bool_provide:nn { semantexvariable } { first_upper } -\g_semantex_data_bool_set_true:nn { semantexvariable } { first_upper } +\semantex_data_tl_provide:nn { class_SemantexVariable } { parseoptions } -\g_semantex_data_bool_provide:nn { semantexvariable } { first_lower } -\g_semantex_data_bool_set_true:nn { semantexvariable } { first_lower } +\semantex_data_tl_provide:nn { class_SemantexVariable } { texclass } -\g_semantex_data_bool_provide:nn { semantexvariable } { par } -\g_semantex_data_bool_set_true:nn { semantexvariable } { par } +\semantex_data_bool_provide:nn { class_SemantexVariable } { leftargument } -\g_semantex_data_bool_provide:nn { semantexvariable } { rightreturnbeforerender } +\semantex_data_tl_provide:nn { class_SemantexVariable } { upperdots } +\semantex_data_tl_provide:nn { class_SemantexVariable } { upperslot } -\g_semantex_data_tl_provide:nn { semantexvariable } { parseoptions } +\semantex_data_tl_provide:nn { class_SemantexVariable } { lowerdots } +\semantex_data_tl_provide:nn { class_SemantexVariable } { lowerslot } -\g_semantex_data_tl_provide:nn { semantexvariable } { texclass } +\semantex_data_tl_provide:nn { class_SemantexVariable } { upperleftdots } +\semantex_data_tl_provide:nn { class_SemantexVariable } { upperleftslot } +\semantex_data_tl_provide:nn { class_SemantexVariable } { lowerleftdots } +\semantex_data_tl_provide:nn { class_SemantexVariable } { lowerleftslot } -%\tl_set:Nn\g_objectmath_semantexvariable_upper_index { hej } -%\tl_set:Nn \g_semantexvariable_output { semantexvariable } -%\bool_new:N \g_semantexvariable_output_if_provided -%\bool_set_true:N \g_semantexvariable_output_if_provided +%\tl_set:Nn\g_objectmath_SemantexVariable_upper { hej } +%\tl_set:Nn \SemantexVariable_output { class_SemantexVariable } +%\bool_new:N \SemantexVariable_output_if_provided +%\bool_set_true:N \SemantexVariable_output_if_provided -\newvariableclass{semantexvariable}[ - %parent=semantexvariable, +\semantex_new_variable_class:Nw \SemantexVariable [ + %parent=SemantexVariable, + output=\SemantexVariable, + ifoutput=false, symbol=, - gradingpos=upper, + gradingposition=upper, %upper=, %lower=, leftpar=(, @@ -3017,21 +4938,51 @@ rightspar=), sparsize=normal, %arg=, - ifoutput=false, - output=semantexvariable, - novaluekeys={ - {bullet}{d={\noexpand\semantexbullet}}, - {doublebullet}{d={\noexpand\semantexdoublebullet}}, + 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}, - {ibullet}{i={\noexpand\semantexbullet}}, - {idoublebullet}{i={\noexpand\semantexdoublebullet}}, - {*}{bullet}, - {**}{doublebullet}, - {i*}{ibullet}, - {i**}{idoublebullet}, + {*}{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}, {smash}{command=\noexpand\smash}, % (widebar}{command=\noexpand\widebar},%For unknown reasons, this only seems to work when run as a primitive {tilde}{command=\noexpand\tilde}, @@ -3051,51 +5002,187 @@ {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=}, % The following four commands do not work due to expansion issues: % {useargwithkeyval}{useargwithkeyval=}, % {argwithkeyval}{ % valuekeys={ -% {arg}{argwithkeyval={\noexpand\l_semantex_key_value_temp}}, +% {arg}{argwithkeyval={\noexpand\l__semantex_key_value_temp}}, % }, % }, -% {argwithnovaluekeys}{ +% {argwithsinglekeys}{ % valuekeys={ -% {arg}{argwithnovaluekeys={\noexpand\l_semantex_key_value_temp}}, +% {arg}{argwithsinglekeys={\noexpand\l__semantex_key_value_temp}}, % }, % }, % {argwithoutkeyval}{ % valuekeys={ -% {arg}{argwithoutkeyval={\noexpand\l_semantex_key_value_temp}}, +% {arg}{argwithoutkeyval={\noexpand\l__semantex_key_value_temp}}, % }, % }, -% {argwithonenovaluekey}{ +% {argwithonesinglekey}{ % valuekeys={ -% {arg}{argwithonenovaluekey={\noexpand\l_semantex_key_value_temp}}, +% {arg}{argwithonesinglekey={\noexpand\l__semantex_key_value_temp}}, % }, % }, }, valuekeys={ - {default}{si={#1}}, + {default}{sindex={#1}}, % {arg}{argwithkeyval={#1}}, - {arg}{argwithnovaluekeys={#1}}, - {degreedefault}{sd={#1}}, - {parseoptions}{ - execute={ - \semantexdataputright{parseoptions}{#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}}, }, -% argwithnovaluekeys, +% argwithsinglekeys, argvaluekeys={ - {default}{standardsep={#1}}, + {default}{s={#1}}, }, - argnovaluekeys={ + argsinglekeys={ {slot}{slot=}, {-}{slot=}, - {*}{slot=}, +% {*}{slot=}, % would be confusing since * does not correspond to slot in the indices {...}{dots=}, }, %command=, % useargwithkeyval, -]
\ No newline at end of file +] + +\cs_set_eq:NN\__semantex_old_version_of_semantex_new_object_of_class_SemantexVariable:Nw \__semantex_new_object_of_class_SemantexVariable:Nw + +\cs_set:Npn \__semantex_new_object_of_class_SemantexVariable:Nw#1 +{ + \msg_error:nnn { semantex } { created_a_SemantexVariable } { #1 } + \__semantex_old_version_of_semantex_new_object_of_class_SemantexVariable:Nw #1 +}
\ No newline at end of file |