summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3token.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3token.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3token.dtx51
1 files changed, 50 insertions, 1 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3token.dtx b/Master/texmf-dist/source/latex/l3kernel/l3token.dtx
index 153ca92f7e0..3aeca13b29d 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3token.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3token.dtx
@@ -35,7 +35,7 @@
%
%<*driver|package>
\RequirePackage{l3names}
-\GetIdInfo$Id: l3token.dtx 2491 2011-07-02 11:49:37Z joseph $
+\GetIdInfo$Id: l3token.dtx 2579 2011-08-14 16:22:30Z bruno $
{L3 Experimental token manipulation}
%</driver|package>
%<*driver>
@@ -1098,6 +1098,25 @@
% definition is global.
% \end{function}
%
+% \begin{function}[TF]{\peek_N_type:}
+% \begin{syntax}
+% \cs{peek_N_type:TF} \Arg{true code} \Arg{false code}
+% \end{syntax}
+% Tests if the next \meta{token} in the input stream can be safely
+% grabbed as an \texttt{N}-type argument. The test will be \meta{false}
+% if the next \meta{token} is either an explicit or implicit
+% begin-group or end-group token (with any character code), or
+% an explicit or implicit space character (with character code $32$
+% and category code $10$), and \meta{true} in all other cases.
+% Note that a \meta{true} result ensures that the next \meta{token} is
+% a valid \texttt{N}-type argument. However, if the next \meta{token}
+% is for instance \cs{c_space_token}, the test will take the
+% \meta{false} branch, even though the next \meta{token} is in fact
+% a valid \texttt{N}-type argument. The \meta{token} will be left
+% in the input stream after the \meta{true code} or \meta{false code}
+% (as appropriate to the result of the test).
+% \end{function}
+%
% \end{documentation}
%
% \begin{implementation}
@@ -2283,6 +2302,36 @@
% \end{macro}
% \end{macro}
%
+% \begin{macro}[TF]{\peek_N_type:}
+% \begin{macro}{\peek_execute_branches_N_type:}
+% The next token is normal if it is neither a begin-group token,
+% nor an end-group token, nor a charcode-$32$ space token.
+% Note that implicit begin-group tokens, end-group tokens, and
+% spaces are also recognized as non-\texttt{N}-type.
+% Here, there is no \meta{search token}, so we feed a dummy
+% \cs{scan_stop:} to the \cs{peek_token_generic::NN} functions.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \peek_execute_branches_N_type:
+ {
+ \bool_if:nTF
+ {
+ \token_if_eq_catcode_p:NN \l_peek_token \c_group_begin_token ||
+ \token_if_eq_catcode_p:NN \l_peek_token \c_group_end_token ||
+ \token_if_eq_meaning_p:NN \l_peek_token \c_space_token
+ }
+ { \peek_false:w }
+ { \peek_true:w }
+ }
+\cs_new_protected_nopar:Npn \peek_N_type:TF
+ { \peek_token_generic:NNTF \peek_execute_branches_N_type: \scan_stop: }
+\cs_new_protected_nopar:Npn \peek_N_type:T
+ { \peek_token_generic:NNT \peek_execute_branches_N_type: \scan_stop: }
+\cs_new_protected_nopar:Npn \peek_N_type:F
+ { \peek_token_generic:NNF \peek_execute_branches_N_type: \scan_stop: }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \subsection{Deprecated functions}
%
% Deprecated on 2011-05-27, for removal by 2011-08-31.