% \begin{meta-comment} % % $Id: mdwkey.dtx,v 1.1 2003/09/05 16:09:56 mdw Exp $ % % Parsing key/value pairs % % (c) 2003 Mark Wooding % %----- Revision history ----------------------------------------------------- % % $Log: mdwkey.dtx,v $ % Revision 1.1 2003/09/05 16:09:56 mdw % New feature\! % % % \end{meta-comment} % % \begin{meta-comment} %% %% mdwkey package -- yet another key/value parser %% Copyright (c) 2003 Mark Wooding %<*package> %% %% This program is free software; you can redistribute it and/or modify %% it under the terms of the GNU General Public License as published by %% the Free Software Foundation; either version 2 of the License, or %% (at your option) any later version. %% %% This program is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied warranty of %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the %% GNU General Public License for more details. %% %% You should have received a copy of the GNU General Public License %% along with this program; if not, write to the Free Software %% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. % %% % \end{meta-comment} % % \begin{meta-comment} %<+package&!plain>\NeedsTeXFormat{LaTeX2e} %<+package&!plain>\ProvidesPackage{mdwkey} %<+package&!plain> [2003/08/21 1.0 key/value parser] % \end{meta-comment} % % \CheckSum{316} %\iffalse %<*package> %\fi %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z %% Digits \0\1\2\3\4\5\6\7\8\9 %% Exclamation \! Double quote \" Hash (number) \# %% Dollar \$ Percent \% Ampersand \& %% Acute accent \' Left paren \( Right paren \) %% Asterisk \* Plus \+ Comma \, %% Minus \- Point \. Solidus \/ %% Colon \: Semicolon \; Less than \< %% Equals \= Greater than \> Question mark \? %% Commercial at \@ Left bracket \[ Backslash \\ %% Right bracket \] Circumflex \^ Underscore \_ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} %% %\iffalse % %\fi % % \begin{meta-comment} % %<*driver> \input{mdwtools} \describespackage{mdwkey} \mdwdoc % % % \end{meta-comment} % %^^A------------------------------------------------------------------------- % \section{User's guide} % % This is a key/value-pair parser, rather like the one in David Carlisle's % \package{keyval} package but a little more powerful. There's no problem % with having both in the same program. % % \subsection{Terminology} % % A \emph{key-value pair} is a pair \syntax{ `=' }, where the % \lit{=} appears at the topmost bracing level. A \emph{tag} is just a % single \syntax{}. A \emph{list} is a sequence of key-value pairs and % tags separated by commas \lit{,} at the topmost bracing level. A \ or % \ has a leading and/or trailing space removed, if there are any, and % if the whole thing is enclosed in braces, then the braces are removed. % Examples: % \begin{itemize} \synshorts % \item "foo = bar" is a key-value pair. The key is `foo' and the value is % `bar'. % \item `{foo = bar}' is a tag. The key is `foo = bar'. % \item `foo = { bar }' is a key-value pair. The key is `foo' and % the value is ` bar ' (with the leading and trailing spaces). % \item `foo = { bar }x' is a key-value pair. The key is `foo' and % the value is `{ bar }x'. % \item `one, two' is a list of two tags, `one' and `two'. % \item `one, {two, three}' is a list of two tags, `one' and `two, three'. % \end{itemize} % There is no way to get an unmatched brace into a \ or \ without % stupid catcode tricks. % % \subsection{Using the system} % % \DescribeMacro\mkdef % New key names, and what to do when they're encountered, is all defined % using |\mkdef|. Keys are gathered into \emph{groups}, so that lots of % people can use the system without treading on their toes. I recommend that % people use \syntax{":"