LATEX-L Archives

Mailing list for the LaTeX3 project


Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Bruno Le Floch <[log in to unmask]>
Wed, 16 Feb 2011 08:28:33 -0500
text/plain (73 lines)
The code for reversing tl follows. I will send the code for full
expansion in a nice form soon.

As I now understand, the key point in all of this is that we can
detect spaces and braces expandably using delimited arguments, and we
can then be sure to act on one token at a time.

The current implementation ( )

- brace group: applies   \UL_table_<table-name>_braces   to the brace group

- token: if   \UL_table_<table-name>_<token>   exists, use it,
else   \UL_table_<table-name>_default{<token>}

For e.g., \Lowercase and \Uppercase, we use many macros (one per
letter that has a different capitalization than itself), but for other
applications I mentionned, there are only a few special tokens. If we
want to limit the number of tokens, nothing prevents us from making
the  \UL_..._default  test its argument against a given list to know
what to do, closer to what Joseph was doing. It will be ~15 times
slower (back to the previous speed) for \Uppercase and \Lowercase, but
for the rest, nothing will change.

By adding an argument to (almost) every macro, we can manipulate
tables of case change with an argument. With some work, this can allow
us some pretty crazy things, e.g.


Tell me if it is useful.

% ======== Code for \UL_reverse:n =========
% To reverse, we just need to set the correct output.
\input ULcase.sty\relax

% To output one token, place it after the end of what we are reading
(this is from
% Joseph's implementation). Namely, at the /start/ of  the argument of
% |\UL_to_case_end:n|.



% The default action is to output the given token.
% Spaces don't need a special treatment.
% Braces are treated in the same way as for the ULnil table, except that the
% output is done using |\UL_reverse_output:n|.


% ========= Tests
\long\def\a{\UL_reverse:n{\a{ b \} cd\{e}f}}
\long\def\b{f{e\{dc \} b }\a}