LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

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

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

Print Reply
Subject:
From:
James Kilfiger <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Mon, 1 Nov 1999 13:41:00 +0000
Content-Type:
text/plain
Parts/Attachments:
text/plain (41 lines)
> we had a bit of discussion some time ago on how to extend xparse
>
> here is one suggestion which i think might be of interest:
>
> suppose we have a parsing class "x" in the second argument of
> \DeclareUserCommand which would take a list of tokens (for example comma
> spearated) and parses the input to see if any of those tokens follows. If so
> it would return \BooleanTrue otherwise \BooleanFalse. eg

I've got an implementation of something like this, but I'm not very
proud of it (it doesn't do expansion, and
\DeclareDocumentCommand{x{\foo\bar}m}{} causes errors, x{} must be the
last argument. and it doesn't use commas).  The internals of the code are:

\long\def\@ddc@x#1#2\toks@{
   % Need to test that #2=\the, without breaking \@ifnexttokenin
   \@ifnexttokenin{#1}
    {\addto@hook\toks@\BooleanTrue #2\toks@}
    {\addto@hook\toks@\BooleanFalse #2\toks@}}

\def\q@stop{\errmessage{quarky~ thing~ expanded!}}
\def\@firstofmany#1#2\q@stop{#1}  % Are there internals that already do this?
\def\@restofmany#1#2\q@stop{#2}
\long\def\@ifnexttokenin#1#2#3#4{
   \ifx/#1/
        #3#4
     \else
      \expandafter\@ifnextchar\@firstofmany#1\q@stop
         {#2\@gobble}
         {\expandafter\@ifnexttokenin\expandafter
                         {\@restofmany#1\q@stop} {#2} {#3} #4\@gobble}
         #4
   \fi
}

(you also have to put a parser in \@ddc for x and rename all the
\ddc@xmmm to avoid a name clash)

Surely this can be done better.
        James

ATOM RSS1 RSS2