diff options
author | Karl Berry <karl@freefriends.org> | 2009-06-09 23:31:15 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-06-09 23:31:15 +0000 |
commit | 215b9a864d5829070bdc66ba736986eb72e5143e (patch) | |
tree | fe0882c81fc4ec945cee4b512f72eaa21ea5f791 /Master/texmf-dist/tex/latex/expl3/l3token.sty | |
parent | df90ec06321940c2f066b05e12f1b5ab099105da (diff) |
expl3 1407 (9jun09)
git-svn-id: svn://tug.org/texlive/trunk@13686 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/expl3/l3token.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/expl3/l3token.sty | 709 |
1 files changed, 354 insertions, 355 deletions
diff --git a/Master/texmf-dist/tex/latex/expl3/l3token.sty b/Master/texmf-dist/tex/latex/expl3/l3token.sty index b9f43418038..034312a4707 100644 --- a/Master/texmf-dist/tex/latex/expl3/l3token.sty +++ b/Master/texmf-dist/tex/latex/expl3/l3token.sty @@ -15,7 +15,7 @@ %% Do not distribute a modified version of this file. %% %% -%% File: l3token.dtx Copyright (C) 2005-2006 LaTeX3 project +%% File: l3token.dtx Copyright (C) 2005-2009 LaTeX3 project %% %% It may be distributed and/or modified under the conditions of the %% LaTeX Project Public License (LPPL), either version 1.3c of this @@ -33,7 +33,7 @@ %% %% The development version of the bundle can be found at %% -%% http://www.latex-project.org/cgi-bin/cvsweb.cgi/ +%% http://www.latex-project.org/svnroot/experimental/trunk/ %% %% for those people who are interested. %% @@ -48,64 +48,108 @@ %% %% ----------------------------------------------------------------------- \RequirePackage{l3names} -\GetIdInfo$Id: l3token.dtx 701 2007-11-27 14:21:05Z morten $ +\GetIdInfo$Id: l3token.dtx 1365 2009-05-31 17:26:17Z mittelba $ {L3 Experimental token investigation and manipulation} \ProvidesExplPackage {\filename}{\filedate}{\fileversion}{\filedescription} -\RequirePackage{l3prg} -\RequirePackage{l3int} -\let_new:NN \char_set_catcode:w \tex_catcode:D -\def_new:Npn \char_set_catcode:nn #1#2{ - \char_set_catcode:w #1 = \int_eval:n{#2} -} -\def_new:Npn \char_value_catcode:w {\int_use:N\tex_catcode:D} -\def_new:Npn \char_value_catcode:n #1{\char_value_catcode:w \int_eval:n{#1}} -\def_new:Npn \char_show_value_catcode:w {\tex_showthe:D\tex_catcode:D} -\def_new:Npn \char_show_value_catcode:n #1{ - \char_show_value_catcode:w \int_eval:n{#1}} -\let_new:NN \char_set_mathcode:w \tex_mathcode:D -\def_new:Npn \char_set_mathcode:nn #1#2{ - \char_set_mathcode:w #1 = \int_eval:n{#2} -} -\def_protected_new:Npn \char_gset_mathcode:w {\pref_global:D\tex_mathcode:D} -\def_new:Npn \char_gset_mathcode:nn #1#2{ - \char_gset_mathcode:w #1 = \int_eval:n{#2} -} -\def_new:Npn \char_value_mathcode:w {\int_use:N\tex_mathcode:D} -\def_new:Npn \char_value_mathcode:n #1{\char_value_mathcode:w \int_eval:n{#1}} -\def_new:Npn \char_show_value_mathcode:w {\tex_showthe:D\tex_mathcode:D} -\def_new:Npn \char_show_value_mathcode:n #1{ - \char_show_value_mathcode:w \int_eval:n{#1}} -\let_new:NN \char_set_lccode:w \tex_lccode:D -\def_new:Npn \char_set_lccode:nn #1#2{ - \char_set_lccode:w #1 = \int_eval:n{#2} -} -\def_new:Npn \char_value_lccode:w {\int_use:N\tex_lccode:D} -\def_new:Npn \char_value_lccode:n #1{\char_value_lccode:w \int_eval:n{#1}} -\def_new:Npn \char_show_value_lccode:w {\tex_showthe:D\tex_lccode:D} -\def_new:Npn \char_show_value_lccode:n #1{ - \char_show_value_lccode:w \int_eval:n{#1}} -\let_new:NN \char_set_uccode:w \tex_uccode:D -\def_new:Npn \char_set_uccode:nn #1#2{ - \char_set_uccode:w #1 = \int_eval:n{#2} -} -\def_new:Npn \char_value_uccode:w {\int_use:N\tex_uccode:D} -\def_new:Npn \char_value_uccode:n #1{\char_value_uccode:w \int_eval:n{#1}} -\def_new:Npn \char_show_value_uccode:w {\tex_showthe:D\tex_uccode:D} -\def_new:Npn \char_show_value_uccode:n #1{ - \char_show_value_uccode:w \int_eval:n{#1}} -\let_new:NN \char_set_sfcode:w \tex_sfcode:D -\def_new:Npn \char_set_sfcode:nn #1#2{ - \char_set_sfcode:w #1 = \int_eval:n{#2} -} -\def_new:Npn \char_value_sfcode:w {\int_use:N\tex_uccode:D} -\def_new:Npn \char_value_sfcode:n #1{\char_value_sfcode:w \int_eval:n{#1}} -\def_new:Npn \char_show_value_sfcode:w {\tex_showthe:D\tex_sfcode:D} -\def_new:Npn \char_show_value_sfcode:n #1{ - \char_show_value_sfcode:w \int_eval:n{#1}} -\def_new:Npn \token_new:Nn #1#2{\glet_new:NN #1#2} -\let_new:NN \c_group_begin_token { -\let_new:NN \c_group_end_token } +\package_check_loaded_expl: +\cs_new_eq:NN \char_set_catcode:w \tex_catcode:D +\cs_new_nopar:Npn \char_set_catcode:nn #1#2 { + \char_set_catcode:w #1 = \intexpr_eval:w #2\intexpr_eval_end: +} +\cs_new_nopar:Npn \char_value_catcode:w { \int_use:N \tex_catcode:D } +\cs_new_nopar:Npn \char_value_catcode:n #1 { + \char_value_catcode:w \intexpr_eval:w #1\intexpr_eval_end: +} +\cs_new_nopar:Npn \char_show_value_catcode:w { + \tex_showthe:D \tex_catcode:D +} +\cs_new_nopar:Npn \char_show_value_catcode:n #1 { + \char_show_value_catcode:w \intexpr_eval:w #1\intexpr_eval_end: +} +\cs_new_nopar:Npn \char_make_escape:N #1 { \char_set_catcode:nn {`#1} {\c_zero} } +\cs_new_nopar:Npn \char_make_begin_group:N #1 { \char_set_catcode:nn {`#1} {\c_one} } +\cs_new_nopar:Npn \char_make_end_group:N #1 { \char_set_catcode:nn {`#1} {\c_two} } +\cs_new_nopar:Npn \char_make_math_shift:N #1 { \char_set_catcode:nn {`#1} {\c_three} } +\cs_new_nopar:Npn \char_make_alignment:N #1 { \char_set_catcode:nn {`#1} {\c_four} } +\cs_new_nopar:Npn \char_make_end_line:N #1 { \char_set_catcode:nn {`#1} {\c_five} } +\cs_new_nopar:Npn \char_make_parameter:N #1 { \char_set_catcode:nn {`#1} {\c_six} } +\cs_new_nopar:Npn \char_make_math_superscript:N #1 { \char_set_catcode:nn {`#1} {\c_seven} } +\cs_new_nopar:Npn \char_make_math_subscript:N #1 { \char_set_catcode:nn {`#1} {\c_eight} } +\cs_new_nopar:Npn \char_make_ignore:N #1 { \char_set_catcode:nn {`#1} {\c_nine} } +\cs_new_nopar:Npn \char_make_space:N #1 { \char_set_catcode:nn {`#1} {\c_ten} } +\cs_new_nopar:Npn \char_make_letter:N #1 { \char_set_catcode:nn {`#1} {\c_eleven} } +\cs_new_nopar:Npn \char_make_other:N #1 { \char_set_catcode:nn {`#1} {\c_twelve} } +\cs_new_nopar:Npn \char_make_active:N #1 { \char_set_catcode:nn {`#1} {\c_thirteen} } +\cs_new_nopar:Npn \char_make_comment:N #1 { \char_set_catcode:nn {`#1} {\c_fourteen} } +\cs_new_nopar:Npn \char_make_invalid:N #1 { \char_set_catcode:nn {`#1} {\c_fifteen} } +\cs_new_nopar:Npn \char_make_escape:n #1 { \char_set_catcode:nn {#1} {\c_zero} } +\cs_new_nopar:Npn \char_make_begin_group:n #1 { \char_set_catcode:nn {#1} {\c_one} } +\cs_new_nopar:Npn \char_make_end_group:n #1 { \char_set_catcode:nn {#1} {\c_two} } +\cs_new_nopar:Npn \char_make_math_shift:n #1 { \char_set_catcode:nn {#1} {\c_three} } +\cs_new_nopar:Npn \char_make_alignment:n #1 { \char_set_catcode:nn {#1} {\c_four} } +\cs_new_nopar:Npn \char_make_end_line:n #1 { \char_set_catcode:nn {#1} {\c_five} } +\cs_new_nopar:Npn \char_make_parameter:n #1 { \char_set_catcode:nn {#1} {\c_six} } +\cs_new_nopar:Npn \char_make_math_superscript:n #1 { \char_set_catcode:nn {#1} {\c_seven} } +\cs_new_nopar:Npn \char_make_math_subscript:n #1 { \char_set_catcode:nn {#1} {\c_eight} } +\cs_new_nopar:Npn \char_make_ignore:n #1 { \char_set_catcode:nn {#1} {\c_nine} } +\cs_new_nopar:Npn \char_make_space:n #1 { \char_set_catcode:nn {#1} {\c_ten} } +\cs_new_nopar:Npn \char_make_letter:n #1 { \char_set_catcode:nn {#1} {\c_eleven} } +\cs_new_nopar:Npn \char_make_other:n #1 { \char_set_catcode:nn {#1} {\c_twelve} } +\cs_new_nopar:Npn \char_make_active:n #1 { \char_set_catcode:nn {#1} {\c_thirteen} } +\cs_new_nopar:Npn \char_make_comment:n #1 { \char_set_catcode:nn {#1} {\c_fourteen} } +\cs_new_nopar:Npn \char_make_invalid:n #1 { \char_set_catcode:nn {#1} {\c_fifteen} } +\cs_new_eq:NN \char_set_mathcode:w \tex_mathcode:D +\cs_new_nopar:Npn \char_set_mathcode:nn #1#2 { + \char_set_mathcode:w #1 = \intexpr_eval:w #2\intexpr_eval_end: +} +\cs_new_protected_nopar:Npn \char_gset_mathcode:w { \pref_global:D \tex_mathcode:D } +\cs_new_nopar:Npn \char_gset_mathcode:nn #1#2 { + \char_gset_mathcode:w #1 = \intexpr_eval:w #2\intexpr_eval_end: +} +\cs_new_nopar:Npn \char_value_mathcode:w { \int_use:N \tex_mathcode:D } +\cs_new_nopar:Npn \char_value_mathcode:n #1 { + \char_value_mathcode:w \intexpr_eval:w #1\intexpr_eval_end: +} +\cs_new_nopar:Npn \char_show_value_mathcode:w { \tex_showthe:D \tex_mathcode:D } +\cs_new_nopar:Npn \char_show_value_mathcode:n #1 { + \char_show_value_mathcode:w \intexpr_eval:w #1\intexpr_eval_end: +} +\cs_new_eq:NN \char_set_lccode:w \tex_lccode:D +\cs_new_nopar:Npn \char_set_lccode:nn #1#2{ + \char_set_lccode:w #1 = \intexpr_eval:w #2\intexpr_eval_end: +} +\cs_new_nopar:Npn \char_value_lccode:w {\int_use:N\tex_lccode:D} +\cs_new_nopar:Npn \char_value_lccode:n #1{\char_value_lccode:w + \intexpr_eval:w #1\intexpr_eval_end:} +\cs_new_nopar:Npn \char_show_value_lccode:w {\tex_showthe:D\tex_lccode:D} +\cs_new_nopar:Npn \char_show_value_lccode:n #1{ + \char_show_value_lccode:w \intexpr_eval:w #1\intexpr_eval_end:} +\cs_new_eq:NN \char_set_uccode:w \tex_uccode:D +\cs_new_nopar:Npn \char_set_uccode:nn #1#2{ + \char_set_uccode:w #1 = \intexpr_eval:w #2\intexpr_eval_end: +} +\cs_new_nopar:Npn \char_value_uccode:w {\int_use:N\tex_uccode:D} +\cs_new_nopar:Npn \char_value_uccode:n #1{\char_value_uccode:w + \intexpr_eval:w #1\intexpr_eval_end:} +\cs_new_nopar:Npn \char_show_value_uccode:w {\tex_showthe:D\tex_uccode:D} +\cs_new_nopar:Npn \char_show_value_uccode:n #1{ + \char_show_value_uccode:w \intexpr_eval:w #1\intexpr_eval_end:} +\cs_new_eq:NN \char_set_sfcode:w \tex_sfcode:D +\cs_new_nopar:Npn \char_set_sfcode:nn #1#2 { + \char_set_sfcode:w #1 = \intexpr_eval:w #2\intexpr_eval_end: +} +\cs_new_nopar:Npn \char_value_sfcode:w { \int_use:N \tex_sfcode:D } +\cs_new_nopar:Npn \char_value_sfcode:n #1 { + \char_value_sfcode:w \intexpr_eval:w #1\intexpr_eval_end: +} +\cs_new_nopar:Npn \char_show_value_sfcode:w { \tex_showthe:D \tex_sfcode:D } +\cs_new_nopar:Npn \char_show_value_sfcode:n #1 { + \char_show_value_sfcode:w \intexpr_eval:w #1\intexpr_eval_end: +} +\cs_new_nopar:Npn \token_new:Nn #1#2 {\cs_gnew_eq:NN #1#2} +\cs_new_eq:NN \c_group_begin_token { +\cs_new_eq:NN \c_group_end_token } \group_begin: \char_set_catcode:nn{`\*}{3} \token_new:Nn \c_math_shift_token {*} @@ -119,260 +163,174 @@ \token_new:Nn \c_letter_token {a} \token_new:Nn \c_other_char_token {1} \char_set_catcode:nn{`\*}{13} -\token_new:Nn \c_active_char_token {*} +\cs_gset_nopar:Npn \c_active_char_token {\exp_not:N*} \group_end: -\def_new:Npn \token_if_group_begin_p:N #1{ +\prg_new_conditional:Nnn \token_if_group_begin:N {p,TF,T,F} { \if_catcode:w \exp_not:N #1\c_group_begin_token - \c_true - \else: - \c_false - \fi: + \prg_return_true: \else: \prg_return_false: \fi: } -\def_test_function_new:npn {token_if_group_begin:N} #1{ - \if:w\token_if_group_begin_p:N #1} -\def_new:Npn \token_if_group_end_p:N #1{ +\prg_new_conditional:Nnn \token_if_group_end:N {p,TF,T,F} { \if_catcode:w \exp_not:N #1\c_group_end_token - \c_true - \else: - \c_false - \fi: + \prg_return_true: \else: \prg_return_false: \fi: } -\def_test_function_new:npn {token_if_group_end:N} #1{ - \if:w\token_if_group_end_p:N #1} -\def_new:Npn \token_if_math_shift_p:N #1{ +\prg_new_conditional:Nnn \token_if_math_shift:N {p,TF,T,F} { \if_catcode:w \exp_not:N #1\c_math_shift_token - \c_true - \else: - \c_false - \fi: + \prg_return_true: \else: \prg_return_false: \fi: } -\def_test_function_new:npn {token_if_math_shift:N} #1{ - \if:w\token_if_math_shift_p:N#1} -\def_new:Npn \token_if_alignment_tab_p:N #1{ +\prg_new_conditional:Nnn \token_if_alignment_tab:N {p,TF,T,F} { \if_catcode:w \exp_not:N #1\c_alignment_tab_token - \c_true - \else: - \c_false - \fi: + \prg_return_true: \else: \prg_return_false: \fi: } -\def_test_function_new:npn {token_if_alignment_tab:N} #1{ - \if:w\token_if_alignment_tab_p:N#1} -\def_new:Npn \token_if_parameter_p:N #1{ - \exp_after:NN\if_catcode:w \cs:w c_parameter_token\cs_end:\exp_not:N #1 - \c_true - \else: - \c_false - \fi: +\prg_new_conditional:Nnn \token_if_parameter:N {p,TF,T,F} { + \exp_after:wN\if_catcode:w \cs:w c_parameter_token\cs_end:\exp_not:N #1 + \prg_return_true: \else: \prg_return_false: \fi: } -\def_test_function_new:npn {token_if_parameter:N} #1{ - \if:w\token_if_parameter_p:N#1} -\def_new:Npn \token_if_math_superscript_p:N #1{ +\prg_new_conditional:Nnn \token_if_math_superscript:N {p,TF,T,F} { \if_catcode:w \exp_not:N #1\c_math_superscript_token - \c_true - \else: - \c_false - \fi: + \prg_return_true: \else: \prg_return_false: \fi: } -\def_test_function_new:npn {token_if_math_superscript:N} #1{ - \if:w\token_if_math_superscript_p:N #1} -\def_new:Npn \token_if_math_subscript_p:N #1{ +\prg_new_conditional:Nnn \token_if_math_subscript:N {p,TF,T,F} { \if_catcode:w \exp_not:N #1\c_math_subscript_token - \c_true - \else: - \c_false - \fi: + \prg_return_true: \else: \prg_return_false: \fi: } -\def_test_function_new:npn {token_if_math_subscript:N} #1{ - \if:w\token_if_math_subscript_p:N #1} -\def_new:Npn \token_if_space_p:N #1{ +\prg_new_conditional:Nnn \token_if_space:N {p,TF,T,F} { \if_catcode:w \exp_not:N #1\c_space_token - \c_true - \else: - \c_false - \fi: + \prg_return_true: \else: \prg_return_false: \fi: } -\def_test_function_new:npn {token_if_space:N} #1{ - \if:w\token_if_space_p:N #1} -\def_new:Npn \token_if_letter_p:N #1{ +\prg_new_conditional:Nnn \token_if_letter:N {p,TF,T,F} { \if_catcode:w \exp_not:N #1\c_letter_token - \c_true - \else: - \c_false - \fi: + \prg_return_true: \else: \prg_return_false: \fi: } -\def_test_function_new:npn {token_if_letter:N} #1{ - \if:w\token_if_letter_p:N #1} -\def_new:Npn \token_if_other_char_p:N #1{ +\prg_new_conditional:Nnn \token_if_other_char:N {p,TF,T,F} { \if_catcode:w \exp_not:N #1\c_other_char_token - \c_true - \else: - \c_false - \fi: + \prg_return_true: \else: \prg_return_false: \fi: } -\def_test_function_new:npn {token_if_other_char:N} #1{ - \if:w\token_if_other_char_p:N #1} -\def_new:Npn \token_if_active_char_p:N #1{ +\prg_new_conditional:Nnn \token_if_active_char:N {p,TF,T,F} { \if_catcode:w \exp_not:N #1\c_active_char_token - \c_true - \else: - \c_false - \fi: + \prg_return_true: \else: \prg_return_false: \fi: } -\def_test_function_new:npn {token_if_active_char:N} #1{ - \if:w\token_if_active_char_p:N #1} -\def_new:Npn \token_if_eq_meaning_p:NN #1#2 { - \if_meaning:NN #1 #2 - \c_true - \else: - \c_false - \fi: +\prg_new_conditional:Nnn \token_if_eq_meaning:NN {p,TF,T,F} { + \if_meaning:w #1 #2 + \prg_return_true: \else: \prg_return_false: \fi: } -\def_test_function_new:npn {token_if_eq_meaning:NN}#1#2{ - \if_meaning:NN #1 #2} -\def_new:Npn \token_if_eq_catcode_p:NN #1#2 { +\prg_new_conditional:Nnn \token_if_eq_catcode:NN {p,TF,T,F} { \if_catcode:w \exp_not:N #1 \exp_not:N #2 - \c_true - \else: - \c_false - \fi: + \prg_return_true: \else: \prg_return_false: \fi: } -\def_test_function_new:npn {token_if_eq_catcode:NN}#1#2{ - \if:w\token_if_eq_catcode_p:NN#1#2} -\def_new:Npn \token_if_charcode_eq_p:NN #1#2 { +\prg_new_conditional:Nnn \token_if_eq_charcode:NN {p,TF,T,F} { \if_charcode:w \exp_not:N #1 \exp_not:N #2 - \c_true - \else: - \c_false - \fi: -} -\def_test_function_new:npn {token_if_eq_charcode:NN}#1#2{ - \if:w\token_if_eq_charcode_p:NN#1#2} -\def_new:Npn \token_if_macro_p:N #1 { - \exp_after:NN \token_if_macro_p_aux:w \token_to_meaning:N #1 -> \q_nil -} -\def_new:Npn \token_if_macro_p_aux:w #1 -> #2 \q_nil{ - \if:w \tlist_if_empty_p:n{#2} \c_false \else: \c_true \fi: -} -\def_test_function_new:npn {token_if_macro:N} #1{\if:w\token_if_macro_p:N#1} -\def_new:Npn \token_if_cs_p:N {\token_if_eq_catcode_p:NN \scan_stop:} -\def_test_function_new:npn {token_if_cs:N} #1{ - \if:w \token_if_eq_catcode_p:NN \scan_stop: #1} -\def_new:Npn \token_if_expandable_p:N #1{ - \exp_after:NN \if_token_eq:NN \exp_not:N #1 \scan_stop: - \c_true - \else: - \c_false - \fi: + \prg_return_true: \else: \prg_return_false: \fi: +} +\prg_new_conditional:Nnn \token_if_macro:N {p,TF,T,F} { + \exp_after:wN \token_if_macro_p_aux:w \token_to_meaning:N #1 -> \q_nil +} +\cs_new_nopar:Npn \token_if_macro_p_aux:w #1 -> #2 \q_nil{ + \if_predicate:w \tl_if_empty_p:n{#2} + \prg_return_false: \else: \prg_return_true: \fi: +} +\prg_new_conditional:Nnn \token_if_cs:N {p,TF,T,F} { + \if_predicate:w \token_if_eq_catcode_p:NN \scan_stop: #1 + \prg_return_true: \else: \prg_return_false: \fi:} +\prg_new_conditional:Nnn \token_if_expandable:N {p,TF,T,F} { + \cs_if_exist:NTF #1 { + \exp_after:wN \if_meaning:w \exp_not:N #1 #1 + \prg_return_false: \else: \prg_return_true: \fi: + } { + \prg_return_false: + } } -\def_test_function_new:npn {token_if_expandable:N} #1{ - \if:w\token_if_expandable_p:N#1} \group_begin: + \char_set_lccode:nn {`\T}{`\T} + \char_set_lccode:nn {`\F}{`\F} \char_set_lccode:nn {`\X}{`\n} \char_set_lccode:nn {`\Y}{`\t} \char_set_lccode:nn {`\Z}{`\d} \char_set_lccode:nn {`\?}{`\\} - \tlist_map_inline:nn{\X\Y\Z\M\T\C\H\A\R\O\U\S\K\I\P\L\G\P\E} + \tl_map_inline:nn{\X\Y\Z\M\C\H\A\R\O\U\S\K\I\P\L\G\P\E} {\char_set_catcode:nn {`#1}{12}} -\tlist_to_lowercase:n{ +\tl_to_lowercase:n{ \group_end: -\def_new:Npn \token_if_chardef_p:N #1 { - \exp_after:NN \token_if_chardef_p_aux:w +\prg_new_conditional:Nnn \token_if_chardef:N {p,TF,T,F} { + \exp_after:wN \token_if_chardef_aux:w \token_to_meaning:N #1?CHAR"\q_nil } -\def_new:Npn \token_if_chardef_p_aux:w #1?CHAR"#2\q_nil{ - \tlist_if_empty_p:n{#1} +\cs_new_nopar:Npn \token_if_chardef_aux:w #1?CHAR"#2\q_nil{ + \tl_if_empty:nTF {#1} {\prg_return_true:} {\prg_return_false:} } -\def_new:Npn \token_if_mathchardef_p:N #1 { - \exp_after:NN \token_if_mathchardef_p_aux:w +\prg_new_conditional:Nnn \token_if_mathchardef:N {p,TF,T,F} { + \exp_after:wN \token_if_mathchardef_aux:w \token_to_meaning:N #1?MAYHCHAR"\q_nil } -\def_new:Npn \token_if_mathchardef_p_aux:w #1?MAYHCHAR"#2\q_nil{ - \tlist_if_empty_p:n{#1} +\cs_new_nopar:Npn \token_if_mathchardef_aux:w #1?MAYHCHAR"#2\q_nil{ + \tl_if_empty:nTF {#1} {\prg_return_true:} {\prg_return_false:} } -\def:Npn \token_if_int_register_p:N #1{ - \if_meaning:NN \tex_countdef:D #1 - \c_false +\prg_new_conditional:Nnn \token_if_int_register:N {p,TF,T,F} { + \if_meaning:w \tex_countdef:D #1 + \prg_return_false: \else: - \exp_after:NN \token_if_int_register_p_aux:w + \exp_after:wN \token_if_int_register_aux:w \token_to_meaning:N #1?COUXY\q_nil \fi: } -\def_new:Npn \token_if_int_register_p_aux:w #1?COUXY#2\q_nil{ - \tlist_if_empty_p:n{#1} +\cs_new_nopar:Npn \token_if_int_register_aux:w #1?COUXY#2\q_nil{ + \tl_if_empty:nTF {#1} {\prg_return_true:} {\prg_return_false:} } -\def:Npn \token_if_skip_register_p:N #1{ - \if_meaning:NN \tex_skipdef:D #1 - \c_false +\prg_new_conditional:Nnn \token_if_skip_register:N {p,TF,T,F} { + \if_meaning:w \tex_skipdef:D #1 + \prg_return_false: \else: - \exp_after:NN \token_if_skip_register_p_aux:w - \token_to_meaning:N #1?SKIP\q_nil + \exp_after:wN \token_if_skip_register_aux:w + \token_to_meaning:N #1?SKIP\q_nil \fi: } -\def_new:Npn \token_if_skip_register_p_aux:w #1?SKIP#2\q_nil{ - \tlist_if_empty_p:n{#1} +\cs_new_nopar:Npn \token_if_skip_register_aux:w #1?SKIP#2\q_nil{ + \tl_if_empty:nTF {#1} {\prg_return_true:} {\prg_return_false:} } -\def:Npn \token_if_dim_register_p:N #1{ - \if_meaning:NN \tex_dimendef:D #1 - \c_false +\prg_new_conditional:Nnn \token_if_dim_register:N {p,TF,T,F} { + \if_meaning:w \tex_dimendef:D #1 + \c_false_bool \else: - \exp_after:NN \token_if_dim_register_p_aux:w + \exp_after:wN \token_if_dim_register_aux:w \token_to_meaning:N #1?ZIMEX\q_nil \fi: } -\def_new:Npn \token_if_dim_register_p_aux:w #1?ZIMEX#2\q_nil{ - \tlist_if_empty_p:n{#1} +\cs_new_nopar:Npn \token_if_dim_register_aux:w #1?ZIMEX#2\q_nil{ + \tl_if_empty:nTF {#1} {\prg_return_true:} {\prg_return_false:} } -\def:Npn \token_if_toks_register_p:N #1{ - \if_meaning:NN \tex_toksdef:D #1 - \c_false +\prg_new_conditional:Nnn \token_if_toks_register:N {p,TF,T,F} { + \if_meaning:w \tex_toksdef:D #1 + \prg_return_false: \else: - \exp_after:NN \token_if_toks_register_p_aux:w + \exp_after:wN \token_if_toks_register_aux:w \token_to_meaning:N #1?YOKS\q_nil \fi: } -\def_new:Npn \token_if_toks_register_p_aux:w #1?YOKS#2\q_nil{ - \tlist_if_empty_p:n{#1} +\cs_new_nopar:Npn \token_if_toks_register_aux:w #1?YOKS#2\q_nil{ + \tl_if_empty:nTF {#1} {\prg_return_true:} {\prg_return_false:} } -\def_new:Npn \token_if_protected_macro_p:N #1 { - \exp_after:NN \token_if_protected_macro_p_aux:w +\prg_new_conditional:Nnn \token_if_protected_macro:N {p,TF,T,F} { + \exp_after:wN \token_if_protected_macro_aux:w \token_to_meaning:N #1?PROYECYEZ~MACRO\q_nil } -\def_new:Npn \token_if_protected_macro_p_aux:w #1?PROYECYEZ~MACRO#2\q_nil{ - \tlist_if_empty_p:n{#1} +\cs_new_nopar:Npn \token_if_protected_macro_aux:w #1?PROYECYEZ~MACRO#2\q_nil{ + \tl_if_empty:nTF {#1} {\prg_return_true:} {\prg_return_false:} } -\def_new:Npn \token_if_long_macro_p:N #1 { - \exp_after:NN \token_if_long_macro_p_aux:w +\prg_new_conditional:Nnn \token_if_long_macro:N {p,TF,T,F} { + \exp_after:wN \token_if_long_macro_aux:w \token_to_meaning:N #1?LOXG~MACRO\q_nil } -\def_new:Npn \token_if_long_macro_p_aux:w #1?LOXG~MACRO#2\q_nil{ - \tlist_if_empty_p:n{#1} -} -\def_new:Npn \token_if_protected_long_macro_p:N #1 { - \exp_after:NN \token_if_protected_long_macro_p_aux:w - \token_to_meaning:N #1?PROYECYEZ~?LOXG~MACRO\q_nil -} -\def_new:Npn \token_if_protected_long_macro_p_aux:w #1 - ?PROYECYEZ~?LOXG~MACRO#2\q_nil{ - \tlist_if_empty_p:n{#1} -} -} -\def_test_function_new:npn {token_if_chardef:N} {\if:w \token_if_chardef_p:N} -\def_test_function_new:npn {token_if_mathchardef:N} { - \if:w \token_if_mathchardef_p:N} -\def_test_function_new:npn {token_if_long_macro:N} { - \if:w \token_if_long_macro_p:N} -\def_test_function_new:npn {token_if_protected_macro:N} { - \if:w \token_if_protected_macro_p:N} -\def_test_function_new:npn {token_if_protected_long_macro:N} { - \if:w \token_if_protected_long_macro_p:N} -\def_test_function_new:npn {token_if_dim_register:N} { - \if:w \token_if_dim_register_p:N} -\def_test_function_new:npn {token_if_skip_register:N} { - \if:w \token_if_skip_register_p:N} -\def_test_function_new:npn {token_if_int_register:N} { - \if:w \token_if_int_register_p:N} -\def_test_function_new:npn {token_if_toks_register:N} { - \if:w \token_if_toks_register_p:N} +\cs_new_nopar:Npn \token_if_long_macro_aux:w #1?LOXG~MACRO#2\q_nil{ + \tl_if_empty:nTF {#1} {\prg_return_true:} {\prg_return_false:} +} +\prg_new_conditional:Nnn \token_if_protected_long_macro:N {p,TF,T,F} { + \exp_after:wN \token_if_protected_long_macro_aux:w + \token_to_meaning:N #1?PROYECYEZ?LOXG~MACRO\q_nil +} +\cs_new_nopar:Npn \token_if_protected_long_macro_aux:w #1 + ?PROYECYEZ?LOXG~MACRO#2\q_nil{ + \tl_if_empty:nTF {#1} {\prg_return_true:} {\prg_return_false:} +} +} \group_begin: \char_set_lccode:nn {`\?}{`\:} \char_set_catcode:nn{`\M}{12} @@ -380,63 +338,63 @@ \char_set_catcode:nn{`\C}{12} \char_set_catcode:nn{`\R}{12} \char_set_catcode:nn{`\O}{12} -\tlist_to_lowercase:n{ +\tl_to_lowercase:n{ \group_end: - \def_new:Npn \token_get_prefix_arg_replacement_aux:w #1MACRO?#2->#3\q_nil#4{ + \cs_new_nopar:Npn \token_get_prefix_arg_replacement_aux:w #1MACRO?#2->#3\q_nil#4{ #4{#1}{#2}{#3} } - \def_new:Npn\token_get_prefix_spec:N #1{ + \cs_new_nopar:Npn\token_get_prefix_spec:N #1{ \token_if_macro:NTF #1{ - \exp_after:NN \token_get_prefix_arg_replacement_aux:w - \token_to_meaning:N #1\q_nil\use_arg_i:nnn + \exp_after:wN \token_get_prefix_arg_replacement_aux:w + \token_to_meaning:N #1\q_nil\use_i:nnn }{\scan_stop:} } - \def_new:Npn\token_get_arg_spec:N #1{ + \cs_new_nopar:Npn\token_get_arg_spec:N #1{ \token_if_macro:NTF #1{ - \exp_after:NN \token_get_prefix_arg_replacement_aux:w - \token_to_meaning:N #1\q_nil\use_arg_ii:nnn + \exp_after:wN \token_get_prefix_arg_replacement_aux:w + \token_to_meaning:N #1\q_nil\use_ii:nnn }{\scan_stop:} } - \def_new:Npn\token_get_replacement_spec:N #1{ + \cs_new_nopar:Npn\token_get_replacement_spec:N #1{ \token_if_macro:NTF #1{ - \exp_after:NN \token_get_prefix_arg_replacement_aux:w - \token_to_meaning:N #1\q_nil\use_arg_iii:nnn + \exp_after:wN \token_get_prefix_arg_replacement_aux:w + \token_to_meaning:N #1\q_nil\use_iii:nnn }{\scan_stop:} } } -\def_new:Npn \token_if_primitive_p:N #1{ - \if:w \token_if_cs_p:N #1\scan_stop: - \if:w \token_if_macro_p:N #1 - \c_false +\prg_new_conditional:Nnn \token_if_primitive:N {p,TF,T,F} { + \if_predicate:w \token_if_cs_p:N #1 + \if_predicate:w \token_if_macro_p:N #1 + \prg_return_false: \else: \token_if_primitive_p_aux:N #1 \fi: \else: - \if:w \token_if_active_p:N #1 - \if:w \token_if_macro_p:N #1 - \c_false + \if_predicate:w \token_if_active_char_p:N #1 + \if_predicate:w \token_if_macro_p:N #1 + \prg_return_false: \else: \token_if_primitive_p_aux:N #1 \fi: \else: - \c_false + \prg_return_false: \fi: \fi: } -\def_new:Npn \token_if_primitive_p_aux:N #1{ - \if:w \token_if_chardef_p:N #1 \c_false +\cs_new_nopar:Npn \token_if_primitive_p_aux:N #1{ + \if_predicate:w \token_if_chardef_p:N #1 \c_false_bool \else: - \if:w \token_if_mathchardef_p:N #1 \c_false + \if_predicate:w \token_if_mathchardef_p:N #1 \prg_return_false: \else: - \if:w \token_if_int_register_p:N #1 \c_false + \if_predicate:w \token_if_int_register_p:N #1 \prg_return_false: \else: - \if:w \token_if_skip_register_p:N #1 \c_false + \if_predicate:w \token_if_skip_register_p:N #1 \prg_return_false: \else: - \if:w \token_if_dim_register_p:N #1 \c_false + \if_predicate:w \token_if_dim_register_p:N #1 \prg_return_false: \else: - \if:w \token_if_toks_register_p:N #1 \c_false + \if_predicate:w \token_if_toks_register_p:N #1 \prg_return_false: \else: - \c_true + \prg_return_true: \fi: \fi: \fi: @@ -444,120 +402,161 @@ \fi: \fi: } -\def_test_function_new:npn {token_if_primitive:N} #1{ - \if:w\token_if_primitive_p:N#1} \token_new:Nn \l_peek_token {?} \token_new:Nn \g_peek_token {?} \token_new:Nn \l_peek_search_token {?} -\def_new:Npn \peek_after:NN {\tex_futurelet:D \l_peek_token } -\def_new:Npn \peek_gafter:NN { +\cs_new_nopar:Npn \peek_after:NN {\tex_futurelet:D \l_peek_token } +\cs_new_nopar:Npn \peek_gafter:NN { \pref_global:D \tex_futurelet:D \g_peek_token } -\tlp_new:Nn \l_peek_true_tlp {} -\tlp_new:Nn \l_peek_false_tlp {} -\def_new:Npn \peek_tmp:w{} -\tlp_new:Nn \l_peek_search_tlp{} -\def_long_new:Npn \peek_token_generic:NNTF #1#2#3#4{ - \let:NN \l_peek_search_token #2 - \tlp_set:Nn \l_peek_search_tlp {#2} - \tlp_set:Nx \l_peek_true_tlp {\exp_not:n{\group_align_safe_end: #3}} - \tlp_set:Nx \l_peek_false_tlp {\exp_not:n{\group_align_safe_end: #4}} +\tl_new:Nn \l_peek_true_tl {} +\tl_new:Nn \l_peek_false_tl {} +\cs_new_nopar:Npn \peek_tmp:w {} +\tl_new:Nn \l_peek_search_tl {} +\cs_new:Npn \peek_token_generic:NNTF #1#2#3#4 { + \cs_set_eq:NN \l_peek_search_token #2 + \tl_set:Nn \l_peek_search_tl {#2} + \tl_set:Nx \l_peek_true_tl {\exp_not:n{\group_align_safe_end: #3}} + \tl_set:Nx \l_peek_false_tl {\exp_not:n{\group_align_safe_end: #4}} \group_align_safe_begin: \peek_after:NN #1 } -\def_long_new:Npn \peek_token_remove_generic:NNTF #1#2#3#4{ - \let:NN \l_peek_search_token #2 - \tlp_set:Nn \l_peek_search_tlp {#2} - \tlp_set:Nx \l_peek_true_aux_tlp { \exp_not:n{ #3 } } - \tlp_set_eq:NN \l_peek_true_tlp \c_peek_true_remove_next_tlp - \tlp_set:Nx \l_peek_false_tlp {\exp_not:n{\group_align_safe_end: #4}} +\cs_new:Npn \peek_token_generic:NNT #1#2#3 { + \peek_token_generic:NNTF #1#2 {#3} {} +} +\cs_new:Npn \peek_token_generic:NNF #1#2#3 { + \peek_token_generic:NNTF #1#2 {} {#3} +} +\cs_new:Npn \peek_token_remove_generic:NNTF #1#2#3#4 { + \cs_set_eq:NN \l_peek_search_token #2 + \tl_set:Nn \l_peek_search_tl {#2} + \tl_set:Nx \l_peek_true_aux_tl { \exp_not:n{ #3 } } + \tl_set_eq:NN \l_peek_true_tl \c_peek_true_remove_next_tl + \tl_set:Nx \l_peek_false_tl {\exp_not:n{\group_align_safe_end: #4}} \group_align_safe_begin: \peek_after:NN #1 } -\tlp_new:Nn \l_peek_true_aux_tlp {} -\tlp_new:Nn \c_peek_true_remove_next_tlp {\group_align_safe_end: - \tex_afterassignment:D \l_peek_true_aux_tlp \let:NN \peek_tmp:w +\cs_new:Npn \peek_token_remove_generic:NNT #1#2#3 { + \peek_token_remove_generic:NNTF #1#2 {#3} {} +} +\cs_new:Npn \peek_token_remove_generic:NNF #1#2#3 { + \peek_token_remove_generic:NNTF #1#2 {} {#3} } -\def_new:Npn \peek_execute_branches_meaning: { - \if_meaning:NN \l_peek_token \l_peek_search_token - \exp_after:NN \l_peek_true_tlp +\tl_new:Nn \l_peek_true_aux_tl {} +\tl_new:Nn \c_peek_true_remove_next_tl {\group_align_safe_end: + \tex_afterassignment:D \l_peek_true_aux_tl \cs_set_eq:NN \peek_tmp:w +} +\cs_new_nopar:Npn \peek_execute_branches_meaning: { + \if_meaning:w \l_peek_token \l_peek_search_token + \exp_after:wN \l_peek_true_tl \else: - \exp_after:NN \l_peek_false_tlp + \exp_after:wN \l_peek_false_tl \fi: } -\def_new:Npn \peek_execute_branches_catcode: { +\cs_new_nopar:Npn \peek_execute_branches_catcode: { \if_catcode:w \exp_not:N\l_peek_token \exp_not:N\l_peek_search_token - \exp_after:NN \l_peek_true_tlp + \exp_after:wN \l_peek_true_tl \else: - \exp_after:NN \l_peek_false_tlp + \exp_after:wN \l_peek_false_tl \fi: } -\def_new:Npn \peek_execute_branches_charcode: { - \predicate:nTF { +\cs_new_nopar:Npn \peek_execute_branches_charcode: { + \bool_if:nTF { \token_if_eq_catcode_p:NN \l_peek_token \c_group_begin_token || \token_if_eq_meaning_p:NN \l_peek_token \c_space_token } - { \l_peek_false_tlp } - { \exp_after:NN \peek_execute_branches_charcode_aux:NN \l_peek_search_tlp } + { \l_peek_false_tl } + { \exp_after:wN \peek_execute_branches_charcode_aux:NN \l_peek_search_tl } } -\def_long_new:Npn \peek_execute_branches_charcode_aux:NN #1#2{ +\cs_new:Npn \peek_execute_branches_charcode_aux:NN #1#2{ \if_charcode:w \exp_not:N #1\exp_not:N#2 - \exp_after:NN \l_peek_true_tlp + \exp_after:wN \l_peek_true_tl \else: - \exp_after:NN \l_peek_false_tlp + \exp_after:wN \l_peek_false_tl \fi: #2 } -\def_new:Npn \peek_meaning:NTF { - \peek_token_generic:NNTF \peek_execute_branches_meaning: -} -\def_new:Npn \peek_meaning_ignore_spaces:NTF { - \let:NN \peek_execute_branches: \peek_execute_branches_meaning: - \peek_token_generic:NNTF \peek_ignore_spaces_execute_branches: -} -\def_new:Npn \peek_meaning_remove:NTF { - \peek_token_remove_generic:NNTF \peek_execute_branches_meaning: -} -\def_new:Npn \peek_meaning_remove_ignore_spaces:NTF { - \let:NN \peek_execute_branches: \peek_execute_branches_meaning: - \peek_token_remove_generic:NNTF \peek_ignore_spaces_execute_branches: -} -\def_new:Npn \peek_catcode:NTF { - \peek_token_generic:NNTF \peek_execute_branches_catcode: -} -\def_new:Npn \peek_catcode_ignore_spaces:NTF { - \let:NN \peek_execute_branches: \peek_execute_branches_catcode: - \peek_token_generic:NNTF \peek_ignore_spaces_execute_branches: -} -\def_new:Npn \peek_catcode_remove:NTF { - \peek_token_remove_generic:NNTF \peek_execute_branches_catcode: -} -\def_new:Npn \peek_catcode_remove_ignore_spaces:NTF { - \let:NN \peek_execute_branches: \peek_execute_branches_catcode: - \peek_token_remove_generic:NNTF \peek_ignore_spaces_execute_branches: -} -\def_new:Npn \peek_charcode:NTF { - \peek_token_generic:NNTF \peek_execute_branches_charcode: -} -\def_new:Npn \peek_charcode_ignore_spaces:NTF { - \let:NN \peek_execute_branches: \peek_execute_branches_charcode: - \peek_token_generic:NNTF \peek_ignore_spaces_execute_branches: -} -\def_new:Npn \peek_charcode_remove:NTF { - \peek_token_remove_generic:NNTF \peek_execute_branches_charcode: -} - -\def_new:Npn \peek_charcode_remove_ignore_spaces:NTF { - \let:NN \peek_execute_branches: \peek_execute_branches_charcode: - \peek_token_remove_generic:NNTF \peek_ignore_spaces_execute_branches: +\cs_new_nopar:Npn \peek_def_aux:nnnn #1#2#3#4 { + \peek_def_aux_ii:nnnnn {#1} {#2} {#3} {#4} { TF } + \peek_def_aux_ii:nnnnn {#1} {#2} {#3} {#4} { T } + \peek_def_aux_ii:nnnnn {#1} {#2} {#3} {#4} { F } +} +\cs_new_nopar:Npn \peek_def_aux_ii:nnnnn #1#2#3#4#5 { + \cs_new_nopar:cpx { #1 #5 } { + \tl_if_empty:nF {#2} { + \exp_not:n { \cs_set_eq:NN \peek_execute_branches: #2 } + } + \exp_not:c { #3 #5 } + \exp_not:n { #4 } + } } -\def_new:Npn \peek_ignore_spaces_aux: { +\peek_def_aux:nnnn + { peek_meaning:N } + {} + { peek_token_generic:NN } + { \peek_execute_branches_meaning: } +\peek_def_aux:nnnn + { peek_meaning_ignore_spaces:N } + { \peek_execute_branches_meaning: } + { peek_token_generic:NN } + { \peek_ignore_spaces_execute_branches: } +\peek_def_aux:nnnn + { peek_meaning_remove:N } + {} + { peek_token_remove_generic:NN } + { \peek_execute_branches_meaning: } +\peek_def_aux:nnnn + { peek_meaning_remove_ignore_spaces:N } + { \peek_execute_branches_meaning: } + { peek_token_remove_generic:NN } + { \peek_ignore_spaces_execute_branches: } +\peek_def_aux:nnnn + { peek_catcode:N } + {} + { peek_token_generic:NN } + { \peek_execute_branches_catcode: } +\peek_def_aux:nnnn + { peek_catcode_ignore_spaces:N } + { \peek_execute_branches_catcode: } + { peek_token_generic:NN } + { \peek_ignore_spaces_execute_branches: } +\peek_def_aux:nnnn + { peek_catcode_remove:N } + {} + { peek_token_remove_generic:NN } + { \peek_execute_branches_catcode: } +\peek_def_aux:nnnn + { peek_catcode_remove_ignore_spaces:N } + { \peek_execute_branches_catcode: } + { peek_token_remove_generic:NN } + { \peek_ignore_spaces_execute_branches: } +\peek_def_aux:nnnn + { peek_charcode:N } + {} + { peek_token_generic:NN } + { \peek_execute_branches_charcode: } +\peek_def_aux:nnnn + { peek_charcode_ignore_spaces:N } + { \peek_execute_branches_charcode: } + { peek_token_generic:NN } + { \peek_ignore_spaces_execute_branches: } +\peek_def_aux:nnnn + { peek_charcode_remove:N } + {} + { peek_token_remove_generic:NN } + { \peek_execute_branches_charcode: } +\peek_def_aux:nnnn + { peek_charcode_remove_ignore_spaces:N } + { \peek_execute_branches_charcode: } + { peek_token_remove_generic:NN } + { \peek_ignore_spaces_execute_branches:} +\cs_new_nopar:Npn \peek_ignore_spaces_aux: { \peek_after:NN \peek_ignore_spaces_execute_branches: } -\def_new:Npn \peek_ignore_spaces_execute_branches: { +\cs_new_nopar:Npn \peek_ignore_spaces_execute_branches: { \token_if_eq_meaning:NNTF \l_peek_token \c_space_token { \tex_afterassignment:D \peek_ignore_spaces_aux: - \let:NN \peek_tmp:w + \cs_set_eq:NN \peek_tmp:w } \peek_execute_branches: } |