summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/stex/source/stex/stex-symbols.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/stex/source/stex/stex-symbols.dtx')
-rw-r--r--macros/latex/contrib/stex/source/stex/stex-symbols.dtx745
1 files changed, 466 insertions, 279 deletions
diff --git a/macros/latex/contrib/stex/source/stex/stex-symbols.dtx b/macros/latex/contrib/stex/source/stex/stex-symbols.dtx
index a8b88cfe72..ba9fa5f097 100644
--- a/macros/latex/contrib/stex/source/stex/stex-symbols.dtx
+++ b/macros/latex/contrib/stex/source/stex/stex-symbols.dtx
@@ -10,7 +10,7 @@
% TODO update copyright
%
%<*driver>
-\providecommand\bibfolder{../../lib/bib}
+\def\bibfolder#1{../../lib/bib/#1}
\input{../../doc/stex-docheader}
\begin{document}
@@ -34,12 +34,17 @@
% This is the documentation for the \pkg{stex-symbols} package.
% For a more high-level introduction,
% see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the
-% \href{\basedocurl/stex.pdf}{full \sTeX documentation}.
+% \href{\basedocurl/stex.pdf}{full \sTeX documentation}.
+%
+% \tableofcontents
%
% \input{../../doc/packages/stex-symbols}
% \fi
%
% \begin{documentation}\label{pkg:symbols:doc}
+% \changes{3.1.0}{2022/03/03}{Introduced sequence variables}
+% \changes{3.1.0}{2022/03/01}{Fixed bug with precedences in variables}
+% \changes{3.1.0}{2022/03/01}{Introduced \detokenize{\varemph, \varemph@uri}}
%
% Code related to symbol declarations and notations
%
@@ -51,7 +56,9 @@
% arguments are:
% \begin{itemize}
% \item |name|: An (\omdoc) name. By default equal to \meta{macroname}.
-% \item |type|: An (ideally semantic) term. Not used by \sTeX, but
+% \item |type|: An (ideally semantic) term, representing a \emph{type}. Not used by \sTeX, but
+% passed on to \mmt for semantic services.
+% \item |def|: An (ideally semantic) term, representing a \emph{definiens}. Not used by \sTeX, but
% passed on to \mmt for semantic services.
% \item |local|: A boolean (by default false). If set, this declaration
% will not be added to the module content, i.e. importing
@@ -152,6 +159,15 @@
args~value~in~symbol~declaration~for~#1~
needs~to~be~i,~a,~b~or~B,~but~#2~given
}
+\msg_new:nnn{stex}{error/unknownsymbol}{
+ No~symbol~#1~found!
+}
+\msg_new:nnn{stex}{error/seqlength}{
+ Expected~#1~arguments;~got~#2!
+}
+\msg_new:nnn{stex}{error/unknownnotation}{
+ Unknown~notation~#1~for~#2!
+}
% \end{macrocode}
%
% \subsection{Symbol Declarations}
@@ -196,6 +212,7 @@
gfc .str_set:N = \l_stex_symdecl_gfc_str , % TODO(?)
specializes .str_set:N = \l_stex_symdecl_specializes_str , % TODO(?)
def .tl_set:N = \l_stex_symdecl_definiens_tl ,
+ reorder .str_set_x:N = \l_stex_symdecl_reorder_str ,
assoc .choices:nn =
{bin,binl,binr,pre,conj,pwconj}
{\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}}
@@ -207,6 +224,7 @@
\str_clear:N \l_stex_symdecl_name_str
\str_clear:N \l_stex_symdecl_args_str
\str_clear:N \l_stex_symdecl_deprecate_str
+ \str_clear:N \l_stex_symdecl_reorder_str
\str_clear:N \l_stex_symdecl_assoctype_str
\bool_set_false:N \l_stex_symdecl_local_bool
\tl_clear:N \l_stex_symdecl_type_tl
@@ -327,6 +345,11 @@
}
\prop_put:Nnx \l_tmpa_prop { assocs } { \int_use:N \l_tmpb_int }
+ \tl_if_empty:NTF \l_stex_symdecl_definiens_tl {
+ \prop_put:Nnx \l_tmpa_prop { defined }{ false }
+ }{
+ \prop_put:Nnx \l_tmpa_prop { defined }{ true }
+ }
% semantic macro
@@ -336,90 +359,116 @@
\l_stex_current_module_str ? \l_stex_symdecl_name_str
}}
}
-
- \bool_if:NF \l_stex_symdecl_local_bool {
- \exp_args:Nx \stex_add_to_current_module:n {
- \tl_set:cn { #1 } { \stex_invoke_symbol:n {
- \l_stex_current_module_str ? \l_stex_symdecl_name_str
- } }
- }
- }
}
\stex_debug:nn{symbols}{New~symbol:~
\l_stex_current_module_str ? \l_stex_symdecl_name_str^^J
Type:~\exp_not:o { \l_stex_symdecl_type_tl }^^J
- Args:~\prop_item:Nn \l_tmpa_prop { args }
+ Args:~\prop_item:Nn \l_tmpa_prop { args }^^J
+ Definiens:~\exp_not:o {\l_stex_symdecl_definiens_tl}
}
% circular dependencies require this:
-
+ \stex_if_do_html:T {
+ \stex_annotate_invisible:nnn {symdecl} {
+ \l_stex_current_module_str ? \l_stex_symdecl_name_str
+ } {
+ \tl_if_empty:NF \l_stex_symdecl_type_tl {
+ \stex_annotate_invisible:nnn{type}{}{$\l_stex_symdecl_type_tl$}
+ }
+ \stex_annotate_invisible:nnn{args}{\prop_item:Nn \l_tmpa_prop { args }}{}
+ \stex_annotate_invisible:nnn{macroname}{#1}{}
+ \tl_if_empty:NF \l_stex_symdecl_definiens_tl {
+ \stex_annotate_invisible:nnn{definiens}{}
+ {$\l_stex_symdecl_definiens_tl$}
+ }
+ \str_if_empty:NF \l_stex_symdecl_assoctype_str {
+ \stex_annotate_invisible:nnn{assoctype}{\l_stex_symdecl_assoctype_str}{}
+ }
+ \str_if_empty:NF \l_stex_symdecl_reorder_str {
+ \stex_annotate_invisible:nnn{reorderargs}{\l_stex_symdecl_reorder_str}{}
+ }
+ }
+ }
\prop_if_exist:cF {
l_stex_symdecl_
\l_stex_current_module_str ? \l_stex_symdecl_name_str
_prop
} {
- \prop_set_eq:cN {
- l_stex_symdecl_
- \l_stex_current_module_str ? \l_stex_symdecl_name_str
- _prop
- } \l_tmpa_prop
+ \bool_if:NTF \l_stex_symdecl_local_bool \stex_do_up_to_module:x \stex_execute_in_module:x {
+ \_@@_restore_symbol:nnnnnnn
+ {\l_stex_symdecl_name_str}
+ { \prop_item:Nn \l_tmpa_prop {args} }
+ { \prop_item:Nn \l_tmpa_prop {arity} }
+ { \prop_item:Nn \l_tmpa_prop {assocs} }
+ { \prop_item:Nn \l_tmpa_prop {defined} }
+ {\bool_if:NT \l_stex_symdecl_make_macro_bool {#1} }
+ {\l_stex_current_module_str}
+ }
}
-
- \seq_clear:c {
- l_stex_symdecl_
- \l_stex_current_module_str ? \l_stex_symdecl_name_str
- _notations
+}
+\cs_new_protected:Nn \_@@_restore_symbol:nnnnnnn {
+ \prop_clear:N \l_tmpa_prop
+ \prop_put:Nnn \l_tmpa_prop { module } { #7 }
+ \prop_put:Nnn \l_tmpa_prop { name } { #1}
+ \prop_put:Nnn \l_tmpa_prop { args } {#2}
+ \prop_put:Nnn \l_tmpa_prop { arity } { #3 }
+ \prop_put:Nnn \l_tmpa_prop { assocs } { #4 }
+ \prop_put:Nnn \l_tmpa_prop { defined } { #5 }
+ \tl_if_empty:nF{#6}{
+ \tl_set:cx{#6}{\stex_invoke_symbol:n{\detokenize{#7 ? #1}}}
}
+ \prop_set_eq:cN{l_stex_symdecl_ \detokenize{#7 ? #1} _prop}\l_tmpa_prop
+ \seq_clear:c{l_stex_symdecl_ \detokenize{#7 ? #1} _notations}
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\textsymdecl}
+% \begin{macrocode}
- \bool_if:NF \l_stex_symdecl_local_bool {
- \exp_args:Nx
- \stex_add_to_current_module:n {
- \seq_clear:c {
- l_stex_symdecl_
- \l_stex_current_module_str ? \l_stex_symdecl_name_str
- _notations
- }
- \prop_set_from_keyval:cn {
- l_stex_symdecl_
- \l_stex_current_module_str ? \l_stex_symdecl_name_str
- _prop
- } {
- name = \prop_item:Nn \l_tmpa_prop { name } ,
- module = \prop_item:Nn \l_tmpa_prop { module } ,
- type = \prop_item:Nn \l_tmpa_prop { type } ,
- args = \prop_item:Nn \l_tmpa_prop { args } ,
- arity = \prop_item:Nn \l_tmpa_prop { arity } ,
- assocs = \prop_item:Nn \l_tmpa_prop { assocs }
- }
- }
- }
+\keys_define:nn { stex / textsymdecl } {
+ name .str_set_x:N = \l_@@_name_str ,
+ type .tl_set:N = \l_@@_type_tl
+}
- \stex_if_smsmode:F {
-% \exp_args:Nx \stex_do_up_to_module:n {
-% \seq_put_right:Nn \exp_not:N \l_stex_all_symbols_seq {
-% \l_stex_current_module_str ? \l_stex_symdecl_name_str
-% }
-% }
- \stex_if_do_html:T {
- \stex_annotate_invisible:nnn {symdecl} {
- \l_stex_current_module_str ? \l_stex_symdecl_name_str
- } {
- \tl_if_empty:NF \l_stex_symdecl_type_tl {\stex_annotate_invisible:nnn{type}{}{$\l_stex_symdecl_type_tl$}}
- \stex_annotate_invisible:nnn{args}{}{
- \prop_item:Nn \l_tmpa_prop { args }
- }
- \stex_annotate_invisible:nnn{macroname}{#1}{}
- \tl_if_empty:NF \l_stex_symdecl_definiens_tl {
- \stex_annotate_invisible:nnn{definiens}{}
- {$\l_stex_symdecl_definiens_tl$}
- }
- \str_if_empty:NF \l_stex_symdecl_assoctype_str {
- \stex_annotate_invisible:nnn{assoctype}{\l_stex_symdecl_assoctype_str}{}
- }
- }
+\cs_new_protected:Nn \_stex_textsymdecl_args:n {
+ \str_clear:N \l_@@_name_str
+ \tl_clear:N \l_@@_type_tl
+ \keys_set:nn { stex / textsymdecl } { #1 }
+}
+
+\NewDocumentCommand \textsymdecl {m O{} m} {
+ \_stex_textsymdecl_args:n { #2 }
+ \str_if_empty:NTF \l_@@_name_str {
+ \_@@_args:n{name=#1,#2}
+ }{
+ \_@@_args:n{#2}
+ }
+ \bool_set_true:N \l_stex_symdecl_make_macro_bool
+ \stex_symdecl_do:n{#1-sym}
+ \stex_execute_in_module:n{
+ \cs_set_nopar:cpn{#1name}{
+ \ifvmode\hbox_unpack:N\c_empty_box\fi
+ \hbox{#3}\xspace
+ }
+ \cs_set_nopar:cpn{#1}{
+ \ifmmode\csname#1-sym\expandafter\endcsname\else
+ \ifvmode\hbox_unpack:N\c_empty_box\fi
+ \symref{#1-sym}{\hbox{#3}}\expandafter\xspace
+ \fi
}
}
+ \stex_execute_in_module:x{
+ \__stex_notation_restore_notation:nnnnn
+ {\l_stex_current_module_str?\tl_if_empty:NTF\l_@@_name_str{#1}\l_@@_name_str}
+ {}{0}
+ {\exp_not:n{\STEXInternalTermMathOMSiiii{\STEXInternalCurrentSymbolStr}{}{\neginfprec}{
+ \comp{\hbox{#3}}\STEXInternalSymbolAfterInvokationTL
+ }}}
+ {}
+ }
+ \stex_smsmode_do:
}
% \end{macrocode}
% \end{macro}
@@ -431,7 +480,8 @@
\cs_new_protected:Nn \stex_get_symbol:n {
\tl_if_head_eq_catcode:nNTF { #1 } \relax {
- \_@@_get_symbol_from_cs:n { #1 }
+ \tl_set:Nn \l_tmpa_tl { #1 }
+ \_@@_get_symbol_from_cs:
}{
% argument is a string
% is it a command name?
@@ -442,7 +492,7 @@
\exp_args:Nx \cs_if_eq:NNTF {
\tl_head:N \l_tmpa_tl
} \stex_invoke_symbol:n {
- \exp_args:No \_@@_get_symbol_from_cs:n { \use:c { #1 } }
+ \_@@_get_symbol_from_cs:
}{
\_@@_get_symbol_from_string:n { #1 }
}
@@ -470,28 +520,52 @@
\cs_new_protected:Nn \_@@_get_symbol_from_string:n {
\tl_set:Nn \l_tmpa_tl {
- \msg_set:nnn{stex}{error/unknownsymbol}{
- No~symbol~#1~found!
- }
- \msg_error:nn{stex}{error/unknownsymbol}
+ \msg_error:nnn{stex}{error/unknownsymbol}{#1}
}
\str_set:Nn \l_tmpa_str { #1 }
- \int_set:Nn \l_tmpa_int { \str_count:N \l_tmpa_str }
- \stex_all_symbols:n {
- \str_if_eq:eeT { \l_tmpa_str }{ \str_range:nnn {##1}{-\l_tmpa_int}{-1}}{
- \seq_map_break:n{\seq_map_break:n{
- \tl_set:Nn \l_tmpa_tl {
- \str_set:Nn \l_stex_get_symbol_uri_str { ##1 }
+ %\int_set:Nn \l_tmpa_int { \str_count:N \l_tmpa_str }
+
+ \str_if_in:NnTF \l_tmpa_str ? {
+ \exp_args:NNno \seq_set_split:Nnn \l_tmpa_seq ? \l_tmpa_str
+ \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str
+ \str_set:Nx \l_tmpb_str {\seq_use:Nn \l_tmpa_seq ?}
+ }{
+ \str_clear:N \l_tmpb_str
+ }
+ \str_if_empty:NTF \l_tmpb_str {
+ \seq_map_inline:Nn \l_stex_all_modules_seq {
+ \seq_map_inline:cn{c_stex_module_##1_constants}{
+ \exp_args:Nno \str_if_eq:nnT{####1} \l_tmpa_str {
+ \seq_map_break:n{\seq_map_break:n{
+ \tl_set:Nn \l_tmpa_tl {
+ \str_set:Nn \l_stex_get_symbol_uri_str { ##1 ? ####1 }
+ }
+ }}
}
- }}
+ }
+ }
+ }{
+ \int_set:Nn \l_tmpa_int { \str_count:N \l_tmpb_str }
+ \seq_map_inline:Nn \l_stex_all_modules_seq {
+ \str_if_eq:eeT{ \l_tmpb_str }{ \str_range:nnn {##1}{-\l_tmpa_int}{-1}}{
+ \seq_map_inline:cn{c_stex_module_##1_constants}{
+ \exp_args:Nno \str_if_eq:nnT{####1} \l_tmpa_str {
+ \seq_map_break:n{\seq_map_break:n{
+ \tl_set:Nn \l_tmpa_tl {
+ \str_set:Nn \l_stex_get_symbol_uri_str { ##1 ? ####1 }
+ }
+ }}
+ }
+ }
+ }
}
}
\l_tmpa_tl
}
-\cs_new_protected:Nn \_@@_get_symbol_from_cs:n {
+\cs_new_protected:Nn \_@@_get_symbol_from_cs: {
\exp_args:NNx \tl_set:Nn \l_tmpa_tl
{ \tl_tail:N \l_tmpa_tl }
\tl_if_single:NTF \l_tmpa_tl {
@@ -519,7 +593,7 @@
%
% \begin{macrocode}
\keys_define:nn { stex / notation } {
- lang .tl_set_x:N = \l_@@_lang_str ,
+% lang .tl_set_x:N = \l_@@_lang_str ,
variant .tl_set_x:N = \l_@@_variant_str ,
prec .str_set_x:N = \l_@@_prec_str ,
op .tl_set:N = \l_@@_op_tl ,
@@ -530,7 +604,7 @@
}
\cs_new_protected:Nn \_stex_notation_args:n {
- \str_clear:N \l_@@_lang_str
+% \str_clear:N \l_@@_lang_str
\str_clear:N \l_@@_variant_str
\str_clear:N \l_@@_prec_str
\tl_clear:N \l_@@_op_tl
@@ -553,31 +627,33 @@
\IfBooleanTF#1{
\stex_setnotation:n {\l_stex_get_symbol_uri_str}
}{}
- \stex_smsmode_do:
+ \stex_smsmode_do:\ignorespacesandpars
}
- \stex_notation_do:nnnn
+ \stex_notation_do:nnnnn
{ \prop_item:cn {l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { args } }
{ \prop_item:cn { l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { arity } }
- { \l_@@_variant_str \c_hash_str \l_@@_lang_str }
+ { \l_@@_variant_str }
+ { \l_@@_prec_str}
}
\stex_deactivate_macro:Nn \notation {module~environments}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\stex_notation_do:nnnn}
+% \begin{macro}{\stex_notation_do:nnnnn}
% \begin{macrocode}
\seq_new:N \l_@@_precedences_seq
\tl_new:N \l_@@_opprec_tl
\int_new:N \l_@@_currarg_int
-\tl_new:N \stex_symbol_after_invocation_tl
+\tl_new:N \STEXInternalSymbolAfterInvokationTL
-\cs_new_protected:Nn \stex_notation_do:nnnn {
- \let\l_stex_current_symbol_str\relax
+\cs_new_protected:Nn \stex_notation_do:nnnnn {
+ \let\STEXInternalCurrentSymbolStr\relax
\seq_clear:N \l_@@_precedences_seq
\tl_clear:N \l_@@_opprec_tl
\str_set:Nx \l_@@_args_str { #1 }
\str_set:Nx \l_@@_arity_str { #2 }
- \str_set:Nx \_@@_suffix_str { #3 }
+ \str_set:Nx \l_@@_suffix_str { #3 }
+ \str_set:Nx \l_@@_prec_str { #4 }
% precedences
\str_if_empty:NTF \l_@@_prec_str {
@@ -628,10 +704,10 @@
\int_compare:nNnTF \l_@@_arity_str = 0 {
\exp_args:NNe
\cs_set:Npn \l_stex_notation_macrocode_cs {
- \_stex_term_math_oms:nnnn { \l_stex_current_symbol_str }
- { \_@@_suffix_str }
+ \STEXInternalTermMathOMSiiii { \STEXInternalCurrentSymbolStr }
+ { \l_@@_suffix_str }
{ \l_@@_opprec_tl }
- { \exp_not:n { #4 } }
+ { \exp_not:n { #5 } }
}
\l_stex_notation_after_do_tl
}{
@@ -640,10 +716,10 @@
{
\cs_generate_from_arg_count:NNnn \l_stex_notation_macrocode_cs
\cs_set:Npn \l_@@_arity_str } { {
- \_stex_term_math_omb:nnnn { \l_stex_current_symbol_str }
- { \_@@_suffix_str }
+ \STEXInternalTermMathOMBiiii { \STEXInternalCurrentSymbolStr }
+ { \l_@@_suffix_str }
{ \l_@@_opprec_tl }
- { \exp_not:n { #4 } }
+ { \exp_not:n { #5 } }
}}
}{
\str_if_in:NnTF \l_@@_args_str B {
@@ -651,20 +727,20 @@
{
\cs_generate_from_arg_count:NNnn \l_stex_notation_macrocode_cs
\cs_set:Npn \l_@@_arity_str } { {
- \_stex_term_math_omb:nnnn { \l_stex_current_symbol_str }
- { \_@@_suffix_str }
+ \STEXInternalTermMathOMBiiii { \STEXInternalCurrentSymbolStr }
+ { \l_@@_suffix_str }
{ \l_@@_opprec_tl }
- { \exp_not:n { #4 } }
+ { \exp_not:n { #5 } }
} }
}{
\exp_args:Nne \use:nn
{
\cs_generate_from_arg_count:NNnn \l_stex_notation_macrocode_cs
\cs_set:Npn \l_@@_arity_str } { {
- \_stex_term_math_oma:nnnn { \l_stex_current_symbol_str }
- { \_@@_suffix_str }
+ \STEXInternalTermMathOMAiiii { \STEXInternalCurrentSymbolStr }
+ { \l_@@_suffix_str }
{ \l_@@_opprec_tl }
- { \exp_not:n { #4 } }
+ { \exp_not:n { #5 } }
} }
}
}
@@ -692,16 +768,16 @@
\str_set:Nx \l_tmpa_str { \str_head:N \l_@@_remaining_args_str }
\str_set:Nx \l_@@_remaining_args_str { \str_tail:N \l_@@_remaining_args_str }
\str_if_eq:VnTF \l_tmpa_str a {
- \_@@_argument_assoc:n
+ \_@@_argument_assoc:nn{a}
}{
\str_if_eq:VnTF \l_tmpa_str B {
- \_@@_argument_assoc:n
+ \_@@_argument_assoc:nn{B}
}{
- \seq_pop_left:NN \l_@@_remaining_precs_seq \l_tmpa_str
+ \seq_pop_left:NN \l_@@_remaining_precs_seq \l_tmpb_str
\tl_put_right:Nx \l_stex_notation_dummyargs_tl {
- { \_stex_term_math_arg:nnn
- { \int_use:N \l_@@_currarg_int }
- { \l_tmpa_str }
+ { \STEXInternalTermMathArgiii
+ { \l_tmpa_str\int_use:N \l_@@_currarg_int }
+ { \l_tmpb_str }
{ ####\int_use:N \l_@@_currarg_int }
}
}
@@ -713,13 +789,13 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\_@@_argument_assoc:n}
+% \begin{macro}{\_@@_argument_assoc:nn}
% \begin{macrocode}
-\cs_new_protected:Nn \_@@_argument_assoc:n {
+\cs_new_protected:Nn \_@@_argument_assoc:nn {
\cs_generate_from_arg_count:NNnn \l_tmpa_cs \cs_set:Npn
{\l_@@_arity_str}{
- #1
+ #2
}
\int_zero:N \l_tmpa_int
\tl_clear:N \l_tmpa_tl
@@ -728,7 +804,7 @@
\tl_put_right:Nx \l_tmpa_tl {
\str_if_eq:nnTF {##1}{a}{ {} }{
\str_if_eq:nnTF {##1}{B}{ {} }{
- {\_stex_term_arg:nn{\int_use:N \l_tmpa_int}{################ \int_use:N \l_tmpa_int}}
+ {\_stex_term_arg:nn{##1\int_use:N \l_tmpa_int}{################ \int_use:N \l_tmpa_int}}
}
}
}
@@ -748,8 +824,8 @@
\seq_pop_left:NN \l_@@_remaining_precs_seq \l_tmpa_str
\tl_put_right:Nx \l_stex_notation_dummyargs_tl { {
- \_stex_term_math_assoc_arg:nnnn
- { \int_use:N \l_@@_currarg_int }
+ \STEXInternalTermMathAssocArgiiii
+ { #1\int_use:N \l_@@_currarg_int }
{ \l_tmpa_str }
{ ####\int_use:N \l_@@_currarg_int }
{ \l_tmpa_cs {####1} {####2} }
@@ -764,132 +840,88 @@
% Called after processing all notation arguments
%
% \begin{macrocode}
-\cs_new_protected:Nn \_@@_final: {
- \exp_args:Nne \use:nn
- {
- \cs_generate_from_arg_count:cNnn {
- stex_notation_ \l_stex_get_symbol_uri_str \c_hash_str
- \_@@_suffix_str
- _cs
- }
- \cs_set:Npn \l_@@_arity_str } { {
- \exp_after:wN \exp_after:wN \exp_after:wN
- \exp_not:n \exp_after:wN \exp_after:wN \exp_after:wN
- { \exp_after:wN \l_stex_notation_macrocode_cs \l_stex_notation_dummyargs_tl \stex_symbol_after_invocation_tl}
- } }
-
- \tl_if_empty:NF \l_@@_op_tl {
- \cs_set:cpx {
- stex_op_notation_ \l_stex_get_symbol_uri_str \c_hash_str
- \_@@_suffix_str
- _cs
- } {
- \_stex_term_oms:nnn {
- \l_stex_get_symbol_uri_str \c_hash_str \_@@_suffix_str
- }{
- \l_stex_get_symbol_uri_str
- }{ \comp{ \exp_args:No \exp_not:n { \l_@@_op_tl } } }
- }
+\cs_new_protected:Nn \_@@_restore_notation:nnnnn {
+ \cs_generate_from_arg_count:cNnn{stex_notation_\detokenize{#1} \c_hash_str \detokenize{#2}_cs}
+ \cs_set_nopar:Npn {#3}{#4}
+ \tl_if_empty:nF {#5}{
+ \tl_set:cn{stex_op_notation_\detokenize{#1} \c_hash_str \detokenize{#2}_cs}{ \comp{ #5 } }
+ }
+ \seq_if_exist:cT { l_stex_symdecl_\detokenize{#1} _notations }{
+ \seq_put_right:cx { l_stex_symdecl_\detokenize{#1} _notations } { \detokenize{#2} }
}
+}
- \exp_args:Ne
- \stex_add_to_current_module:n {
- \cs_generate_from_arg_count:cNnn {
- stex_notation_ \l_stex_get_symbol_uri_str \c_hash_str
- \_@@_suffix_str
- _cs
- } \cs_set:Npn {\l_@@_arity_str} {
+\cs_new_protected:Nn \_@@_final: {
+
+ \stex_execute_in_module:x {
+ \_@@_restore_notation:nnnnn
+ {\l_stex_get_symbol_uri_str}
+ {\l_@@_suffix_str}
+ {\l_@@_arity_str}
+ {
\exp_after:wN \exp_after:wN \exp_after:wN
\exp_not:n \exp_after:wN \exp_after:wN \exp_after:wN
- { \exp_after:wN \l_stex_notation_macrocode_cs \l_stex_notation_dummyargs_tl \stex_symbol_after_invocation_tl}
- }
- \tl_if_empty:NF \l_@@_op_tl {
- \cs_set:cpn {
- stex_op_notation_\l_stex_get_symbol_uri_str \c_hash_str
- \_@@_suffix_str
- _cs
- } {
- \_stex_term_oms:nnn {
- \l_stex_get_symbol_uri_str\c_hash_str \_@@_suffix_str
- }{
- \l_stex_get_symbol_uri_str
- }{ \comp{ \exp_args:No \exp_not:n { \l_@@_op_tl } } }
+ { \exp_after:wN \l_stex_notation_macrocode_cs \l_stex_notation_dummyargs_tl \STEXInternalSymbolAfterInvokationTL}
}
- }
+ {\exp_args:No \exp_not:n \l_@@_op_tl }
}
- %\exp_args:Nx
- % \stex_do_up_to_module:n {
- \seq_put_right:cx {
- l_stex_symdecl_ \l_stex_get_symbol_uri_str
- _notations
- } {
- \_@@_suffix_str
- }
- % }
\stex_debug:nn{symbols}{
- Notation~\_@@_suffix_str
+ Notation~\l_@@_suffix_str
~for~\l_stex_get_symbol_uri_str^^J
Operator~precedence:~\l_@@_opprec_tl^^J
Argument~precedences:~
\seq_use:Nn \l_@@_precedences_seq {,~}^^J
Notation: \cs_meaning:c {
stex_notation_ \l_stex_get_symbol_uri_str \c_hash_str
- \_@@_suffix_str
+ \l_@@_suffix_str
_cs
}
}
-
- \exp_args:Ne
- \stex_add_to_current_module:n {
- \seq_put_right:cn {
- l_stex_symdecl_\l_stex_get_symbol_uri_str
- _notations
- } { \_@@_suffix_str }
- }
-
- \stex_if_smsmode:F {
-
% HTML annotations
- \stex_if_do_html:T {
- \stex_annotate_invisible:nnn { notation }
- { \l_stex_get_symbol_uri_str } {
- \stex_annotate_invisible:nnn { notationfragment }
- { \_@@_suffix_str }{}
- \stex_annotate_invisible:nnn { precedence }
- { \l_@@_prec_str }{}
-
- \int_zero:N \l_tmpa_int
- \str_set_eq:NN \l_@@_remaining_args_str \l_@@_args_str
- \tl_clear:N \l_tmpa_tl
- \int_step_inline:nn { \l_@@_arity_str }{
- \int_incr:N \l_tmpa_int
- \str_set:Nx \l_tmpb_str { \str_head:N \l_@@_remaining_args_str }
- \str_set:Nx \l_@@_remaining_args_str { \str_tail:N \l_@@_remaining_args_str }
- \str_if_eq:VnTF \l_tmpb_str a {
+ \stex_if_do_html:T {
+ \stex_annotate_invisible:nnn { notation }
+ { \l_stex_get_symbol_uri_str } {
+ \stex_annotate_invisible:nnn { notationfragment }
+ { \l_@@_suffix_str }{}
+ \stex_annotate_invisible:nnn { precedence }
+ { \l_@@_prec_str }{}
+
+ \int_zero:N \l_tmpa_int
+ \str_set_eq:NN \l_@@_remaining_args_str \l_@@_args_str
+ \tl_clear:N \l_tmpa_tl
+ \int_step_inline:nn { \l_@@_arity_str }{
+ \int_incr:N \l_tmpa_int
+ \str_set:Nx \l_tmpb_str { \str_head:N \l_@@_remaining_args_str }
+ \str_set:Nx \l_@@_remaining_args_str { \str_tail:N \l_@@_remaining_args_str }
+ \str_if_eq:VnTF \l_tmpb_str a {
+ \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl {
+ \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int a}{} ,
+ \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int b}{}
+ } }
+ }{
+ \str_if_eq:VnTF \l_tmpb_str B {
\tl_set:Nx \l_tmpa_tl { \l_tmpa_tl {
- \c_hash_str \c_hash_str \int_use:N \l_tmpa_int a ,
- \c_hash_str \c_hash_str \int_use:N \l_tmpa_int b
+ \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int a}{} ,
+ \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int b}{}
} }
}{
- \str_if_eq:VnTF \l_tmpb_str B {
- \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl {
- \c_hash_str \c_hash_str \int_use:N \l_tmpa_int a ,
- \c_hash_str \c_hash_str \int_use:N \l_tmpa_int b
- } }
- }{
- \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl {
- \c_hash_str \c_hash_str \int_use:N \l_tmpa_int
- } }
- }
+ \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl {
+ \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int}{}
+ } }
}
}
- \stex_annotate_invisible:nnn { notationcomp }{}{
- \str_set:Nx \l_stex_current_symbol_str {\l_stex_get_symbol_uri_str }
- $ \exp_args:Nno \use:nn { \use:c {
- stex_notation_ \l_stex_current_symbol_str
- \c_hash_str \_@@_suffix_str _cs
- } } { \l_tmpa_tl } $
+ }
+ \stex_annotate_invisible:nnn { notationcomp }{}{
+ \str_set:Nx \STEXInternalCurrentSymbolStr {\l_stex_get_symbol_uri_str }
+ $ \exp_args:Nno \use:nn { \use:c {
+ stex_notation_ \STEXInternalCurrentSymbolStr
+ \c_hash_str \l_@@_suffix_str _cs
+ } } { \l_tmpa_tl } $
+ }
+ \tl_if_empty:NF \l_@@_op_tl {
+ \stex_annotate_invisible:nnn { notationopcomp }{}{
+ $\l_@@_op_tl$
}
}
}
@@ -901,44 +933,38 @@
% \begin{macro}{\setnotation}
% \begin{macrocode}
\keys_define:nn { stex / setnotation } {
- lang .tl_set_x:N = \l_@@_lang_str ,
+% lang .tl_set_x:N = \l_@@_lang_str ,
variant .tl_set_x:N = \l_@@_variant_str ,
unknown .code:n = \str_set:Nx
\l_@@_variant_str \l_keys_key_str
}
\cs_new_protected:Nn \_stex_setnotation_args:n {
- \str_clear:N \l_@@_lang_str
+ % \str_clear:N \l_@@_lang_str
\str_clear:N \l_@@_variant_str
\keys_set:nn { stex / setnotation } { #1 }
}
+\cs_new_protected:Nn \_@@_setnotation:nn {
+ \seq_if_exist:cT{l_stex_symdecl_#1_notations}{
+ \seq_remove_all:cn { l_stex_symdecl_#1 _notations }{ #2 }
+ \seq_put_left:cn { l_stex_symdecl_#1 _notations }{ #2 }
+ }
+}
+
\cs_new_protected:Nn \stex_setnotation:n {
\exp_args:Nnx \seq_if_in:cnTF { l_stex_symdecl_#1 _notations }
- { \l_@@_variant_str \c_hash_str \l_@@_lang_str }{
- \exp_args:Nnx \seq_remove_all:cn { l_stex_symdecl_#1 _notations }
- { \l_@@_variant_str \c_hash_str \l_@@_lang_str }
- \exp_args:Nnx \seq_remove_all:cn { l_stex_symdecl_#1 _notations }
- { \c_hash_str }
- \exp_args:Nnx \seq_put_left:cn { l_stex_symdecl_#1 _notations }
- { \l_@@_variant_str \c_hash_str \l_@@_lang_str }
- \exp_args:Nx \stex_add_to_current_module:n {
- \exp_args:Nnx \seq_remove_all:cn { l_stex_symdecl_#1 _notations }
- { \l_@@_variant_str \c_hash_str \l_@@_lang_str }
- \exp_args:Nnx \seq_put_left:cn { l_stex_symdecl_#1 _notations }
- { \l_@@_variant_str \c_hash_str \l_@@_lang_str }
- \exp_args:Nnx \seq_remove_all:cn { l_stex_symdecl_#1 _notations }
- { \c_hash_str }
- }
+ { \l_@@_variant_str }{
+ \stex_execute_in_module:x{ \_@@_setnotation:nn {#1}{\l_@@_variant_str} }
\stex_debug:nn {notations}{
Setting~default~notation~
- {\l_@@_variant_str \c_hash_str \l_@@_lang_str}~for~
+ {\l_@@_variant_str }~for~
#1 \\
\expandafter\meaning\csname
l_stex_symdecl_#1 _notations\endcsname
}
}{
- % todo throw error
+ \msg_error:nnxx{stex}{unknownnotation}{\l_@@_variant_str}{#1}
}
}
@@ -946,7 +972,7 @@
\stex_get_symbol:n { #1 }
\_stex_setnotation_args:n { #2 }
\stex_setnotation:n{\l_stex_get_symbol_uri_str}
- \stex_smsmode_do:
+ \stex_smsmode_do:\ignorespacesandpars
}
\cs_new_protected:Nn \stex_copy_notations:nn {
@@ -956,9 +982,10 @@
}
\tl_clear:N \l_tmpa_tl
\int_step_inline:nn { \prop_item:cn {l_stex_symdecl_#2_prop}{ arity } } {
- \tl_put_right:Nn \l_tmpa_tl { {## ##1} }
+ \tl_put_right:Nn \l_tmpa_tl { {######## ##1} }
}
- \seq_map_inline:cn {l_stex_symdecl_#2_notations}{
+ \seq_map_inline:cn {l_stex_symdecl_#2_notations}{\begingroup
+ \stex_debug:nn{Here}{Here:~##1}
\cs_set_eq:Nc \l_tmpa_cs { stex_notation_ #2 \c_hash_str ##1 _cs }
\edef \l_tmpa_tl {
\exp_after:wN\exp_after:wN\exp_after:wN \exp_not:n
@@ -966,15 +993,30 @@
\exp_after:wN \l_tmpa_cs \l_tmpa_tl
}
}
- \exp_args:Nx
- \stex_do_up_to_module:n {
- \seq_put_right:cn{l_stex_symdecl_#1_notations}{##1}
- \cs_generate_from_arg_count:cNnn {
- stex_notation_ #1 \c_hash_str ##1 _cs
- } \cs_set:Npn { \prop_item:cn {l_stex_symdecl_#2_prop}{ arity } }{
- \exp_after:wN\exp_not:n\exp_after:wN{\l_tmpa_tl}
+
+ \exp_after:wN \def \exp_after:wN \l_tmpa_tl
+ \exp_after:wN ####\exp_after:wN 1 \exp_after:wN ####\exp_after:wN 2
+ \exp_after:wN { \l_tmpa_tl }
+
+ \edef \l_tmpa_tl {
+ \exp_after:wN \exp_not:n \exp_after:wN {
+ \l_tmpa_tl {######## 1}{######## 2}
}
}
+
+ \stex_debug:nn{Here}{Here:~\expandafter\detokenize\expandafter{\l_tmpa_tl}}
+
+ \stex_execute_in_module:x {
+ \_@@_restore_notation:nnnnn
+ {#1}{##1}
+ { \prop_item:cn {l_stex_symdecl_#2_prop}{ arity } }
+ { \exp_after:wN\exp_not:n\exp_after:wN{\l_tmpa_tl} }
+ {
+ \cs_if_exist:cT{stex_op_notation_ #2\c_hash_str ##1 _cs}{
+ \exp_args:NNo\exp_args:No\exp_not:n{\csname stex_op_notation_ #2\c_hash_str ##1 _cs\endcsname}
+ }
+ }
+ }\endgroup
}
}
@@ -984,10 +1026,7 @@
\stex_get_symbol:n { #2 }
\exp_args:Noo
\stex_copy_notations:nn \l_tmpa_str \l_stex_get_symbol_uri_str
- \exp_args:Nx \stex_add_import_to_current_module:n{
- \stex_copy_notations:nn {\l_tmpa_str} {\l_stex_get_symbol_uri_str}
- }
- \stex_smsmode_do:
+ \stex_smsmode_do:\ignorespacesandpars
}
% \end{macrocode}
@@ -1001,8 +1040,9 @@
args .str_set_x:N = \l_stex_symdecl_args_str ,
type .tl_set:N = \l_stex_symdecl_type_tl ,
def .tl_set:N = \l_stex_symdecl_definiens_tl ,
+ reorder .str_set_x:N = \l_stex_symdecl_reorder_str ,
op .tl_set:N = \l_@@_op_tl ,
- lang .str_set_x:N = \l_@@_lang_str ,
+ % lang .str_set_x:N = \l_@@_lang_str ,
variant .str_set_x:N = \l_@@_variant_str ,
prec .str_set_x:N = \l_@@_prec_str ,
assoc .choices:nn =
@@ -1016,10 +1056,11 @@
\str_clear:N \l_stex_symdecl_name_str
\str_clear:N \l_stex_symdecl_args_str
\str_clear:N \l_stex_symdecl_assoctype_str
+ \str_clear:N \l_stex_symdecl_reorder_str
\bool_set_false:N \l_stex_symdecl_local_bool
\tl_clear:N \l_stex_symdecl_type_tl
\tl_clear:N \l_stex_symdecl_definiens_tl
- \str_clear:N \l_@@_lang_str
+ % \str_clear:N \l_@@_lang_str
\str_clear:N \l_@@_variant_str
\str_clear:N \l_@@_prec_str
\tl_clear:N \l_@@_op_tl
@@ -1033,15 +1074,16 @@
\stex_symdecl_do:n { #1 }
\tl_set:Nn \l_stex_notation_after_do_tl {
\_@@_final:
- \stex_smsmode_do:
+ \stex_smsmode_do:\ignorespacesandpars
}
\str_set:Nx \l_stex_get_symbol_uri_str {
\l_stex_current_module_str ? \l_stex_symdecl_name_str
}
- \exp_args:Nx \stex_notation_do:nnnn
+ \exp_args:Nx \stex_notation_do:nnnnn
{ \prop_item:cn {l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { args } }
{ \prop_item:cn { l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { arity } }
- { \l_@@_variant_str \c_hash_str \l_@@_lang_str }
+ { \l_@@_variant_str }
+ { \l_@@_prec_str}
}
\stex_deactivate_macro:Nn \symdef {module~environments}
% \end{macrocode}
@@ -1059,6 +1101,7 @@
def .tl_set:N = \l_@@_def_tl ,
op .tl_set:N = \l_@@_op_tl ,
prec .str_set_x:N = \l_@@_prec_str ,
+ reorder .str_set_x:N = \l_@@_reorder_str ,
assoc .choices:nn =
{bin,binl,binr,pre,conj,pwconj}
{\str_set:Nx \l_@@_assoctype_str {\l_keys_choice_tl}},
@@ -1072,6 +1115,7 @@
\str_clear:N \l_@@_args_str
\str_clear:N \l_@@_prec_str
\str_clear:N \l_@@_assoctype_str
+ \str_clear:N \l_@@_reorder_str
\str_clear:N \l_@@_bind_str
\tl_clear:N \l_@@_type_tl
\tl_clear:N \l_@@_def_tl
@@ -1137,11 +1181,7 @@
\tl_if_empty:NF \l_@@_op_tl {
\cs_set:cpx {
stex_var_op_notation_ \l_@@_name_str _cs
- } {
- \_stex_term_omv:nn {
- var://\l_@@_name_str
- }{ \comp{ \exp_args:No \exp_not:n { \l_@@_op_tl } } }
- }
+ } { \exp_not:N\comp{ \exp_args:No \exp_not:n { \l_@@_op_tl } } }
}
\tl_set:Nn \l_stex_notation_after_do_tl {
@@ -1151,14 +1191,14 @@
} {{
\exp_after:wN \exp_after:wN \exp_after:wN
\exp_not:n \exp_after:wN \exp_after:wN \exp_after:wN
- { \exp_after:wN \l_stex_notation_macrocode_cs \l_stex_notation_dummyargs_tl \stex_symbol_after_invocation_tl}
+ { \exp_after:wN \l_stex_notation_macrocode_cs \l_stex_notation_dummyargs_tl \STEXInternalSymbolAfterInvokationTL}
}}
\stex_if_do_html:T {
\stex_annotate_invisible:nnn {vardecl}{\l_@@_name_str}{
\stex_annotate_invisible:nnn { precedence }
{ \l_@@_prec_str }{}
\tl_if_empty:NF \l_@@_type_tl {\stex_annotate_invisible:nnn{type}{}{$\l_@@_type_tl$}}
- \stex_annotate_invisible:nnn{args}{}{ \l_@@_args_str }
+ \stex_annotate_invisible:nnn{args}{ \l_@@_args_str }{}
\stex_annotate_invisible:nnn{macroname}{#1}{}
\tl_if_empty:NF \l_@@_def_tl {
\stex_annotate_invisible:nnn{definiens}{}
@@ -1167,6 +1207,9 @@
\str_if_empty:NF \l_@@_assoctype_str {
\stex_annotate_invisible:nnn{assoctype}{\l_@@_assoctype_str}{}
}
+ \str_if_empty:NF \l_@@_reorder_str {
+ \stex_annotate_invisible:nnn{reorderargs}{\l_@@_reorder_str}{}
+ }
\int_zero:N \l_tmpa_int
\str_set_eq:NN \l_@@_remaining_args_str \l_@@_args_str
\tl_clear:N \l_tmpa_tl
@@ -1176,36 +1219,44 @@
\str_set:Nx \l_@@_remaining_args_str { \str_tail:N \l_@@_remaining_args_str }
\str_if_eq:VnTF \l_tmpb_str a {
\tl_set:Nx \l_tmpa_tl { \l_tmpa_tl {
- \c_hash_str \c_hash_str \int_use:N \l_tmpa_int a ,
- \c_hash_str \c_hash_str \int_use:N \l_tmpa_int b
+ \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int a}{} ,
+ \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int b}{}
} }
}{
\str_if_eq:VnTF \l_tmpb_str B {
\tl_set:Nx \l_tmpa_tl { \l_tmpa_tl {
- \c_hash_str \c_hash_str \int_use:N \l_tmpa_int a ,
- \c_hash_str \c_hash_str \int_use:N \l_tmpa_int b
+ \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int a}{} ,
+ \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int b}{}
} }
}{
\tl_set:Nx \l_tmpa_tl { \l_tmpa_tl {
- \c_hash_str \c_hash_str \int_use:N \l_tmpa_int
+ \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int}{}
} }
}
}
}
\stex_annotate_invisible:nnn { notationcomp }{}{
- \str_set:Nx \l_stex_current_symbol_str {var://\l_@@_name_str }
+ \str_set:Nx \STEXInternalCurrentSymbolStr {var://\l_@@_name_str }
$ \exp_args:Nno \use:nn { \use:c {
stex_var_notation_\l_@@_name_str _cs
} } { \l_tmpa_tl } $
}
+ \tl_if_empty:NF \l_@@_op_tl {
+ \stex_annotate_invisible:nnn { notationopcomp }{}{
+ $\l_@@_op_tl$
+ }
+ }
}
- }
+ \str_if_empty:NF \l_@@_bind_str {
+ \stex_annotate_invisible:nnn {bindtype}{\l_@@_bind_str,\l_@@_name_str}{}
+ }
+ }\ignorespacesandpars
}
- \stex_notation_do:nnnn { \l_@@_args_str } { \prop_item:Nn \l_tmpa_prop { arity } } {}
+ \stex_notation_do:nnnnn { \l_@@_args_str } { \prop_item:Nn \l_tmpa_prop { arity } } {}{ \l_@@_prec_str}
}
-\cs_new:Nn \_@@_reset:N {
+\cs_new:Nn \_stex_reset:N {
\tl_if_exist:NTF #1 {
\def \exp_not:N #1 { \exp_args:No \exp_not:n #1 }
}{
@@ -1217,13 +1268,13 @@
\clist_set:Nx \l_@@_names { \tl_to_str:n {#1} }
\exp_args:Nnx \use:nn {
% TODO
- \stex_annotate_invisible:nnn {vardecls}{\clist_use:Nn\l_@@_names,}{
+ \stex_annotate_invisible:nnn {vardecl}{\clist_use:Nn\l_@@_names,}{
#2
}
}{
- \_@@_reset:N \varnot
- \_@@_reset:N \vartype
- \_@@_reset:N \vardefi
+ \_stex_reset:N \varnot
+ \_stex_reset:N \vartype
+ \_stex_reset:N \vardefi
}
}
@@ -1242,8 +1293,143 @@
\str_set:Nn \l_tmpa_str { #1 }
}
\_stex_term_omv:nn {
- var://\l_tmpa_str
- }{ \comp{ #2 } }
+ var://\l_tmpa_str
+ }{
+ \exp_args:Nnx \use:nn {
+ \def\comp{\_varcomp}
+ \str_set:Nx \STEXInternalCurrentSymbolStr { var://\l_tmpa_str }
+ \comp{ #2 }
+ }{
+ \_stex_reset:N \comp
+ \_stex_reset:N \STEXInternalCurrentSymbolStr
+ }
+ }
+}
+
+
+
+\keys_define:nn { stex / varseq } {
+ name .str_set_x:N = \l_@@_name_str ,
+ args .int_set:N = \l_@@_args_int ,
+ type .tl_set:N = \l_@@_type_tl ,
+ mid .tl_set:N = \l_@@_mid_tl ,
+ bind .choices:nn =
+ {forall,exists}
+ {\str_set:Nx \l_@@_bind_str {\l_keys_choice_tl}}
+}
+
+\cs_new_protected:Nn \_@@_seq_args:n {
+ \str_clear:N \l_@@_name_str
+ \int_set:Nn \l_@@_args_int 1
+ \tl_clear:N \l_@@_type_tl
+ \str_clear:N \l_@@_bind_str
+
+ \keys_set:nn { stex / varseq } { #1 }
+}
+
+\NewDocumentCommand \varseq {m O{} m m m}{
+ \_@@_seq_args:n { #2 }
+ \str_if_empty:NT \l_@@_name_str {
+ \str_set:Nx \l_@@_name_str { #1 }
+ }
+ \prop_clear:N \l_tmpa_prop
+ \prop_put:Nnx \l_tmpa_prop { arity }{\int_use:N \l_@@_args_int}
+
+ \seq_set_from_clist:Nn \l_tmpa_seq {#3}
+ \int_compare:nNnF {\seq_count:N \l_tmpa_seq} = \l_@@_args_int {
+ \msg_error:nnxx{stex}{error/seqlength}
+ {\int_use:N \l_@@_args_int}
+ {\seq_count:N \l_tmpa_seq}
+ }
+ \seq_set_from_clist:Nn \l_tmpb_seq {#4}
+ \int_compare:nNnF {\seq_count:N \l_tmpb_seq} = \l_@@_args_int {
+ \msg_error:nnxx{stex}{error/seqlength}
+ {\int_use:N \l_@@_args_int}
+ {\seq_count:N \l_tmpb_seq}
+ }
+ \prop_put:Nnn \l_tmpa_prop {starts} {#3}
+ \prop_put:Nnn \l_tmpa_prop {ends} {#4}
+
+ \cs_generate_from_arg_count:cNnn {stex_varseq_\l_@@_name_str _cs}
+ \cs_set:Npn {\int_use:N \l_@@_args_int} { #5 }
+
+ \exp_args:NNo \tl_set:No \l_tmpa_tl {\use:c{stex_varseq_\l_@@_name_str _cs}}
+ \int_step_inline:nn \l_@@_args_int {
+ \tl_put_right:Nx \l_tmpa_tl { {\seq_item:Nn \l_tmpa_seq {##1}} }
+ }
+ \tl_set:Nx \l_tmpa_tl {\exp_args:NNo \exp_args:No \exp_not:n{\l_tmpa_tl}}
+ \tl_put_right:Nn \l_tmpa_tl {,\ellipses,}
+ \tl_if_empty:NF \l_@@_mid_tl {
+ \tl_put_right:No \l_tmpa_tl \l_@@_mid_tl
+ \tl_put_right:Nn \l_tmpa_tl {,\ellipses,}
+ }
+ \exp_args:NNo \tl_set:No \l_tmpb_tl {\use:c{stex_varseq_\l_@@_name_str _cs}}
+ \int_step_inline:nn \l_@@_args_int {
+ \tl_put_right:Nx \l_tmpb_tl { {\seq_item:Nn \l_tmpb_seq {##1}} }
+ }
+ \tl_set:Nx \l_tmpb_tl {\exp_args:NNo \exp_args:No \exp_not:n{\l_tmpb_tl}}
+ \tl_put_right:No \l_tmpa_tl \l_tmpb_tl
+
+
+ \prop_put:Nno \l_tmpa_prop { notation }\l_tmpa_tl
+
+ \tl_set:cx {#1} {\stex_invoke_sequence:n {\l_@@_name_str}}
+
+ \exp_args:NNo \tl_set:No \l_tmpa_tl {\use:c{stex_varseq_\l_@@_name_str _cs}}
+
+ \int_step_inline:nn \l_@@_args_int {
+ \tl_set:Nx \l_tmpa_tl {\exp_args:No \exp_not:n \l_tmpa_tl {
+ \STEXInternalTermMathArgiii{i##1}{0}{\exp_not:n{####}##1}
+ }}
+ }
+
+ \tl_set:Nx \l_tmpa_tl {
+ \STEXInternalTermMathOMAiiii { varseq://\l_@@_name_str}{}{0}{
+ \exp_args:NNo \exp_args:No \exp_not:n {\l_tmpa_tl}
+ }
+ }
+
+ \tl_set:No \l_tmpa_tl { \exp_after:wN { \l_tmpa_tl \STEXInternalSymbolAfterInvokationTL} }
+
+ \exp_args:Nno \use:nn {
+ \cs_generate_from_arg_count:cNnn {stex_varseq_\l_@@_name_str _cs}
+ \cs_set:Npn {\int_use:N \l_@@_args_int}}{\l_tmpa_tl}
+
+ \stex_debug:nn{sequences}{New~Sequence:~
+ \expandafter\meaning\csname stex_varseq_\l_@@_name_str _cs\endcsname\\~\\
+ \prop_to_keyval:N \l_tmpa_prop
+ }
+ \stex_if_do_html:T{\stex_annotate_invisible:nnn{varseq}{\l_@@_name_str}{
+ \tl_if_empty:NF \l_@@_type_tl {
+ \stex_annotate:nnn {type}{}{$\l_@@_type_tl$}
+ }
+ \stex_annotate:nnn {args}{\int_use:N \l_@@_args_int}{}
+ \str_if_empty:NF \l_@@_bind_str {
+ \stex_annotate:nnn {bindtype}{\l_@@_bind_str}{}
+ }
+ \stex_annotate:nnn{startindex}{}{$#3$}
+ \stex_annotate:nnn{endindex}{}{$#4$}
+
+ \tl_clear:N \l_tmpa_tl
+ \int_step_inline:nn \l_@@_args_int {
+ \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl {
+ \stex_annotate:nnn{argmarker}{##1}{}
+ } }
+ }
+ \stex_annotate_invisible:nnn { notationcomp }{}{
+ \str_set:Nx \STEXInternalCurrentSymbolStr {varseq://\l_@@_name_str }
+ $ \exp_args:Nno \use:nn { \use:c {
+ stex_varseq_\l_@@_name_str _cs
+ } } { \l_tmpa_tl } $
+ }
+ \stex_annotate_invisible:nnn { notationopcomp }{}{
+ $ \prop_item:Nn \l_tmpa_prop { notation } $
+ }
+
+ }}
+
+ \prop_set_eq:cN {stex_varseq_\l_@@_name_str _prop}\l_tmpa_prop
+ \ignorespacesandpars
}
% \end{macrocode}
@@ -1253,6 +1439,7 @@
% \end{macrocode}
%
% \end{implementation}
+% \ifinfulldoc\else\printbibliography\fi
%
% \PrintIndex