LATEX-L Archives

Mailing list for the LaTeX3 project


Options: Use Forum View

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

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

Print Reply
aparsloe <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Sat, 29 Aug 2015 21:09:47 +1200
text/plain (48 lines)
On 29/08/2015 9:26 a.m., Bruno Le Floch wrote:
> Joseph understood your point perfectly well. Xparse takes care of 
> matching nested parentheses, and does that expandably too. It would be 
> possible for Andrew to abuse xparse to grab his parenthesized group, 
> but I am not sure whether I want to advise this or not. It would also 
> be possible to simply copy the code, but finding out where this is 
> done in xparse's code is non-trivial. I could also just provide code 
> that does that, but it would take 30 minutes to get completely right 
> and clean (the code needs to carefully preserve braces when grabbing 
> delimited arguments, for instance). Using \tl_set_rescan:Nnn seems 
> reasonable given the above.

> Bruno 
The suggestion that the documentation note the use of empty setups for 
\tl_set_rescan:Nnn seems to have sparked a wider discussion (much of it 
beyond me, but interesting as a spectator). The final area where I've 
used rescanning is in parsing nested commas for functions of multiple 
arguments. l3fp has max and min. It is easy to translate an expression 
involving possibly nested \max and \min to a form that l3fp can digest. 
All the hard parsing work is conducted out of sight in l3fp. But there 
are other functions, like greatest common divisor, \gcd, which have no 
corresponding l3fp member. To handle an expression like \gcd(15,24,33) I 
equate a comma list to the argument 15,24,33 then pop the items of the 
comma list into token list variables which can be converted to integers 
and fed to the gcd algorithm. But for a nested expression like


the argument of the outer \gcd can't be equated to a comma list without 
mangling the mathematical syntax. I've treated this by rescanning ( and 
) to group begin and end in the argument token list, then equating a 
comma list to the rescanned argument. The individual items of the comma 
list are now the correct ones. The token lists resulting on popping 
items from the comma list are then rescanned with an empty setup to get 
everything back to "normal", converted to integers and fed to the gcd 

To me the way rescanning cuts through the complexity makes it seem (as 
they say in medicine of an effective drug) like a magic bullet.


This email has been checked for viruses by Avast antivirus software.