diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/expl3/l3tl.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/expl3/l3tl.dtx | 195 |
1 files changed, 183 insertions, 12 deletions
diff --git a/Master/texmf-dist/source/latex/expl3/l3tl.dtx b/Master/texmf-dist/source/latex/expl3/l3tl.dtx index 4b38de0d0f1..5c5bc8990be 100644 --- a/Master/texmf-dist/source/latex/expl3/l3tl.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3tl.dtx @@ -36,7 +36,7 @@ \RequirePackage{l3names} %</driver|package> %\fi -\GetIdInfo$Id: l3tl.dtx 1873 2010-03-24 08:32:54Z joseph $ +\GetIdInfo$Id: l3tl.dtx 1905 2010-05-19 07:45:31Z joseph $ {L3 Experimental Token Lists} %\iffalse %<*driver> @@ -86,18 +86,30 @@ % \begin{syntax} % "\tl_new:Nn" <\tlvar> \Arg{initial token list} % \end{syntax} -% Defines <\tlvar> to be a new variable to store a token list. +% Defines <\tlvar> globally to be a new variable to store a token list. % <initial token list> is the initial value of <\tlvar>. This % makes it possible to assign values to a constant token list variable. % % The form "\tl_new:N" initializes the token list variable with an empty value. % \end{function} -% +% +% \begin{function}{\tl_new_local:N | +% \tl_new_local:c | +% \tl_new_local:Nn | +% \tl_new_local:cn | +% \tl_new_local:Nx } +% \begin{syntax} +% "\tl_new_local:Nn" <\tlvar> \Arg{initial token list} +% \end{syntax} +% Locally defines <\tlvar> to be a new variable to store a token list. +% It will only exist while the current group is open. +% \end{function} +% % \begin{function}{\tl_const:Nn} % \begin{syntax} % "\tl_const:Nn" \meta{\tlvar} \Arg{token list} % \end{syntax} -% Defines \meta{\tlvar} as a constant expanding to \meta{token list}. +% Defines \meta{\tlvar} as a global constant expanding to \meta{token list}. % The name of the constant must be free when the constant is created. % \end{function} % @@ -749,15 +761,15 @@ % \tl_head_iii:w / (EXP) % } % \begin{syntax} -% "\tl_head:n" "{" <token1><token2>...<token\,$\sb n$> "}" \\ -% "\tl_tail:n" "{" <token1><token2>...<token\,$\sb n$> "}" \\ -% "\tl_head:w" <token1><token2>...<token\,$\sb n$> "\q_nil" +% "\tl_head:n" "{" <token1><token2>...<token\,$\sb k$> "}" \\ +% "\tl_tail:n" "{" <token1><token2>...<token\,$\sb k$> "}" \\ +% "\tl_head:w" <token1><token2>...<token\,$\sb k$> "\q_nil" % \end{syntax} -% These functions return either the head or the tail of a list, thus in +% These functions return either the head or the tail from a list of tokens, thus in % the above example "\tl_head:n" would return <token1> and "\tl_tail:n" -% would return <token2>\dots<token\,$\sb n$>. "\tl_head_iii:n" returns the first -% three tokens. The ":w" versions require some care as they use a -% delimited argument internally. +% would return <token2>\dots<token\,$\sb k$>. "\tl_head_iii:n" returns the first +% three tokens. The ":w" versions require some care as they expect the token +% list to be delimited by "\q_nil". % \begin{texnote} % These are the Lisp functions "car" and "cdr" but with \LaTeX3 names. % \end{texnote} @@ -874,7 +886,42 @@ % \end{macro} % \end{macro} % \end{macro} -% +% +% \begin{macro}{\tl_new_local:N} +% \begin{macro}{\tl_new_local:c} +% \begin{macro}{\tl_new_local:Nn} +% \begin{macro}{\tl_new_local:cn} +% \begin{macro}{\tl_new_local:Nx} +% \begin{macrocode} +\cs_new_protected:Npn \tl_new_local:Nn #1#2{ + \chk_if_free_cs:N #1 +% \end{macrocode} +% If checking we don't allow constants to be defined. +% \begin{macrocode} +%<*check> + \chk_var_or_const:N #1 +%</check> +% \end{macrocode} +% Otherwise any variable type is allowed. +% \begin{macrocode} + \cs_set_nopar:Npn #1{#2} +} +\cs_generate_variant:Nn \tl_new_local:Nn {cn} +\cs_new_protected:Npn \tl_new_local:Nx #1#2{ + \chk_if_free_cs:N #1 +%<check> \chk_var_or_const:N #1 + \cs_set_nopar:Npx #1{#2} +} +\cs_new_protected_nopar:Npn \tl_new_local:N #1{\tl_new_local:Nn #1{}} +\cs_new_protected_nopar:Npn \tl_new_local:c #1{\tl_new_local:cn {#1}{}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% %\begin{macro}{\tl_const:Nn} % For creating constant token lists: there is not actually anything here % that cannot be achieved using \cs{tl_new:N} and \cs{tl_set:Nn} @@ -2324,6 +2371,130 @@ % \end{macro} % \end{macro} % \end{macro} +% +%\begin{macro}{\_tl_check_exists:N} +% When used as a package, there is an option to be picky and to +% check definitions exist. The message text for this is created later, +% as the mechanism is not yet in place. +% \begin{macrocode} +%<*package> +\tex_ifodd:D \@l@expl@check@declarations@bool \scan_stop: + \cs_set_protected:Npn \_tl_check_exists:N #1 + { + \cs_if_exist:NF #1 + { + \msg_kernel_error:nnx { check } { non-declared-variable } + { \token_to_str:N #1 } + } + } + \cs_set_protected:Npn \tl_set:Nn #1#2 + { + \_tl_check_exists:N #1 + \cs_set_nopar:Npx #1 { \exp_not:n {#2} } + } + \cs_set_protected:Npn \tl_set:Nx #1#2 + { + \_tl_check_exists:N #1 + \cs_set_nopar:Npx #1 {#2} + } + \cs_set_protected:Npn \tl_gset:Nn #1#2 + { + \_tl_check_exists:N #1 + \cs_gset_nopar:Npx #1 { \exp_not:n {#2} } + } + \cs_set_protected:Npn \tl_gset:Nx #1#2 + { + \_tl_check_exists:N #1 + \cs_gset_nopar:Npx #1 {#2} + } + \cs_set_protected:Npn \tl_set_eq:NN #1#2 + { + \_tl_check_exists:N #1 + \_tl_check_exists:N #2 + \cs_set_eq:NN #1 #2 + } + \cs_set_protected:Npn \tl_gset_eq:NN #1#2 + { + \_tl_check_exists:N #1 + \_tl_check_exists:N #2 + \cs_gset_eq:NN #1 #2 + } + \cs_set_protected:Npn \tl_put_right:Nn #1#2 { + \_tl_check_exists:N #1 + \cs_set_nopar:Npx #1 { \exp_not:V #1 \exp_not:n {#2} } + } + \cs_set_protected:Npn \tl_put_right:NV #1#2 { + \_tl_check_exists:N #1 + \cs_set_nopar:Npx #1 { \exp_not:V #1 \exp_not:V #2 } + } + \cs_set_protected:Npn \tl_put_right:Nv #1#2 { + \_tl_check_exists:N #1 + \cs_set_nopar:Npx #1 { \exp_not:V #1 \exp_not:v {#2} } + } + \cs_set_protected:Npn \tl_put_right:No #1#2 { + \_tl_check_exists:N #1 + \cs_set_nopar:Npx #1 { \exp_not:V #1 \exp_not:o {#2} } + } + \cs_set_protected:Npn \tl_put_right:Nx #1#2 { + \_tl_check_exists:N #1 + \cs_set_nopar:Npx #1 { \exp_not:V #1 #2 } + } + \cs_set_protected:Npn \tl_gput_right:Nn #1#2 { + \_tl_check_exists:N #1 + \cs_gset_nopar:Npx #1 { \exp_not:V #1 \exp_not:n {#2} } + } + \cs_set_protected:Npn \tl_gput_right:NV #1#2 { + \_tl_check_exists:N #1 + \cs_gset_nopar:Npx #1 { \exp_not:V #1 \exp_not:V #2 } + } + \cs_set_protected:Npn \tl_gput_right:Nv #1#2 { + \_tl_check_exists:N #1 + \cs_gset_nopar:Npx #1 { \exp_not:V #1 \exp_not:v {#2} } + } + \cs_set_protected:Npn \tl_gput_right:Nx #1#2 { + \_tl_check_exists:N #1 + \cs_gset_nopar:Npx #1 { \exp_not:V #1 #2 } + } + \cs_set_protected:Npn \tl_put_left:Nn #1#2 { + \_tl_check_exists:N #1 + \cs_set_nopar:Npx #1 { \exp_not:n {#2} \exp_not:V #1 } + } + \cs_set_protected:Npn \tl_put_left:NV #1#2 { + \_tl_check_exists:N #1 + \cs_set_nopar:Npx #1 { \exp_not:V #2 \exp_not:V #1 } + } + \cs_set_protected:Npn \tl_put_left:Nv #1#2 { + \_tl_check_exists:N #1 + \cs_set_nopar:Npx #1 { \exp_not:v {#2} \exp_not:V #1 } + } + \cs_set_protected:Npn \tl_put_left:No #1#2 { + \_tl_check_exists:N #1 + \cs_set_nopar:Npx #1 { \exp_not:o {#2} \exp_not:V #1 } + } + \cs_set_protected:Npn \tl_put_left:Nx #1#2 { + \_tl_check_exists:N #1 + \cs_set_nopar:Npx #1 { #2 \exp_not:V #1 } + } + \cs_set_protected:Npn \tl_gput_left:Nn #1#2 { + \_tl_check_exists:N #1 + \cs_gset_nopar:Npx #1 { \exp_not:n {#2} \exp_not:V #1 } + } + \cs_set_protected:Npn \tl_gput_left:NV #1#2 { + \_tl_check_exists:N #1 + \cs_gset_nopar:Npx #1 { \exp_not:V #2 \exp_not:V #1 } + } + \cs_set_protected:Npn \tl_gput_left:Nv #1#2 { + \_tl_check_exists:N #1 + \cs_gset_nopar:Npx #1 { \exp_not:v {#2} \exp_not:V #1 } + } + \cs_set_protected:Npn \tl_gput_left:Nx #1#2 { + \_tl_check_exists:N #1 + \cs_gset_nopar:Npx #1 { #2 \exp_not:V #1 } + } +\tex_fi:D +%</package> +% \end{macrocode} +%\end{macro} % % Show token usage: % \begin{macrocode} |