diff options
author | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2008-07-29 11:23:34 +0000 |
---|---|---|
committer | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2008-07-29 11:23:34 +0000 |
commit | ef285e6a49a93af098150d0b3125a34d3477ba55 (patch) | |
tree | 124a55595390d358e0cda8ae26f78e9a263e9a21 /Master/texmf-dist/source/latex | |
parent | e7477f362711cc9d05dfa1ee71301fb34cce2d94 (diff) |
expl3 update (2008/06/20)
git-svn-id: svn://tug.org/texlive/trunk@9869 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex')
32 files changed, 4059 insertions, 1249 deletions
diff --git a/Master/texmf-dist/source/latex/expl3/expl3.tex b/Master/texmf-dist/source/latex/expl3/expl3.tex new file mode 100644 index 00000000000..8d9e1880667 --- /dev/null +++ b/Master/texmf-dist/source/latex/expl3/expl3.tex @@ -0,0 +1,753 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% based on version for the TUGboat proceedings +% Copyright 1997--98 David Carlisle, Chris Rowley, Frank Mittelbach +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% $Id: expl3.tex 246 2004-11-11 08:20:37Z mittelba $ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\documentclass{article} + +\usepackage{shortvrb} +\MakeShortVerb{\|} + +% A couple of \provide.. so document runs with +% both ltugproc and ltxguide classes +% +\providecommand \m [1]{$\langle$\textit{#1}$\rangle$} +%\providecommand \netaddress {\date} +\providecommand \acro [1]{\textsc{\MakeLowercase{#1}}} +\providecommand \ie {i.e.,~} +\providecommand \eg {e.g.,~} + +\hyphenation{para-meters para-meter} +% I have found at least 3 other hyphenations of this in various refs, +% but I did also find this, which is my personal favourite ---chris + +\hyphenation{ignore ignored ignores} + +\begin{document} + +\title{The \LaTeX3 Programming Language---\\ +a proposed system for \TeX\ macro programming} + + +\author{\copyright~David Carlisle, Chris Rowley and\\ Frank Mittelbach\\ +\LaTeX3 project\\ +\texttt{latex-l@urz.uni-heidelberg.de}} + + +\maketitle + +\begin{abstract} + +This paper gives s brief introduction to a new set of programming +conventions that have been designed to meet the requirements of +implementing large scale \TeX\ macro programming projects such as +\LaTeX. + +The main features of the system described are: +\begin{itemize} +\item classification of the macros (or, in \LaTeX{} terminology, + commands) into \LaTeX{} functions and \LaTeX{} parameters, and also + into modules containing related commands; +\item a systematic naming scheme based on these + classifications; +\item a simple mechanism for controlling the expansion of a function's +arguments. +\end{itemize} +A system such as this is being used experimentally as the basis for +\TeX{} programming within the \LaTeX3 project. +Note that the language is not intended for either +document mark-up or style specification. + +This paper is based on a talk given by David Carlisle in San +Francisco, July 1997, but it describes the work of several people: +principally + Frank Mittelbach and + Denys Duchier, +together with + Johannes Braams, + David Carlisle, + Michael Downes, + Alan Jeffrey, + Chris Rowley and + Rainer Sch\"opf. +\end{abstract} + +\vspace{4pt} + + +\section{Introduction} + +This paper describes the conventions for a \TeX-based programming +language which is intended to provide a more consistent and rational +environment for the construction of large scale systems, such as +\LaTeX, using \TeX{} macros. + +Variants of this language have been in use by The \LaTeX3 Project Team +since around 1990 but the syntax specification to be outlined here +should \emph{not} be considered final. This is an experimental +language thus many aspects, such as the syntax conventions and naming +schemes, may (and probably will) change as more experience is gained +with using the language in practice. + +The next section shows where this language fits into a complete +\TeX-based document processing system. We then describe the major +features of the syntactic structure of command names, including the +argument specification syntax used in function names. + +The practical ideas behind this argument syntax will be explained, +together with the semantics of the expansion control mechanism and the +interface used to define variant forms of functions. The paper also +discusses some advantages of the syntax for parameter names. + +As we shall demonstrate, the use of a structured naming scheme and of +variant forms for functions greatly improves the readability of the +code and hence also its reliability. Moreover, experience has shown +that the longer command names which result from the new syntax do not +make the process of \emph{writing} code significantly harder +(especially when using a reasonably intelligent editor). + +The final section gives some details of our plans to distribute parts +of this system during the next year. +More general information concerning the work of the \LaTeX3 Project +can be found in~\cite{tub:MR98-1}. + + +\section{Languages and interfaces} +\label{sec:langs} + +It is possible to identify several distinct languages related to the +various interfaces that are needed in a \TeX-based document processing +system. This section looks at those we consider most important for +the \LaTeX3 system. + +\begin{description} +\item[Document mark-up] This comprises those commands (often called tags) + that are to embedded in the document (the |.tex| file). + + It is generally accepted that such mark-up should be essentially + \emph{declarative}. + It may be traditional \TeX-based mark-up such as + \LaTeXe, as described in~\cite{A-W:LLa94} and~\cite{A-W:GMS94}, + or a mark-up language defined via \acro{SGML} or \acro{XML}. + + One problem with more traditional \TeX\ coding conventions (as + described in~\cite{A-W:K-TB}) is that the names and syntax of \TeX's + primitive formatting commands are ingeniously designed to be + `natural' when used directly by the author as document mark-up or in + macros. Ironically, the ubiquity (and widely recognised + superiority) of logical mark-up has meant that such explicit + formatting commands are almost never needed in documents or in + author-defined macros. Thus they are used almost exclusively by + \TeX{} programmers to define higher-level commands; and their + idiosyncratic syntax is not at all popular with this community. + Moreover, many of them have names that could be very useful as + document mark-up tags were they not pre-empted as primitives (\eg + |\box| or |\special|). + +\item[Designer interface] This relates a (human) typographic + designer's specification for a document to a program that `formats + the document'. It should ideally use a declarative language that + facilitates expression of the relationship and spacing rules specified + for the layout of the various document elements. + + This language is not embedded in document text and it will be very + different in form to the document mark-up language. For + \acro{SGML}-based systems the \acro{DSSSL} language may come to play + this role. For \LaTeX, this level was almost completely missing + from \LaTeX2.09; \LaTeXe\ made some improvements in this area but it + is still the case that implementing a design specification in + \LaTeX\ requires far more `low-level' coding than is acceptable. +\item[Programmer interface] + This language is the implementation + language within which the basic typesetting functionality is + implemented, building upon the primitives of \TeX\ (or a + successor program). + It may also be used to implement the previous + two languages `within' \TeX, as in the current \LaTeX\ system. +\end{description} + +Only the last of these three interfaces is covered by this paper, +which describes a system aimed at providing a suitable basis for +coding large scale projects in \TeX{} (but this should not preclude its +use for smaller projects). Its main distinguishing features are +summarised here. + +\begin{itemize} +\item A consistent naming scheme for all commands, including \TeX\ + primitives. +\item The classification of commands as \LaTeX{} functions or \LaTeX{} + parameters, and also their division into modules according to their + functionality. +\item A simple mechanism for controlling argument expansion. +\item Provision of a set of core \LaTeX{} functions that is sufficient + for handling programming constructs such as queues, sets, + stacks, property lists. +\item A \TeX{} programming environment in which, for example, all + white space is ignored. +\end{itemize} + +\section{The naming scheme} +\label{sec:scheme} + +The naming conventions for this programming language distinguish +between \textit{functions} and \textit{parameters}. Functions can have +arguments and they are executed. Parameters can be assigned values +and they are used in arguments to functions; they are not directly +executed but are manipulated by mutator and accessor functions. +Functions and parameters with a related functionality (for example +accessing counters, or manipulating token-lists, etc.)\ are collected +together into a +\textit{module}. + + +Note that all these terms are only \LaTeX{} terminology and are not, +for example, intended to indicate that the commands have these +properties when considered in the context of basic \TeX{} or in any +more general programming context. + + +\subsection{Examples} +\label{sec:ex} + +Before giving the details of the naming scheme, here are a few typical +examples to indicate the flavour of the scheme; first some parameter +names. +\begin{quote} +|\l_tmpa_box| is a local parameter (hence the~|l_| prefix) +corresponding to a box register.\\ +|\g_tmpa_int| is a global parameter (hence the~|g_| prefix) +corresponding to an integer register (\ie a \TeX{} count register).\\ +|\c_empty_toks| +is the constant~(|c_|) token register parameter that is for ever empty. +\end{quote} +Now here is an example of a typical function name. + +|\seq_push:Nn| is the function which puts the token list specified by +its second argument onto the stack specified by its first argument. +The different natures of the two arguments are indicated by the~|:Nn| +suffix. The first argument must be a single token which `names' +the stack parameter: such single-token arguments are denoted~|N|. +The second argument is a normal \TeX\ `undelimited argument', which +may either be a single token or a balanced, brace-delimited token +list (which we shall here call a \textit{braced token list}): the~|n| +denotes such a `normal' argument form. + +|\seq_push:cn| would be similar to the above, but in this case the~|c| +means that the stack-name is specified in the first argument by a +token list that expands, using |\csname...|, to a control sequence that +is the \emph{name} of the stack parameter. + +\noindent +The names of these two functions also indicate that they are in the +module called |seq|. + + +\subsection{Formal syntax of the conventions} +\label{sec:namesyn} + +We shall now look in more detail at the syntax of these names.\\ +The syntax of parameter names is as follows: + \begin{quote} + |\|\m{access}|_|\m{module}|_|\m{description}|_|\m{type} + \end{quote} +The syntax of function names is as follows: + \begin{quote} + |\|\m{module}|_|\m{description}|:|\m{arg-spec} + \end{quote} + + +\subsection{Modules and descriptions} +\label{sec:modules} + +The syntax of all names contains +\begin{quote} + \m{module} and \m{description}: +\end{quote} +these both give information about the command. + +A \textit{module} is a collection of +closely related functions and parameters. +Typical module names include~|int| for integer parameters +and related functions,~|seq| for sequences and~|box| for boxes. + +Packages providing new programming functionality will add new modules +as needed; the programmer can choose any unused name, consisting +of letters only, for a module. + +The \textit{description} gives more detailed information about the +function or parameter, and provides a unique name for it. It should +consist of letters and, possibly,~|_|~characters. + +\subsection{Parameters: access and type} +\label{sec:parms} + +The \m{access} part of the name describes how the parameter can be +accessed. Parameters are primarily classified as local, global or +constant (there are further, more technical, classes). This +\textit{access} type appears as a code at the beginning of the name; +the codes used include: +\begin{itemize} +\item[\bf c] + constants (global parameters whose value should not be changed); +\item[\bf g] + parameters whose value should only be set globally; +\item[\bf l] + parameters whose value should only be set locally. +\end{itemize} + +The \m{type} will normally (except when introducing a new data-type) +be in the list of available \textit{data-types}; these include the +primitive \TeX\ data-types, such as the various registers, but to +these will be added data-types built within the \LaTeX{} programming +system. + +Here are some typical data-type names: +\begin{description} +\item[int] integer-valued count register; +\item[toks] token register; +\item[box] box register; +\item[fint] `Fake-integer': (or fake-counter) a data type created to + avoid problems with the limited number of available count registers + in (standard) \TeX; +\item[seq] `sequence': a data-type used to implement lists + (with access at both ends) and stacks; +\item[plist] property list +\end{description} +When the \m{type} and \m{module} are identical (as often happens in +the more basic modules) the \m{module} part is often omitted for +aesthetic reasons. + + +\subsection{Functions: argument specifications} +\label{sec:args} + + Function names end with an \m{arg-spec} after a colon. This + gives an indication of the types of argument that a function takes, + and provides a convenient method of naming similar functions that + differ only in their argument forms (see the next section for + examples). + + The \m{arg-spec} consists of a (possibly empty) list of characters, + each denoting one argument of the function. It is important to + understand that `argument' here refers to the effective argument of + the \LaTeX{} function, not to an argument at the \TeX-level. Indeed, + the top level \TeX\ macro that has this name typically has no + arguments. This is an extension of the existing \LaTeX\ convention + where one says that |\section| has an optional argument and a + mandatory argument, whereas the \TeX\ macro |\section| actually has + zero parameters at the \TeX\ level, it merely calls an internal \LaTeX\ + command which in turn calls others that look ahead for star forms and + optional arguments. + +The list of possible argument specifiers includes the following. +\begin{itemize} +\item[\bf n] Unexpanded token or braced token list.\\ + This is a standard \TeX\ undelimited macro argument. +\item[\bf o] One-level-expanded token or braced token list.\\ + This means that the argument is expanded one level, as by + |\expandafter|, and the expansion is passed to the function as a braced + token list. Note that if the original argument is a braced + token list then only the first token in that list is expanded. +\item[\bf x] Fully-expanded token or braced token list.\\ + This means that the argument is expanded as in the replacement text of + an~|\edef|, and the expansion is passed to the function as a + braced token list. +\item[\bf c] Character string used as a command name.\\ The argument (a + token or braced token list) must, when fully expanded, produce a + sequence of characters which is then used to construct a command + name (via~|\csname|, |\endcsname|). This command name is the single + token that is passed to the function as the argument. +\item[\bf N] Single token (unlike~|n|, the argument must \emph{not} be + surrounded by braces).\\ + A typical example of a command taking an~|N| + argument is~|\def|, in which the command being defined must be + unbraced. + \item[\bf O] One-level-expanded single token (unbraced).\\ + As for~|o|, the one-level expansion is passed (as a + braced token list) to the function. + \item[\bf X] Fully-expanded single token (unbraced).\\ + As for~|x|, the full expansion is passed (as a + braced token list) to the function. + \item[\bf C] Character string used as a command name + then one-level expanded.\\ + The form of the argument is exactly as for~|c|, but the + resulting token is then expanded one level (as for~|O|), and + the expansion is passed to the function as a braced token list. + \item[\bf p] Primitive \TeX\ parameter specification.\\ + This can be something simple like~|#1#2#3|, but may use arbitrary + delimited argument syntax such as: |#1,#2\q_stop#3|. + \item[\bf T,F\hspace{-10pt}] + \hspace{10pt}% + These are special cases of~|n| arguments, used for the + true and false code in conditional commands. +\end{itemize} +There are two other specifiers with more general meanings: +\begin{itemize} +\item[\bf D] This means: \textbf{Do not use}. This special case is used + for \TeX\ primitives and other commands that are provided for use + only while bootstrapping the \LaTeX\ kernel. If the \TeX\ primitive + needs to be used in other contexts it will be given an alternative, + more appropriate, name with a useful argument specification. The + argument syntax of these is often weird, in the sense described next. + \item[\bf w] This means that the argument syntax is `weird' in that it + does not follow any standard rule. It is used for functions with + arguments that take non standard forms: examples are \TeX-level + delimited arguments and the boolean tests needed after certain + primitive |\if|\ldots\ commands. +\end{itemize} + + +\section{Expansion control} +\label{sec:exp} + +\subsection{Simpler means better} +\label{sec;simpler} + +Anyone who programs in \TeX\ is frustratingly familiar with the +problem of arranging that arguments to functions are suitably expanded +before the function is called. To illustrate how expansion control +can bring instant relief to this problem we shall consider two +examples copied from \texttt{latex.ltx}. + +\begin{verbatim} + \global + \expandafter + \expandafter + \expandafter + \let + \expandafter + \reserved@a + \csname \curr@fontshape \endcsname +\end{verbatim} +This first piece of code is in essence simply a +global |\let|. However, the token to be defined is obtained by +expanding |\reserved@a| one level; and, worse, the token to which it +is to be let is obtained by fully expanding |\curr@fontshape| and then +using the characters produced by that expansion to construct a command +name. The result is a mess of interwoven |\expandafter| and~|\csname| +beloved of all \TeX\ programmers, and the code is essentially +unreadable. + +Using the conventions and functionality outlined here, the task would +be achieved with code such as this: +\begin{verbatim} + \glet:Oc \g_reserved_a_tlp + \l_current_font_shape_tlp +\end{verbatim} +The command |\glet:Oc| is a global~|\let| that expands its +first argument once, and generates a command name out of its second +argument, before making the definition. This produces code that +is far more readable and more likely to be correct first time. + +Here is the second example. +\begin{verbatim} + \expandafter + \in@ + \csname sym#3% + \expandafter + \endcsname + \expandafter + {% + \group@list}% +\end{verbatim} +This piece of code is part of the definition of another function. It +first produces two things: a token list, by expanding |\group@list| once; +and a token whose name comes from~`|sym#3|'. Then the function~|\in@| +is called and this tests if its first argument occurs in the token list +of its second argument. + +Again we can improve enormously on the code. First we shall rename +the function~|\in@| according to our conventions. A function such as +this but taking two normal `\texttt{n}' arguments might reasonably be +named |\seq_test_in:nn|; thus the variant function we need will be +defined with the appropriate argument types and its name will be +|\seq_test_in:cO|. Now this code fragment will be simply: +\begin{verbatim} + \seq_test_in:cO {sym#3} \l_group_seq +\end{verbatim} +Note that, in addition to the lack of |\expandafter|, the space after +the~|}| will be silently ignored since all white space is ignored in +this programming environment. + + +\subsection{New functions from old} +\label{sec:newfunc} + +For many common functions the \LaTeX3 kernel will provide variants +with a range of argument forms, and similarly it is expected that +extension packages providing new functions will make them available in +the all the commonly needed forms. + +However, there will be occasions where it is necessary to construct a +new such variant form; therefore the expansion module provides a +straightforward mechanism for the creation of functions with any +required argument type, starting from a function that takes `normal' +\TeX\ undelimited arguments. + +To illustrate this let us suppose you have a `base function' +|\demo_cmd:nnn| that takes three normal arguments, and that you need +to construct the variant |\demo_cmd:cnx|, for which the first argument +is used to construct the \emph{name} of a command, whilst the third +argument must be fully expanded before being passed to +|\demo_cmd:nnn|. +To produce the variant form from the base form, simply use this: +\begin{verbatim} + \exp_def_form:nnn {demo_cmd} {nnn} {cnx} +\end{verbatim} +This defines the variant form so that you can then write, for example: +\begin{verbatim} + \demo_cmd:cnx {abc} {pq} {\rst \xyz } +\end{verbatim} +rather than \ldots\ well, something like this! +\begin{verbatim} + \def \tempa {{pq}}% + \edef \tempb {\rst \xyz}% + \expandafter + \demo@cmd + \csname abc% + \expandafter + \expandafter + \expandafter + \endcsname + \expandafter + \tempa + \expandafter + {% + \tempb + }% +\end{verbatim} + +Another example: you may wish to declare a function +|\demo_cmd_b:xcxcx|, a variant of an existing function +|\demo_cmd_b:nnnnn|, that fully +expands arguments 1,~3 and~5, and produces commands to pass as +arguments 2 and~4 using~|\csname|. +The definition you need is simply +\begin{verbatim} + \exp_def_form:nnn + {demo_cmd_b} {nnnnn} {xcxcx} +\end{verbatim} + +This extension mechanism is written so that if the same new form of +some existing command is implemented by two extension packages then the +two definitions will be identical and thus no conflict will occur. + + +\section{Parameter assignments and accessor functions} +\label{sec:access} + +\subsection{Checking assignments} +\label{sec:check} + +One of the advantages of having a consistent scheme is that the system +can provide more extensive error-checking and debugging facilities. +For example, an accessor function that makes a \emph{global} +assignment of a value to a parameter can check that it is not passed +the name of a \emph{local} parameter as that argument: it does this by +checking that the name starts with~|\g_|. + +Such checking is probably too slow for normal use, but the code can +have hooks built in that allow a format to be made in which all +functions perform this kind of check. + +A typical section of the source% +\footnote{This code uses the \textsf{docstrip} +system described in~\cite{A-W:GMS94}, Section~14.3.} +for such code might look like this +(recall that all white space is ignored): + +\begin{verbatim} + %<*!check> + \let_new:NN + \toks_gset:Nn \tex_global:D + %</!check> + %<*check> + \def_new:Npn + \toks_gset:Nn #1 + { + \chk_global:N #1 + \tex_global:D #1 + } + %</check> +\end{verbatim} +In the above code the function |\toks_gset:Nn| takes a single +token~(|N|) specifying a token register, and globally sets it to the +value passed in the second argument. + +A typical use of it would be: +\begin{verbatim} + \toks_gset \g_xxx_toks {<some value>} +\end{verbatim} +In the normal definition, |\toks_gset| can be simply~|\let| +to~|\global| because the primitive \TeX{} token register does not +require any explicit assignment function: +this is done by the |%<*!check>| code above. + +The alternative definition first checks that the argument +passed as~|#1| is the name of a global parameter and raises an error +if it is not. It does this by taking apart the command name passed +as~|#1| and checking that it starts~|\g_|. + +\subsection{Consistency} +\label{sec:cons} + +The primitive \TeX\ syntax for register assignments has a very minimal +syntax and, apart from box functions, there are no explicit functions +for assigning values to these registers. + +This makes it impossible to implement alternative data-types with a +syntax that is both consistent and at all similar to the syntax for +the primitives; moreover, it encourages a coding style that is very +error prone. + +As in the |\toks_gset:Nn| example given above, all \LaTeX\ data-types +are provided with explicit functions for assignment and for use, even +when these have essentially empty definitions. This allows for better +error-checking as described above; it also allows the construction of +further data-types with a similar interface, even when the +implementation of the associated functions is very complex. + +For example, the `fake-counter' (\texttt{fint}) data-type mentioned +above will appear at the \LaTeX{} programming level to be exactly like +the data-type based on primitive count registers; however, internally +it makes no use of count registers. Typical functions in this module +are illustrated here. + +\begin{verbatim} +\fint_new:N \l_tmpa_fint +\end{verbatim} +This declares the local parameter |\l_example_fint| as a fake-counter. + +\begin{verbatim} +\fint_add:Nn \l_example_fint \c_thirty_two +\end{verbatim} +This increments the value of this fake-counter by 32. + + +\section{The experimental distribution} +\label{sec:dist} + +The initial implementations of a \LaTeX\ programming language using +this kind of syntax remain unreleased (and not completely functional); +they partly pre-date \LaTeXe! The planned distribution will provide a +subset of the functionality of those implementations, in the form of +packages to be used on top of \LaTeXe. + +The intention is to allow experienced \TeX\ programmers to experiment +with the system and to comment on the interface. This means that +\textbf{\itshape the interface will change}. No part of this system, +including the name of anything, should be relied upon as being +available in a later release. Please do \emph{experiment} with these +packages, but do \emph{not} use them for code that you expect to keep +unchanged over a long period. + +In view of the intended experimental use for this distribution we +shall, in the first instance, produce only a few modules for use with +\LaTeXe. These will set up the conventions and the basic functionality +of, for example, the expansion mechanism; they will also implement some +of the basic programming constructs, such as token-lists and sequences. +They are intended only to give a flavour of the code: the full \LaTeX3 +kernel will provide a very rich set of programming constructs so that +packages can efficiently share code, in contrast with the situation in +the current \LaTeX\ where every large package must implement its own +version of queues, stacks, etc., as necessary. + +In the first release of this experimental system at least the +following modules will be distributed. +\begin{description} +\item[l3names] This sets up the basic naming scheme and renames all +the \TeX\ primitives. If it is loaded with the option +\texttt{[removeoldnames]} then the old primitive names such as~|\box| +become \emph{undefined} and are thus available for user +definition. Caution: use of this option will certainly break existing +\TeX\ code! + +\item [l3basics] +This contains the basic definition modules used +by the other packages. + +\item[l3chk] A module that provides functionality comparable to +\LaTeX's |\newcommand| and |\renewcommand|, and also the extra level of +checking described above in section~\ref{sec:check}. + +\item[l3tlp] +This implements a basic data-type, called a \textit{token-list +pointer}, used for storing named token lists: these are essentially +\TeX{} macros with no arguments. + +\item[l3expan] This is the argument expansion module discussed above. + +\item[l3quark] A `quark' is a command that is defined to expand to +itself! Therefore they must never be expanded as this will generate +infinite recursion; they do however have many uses, \eg as +special markers and delimiters within code. + +\item[l3seq] +This implements data-types such as queues and stacks. + +\item[l3prop] +This implements the data-type for `property lists' that are used, in +particular, for storing key/value pairs. + +\item[l3int] +This implements the integer and `fake integer' data-types. + +\item[l3toks] +A data-type corresponding to \TeX's primitive token registers. + +\item[l3io] +A module providing low level input and output functions. + +\item[l3precom] +A `pre-compilation' module that provides functions dealing with pointer +creation and handling, and using external files to record the state of the current +definitions. +\end{description} +This distribution will also contain the \LaTeX\ source for the latest +version of this document, a docstrip install file and three small test +files. + + +In later releases we plan to add further modules and a full-fledged +example of the use of the new language: a proto-type implementation +for the ideas described in the article `Language Information in +Structured Documents: A Model for Mark-up and +Rendering'~\cite{tub:MR98-2}. + +\begin{thebibliography}{1} + +\bibitem{A-W:K-TB} +Donald E Knuth +\newblock {\em The {\TeX}book}. +\newblock Addison-Wesley, Reading, Massachusetts, 1984. + +\bibitem{A-W:GMS94} +Goossens, Mittelbach and Samarin. +\newblock {\em The {\LaTeX} Companion}. +\newblock Addison-Wesley, Reading, Massachusetts, 1994. + +\bibitem{A-W:LLa94} +Leslie Lamport. +\newblock {\em {\LaTeX:} A Document Preparation System}. +\newblock Addison-Wesley, Reading, Massachusetts, second edition, 1994. + +\bibitem{tub:MR98-1} +Frank Mittelbach and Chris Rowley. +\newblock The {\LaTeX3} Project. +\newblock {\em {TUG}boat}, ????? ??? 1998. + +\bibitem{tub:MR98-2} +Frank Mittelbach and Chris Rowley. +\newblock Language Information in +Structured Documents: A Model for Mark-up and Rendering. +\newblock {\em {TUG}boat}, ????? ??? 1998. + +\end{thebibliography} + +\end{document} + + + + + diff --git a/Master/texmf-dist/source/latex/expl3/l32eproc.tex b/Master/texmf-dist/source/latex/expl3/l32eproc.tex new file mode 100644 index 00000000000..d560c0c2338 --- /dev/null +++ b/Master/texmf-dist/source/latex/expl3/l32eproc.tex @@ -0,0 +1,523 @@ +\documentclass + {ltugproc} +% {ltxguide} + +\usepackage{shortvrb} +\MakeShortVerb{\|} +\setlength\hfuzz{10pt} + +% A couple of \provide.. so document runs with +% both ltugproc and ltxguide classes +% +\providecommand\m[1]{$\langle$\textit{#1}$\rangle$} +\providecommand\netaddress{\date} +\providecommand\acro[1]{\textsc{\MakeLowercase{#1}}} + +\begin{document} +\title{The \LaTeX3 Programming Language\\ +A syntax proposal for \TeX\ macro programming} + + +\author{The \LaTeX3 Project} +\netaddress{latex-l@urz.uni-heidelberg.de} + + + +\begin{abstract} +This paper proposes a new set of programming conventions suitable for +implementing large scale \TeX\ programming projects such as \LaTeX. +(This syntax is not suitable for either document +markup, or as a style specification language.) + +The main features include a systematic naming scheme for all commands, +and a systematic mechanism for controlling the expansion of arguments +to functions. + +The syntax is under consideration as a basis for programming within +the \LaTeX3 project. + +This paper is based on a talk given by David +Carlisle but describes the work of several people, principally: + Frank Mittelbach, + Denys Duchier, + Rainer Sch\"opf, + Chris Rowley, + Michael Downes, + Johannes Braams, + David Carlisle and + Alan Jeffrey. +\end{abstract} + +\maketitle + + +\section{Introduction} +This paper describes a \TeX\ based language which is intended to +provide a more consistent and rational programming environment for the +construction of large scale \TeX\ macro projects such as \LaTeX. + +Variants of this language have been in use within the \LaTeX3 project +since around 1990 but the syntax specification to be outlined here +should \emph{not} be considered final. This is an experimental +language, and the syntax and command names may (and probably will) +change as more experience is gained with using the language in +practice. + +\section{Programming Interface levels for \LaTeX} + +One may identify several distinct languages that one might want to see +in a \TeX\ based system. This paper will \emph{only} be concerned with +the last of these three. + +\begin{description} +\item[Document Markup] This language consists of the commands that are + to be embedded in the document instance. It is generally accepted + that such a language should be essentially \emph{declarative}. + One might consider a traditional \TeX\ based markup such as the + \LaTeX2 markup as described in \cite{A-W:LLa94}, or alternatively one + might consider an \acro{SGML} based markup. + + One problem with more traditional \TeX\ coding conventions is that + the command names and syntax of the \TeX\ primitives are designed to + have a `natural' syntax when used directly by the author as document + markup. In fact one almost never uses the primitives in this + way, rather they are just used to define higher level commands. + +\item[Designer's Interface] In order to easily translate a (human) + designer's design specification into a program that accepts the + document instance one would ideally like to have a declarative + language that allows the relationships and spacing rules of the + various document elements to be easily expressed. As this language + is not embedded within the document text, it may take a rather + different form to the markup language described above. For + \acro{SGML} based systems one may consider the \acro{DSSSL} language + as playing this role. For \LaTeX2, then this level was essentially + missing in \LaTeX2.09. \LaTeXe\ made some improvements in this area + but it is still the case that implementing a design specification in + \LaTeX\ requires more `low level' coding than would be desired. +\item[Programmer's Interface] + This language, the subject of this paper, is the implementation + language in which the basic typesetting functionality is + implemented, building upon the primitives supplied by \TeX\ (or a + successor program). It may also be used to implement the previous + two languages `within' \TeX, as in the current \LaTeX\ system. +\end{description} + + +\section{Programming language: Main Features} + +The language outlined in this paper aims to provide a suitable +base for coding large (and small) scale projects in \TeX. +Its main distinguishing features are the following. +\begin{itemize} +\item Consistent naming scheme for all functions, including \TeX\ + primitives. +\item Standard mechanisms for controlling argument expansion. +\item Provision of sufficiently rich set of core functions for + handling programming constructs such as: + sequences, sets, stacks, property lists, etc. +\item White space ignored. +\end{itemize} + +\section{Naming Scheme} + +The name space is divided between \emph{Functions} and +\emph{Parameters}. Functions (normally) take arguments and are +executed, Parameters are usually passed as arguments to functions. +They are not directly executed, but accessed though accessor functions. + +Functions and parameters associated with a similar function (for +example accessing counters, or manipulating lists, etc.) are arranged +into \emph{modules}. Before giving the details of the form of the +command names, we give a few examples. + +|\l_tmpa_box| is a local parameter (hence the |l_| prefix) +corresponding to a box register. + +|\g_tmpa_box| is a global parameter (hence the |g_| prefix) +corresponding to a box register. + +|\c_one| is the constant (|c_|) parameter with value one. + +|\cnt_add:Nn| is the function which adds the value specified by +its second argument to the count register specified by its first +argument. The different natures of the two arguments are indicated by +the |:Nn| suffix. The first argument must be a single token specifying +the name of the count parameter. Such single token arguments are +denoted |N|. The second argument is a normal \TeX\ `non-delimited +argument' which may either be a single token, or a brace delimited +token list containing an expression for the value to be added. +The |n| denotes such `normal' argument forms. + +|\cnt_add:cn| is similar to the above, but in this case the the +counter is specified in the first argument by a list of tokens that +expands to the \emph{name} of the count parameter. + +These examples should give the basic flavour of the scheme. Parameters +are classified into local, global or constant (there are further more +technical cases in addition to these three) and this access type is +shown by |\l_|, |\g_| or |\c_|. Functions are arranged by +\emph{module} (The |cnt| module in these cases) with a descriptive +name followed by an indication of the type of argument to be passed. + +In more detail the specification of the names is as follows. + +Functions have the following general syntax: + \begin{quote} + |\|\m{module}|_|\m{description}|:|\m{arg-spec} + \end{quote} + The programmer can chose an arbitrary \m{module} name (consisting + of letters only) a group of functions with related functionality are + then all given names prefixed by this module name. The \m{description} + is a description of the functionality of the function, and should + consist of letters, and possibly |_| characters. \m{arg-spec} + describes the type of arguments as will be described below. + +The syntax of parameters is as follows: + \begin{quote} + |\|\m{access}|_|\m{module}|_|\m{description}|_|\m{type} + \end{quote} + \m{access} describes how the parameter can be accessed. The + principal access types are \emph{constant}, \emph{local} or + \emph{global}. As described below, some special access types relate + to \TeX\ primitive parameters. The meanings of \m{module} and + \m{description} in the parameter syntax is the same as that for + functions. Finally \m{type} should denote the type of parameter, + such as |cnt| for count registers, etc. + + + +Typical \m{module} names in the kernel include |cnt| for integer count +related functions, |seq| for functions relating to sequences, |box|, +etc. Normally additional packages adding new functionality would add +new modules as needed. + +The \m{description} is an arbitrary name for the function or +parameter, consisting of letters, or the |_| character. + +Function names always end with an \m{arg-spec} after a final colon. +This gives an indication of the types of argument that a function +takes, and provides a convenient method of naming similar functions +that just differ by their argument forms, as will be explained below. + +The \m{arg-spec} consists of a (possibly empty) list of characters +each denoting one argument that the function takes. It is important to +note that `argument' here refers to the conceptual argument of the +function. +The top level \TeX\ macro that has this name typically has no +arguments. This is similar to the existing \LaTeX\ convention where one +says that |\section| has an optional argument and a mandatory +argument, whereas the \TeX\ macro |\section| actually takes no +parameters at the \TeX\ level, it merely calls some standard \LaTeX\ +internal functions which look ahead for star forms and optional +arguments. The list of possible argument specifiers includes: +\begin{description} +\item[n] Unexpanded token (or token-list if in braces). In other words + this is a standard \TeX\ undelimited macro argument. +\item[o] One time expanded token or token-list. In the case of a token + list then only the first token in the list is expanded. +\item[x] Fully expanded token or token-list. Typically this means that + the argument is expanded in the style of |\edef| (|\def:Npx|) before + being passed to the function. +\item[c] A character string used (after expansion) as a command name. + The argument (a token or braced token list) should expand to a + sequence of characters which is then used to construct a command + name (via |\csname|, |\cs:w|). This command token is passed as the + argument to the function. + \item[N] A single token. (Unlike |n|, this argument must not be + surrounded by braces). A typical example of a command taking an N + argument is |\def|, in which the command being defined must be + unbraced. + \item[O] Single unbraced token that is expanded once and passed (as a + braced token list) to the function. + \item[X] Single unbraced token that is fully expanded and passed (as a + braced token list) to the function. + \item[C] A character string used as for |c| arguments but the + resulting command token is then expanded (as for |O|) and the + result passed as a braced token list to the function. + \item[p] A primitive \TeX\ parameter specification. This can be + something simple like |#1#2#3| but may be arbitrary delimited + argument syntax, such as |#1,#2\q_stop#3|. + \item[T, F] These are special cases of |n| arguments, used as the + true and false cases in conditional tests. + \item[D] `Do not use'. This special case is used for \TeX\ primitives + that are only used while bootstrapping the \LaTeX\ kernel. If the + \TeX\ primitive needs to be used in other contexts it will be given + an alternative name with a more appropriate argument specification. + \item[w] `weird' syntax. Used for arguments that take non standard + forms, usually delimited arguments that are needed internally to + implement certain modules, and also the boolean tests of many of the + primitive |\if|\ldots\ tests. +\end{description} + + +For parameters, the \m{type} should be from the list of available +data types (which include the primitive \TeX\ registers, but also +data types built within the system). + +Possible values for \m{type} include: +\begin{description} +\item[cnt] Integer valued counter. +\item[toks] Token register. +\item[box] Box register. +\item[fcnt] `Fake' count register. A data type supplied by the kernel + to avoid problems with the limited number of available count + registers in (standard) \TeX. +\end{description} + +The \m{access} codes that are used in parameter names include +\begin{description} +\item[c] Constants. +\item[l] Parameters that should only be set locally. +\item[g] Parameters that should only be set globally. +\end{description} + +\section{Checking Parameter assignments} +One of the advantages of having a consistent scheme is that the system +can provide more extensive error checking and debugging facilities. +For example a function that makes a global assignment can check that +it is not passed a local parameter as argument by checking that the +name of the command to be assigned starts with |\g_|. Such checking is +probably too slow for production runs, but the kernel has hooks built +in to allow a format to be made in which all functions perform this +kind of check. A typical section of code might look like +\begin{verbatim} +%<*check> +\def_new:Npn \toks_gset:Nn #1 { + \chk_global:N #1 + \pref_global:D #1 +} +%</check> +%<*!check> +\let_new:NN + \toks_gset:Nn \pref_global:D +%</!check> +\end{verbatim} +The function |\toks_gset:Nn| takes a single token (|N|) specifying a +token register, and globally sets it to the value passed in the second +argument. So typical use would be +\begin{verbatim} +\toks_gset \g_xxx_toks {some value} +\end{verbatim} +In the normal definition, |\toks_gset| can be defined just to be |\let| +to |\global|, as the primitive token register does not require any +explicit assignment function. This is the |%<*!check>| code above. +However the alternative definition first checks that the argument +passed as |#1| is a global parameter and raises an error if it is not. +It does this by taking apart the command name passed as |#1| and +checking that it starts |\g_|. + +\section{Consistent use of accessor functions} +The primitive \TeX\ syntax for register assignments has a very minimal +syntax, and apart from box functions there are no explicit functions +for assignment or use of the registers. This makes it very difficult +to implement alternative data types with a syntax that is at all +similar to the syntax for the primitives, and also encourages a coding +style that is very error prone. + +As noted in the example given above, The \LaTeX\ data types are +provided with explicit functions for setting and using the parameters +even when these have essentially empty definitions. This allows for +better error checking as described above, and also allows the +construction of alternative data types with a similar interface. +For example the `fake counter' data type mentioned previously works at +the user level just like the data type based on primitive count +registers, internally it does not use count registers though. +Typical functions in the |fcnt| module include: + + +\verb|\fcnt_new:N \l_tempa_fcnt|\\ +Declare the local parameter |\l_tempa_fcnt| as a fake counter. + +\verb|\fcnt_add:Nn \l_tempa_fcnt \c_thirty_two|\\ +Increment the counter by 32. + +\section{Expansion Control} +Anyone who programs in \TeX\ is used to the problem of arranging that +arguments to functions are suitably expanded before the function is +called. A couple of real examples copied from \texttt{latex.ltx}: +\begin{verbatim} +\global + \expandafter\expandafter\expandafter + \let + \expandafter + \reserved@a + \csname\curr@fontshape\endcsname + +\expandafter + \in@ + \csname sym#3\expandafter\endcsname + \expandafter{\group@list}% +\end{verbatim} +The first piece of code is a global |\let|. The token to be defined +is obtained by expanding \verb|\reserved@a| one level. The command +that it is to be let too is obtained by fully expanding +\verb|\curr@fontshape| and then using the tokens produced by that +expansion to construct a command name. This results in the mess +of interwoven \verb|\expandafter| and \verb|\csname| beloved of all +\TeX\ programmers, and code that is essentially unreadable. + +A similar construction using the conventions outlined here would be +\begin{verbatim} +\glet:Oc + \reserved_a: \l_current_font_shape_tlp +\end{verbatim} +The command \verb|\glet:Oc| is a global |\let| that expands its +argument once, and generates a command name out of its second +argument, before making the definition. This produces coe that +is far more readable. + +Similarly the second piece of code above produces a token list by +expanding \verb|\group@list| once, and then creates a command name out +of `\verb|sym#3|' (this is inside the definition of another fumction). +The function |\in@| is called which tests if its first argument occurs +in the token list of its second argument. + +Again it would be much clearer, if the above function \verb|\in@| was +called (say) \verb|\test_if_in:nn| (a function taking two normal +`\texttt{n}' arguments) and then a variant function was defined with +the appropriate argument types and simply called as follows: +\begin{verbatim} +\test_if_in:co {sym#3} \group_list: +\end{verbatim} +Note that apart from the lack of \verb|\expandafter| the space after +\verb|}| will be silently ignored. + + +For many common functions the kernel will provide functions with a +range of argument forms, and similarly it is expected that extension +packages providing new functions will make then available in the more +common forms. However There will be occasions where it is necessary +to construct such a variant form. + +A consistent mechanism is provided by the kernel to produce functions +with any argument type, starting from a function that takes `normal' +\TeX\ delimited arguments. Suppose you have a function \verb|\cmd:nnn| +that takes two arguments, and you need to construct \verb|\cmd:cnx| +a variant form in which the first argument is passed as a \emph{name} +of a command, and the third argument must be fully expanded before +being passed to \verb|\cmd:nnn|. + +One simply defines \verb|\cmd:cx| as follows: +\begin{verbatim} +\def:Nn \cmd:cnx {\exp_args:Ncnx \cmd:nnn} +\end{verbatim} +The function \verb|\exp_args:Ncnx| takes as its first (\texttt{N}) +argument the `base' function, and then grabs the next three arguments +from the token stream, acts on the first with \verb|\csname|, and the +last with \verb|\edef| and then constructs a call to the base function +with suitably transformed arguments. So +\begin{verbatim} +\cmd:cnx {abc}{pq}{\rst\xyz} +\end{verbatim} +is equivalent, but emminently more readable, to +\begin{verbatim} +\edef\temp{\rst\xyz} +\expandafter\cmd:nnn + \csname abc\expandafter\endcsname + \expandafter{% + \expandafter p\expandafter q% + \expandafter}% + \expandafter{\temp} +\end{verbatim} + +A large range of argument processing functions are provided in +addition to \verb|\exp_args:Ncnx|. If you need a particular argument +combination for which a function is not provided, one may be +constructed in a simple way. For example you need to construct +\verb|\exp_args:Nxcxcxc| a function that fully expands arguments +1,~3 and~5 of a given function, and produces commands to pass as +arguments 2,~4 and~6 using \verb|\csname|. The definition is simply +\begin{verbatim} +\def:Npn \exp_args:Nxcxcxc + {\::x\::c\::x\::c\::x\::c\:::} +\end{verbatim} +Similar functions, |::o| etc exist for all the other argument types, +and they may be strung together in any order, terminated by +\verb|\:::| to create a function which processes arguments in the +desired way. + +As hopefully demonstrated, the use of variant forms greatly improves +the readability of the code, and experience shows that the longer +command names which result from the new syntax do not realy make the +process of \emph{writing} the code any harder. + +\section{The Current Experimental Distribution} +The initial implementations of a \TeX\ format using this kind of +syntax were made with an unreleased (and non functional) format +(which pre-dates \LaTeXe!) The current distribution consists of a +subset of the functionality of that format, converted to run as +packages on top of \LaTeXe. + +The intention is to allow experienced \TeX\ programmers to experiment +on the system and to comment on the interface. This means that +\textbf{\itshape the interface will change}. No part of this system, +including the names of any commands should be relied upon as being +available in a later release. Please do \emph{experiment} with these +packages, but do not use them for documents that you expect to keep +unchanged over a long period. + +In view of the proposed experimental use for this distribution, we +currently have only converted a few modules for use with \LaTeXe. +These set up the basic conventions, and then implement a few basic +programming constructs such as lists and sequences. These are really +to give a flavour of the code, and to indicate that the intention is +that the kernel provide a sufficiently rich set of programming +constructs so that packages may use them and thus more efficiently +share code, unlike the situation in the current \LaTeX\ where every +large package implements its own version of lists, stacks etc. + +The current packages are: +\begin{description} +\item[l3names] +Sets up the basic naming scheme, including naming the \TeX\ +primitives. If used with the option \texttt{[removeoldnames]} +then the old primitive names such as \verb|\box| are \emph{undefined} +and thus made available for user definitions. Use of this option might +possibly break existing \TeX\ code! + +\item [l3basics] +Some basic definitions that are used by the other packages. + +\item[l3chk] +Functions to check (and make) definitions (comparable to the existing +\verb|\newcommand| or \verb|\renewcommand|). + +\item[l3tlp] +Token List Pointers. A basic \LaTeX3 data type for storing token lists. +(These are essentially macros with no arguments.) + + +\item[l3expan] +The argument expansion module discussed in the previous section. + + +\item[l3quarq] + +A `quark' is a command that is defined to expand to itself. So it may +not be directly used (it would generate an infinite loop) but has many +uses as special markers within \LaTeX\ code. + + +\item[l3seq] +A module implementing the basic list and stack data types. + +\item[l3prop] +Property lists are the data type for handling key/value assignments. +\end{description} + +The distribution also contains the \TeX\ source for this document, a +docstrip install file and two small test files. + +\begin{thebibliography}{1} + +\bibitem{A-W:LLa94} +Leslie Lamport. +\newblock {\em {\LaTeX:} A Document Preparation System}. +\newblock Addison-Wesley, Reading, Massachusetts, second edition, 1994. + +\end{thebibliography} + +\end{document} + + diff --git a/Master/texmf-dist/source/latex/expl3/l3alloc.dtx b/Master/texmf-dist/source/latex/expl3/l3alloc.dtx index 0fa4f2aef57..76f141a25b0 100644 --- a/Master/texmf-dist/source/latex/expl3/l3alloc.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3alloc.dtx @@ -32,25 +32,21 @@ %% %% ----------------------------------------------------------------------- % -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3alloc.dtx 581 2006-12-12 12:28:27Z morten $ +\GetIdInfo$Id: l3alloc.dtx 621 2007-09-01 20:14:19Z morten $ {L3 Experimental register allocation}% -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3alloc.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -128,6 +124,8 @@ % this file is loaded as a package on top of \LaTeXe. % % \begin{macrocode} +%<package>\ProvidesExplPackage +%<package> {\filename}{\filedate}{\fileversion}{\filedescription} %<package>\RequirePackage{l3expan} %<package>\RequirePackage{l3num} %<package>\RequirePackage{l3seq}\par diff --git a/Master/texmf-dist/source/latex/expl3/l3basics.dtx b/Master/texmf-dist/source/latex/expl3/l3basics.dtx index 4181fad3182..e34e42f2732 100644 --- a/Master/texmf-dist/source/latex/expl3/l3basics.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3basics.dtx @@ -31,29 +31,26 @@ %% prior consultation with the LaTeX Project Team. %% %% ----------------------------------------------------------------------- -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3basics.dtx 583 2006-12-12 17:26:44Z morten $ +\GetIdInfo$Id: l3basics.dtx 702 2007-11-27 14:21:49Z morten $ {L3 Experimental basic definitions} -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3basics.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi % +% % \title{The \textsf{l3basics} package\thanks{This file % has version number \fileversion, last % revised \filedate.}\\ @@ -429,14 +426,18 @@ % \begin{function}{% % \use_arg_i_after_fi:nw | % \use_arg_i_after_else:nw | -% \use_arg_i_after_or:nw +% \use_arg_i_after_or:nw | +% \use_arg_i_after_orelse:nw % } % \begin{syntax} % "\use_arg_i_after_fi:nw" "{"<arg>"}" "\fi:" % "\use_arg_i_after_else:nw" "{"<arg>"}" "\else:" <balanced text> "\fi:" % "\use_arg_i_after_or:nw" "{"<arg>"}" "\or:" <balanced text> "\fi:" +% "\use_arg_i_after_orelse:nw" "{"<arg>"}" "\or:/\else:" <balanced text> "\fi:" % \end{syntax} -% Executes <arg> after executing closing out "\fi:". +% Executes <arg> after executing closing out +% "\fi:". "\use_arg_i_after_orelse:nw" can be used anywhere where +% "\use_arg_i_after_else:nw" or "\use_arg_i_after_or:nw" are used. % \end{function} % % \subsection{Internal functions} @@ -1089,9 +1090,9 @@ % % \subsection{Engine specific definitions} % -% \begin{function}{\engine_aleph:TF} +% \begin{function}{\engine_if_aleph:TF} % \begin{syntax} -% "\engine_aleph:TF" "{"<true code>"}" "{"<false code>"}" +% "\engine_if_aleph:TF" "{"<true code>"}" "{"<false code>"}" % \end{syntax} % This function detects if we're running an Aleph based format. This % is particularly useful when allocating registers. @@ -1119,6 +1120,8 @@ % in terms of csname usage, an alternative scheme would be to just use % the ``tex\ldots D'' name in the cases where no good alternative exists.} % \begin{macrocode} +%<package>\ProvidesExplPackage +%<package> {\filename}{\filedate}{\fileversion}{\filedescription} %<*initex|package> \tex_let:D \let:NwN \tex_let:D % \end{macrocode} @@ -2264,6 +2267,8 @@ \def_long_new:Npn \def_test_function_aux:Nnnn #1#2#3#4{ #1 {#2TF} #3 {#4 \exp_after:NN\use_arg_i:nn\else:\exp_after:NN\use_arg_ii:nn\fi:} + #1 {#2FT} #3 {#4 + \exp_after:NN\use_arg_ii:nn\else:\exp_after:NN\use_arg_i:nn\fi:} #1 {#2T} #3 {#4 \else:\exp_after:NN\use_none:nn\fi:\use_arg_i:n} #1 {#2F} #3 {#4 @@ -2271,6 +2276,8 @@ \def_long_new:Npn \def_test_function_aux:Nnnx #1#2#3#4{ #1 {#2TF} #3 {#4 \exp_not:n{\exp_after:NN\use_arg_i:nn\else:\exp_after:NN\use_arg_ii:nn\fi:}} + #1 {#2FT} #3 {#4 + \exp_not:n{\exp_after:NN\use_arg_ii:nn\else:\exp_after:NN\use_arg_i:nn\fi:}} #1 {#2T} #3 {#4 \exp_not:n{\else:\exp_after:NN\use_none:nn\fi:\use_arg_i:n}} #1 {#2F} #3 {#4 @@ -2414,10 +2421,10 @@ % % \subsubsection{Engine specific definitions} % -% \begin{macro}{\engine_aleph:TF} +% \begin{macro}{\engine_if_aleph:TF} % In some cases it will be useful to know which engine we're running. % \begin{macrocode} -\def_test_function_new:npn {engine_aleph:}{\if_cs_exist:N \aleph_textdir:D} +\def_test_function_new:npn {engine_if_aleph:}{\if_cs_exist:N \aleph_textdir:D} % \end{macrocode} % \end{macro} % @@ -2529,15 +2536,18 @@ % \begin{macro}{\use_arg_i_after_fi:nw} % \begin{macro}{\use_arg_i_after_else:nw} % \begin{macro}{\use_arg_i_after_or:nw} +% \begin{macro}{\use_arg_i_after_or:nw} % Returns the first argument after ending the conditional. % \begin{macrocode} \def_long_new:Npn \use_arg_i_after_fi:nw #1\fi:{\fi: #1} \def_long_new:Npn \use_arg_i_after_else:nw #1\else:#2\fi:{\fi: #1} -\def_long_new:Npn \use_arg_i_after_or:nw #1\or: #2\fi: {\or:\fi:#1} +\def_long_new:Npn \use_arg_i_after_or:nw #1\or: #2\fi: {\fi:#1} +\def_long_new:Npn \use_arg_i_after_orelse:nw #1 #2#3\fi: {\fi:#1} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} +% \end{macro} % % \subsubsection{Gobbling tokens from input} % diff --git a/Master/texmf-dist/source/latex/expl3/l3box.dtx b/Master/texmf-dist/source/latex/expl3/l3box.dtx index 96e0d4696a8..c697225b8b3 100644 --- a/Master/texmf-dist/source/latex/expl3/l3box.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3box.dtx @@ -1,5 +1,5 @@ % \iffalse -%% File: l3box.dtx Copyright (C) 2005-2006 LaTeX3 project +%% File: l3box.dtx Copyright (C) 2005-2007 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 @@ -32,26 +32,21 @@ %% %% ----------------------------------------------------------------------- % -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3box.dtx 573 2006-08-21 20:59:37Z morten $ +\GetIdInfo$Id: l3box.dtx 718 2007-12-16 22:59:58Z morten $ {L3 Experimental Box module} -% -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3box.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -109,6 +104,8 @@ % \end{function} % % \begin{function}{% +% \box_if_empty_p:N | +% \box_if_empty_p:c | % \box_if_empty:NTF | % \box_if_empty:cTF | % \box_if_empty:NT | @@ -155,16 +152,16 @@ % % % \begin{function}{% -% \box_set_to_previous:N | -% \box_set_to_previous:c | -% \box_gset_to_previous:N | -% \box_gset_to_previous:c | +% \box_set_to_last:N | +% \box_set_to_last:c | +% \box_gset_to_last:N | +% \box_gset_to_last:c | % } % \begin{syntax} -% "\box_set_to_previous:N" <box> +% "\box_set_to_last:N" <box> % \end{syntax} -% Sets <box> equal to the previous box |\R_previous_box| and removes -% |\R_previous_box| from the current list (unless in outer vertical +% Sets <box> equal to the previous box |\R_last_box| and removes +% |\R_last_box| from the current list (unless in outer vertical % or math mode). % \end{function} % @@ -261,11 +258,11 @@ % % % \begin{variable}{% -% \R_previous_box | +% \R_last_box | % } % \begin{syntax} % \end{syntax} -% "\R_previous_box" is a read-only box register. You can set other +% "\R_last_box" is a read-only box register. You can set other % boxes to this box, which will then be removed from the current % list. % \end{variable} @@ -322,8 +319,10 @@ % % \begin{function}{% % \hbox_set_inline_begin:N | +% \hbox_set_inline_begin:c | % \hbox_set_inline_end: | % \hbox_gset_inline_begin:N | +% \hbox_gset_inline_begin:c | % \hbox_gset_inline_end: | % } % \begin{syntax} @@ -454,9 +453,11 @@ % \subsection{The Implementation} % % -% We start by ensuring that the required packages are loaded. +% Announce and ensure that the required packages are loaded. % \begin{macrocode} -%<package&!check>\RequirePackage{l3prg}\par +%<package>\ProvidesExplPackage +%<package> {\filename}{\filedate}{\fileversion}{\filedescription} +%<package&!check>\RequirePackage{l3prg,l3token}\par %<package&check>\RequirePackage{l3chk}\par %<*initex|package> % \end{macrocode} @@ -507,6 +508,8 @@ % \end{macro} % \end{macro} % +% \begin{macro}{\box_if_empty_p:N} +% \begin{macro}{\box_if_empty_p:c} % \begin{macro}{\box_if_empty:NTF} % \begin{macro}{\box_if_empty:cTF} % \begin{macro}{\box_if_empty:NT} @@ -515,6 +518,9 @@ % \begin{macro}{\box_if_empty:cF} % Testing if a \m{box} is empty/void. % \begin{macrocode} +\def_new:Npn \box_if_empty_p:N #1{ + \if_box_empty:N #1 \c_true \else: \c_false \fi:} +\def_new:Npn \box_if_empty_p:c {\exp_args:Nc \box_if_empty_p:N} \def_test_function_new:npn {box_if_empty:N}#1{\if_box_empty:N #1} \def_new:Npn \box_if_empty:cTF {\exp_args:Nc \box_if_empty:NTF} \def_new:Npn \box_if_empty:cT {\exp_args:Nc \box_if_empty:NT} @@ -526,6 +532,8 @@ % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} % % % \begin{macro}{\box_set_eq:NN} @@ -561,23 +569,23 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\R_previous_box} +% \begin{macro}{\R_last_box} % A different name for this read-only primitive. % \begin{macrocode} -\let_new:NN \R_previous_box \tex_lastbox:D +\let_new:NN \R_last_box \tex_lastbox:D % \end{macrocode} % \end{macro} % -% \begin{macro}{\box_set_to_previous:N} -% \begin{macro}{\box_set_to_previous:c} -% \begin{macro}{\box_gset_to_previous:N} -% \begin{macro}{\box_gset_to_previous:c} +% \begin{macro}{\box_set_to_last:N} +% \begin{macro}{\box_set_to_last:c} +% \begin{macro}{\box_gset_to_last:N} +% \begin{macro}{\box_gset_to_last:c} % Set a box to the previous box. % \begin{macrocode} -\def_new:Npn \box_set_to_previous:N #1{\tex_setbox:D#1\R_previous_box} -\def_new:Npn \box_set_to_previous:c {\exp_args:Nc \box_set_to_previous:N} -\def_new:Npn \box_gset_to_previous:N {\pref_global:D \box_set_to_previous:N} -\def_new:Npn \box_gset_to_previous:c {\exp_args:Nc \box_gset_to_previous:N} +\def_new:Npn \box_set_to_last:N #1{\tex_setbox:D#1\R_last_box} +\def_new:Npn \box_set_to_last:c {\exp_args:Nc \box_set_to_last:N} +\def_new:Npn \box_gset_to_last:N {\pref_global:D \box_set_to_last:N} +\def_new:Npn \box_gset_to_last:c {\exp_args:Nc \box_gset_to_last:N} % \end{macrocode} % \end{macro} % \end{macro} @@ -835,23 +843,31 @@ % % % \begin{macro}{\hbox_set_inline_begin:N} +% \begin{macro}{\hbox_set_inline_begin:c} % \begin{macro}{\hbox_set_inline_end:} % \begin{macro}{\hbox_gset_inline_begin:N} +% \begin{macro}{\hbox_gset_inline_begin:c} % \begin{macro}{\hbox_set_inline_end:} % Storing material in a horizontal box. This type is useful in % environment definitions. % \begin{macrocode} \def_new:Npn \hbox_set_inline_begin:N #1 { \tex_setbox:D #1 \tex_hbox:D \c_group_begin_token } +\def:Npn \hbox_set_inline_begin:c {\exp_args:Nc + \hbox_set_inline_begin:N} \let_new:NN \hbox_set_inline_end: \c_group_end_token \def_new:Npn \hbox_gset_inline_begin:N { \pref_global:D \hbox_set_inline_begin:N } +\def:Npn \hbox_gset_inline_begin:c {\exp_args:Nc + \hbox_gset_inline_begin:N } \let_new:NN \hbox_gset_inline_end: \c_group_end_token % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} % % \begin{macro}{\hbox_to_wd:nn} % \begin{macro}{\hbox_to_zero:n} diff --git a/Master/texmf-dist/source/latex/expl3/l3calc.dtx b/Master/texmf-dist/source/latex/expl3/l3calc.dtx index f00c2941940..842e68864c7 100644 --- a/Master/texmf-dist/source/latex/expl3/l3calc.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3calc.dtx @@ -31,25 +31,21 @@ %% prior consultation with the LaTeX Project Team. %% %% ----------------------------------------------------------------------- -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3calc.dtx 573 2006-08-21 20:59:37Z morten $ +\GetIdInfo$Id: l3calc.dtx 621 2007-09-01 20:14:19Z morten $ {L3 Experimental calc module} -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3calc.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -70,14 +66,23 @@ % \begin{itemize} % \item The calc expression is expanded fully, which means there are % no problems with unfinished conditionals. However, the contents of -% |\widthof| etc.\ is not expanded at all. +% |\widthof| etc.\ is not expanded at all. This includes uses in +% traditional \LaTeX\ as in the \textsf{array} package, which tries +% to do an |\edef| several times. The code used in \textsf{l3calc} +% provides self-protection for these cases. % \item Muskip registers are supported although they can only be used % in |\ratio| if already evaluating a muskip expression. For the % other three register types, you can use points. % \item All results are rounded, not truncated. More precisely, the -% primitive \TeX\ operations |\divide| and |\multiply| are not used. +% primitive \TeX\ operations |\divide| and |\multiply| are not +% used. The only instance where one will observe an effect is when +% dividing integers. % \end{itemize} % +% This version of \textsf{l3calc} is a now a complete replacement for +% the original \textsf{calc} package providing the same functionality +% and will prevent the original \textsf{calc} package from loading. +% % \begin{function}{ % \calc_int_set:Nn | % \calc_int_gset:Nn | @@ -179,6 +184,8 @@ % We start by ensuring that the required packages are loaded. % \begin{macrocode} %<*package> +\ProvidesExplPackage + {\filename}{\filedate}{\fileversion}{\filedescription} \RequirePackage{l3int} \RequirePackage{l3skip} \RequirePackage{l3box} @@ -246,39 +253,41 @@ % % % -% \begin{macro}{\calc_assign_generic:NNNNNn} +% \begin{macro}{\calc_assign_generic:NNNNnn} % The generic function. |#1| is a number denoting which type we are % doing. (0=int, 1=dim, 2=skip, 3=muskip), |#2| = temp register A, % |#3| = temp register B, |#4| is a function acting on |#5| which is -% the register to be set. |#6| is the calc expression. This version -% relies on |\real| and |\ratio| having our definitions. +% the register to be set. |#6| is the calc expression. We do a +% little extra work so that |\real| and |\ratio| can still be used +% by the user. % \begin{macrocode} -\def_long_new:Npn \calc_assign_generic:NNNNNn#1#2#3#4#5#6{ - \let:NN\g_calc_A_register#2\let:NN\l_calc_B_register#3 +\def_long_new:Npn \calc_assign_generic:NNNNnn#1#2#3#4#5#6{ + \let:NN\g_calc_A_register#2 + \let:NN\l_calc_B_register#3 \int_set:Nn \l_calc_current_type_int {#1} - \tlp_set:Nx\l_calc_expression_tlp{#6} - \exp_after:NN\calc_open:w\exp_after:NN(\l_calc_expression_tlp! + \group_begin: + \let:NN \real \calc_real:n + \let:NN \ratio\calc_ratio:nn + \tlp_set:Nx\l_calc_expression_tlp{#6} + \exp_after:NN + \group_end: + \exp_after:NN\calc_open:w\exp_after:NN(\l_calc_expression_tlp ! \pref_global:D\g_calc_A_register\l_calc_B_register \group_end: - #4#5\l_calc_B_register + #4{#5}\l_calc_B_register } % \end{macrocode} -% One could lift these restrictions by defining |\calc_generic:NNNNNn| -% like this: +% A simpler version relying on |\real| and |\ratio| having our +% definition is % \begin{verbatim} -% \def_long_new:Npn \calc_assign_generic:NNNNNn#1#2#3#4#5#6{ +% \def_long_new:Npn \calc_assign_generic:NNNNnn#1#2#3#4#5#6{ % \let:NN\g_calc_A_register#2\let:NN\l_calc_B_register#3 % \int_set:Nn \l_calc_current_type_int {#1} -% \group_begin: -% \let:NN \real\calc_real:n -% \let:NN \ratio\calc_ratio:nn -% \tlp_set:Nx\l_calc_expression_tlp{#6} -% \exp_after:NN -% \group_end: -% \exp_after:NN\calc_open:w\exp_after:NN(\l_calc_expression_tlp! +% \tlp_set:Nx\l_calc_expression_tlp{#6} +% \exp_after:NN\calc_open:w\exp_after:NN(\l_calc_expression_tlp ! % \pref_global:D\g_calc_A_register\l_calc_B_register % \group_end: -% #4#5\l_calc_B_register +% #4{#5}\l_calc_B_register % } % \end{verbatim} % \end{macro} @@ -295,22 +304,22 @@ % types. First integer registers. % \begin{macrocode} \def_new:Npn\calc_int_set:Nn{ - \calc_assign_generic:NNNNNn\c_zero\g_calc_A_int\l_calc_B_int\int_set:Nn + \calc_assign_generic:NNNNnn\c_zero\g_calc_A_int\l_calc_B_int\int_set:Nn } \def_new:Npn\calc_int_gset:Nn{ - \calc_assign_generic:NNNNNn\c_zero\g_calc_A_int\l_calc_B_int\int_gset:Nn + \calc_assign_generic:NNNNnn\c_zero\g_calc_A_int\l_calc_B_int\int_gset:Nn } \def_new:Npn\calc_int_add:Nn{ - \calc_assign_generic:NNNNNn\c_zero\g_calc_A_int\l_calc_B_int\int_add:Nn + \calc_assign_generic:NNNNnn\c_zero\g_calc_A_int\l_calc_B_int\int_add:Nn } \def_new:Npn\calc_int_gadd:Nn{ - \calc_assign_generic:NNNNNn\c_zero\g_calc_A_int\l_calc_B_int\int_gadd:Nn + \calc_assign_generic:NNNNnn\c_zero\g_calc_A_int\l_calc_B_int\int_gadd:Nn } \def_new:Npn\calc_int_sub:Nn{ - \calc_assign_generic:NNNNNn\c_zero\g_calc_A_int\l_calc_B_int\int_sub:Nn + \calc_assign_generic:NNNNnn\c_zero\g_calc_A_int\l_calc_B_int\int_sub:Nn } \def_new:Npn\calc_int_gsub:Nn{ - \calc_assign_generic:NNNNNn\c_zero\g_calc_A_int\l_calc_B_int\int_gsub:Nn + \calc_assign_generic:NNNNnn\c_zero\g_calc_A_int\l_calc_B_int\int_gsub:Nn } % \end{macrocode} % \end{macro} @@ -329,22 +338,22 @@ % Dimens. % \begin{macrocode} \def_new:Npn\calc_dim_set:Nn{ - \calc_assign_generic:NNNNNn\c_one\g_calc_A_dim\l_calc_B_dim\dim_set:Nn + \calc_assign_generic:NNNNnn\c_one\g_calc_A_dim\l_calc_B_dim\dim_set:Nn } \def_new:Npn\calc_dim_gset:Nn{ - \calc_assign_generic:NNNNNn\c_one\g_calc_A_dim\l_calc_B_dim\dim_gset:Nn + \calc_assign_generic:NNNNnn\c_one\g_calc_A_dim\l_calc_B_dim\dim_gset:Nn } \def_new:Npn\calc_dim_add:Nn{ - \calc_assign_generic:NNNNNn\c_one\g_calc_A_dim\l_calc_B_dim\dim_add:Nn + \calc_assign_generic:NNNNnn\c_one\g_calc_A_dim\l_calc_B_dim\dim_add:Nn } \def_new:Npn\calc_dim_gadd:Nn{ - \calc_assign_generic:NNNNNn\c_one\g_calc_A_dim\l_calc_B_dim\dim_gadd:Nn + \calc_assign_generic:NNNNnn\c_one\g_calc_A_dim\l_calc_B_dim\dim_gadd:Nn } \def_new:Npn\calc_dim_sub:Nn{ - \calc_assign_generic:NNNNNn\c_one\g_calc_A_int\l_calc_B_int\dim_sub:Nn + \calc_assign_generic:NNNNnn\c_one\g_calc_A_int\l_calc_B_int\dim_sub:Nn } \def_new:Npn\calc_dim_gsub:Nn{ - \calc_assign_generic:NNNNNn\c_one\g_calc_A_int\l_calc_B_int\dim_gsub:Nn + \calc_assign_generic:NNNNnn\c_one\g_calc_A_int\l_calc_B_int\dim_gsub:Nn } % \end{macrocode} % \end{macro} @@ -363,22 +372,22 @@ % Skips. % \begin{macrocode} \def_new:Npn\calc_skip_set:Nn{ - \calc_assign_generic:NNNNNn\c_two\g_calc_A_dim\l_calc_B_dim\skip_set:Nn + \calc_assign_generic:NNNNnn\c_two\g_calc_A_skip\l_calc_B_skip\skip_set:Nn } \def_new:Npn\calc_skip_gset:Nn{ - \calc_assign_generic:NNNNNn\c_two\g_calc_A_dim\l_calc_B_dim\skip_gset:Nn + \calc_assign_generic:NNNNnn\c_two\g_calc_A_skip\l_calc_B_skip\skip_gset:Nn } \def_new:Npn\calc_skip_add:Nn{ - \calc_assign_generic:NNNNNn\c_two\g_calc_A_dim\l_calc_B_dim\skip_add:Nn + \calc_assign_generic:NNNNnn\c_two\g_calc_A_skip\l_calc_B_skip\skip_add:Nn } \def_new:Npn\calc_skip_gadd:Nn{ - \calc_assign_generic:NNNNNn\c_two\g_calc_A_dim\l_calc_B_dim\skip_gadd:Nn + \calc_assign_generic:NNNNnn\c_two\g_calc_A_skip\l_calc_B_skip\skip_gadd:Nn } \def_new:Npn\calc_skip_sub:Nn{ - \calc_assign_generic:NNNNNn\c_two\g_calc_A_dim\l_calc_B_dim\skip_sub:Nn + \calc_assign_generic:NNNNnn\c_two\g_calc_A_skip\l_calc_B_skip\skip_sub:Nn } \def_new:Npn\calc_skip_gsub:Nn{ - \calc_assign_generic:NNNNNn\c_two\g_calc_A_dim\l_calc_B_dim\skip_gsub:Nn + \calc_assign_generic:NNNNnn\c_two\g_calc_A_skip\l_calc_B_skip\skip_gsub:Nn } % \end{macrocode} % \end{macro} @@ -397,22 +406,28 @@ % Muskips. % \begin{macrocode} \def_new:Npn\calc_muskip_set:Nn{ - \calc_assign_generic:NNNNNn\c_three\g_calc_A_dim\l_calc_B_dim\muskip_set:Nn + \calc_assign_generic:NNNNnn\c_three\g_calc_A_muskip\l_calc_B_muskip + \muskip_set:Nn } \def_new:Npn\calc_muskip_gset:Nn{ - \calc_assign_generic:NNNNNn\c_three\g_calc_A_dim\l_calc_B_dim\muskip_gset:Nn + \calc_assign_generic:NNNNnn\c_three\g_calc_A_muskip\l_calc_B_muskip + \muskip_gset:Nn } \def_new:Npn\calc_muskip_add:Nn{ - \calc_assign_generic:NNNNNn\c_three\g_calc_A_dim\l_calc_B_dim\muskip_add:Nn + \calc_assign_generic:NNNNnn\c_three\g_calc_A_muskip\l_calc_B_muskip + \muskip_add:Nn } \def_new:Npn\calc_muskip_gadd:Nn{ - \calc_assign_generic:NNNNNn\c_three\g_calc_A_dim\l_calc_B_dim\muskip_gadd:Nn + \calc_assign_generic:NNNNnn\c_three\g_calc_A_muskip\l_calc_B_muskip + \muskip_gadd:Nn } \def_new:Npn\calc_muskip_sub:Nn{ - \calc_assign_generic:NNNNNn\c_three\g_calc_A_dim\l_calc_B_dim\muskip_add:Nn + \calc_assign_generic:NNNNnn\c_three\g_calc_A_muskip\l_calc_B_muskip + \muskip_add:Nn } \def_new:Npn\calc_muskip_gsub:Nn{ - \calc_assign_generic:NNNNNn\c_three\g_calc_A_dim\l_calc_B_dim\muskip_gadd:Nn + \calc_assign_generic:NNNNnn\c_three\g_calc_A_muskip\l_calc_B_muskip + \muskip_gadd:Nn } % \end{macrocode} % \end{macro} @@ -485,13 +500,16 @@ \if_meaning:NN#1*\let:NN\calc_next:w\calc_multiply:N \else: \if_meaning:NN#1/\let:NN\calc_next:w\calc_divide:N \else: \if_meaning:NN#1)\let:NN\calc_next:w\calc_close: \else: + \if_meaning:NN#1\scan_stop:\let:NN\calc_next:w\calc_post_scan:N + \else: % \end{macrocode} % If we get here, there is an error but let's also disable % |\calc_next:w| since it is otherwise undefined. No need to give % extra errors just for that. % \begin{macrocode} - \let:NN \calc_next:w \scan_stop: - \calc_error:N#1 + \let:NN \calc_next:w \use_noop: + \calc_error:N#1 + \fi: \fi: \fi: \fi: @@ -600,6 +618,7 @@ \group_begin: \let:NN\g_calc_A_register\g_calc_A_int \let:NN\l_calc_B_register\l_calc_B_int + \int_zero:N \l_calc_current_type_int \group_execute_after:N#1\calc_pre_scan:N } \def_new:Npn\calc_multiply_B_by_A:{ @@ -655,10 +674,10 @@ % \begin{macrocode} \def_protected_long:Npn \calc_textsize:Nn#1#2{ \group_begin: - \let:NN\widthof\box_wd:N - \let:NN\heightof\box_ht:N - \let:NN\depthof\box_dp:N - \def:Npn\totalheightof{\box_ht:N\box_dp:N} + \let:NN\calc_widthof_aux:n\box_wd:N + \let:NN\calc_heightof_aux:n\box_ht:N + \let:NN\calc_depthof_aux:n\box_dp:N + \def:Npn\calc_totalheightof_aux:n{\box_ht:N\box_dp:N} \exp_args:No\calc_calculate_box_size:nnn{#1} {\dim_gset:Nn\g_calc_A_register} % \end{macrocode} @@ -666,10 +685,10 @@ % call. % \begin{macrocode} { - \let:NN \depthof\calc_depthof:n - \let:NN \widthof\calc_widthof:n - \let:NN \heightof\calc_heightof:n - \let:NN \totalheightof\calc_totalheightof:n + \let:NN \calc_depthof_aux:n \calc_depthof_auxi:n + \let:NN \calc_widthof_aux:n \calc_widthof_auxi:n + \let:NN \calc_heightof_aux:n \calc_heightof_auxi:n + \let:NN \calc_totalheightof_aux:n \calc_totalheightof_auxi:n #2 } \group_end: @@ -845,8 +864,8 @@ \def_long_new:Npn \calc_minof:nn#1#2{ \calc_maxmin_operation:Nnn < \exp_not:n{{#1}{#2}} } -\let_new:NN \maxof \calc_maxof:nn -\let_new:NN \minof \calc_minof:nn +\let:NN \maxof \calc_maxof:nn +\let:NN \minof \calc_minof:nn % \end{macrocode} % \end{macro} % \end{macro} @@ -854,31 +873,47 @@ % \end{macro} % % \begin{macro}{\calc_widthof:n} +% \begin{macro}{\calc_widthof_aux:n} +% \begin{macro}{\calc_widthof_auxi:n} % \begin{macro}{\calc_heightof:n} +% \begin{macro}{\calc_heightof_aux:n} +% \begin{macro}{\calc_heightof_auxi:n} % \begin{macro}{\calc_depthof:n} +% \begin{macro}{\calc_depthof_aux:n} +% \begin{macro}{\calc_depthof_auxi:n} % \begin{macro}{\calc_totalheightof:n} -% \begin{macro}{\widthof} -% \begin{macro}{\heightof} -% \begin{macro}{\depthof} -% \begin{macro}{\totalheightof} +% \begin{macro}{\calc_totalheightof_aux:n} +% \begin{macro}{\calc_totalheightof_auxi:n} % Text dimension commands. % \begin{macrocode} \def_long_new:Npn \calc_widthof:n#1{ - \calc_textsize:Nn \exp_not:N\widthof\exp_not:n{{#1}} + \calc_textsize:Nn \exp_not:N\calc_widthof_aux:n\exp_not:n{{#1}} } \def_long_new:Npn \calc_heightof:n#1{ - \calc_textsize:Nn \exp_not:N\heightof\exp_not:n{{#1}} + \calc_textsize:Nn \exp_not:N\calc_heightof_aux:n\exp_not:n{{#1}} } \def_long_new:Npn \calc_depthof:n#1{ - \calc_textsize:Nn \exp_not:N\depthof\exp_not:n{{#1}} + \calc_textsize:Nn \exp_not:N\calc_depthof_aux:n\exp_not:n{{#1}} } \def_long_new:Npn \calc_totalheightof:n#1{ - \calc_textsize:Nn \exp_not:N\totalheightof\exp_not:n{{#1}} + \calc_textsize:Nn \exp_not:N\calc_totalheightof_aux:n \exp_not:n{{#1}} } -\let:NN \depthof\calc_depthof:n -\let:NN \widthof\calc_widthof:n -\let:NN \heightof\calc_heightof:n -\let:NN \totalheightof\calc_totalheightof:n +\def_long_new:Npn \calc_widthof_aux:n #1{ + \exp_not:N\calc_widthof_aux:n\exp_not:n{{#1}} +} +\let_new:NN \calc_widthof_auxi:n \calc_widthof_aux:n +\def_long_new:Npn \calc_depthof_aux:n #1{ + \exp_not:N\calc_depthof_aux:n\exp_not:n{{#1}} +} +\let_new:NN \calc_depthof_auxi:n \calc_depthof_aux:n +\def_long_new:Npn \calc_heightof_aux:n #1{ + \exp_not:N\calc_heightof_aux:n\exp_not:n{{#1}} +} +\let_new:NN \calc_heightof_auxi:n \calc_heightof_aux:n +\def_long_new:Npn \calc_totalheightof_aux:n #1{ + \exp_not:N\calc_totalheightof_aux:n\exp_not:n{{#1}} +} +\let_new:NN \calc_totalheightof_auxi:n \calc_totalheightof_aux:n % \end{macrocode} % \end{macro} % \end{macro} @@ -888,25 +923,119 @@ % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} % % \begin{macro}{\calc_ratio:nn} % \begin{macro}{\calc_real:n} -% \begin{macro}{\ratio} -% \begin{macro}{\real} % Ratio and real. % \begin{macrocode} \def_long_new:Npn \calc_ratio:nn#1#2{ \calc_ratio_multiply:nn\exp_not:n{{#1}{#2}}} -\let_new:NN \calc_real:n \calc_real_evaluate:nn +\def_new:Npn \calc_real:n {\calc_real_evaluate:nn} % \end{macrocode} % We can implement real and ratio without actually using these % names. We'll see. % \begin{macrocode} -\let_new:NN \ratio\calc_ratio:nn -\let_new:NN \real\calc_real:n % \end{macrocode} % \end{macro} % \end{macro} +% +% \begin{macro}{\widthof} +% \begin{macro}{\heightof} +% \begin{macro}{\depthof} +% \begin{macro}{\totalheightof} +% \begin{macro}{\ratio} +% \begin{macro}{\real} +% User commands. +% \begin{macrocode} +\let:NN \depthof\calc_depthof:n +\let:NN \widthof\calc_widthof:n +\let:NN \heightof\calc_heightof:n +\let:NN \totalheightof\calc_totalheightof:n +%%\let:NN \ratio\calc_ratio:nn +%%\let:NN \real\calc_real:n +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\setlength} +% \begin{macro}{\gsetlength} +% \begin{macro}{\addtolength} +% \begin{macro}{\gaddtolength} +% \begin{macrocode} +\def_protected:Npn \setlength{\calc_skip_set:Nn} +\def_protected:Npn \gsetlength{\calc_skip_gset:Nn} +\def_protected:Npn \addtolength{\calc_skip_add:Nn} +\def_protected:Npn \gaddtolength{\calc_skip_gadd:Nn} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\calc_setcounter:nn} +% \begin{macro}{\calc_addtocounter:nn} +% \begin{macro}{\calc_stepcounter:n} +% \begin{macro}{\setcounter} +% \begin{macro}{\addtocounter} +% \begin{macro}{\stepcounter} +% \begin{macro}{\calc_chk_document_counter:nn} +% Document commands for \LaTeXe\ counters. Also add support for +% \textsf{amstext}. Note that when \textsf{l3breqn} is used, +% |\mathchoice| will no longer need this switch as the argument is +% only executed once. +% \begin{macrocode} +\newif\iffirstchoice@ \firstchoice@true +\def_protected:Npn \calc_setcounter:nn#1#2{ + \calc_chk_document_counter:nn{#1}{ + \exp_args:Nc\calc_int_gset:Nn {c@#1}{#2} + } +} +\def_protected:Npn \calc_addtocounter:nn#1#2{ + \iffirstchoice@ + \calc_chk_document_counter:nn{#1}{ + \exp_args:Nc\calc_int_gadd:Nn {c@#1}{#2} + } + \fi: +} +\def_protected:Npn \calc_stepcounter:n#1{ + \iffirstchoice@ + \calc_chk_document_counter:nn{#1}{ + \int_gincr:c {c@#1} + \group_begin: + \let:NN \@elt\@stpelt \cs_use:c{cl@#1} + \group_end: + } + \fi: +} +\def_new:Npn \calc_chk_document_counter:nn#1{ + \cs_if_free:cTF{c@#1}{\@nocounterr {#1}} +} +\let:NN \setcounter \calc_setcounter:nn +\let:NN \addtocounter \calc_addtocounter:nn +\let:NN \stepcounter \calc_stepcounter:n +\AtBeginDocument{ + \let:NN \setcounter \calc_setcounter:nn + \let:NN \addtocounter \calc_addtocounter:nn + \let:NN \stepcounter \calc_stepcounter:n +} +% \end{macrocode} +% Prevent the usual \textsf{calc} from loading. +% \begin{macrocode} +%<package>\def:cpn{ver@calc.sty}{2005/08/06} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} % \end{macro} % \end{macro} % diff --git a/Master/texmf-dist/source/latex/expl3/l3chk.dtx b/Master/texmf-dist/source/latex/expl3/l3chk.dtx index f492a516903..281ba7bc1cc 100644 --- a/Master/texmf-dist/source/latex/expl3/l3chk.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3chk.dtx @@ -32,25 +32,21 @@ %% %% ----------------------------------------------------------------------- %% -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3chk.dtx 573 2006-08-21 20:59:37Z morten $ +\GetIdInfo$Id: l3chk.dtx 621 2007-09-01 20:14:19Z morten $ {L3 Experimental check module} -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3chk.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -142,6 +138,8 @@ % % We start by ensuring that the required packages are loaded. % \begin{macrocode} +%<package>\ProvidesExplPackage +%<package> {\filename}{\filedate}{\fileversion}{\filedescription} %<package>\RequirePackage{l3basics} %<package>\RequirePackage{l3int,l3prg} %<*initex|package> diff --git a/Master/texmf-dist/source/latex/expl3/l3clist.dtx b/Master/texmf-dist/source/latex/expl3/l3clist.dtx index f8fdba275bb..1bee2934399 100644 --- a/Master/texmf-dist/source/latex/expl3/l3clist.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3clist.dtx @@ -32,25 +32,21 @@ %% %% ----------------------------------------------------------------------- % -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3clist.dtx 573 2006-08-21 20:59:37Z morten $ +\GetIdInfo$Id: l3clist.dtx 725 2007-12-22 21:25:00Z mittelba $ {L3 Experimental comma separated lists} -% -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} \begin{document} -\DocInput{l3clist.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -459,6 +455,8 @@ % % We start by ensuring that the required packages are loaded. % \begin{macrocode} +%<package>\ProvidesExplPackage +%<package> {\filename}{\filedate}{\fileversion}{\filedescription} %<*package> \NeedsTeXFormat{LaTeX2e} %<!check>\RequirePackage{l3prg,l3quark} @@ -693,7 +691,7 @@ % An here the global variants. % \begin{macrocode} \def_new:Npn \clist_gput_right:Nn { - \clist_put_aux:NNnnNn \tlp_set:Nn \tlp_put_right:Nn , {} + \clist_put_aux:NNnnNn \tlp_gset:Nn \tlp_gput_right:Nn , {} } \def_new:Npn \clist_gput_right:No {\exp_args:NNo \clist_gput_right:Nn} \def_new:Npn \clist_gput_right:cn {\exp_args:Nc \clist_gput_right:Nn} @@ -720,13 +718,13 @@ \clist_if_empty:NF #1 { \exp_after:NN \clist_map_function_aux:Nw - \exp_after:NN #2 #1 , \q_nil , \q_stop + \exp_after:NN #2 #1 , \q_recursion_tail , \q_recursion_stop } } \def_new:Npn \clist_map_function:cN{\exp_args:Nc\clist_map_function:NN} \def_new:Npn \clist_map_function:nN #1#2{ - \tlist_if_empty:nF {#1} - { \clist_map_function_aux:Nw #2 #1 , \q_nil , \q_stop } + \tlist_if_blank:nF {#1} + { \clist_map_function_aux:Nw #2 #1 , \q_recursion_tail , \q_recursion_stop } } % \end{macrocode} % \end{macro} @@ -739,7 +737,7 @@ % element "#2", which is surrounded by braces. % \begin{macrocode} \def_new:Npn \clist_map_function_aux:Nw #1#2,{ - \quark_if_nil:nT{#2} \clist_map_break:w + \quark_if_recursion_tail_stop:n{#2} #1{#2} \clist_map_function_aux:Nw #1 } @@ -747,13 +745,10 @@ % \end{macro} % % \begin{macro}{\clist_map_break:w} -% The break statement is easy: Just gobble everything op to the last -% of the two stop markers "\q_stop" waiting at the end and close the -% "\if_..." we're in. Technically this should get an "w" specifier, -% but it doesn't take any arguments when you call it -- at least not -% any you would expect. +% The break statement is easy. Same as in other modules, gobble +% everything up to the special recursion stop marker. % \begin{macrocode} -\let_new:NN \clist_map_break:w \use_none_delimit_by_q_stop:w +\let_new:NN \clist_map_break:w \use_none_delimit_by_q_recursion_stop:w % \end{macrocode} % \end{macro} % @@ -782,7 +777,7 @@ % \begin{macrocode} \exp_args:NcE \clist_map_function_aux:Nw {clist_map_inline_ \int_use:N \l_clist_inline_level_int :n} - #1 , \q_nil , \q_stop + #1 , \q_recursion_tail , \q_recursion_stop \int_decr:N \l_clist_inline_level_int } } @@ -795,7 +790,7 @@ ##1{#2} \exp_args:Nc \clist_map_function_aux:Nw {clist_map_inline_ \int_use:N \l_clist_inline_level_int :n} - #1 , \q_nil , \q_stop + #1 , \q_recursion_tail , \q_recursion_stop \int_decr:N \l_clist_inline_level_int } } @@ -814,7 +809,8 @@ \def_new:Npn \clist_map_variable:nNn #1#2#3{ \tlist_if_empty:nF{#1} { - \clist_map_variable_aux:Nnw #2 {#3} #1 , \q_nil , \q_stop + \clist_map_variable_aux:Nnw #2 {#3} #1 + , \q_recursion_tail , \q_recursion_stop } } \def_new:Npn \clist_map_variable:NNn {\exp_args:No \clist_map_variable:nNn} @@ -831,7 +827,7 @@ % \begin{macrocode} \def_new:Npn \clist_map_variable_aux:Nnw #1#2#3,{ \def:Npn #1{#3} - \quark_if_nil:NT #1 \clist_map_break:w + \quark_if_recursion_tail_stop:N #1 #2 \clist_map_variable_aux:Nnw #1{#2} } % \end{macrocode} @@ -923,7 +919,7 @@ \if_meaning:NN #1 \scan_stop: % \end{macrocode} % \dots\ if \m{clist} equals |\scan_stop:| it is probably stemming -% from a |\cs:w ... \cd_end:| that was created by mistake somewhere. +% from a |\cs:w ... \cs_end:| that was created by mistake somewhere. % \begin{macrocode} \err_latex_bug:x {Comma~list~ `\token_to_string:N #1'~ has~ an~ erroneous~ structure!} diff --git a/Master/texmf-dist/source/latex/expl3/l3expan.dtx b/Master/texmf-dist/source/latex/expl3/l3expan.dtx index 8eaac134482..1efadb1dab3 100644 --- a/Master/texmf-dist/source/latex/expl3/l3expan.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3expan.dtx @@ -32,26 +32,21 @@ %% %% ----------------------------------------------------------------------- % -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3expan.dtx 573 2006-08-21 20:59:37Z morten $ +\GetIdInfo$Id: l3expan.dtx 735 2008-01-14 22:31:02Z morten $ {L3 Experimental Argument Expansion module} -% -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3expan.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -167,7 +162,8 @@ % functions is postponed until later. % \begin{description} % \item[d] This is pretty much like the |o| type except the token list -% get's expanded twice before being passed on. (|d| is for double) +% get's expanded twice before being passed on. (|d| is for double.) +% It is often useful in conjunction with a forced expansion. % % \item[E] Sometimes you need to unpack a token list or something else % but you don't want it to add the braces that the |o| type @@ -279,6 +275,20 @@ % "c", "N", "O", "o" or "f" in the last position) whenever possible. % \end{itemize} % +% +% When pdf\TeX\ 1.50 arrives, it will contain a primitive for +% performing the equivalent of an "x" expansion after only one +% expansion and most importantly: as an expandable operation. +% \begin{function}{% +% \exp_arg:x +% } +% \begin{syntax} +% " \exp_arg:x" "{" <arg> "}" +% \end{syntax} +% <arg> is expanded fully using an "x" expansion. +% \end{function} +% +% % \subsection{Manipulating the first argument} % % \begin{function}{% @@ -449,13 +459,15 @@ % \end{function} % % -% \begin{function}{\exp_not:o} +% \begin{function}{\exp_not:o | +% \exp_not:d | +% \exp_not:f} % \begin{syntax} % "\exp_not:o" "{"<token list>"}" % \end{syntax} -% Same as "\exp_not:n" except <token list> is expanded once and the -% result of this expansion is then prohibited from being expanded -% further. +% Same as "\exp_not:n" except <token list> is expanded once for the +% "o" type and twice for the "d" type and the result of this expansion +% is then prohibited from being expanded further. % \end{function} % % \begin{function}{\exp_not:E} @@ -474,6 +486,28 @@ % \end{function} % % +% \begin{function}{\exp_stop_f: } +% \begin{syntax} +% <f expansion> ... "\exp_stop_f:" +% \end{syntax} +% This function stops an "f" type expansion. An example use is one such as +% \begin{verbatim} +% \tlp_set:Nf \l_tmpa_tlp { +% \if_case:w \l_tmpa_int +% \or: \use_arg_i_after_orelse:nw{\exp_stop_f: \textbullet} +% \or: \use_arg_i_after_orelse:nw{\exp_stop_f: \textendash} +% \else: \use_arg_i_after_orelse:nw{\exp_stop_f: else-item} +% \fi: +% } +% \end{verbatim} +% This ensures the expansion in stopped right after finishing the +% conditional but without expanding "\textbullet" etc. +% \begin{texnote} +% This function is a space token but it is better to distinguish +% this expansion stopping token from a desired space token when +% writing code. +% \end{texnote} +% \end{function} % % % \begin{variable}{\l_exp_tlp | } @@ -489,6 +523,8 @@ % % We start by ensuring that the required packages are loaded. % \begin{macrocode} +%<package>\ProvidesExplPackage +%<package> {\filename}{\filedate}{\fileversion}{\filedescription} %<package>\RequirePackage{l3tlp} %<*initex|package> % \end{macrocode} @@ -515,12 +551,14 @@ % \end{macrocode} % \end{macro} % -% This code uses internal functions with names that start with |\::| -% to perform the expansions. +% This code uses internal functions with names that start with |\::| +% to perform the expansions. All macros are |long| as this turned out +% to be desirable since the tokens undergoing expansion may be +% arbitrary user input. % \begin{macro}{\exp_arg_next:nnn} % This is basically the same function as |\Dexp_arg_next:nnn|. % \begin{macrocode} -\def_new:Npn\exp_arg_next:nnn#1#2#3{ +\def_long_new:Npn\exp_arg_next:nnn#1#2#3{ #2\:::{#3#1} } % \end{macrocode} @@ -530,7 +568,7 @@ % This function is used to skip an argument that doesn't need to % be expanded. % \begin{macrocode} -\def_new:Npn\::n#1\:::#2#3{ +\def_long_new:Npn\::n#1\:::#2#3{ #1\:::{#2{#3}} } % \end{macrocode} @@ -541,7 +579,7 @@ % single token and doesn't need to be expanded. %^^A was \let_new:NN\::N\::n (changed to match \;N above. % \begin{macrocode} -\def_new:Npn\::N#1\:::#2#3{ +\def_long_new:Npn\::N#1\:::#2#3{ #1\:::{#2#3} } % \end{macrocode} @@ -551,7 +589,7 @@ % This function is used to skip an argument that is turned into % as control sequence without expansion. % \begin{macrocode} -\def_new:Npn\::c#1\:::#2#3{ +\def_long_new:Npn\::c#1\:::#2#3{ \exp_after:NN\exp_arg_next:nnn\cs:w #3\cs_end:{#1}{#2} } % \end{macrocode} @@ -560,7 +598,7 @@ % \begin{macro}{\::o} % This function is used to expand an argument once. % \begin{macrocode} -\def_new:Npn\::o#1\:::#2#3{ +\def_long_new:Npn\::o#1\:::#2#3{ \exp_after:NN\exp_arg_next:nnn\exp_after:NN{\exp_after:NN{#3}}{#1}{#2} } % \end{macrocode} @@ -568,43 +606,58 @@ % % % \begin{macro}{\::f} -% This function is used to expand a token list until the first -% unexpandable token is found. -% The underlying "\int_to_roman:w -`0" expands everything in its -% way to find something terminating the number and thereby expands the -% function in front of it. This scanning procedure is terminated once -% the expansion hits something non-expandable or a space; in case the -% scanner hits a number, this number also terminates the scanning and -% is left untouched. In the example shown earlier the scanning was -% stopped once \TeX{} had fully expanded -% "\let:Nc \aaa {b \l_tmpa_tlp b}" into "\let:NwN \aaa = \blurb" which -% then turned out to contain the non-expandable token "\let:NwN". -% Since the expansion of "\int_to_roman:w -`0" is \m{null}, we -% wind up with a fully expanded list, only \TeX{} has not tried to -% execute any of the non-expandable tokens. This is what -% differentiates this function from the "x" argument type. +% \begin{macro}{\exp_stop_f:} +% This function is used to expand a token list until the first +% unexpandable token is found. The underlying "\int_to_roman:w -`0" +% expands everything in its way to find something terminating the +% number and thereby expands the function in front of it. This +% scanning procedure is terminated once the expansion hits +% something non-expandable or a space. We introduce "\exp_stop_f:" +% to mark such an end of expansion marker; in case the scanner hits +% a number, this number also terminates the scanning and is left +% untouched. In the example shown earlier the scanning was stopped +% once \TeX{} had fully expanded "\let:Nc \aaa {b \l_tmpa_tlp b}" +% into "\let:NwN \aaa = \blurb" which then turned out to contain +% the non-expandable token "\let:NwN". Since the expansion of +% "\int_to_roman:w -`0" is \m{null}, we wind up with a fully +% expanded list, only \TeX{} has not tried to execute any of the +% non-expandable tokens. This is what differentiates this function +% from the "x" argument type. % \begin{macrocode} -\def_new:Npn\::f#1\:::#2#3{ +\def_long_new:Npn\::f#1\:::#2#3{ \exp_after:NN\exp_arg_next:nnn \exp_after:NN{\exp_after:NN{\int_to_roman:w -`0 #3}} {#1}{#2} } +\def_new:Npn \exp_stop_f: {~} % \end{macrocode} % \end{macro} +% \end{macro} % % \begin{macro}{\::x} -% This function is used to expand an argument fully. +% This function is used to expand an argument fully. If the +% pdf\TeX\ primitive "\expanded" is present, we use it. % \begin{macrocode} -\def_new:Npn\::x#1\:::#2#3{ - \tlp_set:Nx\l_exp_tlp{{{#3}}} - \exp_after:NN\exp_arg_next:nnn\l_exp_tlp{#1}{#2}} +\let_new:NN \exp_arg:x \expanded % Move eventually. +\cs_if_free:NTF\exp_arg:x{ + \def_long_new:Npn\::x#1\:::#2#3{ + % \tlp_set:Nx\l_exp_tlp{{{#3}}} + \def:Npx \l_exp_tlp{{{#3}}} + \exp_after:NN\exp_arg_next:nnn\l_exp_tlp{#1}{#2}} +} +{ + \def_long_new:Npn\::x#1\:::#2#3{ + \exp_after:NN\exp_arg_next:nnn + \exp_after:NN{\exp_arg:x{{#3}}}{#1}{#2} + } +} % \end{macrocode} % \end{macro} % % \begin{macro}{\:::} % Just another name for the identity function. % \begin{macrocode} -\def_new:Npn\:::#1{#1} +\def_long_new:Npn\:::#1{#1} % \end{macrocode} % \end{macro} % @@ -612,7 +665,7 @@ % This function creates a control sequence out of |#3| and expands % that once before passing it on to |\exp_arg_next:nnn|. % \begin{macrocode} -\def_new:Npn\::C#1\:::#2#3{ +\def_long_new:Npn\::C#1\:::#2#3{ \exp_after:NN\exp_C_aux:nnn\cs:w #3\cs_end:{#1}{#2}} % \end{macrocode} % \end{macro} @@ -621,8 +674,7 @@ % A helper function for |\::C| wich expands its argument before % passing it on to |\exp_arg_next:nnn|. % \begin{macrocode} -\def_new:Npn\exp_C_aux:nnn #1 - { +\def_long_new:Npn\exp_C_aux:nnn #1{ \exp_after:NN \exp_arg_next:nnn \exp_after:NN @@ -630,7 +682,7 @@ \exp_after:NN {#1} } - } +} % \end{macrocode} % \end{macro} % @@ -641,7 +693,7 @@ % comfortable about your input! Actually this is pretty much just % generic wrapper for |\exp_after:NN|. % \begin{macrocode} -\def:Npn\::E#1\:::#2#3{ +\def_long_new:Npn\::E#1\:::#2#3{ \exp_after:NN\exp_arg_next:nnn \exp_after:NN{#3}{#1}{#2} } % \end{macrocode} @@ -650,7 +702,7 @@ % \begin{macro}{\::e} % Same as |\::E| really but conceptually they are different. % \begin{macrocode} -\def:Npn\::e#1\:::#2#3{ +\def_long_new:Npn\::e#1\:::#2#3{ \exp_after:NN\exp_arg_next:nnn \exp_after:NN{#3}{#1}{#2} } % \end{macrocode} @@ -660,7 +712,7 @@ % This function is used to expand an argument twice. Mostly useful % for |toks| type things. % \begin{macrocode} -\def:Npn\::d#1\:::#2#3{ +\def_long_new:Npn\::d#1\:::#2#3{ \exp_after:NN\exp_after:NN\exp_after:NN\exp_arg_next:nnn \exp_after:NN\exp_after:NN\exp_after:NN{ \exp_after:NN\exp_after:NN\exp_after:NN{#3}}{#1}{#2} @@ -706,50 +758,56 @@ % \begin{macro}{\exp_args:Nxx} % \begin{macro}{\exp_args:NNC} % \begin{macro}{\exp_args:Nnnc} +% \begin{macro}{\exp_args:NNnx} +% \begin{macro}{\exp_args:NNoo} +% \begin{macro}{\exp_args:NNox} % Here are the actual function definitions, using the helper functions % above. % \begin{macrocode} -\def:Npn \exp_args:NC {\::C\:::} +%\def:Npn \exp_args:NNNo {\::N\::N\::o\:::} +%\def:Npn \exp_args:NNOo {\::N\::O\::o\:::} +%\def:Npn \exp_args:NNc {\::N\::c\:::} +%\def:Npn \exp_args:NNo {\::N\::o\::\:::} +%\def:Npn \exp_args:NOOo {\::O\::O\::o\:::} +%\def:Npn \exp_args:NOc {\::O\::c\:::} +%\def:Npn \exp_args:NOo {\::O\::o\:::} %\def:Npn \exp_args:Nc {\::c\:::} %\def:Npn \exp_args:Ncc {\::c\::c\:::} %\def:Npn \exp_args:Nccc {\::c\::c\::c\:::} -\def:Npn \exp_args:Ncx {\::c\::x\:::} -\def:Npn \exp_args:Ncco {\::c\::c\::o\:::} -\def:Npn \exp_args:Nccx {\::c\::c\::x\:::} -\def:Npn \exp_args:Ncnx {\::c\::n\::x\:::} +%\def:Npn \exp_args:Nco {\::c\::o\:::} +%\def:Npn \exp_args:No {\::o\:::} + +\def:Npn \exp_args:NC {\::C\:::} +\def:Npn \exp_args:NNC {\::N\::C\:::} +\def:Npn \exp_args:NNf {\::N\::f\:::} +\def:Npn \exp_args:NNno {\::N\::n\::o\:::} +\def:Npn \exp_args:NNnx {\::N\::n\::x\:::} % new +\def:Npn \exp_args:NNoo {\::N\::o\::o\:::} % new +\def:Npn \exp_args:NNox {\::N\::o\::x\:::} % new +\def:Npn \exp_args:NNx {\::N\::x\:::} \def:Npn \exp_args:NcNc {\::c\::N\::c\:::} \def:Npn \exp_args:NcNo {\::c\::N\::o\:::} \def:Npn \exp_args:Ncco {\::c\::c\::o\:::} -%\def:Npn \exp_args:Nco {\::c\::o\:::} -%\def:Npn \exp_args:NNc {\::N\::c\:::} +\def:Npn \exp_args:Ncco {\::c\::c\::o\:::} +\def:Npn \exp_args:Nccx {\::c\::c\::x\:::} +\def:Npn \exp_args:Ncnx {\::c\::n\::x\:::} +\def:Npn \exp_args:Ncx {\::c\::x\:::} \def:Npn \exp_args:Nf {\::f\:::} -\def:Npn \exp_args:NNf {\::N\::f\:::} \def:Npn \exp_args:Nfo{\::f\::o\:::} \def:Npn \exp_args:Nnf {\::n\::f\:::} -%\def:Npn \exp_args:NNNo {\::N\::N\::o\:::} -\def:Npn \exp_args:NNno {\::N\::n\::o\:::} -%% Strange one this next one... -\def:Npn \exp_args:NnnN {\::n\::n\::N\:::} +\def:Npn \exp_args:NnnN {\::n\::n\::N\:::} %% Strange one this one... +\def:Npn \exp_args:Nnnc {\::n\::n\::c\:::} \def:Npn \exp_args:Nnno {\::n\::n\::o\:::} \def:Npn \exp_args:Nnnx {\::n\::n\::x\:::} -%\def:Npn \exp_args:NNo {\::N\::o\::\:::} \def:Npn \exp_args:Nno {\::n\::o\:::} -%\def:Npn \exp_args:NNOo {\::N\::O\::o\:::} \def:Npn \exp_args:Nnox {\::n\::o\::x\:::} -\def:Npn \exp_args:NNx {\::N\::x\:::} \def:Npn \exp_args:Nnx {\::n\::x\:::} -%\def:Npn \exp_args:No {\::o\:::} -%\def:Npn \exp_args:NOc {\::O\::c\:::} -%\def:Npn \exp_args:NOo {\::O\::o\:::} \def:Npn \exp_args:Noo {\::o\::o\:::} -%\def:Npn \exp_args:NOOo {\::O\::O\::o\:::} \def:Npn \exp_args:Noox {\::o\::o\::x\:::} \def:Npn \exp_args:Nox {\::o\::x\:::} \def:Npn \exp_args:Nx {\::x\:::} \def:Npn \exp_args:Nxo {\::x\::o\:::} \def:Npn \exp_args:Nxx {\::x\::x\:::} -\def:Npn \exp_args:NNC {\::N\::C\:::} -\def:Npn \exp_args:Nnnc {\::n\::n\::c\:::} % \end{macrocode} % \end{macro} % \end{macro} @@ -777,23 +835,36 @@ % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} % % % \subsubsection{Preventing expansion} % % % \begin{macro}{\exp_not:o} +% \begin{macro}{\exp_not:d} +% \begin{macro}{\exp_not:f} % \begin{macrocode} -\def_new:Npn\exp_not:o#1{\exp_not:n\exp_after:NN{#1}} +\def_long_new:Npn\exp_not:o#1{\exp_not:n\exp_after:NN{#1}} +\def_long_new:Npn\exp_not:d#1{ + \exp_not:n\exp_after:NN\exp_after:NN\exp_after:NN{#1} +} +\def_long_new:Npn\exp_not:f#1{ + \exp_not:n\exp_after:NN{\int_to_roman:w -`0 #1} +} % \end{macrocode} % \end{macro} +% \end{macro} +% \end{macro} % % \begin{macro}{\exp_not:E} % \begin{macro}{\exp_not:c} % Two helper functions, which we can probably live without it. % \begin{macrocode} \def_new:Npn\exp_not:E{\exp_after:NN\exp_not:N} -\def_new:Npn\exp_not:c#1{\exp_after:NN\exp_not:N\cs:w#1\cs_end:} +\def_long_new:Npn\exp_not:c#1{\exp_after:NN\exp_not:N\cs:w#1\cs_end:} % \end{macrocode} % \end{macro} % \end{macro} @@ -826,18 +897,18 @@ % syntax. It is important to see that these functions really need % single tokens as arguments whenever capital letters are used. % \begin{macrocode} -\def_new:Npn \exp_args:No #1#2{\exp_after:NN#1\exp_after:NN{#2}} -\def_new:Npn \exp_args:NOo #1#2#3{\exp_after:NN\exp_args:No \exp_after:NN#1 +\def_long_new:Npn \exp_args:No #1#2{\exp_after:NN#1\exp_after:NN{#2}} +\def_long_new:Npn \exp_args:NOo #1#2#3{\exp_after:NN\exp_args:No \exp_after:NN#1 \exp_after:NN#2\exp_after:NN{#3}} -\def_new:Npn \exp_args:NOOo #1#2#3#4{\exp_after:NN\exp_args:NOo +\def_long_new:Npn \exp_args:NOOo #1#2#3#4{\exp_after:NN\exp_args:NOo \exp_after:NN#1\exp_after:NN#2\exp_after:NN#3\exp_after:NN{#4}} -\def_new:Npn \exp_args:NNo #1#2#3{\exp_after:NN#1\exp_after:NN#2 +\def_long_new:Npn \exp_args:NNo #1#2#3{\exp_after:NN#1\exp_after:NN#2 \exp_after:NN{#3}} -\def_new:Npn \exp_args:NNO #1#2#3 {\exp_after:NN#1 +\def_long_new:Npn \exp_args:NNO #1#2#3 {\exp_after:NN#1 \exp_after:NN#2 #3} -\def_new:Npn \exp_args:NNOo #1#2#3#4{\exp_after:NN\exp_args:NNo +\def_long_new:Npn \exp_args:NNOo #1#2#3#4{\exp_after:NN\exp_args:NNo \exp_after:NN#1\exp_after:NN#2\exp_after:NN#3\exp_after:NN{#4}} -\def_new:Npn \exp_args:NNNo #1#2#3#4{\exp_after:NN#1\exp_after:NN#2 +\def_long_new:Npn \exp_args:NNNo #1#2#3#4{\exp_after:NN#1\exp_after:NN#2 \exp_after:NN#3\exp_after:NN{#4}} % \end{macrocode} % \end{macro} @@ -857,14 +928,14 @@ % Here are the functions that turn their argument into csnames but % are expandable. % \begin{macrocode} -\def_new:Npn \exp_args:Nc #1#2{\exp_after:NN#1\cs:w#2\cs_end:} -\def_new:Npn \exp_args:NNc #1#2#3{\exp_after:NN#1\exp_after:NN#2 +\def_long_new:Npn \exp_args:Nc #1#2{\exp_after:NN#1\cs:w#2\cs_end:} +\def_long_new:Npn \exp_args:NNc #1#2#3{\exp_after:NN#1\exp_after:NN#2 \cs:w#3\cs_end:} -\def_new:Npn \exp_args:NOc#1#2#3{\exp_after:NN\exp_args:No\exp_after:NN +\def_long_new:Npn \exp_args:NOc#1#2#3{\exp_after:NN\exp_args:No\exp_after:NN #1\exp_after:NN#2\cs:w#3\cs_end:} -\def_new:Npn \exp_args:Ncc #1#2#3{\exp_after:NN#1 +\def_long_new:Npn \exp_args:Ncc #1#2#3{\exp_after:NN#1 \cs:w#2\exp_after:NN\cs_end:\cs:w#3\cs_end:} -\def_new:Npn \exp_args:Nccc #1#2#3#4{\exp_after:NN#1 +\def_long_new:Npn \exp_args:Nccc #1#2#3#4{\exp_after:NN#1 \cs:w#2\exp_after:NN\cs_end:\cs:w#3\exp_after:NN \cs_end:\cs:w #4\cs_end:} % \end{macrocode} @@ -880,7 +951,7 @@ % always has braces, we could implement this function % with less tokens and only two arguments. % \begin{macrocode} -\def_new:Npn \exp_args:Nco #1#2#3{\exp_after:NN#1\cs:w#2\exp_after:NN +\def_long_new:Npn \exp_args:Nco #1#2#3{\exp_after:NN#1\cs:w#2\exp_after:NN \cs_end:\exp_after:NN{#3}} % \end{macrocode} % \end{macro} diff --git a/Master/texmf-dist/source/latex/expl3/l3final.dtx b/Master/texmf-dist/source/latex/expl3/l3final.dtx index 2eb42fb4a41..f23db756876 100644 --- a/Master/texmf-dist/source/latex/expl3/l3final.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3final.dtx @@ -32,31 +32,26 @@ %% %% ----------------------------------------------------------------------- % -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> +%<*-ini> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -%<*!ini> -\GetIdInfo$Id: l3final.dtx 573 2006-08-21 20:59:37Z morten $ +\GetIdInfo$Id: l3final.dtx 621 2007-09-01 20:14:19Z morten $ {L3 Experimental final module} -%</!ini> -% -% \iffalse +%\iffalse +%</-ini> %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3final.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> -% \fi +%\fi % % \section{Final Wrap-up} % diff --git a/Master/texmf-dist/source/latex/expl3/l3int.dtx b/Master/texmf-dist/source/latex/expl3/l3int.dtx index f4e582ec12f..ccc30e7dd83 100644 --- a/Master/texmf-dist/source/latex/expl3/l3int.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3int.dtx @@ -32,26 +32,21 @@ %% %% ----------------------------------------------------------------------- % -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3int.dtx 573 2006-08-21 20:59:37Z morten $ +\GetIdInfo$Id: l3int.dtx 702 2007-11-27 14:21:49Z morten $ {L3 Experimental Integer module} -% -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3int.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -99,6 +94,7 @@ % % \begin{function}{% % \int_incr:N | +% \int_incr:c | % \int_gincr:N | % \int_gincr:c | % } @@ -111,6 +107,7 @@ % % \begin{function}{% % \int_decr:N | +% \int_decr:c | % \int_gdecr:N | % \int_gdecr:c | % } @@ -154,6 +151,7 @@ % \int_add:Nn | % \int_add:cn | % \int_gadd:Nn | +% \int_gadd:cn | % } % \begin{syntax} % "\int_add:Nn" <int> "{" <integer expr> "}" @@ -165,7 +163,9 @@ % % \begin{function}{% % \int_sub:Nn | +% \int_sub:cn | % \int_gsub:Nn | +% \int_gsub:cn | % } % \begin{syntax} % "\int_gsub:Nn" <int> "{" <integer expr> "}" @@ -356,6 +356,25 @@ % \end{function} % % \begin{function}{% +% \int_max_of:nn | +% \int_min_of:nn | +% } +% \begin{syntax} +% "\int_max_of:nn" "{"<int~expr>"}" "{"<int~expr>"}" +% \end{syntax} +% Return the largest or smallest of two integer expressions. +% \end{function} +% +% \begin{function}{% +% \int_abs:n | +% } +% \begin{syntax} +% "\int_abs:n" "{"<int~expr>"}" +% \end{syntax} +% Return the numerical value of an integer expression. +% \end{function} +% +% \begin{function}{% % \int_if_odd:nTF | % \int_if_odd_p:n | % } @@ -419,6 +438,8 @@ % % We start by ensuring that the required packages are loaded. % \begin{macrocode} +%<package>\ProvidesExplPackage +%<package> {\filename}{\filedate}{\fileversion}{\filedescription} %<package&!check>\RequirePackage{l3num} %<package&check>\RequirePackage{l3chk} %<*initex|package> @@ -443,6 +464,10 @@ % \begin{macro}{\int_decr:N} % \begin{macro}{\int_gincr:N} % \begin{macro}{\int_gdecr:N} +% \begin{macro}{\int_incr:c} +% \begin{macro}{\int_decr:c} +% \begin{macro}{\int_gincr:c} +% \begin{macro}{\int_gdecr:c} % Incrementing and decrementing of integer registers is done with % the following functions. % \begin{macrocode} @@ -485,11 +510,19 @@ \def:Npn \int_decr:N #1{\int_add:Nn#1\c_minus_one} \def:Npn \int_gincr:N #1{\int_gadd:Nn#1\c_one} \def:Npn \int_gdecr:N #1{\int_gadd:Nn#1\c_minus_one} +\def:Npn \int_incr:c {\exp_args:Nc\int_incr:N} +\def:Npn \int_decr:c {\exp_args:Nc\int_decr:N} +\def:Npn \int_gincr:c {\exp_args:Nc\int_gincr:N} +\def:Npn \int_gdecr:c {\exp_args:Nc\int_gdecr:N} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} % % % \begin{macro}{\int_new:N} @@ -556,8 +589,11 @@ % \begin{macro}{\int_add:Nn} % \begin{macro}{\int_add:cn} % \begin{macro}{\int_gadd:Nn} +% \begin{macro}{\int_gadd:cn} % \begin{macro}{\int_sub:Nn} +% \begin{macro}{\int_sub:cn} % \begin{macro}{\int_gsub:Nn} +% \begin{macro}{\int_gsub:cn} % Adding and substracting to and from a counter \ldots % We should think of using these functions % \begin{macrocode} @@ -591,12 +627,18 @@ %</check> %<-check> \pref_global:D \int_sub:Nn } +\def_new:Npn \int_gadd:cn{\exp_args:Nc\int_gadd:Nn} +\def_new:Npn \int_sub:cn{\exp_args:Nc\int_sub:Nn} +\def_new:Npn \int_gsub:cn{\exp_args:Nc\int_gsub:Nn} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} % % % \begin{macro}{\int_use:N} @@ -610,15 +652,6 @@ % \end{macro} % % -% \begin{macro}{\int_gincr:c} -% \begin{macro}{\int_gdecr:c} -% We also need \ldots -% \begin{macrocode} -\def_new:Npn \int_gincr:c {\exp_args:Nc \int_gincr:N} -\def_new:Npn \int_gdecr:c {\exp_args:Nc \int_gdecr:N} -% \end{macrocode} -% \end{macro} -% \end{macro} % % % \begin{macro}{\int_to_arabic:n} @@ -782,7 +815,7 @@ % Turning a number into a symbol is also easy enough. % \begin{macrocode} \def_new:Npn \int_to_symbol:n #1{ - \mode_math:TF + \mode_if_math:TF { \int_convert_number_with_rule:nnN {#1}{9} \int_symbol_math_conversion_rule:n @@ -896,8 +929,38 @@ \def_new:Npn \int_div_truncate:nn { \int_pre_eval_two_args:Nnn\int_div_truncate_raw:nn } +% \end{macrocode} +% Initial version didn't work correctly with e\TeX's implementation. +% \begin{macrocode} +%\def_new:Npn \int_div_truncate_raw:nn #1#2 { +% \int_eval:n{ (2*#1 - #2) / (2* #2) } +%} +% \end{macrocode} +% New version by Heiko: +% \begin{macrocode} \def_new:Npn \int_div_truncate_raw:nn #1#2 { - \int_eval:n{ (2*#1 - #2) / (2* #2) } + \int_eval:w + \if_num:w \int_eval:w#1 = \c_zero + 0 + \else: + (#1 + \if_num:w \int_eval:w #1 < \c_zero + \if_num:w \int_eval:w#2 < \c_zero + -( #2 + + \else: + +( #2 - + \fi: + \else: + \if_num:w \int_eval:w #2 < \c_zero + +( #2 + + \else: + -( #2 - + \fi: + \fi: + 1)/2) + \fi: + /(#2) + \scan_stop: } % \end{macrocode} % For the sake of completeness: @@ -935,6 +998,20 @@ % \end{macro} % \end{macro} % +% \begin{macro}{\int_max_of:nn} +% \begin{macro}{\int_min_of:nn} +% \begin{macro}{\int_abs:n} +% Simple comparison tests. +% \begin{macrocode} +\let_new:NN \int_max_of:nn \num_max_of:nn +\let_new:NN \int_min_of:nn \num_min_of:nn +\let_new:NN \int_abs:nn \num_abs:nn +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% % \begin{macro}{\int_compare_p:nNn} % A predicate function. % \begin{macrocode} @@ -968,18 +1045,19 @@ % \begin{macro}{\int_dowhile:nNnF} % These are quite easy given the above functions. The "while" versions % test first and then execute the body. The "dowhile" does it the -% other way round. +% other way round. The have to be defined as ``long'' since the "T" argument +% might contain "\par" tokens. % \begin{macrocode} -\def_new:Npn \int_whiledo:nNnT #1#2#3#4{ +\def_long_new:Npn \int_whiledo:nNnT #1#2#3#4{ \int_compare:nNnT {#1}#2{#3}{#4 \int_whiledo:nNnT {#1}#2{#3}{#4}} } -\def_new:Npn \int_whiledo:nNnF #1#2#3#4{ +\def_long_new:Npn \int_whiledo:nNnF #1#2#3#4{ \int_compare:nNnF {#1}#2{#3}{#4 \int_whiledo:nNnF {#1}#2{#3}{#4}} } -\def_new:Npn \int_dowhile:nNnT #1#2#3#4{ +\def_long_new:Npn \int_dowhile:nNnT #1#2#3#4{ #4 \int_compare:nNnT {#1}#2{#3}{\int_dowhile:nNnT {#1}#2{#3}{#4}} } -\def_new:Npn \int_dowhile:nNnF #1#2#3#4{ +\def_long_new:Npn \int_dowhile:nNnF #1#2#3#4{ #4 \int_compare:nNnF {#1}#2{#3}{\int_dowhile:nNnF {#1}#2{#3}{#4}} } % \end{macrocode} diff --git a/Master/texmf-dist/source/latex/expl3/l3io.dtx b/Master/texmf-dist/source/latex/expl3/l3io.dtx index 04efa42b8d7..b382744776b 100644 --- a/Master/texmf-dist/source/latex/expl3/l3io.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3io.dtx @@ -32,26 +32,21 @@ %% %% ----------------------------------------------------------------------- % -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3io.dtx 573 2006-08-21 20:59:37Z morten $ +\GetIdInfo$Id: l3io.dtx 621 2007-09-01 20:14:19Z morten $ {L3 Experimental i/o module} -% -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3io.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -298,6 +293,8 @@ % % We start by ensuring that the required packages are loaded. % \begin{macrocode} +%<package>\ProvidesExplPackage +%<package> {\filename}{\filedate}{\fileversion}{\filedescription} %<package&check>\RequirePackage{l3chk}\par %<package>\RequirePackage{l3toks}\par %<*initex|package> diff --git a/Master/texmf-dist/source/latex/expl3/l3keyval.dtx b/Master/texmf-dist/source/latex/expl3/l3keyval.dtx index 8848946602a..4134b0fef51 100644 --- a/Master/texmf-dist/source/latex/expl3/l3keyval.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3keyval.dtx @@ -31,29 +31,26 @@ %% prior consultation with the LaTeX Project Team. %% %% ----------------------------------------------------------------------- -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3keyval.dtx 573 2006-08-21 20:59:37Z morten $ +\GetIdInfo$Id: l3keyval.dtx 621 2007-09-01 20:14:19Z morten $ {L3 Experimental keyval processing} -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3keyval.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi % +% % \title{The \textsf{l3keyval} package\thanks{This file % has version number \fileversion, last % revised \filedate.}\\ @@ -185,6 +182,8 @@ % We start by ensuring that the required packages are loaded. % \begin{macrocode} %<*package> +\ProvidesExplPackage + {\filename}{\filedate}{\fileversion}{\filedescription} \RequirePackage{l3quark} \RequirePackage{l3toks} \RequirePackage{l3int} diff --git a/Master/texmf-dist/source/latex/expl3/l3messages.dtx b/Master/texmf-dist/source/latex/expl3/l3messages.dtx index 5aea5a26d35..b5ae9e6025f 100644 --- a/Master/texmf-dist/source/latex/expl3/l3messages.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3messages.dtx @@ -1,5 +1,5 @@ % \iffalse -%% File: l3messages.dtx Copyright (C) 1990-2006 LaTeX3 project +%% File: l3messages.dtx Copyright (C) 1990-2007 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 @@ -32,33 +32,21 @@ %% %% ----------------------------------------------------------------------- % -%<package>\RequirePackage{l3names} -%<package>\RequirePackage{l3basics} -%<package>\RequirePackage{l3tlp} -%<package>\RequirePackage{l3expan} -%<package>\RequirePackage{l3num} -%<package>\RequirePackage{l3io} -%<package>\RequirePackage{l3int} -%<package>\RequirePackage{l3toks} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3messages.dtx 573 2006-08-21 20:59:37Z morten $ +\GetIdInfo$Id: l3messages.dtx 673 2007-09-28 20:50:33Z mittelba $ {L3 Experimental LaTeX Messages module} -% -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3messages.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -129,7 +117,8 @@ % \end{syntax} % Is used to break an informational, warning or error message up % into multiple lines. May be defined in such a way that the new -% line starts with a standard <continuation>. +% line starts with a standard <continuation>. A normal line break in such +% messages can be achieved with "\iow_newline:" from the l3iow module. % \end{function} % % \subsection{Storing the information} @@ -264,11 +253,6 @@ % % \subsection{Variables and constants} % -% \begin{variable}{\iow_newline} -% Identifier denoting the character that triggers a line break in -% the output. -% \end{variable} -% % \begin{variable}{\c_iow_err_stream} % Output stream used to access the error files during their % generation. @@ -312,6 +296,16 @@ % \subsection{The implementation} % % \begin{macrocode} +%<package>\ProvidesExplPackage +%<package> {\filename}{\filedate}{\fileversion}{\filedescription} +%<package>\RequirePackage{l3basics} +%<package>\RequirePackage{l3tlp} +%<package>\RequirePackage{l3expan} +%<package>\RequirePackage{l3num} +%<package>\RequirePackage{l3io} +%<package>\RequirePackage{l3int} +%<package>\RequirePackage{l3toks} +%<package>\RequirePackage{l3token} %<*initex|package> % \end{macrocode} % @@ -453,13 +447,13 @@ % \end{macrocode} % Make sure that the \emph{continuation} is part of "\err_newline:". % \begin{macrocode} - \def:Npn\err_newline:{\iow_newline#2} + \def:Npn\err_newline:{\iow_newline:#2} % \end{macrocode} % Then write the message. % \begin{macrocode} \io_put_log:x {#1~\io_show_file_lineno:}} \def_new:Npn \err_warn:nn #1#2{ - \def:Npn\err_newline:{\iow_newline#2} + \def:Npn\err_newline:{\iow_newline:#2} \io_put_term:x {#1~\io_show_file_lineno:}} % \end{macrocode} % \end{macro} @@ -471,10 +465,10 @@ % linenumber to the message. % \begin{macrocode} \def_new:Npn \err_info_noline:nn #1#2{ - \def:Npn\err_newline:{\iow_newline#2} + \def:Npn\err_newline:{\iow_newline:#2} \io_put_log:x {#1}} \def_new:Npn \err_warn_noline:nn #1#2{ - \def:Npn\err_newline:{\iow_newline#2} + \def:Npn\err_newline:{\iow_newline:#2} \io_put_term:x {#1}} % \end{macrocode} % \end{macro} @@ -522,7 +516,7 @@ % \end{macrocode} % Make sure that the \emph{continuation} is part of "\err_newline". % \begin{macrocode} - \def:Npn\err_newline:{\iow_newline#2} + \def:Npn\err_newline:{\iow_newline:#2} % \end{macrocode} % Then write the message. % \begin{macrocode} @@ -537,7 +531,7 @@ % occured. % \begin{macrocode} \def_new:Npn \err_fatal_noline:nn #1#2{ - \def:Npn\err_newline:{\iow_newline#2} + \def:Npn\err_newline:{\iow_newline:#2} \io_put_term:x {#1} \tex_end:D } @@ -610,9 +604,9 @@ {\err_latex_bug:x{You~closed~the~wrong~error~file~`#1'.~ Open~is~`\g_err_curr_fname'.}} \iow_long_unexpanded:Nn \c_iow_err_stream {\err_latex_bug:x{Didn't~find~the~ - correct~error~message~to~show.\iow_newline + correct~error~message~to~show.\iow_newline: Was~searching~for~a~function~ - with~the~following~meaning:\iow_newline + with~the~following~meaning:\iow_newline: \token_to_string:N\token_to_meaning:N \token_to_string:N\l_err_label_token} % \end{macrocode} @@ -651,7 +645,7 @@ % Both \m{errmsg} and \m{code} might contain hashmarks denoting % arguments to the error handler. % \begin{macrocode} - \group_begin: \tex_catcode:D`\#\c_other_char_code + \group_begin: \char_set_catcode:nn{`\#}{12} % \end{macrocode} % We also have to check that output goes to the correct error file. % \begin{macrocode} @@ -692,9 +686,9 @@ \cmd_declare:Nnn\err_display_aux:w [#2]{ \group_end: \toks_gset:Nx\g_err_help_toks{#4} - \io_put_term:x{LaTeX~error~\io_show_file_lineno:.\iow_newline + \io_put_term:x{LaTeX~error~\io_show_file_lineno:.\iow_newline: \text_put_sp:\text_put_four_sp: \text_put_sp: - See~LaTeX~manual~for~explanation.\iow_newline + See~LaTeX~manual~for~explanation.\iow_newline: \text_put_sp:\text_put_four_sp: \text_put_sp: Type~\text_put_sp: H~<return>~\text_put_sp: for~ immediate~help.} @@ -801,9 +795,9 @@ % \begin{macrocode} %<*package> \def:Npn\err_help_ignored: { - Your~command~was~ignored.\iow_newline + Your~command~was~ignored.\iow_newline: Type \text_put_sp: I~<command>~<return> - \text_put_sp: to~replace~it~with~another~command,\iow_newline + \text_put_sp: to~replace~it~with~another~command,\iow_newline: or~\text_put_sp: <return> \text_put_sp: to~continue~without~it.} \def:Npn\err_help_textlost: { @@ -811,7 +805,7 @@ \def:Npn\err_help_return_or_X: { Try~typing\text_put_sp: <return> - \text_put_sp: to~proceed.\iow_newline + \text_put_sp: to~proceed.\iow_newline: If~that~doesn't~work,~type \text_put_sp: X~<return>\text_put_sp: to~quit.} @@ -826,10 +820,10 @@ \err_kernel_interrupt_new:NNnnn\cs_free_p:N{1} {Command~name~`\tex_string:D#1'~already~used} {You~tried~to~define~a~command~which~already~has~ - a~meaning.\iow_newline + a~meaning.\iow_newline: If~you~really~want~to~redefine~it~try~ \token_to_string:N\cmd_declare:Nnn\text_put_sp: - next~time.\iow_newline + next~time.\iow_newline: For~this~run~I~will~ignore~your~definition.} {} @@ -842,7 +836,7 @@ \err_kernel_interrupt_new:NNnnn\newcnt{0} {No~such~counter} {The~counter~name~mentioned~in~the~operation~is~not~ - known~to~me.\iow_newline + known~to~me.\iow_newline: Check~the~spelling.} {} @@ -969,4 +963,4 @@ % % Revision 1.1 2005/04/29 22:30:44 braams % first version that can be loaded without producing errors. -% Just a translation from the old stuff, haven't looked at the docu yet
\ No newline at end of file +% Just a translation from the old stuff, haven't looked at the docu yet diff --git a/Master/texmf-dist/source/latex/expl3/l3names.dtx b/Master/texmf-dist/source/latex/expl3/l3names.dtx index e9345ce37e0..3bd4dbf2612 100644 --- a/Master/texmf-dist/source/latex/expl3/l3names.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3names.dtx @@ -39,33 +39,57 @@ \catcode`\#=6 % hash mark is macro parameter character \catcode`\^=7 % \catcode`\^^I=10 % ascii tab is a blank space -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \immediate\write-1{#1; v#2, #3/#4/#5; #8}% +%</initex> +%<package>\begingroup +%<*initex|package> +\def\GetIdInfo$#1 #2.#3 #4 #5 #6 #7${% + \GetIdInfoAux #5\relax{#2}#5\relax{#4}% +} +\def\GetIdInfoAux #1#2#3#4#5#6\relax{% + \ifx#5/% + \expandafter\GetIdInfoAuxCVS + \else + \expandafter\GetIdInfoAuxSVN + \fi +} +%</initex|package> +%<*initex> +\def\GetIdInfoAuxCVS #1#2\relax#3#4{% + \immediate\write-1{#1; v#2, #3; #4}% +} +\def\GetIdInfoAuxSVN #1#2-#3-#4\relax#5#6{% + \immediate\write-1{#1; #2/#3/#4 v#5 #6}% } %</initex> %<*package> -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesPackage{#1}[#3/#4/#5 v#2 #8]% +\def\GetIdInfoAuxCVS #1#2\relax#3#4{% + \gdef\fileversion{#3}% + \gdef\filedate{#2}% + \gdef\filedescription{#4}% + \ProvidesPackage{#1}[#2 v#3 #4]% } -%</package> -%<*dtx> -%\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% +\def\GetIdInfoAuxSVN #1#2-#3-#4\relax#5#6{% + \gdef\fileversion{#5}% + \gdef\filedate{#2/#3/#4}% + \gdef\filedescription{#6}% + \ProvidesPackage{#1}[#2/#3/#4 v#5 #6] } -%\iffalse -%</dtx> +%</package> +%<*driver> +\RequirePackage{l3names} +%</driver> %\fi -\GetIdInfo$Id: l3names.dtx 577 2006-11-21 18:10:26Z morten $ +\GetIdInfo$Id: l3names.dtx 621 2007-09-01 20:14:19Z morten $ {L3 Experimental Naming Scheme for TeX Primitives} % % % \iffalse +%<package>\endgroup %<*driver> +%\fi +\ProvidesFile{l3names.dtx} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} \begin{document} \DocInput{l3names.dtx} @@ -274,7 +298,7 @@ % % \end{description} % -% +% % % \section{Modules} % @@ -284,6 +308,75 @@ % with special prefixes, for example "\tlp_" is the prefix for functions % dealing with token list pointers. % +% \subsection{Using the modules} +% +% Most of the modules can be used on top of \LaTeX\ and are loaded +% with the usual "\usepackage" or "\RequirePackage" instructions. As +% the packages use a coding syntax different from standard \LaTeX\ it +% provides a few functions for setting it up. +% +% \begin{function}{ +% \ExplSyntaxOn | +% \ExplSyntaxOff +% } +% \begin{syntax} +% "\ExplSyntaxOn" <code> "\ExplSyntaxOff" +% \end{syntax} +% Issues a catcode regime where spaces are ignored and colon and +% underscore are letters. +% \end{function} +% +% \begin{function}{ +% l3names | +% \ProvidesExplPackage | +% \ProvidesExplClass +% } +% \begin{syntax} +% "\RequirePackage{l3names}" \\ +% "\ProvidesExplPackage" "{"<package>"}" +% "{"<date>"}" "{"<version>"}" "{"<description>"}" +% \end{syntax} +% The package "l3names" (this module) provides +% "\ProvidesExplPackage" which is a wrapper for "\ProvidesPackage" +% and sets up the \LaTeX3 catcode settings for programming +% automatically. Similar for the relationship between +% "\ProvidesExplClass" and "\ProvidesClass". Spaces are not ignored +% in the arguments of these commands. +% \end{function} +% +% \begin{function}{ +% \GetIdInfo | +% \filename | +% \filenameext | +% \filedate | +% \fileversion | +% \filetimestamp | +% \fileauthor +% } +% \begin{syntax} +% "\RequirePackage{l3names}" \\ +% "\GetIdInfo" "$Id:" <cvs or svn info field> "$" "{"<description>"}" +% \end{syntax} +% Extracts all information from a cvs or svn field. Spaces are not +% ignored in these fields. The information pieces are stored in +% separate control sequences with "\filename" for the part of the +% file name leading up to the period, "\filenameext" for the +% extension, "\filedate" for date, "\fileversion" for version, +% "\filetimestamp" for the time and "\fileauthor" for the author. +% \end{function} +% +% To summarize: Every single package using this syntax should identify +% itself using one of the above methods. Special care is taken so that +% every package or class file loaded with "\RequirePackage" or alike +% are loaded with usual \LaTeX\ catcodes and the \LaTeX3 catcode +% scheme is reloaded when needed afterwards. See implementation for +% details. If you use the "\GetIdInfo" command you can use the +% information when loading a package with +% \begin{verbatim} +% \ProvidesExplPackage{\filename}{\filedate}{\fileversion}{\filedescription} +% \end{verbatim} +% +% % % % \StopEventually{} @@ -306,15 +399,17 @@ \catcode`\^^I=10 % ascii tab is a blank space %</initex> % \end{macrocode} -% +% Reason for |\endlinechar=32| is that a line ending with a backslash +% will be interpreted as the token \verb*|\ | which seems most natural +% and since spaces are ignored it works as we intend elsewhere. % \begin{macrocode} %<*initex|package> -\catcode`\ =9\relax -\catcode`\^^I=9\relax -\catcode`\^^M=9\relax -\catcode`\~=10\relax -\catcode`\_=11\relax\catcode`\:=11\relax -\catcode`\@=11\relax % as long as we use old LaTeX stuff. +\catcode126=10\relax % tilde is a space char. +\catcode32=9\relax % space is ignored +\catcode9=9\relax % tab also ignored +\endlinechar=32\relax % endline is space +\catcode95=11\relax % underscore letter +\catcode58=11\relax % colon letter % \end{macrocode} % % @@ -332,7 +427,8 @@ % is run after the end of this file, to skip past the code which has % been inserted by \LaTeXe\ to manage the file name stack, this code % would break if run once the \TeX\ primitives have been undefined. -% (What a surprise!) +% (What a surprise!) \textbf{The option has been temporarily +% disabled.} % % To get things started, give a new name for |\let|. % \begin{macrocode} @@ -918,31 +1014,38 @@ % Here we define functions that are used to turn on and off the % special conventions used in the kernel of \LaTeX3. % -% First of all, the space, tab and the return characters will all be -% ignored inside \LaTeX3 code. When space characters are needed in -% \LaTeX3 code the |~| character will be used for that purpose. +% First of all, the space, tab and the return characters will all +% be ignored inside \LaTeX3 code, the latter because endline is set +% to a space instead. When space characters are needed in \LaTeX3 +% code the |~| character will be used for that purpose. % % \begin{macrocode} -\tex_def:D\CodeStart{% - \tex_catcode:D `\ =9\tex_relax:D - \tex_catcode:D `\^^M=9\tex_relax:D - \tex_catcode:D `\^^I=9\tex_relax:D - \tex_catcode:D `\~=10\tex_relax:D -%<!initex> \tex_catcode:D `\@=11\tex_relax:D % For LaTeX2e - \tex_catcode:D `\_=11\tex_relax:D - \tex_catcode:D `\:=11\tex_relax:D} +\tex_def:D\ExplSyntaxOn{ + \tex_def:D\ExplSyntaxStatus{00} + \tex_catcode:D 126=10 \tex_relax:D % tilde is a space char. + \tex_catcode:D 32=9 \tex_relax:D % space is ignored + \tex_catcode:D 9=9 \tex_relax:D % tab also ignored + \tex_endlinechar:D =32 \tex_relax:D % endline is space + \tex_catcode:D 95=11 \tex_relax:D % underscore letter + \tex_catcode:D 58=11 \tex_relax:D % colon letter +} % \end{macrocode} % % \begin{macrocode} -\tex_def:D\CodeStop{ - \tex_catcode:D `\ =10\tex_relax:D - \tex_catcode:D `\^^M=5\tex_relax:D - \tex_catcode:D `\^^I=10\tex_relax:D - \tex_catcode:D `\~=13\tex_relax:D -%<!initex> \tex_catcode:D `\@=12\tex_relax:D % For LaTeX2e - \tex_catcode:D `\_=8\tex_relax:D - \tex_catcode:D `\:=12\tex_relax:D} -%</initex|package> +\tex_def:D\ExplSyntaxOff{ + \tex_def:D\ExplSyntaxStatus{01} + \tex_catcode:D 126=13 \tex_relax:D + \tex_catcode:D 32=10 \tex_relax:D + \tex_catcode:D 9=10 \tex_relax:D + \tex_endlinechar:D =13 \tex_relax:D + \tex_catcode:D 95=8 \tex_relax:D + \tex_catcode:D 58=12 \tex_relax:D +} +% \end{macrocode} +% Temporary while names change. +% \begin{macrocode} +\tex_let:D \CodeStart \ExplSyntaxOn +\tex_let:D \CodeStop \ExplSyntaxOff % \end{macrocode} % \end{macro} % \end{macro} @@ -954,61 +1057,173 @@ % characters. These macros provide the necessary settings. % \begin{macrocode} \tex_def:D \NamesStart{ - \tex_catcode:D `\_=11\scan_stop: - \tex_catcode:D `\:=11\scan_stop: - } + \tex_catcode:D `\_=11\tex_relax:D + \tex_catcode:D `\:=11\tex_relax:D +} \tex_def:D \NamesStop{ - \tex_catcode:D `\_=8\scan_stop: - \tex_catcode:D `\:=12\scan_stop: - } + \tex_catcode:D `\_=8\tex_relax:D + \tex_catcode:D `\:=12\tex_relax:D +} % \end{macrocode} % \end{macro} % \end{macro} % +% \begin{macro}{\GetIdInfo} +% \begin{macro}{\GetIdInfoAuxi:w} +% \begin{macro}{\GetIdInfoAuxii:w} +% \begin{macro}{\GetIdInfoAuxCVS:w} +% \begin{macro}{\GetIdInfoAuxSVN:w} +% Extract all information from a cvs or svn field. The +% formats are slightly different but at least the information is in +% the same positions so we check in the date format so see if it +% contains a "/" after the four-digit year. If it does it is cvs +% else svn and we extract information. To be on the safe side we +% ensure that spaces in the argument are seen. % \begin{macrocode} -%<*initex> -\tex_def:D\GetIdInfo{\CodeStop\GetIdInfoAux} -\tex_def:D\GetIdInfoAux$#1~#2.dtx~#3~#4-#5-#6~#7~#8$#9{% - \tex_immediate:D\tex_write:D-1{#2;~v#3,~#4/#5/#6;~#9}% - \CodeStart +\tex_def:D\GetIdInfo{ + \tex_begingroup:D + \tex_catcode:D 32=10 \tex_relax:D % needed? Probably for now. + \GetIdInfoAuxi:w } -%</initex> +\tex_def:D\GetIdInfoAuxi:w$#1~#2.#3~#4~#5~#6~#7~#8$#9{ + \tex_endgroup:D + \tex_def:D\filename{#2} + \tex_def:D\fileversion{#4} + \tex_def:D\filedescription{#9} + \tex_def:D\fileauthor{#7} + \GetIdInfoAuxii:w #5\tex_relax:D + #3\tex_relax:D#5\tex_relax:D#6\tex_relax:D +} +\tex_def:D\GetIdInfoAuxii:w #1#2#3#4#5#6\tex_relax:D{ + \tex_ifx:D#5/ + \tex_expandafter:D\GetIdInfoAuxCVS:w + \tex_else:D + \tex_expandafter:D\GetIdInfoAuxSVN:w + \tex_fi:D +} +\tex_def:D\GetIdInfoAuxCVS:w #1,v\tex_relax:D + #2\tex_relax:D#3\tex_relax:D{ + \tex_def:D\filedate{#2} + \tex_def:D\filenameext{#1} + \tex_def:D\filetimestamp{#3} +% \end{macrocode} +% When creating the format we want the information in the log straight +% away. +% \begin{macrocode} +%<initex>\tex_immediate:D\tex_write:D-1 +%<initex> {\filename;~ v\fileversion,~\filedate;~\filedescription} +} +\tex_def:D\GetIdInfoAuxSVN:w #1\tex_relax:D#2-#3-#4 + \tex_relax:D#5Z\tex_relax:D{ + \tex_def:D\filenameext{#1} + \tex_def:D\filedate{#2/#3/#4} + \tex_def:D\filetimestamp{#5} +%<-package>\tex_immediate:D\tex_write:D-1 +%<-package> {\filename;~ v\fileversion,~\filedate;~\filedescription} +} +%</initex|package> % \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} % % Finally some corrections in the case we are running over \LaTeXe. % -% Every single experimental package should start by doing something -% like this: +% +% +% We want to set things up so that experimental packages and regular +% packages can coexist with the former using the \LaTeX3 programming +% catcode settings. Since it cannot be the task of the end user to +% know how a package is constructed under the hood we make it so that +% the experimental packages have to identify themselves. As an example +% it can be done as % \begin{verbatim} % \RequirePackage{l3names} -% \GetIdInfo$Id: l3names.dtx 577 2006-11-21 18:10:26Z morten $ -% {L3 Experimental sequences and stacks} +% \ProvidesExplPackage{agent}{2007/08/28}{007}{bonding module} % \end{verbatim} -% \emph{OR} +% or by using the "\file"\meta{field} informations from "\GetIdInfo" +% as the packages in this distribution do like this: % \begin{verbatim} % \RequirePackage{l3names} -% \CodeStart +% \GetIdInfo$Id: l3names.dtx 621 2007-09-01 20:14:19Z morten $ +% {L3 Experimental Box module} +% \ProvidesExplPackage +% {\filename}{\filedate}{\fileversion}{\filedescription} % \end{verbatim} -% Since we have to make |\GetIdInfo| stop the special catcode regime -% when reading the package in order to get the information extracted -% correctly, we might as well use it to also issue |\CodeStart|. This -% also means that we automatically get |\CodeStart| issued at the -% beginning of every package without tampering with |\ProvidesPackage| -% which can cause problems when using these experimental packages with -% code relying on characters having traditional catcodes, noticeably -% the catcode of the space character. We cannot simply use the code -% from the top of this file since it contains a call to |\def| which -% may not exist at this point. +% +% +% \begin{macro}{\ProvidesExplPackage} +% \begin{macro}{\ProvidesExplClass} +% First up is the identification. Rather trivial % \begin{macrocode} %<*package> -\tex_def:D\GetIdInfo{\CodeStop\GetIdInfoAux} -\tex_def:D\GetIdInfoAux$#1~#2.dtx~#3~#4-#5-#6~#7~#8$#9{% - \tex_def:D \fileversion{#3}% - \tex_def:D \filedate{#4/#5/#6}% - \ProvidesPackage{#2}[#4/#5/#6~ v#3~ #9]% - \CodeStart +\tex_def:D \ProvidesExplPackage#1#2#3#4{ + \ProvidesPackage{#1}[#2~v#3~#4] + \ExplSyntaxOn } -% \end{macrocode} +\tex_def:D \ProvidesExplClass#1#2#3#4{ + \ProvidesClass{#1}[#2~v#3~#4] + \ExplSyntaxOn +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\org@onefilewithoptions} +% \begin{macro}{\@onefilewithoptions} +% \begin{macro}{\@popfilename} +% The idea behind the code is to record whether or not the \LaTeX3 +% syntax is on or off when about to load a file with class or +% package extension. This status stored in the parameter +% |\ExplSyntaxStatus| and set by |\ExplSyntaxOn| and +% |\ExplSyntaxOff| to |00| and |01| respectively is puched onto the +% stack |\ExplSyntaxStack|. Then the catcodes are set back to +% normal, the file loaded with its options and finally the stack is +% popped again. +% +% |\@popfilename| is appended with a preamble check. If the catcode +% of "@" is being reset it is a fair assumption that we are back in +% the usual preamble and so we switch off our syntax as well. +% \begin{macrocode} +\tex_let:D \org@onefilewithoptions\@onefilewithoptions +\tex_def:D \@onefilewithoptions#1[#2][#3]#4{ + \tex_edef:D \ExplSyntaxStack{ \ExplSyntaxStatus\ExplSyntaxStack } + \ExplSyntaxOff + \org@onefilewithoptions{#1}[{#2}][{#3}]{#4} + \tex_expandafter:D\ExplSyntaxPopStack\ExplSyntaxStack\tex_relax:D +} +\g@addto@macro\@popfilename{% + \tex_ifnum:D\tex_the:D\tex_catcode:D`\@=12\tex_relax:D + \ExplSyntaxOff + \tex_fi:D +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\ExplSyntaxPopStack} +% \begin{macro}{\ExplSyntaxStack} +% Popping the stack is simple: Take the first two tokens which are +% either the sequence "00" or "01" and use them in an if test. The +% stack is initially empty. +% \begin{macrocode} +\tex_def:D\ExplSyntaxPopStack#1#2#3\tex_relax:D{ + \tex_def:D\ExplSyntaxStack{#3} + \tex_if:D#1#2 + \ExplSyntaxOn + \tex_else:D + \ExplSyntaxOff + \tex_fi:D +} +\tex_def:D\ExplSyntaxStack{} +% \end{macrocode} +% \end{macro} +% \end{macro} +% % % A few of the `primitives' assigned above have already been stolen % by \LaTeX, so assign them by hand to the saved real primitive. @@ -1034,14 +1249,9 @@ \tex_ifx:D\name_undefine:N\@gobble % \end{macrocode} % -% Normally just set the catcodes, and let \LaTeXe\ handle the -% package stack. If \LaTeXe\ resets @ reset the white space as well. % \begin{macrocode} + \AtEndOfPackage{\ExplSyntaxOff} \tex_def:D\name_pop_stack:w{} - \g@addto@macro\@popfilename{% - \tex_ifnum:D12=\tex_the:D\tex_catcode:D`@ - \CodeStop - \tex_fi:D} % \end{macrocode} % % \begin{macrocode} @@ -1059,7 +1269,7 @@ % \begin{macrocode} \tex_def:D\ProvidesPackage{ \tex_begingroup:D - \CodeStop + \ExplSyntaxOff \package_provides:w} % \end{macrocode} % @@ -1079,7 +1289,7 @@ % one file, with no options. % \begin{macrocode} \tex_def:D\name_pop_stack:w#1\relax{% - \CodeStop + \ExplSyntaxOff \tex_expandafter:D\@p@pfilename\@currnamestack\@nil \tex_let:D\default@ds\@unknownoptionerror \tex_global:D\tex_let:D\ds@\@empty @@ -1099,7 +1309,7 @@ \tex_def:D\RequirePackage#1{ \tex_expandafter:D\tex_ifx:D \tex_csname:D ver@#1.sty\tex_endcsname:D\tex_relax:D - \CodeStart + \ExplSyntaxOn \tex_input:D#1.sty\tex_relax:D \tex_fi:D} \tex_fi:D diff --git a/Master/texmf-dist/source/latex/expl3/l3num.dtx b/Master/texmf-dist/source/latex/expl3/l3num.dtx index e74c57db79b..624cd7668e5 100644 --- a/Master/texmf-dist/source/latex/expl3/l3num.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3num.dtx @@ -32,26 +32,21 @@ %% %% ----------------------------------------------------------------------- % -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3num.dtx 573 2006-08-21 20:59:37Z morten $ +\GetIdInfo$Id: l3num.dtx 702 2007-11-27 14:21:49Z morten $ {L3 Experimental token numbers} -% -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3num.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -159,7 +154,9 @@ % % \begin{function}{% % \num_add:Nn | +% \num_add:cn | % \num_gadd:Nn | +% \num_gadd:cn | % } % \begin{syntax} % "\num_add:Nn" <num> "{" <integer> "}" @@ -222,6 +219,25 @@ % A predicate version of the above functions. % \end{function} % +% \begin{function}{% +% \num_max_of:nn | +% \num_min_of:nn | +% } +% \begin{syntax} +% "\num_max_of:nn" "{"<num~expr>"}" "{"<num~expr>"}" +% \end{syntax} +% Return the largest or smallest of two \m{num} expressions. +% \end{function} +% +% \begin{function}{% +% \num_abs:n | +% } +% \begin{syntax} +% "\num_abs:n" "{"<num~expr>"}" +% \end{syntax} +% Return the numerical value of a \m{num} expression. +% \end{function} + % % \subsection{Formatting a counter value} % @@ -283,6 +299,20 @@ % % % \begin{function}{% +% \num_value:w | +% } +% \begin{syntax} +% "\num_value:w" <integer> \\ +% "\num_value:w" <tokens> <optional space> +% \end{syntax} +% Expands <tokens> until an <integer> is formed. One space may be +% gobbled in the process. Preferably use with "\num_eval:n". +% \begin{texnote} +% This is the \TeX{} primitive \tn{number}. +% \end{texnote} +% \end{function} +% +% \begin{function}{% % \num_eval:w | % } % \begin{syntax} @@ -345,11 +375,14 @@ % % We start by ensuring that the required packages are loaded. % \begin{macrocode} +%<package>\ProvidesExplPackage +%<package> {\filename}{\filedate}{\fileversion}{\filedescription} %<package&!check>\RequirePackage{l3expan}\par %<package&check>\RequirePackage{l3chk}\par %<*initex|package> % \end{macrocode} % +% \begin{macro}{\num_value:w} % \begin{macro}{\num_eval:w} % \begin{macro}{\if_num:w} % \begin{macro}{\if_num_odd:w} @@ -358,6 +391,7 @@ % Here are the remaining primitives for number comparisons and % expressions. % \begin{macrocode} +\let_new:NN \num_value:w \tex_number:D \let_new:NN \num_eval:w \etex_numexpr:D \let_new:NN \if_num:w \tex_ifnum:D \let_new:NN \if_num_odd:w \tex_ifodd:D @@ -369,6 +403,7 @@ % \end{macro} % \end{macro} % \end{macro} +% \end{macro} % % \begin{macro}{\use_arg_after_or:w} % \begin{macro}{\use_arg_after_else:w} @@ -514,15 +549,21 @@ % \end{macro} % % \begin{macro}{\num_add:Nn} +% \begin{macro}{\num_add:cn} % \begin{macro}{\num_gadd:Nn} +% \begin{macro}{\num_gadd:cn} % Adding is easily done as the second argument goes through % |\num_eval:n|. % \begin{macrocode} \def_new:Npn \num_add:Nn #1#2 {\num_set:Nn #1{#1+#2}} +\def_new:Npn \num_add:cn {\exp_args:Nc\num_add:Nn} \def_new:Npn \num_gadd:Nn {\pref_global:D \num_add:Nn} +\def_new:Npn \num_gadd:cn {\exp_args:Nc\num_gadd:Nn} % \end{macrocode} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} % % % \begin{macro}{\num_use:N} @@ -563,6 +604,21 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\num_max_of:nn} +% \begin{macro}{\num_min_of:nn} +% \begin{macro}{\num_abs:n} +% Functions for $\min$, $\max$, and absolute value. +% \begin{macrocode} +\def_new:Npn \num_abs:n#1{ + \if_num:w \num_eval:n{#1}<\c_zero \exp_after:NN -\fi: #1 +} +\def_new:Npn \num_max_of:nn#1#2{\num_compare:nNnTF {#1}>{#2}{#1}{#2}} +\def_new:Npn \num_min_of:nn#1#2{\num_compare:nNnTF {#1}<{#2}{#1}{#2}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% % \begin{macro}{\l_tmpa_num} % \begin{macro}{\l_tmpb_num} % \begin{macro}{\l_tmpc_num} @@ -593,7 +649,7 @@ % \begin{macro}{\const_new_aux:Nw} % \begin{macrocode} % \begin{macrocode} -\engine_aleph:TF +\engine_if_aleph:TF { \let_new:NN \const_new_aux:Nw \tex_chardef:D \const_new_aux:Nw \c_max_register_num = 65535 \scan_stop: diff --git a/Master/texmf-dist/source/latex/expl3/l3precom.dtx b/Master/texmf-dist/source/latex/expl3/l3precom.dtx index de22e1fe5ab..786181d93b5 100644 --- a/Master/texmf-dist/source/latex/expl3/l3precom.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3precom.dtx @@ -32,26 +32,21 @@ %% %% ----------------------------------------------------------------------- % -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3precom.dtx 573 2006-08-21 20:59:37Z morten $ +\GetIdInfo$Id: l3precom.dtx 621 2007-09-01 20:14:19Z morten $ {L3 Experimental precompilation module} -% -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3precom.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -127,6 +122,8 @@ % % We start by ensuring that the required packages are loaded. % \begin{macrocode} +%<package>\ProvidesExplPackage +%<package> {\filename}{\filedate}{\fileversion}{\filedescription} %<package>\RequirePackage{l3num} %<package>\RequirePackage{l3io} %<package>\RequirePackage{l3seq} diff --git a/Master/texmf-dist/source/latex/expl3/l3prg.dtx b/Master/texmf-dist/source/latex/expl3/l3prg.dtx index 43e2e77448a..72084e07132 100644 --- a/Master/texmf-dist/source/latex/expl3/l3prg.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3prg.dtx @@ -32,30 +32,26 @@ %% %% ----------------------------------------------------------------------- % -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3prg.dtx 574 2006-08-21 23:30:10Z morten $ +\GetIdInfo$Id: l3prg.dtx 697 2007-11-27 14:14:54Z morten $ {L3 Experimental control structures} -% -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3prg.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi % +% % \title{The \textsf{l3prg} package\thanks{This file % has version number \fileversion, last % revised \filedate.}\\ @@ -69,25 +65,25 @@ % % \subsection{Choosing modes} % -% \begin{function}{\mode_vertical_p:| -% \mode_vertical:TF | -% \mode_vertical:T | -% \mode_vertical:F +% \begin{function}{\mode_if_vertical_p:| +% \mode_if_vertical:TF | +% \mode_if_vertical:T | +% \mode_if_vertical:F % } % \begin{syntax} -% "\mode_vertical:TF" "{"<true code>"}" "{"<false code>"}" +% "\mode_if_vertical:TF" "{"<true code>"}" "{"<false code>"}" % \end{syntax} % Determines if \TeX{} is in vertical mode or not and executes either % <true code> or <false code> accordingly. % \end{function} % -% \begin{function}{\mode_horizontal_p:| -% \mode_horizontal:TF | -% \mode_horizontal:T | -% \mode_horizontal:F +% \begin{function}{\mode_if_horizontal_p:| +% \mode_if_horizontal:TF | +% \mode_if_horizontal:T | +% \mode_if_horizontal:F % } % \begin{syntax} -% "\mode_horizontal:TF" "{"<true code>"}" "{"<false code>"}" +% "\mode_if_horizontal:TF" "{"<true code>"}" "{"<false code>"}" % \end{syntax} % Determines if \TeX{} is in horizontal mode or not and executes either % <true code> or <false code> accordingly. @@ -95,25 +91,25 @@ % % % \begin{function}{ -% \mode_inner_p:| -% \mode_inner:TF| -% \mode_inner:T| -% \mode_inner:F +% \mode_if_inner_p:| +% \mode_if_inner:TF| +% \mode_if_inner:T| +% \mode_if_inner:F % } % \begin{syntax} -% "\mode_inner:TF" "{"<true code>"}" "{"<false code>"}" +% "\mode_if_inner:TF" "{"<true code>"}" "{"<false code>"}" % \end{syntax} % Determines if \TeX{} is in inner mode or not and executes either % <true code> or <false code> accordingly. % \end{function} % % \begin{function}{ -% \mode_math:TF| -% \mode_math:T| -% \mode_math:F| +% \mode_if_math:TF| +% \mode_if_math:T| +% \mode_if_math:F| % } % \begin{syntax} -% "\mode_math:TF" "{"<true code>"}" "{"<false code>"}" +% "\mode_if_math:TF" "{"<true code>"}" "{"<false code>"}" % \end{syntax} % Determines if \TeX{} is in math mode or not and executes either % <true code> or <false code> accordingly. @@ -214,14 +210,14 @@ % connected to both parts as sometimes you want to execute some code % depending on the value of a switch (e.g.,~draft/final) and other % times you perhaps want to use it as a predicate function in an -% "\if:w" test. Here \TeX's original concept with "\iffalse" and -% "\iftrue" is a little difficult to handle so the easiest is simply -% to let a boolean either be "\c_true" or "\c_false". This also means -% we get the logical operations And, Or, and Not which can then be -% used on both the boolean type and predicate functions. All -% functions by the name |\prg_if_predicate_| are expandable and -% expect the input to also be fully expandable. More generic -% constructs do not contain |predicate| in their names. +% "\if:w" test. Parsing "\iffalse" +% and "\iftrue" tokens can be quite tricky at times so the easiest is to +% simply let a boolean either be "\c_true" or "\c_false". This +% also means we get the logical operations And, Or, and Not which can +% then be used on both the boolean type and predicate functions. All +% functions by the name |\predicate| are expandable and expect the +% input to also be fully expandable. More generic constructs do not +% contain |predicate| in their names. % % % \subsubsection{The boolean data type} @@ -324,48 +320,49 @@ % % % \begin{function}{% -% \prg_if_predicate:nTF | -% \prg_if_predicate:nT | -% \prg_if_predicate:nF | +% \predicate_p:n | +% \predicate:nTF | +% \predicate:nT | +% \predicate:nF | % } % \begin{syntax} -% "\prg_if_predicate:nTF" "{"<predicate>"}" "{"<true>"}" "{"<false>"}" \\ +% "\predicate:nTF" "{"<list of predicates>"}" "{"<true>"}" +% "{"<false>"}" % \end{syntax} -% The first argument can either be a predicate function like -% "\cs_free_p:N \foo" or one of the logic tests below. +% The functions evaluate the truth value of \m{list of predicates} +% where each predicate is separated by \verb+&&+ or \verb+||+ +% denoting logical And and Or functions. Minimal evaluation is +% carried out so that whenever a truth value cannot be changed +% anymore, the remainding tests are not carried out. Hence +% \begin{verbatim} +% \predicate_p:n{ +% \int_compare_p:nNn 1=1 && +% \predicate_p:n { +% \int_compare_p:nNn 2=3 || +% \int_compare_p:nNn 4=4 || +% \int_compare_p:nNn 1=\error % is skipped +% } && +% \int_compare_p:nNn 2=2 +% } +% \end{verbatim} +% returns \meta{true}. % \end{function} % % % % % \begin{function}{% -% \prg_if_predicate_ors_p:n | -% \prg_if_predicate_or_p:nn | -% \prg_if_predicate_ands_p:n | -% \prg_if_predicate_and_p:nn | -% \prg_if_predicate_not_p:n | +% \predicate_not_p:n | % } % \begin{syntax} -% "\prg_if_predicate_ors_p:n" "{"<predicate> <predicate> ..."}" \\ -% "\prg_if_predicate_or_p:nn" "{"<predicate>"}" "{"<predicate>"}" \\ -% "\prg_if_predicate_ands_p:n" "{"<predicate> <predicate> ..."}" \\ -% "\prg_if_predicate_and_p:nn" "{"<predicate>"}" "{"<predicate>"}" \\ -% "\prg_if_predicate_not_p:n" "{"<predicate>"}" +% "\predicate_not_p:n" "{"<list of predicates>"}" % \end{syntax} -% "\prg_if_predicate_or_p:nn" compares the outcome of two predicate -% functions (or other logic tests) and if either turns out to be -% \m{true} returns \m{true} itself. "\prg_if_predicate_and_p:nn" -% works in a similar way but requires both outcomes to be \m{true} in -% order for it to return \m{true} itself. "\prg_if_predicate_not_p:n" -% reverses the truth value of a predicate test or a logic -% operation. Thus +% "\predicate_not_p:n" +% reverses the truth value of its argument. Thus % \begin{quote} % "\prg_if_predicate_not_p:n {\prg_if_predicate_not_p:n {\c_true}}" % \end{quote} -% ultimately returns \m{true}. The argument of the functions -% "\prg_if_predicate_ors_p:n" and "\prg_if_predicate_ands_p:n" take a -% list of predicate functions (and their arguments) and return either -% \m{true} or \m{false}. +% ultimately returns \m{true}. % \end{function} % % \subsubsection{Generic loops} @@ -446,6 +443,8 @@ % We start by ensuring that the required packages are loaded. % \begin{macrocode} %<*package> +\ProvidesExplPackage + {\filename}{\filedate}{\fileversion}{\filedescription} \RequirePackage{l3quark} \RequirePackage{l3toks} \RequirePackage{l3int} @@ -456,57 +455,57 @@ % % \subsubsection{Choosing modes} % -% \begin{macro}{\mode_vertical_p:} -% \begin{macro}{\mode_vertical:TF} -% \begin{macro}{\mode_vertical:T} -% \begin{macro}{\mode_vertical:F} +% \begin{macro}{\mode_if_vertical_p:} +% \begin{macro}{\mode_if_vertical:TF} +% \begin{macro}{\mode_if_vertical:T} +% \begin{macro}{\mode_if_vertical:F} % For testing vertical mode. % \begin{macrocode} -\def_new:Npn \mode_vertical_p: { +\def_new:Npn \mode_if_vertical_p: { \if_mode_vertical: \c_true \else: \c_false\fi:} -\def_test_function_new:npn{mode_vertical:}{\if_mode_vertical:} +\def_test_function_new:npn{mode_if_vertical:}{\if_mode_vertical:} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % -% \begin{macro}{\mode_horizontal_p:} -% \begin{macro}{\mode_horizontal:TF} -% \begin{macro}{\mode_horizontal:T} -% \begin{macro}{\mode_horizontal:F} +% \begin{macro}{\mode_if_horizontal_p:} +% \begin{macro}{\mode_if_horizontal:TF} +% \begin{macro}{\mode_if_horizontal:T} +% \begin{macro}{\mode_if_horizontal:F} % For testing horizontal mode. % \begin{macrocode} -\def_new:Npn \mode_horizontal_p: { +\def_new:Npn \mode_if_horizontal_p: { \if_mode_horizontal: \c_true \else: \c_false\fi:} -\def_test_function_new:npn{mode_horizontal:}{\if_mode_horizontal:} +\def_test_function_new:npn{mode_if_horizontal:}{\if_mode_horizontal:} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % -% \begin{macro}{\mode_inner_p:} -% \begin{macro}{\mode_inner:TF} -% \begin{macro}{\mode_inner:T} -% \begin{macro}{\mode_inner:F} +% \begin{macro}{\mode_if_inner_p:} +% \begin{macro}{\mode_if_inner:TF} +% \begin{macro}{\mode_if_inner:T} +% \begin{macro}{\mode_if_inner:F} % For testing inner mode. % \begin{macrocode} -\def_new:Npn \mode_inner_p: { +\def_new:Npn \mode_if_inner_p: { \if_mode_inner: \c_true \else: \c_false\fi:} -\def_test_function_new:npn{mode_inner:}{\if_mode_inner:} +\def_test_function_new:npn{mode_if_inner:}{\if_mode_inner:} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % -% \begin{macro}{\mode_math:TF} -% \begin{macro}{\mode_math:T} -% \begin{macro}{\mode_math:F} +% \begin{macro}{\mode_if_math:TF} +% \begin{macro}{\mode_if_math:T} +% \begin{macro}{\mode_if_math:F} % For testing math mode. Uses the kern-save |\scan_align_safe_stop:|. % \begin{macrocode} -\def_test_function_new:npn{mode_math:} { +\def_test_function_new:npn{mode_if_math:} { \scan_align_safe_stop: \if_mode_math: } % \end{macrocode} % \end{macro} @@ -535,8 +534,9 @@ % by using code documented only in Appendix~D of % \emph{The \TeX book}\dots % \begin{macrocode} -\def_new:Npn \group_align_safe_begin: {\if_false:{\fi:\if_num:w0=`}\fi:} -\def_new:Npn \group_align_safe_end: {\if_num:w0=`{\fi:\if_false:}\fi:} +\def_new:Npn \group_align_safe_begin: { + \if_false:{\fi:\if_num:w`}=\c_zero\fi:} +\def_new:Npn \group_align_safe_end: {\if_num:w`{=\c_zero}\fi:} % \end{macrocode} % \end{macro} % \end{macro} @@ -797,15 +797,15 @@ % Defining and setting a boolean is easy. % \begin{macrocode} \def_new:Npn \bool_new:N #1 { \let_new:NN #1 \c_false } -\def_new:Npn \bool_new:c #1 { \let_new:cN #1 \c_false } +\def_new:Npn \bool_new:c #1 { \let_new:cN {#1} \c_false } \def_new:Npn \bool_set_true:N #1 { \let:NN #1 \c_true } -\def_new:Npn \bool_set_true:c #1 { \let:cN #1 \c_true } +\def_new:Npn \bool_set_true:c #1 { \let:cN {#1} \c_true } \def_new:Npn \bool_set_false:N #1 { \let:NN #1 \c_false } -\def_new:Npn \bool_set_false:c #1 { \let:cN #1 \c_false } +\def_new:Npn \bool_set_false:c #1 { \let:cN {#1} \c_false } \def_new:Npn \bool_gset_true:N #1 { \glet:NN #1 \c_true } -\def_new:Npn \bool_gset_true:c #1 { \glet:cN #1 \c_true } +\def_new:Npn \bool_gset_true:c #1 { \glet:cN {#1} \c_true } \def_new:Npn \bool_gset_false:N #1 { \glet:NN #1 \c_false } -\def_new:Npn \bool_gset_false:c #1 { \glet:cN #1 \c_false } +\def_new:Npn \bool_gset_false:c #1 { \glet:cN {#1} \c_false } % \end{macrocode} % \end{macro} % \end{macro} @@ -995,177 +995,102 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\prg_if_predicate:nTF} -% \begin{macro}{\prg_if_predicate:nT} -% \begin{macro}{\prg_if_predicate:nF} -% As the boolean type is actually a predicate function, the next ones -% are just aliases. -% \begin{macrocode} -\let_new:NN \prg_if_predicate:nTF \bool_if:NTF -\let_new:NN \prg_if_predicate:nT \bool_if:NT -\let_new:NN \prg_if_predicate:nF \bool_if:NF -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% -% -% \begin{macro}{\prg_if_predicate_or_p:nn} -% \begin{macro}{\prg_if_predicate_and_p:nn} -% \begin{macro}{\prg_if_predicate_not_p:n} -% The logic operations require a little more work. The idea is to have -% the end result of the logic "and" and "or" functions return "00" and -% "01" resp.\ to be used in an "\if:w" test. The arguments of the -% functions are always something expanding to "\c_true" or "\c_false" -% which is usually resulting from a predicate function or from another -% logical operation. All the functions start with a "0" and depending -% on the results of the tests return either "0" or "1" to the input -% stream to form a new true or false statement. -% -% The comments in the following is mostly to convince myseld of the -% validity of the code. -% \begin{macrocode} -\def_new:Npn \prg_if_predicate_or_p:nn #1#2{ -% \end{macrocode} -% Form a number of the input which is one of "0000", "0001", "0100", or -% "0101". If the truth value of both tests are false we get the "0101" -% else we get a number less than that. So we check if the number formed -% is less than $101$. -% \begin{macrocode} - \if_num:w #1#2<\c_hundred_one -% \end{macrocode} -% If it is we put a "\c_true" back into the input stream. +% \begin{macro}{\predicate_p:n} +% \begin{macro}{\predicate:nTF} +% \begin{macro}{\predicate:nT} +% \begin{macro}{\predicate:nF} +% \begin{macro}{\predicate_auxi:NN} +% \begin{macro}{\predicate_auxii:NNN} +% \begin{macro}{\predicate_88_0:w}^^A% fix! +% \begin{macro}{\predicate_88_1:w}^^A% fix! +% \begin{macro}{\predicate_II_0:w}^^A% fix! +% \begin{macro}{\predicate_II_1:w}^^A fix! +% \begin{macro}{\predicate_02_0:w} +% \begin{macro}{\predicate_02_1:w} +% +% Evaluating the truth value of a list of predicates is done using +% an input syntax somewhat similar to the one found in other +% programming languages. The function evaluates predicates from +% left to right, expanding them to 00 and 01 resp., which leads to +% six different situations of tokens in the input stream: +% \begin{itemize} +% \item[\texttt{00\&\&}] Current truth value is true, logical And +% seen, continue to see if next is also true. +% \item[\texttt{01\&\&}] Current truth value is false, logical And +% seen, break the scanning and return \meta{false}. +% \item[\texttt{00\char`\|\char`\|}] Current truth value is true, +% logical Or seen, break the scanning and return \meta{true}. +% \item[\texttt{01\char`\|\char`\|}] Current truth value is false, +% logical Or seen, continue to see if a later predicate is true. +% \item[\texttt{0002}] Current truth value is true, end marker +% seen, return \meta{true}. +% \item[\texttt{0102}] Current truth value is false, end marker +% seen, return \meta{false}. +% \end{itemize} +% To accomplish this we pre-expand the predicate list using |f| +% type expansion which leads to |00| or |01|, possibly with a +% sequence of unfinished |\else: \c_false \fi:| or similar after +% it, which we remove using the same trick. We also carry over the +% truth value of the evaluated predicate. The expansion stops when +% it sees the end marker or \verb+&&+ or \verb+||+ (assuming these +% are not active characters at the programming level). % \begin{macrocode} - \c_true - \else: -% \end{macrocode} -% Otherwise we insert "\c_false". -% \begin{macrocode} - \c_false - \fi: +\def_long_new:Npn \predicate_p:n #1{ + \group_align_safe_begin: + \exp_after:NN \predicate_auxi:NN + \int_to_roman:w-`\q #1 02\scan_stop: } -% \end{macrocode} -% The "and" function is a little different. Again we can have input of -% the types "0000", "0001", "0100", or "0101". As we require both -% values to be \m{true} in order to continue we simply check if the -% number formed by the input is "0" or not and then put the -% corresponding "0" or "1" back in the input stream as above. We could -% use "\if_num:w" for this test as well but that'll require us to read -% the additional "=\c_zero" which runs a little slower than using -% "\if_case:w" directly, so we use the latter. -% \begin{macrocode} -\def_new:Npn \prg_if_predicate_and_p:nn #1#2{ - \if_case:w #1#2 ~ - \c_true - \else: - \c_false - \fi: +\def_long_test_function_new:npn {predicate:n}#1{ + \group_align_safe_begin: + \if:w \exp_after:NN \predicate_auxi:NN + \int_to_roman:w-`\q #1 02\scan_stop: +} +\def_new:Npn \predicate_auxi:NN 0 #1{ + \exp_after:NN \predicate_auxii:NNN \exp_after:NN #1 + \int_to_roman:w-`\q } % \end{macrocode} -% The "not" function checks a single truth value and reverses it. Here -% we either get a "00" or "01". If the input equals "0" we put a "1" -% in the input stream, else we put a "0". Again we use "\if_case:w" -% because it's slightly faster. +% After removing trailing conditionals we call a macro for the case we +% are in (see list above). % \begin{macrocode} -\def_new:Npn \prg_if_predicate_not_p:n #1{ - \if_case:w #1 ~ - \c_false - \or: - \c_true - \fi: +\def_new:Npn \predicate_auxii:NNN #1#2#3{ + \cs_use:c{predicate_#2#3_#1:w} } +\def_new:cpn{predicate_&&_0:w}{ + \exp_after:NN \predicate_auxi:NN\int_to_roman:w-`\q +} +\def_long_new:cpn{predicate_&&_1:w} #1 02\scan_stop:{ + \group_align_safe_end: 01} +\def_long_new:cpn{predicate_||_0:w} #1 02\scan_stop:{ + \group_align_safe_end: 00} +\def_new:cpn{predicate_||_1:w}{ + \exp_after:NN \predicate_auxi:NN\int_to_roman:w-`\q } +\def_new:cpn{predicate_02_0:w}\scan_stop:{ \group_align_safe_end: 00 } +\def_new:cpn{predicate_02_1:w}\scan_stop:{ \group_align_safe_end: 01 } % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} % % -% \begin{macro}{\prg_if_predicate_ors_p:n} -% \begin{macro}{\prg_if_predicate_ands_p:n} -% \begin{macro}{\prg_if_predicate_andor_aux:NNN} -% \begin{macro}{\prg_if_predicate_andor_break:NNN } -% For longer lists of predicates we can't rely on such structures -% as above. The "\prg_if_predicate_ands_p:n" would have been easy to -% program as simply -% \begin{verbatim} -% \def_new:Npn \prg_if_predicate_and_p:n #1 { -% 0\tex_ifcase:D #1 ~ \exp_after:NN 0 \else: \exp_after:NN 1 \fi: -% } -% \end{verbatim} -% but this would fail with a "! Number too big." in case we were -% testing six predicate functions where the first was false. This -% would mean we would have to first convert the string from binary -% into numerical and then check. While challenging and interesting -% in itself (See \textsf{binhex}) it still imposes a restriction of -% 15 predicate functions\footnote{We would probably never hit that -% limit but why create a restriction when we can avoid it?} and we -% haven't dealt with the "or" case either. -% -% The solution below expands a predicate function until |\c_false| or -% |\c_true| are seen and expanded to |01| or |00| respectively. If -% we're testing the logical AND operation, all predicate functions -% must return \meta{true}; if they don't we can exit and return -% \meta{false}. In an OR operation, we just need one predicate -% function to return \meta{true}, the rest don't matter. Since every -% expansion in the internal loop results in a result of either |00| -% or |01|, we can test against this number to decide what to do. -% -% First up is the top level functions. -% \begin{macrocode} -\def_long_new:Npn \prg_if_predicate_ands_p:n #1{ - \exp_after:NN \prg_if_predicate_andor_aux:NNN \exp_after:NN \c_true - \int_to_roman:w -`0 #1 \scan_stop: \scan_stop: -} -\def_long_new:Npn \prg_if_predicate_ors_p:n #1{ - \exp_after:NN \prg_if_predicate_andor_aux:NNN \exp_after:NN \c_false - \int_to_roman:w -`0 #1 \scan_stop: \scan_stop: -} -% \end{macrocode} -% When we reach the inner loop we have already expanded all tokens in -% the first predicate function as far as possible. This means that -% either are arguments |#2| and |#3| \emph{both} |\scan_stop:| or else -% |#2| is |0| and |#3| is |0| if the predicate returned \meta{true} or -% |1| if it returned \meta{false}. If we reached the end we return -% \meta{true} for the AND function and \meta{false} for the OR -% function. If |#3| is |0| and we are doing the OR test, we want to -% exit and return \meta{true}. If |#3| is |0| and we are in the AND -% test we must continue to check the remaining predicate functions. If -% |#3| is |1| and we are in the OR test we continue in case a later -% predicate function returns \meta{true}. Finally, if |#3| is |1| and -% we are in the AND test we can exit and return \meta{false} before -% deciding what to do. -% \begin{macrocode} -\def_new:Npn \prg_if_predicate_andor_aux:NNN #1#2#3{ - \token_if_eq_meaning:NNTF \scan_stop: #2 - { #1 } - { - \int_compare:nNnTF #3 = #1 - { \exp_after:NN \prg_if_predicate_andor_aux:NNN } - { \exp_after:NN \prg_if_predicate_andor_break:NNN } - \exp_after:NN #1 \int_to_roman:w -`0 - } -} -% \end{macrocode} -% The break loop is called when we know what the final outcome -% is. However we keep expanding because a)~we don't know which tokens -% we might have left dangling ahead and b)~it also provides error -% checking on the remaining predicate functions. |#1| is \meta{false} -% for the OR function and \meta{true} for the AND function so we -% reverse them here. +% \begin{macro}{\predicate_not_p:n} +% The "not" variant just reverses the outcome of |\predicate_p:n|. % \begin{macrocode} -\def_new:Npn \prg_if_predicate_andor_break:NNN #1#2#3{ - \token_if_eq_meaning:NNTF \scan_stop: #2 - { \if:w #1\c_false\else:\c_true\fi: } - { - \exp_after:NN \prg_if_predicate_andor_break:NNN \exp_after:NN #1 - \int_to_roman:w -`0 - } +\def_long_new:Npn \predicate_not_p:n #1{ + \if:w \predicate_p:n{#1} \c_false \else: \c_true \fi: } % \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} +% \end{macro} +% % % \subsubsection{Sorting} % diff --git a/Master/texmf-dist/source/latex/expl3/l3prop.dtx b/Master/texmf-dist/source/latex/expl3/l3prop.dtx index 2315892f1a6..22d7a7ecaeb 100644 --- a/Master/texmf-dist/source/latex/expl3/l3prop.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3prop.dtx @@ -32,26 +32,21 @@ %% %% ----------------------------------------------------------------------- % -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3prop.dtx 581 2006-12-12 12:28:27Z morten $ +\GetIdInfo$Id: l3prop.dtx 668 2007-09-27 15:54:23Z mittelba $ {L3 Experimental Property Lists} -% -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3prop.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -95,21 +90,21 @@ % \end{function} % % \begin{function}{% -% \prop_put:NNn | +% \prop_put:Nnn | % \prop_put:ccn | -% \prop_gput:NNn | -% \prop_gput:NNo | -% \prop_gput:NOo | +% \prop_gput:Nnn | +% \prop_gput:Nno | +% \prop_gput:Noo | % \prop_gput:Ncn | -% \prop_gput:OOo | -% \prop_gput:NOx | -% \prop_gput:cNn | +% \prop_gput:Ooo | +% \prop_gput:Nox | +% \prop_gput:cnn | % \prop_gput:ccn | % \prop_gput:cco | % \prop_gput:ccx | % } % \begin{syntax} -% "\prop_put:NNn" <plist> <key> "{"<token list>"}" +% "\prop_put:Nnn" <plist> "{"<key>"}" "{"<token list>"}" % \end{syntax} % Locally or globally associates <token list> with <key> in the p-list % <plist>. If <key> has already a meaning within <plist> this value is @@ -117,10 +112,10 @@ % \end{function} % % \begin{function}{% -% \prop_gput_if_new:NNn | +% \prop_gput_if_new:Nnn | % } % \begin{syntax} -% "\prop_gput_if_new:NNn" <plist> <key> "{"<token list>"}" +% "\prop_gput_if_new:Nnn" <plist> "{"<key>"}" "{"<token list>"}" % \end{syntax} % Globally associates <token list> with <key> in the p-list % <plist> but only if <key> has so far no meaning within <plist>. @@ -128,14 +123,14 @@ % \end{function} % % \begin{function}{% -% \prop_get:NNN | -% \prop_get:cNN | -% \prop_gget:NNN | +% \prop_get:NnN | +% \prop_get:cnN | +% \prop_gget:NnN | % \prop_gget:NcN | -% \prop_gget:cNN | +% \prop_gget:cnN | % } % \begin{syntax} -% "\prop_get:NNN" <plist> <key> <tlp> +% "\prop_get:NnN" <plist> "{"<key>"}" <tlp> % \end{syntax} % If <info> is the information associated with <key> in the p-list % <plist> then the token list pointer <tlp> gets <info> assigned. @@ -157,21 +152,21 @@ % \end{function} % % \begin{function}{% -% \prop_get_gdel:NNN | +% \prop_get_gdel:NnN | % } % \begin{syntax} -% "\prop_get_gdel:NNN" <plist> <key> <tlp> +% "\prop_get_gdel:NnN" <plist> "{"<key>"}" <tlp> % \end{syntax} -% Like "\prop_get:NNN" but additionally removes <key> (and its <info>) +% Like "\prop_get:NnN" but additionally removes <key> (and its <info>) % from <plist>. % \end{function} % % \begin{function}{% -% \prop_del:NN | -% \prop_gdel:NN | +% \prop_del:Nn | +% \prop_gdel:Nn | % } % \begin{syntax} -% "\prop_del:NN" <plist> <key> +% "\prop_del:Nn" <plist> "{"<key>"}" % \end{syntax} % Locally or globally deletes <key> and its <info> from <plist> if % found. Otherwise does nothing. @@ -180,6 +175,7 @@ % % \begin{function}{\prop_map_function:NN | % \prop_map_function:cN | +% \prop_map_function:Nc | % \prop_map_function:cc | % } % \begin{syntax} @@ -197,8 +193,7 @@ % \end{syntax} % Just like "\prop_map_function:NN" but with the function of two arguments % supplied as inline code. Within <inline function> refer to the -% arguments via "##1" (<key>) and "##2" (<info>). Fast but not -% expandable. +% arguments via "#1" (<key>) and "#2" (<info>). Nestable. % \end{function} % % @@ -235,12 +230,12 @@ % % % \begin{function}{% -% \prop_if_in:NNTF | -% \prop_if_in:NOTF | +% \prop_if_in:NnTF | +% \prop_if_in:NoTF | % \prop_if_in:ccTF | % } % \begin{syntax} -% "\prop_if_in:NNTF" <plist><key>"{"<true code>"}{"<false code>"}" +% "\prop_if_in:NnTF" <plist>"{"<key>"}{"<true code>"}{"<false code>"}" % \end{syntax} % Tests if <key> is used in <plist> and then either executes <true code> % or <false code>. @@ -283,9 +278,9 @@ % "\prop_map_inline:NN". % \end{function} % -% \begin{function}{\prop_split_aux:NNn} +% \begin{function}{\prop_split_aux:Nnn} % \begin{syntax} -% "\prop_split_aux:NNn" <plist> <key> <cmd> +% "\prop_split_aux:Nnn" <plist> <key> <cmd> % \end{syntax} % Internal function that invokes <cmd> with 3 arguments: 1st is the % beginning of <plist> before <key>, 2nd is the value associated with @@ -303,16 +298,26 @@ % % We start by ensuring that the required packages are loaded. % \begin{macrocode} +%<package>\ProvidesExplPackage +%<package> {\filename}{\filedate}{\fileversion}{\filedescription} %<package>\RequirePackage{l3toks}\par +%<package>\RequirePackage{l3quark}\par %<*initex|package> % \end{macrocode} % % A property list is a token register whose contents is -% of the form `\zz{tok$\sb1$}\zv{val$\sb1$} \ldots{} -% \zz{tok$\sb{}n$}\zv{val$\sb{}n$}'. The properties have to be single +% of the form `\zz{q_prop}key$\sb1$\zz{q_prop}\zv{val$\sb1$} \ldots{} +% \zz{q_prop}key$\sb n$\zz{q_prop}\zv{val$\sb{}n$}'. +% The properties have to be single % token, the values might be arbitrary token lists they get surrounded % by braces. % +% \begin{macro}{\q_prop} +% \begin{macrocode} +\quark_new:N\q_prop +% \end{macrocode} +% \end{macro} + % To get values from property-lists, token lists should be passed to % the appropriate functions. % @@ -343,56 +348,51 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\prop_use:N} -% The same goes for clearing a property list, either -% locally or globally. -% \begin{macrocode} -\let_new:NN \prop_use:N \toks_use:N -% \end{macrocode} -% \end{macro} % -% \begin{macro}{\prop_split_aux:NNn} +% +% \begin{macro}{\prop_split_aux:Nnn} % |\prop_split_aux:NNn|\zz{plist}\zz{prop}\zz{cmd} invokes \zz{cmd} % with 3 arguments: 1st is the beginning of \zz{plist} before % \zz{prop}, 2nd is the value associated with \zz{prop}, 3rd is the % rest of \zz{plist} after \zz{prop}. If there is no property % \zz{prop} in \zz{plist}, then the 2nd argument will be |\q_no_value| -% and the 3rd argument is empty; otherwise the 3rd argument has the two -% extra tokens \zz{prop} |\q_no_value| at the end. +% and the 3rd argument is empty; otherwise the 3rd argument has the +% extra tokens |\q_prop| \zz{prop} |\q_prop| |\q_no_value| at the end. % \begin{macrocode} -\def_long_new:Npn \prop_split_aux:NNn #1#2#3{ - \def:Npn \tmp:w ##1#2##2##3\q_stop {#3{##1}{##2}{##3}} - \exp_after:NN\tmp:w \prop_use:N#1#2\q_no_value \q_stop} +\def_long_new:Npn \prop_split_aux:Nnn #1#2#3{ + \def:Npn \tmp:w ##1\q_prop#2\q_prop##2##3\q_stop {#3{##1}{##2}{##3}} + \exp_after:NN\tmp:w \toks_use:N#1\q_prop#2\q_prop\q_no_value \q_stop +} % \end{macrocode} % \end{macro} % -% \begin{macro}{\prop_get:NNN} -% \begin{macro}{\prop_get:cNN} +% \begin{macro}{\prop_get:NnN} +% \begin{macro}{\prop_get:cnN} % \begin{macro}{\prop_get_aux:w} % |\prop_get:NNN |\zz{plist}\zz{prop}\zz{tlp} defines % \zz{tlp} to be the value associated with \zz{prop} in \zz{plist}, % |\q_no_value| if not found. % \begin{macrocode} -\def_long_new:NNn \prop_get:NNN 2{ - \prop_split_aux:NNn #1#2\prop_get_aux:w} -\def_long_new:NNn \prop_get_aux:w 4{\toks_set:Nn#4{#2}} -\def_new:Npn \prop_get:cNN { \exp_args:Nc \prop_get:NNN } +\def_long_new:NNn \prop_get:NnN 2{ + \prop_split_aux:Nnn #1{#2}\prop_get_aux:w} +\def_long_new:NNn \prop_get_aux:w 4{\tlp_set:Nx#4{\exp_not:n{#2}}} +\def_new:Npn \prop_get:cnN { \exp_args:Nc \prop_get:NnN } % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % -% \begin{macro}{\prop_gget:NNN} +% \begin{macro}{\prop_gget:NnN} % \begin{macro}{\prop_gget:NcN} -% \begin{macro}{\prop_gget:cNN} +% \begin{macro}{\prop_gget:cnN} % \begin{macro}{\prop_gget_aux:w} % The global version of the previous function. % \begin{macrocode} -\def_long_new:NNn \prop_gget:NNN 2{ - \prop_split_aux:NNn #1#2\prop_gget_aux:w} -\def_new:Npn \prop_gget:NcN {\exp_args:NNc \prop_gget:NNN} -\def_new:Npn \prop_gget:cNN {\exp_args:Nc \prop_gget:NNN} -\def_long_new:NNn \prop_gget_aux:w 4{\toks_gset:Nn#4{#2}} +\def_long_new:NNn \prop_gget:NnN 2{ + \prop_split_aux:Nnn #1{#2}\prop_gget_aux:w} +\def_new:Npn \prop_gget:NcN {\exp_args:NNc \prop_gget:NnN} +\def_new:Npn \prop_gget:cnN {\exp_args:Nc \prop_gget:NnN} +\def_long_new:NNn \prop_gget_aux:w 4{\tlp_gset:Nx#4{\exp_not:n{#2}}} % \end{macrocode} % \end{macro} % \end{macro} @@ -406,63 +406,66 @@ % from \m{property_list}. One probably also needs the local % variants or only the local one, or\ldots\ We decide this later. % \begin{macrocode} -\def_long_new:NNn \prop_get_gdel:NNN 3{ - \prop_split_aux:NNn #1#2{\prop_get_del_aux:w #3{\toks_gset:Nn #1}#2}} +\def_long_new:NNn \prop_get_gdel:NnN 3{ + \prop_split_aux:Nnn #1{#2}{\prop_get_del_aux:w #3{\toks_gset:Nn #1}{#2}}} \def_long_new:NNn \prop_get_del_aux:w 6{ - \quark_if_no_value:nF{#5} { - \def:Npn \tmp:w ##1#3\q_no_value {#2{#4##1}} + \tlp_set:Nx #1{\exp_not:n{#5}} + \quark_if_no_value:NF #1 { + \def:Npn \tmp:w ##1\q_prop#3\q_prop\q_no_value {#2{#4##1}} \tmp:w #6} } % \end{macrocode} % \end{macro} % \end{macro} % -% \begin{macro}{\prop_put:NNn} +% \begin{macro}{\prop_put:Nnn} % \begin{macro}{\prop_put:ccn} -% \begin{macro}{\prop_gput:NNn} -% \begin{macro}{\prop_gput:NNo} -% \begin{macro}{\prop_gput:NNx} -% \begin{macro}{\prop_gput:NOx} -% \begin{macro}{\prop_gput:NOo} +% \begin{macro}{\prop_gput:Nnn} +% \begin{macro}{\prop_gput:Nno} +% \begin{macro}{\prop_gput:Nnx} +% \begin{macro}{\prop_gput:Nox} +% \begin{macro}{\prop_gput:Noo} % \begin{macro}{\prop_gput:Ncn} -% \begin{macro}{\prop_gput:OOo} +% \begin{macro}{\prop_gput:Ooo} % \begin{macro}{\prop_gput:cNn} % \begin{macro}{\prop_gput:ccn} % \begin{macro}{\prop_gput:cco} % \begin{macro}{\prop_gput:ccx} % \begin{macro}{\prop_put_aux:w} -% |\prop_put:NNn |\zz{plist}\zz{prop}\zv{val} adds/changes the +% |\prop_put:Nnn |\zz{plist}\zz{prop}\zv{val} adds/changes the % value associated with \zz{prop} in \zz{plist} to \zv{val}. % \begin{macrocode} -\def_long_new:NNn \prop_put:NNn 2{ - \prop_split_aux:NNn #1#2{ - \toks_clear:N #1 - \prop_put_aux:w {\toks_put_right:Nn #1}#2} +\def_long_new:NNn \prop_put:Nnn 2{ + \prop_split_aux:Nnn #1{#2}{ + \prop_clear:N #1 + \prop_put_aux:w {\toks_put_right:Nn #1}{#2}} } -\def_new:Npn \prop_put:ccn {\exp_args:Ncc \prop_put:NNn } -\def_long_new:NNn \prop_gput:NNn 2{ - \prop_split_aux:NNn #1#2{ - \toks_gclear:N #1 - \prop_put_aux:w {\toks_gput_right:Nn #1}#2} +\def_new:Npn \prop_put:ccn {\exp_args:Ncc \prop_put:Nnn } + +\def_long_new:NNn \prop_gput:Nnn 2{ + \prop_split_aux:Nnn #1{#2}{ + \prop_gclear:N #1 + \prop_put_aux:w {\toks_gput_right:Nn #1}{#2}} } -\def_new:Npn \prop_gput:NNo {\exp_args:NNNo \prop_gput:NNn} -\def_new:Npn \prop_gput:NNx {\exp_args:Nnnx \prop_gput:NNn} -\def_new:Npn \prop_gput:NOx {\exp_args:Nnox \prop_gput:NNn} -\def_new:Npn \prop_gput:NOo {\exp_args:NNOo \prop_gput:NNn} -\def_new:Npn \prop_gput:Ncn {\exp_args:NNc \prop_gput:NNn } -\def_new:Npn \prop_gput:OOo {\exp_args:NOOo \prop_gput:NNn} -\def_new:Npn \prop_gput:cNn {\exp_args:Nc \prop_gput:NNn} -\def_new:Npn \prop_gput:ccn {\exp_args:Ncc \prop_gput:NNn} -\def_new:Npn \prop_gput:cco {\exp_args:Ncco \prop_gput:NNn} -\def_new:Npn \prop_gput:ccx {\exp_args:Nccx \prop_gput:NNn} + \def_long_new:NNn \prop_put_aux:w 6{ - #1{#2{#6}#3} - \quark_if_no_value:nF {#4} + #1{\q_prop#2\q_prop{#6}#3} + \tlist_if_empty:nF{#5} { - \def:Npn \tmp:w ##1#2\q_no_value {#1{##1}} + \def:Npn \tmp:w ##1\q_prop#2\q_prop\q_no_value {#1{##1}} \tmp:w #5 } } +\def_new:Npn \prop_gput:Nno {\exp_args:NNno \prop_gput:Nnn} +\def_new:Npn \prop_gput:Nnx {\exp_args:NNnx \prop_gput:Nnn} +\def_new:Npn \prop_gput:Nox {\exp_args:NNox \prop_gput:Nnn} +\def_new:Npn \prop_gput:Noo {\exp_args:NNoo \prop_gput:Nnn} +\def_new:Npn \prop_gput:Ncn {\exp_args:NNc \prop_gput:Nnn} +\def_new:Npn \prop_gput:Ooo {\exp_args:NOoo \prop_gput:Nnn} +\def_new:Npn \prop_gput:cnn {\exp_args:Nc \prop_gput:Nnn} +\def_new:Npn \prop_gput:ccn {\exp_args:Ncc \prop_gput:Nnn} +\def_new:Npn \prop_gput:cco {\exp_args:Ncco \prop_gput:Nnn} +\def_new:Npn \prop_gput:ccx {\exp_args:Nccx \prop_gput:Nnn} % \end{macrocode} % \end{macro} % \end{macro} @@ -479,23 +482,21 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\prop_del:NN} -% \begin{macro}{\prop_gdel:NN} +% \begin{macro}{\prop_del:Nn} +% \begin{macro}{\prop_gdel:Nn} % \begin{macro}{\prop_del_aux:w} % |\prop_del:NN |\zz{plist}\zz{prop} deletes the entry for % \zz{prop} in \zz{plist}, if any. % \begin{macrocode} -\def_long_new:NNn \prop_del:NN 2{ - \prop_split_aux:NNn #1#2{\prop_del_aux:w {\toks_set:Nn #1}#2}} -\def_long_new:NNn \prop_gdel:NN 2{ - \prop_split_aux:NNn #1#2{\prop_del_aux:w {\toks_gset:Nn #1}#2}} -\def_long_new:NNn \prop_del_aux:w 5{\quark_if_no_value:nF {#4} -% \end{macrocode} -% I see no reason for updating the property list if we don't find -% any entry. -% \begin{macrocode} -% {#1{#3}} - {\def:Npn \tmp:w ##1#2\q_no_value {#1{#3##1}}\tmp:w #5}} +\def_long_new:NNn \prop_del:Nn 2{ + \prop_split_aux:Nnn #1{#2}{\prop_del_aux:w {\toks_set:Nn #1}{#2}}} +\def_long_new:NNn \prop_gdel:Nn 2{ + \prop_split_aux:Nnn #1{#2}{\prop_del_aux:w {\toks_gset:Nn #1}{#2}}} +\def_long_new:NNn \prop_del_aux:w 5{ + \def:Npn \tmp:w {#4} + \quark_if_no_value:NF \tmp:w + {\def:Npn \tmp:w ##1\q_prop#2\q_prop\q_no_value {#1{#3##1}} + \tmp:w #5}} % \end{macrocode} % \end{macro} % \end{macro} @@ -503,8 +504,8 @@ % % % -% \begin{macro}{\prop_if_in:NNTF} -% \begin{macro}{\prop_if_in:NOTF} +% \begin{macro}{\prop_if_in:NnTF} +% \begin{macro}{\prop_if_in:NoTF} % \begin{macro}{\prop_if_in:ccTF} % \begin{macro}{\prop_if_in_aux:w} % |\prop_if_in:NNTF| \m{property_list} \m{property_key} @@ -512,25 +513,26 @@ % \m{property_key} is on the \m{property_list} and then select % either the true or false case. % \begin{macrocode} -\def_new:NNn \prop_if_in:NNTF 2{ - \prop_split_aux:NNn #1#2\prop_if_in_aux:w} -\def_new:Npn \prop_if_in:NOTF {\exp_args:Nno \prop_if_in:NNTF} -\def_new:Npn \prop_if_in:ccTF {\exp_args:Ncc \prop_if_in:NNTF} +\def_new:NNn \prop_if_in:NnTF 2{ + \prop_split_aux:Nnn #1{#2}\prop_if_in_aux:w} \def_new:NNn \prop_if_in_aux:w 3{\quark_if_no_value:nFT {#2}} + +\def_new:Npn \prop_if_in:NoTF {\exp_args:NNo \prop_if_in:NnTF} +\def_new:Npn \prop_if_in:ccTF {\exp_args:Ncc \prop_if_in:NnTF} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % -% \begin{macro}{\prop_gput_if_new:NNn} +% \begin{macro}{\prop_gput_if_new:Nnn} % |\prop_gput_if_new:NNn| \m{property_list} \m{property_key} % \m{property_value} is equivalent to % \begin{tabbing} % xxxxx\=xxxxx\= \kill % |\prop_if_in:NNTF |\m{property}\m{property_key} \\ % \> |{}%| \\ -% \> |{\prop_gput:NNn| \\ +% \> |{\prop_gput:Nnn| \\ % \>\> \m{property_list} \\ % \>\> \m{property_key} \\ % \>\> \m{property_value}|}| @@ -539,10 +541,10 @@ % F. and Louis A. which makes writing macros sometimes difficult; I % find myself humming instead of working): % \begin{macrocode} -\def_long_new:NNn \prop_gput_if_new:NNn 2{ - \prop_split_aux:NNn #1#2{\prop_put_if_new_aux:w #1#2}} +\def_long_new:NNn \prop_gput_if_new:Nnn 2{ + \prop_split_aux:Nnn #1{#2}{\prop_put_if_new_aux:w #1{#2}}} \def_long_new:NNn \prop_put_if_new_aux:w 6{ - \quark_if_no_value:nT {#4}{#1{#2{#6}#3}}} + \tlist_if_empty:nT {#5}{#1{\q_prop#2\q_prop{#6}#3}}} % \end{macrocode} % \end{macro} % @@ -558,12 +560,12 @@ % This makes two \m{plist}s have the same contents. % \begin{macrocode} \let_new:NN \prop_set_eq:NN \toks_set_eq:NN -\let_new:NN \prop_set_eq:Nc \toks_set_eq:Nc +\let_new:NN \prop_set_eq:Nc \toks_set_eq:Nc \let_new:NN \prop_set_eq:cN \toks_set_eq:cN -\let_new:NN \prop_set_eq:cc \toks_set_eq:cc -\let_new:NN \prop_gset_eq:NN \toks_gset_eq:NN +\let_new:NN \prop_set_eq:cc \toks_set_eq:cc +\let_new:NN \prop_gset_eq:NN \toks_gset_eq:NN \let_new:NN \prop_gset_eq:Nc \toks_gset_eq:Nc -\let_new:NN \prop_gset_eq:cN \toks_gset_eq:cN +\let_new:NN \prop_gset_eq:cN \toks_gset_eq:cN \let_new:NN \prop_gset_eq:cc \toks_gset_eq:cc % \end{macrocode} % \end{macro} @@ -622,13 +624,13 @@ % two arguments are equal; if they are not |#3| is executed. % \begin{macrocode} \def_new:NNn \prop_if_eq:NNTF 2 { - \tlist_if_eq:xxTF{\prop_use:N #1}{\prop_use:N #2} + \tlist_if_eq:xxTF{\toks_use:N #1}{\toks_use:N #2} } \def_new:NNn \prop_if_eq:NNT 2 { - \tlist_if_eq:xxT{\prop_use:N #1}{\prop_use:N #2} + \tlist_if_eq:xxT{\toks_use:N #1}{\toks_use:N #2} } \def_new:NNn \prop_if_eq:NNF 2 { - \tlist_if_eq:xxF{\prop_use:N #1}{\prop_use:N #2} + \tlist_if_eq:xxF{\toks_use:N #1}{\toks_use:N #2} } \def_new:Npn \prop_if_eq:NcTF {\exp_args:NNc \prop_if_eq:NNTF} \def_new:Npn \prop_if_eq:NcT {\exp_args:NNc \prop_if_eq:NNT} @@ -655,33 +657,69 @@ % % \begin{macro}{\prop_map_function:NN} % \begin{macro}{\prop_map_function:cN} +% \begin{macro}{\prop_map_function:Nc} % \begin{macro}{\prop_map_function:cc} -% \begin{macro}{\prop_map_function_aux:NNn} +% \begin{macro}{\prop_map_function_aux:w} % Maps a function on every entry in the property list. The % function must take 2 arguments: a key and a value. % \begin{macrocode} \def_new:Npn \prop_map_function:NN #1#2{ - \exp_after:NN \prop_map_function_aux:NNn - \exp_after:NN #2 \prop_use:N #1 \q_nil \q_no_value \q_stop + \exp_after:NN \prop_map_function_aux:w + \exp_after:NN #2 \toks_use:N #1 \q_prop{}\q_prop \q_no_value \q_stop +} +\def_new:Npn \prop_map_function_aux:w #1\q_prop#2\q_prop#3{ + \if:w \tlist_if_empty_p:n{#2} + \exp_after:NN \prop_map_break:w + \fi: + #1{#2}{#3} + \prop_map_function_aux:w #1 +} +% problem with the above impl, is that an empty key stops the mapping but all +% other functions in the module allow the use of empty keys (as one value) + +\def:Npn \prop_map_function:NN #1#2{ + \exp_after:NN \prop_map_function_aux:w + \exp_after:NN #2 \toks_use:N #1 \q_prop \q_no_value \q_prop \q_no_value +} +\def:Npn \prop_map_function_aux:w #1\q_prop#2\q_prop#3{ + \quark_if_no_value:nF{#2} + { + #1{#2}{#3} + \prop_map_function_aux:w #1 + } +} +% problem with the above impl is that \quark_if_no_value:nF is fairly slow and +% if \quark_if_no_value:NF is used instead we have to do an assignment thus +% making the mapping not expandable (is that important?) + +\def:Npn \prop_map_function:NN #1#2{ + \exp_after:NN \prop_map_function_aux:w + \exp_after:NN #2 \toks_use:N #1 \q_prop \q_nil \q_prop \q_no_value \q_stop } -\def_new:Npn \prop_map_function_aux:NNn #1#2#3{ - \if_meaning:NN \q_nil #1 +\def:Npn \prop_map_function_aux:w #1\q_prop#2\q_prop#3{ + \if_meaning:NN \q_nil #2 \exp_after:NN \prop_map_break:w \fi: - #1#2{#3} - \prop_map_function_aux:NNn #1 + #1{#2}{#3} + \prop_map_function_aux:w #1 } + +% (potential) problem with the above impl is that it will returns true is #2 +% contains more than just \q_nil thus executing whatever follows. Claim: this +% can't happen :-) so we should be ok + \def_new:Npn \prop_map_function:cN {\exp_args:Nc \prop_map_function:NN } +\def_new:Npn \prop_map_function:Nc {\exp_args:NNc \prop_map_function:NN } \def_new:Npn \prop_map_function:cc {\exp_args:Ncc \prop_map_function:NN} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} +% \end{macro} % % \begin{macro}{\prop_map_inline:Nn} % \begin{macro}{\prop_map_inline:cn} -% \begin{macro}{\prop_map_inline_aux:Nn} % \begin{macro}{\l_prop_inline_level_num} % The inline functions are straight forward. It takes longer % to test if the list is empty than to run it on an empty list so @@ -692,19 +730,15 @@ \num_incr:N \l_prop_inline_level_num \def_long:cpn {prop_map_inline_ \num_use:N \l_prop_inline_level_num :n} ##1##2{#2} - \exp_args:NcE \prop_map_function:N - {prop_map_inline_ \num_use:N \l_prop_inline_level_num :n} - \prop_use:N #1 - \q_nil \q_no_value \q_stop + \prop_map_function:Nc #1 + {prop_map_inline_ \num_use:N \l_prop_inline_level_num :n} \num_decr:N \l_prop_inline_level_num } \def_new:Npn \prop_map_inline:cN { \exp_args:Nc \prop_map_inline:NN } - % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} -% \end{macro} % % \begin{macro}{\prop_map_break:w} % The break statement. @@ -713,6 +747,37 @@ % \end{macrocode} % \end{macro} % +% Finally a bunch of compatibility commands with the old syntax: they will +% vanish soon! +% \begin{macrocode} +\def:Npn \prop_put:NNn {\typeout{Warning:~name~ + changed~ to~ \string\prop_put:Nnn}\prop_put:Nnn} +\def:Npn \prop_gput:NNn {\typeout{Warning:~name~ + changed~ to~ \string\prop_gput:Nnn }\prop_gput:Nnn } +\def:Npn \prop_gput:NNo {\typeout{Warning:~name~ + changed~ to~ \string\prop_gput:Nno }\prop_gput:Nno } +\def:Npn \prop_gput:cNn {\typeout{Warning:~name~ + changed~ to~ \string\prop_gput:cnn }\prop_gput:cnn } +\def:Npn \prop_gput_if_new:NNn {\typeout{Warning:~name~ + changed~ to~ \string\prop_gput_if_new:Nnn }\prop_gput_if_new:Nnn } +\def:Npn \prop_get:NNN {\typeout{Warning:~name~ + changed~ to~ \string\prop_get:NnN }\prop_get:NnN } +\def:Npn \prop_get:cNN {\typeout{Warning:~name~ + changed~ to~ \string\prop_get:cnN }\prop_get:cnN } +\def:Npn \prop_gget:NNN {\typeout{Warning:~name~ + changed~ to~ \string\prop_gget:NnN }\prop_gget:NnN } +\def:Npn \prop_gget:cNN {\typeout{Warning:~name~ + changed~ to~ \string\prop_gget:cnN }\prop_gget:cnN } +\def:Npn \prop_get_gdel:NNN {\typeout{Warning:~name~ + changed~ to~ \string\prop_get_gdel:NnN }\prop_get_gdel:NnN } +\def:Npn \prop_del:NN {\typeout{Warning:~name~ + changed~ to~ \string\prop_del:Nn }\prop_del:Nn } +\def:Npn \prop_gdel:NN {\typeout{Warning:~name~ + changed~ to~ \string\prop_gdel:Nn }\prop_gdel:Nn } +\def:Npn \prop_if_in:NNTF {\typeout{Warning:~name~ + changed~ to~ \string\prop_if_in:NnTF }\prop_if_in:NnTF } +% \end{macrocode} +% % Show token usage: % \begin{macrocode} %</initex|package> @@ -728,123 +793,9 @@ \file_input_stop: % \end{macrocode} % -% -% \section {Properties} -% -% -% This is the version that uses individual pointers to hold the values. -% maybe we need both? -% It is currently disabled because it does not work with the -% implementation of the mark mechanism. -% -% A property list is a control sequence whose top_level expansion is -% of the form `\zz{tok$\sb1$}\zv{val$\sb1$} \ldots{} -% \zz{tok$\sb{}n$}\zv{val$\sb{}n$}'. The properties have to be single token, -% the values might be arbitrary token lists they get surrounded by -% braces. -% -% To get values from property_lists token_lists should be passed to -% the appropriate functions. -% -% -% \begin{macro}{\prop_split_aux:NNn} -% |\prop_split_aux:NNn|\zz{plist}\zz{prop}\zz{cmd} invokes \zz{cmd} -% with 3 arguments: 1st is the beginning of \zz{plist} before -% \zz{prop}, 2nd is the value associated with \zz{prop}, 3rd is the -% rest of \zz{plist} after \zz{prop}. If there is no property -% \zz{prop} in \zz{plist}, then the 2 arg is |\q_no_value | and -% the 3rd arg is empty; otherwise the 3rd argument has the two -% extra tokens \zz{prop} |\q_no_value| at the end. -% \begin{macrocode} -\def_long:Npn \prop_split_aux:NNn #1#2#3{ - \def:Npn \tmp:w ##1#2##2##3\q_stop {#3{##1}##2{##3}} - \exp_after:NN\tmp:w #1#2\q_no_value \q_stop} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\prop_get:NNN} -% \begin{macro}{\prop_get_aux:w} -% |\prop_get:NNN |\zz{plist}\zz{prop}\zz{tlp} defines -% command to be the value associated with \zz{prop} in \zz{plist}, -% |\q_no_value| if not found. -% \begin{macrocode} -\def_long:Npn \prop_get:NNN #1#2{\prop_split_aux:NNn - #1#2\prop_get_aux:w} -\def_long:Npn \prop_get_aux:w #1#2#3#4{\tlp_set_eq:NN#4#2} -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% -% \begin{macro}{\prop_put:NNn} -% \begin{macro}{\prop_put_aux:w} -% \begin{macro}{\prop_gput:NNn} -% \begin{macro}{\prop_gput:NNx} -% \begin{macro}{\prop_gput:NNo} -% \begin{macro}{\prop_gput:NOx} -% \begin{macro}{\prop_gput:NOo} -% \begin{macro}{\prop_gput:OOo} -% \begin{macro}{\prop_gput:ccx} -% |\prop_put:NNn |\zz{plist}\zz{prop}\zv{val} adds/changes the -% value associated with \zz{prop} in \zz{plist} to \zv{val}. -% \begin{macrocode} -\def_long:Npn \prop_put:NNn #1#2{\prop_split_aux:NNn - #1#2{\prop_put_aux:w \tlp_set:Nn #1#2}} -\def_long:Npn \prop_gput:NNn #1#2{\prop_split_aux:NNn - #1#2{\prop_put_aux:w \tlp_gset:Nn #1#2}} -\def:Npn \prop_gput:NNo {\exp_args:Nnno \prop_gput:NNn} -\def:Npn \prop_gput:NOx {\exp_args:Nnox \prop_gput:NNn} -\def:Npn \prop_gput:NNx {\exp_args:Nnnx \prop_gput:NNn} -\def:Npn \prop_gput:NOo {\exp_args:NNOo \prop_gput:NNn} -\def:Npn \prop_gput:OOo {\exp_args:NOOo \prop_gput:NNn} -\def:Npn \prop_gput:ccn {\exp_args:Ncc \prop_gput:NNn} -\def:Npn \prop_gput:ccx {\exp_args:Nccx \prop_gput:NNn} -\def_long:Npn \prop_put_aux:w #1#2#3#4#5#6#7{ - \quark_if_no_value:nTF#5 - { - \cs_ggen_sym:N\l_testa_tlp - \exp_after:NN#1\exp_after:NN#2\exp_after:NN{\exp_after:NN#3\l_testa_tlp#4} - \exp_after:NN\tlp_gset:Nn\l_testa_tlp - } - {#1#5} - {#7}} -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% -% -% Show token usage: % \begin{macrocode} -%<*showmemory> -%\showMemUsage -%</showmemory> %</unused> % \end{macrocode} % % \endinput % -% $Log$ -% Revision 1.15 2006/03/20 18:26:38 braams -% Updated the copyright notice (2006) and demoted all implementation -% sections to subsections and so on to clean up the toc for source3.tex -% -% Revision 1.14 2005/12/27 16:00:44 morten -% Update map functions and changed RCS information retrieval -% -% Revision 1.13 2005/03/22 23:26:14 morten -% Added more functions, removed dependency of l3seq -% -% Revision 1.12 2005/03/16 22:36:04 braams -% Added the tweaks necessary to be able to load with initex -% -% Revision 1.11 2005/03/11 21:40:35 braams -% Fixed the use of RCS information; added \StopEventually -% diff --git a/Master/texmf-dist/source/latex/expl3/l3quark.dtx b/Master/texmf-dist/source/latex/expl3/l3quark.dtx index 2511109c1cf..5379adeeda2 100644 --- a/Master/texmf-dist/source/latex/expl3/l3quark.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3quark.dtx @@ -32,26 +32,21 @@ %% %% ----------------------------------------------------------------------- % -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3quark.dtx 573 2006-08-21 20:59:37Z morten $ +\GetIdInfo$Id: l3quark.dtx 705 2007-12-02 22:14:25Z morten $ {L3 Experimental Quark Commands} -% -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3quark.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -85,6 +80,9 @@ % % By convention all constants of type quark start out with "\q_". % +% The documentation needs some updating. +% +% % \subsection{Functions} % % \begin{function}{% @@ -171,6 +169,60 @@ % "\q_nil" as an end marker. % \end{function} % +% \subsection{Recursion} +% +% This module provides a uniform interface to intercepting and +% terminating loops as when one is doing tail recursion. The building +% blocks follow below. +% +% \begin{variable}{\q_recursion_tail} +% This quark is appended to the data structure in question and +% appears as a real element there. This means it gets any list +% separators around it. +% \end{variable} +% +% \begin{variable}{\q_recursion_stop} +% This quark is added \emph{after} the data structure. Its purpose +% is to make it possible to terminate the recursion at any point +% easily. +% \end{variable} +% +% \begin{function}{% +% \quark_if_recursion_tail_stop:N | +% \quark_if_recursion_tail_stop:n | +% \quark_if_recursion_tail_stop:o | +% } +% \begin{syntax} +% "\quark_if_recursion_tail_stop:n" "{"<list element>"}" \\ +% "\quark_if_recursion_tail_stop:N" <list element> +% \end{syntax} +% This tests whether or not <list element> is equal to +% "\q_recursion_tail" and then exits, i.e., it gobbles the remainder of +% the list up to and including "\q_recursion_stop" which \emph{must} +% be present. +% +% If <list element> is not under your complete control it is advisable +% to use the "n". If you wish to use the "N" form you \emph{must} +% ensure it is really a single token such as if you have +% \begin{quote} +% "\tlp_set:Nn \l_tmpa_tlp {" <list element> "}" +% \end{quote} +% \end{function} +% +% \begin{function}{% +% \quark_if_recursion_tail_stop_do:Nn | +% \quark_if_recursion_tail_stop_do:nn | +% \quark_if_recursion_tail_stop_do:on | +% } +% \begin{syntax} +% "\quark_if_recursion_tail_stop_do:nn"\\ +% "{"<list element>"}" "{" <post action> "}" +% "\quark_if_recursion_tail_stop_do:Nn" +% <list element> "{" <post action> "}" +% \end{syntax} +% Same as "\quark_if_recursion_tail_stop:N" except here the second +% argument is executed after the recursion has been terminated. +% \end{function} % % \subsection{Constants} % @@ -196,6 +248,8 @@ % We check for \texttt{l3expan} since this a basic package that is % essential for use of any higher-level package. % \begin{macrocode} +%<package>\ProvidesExplPackage +%<package> {\filename}{\filedate}{\fileversion}{\filedescription} %<package>\RequirePackage{l3expan}\par %<*initex|package> % \end{macrocode} @@ -236,6 +290,94 @@ % \end{macro} % % +% \begin{macro}{\q_recursion_tail} +% \begin{macro}{\q_recursion_stop} +% Quarks for ending recursions. Only ever used there! +% |\q_recursion_tail| is appended to whatever list structure we are +% doing recursion on, meaning it is added as a proper list item with +% whatever list separator is in use. |\q_recursion_stop| is placed +% directly after the list. +% \begin{macrocode} +\quark_new:N\q_recursion_tail +\quark_new:N\q_recursion_stop +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\quark_if_recursion_tail_stop:n} +% \begin{macro}{\quark_if_recursion_tail_stop:N} +% \begin{macro}{\quark_if_recursion_tail_stop:o} +% When doing recursions it is easy to spend a lot of time testing if +% we found the end marker. To avoid this, we use a recursion end +% marker every time we do this kind of task. Also, if the recursion +% end marker is found, we wrap things up and finish. +% \begin{macrocode} +\def_long_new:Npn \quark_if_recursion_tail_stop:n #1 { + \exp_after:NN\if_meaning:NN + \quark_if_recursion_tail_aux:w #1?\q_nil\q_recursion_tail\q_recursion_tail + \exp_after:NN \use_none_delimit_by_q_recursion_stop:w + \fi: +} +\def_long_new:Npn \quark_if_recursion_tail_stop:N #1 { + \if_meaning:NN#1\q_recursion_tail + \exp_after:NN \use_none_delimit_by_q_recursion_stop:w + \fi: +} +\def_new:Npn \quark_if_recursion_tail_stop:o{ + \exp_args:No\quark_if_recursion_tail_stop:n +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\quark_if_recursion_tail_stop_do:nn} +% \begin{macro}{\quark_if_recursion_tail_stop_do:Nn} +% \begin{macro}{\quark_if_recursion_tail_stop_do:on} +% \begin{macrocode} +\def_long_new:Npn \quark_if_recursion_tail_stop_do:nn #1#2 { + \exp_after:NN\if_meaning:NN + \quark_if_recursion_tail_aux:w #1?\q_nil\q_recursion_tail + \exp_after:NN \use_arg_i_delimit_by_q_recursion_stop:nw + \else: + \exp_after:NN\use_none:n + \fi: + {#2} +} +\def_long_new:Npn \quark_if_recursion_tail_stop_do:Nn #1#2 { + \if_meaning:NN #1\q_recursion_tail + \exp_after:NN \use_arg_i_delimit_by_q_recursion_stop:nw + \else: + \exp_after:NN\use_none:n + \fi: + {#2} +} +\def_new:Npn \quark_if_recursion_tail_stop_do:on{ + \exp_args:No\quark_if_recursion_tail_stop_do:nn +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\quark_if_recursion_tail_aux:w} +% \begin{macro}{\use_none_delimit_by_q_recursion_stop:w} +% \begin{macro}{\use_arg_i_delimit_by_q_recursion_stop:nw} +% Helper macros for picking up the first token of a list to see if +% it is "\q_recursion_tail" and to stop the recursion. +% \begin{macrocode} +\def_long_new:Npn \quark_if_recursion_tail_aux:w + #1#2\q_nil\q_recursion_tail{#1} +\def_long_new:Npn\use_none_delimit_by_q_recursion_stop:w + #1\q_recursion_stop {} +\def_long_new:Npn\use_arg_i_delimit_by_q_recursion_stop:nw + #1#2\q_recursion_stop {#1} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% % \begin{macro}{\quark_if_no_value_p:N} % \begin{macro}{\quark_if_no_value:NTF} % \begin{macro}{\quark_if_no_value:NT} diff --git a/Master/texmf-dist/source/latex/expl3/l3seq.dtx b/Master/texmf-dist/source/latex/expl3/l3seq.dtx index dff922a84d2..259d5630c43 100644 --- a/Master/texmf-dist/source/latex/expl3/l3seq.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3seq.dtx @@ -32,27 +32,21 @@ %% %% ----------------------------------------------------------------------- % -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3seq.dtx 573 2006-08-21 20:59:37Z morten $ +\GetIdInfo$Id: l3seq.dtx 621 2007-09-01 20:14:19Z morten $ {L3 Experimental sequences and stacks} -% -% -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3seq.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -375,6 +369,8 @@ % % We start by ensuring that the required packages are loaded. % \begin{macrocode} +%<package>\ProvidesExplPackage +%<package> {\filename}{\filedate}{\fileversion}{\filedescription} %<package&!check>\RequirePackage{l3quark} %<package&!check>\RequirePackage{l3tlp} %<package&check>\RequirePackage{l3chk} diff --git a/Master/texmf-dist/source/latex/expl3/l3skip.dtx b/Master/texmf-dist/source/latex/expl3/l3skip.dtx index fee0baa4d0a..11545f09d82 100644 --- a/Master/texmf-dist/source/latex/expl3/l3skip.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3skip.dtx @@ -1,5 +1,5 @@ % \iffalse -%% File: l3skip.dtx Copyright (C) 2005-2006 Frank Mittelbach, LaTeX3 project +%% File: l3skip.dtx Copyright (C) 2005-2007 Frank Mittelbach, 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 @@ -32,26 +32,21 @@ %% %% ----------------------------------------------------------------------- % -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3skip.dtx 573 2006-08-21 20:59:37Z morten $ +\GetIdInfo$Id: l3skip.dtx 666 2007-09-27 15:53:26Z mittelba $ {L3 Experimental skip registers} -% -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3skip.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -125,6 +120,7 @@ % \skip_add:Nn | % \skip_add:cn | % \skip_gadd:Nn | +% \skip_gadd:cn | % } % \begin{syntax} % "\skip_add:Nn" <skip> "{" <length> "}" @@ -315,6 +311,7 @@ % \dim_add:Nn | % \dim_add:cn | % \dim_gadd:Nn | +% \dim_gadd:cn | % } % \begin{syntax} % "\dim_add:Nn" <dim> "{" <length> "}" @@ -519,6 +516,8 @@ % % We start by ensuring that the required packages are loaded. % \begin{macrocode} +%<package>\ProvidesExplPackage +%<package> {\filename}{\filedate}{\fileversion}{\filedescription} %<package&!check>\RequirePackage{l3int} %<package&!check>\RequirePackage{l3prg} %<package&check>\RequirePackage{l3chk} @@ -740,10 +739,9 @@ % and the logic test will take the true branch. % \begin{macrocode} \def_new:Npn \skip_infinite_glue:nTF #1{ - \prg_logic_test:nTF { - \prg_logic_or_p:nn - { \int_compare_p:nNn {\etex_gluestretchorder:D #1 } > \c_zero } - { \int_compare_p:nNn {\etex_glueshrinkorder:D #1 } > \c_zero } + \predicate:nTF { + \int_compare_p:nNn {\etex_gluestretchorder:D #1 } > \c_zero || + \int_compare_p:nNn {\etex_glueshrinkorder:D #1 } > \c_zero } } % \end{macrocode} @@ -840,6 +838,7 @@ % \begin{macro}{\dim_add:cn} % \begin{macro}{\dim_add:Nc} % \begin{macro}{\dim_gadd:Nn} +% \begin{macro}{\dim_gadd:cn} % Addition. % \begin{macrocode} \def_new:Npn \dim_add:Nn #1#2{ @@ -852,27 +851,32 @@ \def_new:Npn\dim_add:cn{\exp_args:Nc\dim_add:Nn} \def_new:Npn\dim_add:Nc{\exp_args:NNc\dim_add:Nn} \def_new:Npn \dim_gadd:Nn { \pref_global:D \dim_add:Nn } +\def_new:Npn\dim_gadd:cn{\exp_args:Nc\dim_gadd:Nn} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} +% \end{macro} % % \begin{macro}{\dim_sub:Nn} % \begin{macro}{\dim_sub:cn} % \begin{macro}{\dim_sub:Nc} % \begin{macro}{\dim_gsub:Nn} +% \begin{macro}{\dim_gsub:cn} % Subtracting. % \begin{macrocode} \def_new:Npn \dim_sub:Nn #1#2{\tex_advance:D#1-#2\scan_stop:} \def_new:Npn\dim_sub:cn{\exp_args:Nc\dim_sub:Nn} \def_new:Npn\dim_sub:Nc{\exp_args:NNc\dim_sub:Nn} \def_new:Npn \dim_gsub:Nn {\pref_global:D \dim_sub:Nn } +\def_new:Npn\dim_gsub:cn{\exp_args:Nc\dim_gsub:Nn} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} +% \end{macro} % % \begin{macro}{\dim_use:N} % \begin{macro}{\dim_use:c} diff --git a/Master/texmf-dist/source/latex/expl3/l3tlp.dtx b/Master/texmf-dist/source/latex/expl3/l3tlp.dtx index 9cf83e3912b..8cf7b54eb5f 100644 --- a/Master/texmf-dist/source/latex/expl3/l3tlp.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3tlp.dtx @@ -1,5 +1,5 @@ % \iffalse -%% File: l3tlp.dtx Copyright (C) 1990-2006 LaTeX3 project +%% File: l3tlp.dtx Copyright (C) 1990-2007 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 @@ -32,25 +32,21 @@ %% %% ----------------------------------------------------------------------- % -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3tlp.dtx 581 2006-12-12 12:28:27Z morten $ +\GetIdInfo$Id: l3tlp.dtx 735 2008-01-14 22:31:02Z morten $ {L3 Experimental Token List Pointers} -% -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} \begin{document} -\DocInput{l3tlp.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -83,7 +79,9 @@ % % \subsection{Functions} % -% \begin{function}{\tlp_new:Nn | +% \begin{function}{\tlp_new:N | +% \tlp_new:c | +% \tlp_new:Nn | % \tlp_new:cn | % \tlp_new:Nx } % \begin{syntax} @@ -92,6 +90,8 @@ % Defines <tlp> to be a new variable (or constant) of type token list % pointer. <initial token list> is the initial value of <tlp>. This % makes it possible to assign values to a constant token list pointer. +% +% The form "\tlp_new:N" initializes the token list pointer with an empty value. % \end{function} % % \begin{function}{% @@ -101,18 +101,23 @@ % \begin{syntax} % "\tlp_use:N" <tlp> % \end{syntax} -% Function that inserts the <tlp> into the processing stream. +% Function that inserts the <tlp> into the processing stream. Instead of +% |\tlp_use:N| simply placing the <tlp> into the input stream is also +% supported.|\tlp_use:c| will complain is the <tlp> hasn't been declared +% previously! % \end{function} % % \begin{function}{% % \tlp_set:Nn | % \tlp_set:Nc | % \tlp_set:No | +% \tlp_set:Nd | % \tlp_set:Nf | % \tlp_set:Nx | % \tlp_gset:Nn | % \tlp_gset:Nc | % \tlp_gset:No | +% \tlp_gset:Nd | % \tlp_gset:Nx | % \tlp_gset:cn | % \tlp_gset:cx } @@ -156,13 +161,17 @@ % \begin{function}{% % \tlp_put_left:Nn | % \tlp_put_left:No | +% \tlp_put_left:Nx | % \tlp_gput_left:Nn | % \tlp_gput_left:No | % \tlp_gput_left:Nx | % \tlp_put_right:Nn | +% \tlp_put_right:No | +% \tlp_put_right:Nx | % \tlp_put_right:cc | % \tlp_gput_right:Nn | % \tlp_gput_right:No| +% \tlp_gput_right:Nx| % \tlp_gput_right:cn| % \tlp_gput_right:co| % } @@ -174,6 +183,21 @@ % list> might be subject to expansion before assignment. % \end{function} % +% A word of warning is appropriate here: Token list pointers are +% implemented as macros and as such currently inherit some of the +% peculiarities of how \TeX\ handles "#"s in the argument of +% macros. In particular, the following actions are legal +% \begin{verbatim} +% \tlp_set:Nn \l_tmpa_tlp{##1} +% \tlp_put_right:Nn \l_tmpa_tlp{##2} +% \tlp_set:No \l_tmpb_tlp{\l_tmpa_tlp ##3} +% \end{verbatim} +% |x| type expansions where macros being expanded contain |#|s do not +% work and will not work until there is an |\expanded| primitive in +% the engine. If you want them to work you must double |#|s another +% level. +% +% % \begin{function}{% % \tlp_set_eq:NN | % \tlp_set_eq:Nc | @@ -487,9 +511,6 @@ % support arbitrary string comparison. % \end{variable} % -% \begin{function}{\tlp_put_left_aux:w} -% Used by "\tlp_put_left:Nn" and its variants. -% \end{function} % % \begin{function}{\tlp_to_str_aux:w} % Function used to implement "\tlp_to_str:N". @@ -656,6 +677,8 @@ % % We start by ensuring that the required packages are loaded. % \begin{macrocode} +%<package>\ProvidesExplPackage +%<package> {\filename}{\filedate}{\fileversion}{\filedescription} %<package&!check>\RequirePackage{l3basics} %<package&check>\RequirePackage{l3chk} % \end{macrocode} @@ -670,6 +693,8 @@ % % % +% \begin{macro}{\tlp_new:N} +% \begin{macro}{\tlp_new:c} % \begin{macro}{\tlp_new:Nn} % \begin{macro}{\tlp_new:cn} % \begin{macro}{\tlp_new:Nx} @@ -698,10 +723,14 @@ %<check> \chk_var_or_const:N #1 \gdef:Npx #1{#2} } +\def_new:Npn \tlp_new:N #1{\tlp_new:Nn #1{}} +\def_new:Npn \tlp_new:c #1{\tlp_new:cn {#1}{}} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} % % % \begin{macro}{\tlp_use:N} @@ -728,6 +757,7 @@ % % \begin{macro}{\tlp_set:Nn} % \begin{macro}{\tlp_set:No} +% \begin{macro}{\tlp_set:Nd} % \begin{macro}{\tlp_set:Nf} % \begin{macro}{\tlp_set:Nx} % \begin{macro}{\tlp_set:cn} @@ -735,6 +765,7 @@ % \begin{macro}{\tlp_set:cx} % \begin{macro}{\tlp_gset:Nn} % \begin{macro}{\tlp_gset:No} +% \begin{macro}{\tlp_gset:Nd} % \begin{macro}{\tlp_gset:Nx} % \begin{macro}{\tlp_gset:cn} % \begin{macro}{\tlp_gset:cx} @@ -789,11 +820,13 @@ % expansion module. % \begin{macrocode} \def_new:Npn \tlp_set:No {\exp_args:NNo \tlp_set:Nn} +\def_new:Npn \tlp_set:Nd {\exp_args:NNd \tlp_set:Nn} \def_new:Npn \tlp_set:Nf {\exp_args:NNf \tlp_set:Nn} \def_new:Npn \tlp_set:cn {\exp_args:Nc \tlp_set:Nn} \def_new:Npn \tlp_set:co {\exp_args:Nco \tlp_set:Nn} \def_new:Npn \tlp_set:cx {\exp_args:Nc \tlp_set:Nx} \def_new:Npn \tlp_gset:No {\exp_args:NNo \tlp_gset:Nn} +\def_new:Npn \tlp_gset:Nd {\exp_args:NNd \tlp_gset:Nn} \def_new:Npn \tlp_gset:cn {\exp_args:Nc \tlp_gset:Nn} \def_new:Npn \tlp_gset:cx {\exp_args:Nc \tlp_gset:Nx} % \end{macrocode} @@ -809,6 +842,8 @@ % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} % % \begin{macro}{\tlp_set_eq:NN} % \begin{macro}{\tlp_set_eq:Nc} @@ -916,37 +951,62 @@ % % \begin{macro}{\tlp_put_left:Nn} % \begin{macro}{\tlp_put_left:No} +% \begin{macro}{\tlp_put_left:Nx} % \begin{macro}{\tlp_gput_left:Nn} % \begin{macro}{\tlp_gput_left:No} % \begin{macro}{\tlp_gput_left:Nx} -% \begin{macro}{\tlp_put_left_aux:w} -% We can add tokens to the left (either globally or locally). -% \begin{macrocode} -\def_new:Npn \tlp_put_left:Nn #1{ -% \end{macrocode} -% We need expanding over a brace to ensure that if |#1| contains -% just one token within braces the braces are preserved. -% \begin{macrocode} - \exp_args:No \tlp_put_left_aux:w {#1}#1} -\def_new:Npn\tlp_put_left:No{\exp_args:NNo\tlp_put_left:Nn} -\def_new:Npn \tlp_gput_left:Nn { -%<*check> - \pref_global_chk: -%</check> -%<-check> \pref_global:D - \tlp_put_left:Nn +% We can add tokens to the left (either globally or locally). It is +% not quite as easy as we would like because we have to ensure the +% assignments +% \begin{verbatim} +% \tlp_set:Nn \l_tmpa_tlp{##1abc##2def} +% \tlp_set:Nn \l_tmpb_tlp{##1abc} +% \tlp_put_right:Nn \l_tmpb_tlp {##2def} +% \end{verbatim} +% cause |\l_tmpa_tlp| and |\l_tmpb_tlp| to be identical. The old +% code did not succeed in doing this (it gave an error) and so we +% use a different technique where the item(s) to be added are first +% stored in a temporary pointer and then added using an |x| type +% expansion combined with the appropriate level of +% non-expansion. Putting the tokens directly into one assignment +% does not work unless we want full expansion. Note (according to +% the warning earlier) \TeX\ does not allow us to treat |#|s the +% same in all cases. Tough. +% \begin{macrocode} +\def_long_new:Npn \tlp_put_left:Nn #1#2{ + \tlp_set:Nn \l_exp_tlp{#2} + \tlp_set:Nx #1{\exp_not:o{\l_exp_tlp}\exp_not:o{#1}} +%<check> \chk_local_or_pref_global:N #1 } -\def_new:Npn\tlp_gput_left:No{\exp_args:NNo\tlp_gput_left:Nn} -\def_new:Npn\tlp_gput_left:Nx{\exp_args:NNx\tlp_gput_left:Nn} -\def_long_new:Npn \tlp_put_left_aux:w #1#2#3{\tlp_set:Nn #2{#3#1} -% \end{macrocode} -% We check the type afterwards to avoid conflicts with the use of -% |\pref_global:D|. -% \begin{macrocode} -%<*check> - \chk_local_or_pref_global:N #2 -%</check> +\def_long_new:Npn \tlp_put_left:No #1#2{ + \tlp_set:Nn \l_exp_tlp{#2} + \tlp_set:Nx #1{\exp_not:d{\l_exp_tlp}\exp_not:o{#1}} +%<check> \chk_local_or_pref_global:N #1 +} +\def_long_new:Npn \tlp_put_left:Nx #1#2{ + \tlp_set:Nx #1{#2\exp_not:o{#1}} +%<check> \chk_local_or_pref_global:N #1 +} +\def_long_new:Npn \tlp_gput_left:Nn #1#2{ + \tlp_set:Nn \l_exp_tlp{#2} + \tlp_gset:Nx #1{\exp_not:o{\l_exp_tlp}\exp_not:o{#1}} +%<check> \chk_local_or_pref_global:N #1 +} +\def_long_new:Npn \tlp_gput_left:No #1#2{ + \tlp_set:Nn \l_exp_tlp{#2} + \tlp_gset:Nx #1{\exp_not:d{\l_exp_tlp}\exp_not:o{#1}} +%<check> \chk_local_or_pref_global:N #1 +} +\def_long_new:Npn \tlp_gput_left:Nx #1#2{ + \tlp_gset:Nx #1{#2\exp_not:o{#1}} +%<check> \chk_local_or_pref_global:N #1 } +\def_long_new:Npn \tlp_put_left:cn{\exp_args:Nc\tlp_put_left:Nn} +\def_long_new:Npn \tlp_put_left:co{\exp_args:Nc\tlp_put_left:No} +\def_long_new:Npn \tlp_put_left:cx{\exp_args:Nc\tlp_put_left:Nx} +\def_long_new:Npn \tlp_gput_left:cn{\exp_args:Nc\tlp_gput_left:Nn} +\def_long_new:Npn \tlp_gput_left:co{\exp_args:Nc\tlp_gput_left:No} +\def_long_new:Npn \tlp_gput_left:cx{\exp_args:Nc\tlp_gput_left:Nx} % \end{macrocode} % \end{macro} % \end{macro} @@ -967,15 +1027,37 @@ % These are variants of the functions above, but for adding tokens % to the right. % \begin{macrocode} -\def_long_new:Npn \tlp_put_right:Nn #1#2{\tlp_set:No #1{#1#2}} -\def_long_new:Npn \tlp_gput_right:Nn #1#2{\tlp_gset:No #1{#1#2}} -\def_new:Npn \tlp_gput_right:No {\exp_args:NNo \tlp_gput_right:Nn} -\def_new:Npn \tlp_gput_right:Nx {\exp_args:NNx \tlp_gput_right:Nn} +\def_long_new:Npn \tlp_put_right:Nn #1#2{ + \tlp_set:Nn \l_exp_tlp{#2} + \tlp_set:Nx #1{\exp_not:o{#1}\exp_not:o{\l_exp_tlp}} +%<check> \chk_local_or_pref_global:N #1 +} +\def_long_new:Npn \tlp_gput_right:Nn #1#2{ + \tlp_set:Nn \l_exp_tlp{#2} + \tlp_gset:Nx #1{\exp_not:o{#1}\exp_not:o{\l_exp_tlp}} +%<check> \chk_local_or_pref_global:N #1 +} +\def_long_new:Npn \tlp_put_right:No #1#2{ + \tlp_set:Nn \l_exp_tlp{#2} + \tlp_set:Nx #1{\exp_not:o{#1}\exp_not:d{\l_exp_tlp}} +%<check> \chk_local_or_pref_global:N #1 +} +\def_long_new:Npn \tlp_gput_right:No #1#2{ + \tlp_set:Nn \l_exp_tlp{#2} + \tlp_gset:Nx #1{\exp_not:o{#1}\exp_not:d{\l_exp_tlp}} +%<check> \chk_local_or_pref_global:N #1 +} +\def_long:Npn \tlp_put_right:Nx #1#2{ + \tlp_set:Nx #1{\exp_not:o{#1}#2} +%<check> \chk_local_or_pref_global:N #1 +} +\def_long:Npn \tlp_gput_right:Nx #1#2{ + \tlp_gset:Nx #1{\exp_not:o{#1}#2} +%<check> \chk_local_or_pref_global:N #1 +} \def_new:Npn \tlp_gput_right:cn {\exp_args:Nc \tlp_gput_right:Nn} -\def_new:Npn \tlp_gput_right:co {\exp_args:Nco \tlp_gput_right:Nn} +\def_new:Npn \tlp_gput_right:co {\exp_args:Nc \tlp_gput_right:No} \def_new:Npn \tlp_put_right:cc {\exp_args:Ncc \tlp_put_right:Nn} -\def_new:Npn \tlp_put_right:No {\exp_args:NNo \tlp_put_right:Nn} -\def_new:Npn \tlp_put_right:Nx {\exp_args:Nnx \tlp_put_right:Nn} % \end{macrocode} % \end{macro} % \end{macro} @@ -1297,14 +1379,14 @@ % marker will be read immediately and the loop terminated. % \begin{macrocode} \def_long_new:Npn \tlist_map_function:nN #1#2{ - \tlist_map_function_aux:Nn #2 #1 \q_nil \q_stop + \tlist_map_function_aux:Nn #2 #1 \q_recursion_tail \q_recursion_stop } \def_new:Npn \tlp_map_function:NN #1#2{ \exp_after:NN \tlist_map_function_aux:Nn - \exp_after:NN #2 #1 \q_nil \q_stop + \exp_after:NN #2 #1 \q_recursion_tail \q_recursion_stop } \def_long_new:Npn \tlist_map_function_aux:Nn #1#2{ - \quark_if_nil:nT{#2} \tlist_map_break:w + \quark_if_recursion_tail_stop:n{#2} #1{#2} \tlist_map_function_aux:Nn #1 } \def_new:Npn\tlp_map_function:cN{\exp_args:Nc\tlp_map_function:NN} @@ -1332,7 +1414,7 @@ ##1{#2} \exp_args:Nc \tlist_map_function_aux:Nn {tlist_map_inline_ \num_use:N \l_tlp_inline_level_num :n} - #1 \q_nil\q_stop + #1 \q_recursion_tail\q_recursion_stop \num_decr:N \l_tlp_inline_level_num } \def_long_new:Npn \tlp_map_inline:Nn #1#2{ @@ -1341,7 +1423,7 @@ ##1{#2} \exp_args:NcE \tlist_map_function_aux:Nn {tlist_map_inline_ \num_use:N \l_tlp_inline_level_num :n} - #1 \q_nil\q_stop + #1 \q_recursion_tail\q_recursion_stop \num_decr:N \l_tlp_inline_level_num } \def_new:Npn\tlp_map_inline:cN{\exp_args:Nc\tlp_map_inline:NN} @@ -1361,7 +1443,7 @@ % \zz{temp} to each element and executes \zz{action}. % \begin{macrocode} \def_long_new:Npn \tlist_map_variable:nNn #1#2#3{ - \tlist_map_variable_aux:Nnn #2 {#3} #1 \q_nil \q_stop + \tlist_map_variable_aux:Nnn #2 {#3} #1 \q_recursion_tail \q_recursion_stop } \def_new:Npn \tlp_map_variable:NNn {\exp_args:No \tlist_map_variable:nNn} \def_new:Npn \tlp_map_variable:cNn {\exp_args:Nc \tlp_map_variable:NNn} @@ -1377,7 +1459,7 @@ % \begin{macrocode} \def_long_new:Npn \tlist_map_variable_aux:Nnn #1#2#3{ \tlp_set:Nn #1{#3} - \quark_if_nil:NT #1 \tlist_map_break:w + \quark_if_recursion_tail_stop:N #1 #2 \tlist_map_variable_aux:Nnn #1{#2} } % \end{macrocode} @@ -1387,7 +1469,7 @@ % \begin{macro}{\tlp_map_break:w} % The break statement. % \begin{macrocode} -\let_new:NN \tlist_map_break:w \use_none_delimit_by_q_stop:w +\let_new:NN \tlist_map_break:w \use_none_delimit_by_q_recursion_stop:w \let_new:NN \tlp_map_break:w \tlist_map_break:w % \end{macrocode} % \end{macro} @@ -1459,7 +1541,7 @@ % \end{macrocode} % However all of this only makes sense if we actually have that % primitive. Therefore we disable it again if it is not there and -% define \verb|\tlist_if_eq:NN| the old fashioned (and unexpandable) +% define \verb|\tlist_if_eq:nn| the old fashioned (and unexpandable) % way. % \begin{macrocode} \cs_if_really_free:cT{pdf_strcmp:D}{ @@ -1468,12 +1550,46 @@ \tlp_set:Nx \l_testb_tlp {\exp_not:n{#2}} \if_meaning:NN\l_testa_tlp \l_testb_tlp } + \def_long_test_function:npn{tlist_if_eq:no}#1#2{ + \tlp_set:Nx \l_testa_tlp {\exp_not:n{#1}} + \tlp_set:Nx \l_testb_tlp {\exp_not:o{#2}} + \if_meaning:NN\l_testa_tlp \l_testb_tlp + } + \def_long_test_function:npn{tlist_if_eq:nx}#1#2{ + \tlp_set:Nx \l_testa_tlp {\exp_not:n{#1}} + \tlp_set:Nx \l_testb_tlp {#2} + \if_meaning:NN\l_testa_tlp \l_testb_tlp + } + \def_long_test_function:npn{tlist_if_eq:on}#1#2{ + \tlp_set:Nx \l_testa_tlp {\exp_not:o{#1}} + \tlp_set:Nx \l_testb_tlp {\exp_not:n{#2}} + \if_meaning:NN\l_testa_tlp \l_testb_tlp + } \def_long_test_function:npn{tlist_if_eq:oo}#1#2{ \tlp_set:Nx \l_testa_tlp {\exp_not:o{#1}} \tlp_set:Nx \l_testb_tlp {\exp_not:o{#2}} \if_meaning:NN\l_testa_tlp \l_testb_tlp } - \def_long:Npn\tlist_compare:xx #1#2{\ERROR} + \def_long_test_function:npn{tlist_if_eq:ox}#1#2{ + \tlp_set:Nx \l_testa_tlp {\exp_not:o{#1}} + \tlp_set:Nx \l_testb_tlp {#2} + \if_meaning:NN\l_testa_tlp \l_testb_tlp + } + \def_long_test_function:npn{tlist_if_eq:xn}#1#2{ + \tlp_set:Nx \l_testa_tlp {#1} + \tlp_set:Nx \l_testb_tlp {\exp_not:n{#2}} + \if_meaning:NN\l_testa_tlp \l_testb_tlp + } + \def_long_test_function:npn{tlist_if_eq:xo}#1#2{ + \tlp_set:Nx \l_testa_tlp {#1} + \tlp_set:Nx \l_testb_tlp {\exp_not:o{#2}} + \if_meaning:NN\l_testa_tlp \l_testb_tlp + } + \def_long_test_function:npn{tlist_if_eq:xx}#1#2{ + \tlp_set:Nx \l_testa_tlp {#1} + \tlp_set:Nx \l_testb_tlp {#2} + \if_meaning:NN\l_testa_tlp \l_testb_tlp + } } % \end{macrocode} % \end{macro} @@ -1507,7 +1623,7 @@ \def_new:Npn \tlp_if_in:cnTF {\exp_args:Nc\tlp_if_in:NnTF} \def_long:Npn \tlp_if_in:NnT #1#2{ \def_long:Npn\tmp:w ##1 #2 ##2\q_stop{ - \quark_if_no_value:nFT{##2} + \quark_if_no_value:nF{##2} } \exp_after:NN \tmp:w #1 #2 \q_no_value \q_stop } @@ -1565,14 +1681,14 @@ % again later on. % \begin{macrocode} \def_long_new:NNn \tlp_replace_in_aux:NNnn 4{ - \def:Npn \tmp:w ##1#3##2\q_stop{ + \def_long:Npn \tmp:w ##1#3##2\q_stop{ \quark_if_no_value:nF{##2} { % \end{macrocode} % At this point |##1| starts with a |\q_mark| so remove it. % \begin{macrocode} \tlp_set:Nx\l_tlp_replace_tlp{\exp_not:o{\use_none:n##1#4}} - \def:Npn \tmp:w ####1#3\q_no_value{ + \def_long:Npn \tmp:w ####1#3\q_no_value{ \tlp_put_right:Nx \l_tlp_replace_tlp {\exp_not:o{\use_none:n ####1}} } \tmp:w \q_mark ##2 @@ -1618,7 +1734,7 @@ % \begin{macrocode} \def_long:NNn \tlp_replace_all_in_aux:NNnn 4{ \tlp_clear:N \l_tlp_replace_tlp - \def:Npn \tmp:w ##1#3##2\q_stop{ + \def_long:Npn \tmp:w ##1#3##2\q_stop{ \quark_if_no_value:nTF{##2} { \tlp_put_right:Nx \l_tlp_replace_tlp {\exp_not:o{\use_none:n##1}} @@ -1812,11 +1928,10 @@ % and putting it in front of the ones before it. % \begin{macrocode} \def_long_new:Npn \tlist_reverse:n #1{ - \tlist_reverse_aux:nN {} #1 \q_nil\q_stop + \tlist_reverse_aux:nN {} #1 \q_recursion_tail\q_stop } \def_long_new:Npn \tlist_reverse_aux:nN #1#2{ - \quark_if_nil:NT #2 - { \use_arg_i_delimit_by_q_stop:nw {#1} } + \quark_if_recursion_tail_stop_do:nn {#2}{ #1 } \tlist_reverse_aux:nN {#2#1} } % \end{macrocode} diff --git a/Master/texmf-dist/source/latex/expl3/l3token.dtx b/Master/texmf-dist/source/latex/expl3/l3token.dtx index 43e8a4b5e81..1df1e08240d 100644 --- a/Master/texmf-dist/source/latex/expl3/l3token.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3token.dtx @@ -31,26 +31,21 @@ %% prior consultation with the LaTeX Project Team. %% %% ----------------------------------------------------------------------- -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3token.dtx 578 2006-11-21 18:13:24Z morten $ +\GetIdInfo$Id: l3token.dtx 701 2007-11-27 14:21:05Z morten $ {L3 Experimental token investigation and manipulation} -% -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3token.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -185,6 +180,28 @@ % \end{texnote} % \end{function} % +% \begin{function}{ +% \char_set_mathcode:nn | +% \char_set_mathcode:w | +% \char_gset_mathcode:nn | +% \char_gset_mathcode:w | +% \char_value_mathcode:n | +% \char_value_mathcode:w | +% \char_show_value_mathcode:n | +% \char_show_value_mathcode:w +% } +% \begin{syntax} +% "\char_set_mathcode:nn" "{"<char>"}" "{"<number>"}"\\ +% "\char_set_mathcode:w" <char> = <number> \\ +% "\char_value_mathcode:n" "{"<char>"}"\\ +% "\char_show_value_mathcode:n" "{"<char>"}" +% \end{syntax} +% Set the math code for <char>. +% \begin{texnote} +% "\char_set_mathcode:w" is the \TeX\ primitive \tn{mathcode} renamed. +% \end{texnote} +% \end{function} +% % % \subsection{Generic tokens} % @@ -739,6 +756,8 @@ % \subsection{Implementation} % First a few required packages to get this going. % \begin{macrocode} +%<package>\ProvidesExplPackage +%<package> {\filename}{\filedate}{\fileversion}{\filedescription} %<package>\RequirePackage{l3prg} %<package>\RequirePackage{l3int} %<*initex|package> @@ -770,6 +789,39 @@ % \end{macro} % \end{macro} % +% \begin{macro}{\char_set_mathcode:w} +% \begin{macro}{\char_set_mathcode:nn} +% \begin{macro}{\char_gset_mathcode:w} +% \begin{macro}{\char_gset_mathcode:nn} +% \begin{macro}{\char_value_mathcode:w} +% \begin{macro}{\char_value_mathcode:n} +% \begin{macro}{\char_show_value_mathcode:w} +% \begin{macro}{\char_show_value_mathcode:n} +% Math codes. +% \begin{macrocode} +\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}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% % \begin{macro}{\char_set_lccode:w} % \begin{macro}{\char_set_lccode:nn} % \begin{macro}{\char_value_lccode:w} @@ -1829,10 +1881,9 @@ % |\c_space_token|. % \begin{macrocode} \def_new:Npn \peek_execute_branches_charcode: { - \prg_if_predicate:nTF { - \prg_if_predicate_or_p:nn - {\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} + \predicate: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 } % \end{macrocode} diff --git a/Master/texmf-dist/source/latex/expl3/l3toks.dtx b/Master/texmf-dist/source/latex/expl3/l3toks.dtx index fd37864c815..a5d78d7386c 100644 --- a/Master/texmf-dist/source/latex/expl3/l3toks.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3toks.dtx @@ -32,26 +32,21 @@ %% %% ----------------------------------------------------------------------- % -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3toks.dtx 580 2006-11-26 15:56:47Z morten $ +\GetIdInfo$Id: l3toks.dtx 728 2008-01-01 16:11:58Z morten $ {L3 Experimental Token Registers} -% -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3toks.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -245,6 +240,8 @@ % We check for \texttt{l3expan} since this a basic package that is % essential for use of any higher-level package. % \begin{macrocode} +%<package>\ProvidesExplPackage +%<package> {\filename}{\filedate}{\fileversion}{\filedescription} %<package&check>\RequirePackage{l3chk}\par %<package>\RequirePackage{l3expan}\par %<*initex|package> @@ -576,6 +573,10 @@ % \begin{macro}{\toks_if_eq:ccTF} % \begin{macro}{\toks_if_eq:ccT} % \begin{macro}{\toks_if_eq:ccF} +% \begin{macro}{\toks_if_eq_p:NN} +% \begin{macro}{\toks_if_eq_p:cN} +% \begin{macro}{\toks_if_eq_p:Nc} +% \begin{macro}{\toks_if_eq_p:cc} % This function test whether two token registers contain the same. % \begin{macrocode} \def_new:NNn \toks_if_eq:NNTF 2 { @@ -596,6 +597,12 @@ \def_new:Npn \toks_if_eq:ccTF {\exp_args:Ncc \toks_if_eq:NNTF} \def_new:Npn \toks_if_eq:ccT {\exp_args:Ncc \toks_if_eq:NNT} \def_new:Npn \toks_if_eq:ccF {\exp_args:Ncc \toks_if_eq:NNF} +\def_new:NNn \toks_if_eq_p:NN 2 { + \tlist_if_eq_p:xx {\toks_use:N #1} {\toks_use:N #2} +} +\def_new:Npn \toks_if_eq_p:cN {\exp_args:Nc \toks_if_eq_p:NN} +\def_new:Npn \toks_if_eq_p:Nc {\exp_args:NNc \toks_if_eq_p:NN} +\def_new:Npn \toks_if_eq_p:cc {\exp_args:Ncc \toks_if_eq_p:NN} % \end{macrocode} % \end{macro} % \end{macro} @@ -609,6 +616,10 @@ % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} % % \begin{macro}{\l_tmpa_toks} % \begin{macro}{\l_tmpb_toks} diff --git a/Master/texmf-dist/source/latex/expl3/l3vers.dtx b/Master/texmf-dist/source/latex/expl3/l3vers.dtx index 06f9d44c694..748c99bde33 100644 --- a/Master/texmf-dist/source/latex/expl3/l3vers.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3vers.dtx @@ -31,26 +31,21 @@ %% prior consultation with the LaTeX Project Team. %% %% ----------------------------------------------------------------------- -%<package>\RequirePackage{l3names} -%<*dtx> +%<*driver|package> +\RequirePackage{l3names} +%</driver|package> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% - \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -} -%\iffalse -%</dtx> -%\fi -\GetIdInfo$Id: l3vers.dtx 573 2006-08-21 20:59:37Z morten $ +\GetIdInfo$Id: l3vers.dtx 621 2007-09-01 20:14:19Z morten $ {L3 Experimental LaTeX format version} -% -% \iffalse +%\iffalse %<*driver> +%\fi +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] +%\iffalse \documentclass{l3doc} - \begin{document} -\DocInput{l3vers.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi @@ -68,7 +63,7 @@ % \begin{macrocode} %<*initex> \def:Npn\c_format_name{Experimental~ LaTeX3} -\def:Npn\c_format_date{2005/12/25} +\def:Npn\c_format_date{2007/09/01} %^^A\def:Npx\c_format_version{--release--date--goes--here--} % \end{macrocode} % \end{macro} @@ -90,7 +85,7 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J !~~You~are~attempting~to~make~an~experimental~LaTeX3~format~from^^J !~~source~files~that~are~more~than~ - \num_use:N\num_eval:n{\c_fmt_too_old}~months~old.^^J + \num_value:w\num_eval:n{\c_fmt_too_old}~months~old.^^J !^^J !~~If~you~enter~<return>~to~scroll~past~this~message~then~the~format^^J !~~will~be~built,~but~please~consider~obtaining~newer~source~files^^J diff --git a/Master/texmf-dist/source/latex/expl3/l3xref-test.tex b/Master/texmf-dist/source/latex/expl3/l3xref-test.tex new file mode 100644 index 00000000000..cd58b6deb5f --- /dev/null +++ b/Master/texmf-dist/source/latex/expl3/l3xref-test.tex @@ -0,0 +1,105 @@ +%% +%% This is file `l3xref-test.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% l3xref.dtx (with options: `testfile') +%% +%% +%% EXPERIMENTAL CODE +%% +%% Do not distribute this file without also distributing the +%% source files specified above. +%% +%% Do not distribute a modified version of this file. +%% +%% +%% File: l3xref.dtx Copyright (C) 2006 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 +%% license or (at your option) any later version. The latest version +%% of this license is in the file +%% +%% http://www.latex-project.org/lppl.txt +%% +%% This file is part of the ``expl3 bundle'' (The Work in LPPL) +%% and all files in that bundle must be distributed together. +%% +%% The released version of this bundle is available from CTAN. +%% +%% ----------------------------------------------------------------------- +%% +%% The development version of the bundle can be found at +%% +%% http://www.latex-project.org/cgi-bin/cvsweb.cgi/ +%% +%% for those people who are interested. +%% +%%%%%%%%%%% +%% NOTE: %% +%%%%%%%%%%% +%% +%% Snapshots taken from the repository represent work in progress and may +%% not work or may contain conflicting material! We therefore ask +%% people _not_ to put them into distributions, archives, etc. without +%% prior consultation with the LaTeX Project Team. +%% +%% ----------------------------------------------------------------------- +\RequirePackage{l3names} +\GetIdInfo$Id: l3xref.dtx 621 2007-09-01 20:14:19Z morten $ + {L3 Experimental cross referencing} +\ProvidesFile{\jobname.tex} + [\filedate\space v\fileversion\space\filedescription] +\documentclass{article} +\usepackage{l3xref} +\ExplSyntaxOn +\def:Npn \startrecording {\iow_open:Nn \xref_write {\jobname.xref}} +\def:Npn \DefineCrossReferences { + \group_begin: + \NamesStart + \InputIfFileExists{\jobname.xref}{}{} + \group_end: +} +\AtBeginDocument{\DefineCrossReferences\startrecording} + +\xref_new:nn {name}{} +\def:Npn \setname{\tlp_set:Nn\l_xref_curr_name_tlp} +\def:Npn \getname{\xref_get_value:nn{name}} + +\xref_deferred_new:nn {page}{\thepage} +\def:Npn \getpage{\xref_get_value:nn{page}} + +\xref_deferred_new:nn {valuepage}{\number\value{page}} +\def:Npn \getvaluepage{\xref_get_value:nn{valuepage}} + +\let:NN \setlabel \xref_set_label:n + +\ExplSyntaxOff +\begin{document} +\pagenumbering{roman} + +Text\setname{This is a name}\setlabel{testlabel1}. More +text\setname{This is another name}\setlabel{testlabel2}. \clearpage + +Text\setname{This is a third name}\setlabel{testlabel3}. More +text\setname{Hello World!}\setlabel{testlabel4}. \clearpage + +\pagenumbering{arabic} + +Text\setname{Name 5}\setlabel{testlabel5}. More text\setname{Name + 6}\setlabel{testlabel6}. \clearpage + +Text\setname{Name 7}\setlabel{testlabel 7}. More text\setname{Name + 8}\setlabel{testlabel8}. \clearpage + +Now let's extract some values. \getname{testlabel1} on page +\getpage{testlabel1} with value \getvaluepage{testlabel1}. + +Now let's extract some values. \getname{testlabel 7} on page +\getpage{testlabel 7} with value \getvaluepage{testlabel 7}. +\end{document} +%% +%% +%% End of file `l3xref-test.tex'. diff --git a/Master/texmf-dist/source/latex/expl3/l3xref.dtx b/Master/texmf-dist/source/latex/expl3/l3xref.dtx index 2f03bf8b387..742def4b143 100644 --- a/Master/texmf-dist/source/latex/expl3/l3xref.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3xref.dtx @@ -32,33 +32,30 @@ %% %% ----------------------------------------------------------------------- % -%<package>\RequirePackage{l3names} -%<*dtx|testfile> +%<*driver|package|testfile> +\RequirePackage{l3names} +%</driver|package|testfile> %\fi -\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{% - \def\fileversion{#2}% - \def\filedate{#3/#4/#5}% +\GetIdInfo$Id: l3xref.dtx 621 2007-09-01 20:14:19Z morten $ + {L3 Experimental cross referencing} %\iffalse -%<dtx> \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]% -%<-dtx> \ProvidesFile{\jobname.tex}[#3/#4/#5 v#2 #8]% +%<*testfile> +\ProvidesFile{\jobname.tex} + [\filedate\space v\fileversion\space\filedescription] +%</testfile> +%<*driver> %\fi -} +\ProvidesFile{\filename.\filenameext} + [\filedate\space v\fileversion\space\filedescription] %\iffalse -%</dtx|testfile> -%\fi -\GetIdInfo$Id: l3xref.dtx 579 2006-11-25 23:38:03Z morten $ - {L3 Experimental cross referencing} -% -% \iffalse -%<*driver> \documentclass{l3doc} - \begin{document} -\DocInput{l3xref.dtx} +\DocInput{\filename.\filenameext} \end{document} %</driver> % \fi % +% % \title{The \textsf{l3xref} package\thanks{This file % has version number \fileversion, last % revised \filedate.}\\ @@ -117,6 +114,8 @@ % We start by ensuring that the required packages are loaded. % \begin{macrocode} %<*package> +\ProvidesExplPackage + {\filename}{\filedate}{\fileversion}{\filedescription} \RequirePackage{l3quark} \RequirePackage{l3toks} \RequirePackage{l3io} @@ -310,7 +309,7 @@ %<*testfile> \documentclass{article} \usepackage{l3xref} -\CodeStart +\ExplSyntaxOn \def:Npn \startrecording {\iow_open:Nn \xref_write {\jobname.xref}} \def:Npn \DefineCrossReferences { \group_begin: @@ -332,7 +331,7 @@ \let:NN \setlabel \xref_set_label:n -\CodeStop +\ExplSyntaxOff \begin{document} \pagenumbering{roman} diff --git a/Master/texmf-dist/source/latex/expl3/source3.tex b/Master/texmf-dist/source/latex/expl3/source3.tex new file mode 100644 index 00000000000..1199dbf3209 --- /dev/null +++ b/Master/texmf-dist/source/latex/expl3/source3.tex @@ -0,0 +1,399 @@ +% \iffalse +%% File: source3.dtx Copyright (C) 1990-2006 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 +%% license or (at your option) any later version. The latest version +%% of this license is in the file +%% +%% http://www.latex-project.org/lppl.txt +%% +%% This file is part of the ``expl3 bundle'' (The Work in LPPL) +%% and all files in that bundle must be distributed together. +%% +%% The released version of this bundle is available from CTAN. +%% +%% ----------------------------------------------------------------------- +%% +%% The development version of the bundle can be found at +%% +%% http://www.latex-project.org/cgi-bin/cvsweb.cgi/ +%% +%% for those people who are interested. +%% +%%%%%%%%%%% +%% NOTE: %% +%%%%%%%%%%% +%% +%% Snapshots taken from the repository represent work in progress and may +%% not work or may contain conflicting material! We therefore ask +%% people _not_ to put them into distributions, archives, etc. without +%% prior consultation with the LaTeX Project Team. +%% +%% ----------------------------------------------------------------------- +%% \fi + +% This document will typeset the LaTeX3 sources as a single document. +% This will produce quite a large file (roughly ??? pages) and may +% take a long time. +% +% Some notes on processing this document are contained at the end +% of this document, after \end{document} +% +% DPC 1997/11/17 +% JLB 2005/03/09 copied from source2e.tex for l3in2e sources +% First a special index style for makeindex +% + +\begin{filecontents}{source3.ist} +actual '=' +quote '!' +level '>' +preamble +"\n \\begin{theindex} \n \\makeatletter\\scan@allowedfalse\n" +postamble +"\n\n \\end{theindex}\n" +item_x1 "\\efill \n \\subitem " +item_x2 "\\efill \n \\subsubitem " +delim_0 "\\pfill " +delim_1 "\\pfill " +delim_2 "\\pfill " +% The next lines will produce some warnings when +% running Makeindex as they try to cover two different +% versions of the program: +lethead_prefix "{\\bfseries\\hfil " +lethead_suffix "\\hfil}\\nopagebreak\n" +lethead_flag 1 +heading_prefix "{\\bfseries\\hfil " +heading_suffix "\\hfil}\\nopagebreak\n" +headings_flag 1 + +% and just for source3: +% Remove R so I is treated in sequence I J K not I II III +page_precedence "rnaA" +\end{filecontents} + +\begin{filecontents}{l3doc.cfg} + \DisableCrossrefs + \AtEndOfClass{\OnlyDescription} +\end{filecontents} + +\begin{filecontents}{l3full.cfg} + +% Set up the Index and Change History to use \part + \IndexPrologue{\part*{Index}% + \markboth{Index}{Index}% + \addcontentsline{toc}{part}{Index}% + The italic numbers denote the pages where the + corresponding entry is described, + numbers underlined point to the definition, + all others indicate the places where it is used.} + + \GlossaryPrologue{\part*{Change History}% +% Allow control names to be hyphenated here... + {\GlossaryParms\ttfamily\hyphenchar\font=`\-}% + \markboth{Change History}{Change History}% + \addcontentsline{toc}{part}{Change History}} + + \RecordChanges + \CodelineIndex + \EnableCrossrefs + \AlsoImplementation + \setcounter{IndexColumns}{2} +\end{filecontents} + + +\documentclass{l3doc} + +\listfiles + +% Do not index some TeX primitives, and some common plain TeX commands. + +%% to be filled in later\DoNotIndex{...} +% The standard \changes command modified slightly to better cope with +% this multiple file document. +%\makeatletter +%\def\changes@#1#2#3{% +% \let\protect\@unexpandable@protect +% \edef\@tempa{\noexpand\glossary{#2\space\currentfile\space#1\levelchar +% \ifx\saved@macroname\@empty +% \space +% \actualchar +% \generalname +% \else +% \expandafter\@gobble +% \saved@macroname +% \actualchar +% \string\verb\quotechar*% +% \verbatimchar\saved@macroname +% \verbatimchar +% \fi +% :\levelchar #3}}% +% \@tempa\endgroup\@esphack} +%\makeatother + +% Needed for documentation in ltoutenc.dtx +\usepackage{textcomp} + +\begin{document} + \title{The \LaTeX3 Sources} + \author{\Team} + + \pagenumbering{roman} + \maketitle + \renewcommand\maketitle{} + + \tableofcontents + + \clearpage + + \pagenumbering{arabic} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Each of the following \DocInput lines includes a file with extension +% .dtx. Each of these files may be typeset separately. For instance +% latex l3boxes.dtx +% will typeset the source of the LaTeX3 box commands. +% +% If this file is processed, each of these separate dtx files will be +% contained as a part of a single document. Using ltxdoc.cfg you can +% then optionally produce a combined index and/or change history for +% the entire source of the format file. Note that such a document will +% be quite large (about ??? pages). +% + + \DocInput{l3names.dtx} % System dependant initialisation + + \DocInput{l3basics.dtx} % + + \DocInput{l3chk.dtx} % Checking assignments + + \DocInput{l3tlp.dtx} % + + \DocInput{l3expan.dtx} % + + \DocInput{l3num.dtx} % + + \DocInput{l3seq.dtx} % + + \DocInput{l3alloc.dtx} % + + \DocInput{l3io.dtx} % + + \DocInput{l3clist.dtx} % + + \DocInput{l3prop.dtx} % + + \DocInput{l3int.dtx} % + + \DocInput{l3skip.dtx} % + + \DocInput{l3toks.dtx} % + + \DocInput{l3messages.dtx} % + + \DocInput{l3box.dtx} % + + \DocInput{l3precom.dtx} % + + \DocInput{l3quark.dtx} % + + \DocInput{l3prg.dtx} % + + \DocInput{l3token.dtx} % + + \DocInput{l3xref.dtx} % + + \DocInput{l3calc.dtx} % + +%% \DocInput{l3vers.dtx} % Current version date + + \includeltpatch % Corrections distributed after the full release + +% Stop here if ltxdoc.cfg says \AtEndOfClass{\OnlyDescription} +\StopEventually{\PrintIndex\end{document}} + +\clearpage +\pagestyle{headings} + +% Make TeX shut up. +\hbadness=10000 +\newcount\hbadness +\hfuzz=\maxdimen + +\typeout{% + \string # Produce change log with^^J% + makeindex -s gglo.ist -o source3.gls source3.glo} + + +\PrintChanges + +\clearpage + +% makeindex needs a symbol between the parts of composite page numbers +% but we dont want one, so: +\typeout{% + \string # Produce index with^^J% + makeindex -s source3.ist source3.idx} + +\begingroup +\def\endash{--} +\catcode`\-\active +\def-{\futurelet\temp\indexdash} +\def\indexdash{\ifx\temp-\endash\fi} + +\PrintIndex +\endgroup + +% Make sure that the index is not printed twice +% (ltxdoc.cfg might have a second \PrintIndex command) +\let\PrintChanges\relax +\let\PrintIndex\relax + +\end{document} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +To use this file to produce a fully indexed source code +you need to execute the following (or equivalent) commands: + + latex source3.tex + + makeindex -s source3.ist source3.idx + makeindex -s gglo.ist -o source3.gls source3.glo + + latex source3.tex + latex source3.tex + + +The makeindex style source3.ist is used in place of the usual +doc gind.ist to ensure that I is used in the sequence I J K +not I II II, which would be the default makeindex behaviour. + +The third run with latex is only required to get the table of +contents entries for the change log and index. You may speed things up +by using the \includeonly mechanism so as not to typeset the source +files on the second run. This involves changing the file +ltxdoc.cfg +between the latex runs. + +The following unix script automates this. + (It could easily be ported to scripts for DOS or VMS, + rm is ReMove a file, and echo "..." > file writes ... to "file".) + + +After this script (after the second ==============) is a similar script +that will produce the documentation for all the files in the base +distribution that are *not* included in source3.dvi. This second script +was requested, but before using it, beware it will take a long time! +It may however be modified as required, eg to not typeset the fdd files +or whatever... + +============== +#!/bin/sh + +rm -f source3.gls source3.ind source3.toc + +# First run: +# Create new standard ltxdoc.cfg file +# Pass the (possibly empty) list of arguments supplied on the +# command line to article class. +# +# If you use A4 paper, running this script with argument +# a4paper +# may save about 30 pages. +# +echo "\PassOptionsToClass{$*}{article}" > ltxdoc.cfg + + +# Now LaTeX the file with this cfg file. +# +latex source3.tex + + +# Make the Change log and Glossary. +# +makeindex -s source3.ist source3.idx +makeindex -s gglo.ist -o source3.gls source3.glo + + +# Second run: append \includeonly{} to ltxdoc.cfg to speed up things +# (this run needed only to get changes and index listed in .toc file) +# +# Note that the index will not be made incorrect by the insertion +# of the table of contents as the front matter uses a diferent page +# numbering scheme. +# +echo "\includeonly{}" >> ltxdoc.cfg + +latex source3.tex + + +# Third and final run, to put everything together. +# First restore the cfg file: +# +echo "\PassOptionsToClass{$*}{article}" > ltxdoc.cfg +latex source3.tex + + +============== +#!/bin/sh + +# Running this script will process all the dtx fdd and *guide.tex +# and ltnews*.tex files in the LaTeX distribution, except the dtx +# files included in source3.tex. +# (The shell first script in the comments of source3.tex will +# process those.) + +# Any command line arguments (eg a4paper) are taken as options to the +# article class. + +# This script is likely to take ages! + +echo "\PassOptionsToClass{$*}{article}" > ltxdoc.cfg +echo "\batchmode" >> ltxdoc.cfg + +# The next four lines produce full indexes and change logs +# you may not want those. +echo "\AtBeginDocument{\RecordChanges}" >> ltxdoc.cfg +echo "\AtEndDocument{\PrintChanges}" >> ltxdoc.cfg +echo "\AtBeginDocument{\CodelineIndex\EnableCrossrefs}" >> ltxdoc.cfg +echo "\AtEndDocument{\PrintIndex}" >> ltxdoc.cfg + +# If you do not want any code listings, just documentation, then instead +# of the above four lines, uncomment the following: +# echo "\AtBeginDocument{\OnlyDescription}" >> ltxdoc.cfg + +echo "\PassOptionsToClass{$*}{article}" > ltxguide.cfg +echo "\batchmode" >> ltxguide.cfg + +cp ltxguide.cfg ltnews.cfg + + +for i in *dtx *fdd *guide.tex ltnews*.tex +do +B=`basename $i .dtx` + +if (grep "Include{$B}" source3.tex >/dev/null ; ) +then +echo In source3: $i +else +echo latex $i + if (latex $i > /dev/null) + then + echo latex $i + latex $i > /dev/null + echo makeindex -s gind.ist $B.idx + makeindex -s gind.ist $B.idx > /dev/null 2> /dev/null + echo makeindex -s gglo.ist -o $B.gls $B.glo + makeindex -s gglo.ist -o $B.gls $B.glo > /dev/null 2> /dev/null + echo latex $i + latex $i > /dev/null + else + echo "!!! LaTeX ERROR: $i. (See $B.log.)" + fi +fi + +done diff --git a/Master/texmf-dist/source/latex/expl3/test1.tex b/Master/texmf-dist/source/latex/expl3/test1.tex new file mode 100644 index 00000000000..d40189e37dc --- /dev/null +++ b/Master/texmf-dist/source/latex/expl3/test1.tex @@ -0,0 +1,89 @@ +% \iffalse +%% File: test1 Copyright (C) 1990-2006 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 +%% license or (at your option) any later version. The latest version +%% of this license is in the file +%% +%% http://www.latex-project.org/lppl.txt +%% +%% This file is part of the ``expl3 bundle'' (The Work in LPPL) +%% and all files in that bundle must be distributed together. +%% +%% The released version of this bundle is available from CTAN. +%% +%% ----------------------------------------------------------------------- +%% +%% The development version of the bundle can be found at +%% +%% http://www.latex-project.org/cgi-bin/cvsweb.cgi/ +%% +%% for those people who are interested. +%% +%%%%%%%%%%% +%% NOTE: %% +%%%%%%%%%%% +%% +%% Snapshots taken from the repository represent work in progress and may +%% not work or may contain conflicting material! We therefore ask +%% people _not_ to put them into distributions, archives, etc. without +%% prior consultation with the LaTeX Project Team. +%% +%% ----------------------------------------------------------------------- +%% +\def\next$Id: #1.tex #2 #3-#4-#5 #6 #7$#8{% + \def\fileversion{#2}% + \def\filedate{#3/#4/#5}% + \ProvidesFile{#1.tex}[#3/#4/#5 v#2 #8]% +} +\next$Id: test1.tex 573 2006-08-21 20:59:37Z morten $ + {L3 Test 1} +% \fi + +\documentclass{article} + +\tracingmacros2 +\usepackage{l3expan,l3io} + +\begin{document} + +\CodeStart + + +\def_new:Npn\test_cmd:nn#1#2{ + \iow_unexpanded_term:n{} + \iow_unexpanded_term:n{Argument~1:~#1} + \iow_unexpanded_term:n{Argument~2:~#2}} + + + +\def:Npn\a{A} +\def:Npn\b{B} + +\def:Npn\aa{\a} +\def:Npn\bb{\b} + +\exp_def_form:nnn {test_cmd}{nn}{oo} +\exp_def_form:nnn {test_cmd}{nn}{xx} +\exp_def_form:nnn {test_cmd}{nn}{cc} +\exp_def_form:nnn {test_cmd}{nn}{nx} + +\test_cmd:nn{a}{b} + +\test_cmd:nn{\a}{\b} + +\test_cmd:oo\aa\bb + +\test_cmd:xx\aa\bb + +\test_cmd:cc{a}{b} + +\test_cmd:nx{a}{\b} + +\CodeStop + +\LaTeX\ still works! + +\end{document} + diff --git a/Master/texmf-dist/source/latex/expl3/test2.tex b/Master/texmf-dist/source/latex/expl3/test2.tex new file mode 100644 index 00000000000..764ad74fc39 --- /dev/null +++ b/Master/texmf-dist/source/latex/expl3/test2.tex @@ -0,0 +1,73 @@ +% \iffalse +%% File: test2 Copyright (C) 1990-2006 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 +%% license or (at your option) any later version. The latest version +%% of this license is in the file +%% +%% http://www.latex-project.org/lppl.txt +%% +%% This file is part of the ``expl3 bundle'' (The Work in LPPL) +%% and all files in that bundle must be distributed together. +%% +%% The released version of this bundle is available from CTAN. +%% +%% ----------------------------------------------------------------------- +%% +%% The development version of the bundle can be found at +%% +%% http://www.latex-project.org/cgi-bin/cvsweb.cgi/ +%% +%% for those people who are interested. +%% +%%%%%%%%%%% +%% NOTE: %% +%%%%%%%%%%% +%% +%% Snapshots taken from the repository represent work in progress and may +%% not work or may contain conflicting material! We therefore ask +%% people _not_ to put them into distributions, archives, etc. without +%% prior consultation with the LaTeX Project Team. +%% +%% ----------------------------------------------------------------------- +%% +\def\next$Id: #1.tex #2 #3-#4-#5 #6 #7$#8{% + \def\fileversion{#2}% + \def\filedate{#3/#4/#5}% + \ProvidesFile{#1.tex}[#3/#4/#5 v#2 #8]% +} +\next$Id: test2.tex 573 2006-08-21 20:59:37Z morten $ + {L3 Test 2} +% \fi + + +\RequirePackage[removeoldnames]{l3names} +\RequirePackage{l3expan} + +\CodeStart + + +\def_new:Npn\foo:nn#1#2{\def:Npn\xxx{(#1)(#2)}\tex_show:D\xxx} + +\def:Npn\a{A}\def:Npn\b{B} +\def:Npn\aa{\a}\def:Npn\bb{\b} + +\def:Npn\foo:oo{\exp_args:Noo\foo:nn} +\def:Npn\foo:xx{\exp_args:Nxx\foo:nn} +\def:Npn\foo:cc{\exp_args:Ncc\foo:nn} +\def:Npn\foo:nx{\exp_args:Nnx\foo:nn} + +\foo:nn{a}{b} + +\foo:nn{\a}{\b} + +\foo:oo\aa\bb + +\foo:xx\aa\bb + +\foo:cc{a}{b} + +\foo:nx{a}{\b} + +\tex_end:D diff --git a/Master/texmf-dist/source/latex/expl3/test3.tex b/Master/texmf-dist/source/latex/expl3/test3.tex new file mode 100644 index 00000000000..3dd5f714d35 --- /dev/null +++ b/Master/texmf-dist/source/latex/expl3/test3.tex @@ -0,0 +1,135 @@ +% \iffalse +%% File: test2 Copyright (C) 1990-2006 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 +%% license or (at your option) any later version. The latest version +%% of this license is in the file +%% +%% http://www.latex-project.org/lppl.txt +%% +%% This file is part of the ``expl3 bundle'' (The Work in LPPL) +%% and all files in that bundle must be distributed together. +%% +%% The released version of this bundle is available from CTAN. +%% +%% ----------------------------------------------------------------------- +%% +%% The development version of the bundle can be found at +%% +%% http://www.latex-project.org/cgi-bin/cvsweb.cgi/ +%% +%% for those people who are interested. +%% +%%%%%%%%%%% +%% NOTE: %% +%%%%%%%%%%% +%% +%% Snapshots taken from the repository represent work in progress and may +%% not work or may contain conflicting material! We therefore ask +%% people _not_ to put them into distributions, archives, etc. without +%% prior consultation with the LaTeX Project Team. +%% +%% ----------------------------------------------------------------------- +%% +% \fi +\documentclass{article} + +\usepackage{l3precom} + +% let's dump what is known about the LaTeX internals so far. +% this will not be much as the very basic stuff doesn't get +% dumped and we haven't got anything else. +% +\dumpLaTeXstate{test1} + +\CodeStart + +% we need some variants of tlp_set which are not yet +% defined for use in the code below. +% +\exp_def_form:nnn{tlp_set}{Nn}{on} +\exp_def_form:nnn{tlp_gset}{Nn}{on} + +% okay, here we either load a dump file (testdump.cmp) +% and then jump tp \cs_dump: or we compile one for next time. +% don't forget that if you change code below it will only have any +% affect if a new dump file is written so you may have to remove +% the existing one. +% +\cs_load_dump:n{testdump} + +% two test definitions +% +\def_new:Npn\foo{some foo} +\def_new:Npn\baz{some baz} + +% we say that \foo should be dumped in the compiled style. +% this is pretty useless as it is certainly not faster than defining +% it in the first place. but this is only done for showing that it +% works. just assume that \foo is actually a pretty difficult +% definition which does need a lot of static compilation due to +% parsing, comparing values, etc., so that it is much faster load the +% final version rather than do the compilation each time again. +% +% btw note that \baz is not dumped and will not be available in the +% production run (ie the one using the cmp file) +% +\cs_record_name:N\foo + +% get our self a scratch register (again this will not be available in +% the production run) +% +\tlp_new:Nn\l_scratch_tlp{} + +% now we generate a unique cs name and assign it the string "foo". +% again pretty useless example. but with this mechansim you can build +% complex graph structures etc using these names as pointers, etc. and +% in such a case you need to dump the state of your graph at some +% point to be able to load it very fast in production. +% +\cs_gen_sym:N\l_scratch_tlp{} +\tlp_set:on \l_scratch_tlp {foo} + +% ditto for a global unique name +% +\cs_ggen_sym:N\l_scratch_tlp{} +\tlp_gset:on \l_scratch_tlp {bar} + +% and now we dump the whole rubbish. In the current implementation +% only csnames can be precompiled, perhaps registers should be handled +% similarly. +% +\cs_dump: + +% and some int register to show something in the second LaTeX state +% dump. +% +\int_new:N\l_my_int +\int_set:Nn\l_my_int{42} +% +% as the allocation routines are not distributed we have to do this +% manually. +% +\register_record_name:N\l_my_int + +\dumpLaTeXstate{test2} + +% and changing something ... what happens with the LaTeX state? +% +\int_set:Nn\l_my_int{0} +\def:Npn\file_not_found:nTF#1#2#3{} + +\dumpLaTeXstate{test3} + +\CodeStop + +\begin{document} + +\LaTeX\ still works! + +\end{document} + + + + |