Debian Codegraph @

texmf-dist/doc/latex/tokenizer/tokenizer.tex

raw
1 % Copyright 2003 Sascha Herpers
2 %
3 % This file can be redistributed and/or modified under the terms
4 % of the LaTeX Project Public License Distributed from CTAN
5 % archives in directory macros/latex/base/lppl.txt; either
6 % version 1 of the License, or any later version.
7 %
8 %
9 % 2003-05-22
10 % Sascha Herpers
11 % [email protected]
12 \documentclass[draft]{article}
13 \usepackage{tokenizer}
14 \usepackage{verbatim}
15 \usepackage{tabularx}
16
17 \setlength{\parindent}{0pt}
18
19 \begin{document}
20 \title{\texttt{tokenizer.sty}}
21 \author{Sascha Herpers\thanks{[email protected]}}
22 \date{\today} \maketitle
23 \begin{abstract}
24 \noindent This package provides a command \verb+\GetTokens+, which
25 splits a comma separated list of strings into
26 tokens.\footnote{Thanks to Harald Harders for his support.}\\
27
28 \noindent Version: 1.1.0 (May 26, 2003)
29 \end{abstract}
30
31 \section{Usage}
32 This package defines the following command:
33 \begin{center}
34 \verb+\GetTokens{<name1>}{<name2>}{<source>}+.
35 \end{center}
36
37 \verb+\GetTokens+ can be used to split a comma separated list of
38 strings passed as \verb+<source>+ into two tokens at the first
39 encounter of a comma. While doing so, two commands with the name
40 \verb+<name1>+ and \verb+<name2>+ are defined. The string up to
41 the first comma of \verb+<source>+ is assigned as value for
42 \verb+\<name1>+ and the rest is assigned to \verb+\<name2>+.\\
43
44 By default the tokens are left as is, i.\,e. leading and trailing
45 spaces are not removed. However, if this behavior is not
46 desirable, you can use the package option \textbf{trim}.
47 Specifying this option causes each token to be stripped off
48 leading and trailing spaces.\footnote{Omitting the trim options
49 has the same result as using the \textbf{notrim} option.}\\
50
51 As a byproduct to the trim option the tokenizer package defines
52 the following command:
53 \begin{center}
54 \verb+\TrimSpaces{<source>}+
55 \end{center}
56 \verb+\TrimSpaces+ can be used remove spaces from the text passed
57 as first parameters.
58
59 \section{Example}
60 The example shown in listing 1 illustrates the use of
61 \verb+\GetTokens+. Firstly, a source string \verb+\Source+ is
62 created, which contains the strings to be separated. The following
63 while statement loops until there are no more tokens to process.
64 \verb+\GetTokens+ is called and the separated tokens are stored in
65 two commands \verb+\TokenOne+ and \verb+\TokenTwo+, which are
66 created by \verb+\GetTokens+. Lastly, \verb+\Source+ is replaced
67 by the remainder string contained in \verb+\TokenTwo+.\\
68
69
70 \hrule
71 \begin{verbatim}
72 \def\Source{ this , is , a , short , test }
73 The string \emph{\Source} contains the following tokens:\\
74 \whiledo{\not\equal{\Source}{}}
75 {
76 \GetTokens{TokenOne}{TokenTwo}{\Source}
77 \hspace*{.3cm}$\bullet$ [\TokenOne]\\
78 \let\Source\TokenTwo
79 }
80 \end{verbatim}
81 \hrule
82 \begin{center}
83 Listing 1: example usage of \verb+\GetTokens+
84 \end{center}
85
86 This is the output produced by the above example:\\
87 \begin{center}
88 \begin{minipage}{9cm}
89 \def\Source{ this , is , a , short , test }
90 The string \emph{\Source} contains the following tokens:\\
91 \whiledo{\not\equal{\Source}{}}
92 {
93 \GetTokens{TokenOne}{TokenTwo}{\Source}
94 \hspace*{.3cm}$\bullet$ [\TokenOne]\\
95 \let\Source\TokenTwo
96 }
97 \end{minipage}
98 \end{center}
99
100 \newpage
101 \section{History}
102 \begin{tabularx}{\textwidth}{lX}
103 \hline
104 date & change\\
105 \hline
106 05/26/03 & added packages options \textbf{trim} and \textbf{notrim}\\
107 \end{tabularx}
108
109 \end{document}