% \iffalse
%
% NOTE: This file still contains very long lines (upto approx 270 characters).
%       I haven't wrapped them since I won't do that by hand, and I haven't
%       written any program doing the work.
%
%       If you want to read this .dtx file, you might get in trouble with
%       such long lines!
%
% Trademarks appear throughout this documentation without any trademark
% symbol, so you can't assume that a name is free. There is no intention
% of infringement; the usage is to the benefit of the trademark owner.
%
%
%  S O F T W A R E   L I C E N S E
% =================================
%
% The files  listings.dtx  and  listings.ins  and all files generated
% from only these two files are referred as `the listings package' or
% simply `the package'. A `language driver' or short `driver' is
% generated from  lstdrvrs.dtx.
%
% Copyright.
%   The listings package is copyright 1996--1999 Carsten Heinz.
%   The language drivers are copyright 1997/1998/1999 any individual
%   author listed in the driver files.
%
% Distribution and warranty.
%   The listings package as well as lstdrvrs.dtx and all drivers are
%   distributed under the terms of the LaTeX Project Public License
%   from CTAN archives in directory  macros/latex/base/lppl.txt.
%   Either version 1.0 or, at your option, any later version.
%
% Use of the package.
%   The listings package is free software. However, if you distribute the
%   package as part of a commercial product or if you use the package to
%   prepare a document and sell the document (books, journals, and so on),
%   I'd like to encourage you to make a donation to the LaTeX3 fund. The
%   size of this `license fee' should depend on the value of the package
%   for your product.
%
%   If you use the package to typeset a non-commercial document, please
%   send me a copy of the document (hardcopy, .dvi, .ps, .pdf, etc.) to
%   support further development.
%
% Modification advice.
%   Permission is granted to change the listings package as well as
%   lstdrvrs.dtx. You are not allowed to distribute any changed version
%   of the package or any changed version of lstdrvrs.dtx, neither under
%   the same name nor under a different one. Tell the author of the
%   package about your local changes: other users will welcome removed
%   bugs, new features and additional programming languages.
%
% Contacts.
%   Send comments and ideas on the package, error reports and additional
%   programming languages to
%
%       Carsten Heinz
%       Tellweg 6
%       42275 Wuppertal
%       Germany
%
%   or preferably to 
%
%       cheinz@gmx.de
%
% end of software license
%
%<*driver>
\documentclass{ltxdoc}

\usepackage[writefile,doc,breaklines]{listings}[1999/07/12]
\IfFileExists{fancyvrb.sty}{\usepackage{fancyvrb}}{}
\IfFileExists{color.sty}{\usepackage{color}}{}

%\EnableCrossrefs         
%\CodelineIndex
\DisableCrossrefs         
\OnlyDescription

\begin{document}
    \DocInput{listings.dtx}
\end{document}
%</driver>
% \fi
%
%^^A
%^^A check which packages are available
%^^A
% \newif\iffancyvrb
% \IfFileExists{fancyvrb.sty}{\fancyvrbtrue}{}
% \newif\ifcolor
% \IfFileExists{color.sty}{\colortrue}{}
%
%
% \makeatletter
%^^A
%^^A Modified environments (TODO: Both must be rewritten since only one environment is indexed.)
%^^A
%\def\aspect{^^A
%    \def\SpecialMainEnvIndex##1{^^A
%        \@bsphack
%        \index{aspects:\levelchar{\protect\sffamily##1}\encapchar main}^^A
%        \@esphack}^^A
%    \begingroup \catcode`\\12 \MakePrivateLetters
%    \m@cro@ \iffalse}
%\let\endaspect\endmacro
%
%\def\lstkey{^^A
%    \def\SpecialMainEnvIndex##1{^^A
%        \@bsphack
%        \index{keys:\levelchar{\protect\ttfamily##1}\encapchar main}^^A
%        \@esphack}^^A
%    \begingroup \catcode`\\12 \MakePrivateLetters
%    \m@cro@ \iffalse}
%\let\endlstkey\endmacro
%
%^^A
%^^A We redefine the appearance of part, section, ...
%^^A
%\def\@part[#1]#2{\addcontentsline{toc}{part}{#1}%
%    {\parindent\z@ \raggedright \interlinepenalty\@M
%     \normalfont \huge \bfseries #2\markboth{}{}\par}%
%    \nobreak\vskip 3ex\@afterheading}
%\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}^^A
%                                      {1.25ex \@plus1ex \@minus.2ex}^^A
%                                      {-1em}^^A
%                                      {\normalfont\normalsize\bfseries}}
%\renewcommand*\l@section[2]{^^A
%    \addpenalty\@secpenalty
%    \addvspace{.25em \@plus\p@}^^A
%    \setlength\@tempdima{1.5em}^^A
%    \begingroup
%      \parindent \z@ \rightskip \@pnumwidth
%      \parfillskip -\@pnumwidth
%      \leavevmode ^^A \bfseries
%      \advance\leftskip\@tempdima
%      \hskip -\leftskip
%      #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
%    \endgroup}
%\renewcommand*\l@subsection{\@dottedtocline{2}{0pt}{2.3em}}
%\renewcommand*\l@subsubsection{\@dottedtocline{3}{0pt}{3.2em}}
%
%^^A
%^^A Suppress warning
%^^A
% \let\lstenv@DroppedWarning\relax
%
%^^A
%^^A The following definitions come in handy.
%^^A
% \gdef\lst@emails{}
% \newcommand*\lstthanks[2]{#1\lst@AddTo\lst@emails{,#1,<#2>}}
% \newcommand*\lsthelper[3]{{\let~\ #1}\lst@IfOneOf#1\relax\lst@emails
%     {}{\typeout{^^JWarning: Unknown helper #1.^^J}}}
% \makeatother
%
% \newcommand*\lst{\texttt{lst}}
% \let\packagename\textsf
% \let\keyname\texttt
% \let\hookname\texttt
% \newcommand*\aspectname[1]{{\normalfont\sffamily#1}}
% \newcommand*\floatrule{\hbox{\vbox{\hrule width \linewidth}}}
%
%^^A
%^^A We don't need driver files since we provide our own language.
%^^A
% \lstdefinelanguage[doc]{Pascal}{^^A
%  keywords={alfa,and,array,begin,boolean,byte,case,char,const,div,^^A
%      do,downto,else,end,false,file,for,function,get,goto,if,in,^^A
%      integer,label,maxint,mod,new,not,of,or,pack,packed,page,program,^^A
%      procedure,put,read,readln,real,record,repeat,reset,rewrite,set,^^A
%      text,then,to,true,type,unpack,until,var,while,with,write,writeln},^^A
%  sensitive=false,^^A
%  doublecomment={(*}{*)}{\{}{\}},^^A
%  stringizer=[d]{'}}^^A
% \lstset{defaultdialect=[doc]Pascal}
% \lstset{language=Pascal}
% \lstdefinestyle{}
%    {basicstyle={},%
%     keywordstyle=\bfseries,identifierstyle={},%
%     commentstyle=\itshape,stringstyle={},%
%     labelstyle={},labelstep=0}
% \lstset{style={}}
%
%
%^^A
%^^A The long awaited beginning of documentation
%^^A
% \newbox\abstractbox
% \setbox\abstractbox=\vbox{
%	\begin{abstract}
%	Listings.dtx is a source code printer for \LaTeX.
%	You can typeset stand alone files as well as enter listings using an environment similar to \texttt{verbatim} as well as you can print fragments using a command similar to |\verb|.
%	Many parameters control the output and the package supports a wide spectrum of programming languages --- some come already with \texttt{lstdrvrs.dtx}.
%	\end{abstract}}
%
% \title{{Listings.dtx} Version $0.2000^{\hbox{\normalsize\textcircled{\scriptsize\lower0.2em\hbox{$\ddot\smile$}}}}$}
% \author{Copyright 1996--1999 Carsten Heinz}
% \date{\box\abstractbox}
%
% \csname @twocolumntrue\endcsname
% \maketitle
% \csname @starttoc\endcsname{toc}
% \vfill
% \noindent \textbf{Minor incompatibilities!}
% And again there will be teething troubles since some sensitive parts have been rewritten.
% \onecolumn
%
%
% \section*{Preface}
%
% \paragraph{Trademarks.}
% Trademarks appear throughout this documentation without any trademark symbol, so you can't assume that a name is free.
% There is no intention of infringement; the usage is to the benefit of the trademark owner.
%
% \paragraph{Alternatives.}
% This package is certainly not the final utility for typesetting source code.
% Other programs do their jobs very well if you are not satisfied with \packagename{listings}.
% Mainly I should mention the `general text to PostScript' converter \packagename{a2ps} and the `source code to \texttt{.tex}' cross compiler \packagename{LGrind}.
% Both's functionality can be compared with the functionality of this package.
% Therefore they are too complex to describe them here more detailed.
%
% The \packagename{listing} package --- note the missing \packagename{s} --- is not worth to talk about in our context since it defines |\listoflistings| and an environment without any keyword, comment, string or whatever else detection.\footnote{
% Furthermore the aphorism about documentation at the end of \texttt{listing.sty} is not true.}\space ^^A :-)
% But it's possibly useful if you have another tool doing that work.
%
% The \packagename{algorithms} package (\texttt{algorithmic.sty} and \texttt{algorithm.sty}) goes a quite different way.
% You describe an algorithm and the package \emph{formats} it!
% `Ruled', `boxed' and floating algorithms, a list of algorithms and line numbers are also supported.
%
% To complete the alternatives, here some packages for verbatim listings, which do not pretty-print the source code --- at least not automatically.
% \packagename{verbatim} and \packagename{moreverb} together provide verbatim listings, verbatim listings of stand alone files, verbatim output to a file, `boxed' verbatims and line numbers.
% The \packagename{alltt} package is like \packagename{verbatim} except that |\|, |{| and |}| have the usual meanings:
% You can use commands in the verbatims, e.g.\ select different fonts or enter math mode.
% Finally I'd like to mention \packagename{fancyvrb}.
% Roughly speaking it's a super set of the other three packages, but many more parameters control the output.
% Moreover there exists an interface to \packagename{listings}, i.e.\ you can pretty-print source code automatically.
%
% All packages are available from CTAN.
%
% \paragraph{Reading this manual.}
% If you are experienced with the \packagename{listings} package, you should read the paragraph ``\emph{News and changes}'' below.
% If you've just decided to try or to use this package (possibly together with an alternative listed above), read section ``\emph{\ref{uGettingStarted}. Getting started}'' step by step.
% Afterwards and after some practice with the most basic features you should be able to pick up more from the main reference.
%
% \paragraph{News and changes.}
% We begin with some new features.
% The `escape', `frame' and `fancyvrb' aspects have been extended and automatic breaking of long lines is completely new.
% Second order keywords need no extra loading since they are built-in.
% About 30 keys have been added, look in sections \ref{uMainReference} and \ref{uExperimentalFeatures} for the label `0.20' in the right margin.
% In particular listings might have captions and can float.
% Note also that |\lstinline| has an optional key=value list and that |\lstbox| doesn't exist any more.
% The package uses an auto-detection.
% Eventually I hope that the package works under Lambda.
%
% Now come commands and keys which have been renamed or replaced (often by more genereal ones).
% \begin{center}
%   \begin{tabular}{r@{\quad was\quad}l}
%   \cs{lstlistoflistings}&\cs{listoflistings}\\
%   \cs{lstlistlistingname}&\cs{listlistingsname}\\
%   \keyname{identifierstyle}&\keyname{nonkeywordstyle}\\
%   \keyname{directives}&\keyname{cdirectives}\\
%   \keyname{keywordcommentsemicolon}&\keyname{doublekeywordcommentsemicolon}\\
%   \keyname{advancelabel}&\keyname{advancelineno}
%   \end{tabular}
%   \begin{tabular}{r@{\quad replaces\quad}l}
%   \keyname{basewidth}&\keyname{baseem}\\
%   \keyname{stringspaces}&\keyname{blankstring}\\
%   \cs{lst@definelanguage}&\cs{lstdefinedrvlanguage}\\
%   \end{tabular}
% \end{center}
%
% By definition |\lststorekeywords|, \keyname{pre}, \keyname{post}, |\lstname| and |\lstintname| are obsolete.
% Read section \ref{uObsoleteKeysAndCommands} if you want to know more.
%
% \paragraph{Mailing list.}
%   If you want to receive release information, bug reports, work-arounds, and so on, email to \texttt{cheinz@gmx.de} with subject \texttt{subscribe listings}.
%   In the body you might state which information you don't want.
%
% \paragraph{Thanks.}
% There are many people I have to thank for fruitful communication, posting their ideas, giving error reports (first bug finder is listed), adding programming languages to \texttt{lstdrvrs.dtx}, and so on.
% If you want to know that in detail, search for the names in the implementation part.
%^^A
%^^A Thanks for error reports (first bug finder only), new programming languages, etc.
%^^A Special thanks for communication which lead to kernel extensions.
%^^A 
% Special thanks go to (alphabetical order)
% \begin{quote}
% \hyphenpenalty=10000\relax \rightskip=0pt plus \linewidth\relax
%   \lstthanks{Andreas~Bartelt}{Andreas.Bartelt@Informatik.Uni-Oldenburg.DE},
%   \lstthanks{Jan~Braun}{Jan.Braun@tu-bs.de},
%   \lstthanks{Denis~Girou}{Denis.Girou@idris.fr},
%   \lstthanks{Arne~John~Glenstrup}{panic@diku.dk},
%   \lstthanks{Rolf~Niepraschk}{niepraschk@PTB.DE},
%   \lstthanks{Rui~Oliveira}{rco@di.uminho.pt} and
%   \lstthanks{Boris~Veytsman}{boris@plmsc.psu.edu}.
% \end{quote}
% Moreover I wish to thank
% \begin{quote}
% \hyphenpenalty=10000\relax \rightskip=0pt plus \linewidth
%   \lstthanks{Bj{\o}rn~{\AA}dlandsvik}{bjorn@imr.no},
%   \lstthanks{Gaurav~Aggarwal}{gaurav@ics.uci.edu},
%   \lstthanks{Jason~Alexander}{jalex@ea.oac.uci.edu},
%   \lstthanks{Donald~Arseneau}{ASND@erich.triumf.ca},
%   \lstthanks{Peter~Bartke}{bartke@inf.fu-berlin.de},
%   \lstthanks{Peter~Biechele}{peter.biechele@physik.uni-freiburg.de},
%   \lstthanks{Kai~Below}{below@tu-harburg.de},
%   \lstthanks{David~Carlisle}{carlisle@cs.man.ac.uk},
%   \lstthanks{Patrick~Cousot}{Patrick.Cousot@wanadoo.fr},
%   \lstthanks{Holger~Danielsson}{dani@fbg.schwerte.de},
%   \lstthanks{Detlev~Dr\"oge}{droege@informatik.uni-koblenz.de},
%   \lstthanks{Anders~Edenbrandt}{Anders.Edenbrandt@dna.lth.se},
%   \lstthanks{David~John~Evans}{Matrix.Software@dial.pipex.com},
%   \lstthanks{Harald~Harders}{h.harders@tu-bs.de},
%   \lstthanks{Christian~Haul}{haul@dvs1.informatik.tu-darmstadt.de},
%   \lstthanks{Aidan~Philip~Heerdegen}{Aidan.Heerdegen@anu.edu.au},
%   \lstthanks{J\"urgen~Heim}{heim@astro.uni-tuebingen.de},
%   \lstthanks{Dr.~Jobst~Hoffmann}{HOFFMANN@rz.rwth-aachen.de},
%   \lstthanks{Torben~Hoffmann}{toho@it.dtu.dk},
%   \lstthanks{Berthold~H\"ollmann}{bhoel@starship.python.net},
%   \lstthanks{Marcin~Kasperski}{Marcin.Kasperski@softax.com.pl},
%   \lstthanks{Knut~M\"uller}{knut@physik3.gwdg.de},
%   \lstthanks{Torsten~Neuer}{tneuer@inwise.de},
%   \lstthanks{Heiko~Oberdiek}{oberdiek@ruf.uni-freiburg.de},
%   \lstthanks{Zvezdan~V.~Petkovic}{zpetkovic@acm.org},
%   \lstthanks{Michael~Piotrowski}{mxp@linguistik.uni-erlangen.de},
%   \lstthanks{Manfred~Piringer}{sz0490@rrze.uni-erlangen.de},
%   \lstthanks{Ralf~Quast}{rquast@hs.uni-hamburg.de},
%   \lstthanks{Aslak~Raanes}{araanes@ifi.ntnu.no},
%   \lstthanks{Detlef~Reimers}{dreimers@aol.com},
%   \lstthanks{Magne~Rudshaug}{magne@ife.no},
%   \lstthanks{Andreas~Stephan}{Andreas.Stephan@victoria.de},
%   \lstthanks{Gregory~Van~Vooren}{Gregory.VanVooren@rug.ac.be},
%   \lstthanks{Dominique~de~Waleffe}{ddw@miscrit.be},
%   \lstthanks{Michael~Weber}{mweber@informatik.hu-berlin.de},
%   \lstthanks{Herbert~Weinhandl}{weinhand@grz08u.unileoben.ac.at},
%   \lstthanks{Michael~Wiese}{wiese@itwm.uni-kl.de},
%   \lstthanks{J\"orn~Wilms}{wilms@rocinante.colorado.edu} and
%   \lstthanks{Kai~Wollenweber}{kai@ece.WPI.EDU}.
% \end{quote}
% I hope this list is complete.
%
%^^A \lsthelper{Bj{\o}rn~{\AA}dlandsvik}{1997/10/27}{listings.sty is incompatible to inputenc.sty}
%^^A \lsthelper{Andreas~Bartelt}{1997/09/11}{single line comes out using \inputlisting inside \fbox}
%^^A \lsthelper{Michael~Piotrowski}{1997/11/04}{! Use of \lstdrv@perl@TestCommentCut doesn't match its definition^^J\lst@line ->I^^JRF::LangID -- Statistical identification of language for IRF/1^^J^^J(POD ist Zeile `=irgendwas' bis Zeile `=cut')}
%^^A \lsthelper{Manfred~Piringer}{1998/11/22}{File ended while scanning use of \lst@MSkipUptoFirst@}
%
%
% \part{User's guide}
%
%
% \section{Getting started}\label{uGettingStarted}
% 
%
% \subsection{Software license}
%
% The files \texttt{listings.dtx} and \texttt{listings.ins} and all files generated from only these two files are referred to as `the \packagename{listings} package' or simply `the package'.
% A `language driver' or short `driver' is generated from \texttt{lstdrvrs.dtx}.
%
% \paragraph{Copyright.}
%   The \packagename{listings} package is copyright 1996--1999 Carsten Heinz.
%   The language drivers are copyright 1997/1998/1999 any individual author listed in the driver files.
%
% \paragraph{Distribution and warranty.}
%   The \packagename{listings} package as well as \texttt{lstdrvrs.dtx} and all drivers are distributed under the terms of the \LaTeX\ Project Public License from CTAN archives in directory |macros/latex/base/lppl.txt|, either version 1.0 or, at your option, any later version.
%
% \paragraph{Use of the package.}
%   The \packagename{listings} package is free software.
%   However, if you distribute the package as part of a commercial product or if you use the package to prepare a document and sell the document (books, journals, and so on), I'd like to encourage you to make a donation to the \LaTeX3 fund.
%   The size of this `license fee' should depend on the value of the package for your product.
%
%   If you use the package to typeset a non-commercial document, please send me a copy of the document (hardcopy, \texttt{.dvi}, \texttt{.ps}, \texttt{.pdf}, etc.) to support further development.
%
% \paragraph{Modification advice.}
%   Permission is granted to modify the \packagename{listings} package as well as \texttt{lstdrvrs.dtx}.
%   You are not allowed to distribute any changed version of the package or any changed version of \texttt{lstdrvrs.dtx}, neither under the same name nor under a different one.
%   Instead contact the address below:
%   Other users will welcome removed bugs, new features and additional programming languages.
%
% \paragraph{Contacts.}
%   Send your comments, ideas, bug reports and additional programming languages to \emph{Carsten Heinz, Tellweg 6, 42275 Wuppertal, Germany} or preferably to \texttt{cheinz@gmx.de}.
%
%
% \subsection{Installation}
%
% \begin{enumerate}
% \item Following the \TeX\ directory structure (TDS) you should put the files of the \packagename{listings} package into directories as follows:
%       \begin{center}
%       \begin{tabular}{l@{\quad$\to$\quad}l}
%       \texttt{listings.dvi}&\texttt{texmf/doc/latex/listings}\\
%       \texttt{listings.dtx}, \texttt{listings.ins}&\texttt{texmf/source/latex/listings}\\
%       \texttt{lstdrvrs.dtx}&\texttt{texmf/source/latex/listings}
%       \end{tabular}
%       \end{center}
%       Of course, you need not to use the TDS.
%       Simply adjust the directories below.
% \item	Remove all files from \texttt{texmf/tex/latex/listings} or create that directory if you don't update from an earlier version.
% \item	Change the working directory to \texttt{texmf/source/latex/listings} and run \texttt{listings.ins} through \TeX.
% \item Move the generated files to \texttt{texmf/tex/latex/listings} if this is not already done.
%       \begin{center}
%       \begin{tabular}{l@{\quad$\to$\quad}l}
%       \texttt{listings.sty}, \texttt{lstmisc.sty}&\texttt{texmf/tex/latex/listings}\\
%       \texttt{lstlang1.sty}, \texttt{lstlang2.sty}&\texttt{texmf/tex/latex/listings}\\
%       \texttt{listings.cfg}&\texttt{texmf/tex/latex/listings}
%       \end{tabular}
%       \end{center}
% \item If your \TeX\ implementation uses a filename database, update it.
% \end{enumerate}
% Note that \packagename{listings} requires at least version 1.10 of the \packagename{keyval} package included in the \packagename{graphics} bundle by David Carlisle.
%
% You might need to increase save stack size or string memory since \packagename{listings} 0.20 needs lots of them.
% But that depends a bit on the used features.
%
%
% \subsection{A minimal file}\label{uAMinimalFile}
%
% Please read section \ref{uPackageLoading} before you use this package in a real document.
% Here is some kind of minimal file.
% \begin{verbatim}
%    \documentclass{article}
%
%    \usepackage{listings}
%    \lstloadlanguages{C++,Pascal}% if both are needed
%
%    \begin{document}
%
%    \lstset{language=Pascal}% select Pascal
%    % Any example can be inserted here.
%
%    \end{document}\end{verbatim}
% We load the \packagename{listings} package and then C++ and Standard~Pascal language drivers.
% This selects neither Pascal nor C++.
% Later in the document Pascal becomes active.
%
%
% \subsection{Typesetting listings\enskip I}
%
% You can print stand alone files or source code you typed directly into a \texttt{.tex} file, where you have the choice between `displayed' listings or code fragments within a paragraph.
% In imitation of \LaTeX's |\verb| command you can write |\lstinline!var i:integer;!| and get `\lstinline!var i:integer;!'.
% The exclamation marks delimit the code fragment and could be replaced by any character not in the code fragment, i.e.\ |\lstinline$var i:integer;$| would produce the same output.
%
% \medbreak
% The \texttt{lstlisting} environment typesets the source code in between.
% It has one optional and one name parameter, which we leave empty for the moment.
% \begin{lstsample}{}
%    \begin{lstlisting}{}
%    for i:=maxint to 0 do
%    begin
%        { do nothing }
%    end;
%
%    Write('Keywords are case ');
%    WritE('insensitive here.');
%    \end{lstlisting}
% \end{lstsample}
% You might take the \LaTeX\ source code you see on the right, put it into the minimal file, and run it through a \TeX\ compiler.
% You'll get an output similar to the result shown on the left.
% The optional argument tells the package to perform special tasks, for example to print only the lines 2--5:
% \begin{lstsample}{\lstset{frame=trbl,frametextsep=0pt}}
%    \begin{lstlisting}[first=2,last=5]{}
%    for i:=maxint to 0 do
%    begin
%        { do nothing }
%    end;
%
%    Write('Keywords are case ');
%    WritE('insensitive here.');
%    \end{lstlisting}
% \end{lstsample}
% Note that the specified lines must exist, or you will get a ``runaway argument'' error.
% The frame shows that empty lines at the end of a listing are not printed.
% If you definitely what the line 5 here, read about \keyname{showlines} in section \ref{uTypesettingListings}.
%
% \medbreak
% The command |\lstinputlisting| also has one optional and one file name argument.
% It pretty-prints the stand alone file:
% \begin{lstsample}{\lstset{basewidth=.5em}}
%    \lstinputlisting{listings.tmp}
% \end{lstsample}
% Do you wonder about the left-hand side?
% Well, the file \texttt{listings.tmp} contains the current/last example.
% This is exactly the line you see on the right.
% If you want this line to be typeset in Pascal mode, you get what you've got.
%
%
% \subsection{The ``key=value'' interface}\label{uTheKey=ValueInterface}
%
% The \packagename{listings} package uses \texttt{keyval.sty} from the \packagename{graphics} bundle by David Carlisle.
% Each `parameter' is controlled by an associated key and a user supplied value.
% The command |\lstset| gets a ``key=value'' as argument.
% You have seen this in the minimal file and in the last section.
% You can set more than one parameter with a single |\lstset| if you separate two or more key=value pairs by commas like this:
% \begin{verbatim}
%    \lstset{language=Pascal,keywordstyle=\bfseries}\end{verbatim}
% If the value itself contains a comma, you must enclose the value in braces, for example |\lstset{keywords={one,two,three}}|.
% Without the additional braces the \packagename{keyval} package would set the one and only keyword |one|, and then give an error message since the keys |two| and |three| do not exist.
%
% \medbreak
% |\lstinputlisting|, |\lstinline| and the |lstlisting| environment all have an optional argument.
% If you use a key=value list as optional argument, these selections are valid for the particular listing only and the previous values are restored afterwards.
% For example, if the current language is Pascal, but you want \texttt{testfile.f95} from line 3 on, write
% \begin{verbatim}
%    \lstinputlisting[first=3,language=Fortran]{testfile.f95}\end{verbatim}
% Afterwards Pascal is still active.
% This principle applies to all keys.
%
% Some keys also have optional arguments.
% If you want to use such an optional argument inside the optional argument of a pretty-printing command or environment, you must put braces around the whole value.
% You'll find an example on page \pageref{lst:AFloatingExample}.
%
% \medbreak
% Finally you should know that there are different kinds of keys.
% Some like \keyname{first} and \keyname{last} make sense only if they are used for a single listing, and therefore used inside an optional argument.
% Other keys don't worry about whether they are set via |\lstset| or via an optional arguments.
% Furthermore some keys have default values, e.g.\ |flexiblecolumns| without any |=true| turns flexible columns on.
% But you must use |=false| if you want to turn them off.
%
%
% \subsection{Typesetting listings\enskip II}
%
% You already know all pretty-printing commands and environments.
% You need to learn the parameters which control how the listings are printed.
% First you'll have to ensure that your source code can be processed at all.
% Please read section \ref{uNationalCharacters} if you use national characters inside listings, i.e.\ characters with (ASCII) codes greater than 127.
% Otherwise you'll get really funny results.
%
% You might get some unexpected output if your source code contains a tabulator.
% The package assumes tabulator stops at columns 9, 17, 25, 33, and so on.
% This is pre-defined via |\lstset{tabsize=8}|.
% If you change the eight to the number $n$, you will get tabulator stops at columns $n+1,\allowbreak 2n+1,\allowbreak 3n+1,$ and so on.
% \begin{lstsample}{}
%    \lstset{tabsize=2}
%    \begin{lstlisting}{}
%    123456789
%    	{ one tabulator }
%    		{ two tabs }
%    123		{ 123 + two tabs }
%    \end{lstlisting}
% \end{lstsample}
% Note that the left-hand side is printed with |tabsize=2|, but the verbatim code uses |tabsize=4|.
% Tabulators can be made visible via the \keyname{visibletabs} key, see section \ref{uFigureOutTheAppearance}.
%
% Another special character is a form feed causing an empty line.
% If you want a new page every form feed, write |\lstset{formfeed=\newpage}|.
%
% \medbreak
% Another item is about how source code looks like in your |.tex| file.
% You might want to use indention which must be removed to pretty-print a listing.
% If you indent each code line by three characters, you can remove them via |gobble=3|:
% \def\lstsampleverbcmd{\lstset{visiblespaces}}
% \begin{lstsample}{}
%    \begin{lstlisting}[gobble=3]{}
%    1  for i:=maxint to 0 do
%     2 begin
%      3    { do nothing }
%    123end;
%
%       Write('Keywords are case ');
%       WritE('insensitive here.');
%    \end{lstlisting}
% \end{lstsample}
% \let\lstsampleverbcmd\empty
% Note that empty lines as well as the beginning and the end of the environment need not to respect the indention.
% Moreover note that tabulators expand to |tabsize| spaces before we gobble.
% If we don't gobble characters any more, tabulators don't expand to spaces.
%
% \medbreak
% Something different at the end of this section.
% By default listings do not float, but look at this:
% \def\lstsampleverbcmd{\label{lst:AFloatingExample}}
% \begin{lstsample}{\lstset{frame=tb}}
%    \begin{lstlisting}[float,caption={[]A floating example}]{}
%    for i:=maxint to 0 do
%    begin
%        { do nothing }
%    end;
%
%    Write('Keywords are case ');
%    WritE('insensitive here.');
%    \end{lstlisting}
% \end{lstsample}
% \let\lstsampleverbcmd\empty
% The empty optional argument for \keyname{caption} prevents the package from using a listing number.
% The key \keyname{float} is not boolean.
% It is used without any value or gets a subset of |tbph| which determines the placement of the float.
% This is similar to the standard |figure| and |table| environments.
% If you put the example into the minimal file and run it through \TeX, please don't wonder:
% You'll miss the horizontal rules since they are described in section \ref{uFrames}.
%
%
% \subsection{Figure out the appearance}
%
% Keywords are typeset bold, comments in italic shape and spaces in strings appear as \textvisiblespace.
% You can change that default behaviour, for example
%\ifcolor
% \begin{verbatim}
%\lstset{
%    basicstyle=\small,          % print whole listing small
%    keywordstyle=\color{red}\bfseries
%                 \underbar,     % underlined bold red keywords
%    identifierstyle={},         % nothing happens to other identifiers
%    commentstyle=\color{white}, % white comments
%    stringstyle=\ttfamily,      % typewriter type for strings
%    stringspaces=false}         % no special string spaces\end{verbatim}
% We typeset a previous example with these selections again.
% \begin{lstsample}{\lstset{basicstyle=\small,identifierstyle={},^^A
%        keywordstyle=\color{red}\bfseries\underbar,commentstyle=\color{white},^^A
%        stringstyle=\ttfamily,stringspaces=false}}
%    \begin{lstlisting}{}
%    for i:=maxint to 0 do
%    begin
%        { do nothing }
%    end;
%
%    Write('Keywords are case ');
%    WritE('insensitive here.');
%    \end{lstlisting}
% \end{lstsample}
%\else
% \begin{verbatim}
%\lstset{
%    basicstyle=\small,          % print whole listing small
%    keywordstyle=\bfseries\underbar,
%                                % underlined bold keywords
%    identifierstyle={},         % nothing happens to other identifiers
%    commentstyle=\itshape,      % default
%    stringstyle=\ttfamily,      % typewriter type for strings
%    stringspaces=false}         % no special string spaces\end{verbatim}
% We typeset a previous example with these selections again.
% \begin{lstsample}{\lstset{basicstyle=\small,identifierstyle={},^^A
%        keywordstyle=\bfseries\underbar,commentstyle=\itshape,^^A
%        stringstyle=\ttfamily,stringspaces=false}}
%    \begin{lstlisting}{}
%    for i:=maxint to 0 do
%    begin
%        { do nothing }
%    end;
%
%    Write('Keywords are case ');
%    WritE('insensitive here.');
%    \end{lstlisting}
% \end{lstsample}
%\fi
% The style definition above uses two different kinds of commands.
% On the one hand |\ttfamily| and |\bfseries| both take no arguments, and on the other |\underline| gets exactly one argument.
% In general the \emph{very last} token of |keywordstyle| and |identifierstyle| \emph{might} be a macro getting exactly one argument, namely the (non)keyword.
% All other tokens \emph{must not} take any arguments --- or you will get deep in trouble.
%
% \medbreak
% \textbf{Warning:}
% You shouldn't use striking styles too often, but `too often' depends on how many keywords the source code contains, for example.
% Your eyes would concentrate on the framed, bold red printed keywords only, and your brain must compensate this.
% Reading such source code could be very exhausting.
% If it were longer, the last example would be quite good in this sense.
% Believe me.
%
%
% \subsection{Line numbers}
%
% There are three stages:
% Print line numbers, control the printed line numbers, and refer to line numbers.
% Let us try to print tiny numbers, each second line, 5pt distance to the listing:
% \begin{lstsample}{}
%    \lstset{labelstyle=\tiny,%  <===
%            labelstep=2,%       <===
%            labelsep=5pt}%      <===
%
%    \begin{lstlisting}{}
%    for i:=maxint to 0 do
%    begin
%        { do nothing }
%    end;
%    \end{lstlisting}
% \end{lstsample}
% Note that |labelstep=0| turns line numbering off and |labelsep=10pt| is default.
% However, in the sequel we use the selections from above even if it doesn't appear in the verbatim part.
%
% \medbreak
% The \texttt{lstlisting} environment allows you to interrupt your listings.
% Remember that the environment has a name argument.
% Listings with identical names (case sensitive!) have a common line counter.
% \begin{lstsample}{\lstset{labelstyle=\tiny,labelstep=2,labelsep=5pt}}
%    \begin{lstlisting}{Test}%   <===
%    for i:=maxint to 0 do
%    begin
%        { do nothing }
%    end;
%
%    \end{lstlisting}
% \end{lstsample}
% \begin{lstsample}{\lstset{labelstyle=\tiny,labelstep=2,labelsep=5pt}}
%    And we continue the listing:
%    \begin{lstlisting}{Test}%   <===
%    Write('Keywords are case ');
%    WritE('insensitive here.');
%    \end{lstlisting}
% \end{lstsample}
% The next |Test| listing goes on with line number {\makeatletter\lstno@Test}.
% Note that the empty line at the end of the first part is not printed, but it counts for line numbering.
% This continue mechanism has two exceptions:
% An empty (= |{}|) named listing always starts with line number one, no matter whether line numbers are printed or not.
% A space (= |{ }|) named listing continues the last empty or space named one.
%
% In fact, that's not true.
% The key \keyname{firstlabel} controls the line number of the first printed line:
% \begin{lstsample}{\lstset{labelstyle=\tiny,labelstep=2,labelsep=5pt}}
%    \begin{lstlisting}[firstlabel=2]{}
%    for i:=maxint to 0 do
%    begin
%        { do nothing }
%    end;
%
%    \end{lstlisting}
% \end{lstsample}
% \begin{lstsample}{\lstset{labelstyle=\tiny,labelstep=2,labelsep=5pt}}
%    And we continue the listing:
%    \begin{lstlisting}[firstlabel=1]{ }
%    Write('Keywords are case ');
%    WritE('insensitive here.');
%    \end{lstlisting}
% \end{lstsample}
%
% Finally you should know how to reference line numbers.
% You need one character not used otherwise in the source code.
% In the example we use the percent character which must be entered as |\%|.
% After |\lstset{escapechar=\%}| you can put \TeX\ material between two percent characters, for example |\label{comment}|.
% \begin{lstsample}{\lstset{labelstyle=\tiny,labelstep=2,labelsep=5pt}}
%    \lstset{escapechar=\%}%     <===
%
%    \begin{lstlisting}{}
%    for i:=maxint to 0 do
%    begin
%        { do nothing }%\label{comment}%
%    end;
%    \end{lstlisting}
%    Line \ref{comment} \ldots
% \end{lstsample}
% You should put |%\label{|whatever|}%| into a comment if you want to reference line numbers of a stand alone file.
% Or your compiler/interpreter will have problems.
%
%
% \subsection{Indent the listing}
%
% The examples are typeset with centered \texttt{minipage}s.
% That's the reason why you can't see that line numbers are printed in the margin.
% Now we separate the minipage margin and the minipage by a vertical rule:
% \begin{lstsample}{\lstset{frame=l,frametextsep=0pt,labelstyle=\tiny,labelstep=2,labelsep=5pt}}
%    Some text before
%    \begin{lstlisting}{}
%    for i:=maxint to 0 do
%    begin
%        { do nothing }
%    end;
%    \end{lstlisting}
% \end{lstsample}
% The listing is lined up with the normal text.
% The parameter |indent| moves the listing to the right (or left if the dimension is negative).
% \begin{lstsample}{\lstset{frame=l,frametextsep=0pt,labelstyle=\tiny,labelstep=2,labelsep=5pt}}
%    Some text before
%    \lstset{indent=15pt}%       <===
%    \begin{lstlisting}{}
%    for i:=maxint to 0 do
%    begin
%        { do nothing }
%    end;
%    \end{lstlisting}
%
%    \begin{lstlisting}{ }
%    Write('Insensitive');
%    WritE('keywords.');
%    \end{lstlisting}
% \end{lstsample}
% Note that |\lstset{indent=15pt}| also changes the indent for the second listing.
% If you want to indent a single listing, use the optional argument of the environment or input command.
%
% \medbreak
% If you use environments like \texttt{itemize} or \texttt{enumerate}, there is `natural' indention coming from these environments.
% By default the \packagename{listings} package respects this.
% But you might use |wholeline=true| (or |false|) to make your own decision.
% You can use it together with |indent|, of course.
% Refer section \ref{uAllAboutListingAlignment} for a description of |spread|.
%
%
% \subsection{Fixed and flexible columns}\label{uFixedAndFlexibleColumns}
%
% The first thing a reader notices is --- except different styles for keywords, etc. --- the column alignment of a listing.
% The problem: I don't like listings in typewriter type and other fonts need not to have a fixed width.
% But we don't want
% \begin{itemize}\item[]\begin{tabular}{@{}l}
%	if\ x=y\ then\ write('alignment')\\
%	\ \ \ \ \ \ \ else\ print('alignment');
% \end{tabular}\end{itemize}
% only because spaces are not wide enough.
% There is a simple trick to avoid such things.
% We make boxes of the same width and put one character in each box:
% \def\docharfbox#1#2{\fbox{\hbox to#1em{\hss\vphantom{fy}#2\hss}}}
% \def\docharbox#1#2{\hbox to#1em{\hss#2\hss}}
% \begin{itemize}\item[]
%    \def\makeboxes#1{\docharfbox1#1\ifx#1\relax\else\expandafter\makeboxes\fi}
%    \makeboxes if\ x=y\ then\ write\relax\space\ldots\\
%    \makeboxes \ \ \ \ \ \ \ else \ print\relax\space\ldots
% \end{itemize}
% Going this way the alignment of columns can't be disturbed.
%   \def\makeboxes#1{\docharbox{0.45}#1\ifx#1\relax\else\expandafter\makeboxes\fi}
% But if the boxes are not wide enough, we get `\makeboxes if\ x=y\ then\relax\ldots', and choosing the width so that the widest character fits in leads to
%   \def\makeboxes#1{\docharbox{1}#1\ifx#1\relax\else\expandafter\makeboxes\fi}
% `\makeboxes if\ x=y\ then\ write\relax\ldots'.
% Both are not acceptable.
% Since all input will be cut up in units, we can put each unit in a box, which width is multiplied by the number of characters we put in, of course.
% The result is
%   \def\makeboxes#1#2{\docharfbox{#1}{#2}\ifx#2\relax\else\expandafter\makeboxes\fi}
%   \makeboxes{1.4}{i\hss f}{.7}{\ }{.7}{x}{.7}{=}{.7}{y}{.7}{\ }{2.8}{t\hss h\hss e\hss n}{.7}{\ }{3.5}{w\hss r\hss i\hss t\hss e}{.7}\relax\space.
% Since we put wide and thin characters in the same box, the width of a single character box need not to be the width of the widest character.
% The empirical value {\makeatletter\lst@widthfixed} (which is called `base width' later) is a compromise between overlapping characters and the number of boxes not exceeding the text width, i.e.\ how many characters fit a line without getting an overfull |\hbox|.
%
% \medbreak
% \begingroup
% But overlapping characters are a problem if you use many upper case letters, e.g.\ \docharbox{3}{W\hss O\hss M\hss E\hss N} --- blame me and not the women, in fact \docharbox{1.8}{M\hss E\hss N} doesn't look better.
% To go around this problem the \packagename{listings} package supports more `flexible columns' in contrast to the fixed columns above.
% Arne John Glenstrup (whose idea the format was) pointed out that he had good experience with flexible columns and assembler listings.
% The differences can be summed up as follows: The fixed column format ruins the nice spacing intended by the font designer, and the flexible format ruins the column alignment (possibly) intended by the programmer.
% We illustrate that:
%   \lstset{style={},language={}}
%   \def\sample{\begin{lstlisting}{}^^J\ WOMEN\ \ are^^J \ \ \ \ \ \ \ MEN^^J WOMEN are^^J better MEN^^J \end{lstlisting}}
%   \begin{center}\begin{tabular}{c@{\qquad\quad}c@{\qquad\quad}c}
%   verbatim&fixed columns&flexible columns\\
%       &with {\makeatletter\lst@widthfixed}&with {\makeatletter\lst@widthflexible}\\ \noalign{\medskip}
%   \setkeys{lst}{basicstyle=\ttfamily,basewidth=0.51em}\sample&\lstset{flexiblecolumns=false}\sample&\lstset{flexiblecolumns=true}\sample\lstset{flexiblecolumns=false}
%   \end{tabular}\end{center}
% Hope this helps.
% Note the varying numbers of spaces between `WOMEN' and `are' and look at the different outputs.
% The flexible column format typesets all characters at their natural width.
% In particular characters never overlap.
% If a word needs more space than reserved ('WOMEN'), the rest of the line moves to the right.
% Sometimes a following word needs less space than reserved, or there are spaces following each other.
% Such `surplus' space is used to fix the column alignment:
% The two blanks in the first line came out as a single space.
% You can see this since the single space in the third line has been printed properly.
% We can show all this more drastic if we reduce the width of a single character box:
%   \begin{center}\lstset{basewidth={0.3em,0.0em}}\begin{tabular}{c@{\qquad\quad}c@{\qquad\quad}c}
%       &{\makeatletter\lst@widthfixed}&{\makeatletter\lst@widthflexible}\\ \noalign{\medskip}
%   \setkeys{lst}{basicstyle=\ttfamily,basewidth=0.51em}\sample&\lstset{flexiblecolumns=false}\sample&\lstset{flexiblecolumns=true}\sample\lstset{flexiblecolumns=false}
%   \end{tabular}\end{center}
% In flexible column mode the first `MEN' moves to the left since the blanks before are $7\cdot 0.0$em$=0$em wide.
% Even in flexible mode you shouldn't reduce `base width' to less than 0.33333em ($\approx$ width of a single space in some fonts).
% \endgroup
%
% \medbreak
% You want to know how to select the flexible column format and how to reset to fixed columns?
% Try |flexiblecolumns| and |flexiblecolumns=false|.
% The pre-definition of the `base width' is |basewidth={0.6em,0.45em}|, where the first width is for fixed mode and the second for flexible columns.
% Change it if you like.
%
%
% \subsection{Selecting other languages}\label{uSelectingOtherLanguages}
%
% You already know that |language=|\meta{language name} selects programming languages --- at least Pascal.
% But that's not the whole truth.
% Some languages know different dialects (= version or implementation), for example Fortran 77 and Fortran 90.
% You can choose such special versions with the optional argument of |language|.
% Write
% \begin{verbatim}
%    \lstset{language=[77]Fortran}% Fortran 77
%    \lstset{language=[XSC]Pascal}% Pascal XSC\end{verbatim}
% to select Fortran 77 and Pascal XSC, respectively.
% Remember that you must put braces around the value if you select a language with the optional arguments.
%
% Table \ref{dPredefinedLanguages} shows all languages and dialects supported by \texttt{lstdrvrs.dtx}.
% Use the given names as (optional) values to |language|.
% An `empty' language is also defined: |\lstset{language={}}| detects no keywords, no comments, no strings, and so on.
%^^A
%^^A A definition to print languages in two column format.
%^^A
% \begingroup \makeatletter \catcode`\^^M=9
% \gdef\lsttwocolumns#1{%
%     \setbox\z@=\vbox{\noindent#1}%
%     \begin{center}
%     \@tempdima=.5\ht\z@ \advance\@tempdima.5\baselineskip
%     \splittopskip\z@ \vbadness\@MM\setbox\@ne=\vsplit\z@ to\@tempdima
%     \floatrule
%     \hbox{\kern.03\linewidth
%           \hb@xt@.35\linewidth{\vtop{\hrule\@height\z@\box\@ne}\hss}
%           \kern.04\linewidth
%           \hb@xt@.55\linewidth{\vtop{\hrule\@height\z@\box\z@}\hss}
%           \kern.03\linewidth}
%     \floatrule
%     \end{center}}
% \endgroup
%^^A
% \begin{table}[htb]
% \caption{Pre-defined languages}\label{dPredefinedLanguages}
% \lsttwocolumns{^^A
%     Ada (\texttt{95},\texttt{83})\\
%     Algol (\texttt{68},\texttt{60})\\
%     C (\texttt{ANSI},\texttt{Objective})\\
%     Caml (\texttt{light},\texttt{Objective})\\
%     Cobol (\texttt{1985},\texttt{1974},\texttt{ibm})\\
%     Comal 80\\
%     C++ (\texttt{ANSI},\texttt{Visual})\\
%     csh\\
%     Delphi\\
%     Eiffel\\
%     Elan\\
%     Euphoria\\
%     Fortran (\texttt{95},\texttt{90},\texttt{77})\\
%     Haskell\\
%     HTML\\
%     IDL\\
%     Java\\
%     Lisp\\
%     Logo\\
%     Make (empty,\texttt{gnu})\\
%     Mathematica (\texttt{3.0},\texttt{1.0})\\
%     Matlab\\
%     Mercury\\
%     Miranda\\
%     ML\\
%     Modula-2\\
%     Oberon-2\\
%     Pascal (\texttt{Standard},\texttt{XSC},\texttt{Borland6})\\
%     Perl\\
%     PL/I\\
%     POV\\
%     Prolog\\
%     Python\\
%     SHELXL\\
%     Simula (\texttt{67},\texttt{CII},\texttt{DEC},\texttt{IBM})\\
%     SQL\\
%     TeX (\texttt{plain},\texttt{primitive},\texttt{LaTeX},\texttt{alLaTeX})\\
%     VHDL}
% \end{table}
% Each first dialect is default dialect, e.g.\ |\lstset{language=C}| selects ANSI C.
% After |\lstset{defaultdialect=[Objective]C}| Objective-C is default dialect for C, but the language is not selected with the command.
% Note that pre-defined default dialects change from release to release.
% Thus: Always define (after package loading) the dialects you use as default dialects.
%
% \medskip
% Remark:
% The languages have all bugs coming from the language defining commands described in section \ref{uLanguageDefinitions}, e.g.\ in Ada and Matlab it is still possible that the package assumes a string where none exists.
%
%
%^^A
%^^A Two environments for documentation.
%^^A
% \def\BeginRemark#1{\begin{quote}\topsep0pt\let\small\footnotesize\small#1:}
% \def\EndRemark{\end{quote}}
% \newenvironment{TODO}{\BeginRemark{To do}}{\EndRemark}
% \newenvironment{REMOVED}{\BeginRemark{Removed definition}}{\EndRemark}
%
%^^A
%^^A Some commands to be used within `macrosyntax' and the environment itself.
%^^A
% \newcommand*\macrosyntaxbreak{\hfill\kern0pt\discretionary{}{\kern\labelwidth}{}}
% \newcommand*\macrosyntaxnewline{\newline\hbox{}\kern\labelwidth}
% \newcommand*\macrosyntaxor{\qquad or\qquad}
% \newenvironment{macrosyntax}
%    {\list{}{\itemindent-\leftmargin \def\makelabel##1{\hss\lstmklab##1,\relax}}}
%    {\endlist}
% \def\lstmklab#1,#2\relax{^^A
%    \ifx\empty#2\empty
%        \lstmklabb#1,,\relax 
%    \else
%        \lstmklabb#1,#2\relax
%    \fi}
% \def\lstmklabb#1,#2,\relax{^^A
%    \llap{\scriptsize\itshape#2}^^A
%    \rlap{\hskip-\itemindent\hskip\labelwidth\hskip\linewidth#1}}
%
%
% \section{Main reference}\label{uMainReference}
%
% In this section we list all user environments, commands and keys together with their parameters and possible values.
% Parts dealing with yet unknown features should always contain examples.
% If not write your own ones.
% The numbers in the right margin give the version number of introduction (either as internal or as user macro/key).
% The labels on the left give you some important information about the key or command.
% For example, \emph{addon} indicates additional functionality.
% The labels should be clear.
%
% \begin{macrosyntax}
% \item[0.19] |\lstset|\marg{key=value list}
%
%       sets the values of the specified keys, see section \ref{uTheKey=ValueInterface}.
% \end{macrosyntax}
%
%
% \subsection{Package loading}\label{uPackageLoading}
%
% As usual in \LaTeX\ the package is loaded by |\usepackage[|\meta{options}|]{listings}|, where |[|\meta{options}|]| is optional.
% Each option loads a `\packagename{listings}-aspect' (= collection of commands and keys) or prevents the package from loading it if the aspect name is preceded by an exclamation mark.
% But even in the latter case an aspect is loaded later if a pre-defined programming language needs it.
% See section \ref{dWhyLstAspects} for a complete list of aspects.
% Here are the main ones.
% \begin{description}
% \item[\normalfont\texttt{0.17}]
%       Use this option to compile documents created with version 0.17 of the \packagename{listings} package.
%       Note that you can't use old driver files and that the option \emph{does not guarantee full compatibility}.
% \item[\normalfont\texttt{0.19}]
%       to compile documents created with version 0.19.
% \item[\normalfont\texttt{rdkeywords}, \texttt{breaklines}, \texttt{index} and \texttt{procnames}]
%       define the keys of the aspect(s).
%       It will be obvious which \emph{optional} marked keys belong to which aspect.
% \item[\normalfont\texttt{fancyvrb}]
%       This option is different since the key \keyname{fancyvrb} is always defined and loads some definitions on demand.
%       The option loads these definitions at package loading which is faster than loading it later.
%       If you use this option, the \packagename{fancyvrb} package must already be loaded!
% \end{description}
% It makes no sense to write |\usepackage[!0.17]{listings}| to `unload' the compatibility mode since it isn't loaded by default anyway.
% But if you don't use line numbering, you can write |\usepackage[!labels]{listings}| to save some \TeX\ memory.
% However, you can load it later with |\lstloadaspects{labels}|.
% \begin{macrosyntax}
% \item[0.20,new] |\lstloadaspects|\marg{comma separated list of aspect names}
%
%       loads the specified aspects if they are not already loaded.
% \end{macrosyntax}
% After package loading I strongly recommend to load all used dialects of programming languages with the following command, which can be used in the preamble only (before |\begin{document}|).
% \begin{macrosyntax}
% \item[0.19,preamble] |\lstloadlanguages|\marg{comma separated list of languages}
%
%       It loads all specified languages, where each language is given in the form |[|\meta{dialect}|]|\meta{language}.
%       Write |[Visual]C++| if you use Visual C++; |C++| would load ANSI C++ only.
%
% \item[0.20,new,data] |\lstdriverfiles|
%
%       contains a comma separated list of the language driver file names.
%       This macro is usually defined in a configuration file.
% \end{macrosyntax}
% Finally note that the \packagename{float} package must be loaded before \packagename{listings}.
%
%
% \subsection{Languages and styles}\label{uLanguagesAndStyles}
%
% We distinguish programming languages and styles used to print a listing.
% Since both are defined in terms of key=value lists, it is possible to use a style key inside a language definition or vice versa.
% However, the pre-defined languages don't use style keys.
% \begin{macrosyntax}
% \item[0.17] \keyname{language}|=|\marg{dialect}\meta{language name}
%
%       activates a (dialect of a) programming language.
%       The arguments are case insensitive and spaces have no effect.
%
% \item[0.19] \keyname{defaultdialect}|=|\marg{dialect}\meta{language}
%
%       defines a default dialect for a language, that means a dialect which is selected whenever you leave out the optional argument.
%       If you have defined a default dialect other than empty, for example |defaultdialect=[iama]fool|, you can't select the `empty' dialect, even not with |language=[]fool|.
%
%       Note that a configuration file possibly defines some default dialects.
%
% \item[0.18] \keyname{style}|=|\meta{style name}
%
%       activates a style.
%       The argument is case insensitive.
%
% \item[0.19] |\lstdefinestyle|\marg{style name}\marg{key=value list}
%
%       stores the key=value list.
%       You can select the style via \keyname{style}|=|\meta{style name}.
% \begin{TODO}
% It's easy to crash the package with \keyname{style} --- and also with \keyname{language}.
% Write |\lstdefinestyle{crash}{style=crash}| and |\lstset{style=crash}|.
% \TeX's capacity will exceed, sorry [parameter stack size].
% Only bad girls use such recursive calls, but only good girls use this package.
% Thus the problem is of minor interest.
% \end{TODO}
% \end{macrosyntax}
%
%
% \subsection{Typesetting listings}\label{uTypesettingListings}
%
% First come the pretty-printing commands and environments.
% They all have an optional \meta{key=value list} which modify parameters for the specific listing only.
% Note that empty lines at the end of listings are always dropped, but they count for line numbering.
% \begin{macrosyntax}
% \item[0.18] |\lstinline|\oarg{key=value list}
%
%       works like |\verb| but uses the active language and style.
%       You can write `|\lstinline!var i:integer;!|' and get `\lstinline!var i:integer;!'.
%       Note that these listings use flexible columns except |flexiblecolumns=false| is a key=value pair in the optional argument.
%
% \item[0.1] |\lstinputlisting|\oarg{key=value list}\marg{file name}
%
%       typesets the stand alone source code file.
%
% \item[0.15] |lstlisting|\oarg{key=value list}\marg{name}
%
%       typesets the code between |\begin{lstlisting}| (+ arguments + line break) and |\end{lstlisting}|.
%       Source code right before and \LaTeX\ code after the end of environment is typeset (if nonempty line) respectively executed.
%
%       Same named listings have common line counter, i.e.\ the second (same named) listing continues the first, the third continues the second, and so on.
%       There are two exceptions: An empty-named listing starts with line number 1 and is continued with space-named listings (= |{ }|).
%
% \item[0.1,addon] \keyname{first}|=|\meta{line number}
% \item[0.1,addon] \keyname{last}|=|\meta{line number}
%
%       determine the printed line range of stand alone files and environments.
%       They must be used on individual listings in the optional arguments.
%       Default range is 1--9999999.
%
% \item[0.12,addon] \keyname{print}|=|\meta{true$\vert$false}\macrosyntaxor\keyname{print}
%
%       controls whether the command respectively environment typeset the listings.
%       If you use |print=false| at the beginning of a document to compile a draft version, you might use |print| in optional arguments to typeset particular listings in spite of that.
%
% \item[0.20,new] \keyname{showlines}\meta{true$\vert$false}\macrosyntaxor\keyname{showlines}
%
%       If true, the package prints empty lines at the end of listings --- no matter what I've said before.
%
% \item[0.19,new] \keyname{gobble}|=|\meta{number}
%
%       gobbles \meta{number} characters at the beginning of each line.
%       If necessary, tabulators expand to |tabsize| spaces before they are gobbled.
%       Code lines with less than \meta{number} characters are considered to be empty.
%
%       If you use this key together with the environment, |\end{lstlisting}| need not to be indented by \meta{number} spaces.
%       The package will find the end.
%
%\iffalse
% \item[0.20,new] \keyname{continue}|=|\meta{true$\vert$false}\macrosyntaxor\keyname{continue}
%
%       puts the package over to (not) continued listings.
%       This affects \keyname{pre} and \keyname{post} (both obsolete) and the list of listings:
%       If you don't specifiy a caption, continued listings get no entry.
%\fi
%
% \item[0.20,new] \keyname{float}|=|\meta{subset of \textup{\texttt{tbph}}}\macrosyntaxor\keyname{float}
%
%       makes sense with individual listings only and lets them float.
%       The argument controls where \LaTeX\ is allowed to put the float:
%       At the top or bottom of the current/next page, on a separate page, or here = where the listing appears.
%       If you use the key without a value, it uses the placement specifier |tbp|.
% \end{macrosyntax}
%
%
% \subsection{Captions}
%
% In despite of \LaTeX\ standard behaviour captions and floats are independent from each other here:
% You can use captions together with non-floating listings.
% It's up to you whether a titled listing also gets a number, how the number looks like, and so on.
% Lastly you can print a list of listings.
% \begin{macrosyntax}
% \item[0.20,new] \keyname{caption}|={|\oarg{short}\meta{caption text}|}|
%
%       can only be used on individual listings.
%       If you don't use \oarg{short}, the package assumes \meta{short}$=$\meta{caption text}.
%       If \meta{short} is empty, the listing is neither numbered nor it appears in the list of listings.
%
%       You may use |\label| inside \meta{caption text} and elsewhere |\ref| to refer to the listing.
%       This makes sense only if \meta{short} is not empty.
%
%       Note: The braces around the value are necessary if and only if you use the optional \meta{short} argument (or if \meta{caption text} contains |]|).
%
% \item[0.20,new] \keyname{captionpos}|=|\meta{subset of \textup{\texttt{tb}}}
%
%       specifies the position(s) of the caption.
%       After loading the package it puts captions at the top of listings.
%
% \item[0.16,renamed] |\lstlistoflistings|
%
%       prints a list of listings.
%       The names are the (short) captions, file names or names of the listings.
%
% \item[0.16,renamed] |\lstlistlistingname|
%
%       contains |Listings|, the header name for the list of listings.
%
% \item[0.20,new,data] |\lstlistingname|
%
%       contains |Listing|.
%       It's the string used to label the caption, see page \pageref{lst:AFloatingExample}.
%
% \item[0.20,new,data] |\thelstlisting|
%
%       prints the caption's label number.
%       The default definition depends on whether the document class supports chapters.
%       It's either |\arabic{lstlisting}| or |\thechapter.\arabic{lstlisting}|, but nonpositive chapter numbers are not printed.
%
% \item[0.20,new] \keyname{abovecaptionskip}|=|\meta{skip}
% \item[0.20,new] \keyname{belowcaptionskip}|=|\meta{skip}
%
%       is the vertical skip above respectively below each caption.
%       The pre-definition is |\smallskipamount|.
% \end{macrosyntax}
%
%
% \subsection{Labels}
%
% \begin{macrosyntax}
% \item[0.16] \keyname{labelstep}|=|\meta{step}
%
%       No labels are printed if \meta{step} is zero, which is the pre-definition.
%       Otherwise all lines such that ``line number $\equiv 0$ modulo \meta{step}'' get a label, which appearance is controlled by |labelstyle| and |\thelstlabel|.
%
% \item[0.16] \keyname{labelstyle}|=|\meta{style}
%
%       determines the font and size of the labels.
%       It is pre-defined to be empty.
%
% \item[0.20,new,data] |\thelstlabel|
%
%       prints the label numbers of the lines.
%       |\arabic{lstlisting}| is the default definition.
%
% \item[0.19] \keyname{labelsep}|=|\meta{dimension}
%
%       is the distance between label and listing.
%       {\makeatletter\lst@labelsep} is default separation.
%
% \item[0.20,new] \keyname{firstlabel}|=|\meta{number}
% \item[0.19,renamed] \keyname{advancelabel}|=|\meta{number}
%
%       sets respectively advances the number of the first label.
%       Both keys must be used in the optional key=value list.
% \end{macrosyntax}
% We show an example on how to redefine |\thelstlabel|.
% However, if you put the verbatim part into the minimal file, you won't get the result shown on the left.
% \begingroup \makeatletter
% \begin{lstsample}{\lstset{labelstep=1}\let\lst@labeladvance\m@ne}
%    \renewcommand*\thelstlabel
%        {\oldstylenums{%
%             \the\value{lstlabel}}}
%    \begin{lstlisting}[firstlabel=753]{}
%    begin { empty lines }
%
%
%
%
%
%
%    end; { empty lines }
%    \end{lstlisting}
% \end{lstsample}
% \endgroup
%
% \textbf{Exercise:}
% The example shows a sequence $n,n+1,\ldots,n+7$ of 8 three-digit figures such that the sequence contains each digit $0,1,\ldots,9$.
% But 8 is not minimal with that property.
% Find the minimal number and prove that it is minimal.
% Minimal means nonnegative number here.
% How many minimal sequences do exist?
%
% Now look at the generalized problem:
% Let $k\in\{1,\ldots,10\}$ be given.
% Find the minimal number $m\in\{1,\ldots,10\}$ such that there is a sequence $n,{n+1},\ldots,{n+m-1}$ of $m$ $k$-digit figures which contains each digit $\{0,\ldots,9\}$.
% Prove that the number is minimal.
% How many minimal sequences do exist?
%
% If you solve this problem with a computer, write a \TeX\ program!
%
%
% \subsection{Figure out the appearance}\label{uFigureOutTheAppearance}
%
% \begin{macrosyntax}
% \item[0.18] \keyname{basicstyle}|=|\meta{basic style and size}
% \item[0.11] \keyname{keywordstyle}|=|\meta{style for keywords}
% \item[0.19] \keyname{ndkeywordstyle}|=|\meta{style for second order keywords}
% \item[0.19,optional] \keyname{rdkeywordstyle}|=|\meta{style for third order keywords}
% \item[0.18,renamed] \keyname{identifierstyle}|=|\meta{style}
% \item[0.11] \keyname{commentstyle}|=|\meta{style}
% \item[0.12] \keyname{stringstyle}|=|\meta{style}
% \item[0.20,new,optional] \keyname{texcsstyle}|=|\meta{style}
% \item[0.20,new,optional] \keyname{directivestyle}|=|\meta{style}
%
%       Each value of these keys determines the font and size (or more general style) in which special parts of a listing appear.
%       The \emph{last} token of (nd,rd) keyword and identifier style might be an one-parameter command like |\textbf| or |\underline|.
%
%       The package uses keyword style if \TeX\ control sequences or compiler directives are defined but no style is specified.
%
% \item[0.12] \keyname{stringspaces}|=|\meta{true$\vert$false}
%
%       lets blank spaces in strings appear {\textvisiblespace} or as blank spaces.
%       The first (=true) is pre-defined.
%
% \item[0.20,new] \keyname{visiblespaces}|=|\meta{true$\vert$false}
%
%       lets all blank spaces appear {\textvisiblespace} or as blank spaces.
%       The latter case (=false) is pre-defined.
%
% \item[0.20,new] \keyname{visibletabs}|=|\meta{true$\vert$false}
%
%       make tabulators visible or invisible (default).
%       A visible tabulator looks like \lstinline[visibletabs]!	!, but that can be changed.
%       If you choose invisible tabulators but visible spaces, tabulators are converted to appropriate number of spaces.
%
% \item[0.20,new] \keyname{tab}|=|\meta{token sequence}
%
%		\meta{token sequence} is used to print a visible tabulator.
%		You might want to use |$\to$|, |$\mapsto$|, |$\dashv$| or something like that instead of the strange default definition.
%
% \item[0.12] \keyname{tabsize}|=|\meta{number}
%
%       sets tabulator stops at columns $\meta{number}+1$, $2\cdot\meta{number}+1$, $3\cdot\meta{number}+1$, and so on.
%       Each tabulator in a listing moves the current column to the next tabulator stop.
%       It is initialized with |tabsize=8|.
%
% \item[0.19] \keyname{formfeed}|=|\meta{token sequence}
%
%		Whenever a listing contains a form feed \meta{token sequence} is executed.
%		It is initialized with |formfeed=\bigbreak|.
% \end{macrosyntax}
%
%
% \subsection{Language specific style keys}
%
% \begin{macrosyntax}
% \item[0.19,optional] \keyname{printpod}|=|\meta{true$\vert$false}
%
%		prints or drops PODs in Perl.
%
% \item[0.20,new,optional] \keyname{usekeywordsinside}|=|\meta{true$\vert$false}
%
%		The package either use the first order keyword list for HTML or prints all identifiers inside |<>| in keyword style.
%       The first case is selected by default.
%
% \item[0.20,new,optional] \keyname{makemacrouse}|=|\meta{true$\vert$false}
%
%       is true by default: Macro use of identifiers defined as first order keywords also prints the surrounding |$(| and |)| in keyword style.
%       E.g.\ you could get \textbf{\textdollar(}\textbf{strip} \textdollar(BIBS)\textbf{)}.
%       If deactivated you would get \textdollar(\textbf{strip} \textdollar(BIBS)).
% \end{macrosyntax}
%
%
% \subsection{All about listing alignment}\label{uAllAboutListingAlignment}
%
% We start with the alignment of listings and surrounding text.
% \begin{macrosyntax}
% \item[0.19] \keyname{indent}|=|\meta{dimension}
%
%       indents each listing by \meta{dimension}, which is initialized with 0pt.
%       This command is the best way to move line numbers (and the listing) to the right.
%
% \item[0.19] \keyname{wholeline}|=|\meta{true$\vert$false}
%
%       prevents or lets the package use indention from list environments like \texttt{enumerate} or \texttt{itemize}.
%
% \item[0.16,bug] \keyname{spread}|=|\meta{dimension}\macrosyntaxor\keyname{spread}|={|\meta{inner}|,|\meta{outer}|}|
%
%       defines \emph{additional} line width for listings, which may avoid overfull |\hbox|es if a listing has long lines.
%       The inner and outer spread is given explicitly or is equally shared.
%       It is initialized via |spread=0pt|.
%       For one sided documents `inner' and `outer' have the effect of `left' and `right'.
%       Note that \keyname{indent} is always `left'.
%
%       Bug (two sided documents):
%       At top of page it's possible that the package uses inner instead of outer spread or vice versa.
%       This happens when \TeX\ finally moves one or two source code lines to the next page, but hasn't decided it when the \packagename{listings} package processes them.
%       Work-around: interrupt the listing and/or use an explicit |\newpage|.
%
% \item[0.17] \keyname{lineskip}|=|\meta{additional space between lines}
%
%       specifies the additional space between lines in listings.
%       You may write |lineskip=-1pt plus 1pt minus 0.5pt| for example, but 0pt is the default.
%
% \item[0.18] \keyname{boxpos}|=|\meta{\textup{\texttt{b}}$\vert$\textup{\texttt{c}}$\vert$\textup{\texttt{t}}}
%
%       Sometimes the \packagename{listings} package puts a |\hbox| around a listing --- or it couldn't be printed or even processed correctly.
%       The key determines the vertical alignment to the surrounding material: bottom baseline, top baseline or centered.
%
%       Note that |\hbox|ed listings don't use \keyname{spread}, for example.
% \end{macrosyntax}
% Now we go on with column alignment inside listings.
% \begin{macrosyntax}
% \item[0.19] \keyname{outputpos}|=|\meta{\textup{\texttt{c}}$\vert$\textup{\texttt{l}}$\vert$\textup{\texttt{r}}}
%
%       controls horizontal orientation of smallest output units (keywords, identifiers, etc.).
%       The arguments work as follows, where vertical bars visualize the effect:
%           $\vert$\hbox to 4.2em{\hss l\hss i\hss s\hss t\hss i\hss n\hss g\hss }$\vert$,
%           $\vert$\hbox to 4.2em{l\hss i\hss s\hss t\hss i\hss n\hss g\hss }$\vert$ and
%           $\vert$\hbox to 4.2em{\hss l\hss i\hss s\hss t\hss i\hss n\hss g}$\vert$
%       in fixed column mode resp.\ 
%           $\vert$\hbox to 3.15em{\hss listing\hss}$\vert$,
%           $\vert$\hbox to 3.15em{listing\hss}$\vert$ and
%           $\vert$\hbox to 3.15em{\hss listing}$\vert$
%       with flexible columns (using pre-defined base widths).
%       By default the output is centered.
%
% \item[0.18] \keyname{flexiblecolumns}|=|\meta{true$\vert$false}\macrosyntaxor\keyname{flexiblecolumns}
%
%       selects the flexible respectively the fixed column format, refer section \ref{uFixedAndFlexibleColumns}.
%
% \item[0.16,new] \keyname{basewidth}|=|\meta{width}\macrosyntaxor\keyname{basewidth}|={|\meta{fixed}|,|\meta{flexible mode}|}|
%
%       sets the width of a single character box for fixed and flexible column mode (both to the same value or individually).
%       |basewidth={|{\makeatletter\lst@widthfixed}|,|{\makeatletter\lst@widthflexible}|}| is the pre-definition.
%
% \item[0.20,new] \keyname{fontadjust}|=|\meta{true$\vert$false}\macrosyntaxor\keyname{fontadjust}
%
%       If true the package adjusts the base width every font selection.
%       This makes sense only if \keyname{basewidth} is given in font specific units like `em' or `ex' --- otherwise this boolean has no effect.
%
%       After loading the package it doesn't adjust the width every font selection:
%       It looks at \keyname{basewidth} each listing and uses the value for the whole listing.
%       This is possibly inadequate if the style keys in section \ref{uFigureOutTheAppearance} make heavy font size changes, see the example below.
%
%       If you prefer the \packagename{LGrind} package rather than \packagename{listings} (I can't imagine that ;\,--\,), you should try |basewidth=1ex| together with |flexiblecolumns| and |fontadjust|, but you have to play a bit with the base width.
% \end{macrosyntax}
% \begin{lstsample}{\lstset{basicstyle=\normalsize}}
%    \lstset{commentstyle=\scriptsize}
%    \begin{lstlisting}{}
%    { scriptsize font
%      doesn't look good }
%    for i:=maxint to 0 do
%    begin
%        { do nothing }
%    end;
%    \end{lstlisting}
% \end{lstsample}
% \begin{lstsample}{\lstset{basicstyle=\normalsize,commentstyle=\scriptsize}}
%    \begin{lstlisting}[fontadjust]{}
%    { scriptsize font
%      looks better now }
%    for i:=maxint to 0 do
%    begin
%        { do nothing }
%    end;
%    \end{lstlisting}
% \end{lstsample}
% Note that \keyname{fontadjust} also effects the keywords!
%
%
% \subsection{Frames}\label{uFrames}
%
% \begin{macrosyntax}
% \item	[0.19] \keyname{frame}|=|\meta{any subset of \textup{\texttt{trblTRBL}}}
%
%		The characters \texttt{trblTRBL} are attached to lines at the top and bottom of a listing and to lines on the right and left.
%		There are two lines if you use upper case letters.
%		If you want a single frame around a listing, write |frame=tlrb| or |frame=bltr|, for example, but as optional argument or argument to |\lstset|, of course.
%		If you want double lines at the top and on the left and no other lines, write |frame=TL|.
%
%		Note that frames reside outside the listing's space.
%		Use |spread| if you want to shrink frames (to |\linewidth| for example) and use |indent| to move line number inside frames.
%
% \item	[0.19] \keyname{framerulewidth}|=|\meta{dimension}
% \item	[0.19] \keyname{framerulesep}|=|\meta{dimension}
%
%		These keys control the width of the rules and the space between double rules.
%		Pre-defined values are {\makeatletter\lst@framerulewidth} width and {\makeatletter\lst@framerulesep} separation.
%
% \item	[0.19] \keyname{frametextsep}|=|\meta{dimension}
%
%		controls the space between frame and listing.
%		The pre-defined value is {\makeatletter\lst@frametextsep}.
%
% \item[0.20,new] \keyname{framespread}|=|\meta{dimension}
%
%       makes the frame on each side half \meta{dimension} wider.
%       It is initilaized with 0pt.
%
% \item[0.20,new] \keyname{frameround}|=|\meta{\textup{\texttt{t}}$\vert$\textup{\texttt{f}}}\meta{\textup{\texttt{t}}$\vert$\textup{\texttt{f}}}\meta{\textup{\texttt{t}}$\vert$\textup{\texttt{f}}}\meta{\textup{\texttt{t}}$\vert$\textup{\texttt{f}}}
%
%       The four letters are attached to the top right, bottom right, bottom left and top left corner.
%       In this order.
%       \texttt{t} makes the according corner round.
%       If you use round corners, the rule width is set via |\thinlines| and |\thicklines|.
%
%       Note: The size of the quarter circles is independent from \keyname{framespread}.
%       The size is possibly adjusted to fit \LaTeX's circle sizes.
% \end{macrosyntax}
% \keyname{frame} does not work with |fancyvrb=true| or when the package internally makes a |\hbox| around the listing!
% And there are certainly more problems with other commands.
% Take the time to report in.
%
% \begin{lstsample}{}
%    \lstset{frameround=tttt}
%    \begin{lstlisting}[frame=trBL]{}
%    for i:=maxint to 0 do
%    begin
%        { do nothing }
%    end;
%    \end{lstlisting}
% \end{lstsample}
%
% \begin{lstsample}{}
%    \lstset{framespread=5mm}
%    \begin{lstlisting}[frame=trbl]{}
%    for i:=maxint to 0 do
%    begin
%        { do nothing }
%    end;
%    \end{lstlisting}
% \end{lstsample}
%
% Do you want exotic frames?
% Try the following key if you want for example
% \begin{lstsample}{\lstset{frameshape={RYRYNYYYY}{yny}{yny}{RYRYNYYYY}}}
%    \begin{lstlisting}{}
%    for i:=maxint to 0 do
%    begin
%        { do nothing }
%    end;
%    \end{lstlisting}
% \end{lstsample}
% \begin{macrosyntax}
% \item[0.20,new] \keyname{frameshape}|=|\marg{top shape}\marg{left shape}\marg{right shape}\marg{bottom shape}
%
%       gives you full control over the drawn frame parts.
%       The arguments are not case sensitive.
%
%       \meta{left shape} and \meta{right shape} are both `left-to-right' |y|/|n| character sequences (or empty).
%       Each |y| lets the package draw a rule, otherwise the rule is blank.
%       These vertical rules are drawn `left-to-right' according to the specified shapes.
%       The example above uses |yny| for both shapes.
%
%       \meta{top shape} and \meta{bottom shape} are `left-rule-right' sequences (or empty).
%       The first `left-rule-right' sequence is attached to the most inner rule + corners, the second to the next, and so on.
%       Each sequence has three characters:
%       `rule' is either |y| or |n|; `left' and `right' are |y|, |n| or |r| (which makes a corner round).
%       The example uses |RYRYNYYYY| for both shapes:
%       |RYR| describes the most inner (top and bottom) frame shape, |YNY| the middle, and |YYY| most outer.
% \end{macrosyntax}
% Above I used
% \begin{verbatim}
%    \lstset{frameshape={RYRYNYYYY}{yny}{yny}{RYRYNYYYY}}\end{verbatim}
% Note that you are not resticted to two or three levels.
% However you'll get in trouble if you use round corners when they are too big.
%
%
% \subsection{Escaping to \LaTeX}
%
% \textbf{Note:} {\itshape Any escape to \LaTeX\ may disturb the column alignment since the package can't control the spacing there.}
% \begin{macrosyntax}
% \item[0.18] \keyname{texcl}|=|\meta{true$\vert$false}\macrosyntaxor\keyname{texcl}
%
%       activates or deactivates \LaTeX\ comment lines.
%       If activated comment line delimiters are printed as usual, but the comment line text (up to the end of line) is read as \LaTeX\ code and typeset in comment style.
% \end{macrosyntax}
% The example uses C++ comment lines (but doesn't say how to define them).
% Without |\upshape| we would get \textit{calculate} since the comment style is |\itshape|.
% \begin{lstsample}{\lstset{commentline=//}}
%    \begin{lstlisting}[texcl]{}
%    // \upshape calculate $a_{ij}$
%      A[i][j] = A[j][j]/A[i][j];
%    \end{lstlisting}
% \end{lstsample}
%
% \begin{macrosyntax}
% \item[0.19] \keyname{mathescape}|=|\meta{true$\vert$false}
%
%       activates or deactivates special behaviour of the dollar sign.
%       If activated a dollar sign acts as \TeX's text math shift.
%
%       This key is useful if you want to typeset formulas in a nice way.
%
% \item[0.19] \keyname{escapechar}|=|\meta{single character}\macrosyntaxor\keyname{escapechar}|={}|
%
%       If not empty the given character escapes the user to \LaTeX:
%       All code between two such characters is interpreted as \LaTeX\ code.
%       Note that \TeX's special characters must be entered with a preceding backslash, e.g.\ |escapechar=\%|.
%
% \item[0.20,new] \keyname{escapeinside}|=|\meta{single character}\meta{single character}\macrosyntaxor\keyname{escapeinside}|={}|
%
%       Is a generalization of \keyname{escapechar}.
%       If the value is not empty, the package escapes to \LaTeX\ between the first and second character.
%
% \item[0.20,new] \keyname{escapebegin}|=|\meta{`begin' tokens}
% \item[0.20,new] \keyname{escapeend}|=|\meta{`end' tokens}
%
%       The tokens are executed at the beginning respectively at the end of each escape, in particular for \keyname{texcl}.
%       See section \ref{uNationalCharacters} for an application.
% \end{macrosyntax}
%
% \begin{lstsample}{\lstset{commentline=//}}
%    \begin{lstlisting}[mathescape]{}
%    // calculate $a_{ij}$
%      $a_{ij} = a_{jj}/a_{ij}$;
%    \end{lstlisting}
% \end{lstsample}
%
% \begin{lstsample}{\lstset{commentline=//}}
%    \begin{lstlisting}[escapechar=\%]{}
%    // calc%ulate $a_{ij}$%
%      %$a_{ij} = a_{jj}/a_{ij}$%;
%    \end{lstlisting}
% \end{lstsample}
%
% \begin{lstsample}{\lstset{commentline=//}}
%    \lstset{escapeinside=`'}
%    \begin{lstlisting}{}
%    // calc`ulate $a_{ij}$'
%      `$a_{ij} = a_{jj}/a_{ij}$';
%    \end{lstlisting}
% \end{lstsample}
% In the first example the comment line up to $a_{ij}$ has been typeset in comment style and by the \packagename{listings} package.
% The $a_{ij}$ itself is typeset in `\TeX\ math mode' without comment style.
% About the half comment line of the second example has been typeset by this package.
% The rest is in `\LaTeX\ mode' without comment style.
%
% To avoid problems with the current and future version of this package:
% \begin{enumerate}
% \item Don't use any command of the \packagename{listings} package when you have escaped to \LaTeX.
% \item Any environment must start and end inside the same escape.
% \item You might use |\def|, |\edef|, etc., but do not assume that the definitions are present later --- except they are |\global|.
% \item |\if \else \fi|, groups, math shifts |$| and |$$|, \ldots\ must be balanced each escape.
% \item \ldots
% \end{enumerate}
% Expand that list yourself and mail me about new items.
%
%
% \subsection{National characters}\label{uNationalCharacters}
%
% You probably want to use national characters in your listings, for example in comments.
% The first possibilty makes use of \keyname{escapechar} or \keyname{escapeinside}:
% \begin{lstsample}{}
%     \begin{lstlisting}[escapechar=`]{}
%     `\"a \`e {\=\i} {\oe} \u u`
%     \end{lstlisting}
% \end{lstsample}
% A better way is to type in the national characters directly:
% \begin{macrosyntax}
% \item[0.18] \keyname{extendedchars}|=|\meta{true$\vert$false}\macrosyntaxor\keyname{extendedchars}
%
%		allows or prohibits extended characters in listings, i.e.\ characters with codes 128--255.
%		If you use extended characters, you should use the \packagename{fontenc} or \packagename{inputenc} package --- read section \ref{uAccentsAndSplittedListings} if you use the latter one.
% \end{macrosyntax}
% However, the extended character tables don't cover Arabic, Chinese, Hebrew, Japanese, and so on.
% In this case you'll have to use $\Lambda$ (Lambda), the \LaTeX\ pendant to Omega.
% The keys \keyname{escapebegin} and \keyname{escapeend} allows you to select and deselect $\Omega$\ compiled translation processes.
% Then the most comfortable way of usage are comment lines.
% \begin{verbatim}
%    \lstset{escapebegin=\begin{arab},escapeend=\end{arab}}
%
%    \begin{lstlisting}[texcl]{}
%    // Replace text by Arabic comment.
%    for (int i=0; i<1; i++) { };
%    \end{lstlisting}\end{verbatim}
% If your programming language doesn't have comment lines, you'll have to use \keyname{escapechar} or \keyname{escapeinside}:
% \begin{verbatim}
%    \lstset{escapebegin=\begin{greek},escapeend=\end{greek}}
%
%    \begin{lstlisting}[escapeinside=`']{}
%    /* `Replace text by Greek comment.' */
%    for (int i=0; i<1; i++) { };
%    \end{lstlisting}\end{verbatim}
% There is a more clever way if the comment delimiters of the programming language are single characters like the braces in Pascal:
% \begin{verbatim}
%    \lstset{escapebegin=\textbraceleft\begin{arab},
%            escapeend=\end{arab}\textbraceright}
%
%    \begin{lstlisting}[escapeinside=\{\}]{}
%    for i:=maxint to 0 do
%    begin
%        { Replace text by Arabic comment. }
%    end;
%    \end{lstlisting}\end{verbatim}
% Finally note that the `interface' to $\Lambda$ is completely untested.
%
%
% \subsection{Environments}\label{uEnvironments}
%
% The command used to define the \texttt{lstlisting} environment is public now.
% The syntax comes from \LaTeX's |\newenvironment|.
% \begin{macrosyntax}
% \item[0.19] |\lstnewenvironment|\marg{name}\oarg{number of parameters}\oarg{opt.~default~arg.}\macrosyntaxbreak
%       |{|\meta{starting code}|}||{|\meta{ending code}|}|
% \end{macrosyntax}
% We present two examples, namely \texttt{lstlisting} and version 0.17 \texttt{listing} environment.
% The latter one is quite simple since the one and only and optional argument is the name.
% \begin{verbatim}
%\lstnewenvironment{listing}[1][]
%    {\gdef\lst@intname{#1}}
%    {}\end{verbatim}
% The other is more difficult.
% First we test whether the nonoptional name argument is an EOL character.
% If this is the case, the user has forgotten the name and an error message is issued.
% Then we use the optional key=value list.
% The rest ensures correct (continued) line numbering.
% \begin{verbatim}
%\lstnewenvironment{lstlisting}[2][]
%    {\lst@TestEOLChar{#2}%
%     \lstset{#1}%
%     \csname lst@SetFirstLabel\endcsname}
%    {\csname lst@SaveFirstLabel\endcsname}\end{verbatim}
% The package defines one more (optional) environment for documentation.
% It's the environment which typesets verbatim code on the right and the result on the left (or the result atop the code if the verbatim code is too wide).
% The definition is a bit longer, needs to be explained, and is therefore not shown here.
%
% Finally note that all \lst-environments can also be used in command fashion like this
% \begin{lstsample}{\lstset{language={},basicstyle=\ttfamily}}
%    \lstlisting[gobble=4]{}
%        \begin{lstlisting}{}
%        Silly sentence?
%        \end{listings}
%    \endlstlisting
% \end{lstsample}
%
%
% \subsection{Interface to \packagename{fancyvrb}}
%
% The \packagename{fancyvrb} package --- fancy verbatims --- from Timothy van Zandt provides macros for reading, writing and typesetting verbatim code.
% It has some remarkable features the \packagename{listings} package doesn't have.
% Some are also possible, but you must find somebody who implements them ; -- ).
% The \packagename{fancyvrb} package is available from \texttt{CTAN: macros/latex/contrib/supported/fancyvrb}.
%
% \begin{macrosyntax}
% \item	[0.19]|fancyvrb=|\meta{true$\vert$false}
%
%       activates or deactivates the interface.
%       This defines an appropriate version of |\FancyVerbFormatLine| to make the two packages work together.
%       If active, the verbatim code read by the \packagename{fancyvrb} package is typeset by the \packagename{listings} package, i.e.\ with emphasized keywords, strings, comments, and so on.
%       --- You should know that |\FancyVerbFormatLine| is responsible for typesetting a single code line.
%
%       If \packagename{fancyvrb} and \packagename{listings} provide similar functionality, use \packagename{fancyvrb}'s.
%
%       This second interface works with |Verbatim|, |BVerbatim| and |LVerbatim|.
%       But you shouldn't use \keyname{defineactive}. (As far as I can see it doesn't matter since it does nothing at all.)
% \end{macrosyntax}
%
% \iffancyvrb
% \begin{lstsample}{}
%    \lstset{commentline=\ }% :-)
%    \fvset{commandchars=\\\{\}}
%
%    \begin{BVerbatim}
%    First verbatim line.
%    \fbox{Second} verbatim line.
%    \end{BVerbatim}
%    \vskip72.27pt
%
%    \lstset{fancyvrb}
%    \begin{BVerbatim}
%    First verbatim line.
%    \fbox{Second} verbatim line.
%    \end{BVerbatim}
%    \lstset{fancyvrb=false}
% \end{lstsample}
% The last two lines are wider than the first two since the default |basewidth| equals not the width of a single typewriter type character.
% \else
% \begin{center}
% \packagename{fancyvrb} seems to be unavailable on your platform, thus the example couldn't be printed here.
% \end{center}
% \fi
%
%
% \subsection{Language definitions}\label{uLanguageDefinitions}
%
% Language definitions and also some style definitions tend to have long definition parts.
% This is why I and possibly other people tend to forget commas between the key=value elements.
% If you select a language and get a |Missing| |=| |inserted| |for| |\ifnum| error, this is surely due to a missing comma after |keywords=|value.
% If you encounter unexspected characters after selecting a language (or style), you have either forgotten a comma or you have given to many arguments to a key, for example |commentline={--}{!}|.
% \begin{macrosyntax}
% \item[0.19,addon] |\lstdefinelanguage|\macrosyntaxnewline[\oarg{dialect}]\marg{language}\macrosyntaxnewline[\oarg{base dialect}\marg{and base language}]\macrosyntaxnewline\marg{key=value list}\macrosyntaxnewline[\oarg{list of required aspects \textup(keywordcomments,texcs,etc.\textup)}]
%
%		defines a programming language.
%       If the language definition is based on another, you must specify the whole \oarg{base dialect}\marg{and base language}.
%       An empty \meta{base dialect} uses the default dialect which might changes.
%
%       The \meta{key=value list} is executed (additionally) when you select the language.
%       The last optional argument should specify which \lst-aspects (see section \ref{dWhyLstAspects}) the language definition requires.
%       For example, ANSI C uses |keywords|, |comments|, |strings| and |directives|.
%
%       |\lst@definelanguage| (same syntax) defines languages in driver files.
%
% \item[0.18] |\lstalias|\marg{alias}\marg{language}
%
%		defines an alias for a programming language.
%		Any dialect of \meta{alias} selects in fact the same dialect of \meta{language}.
%		It's also possible to define an alias for one dialect: |\lstalias|\oarg{dialect alias}\marg{alias}\oarg{dialect}\marg{language}.
%		Here all four parameters are \emph{non}optional.
%		An alias with empty \meta{dialect} will select the default dialect.
%		Note that aliases can't be nested: The two aliases |\lstalias{foo1}{foo2}| and |\lstalias{foo2}{foo3}| redirect |foo1| not to |foo3|.
%
%		Note that a configuration file possibly defines some aliases.
% \end{macrosyntax}
%
% Now come all the language keys, which might be used in the key=value list of |\lstdefinelanguage|.
% Note: {\itshape If you want to enter {\upshape|\|, |{|, |}|, |%|, |#|} or {\upshape|&|} inside or as an argument here, you must do it with a preceding backslash!}
%
% \begin{macrosyntax}
% \item[0.11] \keyname{keywords}|=|\marg{keywords}
% \item[0.11] \keyname{morekeywords}|=|\marg{additional keywords}
% \item[0.18] \keyname{deletekeywords}|=|\marg{keywords to remove}
%
% \item[0.19] \keyname{ndkeywords}|=|\marg{second order keywords}
% \item[0.19] \keyname{morendkeywords}|=|\marg{additional second order keywords}
% \item[0.19] \keyname{deletendkeywords}|=|\marg{second order keywords to remove}
%
% \item[0.19,optional] \keyname{rdkeywords}|=|\marg{third order keywords}
% \item[0.19,optional] \keyname{morerdkeywords}|=|\marg{additional third order keywords}
% \item[0.19,optional] \keyname{deleterdkeywords}|=|\marg{third order keywords to remove}
%
%       Each \meta{keywords} like value (here and below) is a list of keywords separated by commas.
%       |keywords={save,Test,test}| defines three keywords (if keywords are case sensitive).
%       Use |keywords={}| to remove all first order keywords.
%
%^^A
%^^A We need some definitions here.
%^^A
%\makeatletter
%\def\lstspec#1{^^A
%    \ifx\relax#1\else
%        {\lstset{keywords=#1}\setbox\@tempboxa\hbox{\lstinline a#1a}}^^A
%        \lst@ifspec\lstinline a#1a\fi
%        \expandafter\lstspec
%    \fi}^^A
%\lst@AddToHook{OutputOther}{\global\let\lst@ifspec\iffalse}^^A
%\lst@AddToHook{Output}{\lstspectest}^^A
%\gdef\lstspecfalse{\global\let\lst@ifspec\iffalse}^^A
%\gdef\lstspectest{^^A
%    \global\let\lst@ifspec=\iftrue
%	 \ifx\lst@thestyle\lst@gkeywordstyle\else
%        \lstspecfalse
%	 \fi}^^A
%\makeatother
%	{\lstset{language={}}^^A
%    \texttt{\lstspec !"\#$\%&'()*+-./0123456789:;<=>?@[\\]^_`\{\|\}\~\relax}}
%^^A
%^^A End of test.
%^^A
%       can all be used in keywords, but note that you must write |\#|, |\%|, |\&|, |\\|, |\{| and |\}| instead of |#|, |%|, |&|, |\|, |{| and |}|.
%       Please read the notes about the `|also|' keys if you use unusual charaters in keywords.
%
%       Note that there is the key \keyname{texcs} to define control sequences as keywords.
%
% \item[0.14] \keyname{sensitive}|=|\meta{true$\vert$false}
%
%		makes the keywords (first, second and third) case sensitive resp.\ insensitive.
%		This key affect the keywords only in the phase of typesetting.
%		In all other situations keywords are case sensitive, i.e.\ |deletekeywords={save,Test}| removes `save' and `Test', but neither `SavE' nor `test'.
%
% \item[0.19] \keyname{alsoletters}|=|\marg{character sequence}
% \item[0.19] \keyname{alsodigits}|=|\marg{character sequence}
% \item[0.19] \keyname{alsoother}|=|\marg{character sequence}
%
%       These keys support the `special character' auto-detection of the keyword commands.
%       For our purpose here, identifiers are out of letters (|A|--|Z|,|a|--|z|,|_|,|@|,|$|) and digits (|0|--|9|), but an identifier must begin with a letter.
%       If you write |keywords={one-two,\#include}|, the minus becomes necessarily a digit and the sharp a letter since the keywords can't be detected otherwise.
%       This means that the defined keywords affect the process of building the `output units'!
%
%       The three keys overwrite such default behaviour.
%       Each character of the sequence becomes a letter, digit and other, respectively.
%       Note that the auto-detection might fail if you remove keywords.
%
% \item[0.20,new] \keyname{otherkeywords}|=|\marg{keywords}
%
%       Each given `keyword' is printed in keyword style, but without changing the `letter', `digit' and `other' status of the characters.
%       This key is designed to define keywords like |=>|, |->|, |-->|, |--|, |::|, and so on.
%       If one keyword is a subsequence of another (like |--| and |-->|), you must specify the shorter first.
%
% \item[0.19] \keyname{stringtest}|=|\meta{true$\vert$false}
%
%       enables or disables string tests:
%       If activated line exceeding strings issue warnings and the package exits string mode.
%
% \item[0.12] \keyname{stringizer}|=|\oarg{b$\vert$d$\vert$m$\vert$bd}\marg{character sequence}
%
%       Each character might start a string or character literal.
%       'Stringizers' match each other, i.e.\ starting and ending delimiters are the same.
%       The optional argument controls how the stringzier(s) itself is/are represented in a string or character literal:
%       It is preceded by a |b|ackslash, |d|oubled (or both is allowed via |bd|) or it is |m|atlabed.
%       The latter one is a special type for Ada and Matlab and possibly more languages, where the stringizers are also used for other purposes.
%       In general the stringizer is also doubled, but a string does not start after a letter or a right parenthesis.
%
% \item[0.19,optional] \keyname{texcs}|=|\marg{list of control sequences \textup(without backslashes\textup)}
% \item[0.20,optional] \keyname{moretexcs}|=|\marg{list of control sequences \textup(without backslashes\textup)}
%
%       defines/expands the list of control sequences for \TeX\ and \LaTeX.
%
% \item[0.18,renamed,optional] |directives={|\meta{list of compiler directives}|}|
%
%       defines compiler directives in C, C++, Objective-C and POV.
% \item[0.20,new,optional] \keyname{keywordsinside}|=|\meta{character}\meta{character}\macrosyntaxor\keyname{keywordsinside}|={}|
%
%       The first order keywords are active only between the first and second character.
%       This key is used for HTML.
% \end{macrosyntax}
% If you have already defined any of the following comments and you want to remove it, let all arguments to the comment key empty.
% \begin{macrosyntax}
% \item[0.13,addon] \keyname{commentline}|=|\meta{delimiter}
%
%       The characters (\emph{in the given order}) start a comment line, which in general starts with the delimiter and ends at end of line.
%       If the character sequence |//| starts a comment line (like in C++, Comal 80 or Java), |commentline=//| is the correct declaration.
%       For Matlab it would be |commentline=\%| --- note the preceding backslash.
%
% \item[0.18] \keyname{fixedcommentline}|=|\oarg{n=preceding columns}\meta{character sequence}
%
%       Each given character becomes a `fixed comment line' separator: It starts a comment line if and only if it is in column $n+1$.
%       Fortran 77 declares its comments via |fixedcommentline=*Cc| ($n=0$ is default).
%
% \item[0.13,addon] \keyname{singlecomment}|=|\marg{delimiter}\marg{delimiter}
% \item[0.13,addon] \keyname{doublecomment}|=|\marg{delimiter}\marg{delimiter}\marg{delimiter}\marg{delimiter}
%
%       Here we have two or four delimiters.
%       The second ends a comment starting with the first, and similarly the fourth and third delimiter for double comments.
%       If you need three such comments you can use \keyname{singlecomment} and \keyname{doublecomment} at the same time.
%       C, Java, PL/I, Prolog and SQL all define single comments via |singlecomment={/*}{*/}|, and Algol does it with |singlecomment={\#}{\#}|, which means that the sharp delimits both beginning and end of a single comment.
%
% \item[0.13,addon] \keyname{nestedcomment}|=|\marg{delimiter}\marg{delimiter}
%
%       is similar to \keyname{singlecomment}, but comments can be nested.
%       Identical arguments are not allowed --- think a while about it!
%       Modula-2 and Oberon-2 use |nestedcomment={(*}{*)}|.
%
% \item[0.17,optional] \keyname{keywordcomment}|=|\marg{keywords}
% \item[0.17,renamed,optional] \keyname{keywordcommentsemicolon}|=|\marg{keywords}\marg{keywords}\marg{keywords}
%
%       A (paired) keyword comment begins with a keyword and ends with the same keyword.
%       Consider |keywordcomment={comment,co}|.
%       Then `\textbf{comment}\allowbreak\ldots\textbf{comment}' and `\textbf{co}\ldots\textbf{co}' are comments.
%
%       Defining a (double) keyword comment semicolon needs three keyword lists, e.g.\ |{end}{else,end}{comment}|.
%       A semicolon always ends such a comment.
%       Any keyword of the first argument begins a comment and any keyword of the second argument ends it (and a semicolon also); a comment starting with any keyword of the third argument is terminated with the next semicolon only.
%       In the example all possible comments are `\textbf{end}\ldots\textbf{else}', `\textbf{end}\ldots\textbf{end}' (does not start a comment again) and `\textbf{comment}\ldots;' and `\textbf{end}\ldots;'.
%       Maybe a curious definition, but Algol and Simula use such comments.
%
%       Note: The keywords here need not to be a subset of the defined keywords.
%       They won't appear in keyword style if they aren't.
%
% \item[0.17,optional] \keyname{podcomment}|=|\meta{true$\vert$false}
%
%       activates or deactivates PODs --- Perl specific.
% \end{macrosyntax}
%
%
% \subsection{Obsolete keys and commands}\label{uObsoleteKeysAndCommands}
%
% We come to the obsolete features --- obsolete by definition.
% Don't use these keys and commands any more.
% In the worst case other keys must be introduced.
% This might sound strange but in particular the arguments of \keyname{pre} and \keyname{post} are hardly to control.
% Therefor they are deactivated in some cases, and this means that all features defined via these keys are deactivated.
% That's not good.
% \begin{macrosyntax}
% \item[0.12,obsolete] \keyname{pre}|=|\oarg{continue}\marg{commands to execute}
% \item[0.12,obsolete] \keyname{post}|=|\oarg{continue}\marg{commands to execute}
%
%       The given control sequences are executed before and after typesetting resp.\ when continuing a listing, but in all cases inside a group.
%       The commands are not executed for |\lstinline| or if the package makes an extra |\hbox| around the listing.
%       The reason is that the user given pre and post commands are assumed to be unsave inside |\hbox|.
%       By default \meta{continue} equals \meta{commands to execute}.
%       All arguments are pre-set empty.
%
% \item[0.18,obsolete] |\lststorekeywords|\meta{macro}\marg{keywords}
%
%       stores \meta{keywords} in \meta{macro} for use with keyword keys.
%       This command can't be used in a language definition since it is a command and not a key.
%
% \item[0.19,obsolete] |\lstname|
%
%       contains the name of the current (last) listing in \emph{printable} form.
%
% \item[0.19,obsolete] |\lstintname|
%
%       contains the name of the current (last) listing possibly in nonprintable form.
% \end{macrosyntax}
%
%
% \section{Experimental features}\label{uExperimentalFeatures}
%
% This section describes the more or less unestablished parts of the \packagename{listings} package.
% It's unlikely that they are removed, but they are liable to (heavy) changes and improvements.
%
%
% \subsection{Listings inside arguments}
%
% There are some things to consider if you want to use |\lstinline| or the listing environment inside arguments.
% Since \TeX\ reads the argument before the `\lst-macro' is executed, this package can't do anything to preserve the input:
% Spaces shrink to one space, the tabulator and the end of line are converted to spaces, the comment character is not printable, and so on.
% Hence, you must work a bit more.
% You have to put a backslash in front of each of the following four characters: |\{}%|.
% Moreover you must protect spaces in the same manner if: (i) there are two or more spaces following each other or (ii) the space is the first character in the line.
% That's not enough: Each line must be terminated with a `line feed' |^^J|.
% Finally you can't escape to \LaTeX\ inside such listings.
%
% The easiest examples are with |\lstinline| since we need no line feed.
% \begin{verbatim}
%\footnote{\lstinline!var i:integer;! and
%          \lstinline!protected\ \ spaces! and
%          \fbox{\lstinline!\\\{\}\%!}}\end{verbatim}
% yields\lstset{language=Pascal}\footnote{\lstinline!var i:integer;! and \lstinline!protected\ \ spaces! and \fbox{\lstinline!\\\{\}\%!}} if the current language is Pascal.
% Now environment examples:
%
% \begingroup
% \lstset{language={}}
% \begin{lstsample}{}
%    \fbox{%^^J
%    \begin{lstlisting}{}^^J
%    \ !"#$\%&'()*+,-./^^J
%    0123456789:;<=>?^^J
%    @ABCDEFGHIJKLMNO^^J
%    PQRSTUVWXYZ[\\]^_^^J
%    `abcdefghijklmno^^J
%    pqrstuvwxyz\{|\}~^^J
%    \end{lstlisting}}
% \end{lstsample}
%
% \begin{lstsample}{}
%    \fbox{%^^J
%    \begin{lstlisting}{}^^J
%    We need no protection here,^^J
%    \ but\ \ in\ \ this\ \ line.^^J
%    \end{lstlisting}}
% \end{lstsample}
% \endgroup
%
%
% \subsection{Export of identifiers}
%
%^^A \lsthelper{Aslak~Raanes}{1997/11/24}{export function names}
% It would be nice to export function or procedure names, for example to index them automatically or to use them in |\lstlistoflistings| instead of a listing name.
% In general that's a dream so far.
% The problem is that programming languages use various syntaxes for function and procedure declaration or definition.
% A general interface is completely out of the scope of this package --- that's the work of a compiler and not of a pretty printing tool.
% However, it is possible for particular languages: in Pascal each function or procedure definition and variable declaration is preceded by a particular keyword.
% \begin{macrosyntax}
% \item	[0.19,optional] \keyname{index}|=|\marg{identifiers}
% \item	[0.20,new,optional] \keyname{ndindex}|=|\marg{identifiers}
%
%		\meta{identifiers} is a comma-separated list of identifiers.
%		Each appearance of such an identifier is indexed.
%
% \item	[0.19,optional] \keyname{indexmacro}|=|\meta{`one parameter' macro}
% \item	[0.20,new,optional] \keyname{ndindexmacro}|=|\meta{`one parameter' macro}
%
%		The specified macro gets exactly one parameter, namely the (nd)identifier, and must do the indexing.
%		(|nd|)|indexmacro=\lstindexmacro| is the pre-definition and we have\vspace{-.5\baselineskip}
% \begin{verbatim}
%    \newcommand\lstindexmacro[1]{\index{{\ttfamily#1}}}\end{verbatim}
%
% \item[0.19,optional] \keyname{prockeywords}|=|\marg{keywords}
%
%		\meta{keywords} is a comma-separated list of keywords, which indicate a function or procedure definition.
%		Any identifier following such a keyword appears in `procname' style.
%		For Pascal you might use\vspace{-.5\baselineskip}
% \begin{verbatim}
%    prockeywords={program,procedure,function}\end{verbatim}
%
% \item[0.19,optional] \keyname{procnamestyle}|=|\meta{style for procedure names}
%
%		defines the style in which procedure and function names appear.
%
% \item[0.19,optional] \keyname{indexprocnames}|=|\meta{true$\vert$false}
%
%		If activated, procedure and function names are also indexed (if used with |index| option).
% \end{macrosyntax}
%
%
% \subsection{Automatic line breaking}
%
% \begin{macrosyntax}
% \item[0.20,new,optional] \keyname{breaklines}|=|\meta{true$\vert$false}\macrosyntaxor\keyname{breaklines}
%
%       activates or deactivates automatic line breaking of long lines.
%       This is deactivated by default.
%
% \item[0.20,new,optional] \keyname{breakindent}|=|\meta{dimension}
%
%       indents the second, third, \ldots\ line of broken lines by \meta{dimension}.
%       It is initialized with \csname lst@breakindent\endcsname.
%
% \item[0.20,new,optional] \keyname{breakautoindent}|=|\meta{true$\vert$false}\macrosyntaxor\keyname{breakautoindent}
%
%       activates or deactivates automatic indention of broken lines.
%       This indention is used additionally to \keyname{breakindent} and is equal to the indention of the source code line, see the example below.
%       It is activated by default.
%
%       |visiblespaces=true| converts `invisibles' spaces and tabulators to visible \textvisiblespace.
%       This will set `auto indent' to 0pt, i.e.\ there is no automatic indention.
%
% \item[0.20,new,optional] \keyname{prebreak}|=|\meta{tokens}
% \item[0.20,new,optional] \keyname{postbreak}|=|\meta{tokens}
%
%       \meta{tokens} appear at the end of the current line respectively at the beginning of the next (broken part of the) line.
%       Both \meta{tokens} are initialized empty.
%
%       You must not use dynamic space (in particular spaces) since internally we use |\discretionary|.
%       However |\space| is redefined to be used inside \meta{tokens}.
% \end{macrosyntax}
% We use tabulators now to create long lines, but the verbatim part uses |tabsize=1|.
%
% \begingroup
% \hfuzz=1in
% \def\lstsampleverbcmd{\lstset{tabsize=1}}
% \begin{lstsample}{\lstset{stringizer="}}
%    \lstset{postbreak=\space\space,breakindent=0pt,breaklines}
%
%    \begin{lstlisting}{}
%    		"A very long string doesn't fit the current line width."
%    				"An even longer line doesn't fit also, of course, and goes over three lines."
%    \end{lstlisting}
%
%    \begin{lstlisting}[breakautoindent=false]{}
%    		{ Now auto indention is off, and only breakindent=0pt and postbreak are used. }
%    \end{lstlisting}
%
%    \begin{lstlisting}[visiblespaces]{}
%    		{ `visiblespaces=true' implies `breakautoindent=false'. }
%    \end{lstlisting}
% \end{lstsample}
% \endgroup
%
%
% \subsection{Literate programming}
%
% We begin with an example and hide the crucial key=value list.
% \begin{lstsample}{\lstset{literate={:=}{{$\gets$}}1 {<=}{{$\leq$}}1 {>=}{{$\geq$}}1 {<>}{{$\neq$}}1}}
%    \begin{lstlisting}{}
%    var i:integer;
%
%    if (i<=0) i := 1;
%    if (i>=0) i := 0;
%    if (i<>0) i := 0;
%    \end{lstlisting}
% \end{lstsample}
% Funny, isn't it?
% We could write |i := 0| respectively i| |$\gets$| |0 instead, but that's not literate :\,--\,).
% Now you might want to know how this has been done.
% Have a \emph{close} look at the following key.
% \begin{macrosyntax}
% \item[0.20,new] \keyname{literate}|=|\meta{replacement item}\ldots\meta{replacement item}
%
%       First note that there are no commas between the items.
%       Each item consists of three arguments: \marg{replace}\marg{replacement text}\marg{length}.
%       \meta{replace} is the original character sequence.
%       Instead of printing these characters we use \meta{replacement text}, which takes the width of \meta{length} characters in the output.
%
%       Each `printing unit' in \meta{replacement text} \emph{must} be braced except it's a single character.
%       For example, you must put braces around |$\leq$|.
%       If you want to replace |<-1->| by |$\leftarrow1\rightarrow$| the replacement item would be |{<-1->}{{$\leftarrow$}1{$\rightarrow$}}3|.
%       Note the braces around the arrows.
%
%       If one \meta{replace} is a subsequence of another \meta{replace}, you must use the shorter sequence first.
%       For example, |{-}| must be used before |{--}| and this before |{-->}|.
% \end{macrosyntax}
% In the example above I've used
% \begin{verbatim}
%  literate={:=}{{$\gets$}}1 {<=}{{$\leq$}}1 {>=}{{$\geq$}}1 {<>}{{$\neq$}}1\end{verbatim}
%
%
% \section{Troubleshooting}
%
% The known bugs have already been described.
% Contact me if you encounter any other problems if they are not described below.
% For a bug report create a \emph{short} file which demonstrates the problem.
% Please start from the minimal file in section \ref{uAMinimalFile}.
% However, include the file itself and the created \texttt{.log} file in your bug report.
%
%
% \subsection{Accents and splitted listings}\label{uAccentsAndSplittedListings}
%
% \lsthelper{Marcin~Kasperski}{1999/04/28}{listings spoil table of contents (when splitted between pages)} reported a deep problem and \lsthelper{Donald~Arseneau}{1999/05/13}{Re: delayed write and catcode changes} let me understand it a bit.
% Thanks to both.
% But now a description and possible solutions.
% Let's say that a new section starts on the current page and the section name contains an accented character.
% In particular this could be an extended character if you use \packagename{inputenc} (since that package makes these characters active and makes appropriate definitions).
% Furthermore a listing should start on the same page and end on the next page.
% Then you probably get an ``undefined control sequence'' error if you try to make a |\tableofcontents|.
% The control sequence comes from the accent command and the character to be accented:
% A space is missing in between.
% The accents |\`|, |\'|, |\^|, |\"|, etc.\ will work since there need not to be a space between command and accented character.
% But |\c|, |\d|, |\k|, etc. won't work:
% If you write |\c o|, the \texttt{.toc} file will show |\co| and that's usually undefined.
% The problem is neither limited to accents nor to |\tableofcontents|.
% Try |\index| and/or |\oe|, |\o|, |\L|, and so on.
%
% If you type in the accents directly (accents for simplicity), you can make braces around the character to be accented, e.g.\ write |\c{o}| instead of |\c o| or write |{\oe}| instead of |\oe|.
% Then missing spaces don't hurt.
% This solution was proposed by \lsthelper{Heiko~Oberdiek}{1999/05/??}{Re: delayed write and catcode changes}.
%
% If you use extended characters realized with \packagename{inputenc}, you can't go that way.
% I see two possibilities if you absolutely want to keep the \packagename{inputenc} package:
% (i) insert appropriate braces in \texttt{.def} files (but note the copyright and modification notices in these files!) or better (ii) let the \packagename{listings} package define a work-around.^^A
% \footnote{The work-around would define a local version of the output routine:
% At the beginning we switch back to \TeX's original catcodes and at the end we activate the \packagename{listings}' ones again.}
% Alternatively you could use \packagename{fontenc}.
% \lsthelper{Marcin~Kasperski}{1999/05/06}{web2c solution} solved the problem by using the web2c \TeX\ character translation capability and used |%& -translate-file=|\meta{file} as the very first line of the document.
%
%
% \subsection{Bold typewriter fonts}
%
% Many people asked for bold typewriter fonts since they aren't included in the \LaTeX\ standard distribution.
% Here now one answer on how to use them in spite of that.
% Firstly you'll need Metafont source files for bold typewriter, e.g.\ \texttt{cmbtt8.mf}, \texttt{cmbtt9.mf} and \texttt{cmbtt10.mf} from CTAN.
% Secondly you have to create \texttt{.tfm} files, i.e.\ run the Metafont program on these sources.
% This is possibly done automatically when you use the fonts in a document.
% Finally you must tell \LaTeX\ that you've installed bold typewriter fonts:
% Write
% \begin{verbatim}
%\DeclareFontShape{OT1}{cmtt}{bx}{n}
%     {<5><6><7><8>cmbtt8%
%      <9>cmbtt9%
%      <10><10.95>cmbtt10%
%      <12><14.4><17.28><20.74><24.88>cmbtt10%
%      }{}\end{verbatim}
% before |\begin{document}|.
% That's all, folks!
%
%
% \section{Forthcoming}
%
% I'd like to support more languages, for example Maple, PostScript, Reduce, and so on.
% Fortunately my lifetime is limited, so other people may do that work.
% Please (e-)mail me your language definitions.
%
% There will definitely a \texttt{savemem} option.
% If used, it reduces the required \TeX\ memory (and sometimes even runtime).
%
% The \aspectname{procnames} and \aspectname{index} aspects are still unsatisfactory.
% For example, `procnames' marks (and indexes) only the function definitions so far, but it would be possible to mark also the following function calls:
% Write another `keyword class' which is empty at the very beginning (and can be reset with a key); each function definition appends a `keyword' which will appear in `procnamestyle'.
%
% \lsthelper{Torben~Hoffmann}{1999/02/18}{pre-compile listings} stated the idea of pre-compiled listings.
% But if the package reads a listing to compare it with the pre-compiled version, all `escape features' get lost (since the package can switch to its active characters, but not its active characters back to \TeX's catcodes).
% Thus, pre-compiled listings are possibly never implemented.
%
% From \lsthelper{Rolf~Niepraschk}{1999/07/12}{two active language definitions} comes one more interesting idea, namely that two (or more) language definitions could be active at the same time.
% This would be useful if a makefile also contains parts of a shell-script language, for example.
%
%
%^^A \newlabel{dWhyLstAspects}{{6.6}{52}}
% \StopEventually{}
%
%
% \part{Developer's guide}
%
% First I must apologize for this developer's guide since some parts are not explained as good as possible.
% But note also that you are in a pretty good shape:
% This developer's guide exists!
%
%
% \section{Basic concepts}
%
% The functionality of the \packagename{listings} package appears to be divided into two parts:
% On the one hand commands which actually typeset listings and on the other via |\lstset| adjustable parameters.
% Both could completely be implemented in terms of \lst-aspects, which are (usually independent) collections of keys, commands, and internal hooks and definitions.
% In fact the package defines a couple of aspects, in particular the `kernel' $=$ `main engine'.
% The other aspects drive this engine, and language and style definitions tell the aspects how to drive --- the relations between car, driver and assistant driver are exactly reproduced.
%
%
% \subsection{How to define \lst-aspects}\label{dHowToDefineLstAspects}
%
% An aspect definition starts with |\lst@BeginAspect| plus arguments and finishes at the next |\lst@EndAspect|.
% In particular aspect definitions can't be nested.
% \begin{macrosyntax}
% \item[0.20] |\lst@BeginAspect|[\oarg{list of required aspects}]\marg{aspect name}
% \item[0.20] |\lst@EndAspect|
% \end{macrosyntax}
% The optional list is a comma separated list of required aspect names.
% The complete aspect is not defined in each of the following cases:
% \begin{enumerate}
% \item The aspect is already defined or \meta{aspect name} is empty.
% \item A required aspect is neither defined nor loadable via |\lstloadaspects|.
% \item The list |\lst@loadaspects| is defined and doesn't contain \meta{aspect name}.
% \end{enumerate}
% Consequently you can't define a part of an aspect and later on another part.
% However, it is possible to define aspect $A_1$ and later aspect $A_2$ which requires $A_1$.
%
% You can put any \TeX\ material in between the two commands, but note that definitions must be |\global| if you need them later --- \LaTeX's |\newcommand| makes local definitions and can't be preceded by |\global|.
% So use the following commands, |\gdef|, and commands described in the later sections.
% \begin{macrosyntax}
% \item[0.20] |\lst@UserCommand|\meta{macro}\meta{parameter text}\marg{replacement text}
%
%       The macro is equivalent to |\gdef|.
%       The only purpose is to distinguish user commands and internal (global) definitions.
%
% \item[0.19] |\lst@Key|\marg{key name}\marg{init value}[\oarg{default value}]\marg{definition}
% \item[0.19] |\lst@Key|\marg{key name}|\relax|[\oarg{default value}]\marg{definition}
%
%       defines a key using the \packagename{keyval} package from David Carlisle.
%       \meta{definition} is the replacement text of a macro with one parameter.
%       The argument is either the value from `key=value' or \meta{default value} if no `=value' is given.
%       The helper macros |\lstKV@...| below might simplify \meta{definition}.
%
%       The key is not initialized if the second argument is |\relax|.
%       Otherwise \meta{init value} is the very first (init) value to the key.
%       Note that we locally switch to |\globalsdefs=1| to ensure that initialization is not effected by grouping.
%
% \item[0.19] |\lst@AddToHook|\marg{name of hook}\marg{\TeX\ material}
%
%       adds \TeX\ material at pre-defined points.
%       Section \ref{dHooks} lists all hooks and where they are defined respectively executed.
%       |\lst@AddToHook{A}{\csa}| before |\lst@AddToHook{A}{\csb}| \emph{does not} guarantee that |\csa| is executed before |\csb|.
%
% \item[0.20] |\lst@AddToHookExe|\marg{name of hook}\marg{\TeX\ material}
%
%       also executes \meta{\TeX\ material} for initialization.
%       You might use local variables --- local in the sense of \TeX\ and/or usual programming languages --- but when the code is executed for initialization all assignments are global:
%       We set |\globaldefs| locally to one.
%
% \item[0.20] |\lst@UseHook|\marg{name of hook}
%
%       executes the hook.
% \end{macrosyntax}
% And now some examples.
% If you want control messages, you might write
% \begin{verbatim}
%    \lst@AddToHook{Init}{\message{\MessageBreak Processing listing ...}}
%    \lst@AddToHook{DeInit}{\message{complete.\MessageBreak}}\end{verbatim}
% If you want the user to control the messages at |Init|, you could define an aspect like this (|\lst@AddTo| is described in section \ref{dGeneralPurposeMacros}):
% \begin{verbatim}
%    \lst@BeginAspect{message}
%    \lst@Key{message}\relax{\gdef\lst@message{#1}}
%    \lst@Key{moremessage}\relax{\lst@AddTo\lst@message{\MessageBreak#1}}
%    \lst@AddToHook{Init}{\typeout{\MessageBreak\lst@message}}
%    \lstset{message=Annoying message every listing.}
%    \lst@EndAspect\end{verbatim}
% There are certainly aspects which are more useful.
% To serve this goal we define some basic macros to evaluate the argument |#1| to the definition part of a key, i.e.\ they can be used in \meta{definition} of the |\lst@Key| command.
% The additional prefix |KV| refers to the \packagename{keyval} package.
% \begin{macrosyntax}
% \item[0.20] |\lstKV@TwoArg|\marg{value}\marg{subdefinition}
% \item[0.20] |\lstKV@ThreeArg|\marg{value}\marg{subdefinition}
% \item[0.20] |\lstKV@FourArg|\marg{value}\marg{subdefinition}
%
%       \meta{subdefinition} is the replacement text of a macro with two, three or four parameters.
%       We call this macro with the arguments given by \meta{value}.
%       Empty arguments are added if necessary.
%
% \item[0.19] |\lstKV@OptArg|\oarg{default arg.}\marg{value}\marg{subdefinition}
%
%       |[|\meta{default arg.}|]| is \emph{not} optional.
%       \meta{subdefinition} is the replacement text of a macro with parameter text |[##1]##2|.
%       Note that the macro parameter character |#| is doubled since used within another macro.
%       \meta{subdefinition} accesses these arguments via |##1| and |##2|.
%
%       \meta{value} is usually the argument |#1| passed by the \packagename{keyval} package.
%       If \meta{value} has no optional argument, \meta{default arg.} is inserted to provide the arguments to \meta{subdefinition}.
%
% \item[0.20] |\lstKV@CSTwoArg|\marg{value}\marg{subdefinition}
%
%       \meta{value} is a comma separated list (|CS|) of one or two arguments, which are given to \meta{subdefinition} $=$ replacement text of a macro with two parameters.
%       An empty second argument is added if necessary.
%
% \item[0.19] |\lstKV@SetIf|\marg{value}\meta{if macro}
%
%       \meta{if macro} becomes |\iftrue| if the first character of \meta{value} equals |t| or |T|.
%       Otherwise it becomes |\iffalse|.
%       Usually you will use |#1| as \meta{value}.
% \end{macrosyntax}
% Some examples.
% The key \keyname{sensitive} belongs to the \aspectname{keywords} aspect.
% Therefore it is defined in between |\lst@BeginAspect{keywords}| and |\lst@EndAspect|, which is not shown here.
% \begin{verbatim}
%    \lst@Key{sensitive}\relax[t]{\lstKV@SetIf{#1}\lst@ifsensitive}
%    \lst@AddToHookExe{SetLanguage}{\let\lst@ifsensitive\iftrue}\end{verbatim}
% The last line is equivalent to
% \begin{verbatim}
%    \lst@AddToHook{SetLanguage}{\let\lst@ifsensitive\iftrue}
%    \global\let\lst@ifsensitive\iftrue\end{verbatim}
% We initialize the variable globally since the user might request an aspect in a group.
% Afterwards the variable is used locally --- there is no |\global| in \meta{\TeX\ material}.
% Note that we could also define and init the key as follows:
% \begin{verbatim}
%    \lst@Key{sensitive}t[t]{\lstKV@SetIf{#1}\lst@ifsensitive}
%    \lst@AddToHook{SetLanguage}{\let\lst@ifsensitive\iftrue}\end{verbatim}
%
% |caption| is a kernel key.
% We use \meta{value} as \meta{default arg.}:
% The `lol'-entry and the printed caption are identical if no optional argument is given.
% \begin{verbatim}
%    \lst@Key{caption}\relax{\lstKV@OptArg[{#1}]{#1}%
%        % `[##1]##2' replacement text
%        {\def\lst@caption{##2}\def\lst@@caption{##1}}}
%    \lst@AddToHook{PreSet}{\let\lst@caption\@empty\let\lst@@caption\@empty}\end{verbatim}
% Captions are reset via |PreSet| before a key=value list might change this.
%
%
% \subsection{Hooks}\label{dHooks}
%
% Several problems arise if you want to define an aspect.
% You should and/or must
%   find additional functionality (of general interest),
%   implement that functionality,
%   create the user interface,
%   and interface with the \packagename{listings} package, i.e.\ find the right hooks and insert appropriate \TeX\ material.
% The first two problems are out of the scope of this developer's guide.
% The commands |\lstKV@...| in section \ref{dHowToDefineLstAspects} might help you with the third item.
% Here now we describe all hooks of the \packagename{listings} package.
% All hooks are executed inside an overall group.
% This group starts somewhere near the beginning and ends somewhere at the end of each listing.
% Don't make any other assumptions on grouping.
% So define variables globally if it's necessary --- and be alert of side effects if you don't use your own groups ; -- ).
% \begin{macrosyntax}
% \item |AfterBeginComment|
%
%       is executed after the package has entered comment mode.
%       The starting delimiter is already typeset when the hook is called.
%
% \item |BoxUnsave|
%
%       contains all material to deactivate all commands and registers which are possibly unsave inside |\hbox|.
%       It is used whenever the package makes a box around a listing and for \packagename{fancyvrb} support.
%
% \item |DeInit|
%
%       called at the very end of typesetting a listing but before closing the box from |BoxUnsave| or ending a float.
%
% \item |DetectKeywords|
%
%       This |Output| subhook is executed if and only if mode changes are allowed, i.e. if and only if the package doesn't process a comment, string, and so on  --- see section \ref{dInternalModes}.
%
% \item |EmptyStyle|
%
%       executed to select the `empty' style --- except the user has redefined the style.
%
% \item |EndGroup|
%
%       executed whenever the package closes a group, e.g.\ at end of comment or string.
%
% \item |EOL|
%
%       called at each end of line, right before |InitVarsEOL|.
%
% \item |EveryLine|
%
%       executed at the beginning of each line.
%       This hook must not change the horizontal or vertical position.
%
% \item |ExitVars|
%
%       executed right before |DeInit|.
%
% \item |FontAdjust|
%
%       adjusts font specific internal values (currently |\lst@width| only).
%
% \item |Init|
%
%       executed once to initialize things before the character table is changed.
%       It is called after |PreInit| and before |InitVars|.
%
% \item |InitVars|
%
%       called to init variables each listing.
%
% \item |InitVarsBOL|
%
%       initializes variables at the beginning of each line.
%
% \item |InitVarsEOL|
%
%       updates variables at the end of each line.
%
% \item |InlineUnsave|
%
%       deactivates features for inline listings.
%
% \item |ModeTrue|
%
%       executed by the package when mode changes become illegal.
%
% \item |OmegaOutputBox|
%
%       |OutputBox| subhook makes the package work together with Lambda.
%
% \item |Output|
%
%       Called before an identifier is printed.
%       If you want a special printing style, modify |\lst@thestyle|.
%
% \item |OutputBox|
%
%       used inside each output box.
%
% \item |OutputOther|
%
%       Called before other character strings are printed.
%
% \item |PostOutput|
%
%       Called after printing an identifier or any other output unit.
%
% \item |PreInit|
%
%       called right before |Init|.
%
% \item |PreSet|
%
%       Each typesetting command/environment calls this hook to init internals before any user supplied key is set.
%
% \item |SelectCharTable|
%
%       is executed after the package has selected the standard character table.
%       Aspects adjust the character table here and define stringizer, comment delimiters, and so on.
%
% \item |SetStyle|
%
%       Called before internal assignments for setting a style are made.
%       This hook determines which parameters are reset every style selection.
%
% \item |SetLanguage|
%
%       Called before internal assignments for setting a language are made.
%       This hook determines which parameters are reset every language selection.
% \end{macrosyntax}
%
%
% \subsection{Character tables}
%
% Now you know how a car looks like, and you can get a driving license if you take some practice.
% But you will have difficulties if you want to make heavy alterations to the car.
% So let's take a closer look and come to the most difficult part: the engine.
% We'll have a look at the big picture and fill in the details step by step.
% For our purpose it's good to override \TeX's character table.
% First we define a standard character table, which is made out of
% \begin{itemize}
% \item letters $=$ characters identifiers are of,
% \item digits $=$ characters for identifiers or numerical constants,
% \item spaces $=$ characters treated as blank spaces,
% \item tabulators $=$ characters treated as tabulators,
% \item form feeds $=$ characters treated as form feed characters, and
% \item others $=$ all other characters.
% \end{itemize}
% This character table is altered depending on the current programming language.
% We may define stringizers, comment indicators and other special characters.
% Table \ref{dStdCharTable} shows the standard character table.
% \begin{table}[htb]
% \caption{Standard character table}\label{dStdCharTable}
% \begin{tabular}{ll}
% \noalign{\smallskip\floatrule}
% class & characters\\
% \noalign{\smallskip}
% letter & \texttt{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}\\
%        & \texttt{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}\\
%        & \texttt{@ \textdollar\ } |_|\\
% digit  & \texttt{0 1 2 3 4 5 6 7 8 9}\\
% other  & \texttt{!\ " \#\ \%\ \&\ ' ( ) * + , - .\ / :\ ; < = > ?}\\
%        & {\catcode`\|=12\texttt{[ \char92\ ] \textasciicircum\ \char123\ | \char125\ \textasciitilde}}\\
% space  & chr(32)\\
% tabulator & chr(9)\\
% form feed & chr(12)\\
% \noalign{\floatrule\smallskip}
% \end{tabular}
% Note: Extended characters of codes 128--255 (if defined) are \emph{currently} letters.
% \end{table}
% How these `classes' work together?
% Let's say that the current character string is `|tr|'.
% Then letter `|y|' simply appends the letter and we get `|try|'.
% The next nonletter (and nondigit) causes the output of the characters.
% Then we collect all coming nonletters until reaching a letter again.
% This causes the output of the nonletters, and so on.
% Internally each character becomes active in the sense of \TeX\ and is defined to do the right thing, e.g.\ we say
% \begin{verbatim}
%    \def A{\lst@ProcessLetter A}\end{verbatim}
% where the first `|A|' is active and the second has catcode 11 (= letter).
% The macro |\lst@ProcessLetter| gets one token and treats it as a letter.
% The following macros exist, where the last three get no explicit argument.
% \begin{macrosyntax}
% \item[0.18] |\lst@ProcessLetter| \meta{spec.\ token}
% \item[0.18] |\lst@ProcessDigit| \meta{spec.\ token}
% \item[0.18] |\lst@ProcessOther| \meta{spec.\ token}
% \item[0.18] |\lst@ProcessTabulator|
% \item[0.18] |\lst@ProcessSpace|
% \item[0.20] |\lst@ProcessFormFeed|
% \end{macrosyntax}
% Moreover the \aspectname{strings} aspect defines the following five.
% \begin{macrosyntax}
% \item[0.18] |\lst@ProcessStringizer@b| \meta{spec.\ token}
% \item[0.18] |\lst@ProcessStringizer@d| \meta{spec.\ token}
% \item[0.18] |\lst@ProcessStringizer@m| \meta{spec.\ token}
% \item[0.19] |\lst@ProcessStringizer@bd| \meta{spec.\ token}
% \item[0.19] |\lst@ProcessStringizer@db| \meta{spec.\ token}
% \end{macrosyntax}
% \meta{spec.\ token} is supposed to do two things.
% Usually it expands to a printable version of the character.
% But if |\lst@UM| is equivalent to |\@empty|, \meta{spec.\ token} must expand to a character token.
% For example, the sharp usually expands to |\#|, which is defined via |\chardef| and is not a character token.
% But if |\lst@UM| is equivalent to |\@empty|, the sharp expands to the character `|#|' (catcode 12).
% Note: \emph{Changes to} |\lst@UM| \emph{must be locally.}
% However, there should be no need to do such basic things yourself.
% The \packagename{listings} package provides advanced macros which use that feature, e.g.\ |\lst@InstallKeywords| in section \ref{dKeywordsAndWorkingIdentifiers}.
%
% You can use the following commands to modify the character table.
% \begin{macrosyntax}
% \item[0.20] |\lst@UseBasicClasses|\marg{letters}\marg{digits}\marg{others}
%
%       modifies the standard character table.
%       The specified characters become letters, digits and others, respectively.
%       The `characters' |\|, |{|, |}|, |%| and |#| must be entered with preceding backslashes.
%
%       Note: The keys |alsoletter|, |alsodigit| and |alsoother| exist and should be used instead.
%       Internally the keys use this command here.
%
% \item[0.18] |\lst@Def|\marg{character code}\meta{parameter text}\marg{definition}
% \item[0.18] |\lst@Let|\marg{character code}\meta{token}
%
%       defines respectively assigns \meta{token} to the specified character, but doesn't make it active.
%       Note that a parameter usually reads the next character(s) of the source code.
%       It is also possible that \TeX\ reads some code of the \packagename{listings} package, e.g.\ |\relax| or |\@empty|.
%       Therefore don't use \TeX's ord-operator |`| on such a parameter, e.g.\ don't write |\ifnum`#1=65| to test against `|A|'.
%       Moreover it is not save to read more than one character ahead.
%
%       The relatively slow commands |\lst@Def| and |\lst@Let| are for modifying the character table.
%       The real definition of the standard character table differs from the following example, but it could begin with
% \begin{verbatim}
%    \lst@Let{9}\lst@ProcessTabulator
%    \lst@Let{32}\lst@ProcessSpace
%    \lst@Def{48}{\lst@ProcessDigit 0}
%    \lst@Def{65}{\lst@ProcessLetter A}\end{verbatim}
%
% \item[0.20] |\lst@SaveDef|\marg{character code}\meta{macro}
%
%       Saves the current definition of the specified character in \meta{macro}.
%       You should always save a character definition before you redefine it!
%       And use the saved version instead of writing directly |\lst@Process|\ldots\space --- the character could already be redefined and thus not equivalent to its standard definition.
%
% \item[0.20] |\lst@DefSaveDef|\marg{character code}\meta{macro}\meta{parameter text}\marg{definition}
% \item[0.20] |\lst@LetSaveDef|\marg{character code}\meta{macro}\meta{token}
%
%       combines |\lst@SaveDef| and |\lst@Def| respectively |\lst@Let|.
%
% \item[0.20] |\lst@activecharstrue|
% \item[0.20] |\lst@activecharsfalse|
%
%       controls whether selecting the character table also makes all characters active (standard/extended).
%       This is usually true and therefore default.
%       Only the \packagename{fancyvrb} interface sets it locally false.
% \end{macrosyntax}
% That's all about how to alter the character table.
% Finally you must know where the character table can be changed.
% Hook material at |SelectCharTable| makes permanent changes, i.e.\ it (usually) effects all languages.
% The following two \emph{keys} can be used in any language definition and effects the particular language only.
% These keys replace the old |\lstSCT@|\meta{language}(|@|\meta{dialect}) mechanism and are possibly changed in future.
% \begin{macrosyntax}
% \item[0.20,key] |SelectCharTable=|\meta{\TeX\ code}
% \item[0.20,key] |MoreSelectCharTable=|\meta{\TeX\ code}
%
%       uses \meta{\TeX\ code} (additionally) to select the character table.
%       The code is executed after the standard character table is selected, but possibly before other aspects make more changes.
%       Since previous meanings are always saved and executed inside the new definition, this should be harmless.
% \end{macrosyntax}
% At the end come two rather useless examples.
% Each point (full stop) will cause a message `|.|' on the terminal and in the |.log| file if language |useless| is active:
% \begin{verbatim}
%    \lstdefinelanguage{useless}
%        {SelectCharTable=\lst@DefSaveDef{46}% save chr(46) ...
%             \lsts@point             % ... in \lsts@point and ...
%             {\message{.}\lsts@point}% ... use new definition
%        }\end{verbatim}
% If you want to count points, you could write
% \begin{verbatim}
%    \newcount\lst@points % \global
%    \lst@AddToHook{Init}{\global\lst@points\z@}
%    \lst@AddToHook{DeInit}{\message{Number of points: \the\lst@points}}
%    \lstdefinelanguage[2]{useless}
%        {SelectCharTable=\lst@DefSaveDef{46}\lsts@point
%             {\global\advance\lst@points\@ne \lsts@point}
%        }\end{verbatim}
% |% \global| indicates that the allocated counter is used globally.
% We zero the counter at the beginning of each listing, display a message about the current value at the end of a listing, and each processed point advances the counter by one.
%
%
% \subsection{Internal modes}\label{dInternalModes}
%
% You probably know \TeX's conditional commands |\ifhmode|, |\ifvmode|, |\ifmmode| and |\ifinner|.
% They tell you whether \TeX\ is in (restricted) horizontal and/or (internal) vertical and/or in (nondisplay) mathematical mode.
% For example, true |\ifhmode| and true |\ifinner| indicate restricted horizontal mode, which means that you are in a |\hbox|.
% The typical user doesn't care about such modes, \TeX\ manages all this.
% But since you're reading the developer's guide, we discuss the analogon for the \packagename{listings} package now.
% We use modes to distinguish comments from strings, comment lines from single comments, and so on.
% Each aspect may define its own mode(s) simply by allocating it/them inside the aspect definition.
% \begin{macrosyntax}
% \item[0.19] |\lst@NewMode|\meta{mode name}
%
%       defines a new mode, which is simply a nonnegative integer assigned to \meta{mode name}.
%       \meta{mode name} should have the prefix |lst@| and suffix |mode|.
%       Table \ref{dDefinedInternalModes} shows all modes currently existing.
% \end{macrosyntax}
% \begin{table}[htbp]
% \caption{Internal modes}\label{dDefinedInternalModes}
% \def\lsttabspace{\hspace*{1em}\hfill}
% \begin{tabular}{lp{0.52\linewidth}}
% \noalign{\smallskip\floatrule}
% aspect\lsttabspace \meta{mode name} & description/indicates that we are processing \ldots\\
% \noalign{\smallskip}
% kernel\lsttabspace |\lst@nomode| &
%       If this mode is active, \TeX's `character table' is present; the other implication is not true.
%       Any other mode \emph{may} imply that catcodes and/or definitions of characters are changed.
% \\
%       \lsttabspace |\lst@Pmode| &
%       is a general processing mode.
%       If active we are processing a listing, but haven't entered a more special mode.
% \\
%       \lsttabspace |\lst@GPmode| &
%       general purpose mode for language definitions.
% \\
% \aspectname{strings}\lsttabspace |\lst@stringmode| &
%       \ldots\ a string.
% \\
% \aspectname{comments}\lsttabspace |\lst@CLmode| &
%       \ldots\ a (fixed) comment line.
% \\
%       \lsttabspace |\lst@SCmode| &
%       \ldots\ a single comment.
% \\
%       \lsttabspace |\lst@DCAmode| &
%       \ldots\ the first type of a double comment.
% \\
%       \lsttabspace |\lst@DCBmode| &
%       \ldots\ the second type of a double comment.
% \\
%       \lsttabspace |\lst@NCmode| &
%       \ldots\ a nested comment.
% \\
% \aspectname{pod}\lsttabspace |\lst@PODmode| &
%       \ldots\ a POD --- Perl specific.
% \\
% \aspectname{escape}\lsttabspace |\lst@TeXCLmode| &
%       \ldots\ a comment line, but \TeX's character table is present --- except the EOL character, which is needed to terminate this mode.
% \\
%       \lsttabspace |\lst@TeXmode| &
%       indicates that \TeX's character table is present --- except one user specified character, which is needed to terminate this mode.
% \\
% \aspectname{directives}\lsttabspace |\lst@CDmode| &
%       indicates that the current line began with a compiler directive.
% \\
% \aspectname{keywordcomments}\lsttabspace |\lst@KCmode| &
%       \ldots\ a keyword comment.
% \\
%       \lsttabspace |\lst@KCSmode| &
%       \ldots\ a keyword comment which can be terminated by a semicolon only.
% \\
% \noalign{\floatrule\smallskip}
% \end{tabular}
% \end{table}
% Two variables show the internal state of processing.
% You are allowed to read them, but \emph{direct write access is prohibited}.
% Note: |\lst@ifmode| is \emph{not} obsolete since there is no relation between the boolean and the current mode.
% It will happen that we enter a mode without setting |\lst@ifmode| true, and we'll set it true without assigning any mode!
% Moreover it plays another important role: Keywords are detected if and only if this boolean is false.
% \begin{macrosyntax}
% \item[0.18,counter] |\lst@mode|
%
%       keeps the current mode number.
%       Use |\ifnum\lst@mode=|\meta{mode name} to test against a mode.
%       Don't modify the counter directly.
%
% \item[0.18,boolean] |\lst@ifmode|
%
%		No mode change is allowed if this boolean is true --- except leaving the current mode.
%       Use |\lst@modetrue| to modify this variable, but do it only in \meta{start tokens}:
%
% \item[0.19] |\lst@EnterMode|\meta{mode name}\marg{start tokens}
%
%		opens a new group level, enters the mode \meta{mode name} and executes \meta{start tokens}.
%       Use |\lst@modetrue| somewhere in \meta{start tokens} if the mode prohibits mode changes.
%       You must test yourself whether you're allowed to enter the mode.
%
% \item[0.19] |\lst@LeaveMode|
%
%		returns to the previous mode by closing a group level (if and only if the current mode isn't |\lst@nomode| already).
%       You must test yourself whether you're allowed to leave a mode.
%
% \item[0.19] |\lst@LeaveAllModes|
%
%       returns to |\lst@nomode|.
%       This is some kind of emergency macro, so don't use it!
%
% \item[0.19] |\lst@InterruptModes|
% \item[0.19] |\lst@ReenterModes|
%
%       The first command returns to |\lst@nomode|, but saves the accumulated mode sequence.
%       Afterwards the second macro enters this mode sequence again.
%       In between these commands you may enter any mode you want, but note that the commands can't be nested:
%       If you interrupt modes, enter some modes and say `interrupt modes' again, then two re-enters will not take you back in front of the first `interrupt modes'.
%
%       Remember that |\lst@nomode| implies that \TeX's character table is active.
% \end{macrosyntax}
% We now look at the example
% \begin{verbatim}
%    \begin{lstlisting}{}
%    // comment
%    "string"
%    \end{lstlisting}\end{verbatim}
% and assume |language=C++| and |texcl=true|.
% |\ifnum\lst@mode=\lst@nomode| is true when the package doesn't process a listing or initializes it.
% A lonely right arrow in the following table means |\lst@EnterMode|, wheras a non-lonely right arrow means `leads to'.
% \begin{center}
% \small
% \begin{tabular}{@{}lll@{}}
% mode before & code/output & and after\\
% |\lst@nomode|
%       & |\begin{lstlisting}{}| & $\to$ |\lst@Pmode|\\ \\
% $\to$ |\lst@CLmode|
%       & |//| & |\lst@LeaveMode| $\to$ |\lst@Pmode|\\
%       &      & |\lst@InterruptModes|\\
%       &      & $\to$ |\lst@TeXCLmode|\\
%       & |   comment| & |\lst@ReenterModes| $\to$ |\lst@Pmode|\\ \\
% $\to$ |\lst@stringmode|
%       & |"string"| & |\lst@LeaveMode| $\to$ |\lst@Pmode|\\ \\
%       & |\end{lstlisting}| & |\lst@LeaveAllModes| $\to$ |\lst@nomode|\\
% \end{tabular}
% \end{center}
% I should explain more detailed what is going on.
% Look at the second line.
% The package reads two slashes and detects a comment line; it therefore enters |\lst@CLmode| and outputs the slashes.
% Now the package must leave the mode (to reenter the correct mode later), interrupt the current mode sequence and go to |\lst@TeXCLmode|.
% At the end of line we reenter the mode sequence leading to |\lst@Pmode|, which was active before the slashes had been read.
% The package goes on reading the double quote, enters |\lst@stringmode|, prints the stringizer, and so on.
%
%
% \subsection{On the output}
%
% The \packagename{listings} package uses some variables to keep the output data.
% These variables belong to the kernel, but |\lst@lastother|, |\lst@token| and |\lst@length| are `character class' variables which are used by the `output'.
% All the other are true `output' variables.
% Any write access is not recommended.
% \begin{macrosyntax}
% \item[0.18,token] |\lst@token|
%
%       contains the current character string.
%       Each `character' usually expands to its printable version, but it must expand to a character token if |\lst@UM| is equivalent to |\@empty|.
%
% \item[0.12,counter] |\lst@length|
%
%       is the length of the current character string.
%
% \item[0.18] |\lst@PrintToken|
%
%       prints (outputs, typesets) the current character string and resets it.
%       This macro keeps track of all variables described here.
%
% \item[0.12,dimension] |\lst@width|
%
%       is the current width of a single character box.
%
% \item[0.20,global dimension] |\lst@linewidth|
%
%       is the width of so far printed line.
%
% \item[0.18,global counter] |\lst@column|
% \item[0.12,global counter] |\lst@pos| (nonpositive)
%
%       |\lst@column|$-$|\lst@pos| is the length of the so far printed line.
%       We use two counters since this simplifies tabulator handling:
%       |\lst@pos| is a nonpositive representative of `length of so far printed line' modulo \keyname{tabsize}.
%       It's usually not the biggest nonpositive representative.
%
% \item[0.20] |\lst@CalcLineLength|
%
%       |\@tempcnta| gets |\lst@column| $-$ |\lst@pos| $+$ |\lst@length|.
%       This is the current column number minus one.
%
% \item[0.18,global dimension] |\lst@lostspace|
%
%       equals `lost' space $=$ desired current line width minus real line width.
%       Whenever this dimension is positive the flexible column format can use this space to fix the column alignment.
%
% \item[0.18] |\lst@UseLostSpace|
%
%       inserts |\lst@lostspace| if and only if it's positive.
%       |\lst@lostspace| and |\lst@linewidth| are updated if necessary.
%
% \item[0.19] |\lst@InsertLostSpace|
% \item[0.19] |\lst@InsertHalfLostSpace|
%
%       always insert (half) |\lst@lostspace| and update registers.
%
% \item[0.17,macro] |\lst@lastother|
%
%       equals \meta{spec.\ token} version of the last processed nonidentifier-character.
%       Since programming languages redefine the standard character table, we use the original \meta{spec.\ token}.
%       For example, if the stringizer double quote was processed last, |\lst@lastother| is not equivalent to the macro which enters and leaves string mode.
%       It's equivalent to |\lstum@"|, where |"| belongs to the control sequence!
%       Remember that \meta{spec.\ token} expands either to a printable or to a token character.
%
%       |\lst@lastother| is equivalent to |\@empty| if such a character is not available, e.g.\ at the beginning of a line.
%       Sometimes an indentifier has already been printed after processing the last `other' character, i.e.\ the character is far, far away.
%       In this case |\lst@lastother| equals |\relax|.
%
% \item[0.20] |\lst@SaveOutputDef|\marg{character code}\meta{macro}
%
%       Stores the \meta{spec.\ token} corresponding to \meta{character code} in \meta{macro}.
%       This is the only save way to get a correct meaning to test against |\lst@lastother|.
%       Consider |\lst@SaveOutputDef{"5C}\lstum@backslash|.
%       The `b'ackslashed stringizer could then say |\ifx\lst@lastother\lstum@backslash|\ldots\ to test whether the last character has been a backslash.
%
%       You'll get a ``runaway argument'' error if \meta{character code} is not between 33 and 126 (inclusive).
%
% \item[0.17] |\lst@outputspace|
%
%       Use this pre-defined \meta{spec.\ token} (obviously for character code 32) to test against |\lst@lastother|.
%
% \item[0.20] |\lstum@backslash|
%
%       Use this pre-defined \meta{spec.\ token} (for character code 92) to test against |\lst@lastother|.
% \end{macrosyntax}
%
%
% \subsection{Why \lst-aspects?}\label{dWhyLstAspects}
%
% Eventually I should answer this question.
% We defined a \lst-aspect as a collection of user keys, user commands, and internal hooks and definitions.
% Keys, commands and hooks are all known, and making collections is just like putting together what belong together.
% Nevertheless, \lst-aspects are a \emph{tool} to clear up the dependencies of different package parts and to debug the package.
% For example, we could load the kernel and no other aspects by
% \begin{verbatim}
%    \makeatletter
%    \def\lst@loadaspects{}
%    \makeatother
%    \usepackage{listings}\end{verbatim}
% For aspect-testing we then use options to load particular aspects.
% Here now is a list of all aspects and related keys and commands.
% \begin{description}
% \hyphenpenalty=10000\relax \rightskip=0pt plus \linewidth\relax
% \item[\aspectname{strings}]\leavevmode
%
%       \keyname{stringizer}, \keyname{stringstyle}, \keyname{stringspaces}, \keyname{stringtest}
%
% \item[\aspectname{comments}]\leavevmode
%
%       \keyname{commentstyle}, \keyname{commentline}, \keyname{fixedcommentline}, \keyname{singlecomment}, \keyname{doublecomment}, \keyname{nestedcomment}
%
% \item[\aspectname{pod}]\leavevmode
%
%       \keyname{printpod}, \keyname{podcomment}
%
% \item[\aspectname{escape}]\leavevmode
%
%       \keyname{texcl}, \keyname{escapebegin}, \keyname{escapeend}, \keyname{escapechar}, \keyname{escapeinside}, \keyname{mathescape}
%
% \item[\aspectname{writefile}] requires 1 |\toks|, 1 |\write|
%
%       |\lst@BeginWriteFile|, |\lst@BeginAlsoWriteFile|, |\lst@EndWriteFile|
%
% \item[\aspectname{style}]\leavevmode
%
%       \cs{lstdefinestyle}, \keyname{style}, empty style
%
% \item[\aspectname{language}]\leavevmode
%
%       |\lstalias|, \keyname{defaultdialect}, |\lstdriverfiles|$^{\mathrm{data}}$, |\lstloadlanguages|$^{\mathrm{preamble}}$, |\lstdefinelanguage|, |\lst@definelanguage|, empty language, \keyname{language}
%
% \item[\aspectname{keywords}]\leavevmode
%
%       \keyname{keywords}, \keyname{morekeywords}, \keyname{deletekeywords}, \keyname{keywordstyle}
%       \keyname{sensitive}, |\lststorekeywords|,
%       \keyname{ndkeywords}, \keyname{morendkeywords}, \keyname{deletendkeywords}, \keyname{ndkeywordstyle},
%       \keyname{otherkeywords}
%
% \item[\aspectname{rdkeywords}] requires \aspectname{keywords}
%
%       \keyname{rdkeywords}, \keyname{morerdkeywords}, \keyname{deleterdkeywords}, \keyname{rdkeywordstyle}
%
% \item[\aspectname{html}] requires \aspectname{keywords} 
%
%       \keyname{keywordsinside}, \keyname{usekeywordsinside}
%
% \item[\aspectname{tex}] requires \aspectname{keywords}
%
%       \keyname{texcs}, \keyname{moretexcs}, \keyname{texcsstyle}
%
% \item[\aspectname{directives}] requires \aspectname{keywords}
%
%       \keyname{directives}, \keyname{directivestyle}
%
% \item[\aspectname{index}] requires \aspectname{keywords}
%
%       \keyname{index}, \keyname{indexmacro},
%       \keyname{ndindex}, \keyname{ndindexmacro}, |\lstindexmacro|
%
% \item[\aspectname{procnames}] requires \aspectname{keywords}
%
%       \keyname{procnamekeys}, \keyname{procnamestyle}, \keyname{indexprocnames}
%
% \item[\aspectname{keywordcomments}] requires \aspectname{keywords}, \aspectname{comments}
%
%       \keyname{keywordcomment}, \keyname{keywordcommentsemicolon}
%
% \item[\aspectname{labels}] requires 2 |\count|
%
%       \keyname{labelstyle}, \keyname{labelsep}, \keyname{labelstep}, \keyname{firstlabel}, \keyname{advancelabel}, |\thelstlabel|
%
% \item[\aspectname{lineshape}] requires 2 |\dimen|
%
%       \keyname{wholeline}, \keyname{indent}, \keyname{spread}, \keyname{lineskip}
%
% \item[\aspectname{breaklines}] requires \aspectname{lineshape}
%
%       \keyname{breaklines}, \keyname{breakindent}, \keyname{breakautoindent}, \keyname{prebreak}, \keyname{postbreak}
%
% \item[\aspectname{frames}] requires \aspectname{lineshape}
%
%       \keyname{frame}, \keyname{frameround}, \keyname{framerulewidth}, \keyname{framerulesep}, \keyname{frametextsep}, \keyname{framespread}, \keyname{frameshape}
%
% \item[\aspectname{make}] requires \aspectname{keywords}
%
%       \keyname{makemacrouse}
%
% \item[\aspectname{doc}] requires \aspectname{writefile} and 1 |\box|
%
%       |lstsample| environment
%
% \item[\aspectname{0.17}] defines a couple of commands.
% \item[\aspectname{0.19}] defines some commands and keys.
% \item[\aspectname{fancyvrb}] requires 1 |\box|
% \end{description}
% The kernel allocates 6 |\count|, 4 |\dimen| and 1 |\toks|.
% Moreover it defines the following keys, commands and environments:
% \begin{itemize}\item[]
% \hyphenpenalty=10000\relax \rightskip=0pt plus \linewidth\relax
% |\lstloadaspects|, 
% \keyname{abovecaptionskip}, \keyname{alsodigit}, \keyname{alsoletter}, \keyname{alsoother}, 
% \keyname{basewidth}, \keyname{basicstyle}, \keyname{belowcaptionskip}, \keyname{boxpos},
% \keyname{caption}, \keyname{captionpos}, \keyname{continue}, 
% \keyname{extendedchars},
% \keyname{fancyvrb}, \keyname{first}, \keyname{flexiblecolumns}, \keyname{float}, \keyname{fontadjust}, \keyname{formfeed}, 
% \keyname{gobble},
% \keyname{identifierstyle},
% \keyname{last}, \keyname{literate}, |\lstinline|, |\lstinputlisting|, |lstlisting| environment, |\lstlistingname|, |\lstlistlistingname|, |\lstlistoflistings|, |\lstnewenvironment|, |\lstset|,
% \keyname{MoreSelectCharTable},
% \keyname{outputpos},
% \keyname{post}, \keyname{pre}, \keyname{print}
% \keyname{SelectCharTable}, \keyname{showlines},
% \keyname{tab}, \keyname{tabsize}, \keyname{visiblespaces}, \keyname{visibletabs}
% \end{itemize}
%
%
% \section{Getting the kernel run}
%
% If you want new pretty-printing environments, you should be happy with section \ref{uEnvironments}.
% New commands like |\lstinline| or |\lstinputlisting| are more difficult.
% Roughly speaking you must follow these steps, where vertical dots mean ``Do whatever you want.'':
% \begin{enumerate}
% \item Open a group to make all changes local.
% \item $\vdots$
% \item Call |\lsthk@PreSet| in any case and redefine the global macro |\lst@intname| (\lst\space internal name) afterwards if you want.
%       This name is used for the list of listings, for example.
% \item Now you \emph{can} (but need not to) use |\lstset| to set some new values.
% \item $\vdots$
% \item Execute |\lst@Init\relax| to finish initialization.
% \item $\vdots$
% \item Eventually comes the source code, which is processed by the kernel.
%       You must ensure that the characters are either not already read or all active.
%       You must have installed a way to detect the end of the source code, of course.
%       If you've reached the end, you must execute |\lst@DeInit| to shutdown the kernel savely.
% \item $\vdots$
% \item Close the group from the beginning.
% \end{enumerate}
% For example, consider the |\lstinline| command in case of being not inside an argument.
% Then the steps are as follows.
% \begin{enumerate}
% \item |\hbox\bgroup| opens a group and puts listing in a |\hbox|.
% \item |\def\lst@boxpos{b}| |\let\lst@ifflexible\iftrue| `baseline' aligns the listing and chooses flexible columns.
% \item |\lsthk@PreSet|
% \item |\lstset{#1}| where |#1| is the user provided key=value list.
% \item |\lsthk@InlineUnsave| deactivates all features not save inside a code fragment.
% \item |\lst@Init\relax|
% \item |\everypar{}| deactivates the hook |EveryLine|.
%       If |#1| is the next character after |\lstinline| then |\lst@Def{`#1}{\lst@DeInit\egroup}| installs the `end inline' detection.
%       Moreover chr(13) is redefined to end the fragment in the same way but also to issue an error message.
% \item After reading the source code |\lst@DeInit| (coming from |\lst@Def| above) ends the fragment correctly.
% \item Nothing.
% \item |\egroup| (also from |\lst@Def|) closes the |\hbox| group.
% \end{enumerate}
% The real definition is different since we allow source code inside arguments, see section \ref{iInlineListings}.
% Read also section \ref{iTheInputCommand} if you really want to write pretty-printing commands.
%
%
% \section{Useful internal definitions}
%
%
% \subsection{General purpose macros}\label{dGeneralPurposeMacros}
%
% \begin{macrosyntax}
% \item[0.19] |\lst@AddTo|\meta{macro}\marg{\TeX~material}
%
%       adds \meta{\TeX~material} globally to the contents of \meta{macro}.
%
% \item[0.20] |\lst@Extend|\meta{macro}\marg{\TeX~material}
%
%       calls |\lst@AddTo| after the first token of \meta{\TeX~material} is |\expand|ed|after|.
%       The name `extend' might remind you of the inserted |\expandafter|s.
%       For example, |\lst@Extend \a \b| merges the contents of the two macros and stores it globally in |\a|.
%
% \item[0.19] |\lst@lAddTo|\meta{macro}\marg{\TeX~material}
% \item[0.20] |\lst@lExtend|\meta{macro}\marg{\TeX~material}
%
%       are local versions of |\lst@AddTo| and |\lst@Extend|.
%
% \item[0.18] |\lst@DeleteKeysIn|\meta{macro}\meta{macro \textup(keys to remove\textup)}
%
%       Both macros contain a comma separated list of keys (or keywords).
%       All keys appearing in the second macro are removed from the first.
%
% \item[0.19] |\lst@ReplaceIn|\meta{macro}\meta{macro \textup(containing replacement list\textup)}
% \item[0.20] |\lst@ReplaceInArg|\meta{macro}\marg{replacement list}
%
%       The replacement list has the form $a_1b_1$\ldots$a_nb_n$, where each $a_i$ and $b_i$ is a character sequence (enclosed in braces if necessary) and may contain macros, but the first token of $b_i$ must not be equivalent to |\@empty|.
%       Each sequence $a_i$ inside the first macro is replaced by $b_i$.
%       The suffix |Arg| refers to the \emph{braced} second argument instead of a (nonbraced) macro.
%       It's a hint that we get the `real' argument and not a `pointer' to the argument.
%
% \item[0.20] |\lst@IfSubstring|\marg{character sequence}\meta{macro}\marg{then}\marg{else}
%
%       \meta{then} is executed if \meta{character sequence} is a substring of the contents of \meta{macro}.
%       Otherwise \meta{else} is called.
%
% \item[0.12] |\lst@IfOneOf|\meta{character sequence}|\relax|\meta{macro}\marg{then}\marg{else}
%
%       |\relax| terminates the first parameter here since it is faster than enclosing it in braces.
%       \meta{macro} contains a comma separated list of identifiers.
%       If the character sequence is one of these indentifiers \meta{then} is executed, and otherwise \meta{else}.
%
% \item[0.18] |\lst@IfNextChars|\meta{macro}\marg{then}\marg{else}
% \item[0.19] |\lst@IfNextCharsArg|\marg{character sequence}\marg{then}\marg{else}
%
%       Both macros execute either \meta{then} or \meta{else} according to whether the given character sequence respectively the contents of the given macro is found (after the three arguments).
%       Note an important difference between these macros and \LaTeX's |\@ifnextchar|:
%       We remove the characters behind the arguments until it is possible to decide which part must be executed.
%       However, we save these characters in the macro |\lst@eaten|, so they can be inserted using \meta{then} or \meta{else}.
%
% \item[0.19] |\lst@IfNextCharActive|\marg{then}\marg{else}
%
%       executes \meta{then} if next character is active, and \meta{else} otherwise.
%
% \item[0.20] |\lst@DefActive|\meta{macro}\marg{character sequence}
%
%       stores the character sequence in \meta{macro}, but all characters become active.
%       The string \emph{must not} contain a begin group, end group or escape character (|{}\|); it may contain a left brace, right brace or backslash with other meaning ($=$ catcodes).
%       This command would be quite surplus if \meta{character sequence} is not already read by \TeX\ since such catcodes can be changed easily.
%       It is explicitly allowed that the charcaters have been read, e.g.\ in |\def\test{\lst@DefActive\temp{ABC}}|!
%
%       Note that this macro changes |\lccode|s 0--9 without restoring them.
%
% \item[0.20] |\lst@DefOther|\meta{macro}\marg{character sequence}
%
%       stores \meta{character sequence} in \meta{macro}, but all characters have catcode 12.
%       Moreover all spaces are removed and control sequences are converted to their name without preceding backslash.
%       For example, |\{ Chip \}| leads to |{Chip}| where all catcodes are 12 --- internally the primitive |\meaning| is used.
%
% \iffalse
% \item[0.19] |\lst@MakeActive|\marg{character sequence}
%
%       stores the character sequence in |\lst@arg|, but all characters become active.
%       The string \emph{must not} contain a begin group, end group or escape character (|{}\|); it may contain a left brace, right brace or backslash with other meaning ($=$ catcodes).
%       This command would be quite surplus if \meta{character sequence} is not already read by \TeX\ since such catcodes can be changed easily.
%       It is explicitly allowed that the charcaters have been read, e.g.\ in |\def\test{\lst@MakeActive{ABC}}|!
%
%       Note that |\lst@MakeActive| changes |\lccode|s 0--9 without restoring them.
% \fi
% \end{macrosyntax}
%
%
% \subsection{Keywords and working identifiers}\label{dKeywordsAndWorkingIdentifiers}
%
% The \aspectname{keywords} aspect defines one main macro and a couple of also useful `helpers'.
% For example, the first order keywords are completely defined via
% \begin{verbatim}
%    \lst@InstallKeywords k{keywords}\lst@keywordstyle\iftrue
%    \global\let\lst@keywordstyle\@empty % init\end{verbatim}
% Initialization of |\lst@keywordstyle| is the only additional thing to do.
% Another application is the \aspectname{index} aspect.
% We don't discuss the default `index' handler or the key to set the handler, but you must know that |\lst@indexmacro| is the current handler.
% Then a single macro call defines all the rest.
% \begin{verbatim}
%    \lst@InstallKeywords w{index}
%        {\expandafter\lst@indexmacro\expandafter{\the\lst@token}}\iftrue\end{verbatim}
% Here the `style macro' is replaced by a working procedure and we use a `prefix' other than |k|.
%
% \begin{macrosyntax}
% \item[0.20] |\lst@InstallKeywords|\marg{prefix}\marg{key name}\meta{style macro}|\iftrue|$\vert$|false|
%
%       installs either a keyword class if \meta{prefix}$=$|k| or otherwise a `working' class of identifiers.
%       See |\lst@InstallKeywordTest| on details about \meta{prefix} and the last argument |\iftrue|$\vert$|false|.
%
%       We define the key \meta{key name} which gets a list of keywords or identifiers, and furthermore |more|\meta{key name}, |delete|\meta{key name} and \meta{key name}|tyle| for a keyword class.
%       The very last key is not a typo.
%       Eventually this macro calls |\lst@InstallKeywordTest| with appropriate arguments.
%
%       Note: |{|\meta{replacement text}|}| instead of \meta{style macro} is also allowed, where the replacement text takes \emph{no arguments}.
%       This is especially useful for working identifiers.
%       If a working macro uses variables and needs values from previous calls, you must define these variables |\global|ly.
%       It's not sure whether working macros are executed inside a (separate) group or not.
%
% \item[0.20] |\lst@InstallKeywordTest|\marg{prefix}\meta{keyword macro}\meta{global macro}\meta{style macro}\macrosyntaxbreak|\iftrue|$\vert$|false|
%
%       installs (if not already done) a keyword or `working identifier' test.
%       Each different \meta{prefix} inserts another test.
%       Thus, conflicts between different classes of working identifiers can be removed by choosing prefixes other than |w|.
%       This slows down the package, of course.
%
%       The keyword list \meta{keyword macro} is used together with the installed test.
%       We need \meta{global macro} (uniquely connected to \meta{keyword macro}) to keep track of the keywords or identifiers.
%
%       Note: \meta{style macro} must be a macro; any replacement text will fail!
%
%       The last argument determines whether it's installed at the \hookname{DetectKeywords} (if true) or \hookname{Output} hook.
%
% \item[0.20] |\lst@UpdateKeywords|\marg{prefix}\meta{keyword macro}\meta{global macro}\meta{style macro}
%
%       For each keyword class we have a list of user defined keywords and a list of currently defined (global) keywords.
%       This macro updates the global keywords and is best used in the |Init| hook.
%       For example, the first order keywords use
%           {\small|\lst@UpdateKeywords k\lst@keywords\lst@gkeywords\lst@keywordstyle|},
%       which is installed by |\lst@InstallKeywords|.
%
%       Note: \meta{style macro} must be a macro; any replacement text will fail!
%
% \item[0.19] |\lst@MakeKeywords|\meta{keyword macro}\meta{`also' macro}\marg{keyword list}
% \item[0.19] |\lst@MakeMoreKeywords|\meta{keyword macro}\meta{`also' macro}\marg{keyword list}
% \item[0.20] |\lst@DeleteKeywords|\meta{keyword macro}\meta{`also' macro}\marg{keyword list}
%
%       are used in defining the keyword keys.
%       \meta{keyword list} is assigned or added to or removed from \meta{keyword macro}.
%       For example, the replacement text of |keywords| is |\lst@MakeKeywords\lst@keywords\lst@keywords@also{#1}|, where |#1| is the current \meta{keyword list}.
%
%       \meta{`also' macro} holds two arguments both enclosed in group braces.
%       Don't change the macro yourself.
%       The arguments contain characters which aren't letters and digits by default but used in \meta{keyword list} as letters (= beginning of an identifier) and digits (= in the middle).
%       The \packagename{listings} package must be informed of such characters via
%           |\expandafter| |\lst@UseBasicClasses\lst@keywords@also{}|
%       in the |Init| hook --- the `use' macro takes three arguments: letters, digits and others --- but that's deep inside the package.
% \end{macrosyntax}
%
%
% \subsection{Comments}
%
% Earlier versions of this package used completely different macros to define different comment types.
% Now we have three main macros which are used by all ($=$ most common) comments.
% For example, the delimiters for |C++| single comments are defined via
% \begin{verbatim}
%    \lst@CArg{BC} /*\relax\lst@CommentB\lst@SCmode{}{}{}\@empty
%    \lst@CArg{EC} */\relax\lst@CommentE\lst@SCmode{}{}{}\end{verbatim}
% where all arguments from |\lst@SCmode| on go to |\lst@CommentB|.
%
% \begin{macrosyntax}
% \item[0.19] |\lst@CArg|\marg{prefix}\meta{character sequence}|\relax|\meta{macro}
%
%       is a service macro for |\lst@CommentB|$\vert$|E| which are described below.
%       It calls \meta{macro} with some arguments:
%       \meta{character sequence} is made into \meta{1st}\meta{2nd}|{|\meta{rest}|}| (all active) and \meta{prefix} and \meta{1st} are used to build an undefined macro name \meta{save 1st}.
%
% \item[0.19] |\lst@CommentB|\meta{1st}\meta{2nd}\marg{rest}\meta{save 1st}\meta{mode}|{|\meta{execute}|}|\macrosyntaxbreak\marg{delim~exe~modetrue}\marg{delim~exe~modefalse}\meta{style~macro}
%
%       defines the sequence \meta{1st}\meta{2nd}\meta{rest} to begin a \meta{mode} comment.
%       \meta{execute} is executed when the package comes to \meta{1st}, whereas \meta{delim~exe~modetrue} and \meta{delim~exe~modefalse} are executed only if the whole comment delimiter \meta{1st}\meta{2nd}\meta{rest} is found.
%       These two are executed according to whether |\lst@ifmode| is true or false, i.e.\ exactly one is called if the whole delimiter is found.
%
%       By default the package enters comment mode if the delimiter is found and |\lst@ifmode| is false.
%       Internally we make an appropriate definition of |\lst@bnext|, which can be gobbled by placing |\@gobblethree| at the very end of \meta{delim exe modefalse}.
%       There you can also make your own definition (and gobble the default).
%       The next input characters come right after |\lst@bnext|.
%
%       \meta{style macro} is called \emph{additionally} to |\lst@commentstyle| at the beginning of the comment.
%       Currently all \meta{style macro}s are |\@empty|.
%       But it would be quite easy to support an extra |singlecommentstyle| for example.
%       Write
% \begin{verbatim}
%    \lst@Key{singlecommentstyle}{}{\def\lst@scommentstyle{#1}}\end{verbatim}
%       and use |\lst@scommentstyle| instead of |\@empty| in |\lst@SingleComment|.
%       Don't bother me about credits to you if you've implemented this for single comments or other comment types.
%       And one final hint:
%       Don't forget to initialize |\lst@scommentstyle| \emph{globally} before any listing is typeset.
%
%       \meta{save 1st} must be an undefined macro and is used internally to store the previous meaning of \meta{1st}.
%       The arguments \meta{2nd} and/or \meta{rest} are empty or equivalent to |\@empty| if the comment delimiter has strictly less than three characters.
%       All characters of \meta{1st}\meta{2nd}\meta{rest} must already be active (if not empty).
%       That's not a problem since the macro |\lst@CArg| does this job.
%
% \item[0.19] |\lst@CommentE|\meta{1st}\meta{2nd}\marg{rest}\meta{save 1st}\meta{mode}\marg{execute}\macrosyntaxbreak\marg{delim~exe~modetrue}\marg{delim~exe~modefalse}
%
%       defines the sequence \meta{1st}\meta{2nd}\meta{rest} to end a \meta{mode} comment.
%       \meta{execute} is executed when the package comes to \meta{1st}, whereas \meta{delim~exe~modetrue} and \meta{delim~exe~modefalse} are executed only if the whole comment delimiter \meta{1st}\meta{2nd}\meta{rest} is found.
%       These two are executed according to whether |\lst@mode| equals \meta{mode}, i.e.\ exactly one is called if the whole delimiter is found.
%
%       By default the package ends comment mode if the delimiter is found and |\lst@mode| equals \meta{mode}.
%       Internally we make an appropriate definition of |\lst@enext| (not |\lst@bnext|), which can be gobbled by placing |\@gobblethree| at the very end of \meta{delim exe modetrue}.
%       There you can also make your own definition (and gobble the default).
%       The next input characters come right after |\lst@enext|.
%
%       \meta{save 1st} must be an undefined macro and is used internally to store the previous meaning of \meta{1st}.
%       The arguments \meta{2nd} and/or \meta{rest} are empty or equivalent to |\@empty| if the comment delimiter has strictly less than three characters.
%       All characters of \meta{1st}\meta{2nd}\meta{rest} must already be active (if not empty).
%
% \item[0.18] |\lst@BeginComment|\meta{mode}\meta{style}\meta{input}
% \item[0.18] |\lst@@BeginComment|\meta{mode}\meta{style}\meta{input}\meta{input}
%
%       The first macro starts a comment indicated by a single character (like |%| in \TeX), whereas the second handles the case of two or more characters.
%       The input is the comment delimiter.
%
% \item[0.18] |\lst@EndComment| finishes any comment mode.
% \end{macrosyntax}
% The last three macros are used by the other macros to enter respectively leave comment modes.
%
% \subsection{Strings}
%
% We list some definitions.
% \begin{macrosyntax}
% \item[0.19] |\lst@legalstringizer|
%
%       contains a list of supported string types.
%       Currently this is \texttt{\csname lst@legalstringizer\endcsname}.
%       For each \meta{type} there must exist the macro |\lst@ProcessStringizer@|\meta{type}, which actually determines the next operation.
%       The macro gets the stringizer as argument.
%       The previous definition of the stringizer character is stored in |\lsts@s|\meta{stringizer}.
%
% \item[0.18] |\lst@BeginString|\meta{macro=`old character definition'}
% \item[0.18] |\lst@EndString|
%
%       starts respectively ends a string.
%       The argument is the macro in which the previous definition of the stringizer is saved.
% \end{macrosyntax}
%
%
% \part{Implementation}
%
% \CheckSum{7253}
%^^A
%^^A Don't index TeX-primitives.
%^^A
% \DoNotIndex{\advance,\afterassignment,\aftergroup,\batchmode,\begingroup}
% \DoNotIndex{\box,\catcode,\char,\chardef,\closeout,\copy,\count,\csname,\def}
% \DoNotIndex{\dimen,\discretionary,\divide,\dp,\edef,\else,\end,\endcsname}
% \DoNotIndex{\endgroup,\endinput,\endlinechar,\escapechar,\everypar}
% \DoNotIndex{\expandafter,\fi,\gdef,\global,\globaldefs,\hbadness,\hbox}
% \DoNotIndex{\hrulefill,\hss,\ht}
% \DoNotIndex{\if,\ifdim,\iffalse,\ifhmode,\ifinner,\ifnum,\ifodd,\iftrue}
% \DoNotIndex{\ifvoid,\ifx,\ignorespaces,\immediate,\input,\jobname,\kern}
% \DoNotIndex{\lccode,\leftskip,\let,\long,\lower,\lowercase,\meaning,\message}
% \DoNotIndex{\multiply,\muskip,\noexpand,\noindent,\openout,\par,\parfillskip}
% \DoNotIndex{\parshape,\parskip,\raise,\read,\relax,\rightskip,\setbox,\skip}
% \DoNotIndex{\string,\the,\toks,\uppercase,\vbox,\vcenter,\vrule,\vtop,\wd}
% \DoNotIndex{\write,\xdef}
%
%^^A
%^^A Don't index LaTeX's private definitions.
%^^A
% \DoNotIndex{\@@end,\@@par,\@M,\@arabic,\@circlefnt,\@currentlabel}
% \DoNotIndex{\@currenvir,\@depth,\@doendpe,\@dottedtocline,\@eha,\@ehc}
% \DoNotIndex{\@empty,\@firstofone,\@firstoftwo,\@float,\@for,\@getcirc}
% \DoNotIndex{\@gobble,\@gobbletwo,\@halfwidth,\@height,\@ifnextchar}
% \DoNotIndex{\@ifundefined,\@ignoretrue,\@makecaption,\@makeother,\@namedef}
% \DoNotIndex{\@ne,\@noligs,\@notprerr,\@onlypreamble,\@secondoftwo,\@spaces}
% \DoNotIndex{\@starttoc,\@totalleftmargin,\@undefined,\@whilenum}
% \DoNotIndex{\@wholewidth,\@width}
% \DoNotIndex{\c@chapter,\c@figure,\c@page,\end@float,\f@family,\filename@area}
% \DoNotIndex{\filename@base,\filename@ext,\filename@parse,\if@twoside}
% \DoNotIndex{\l@ngrel@x,\m@ne,\new@command,\nfss@catcodes,\tw@,\thr@@}
% \DoNotIndex{\z@,\zap@space}
%
%^^A
%^^A Don't index LaTeX's package definitions.
%^^A
% \DoNotIndex{\CurrentOption,\DeclareOption,\IfFileExists,\InputIfFileExists}
% \DoNotIndex{\MessageBreak,\NeedsTeXFormat,\PackageError,\PackageWarning}
% \DoNotIndex{\ProcessOptions,\ProvidesFile,\ProvidesPackage,\RequirePackage}
%
%^^A
%^^A Don't index LaTeX's public definitions.
%^^A
% \DoNotIndex{\abovecaptionskip,\active,\addcontentsline,\addtocounter,\begin}
% \DoNotIndex{\belowcaptionskip,\bfseries,\bgroup,\bigbreak,\chapter}
% \DoNotIndex{\contentsname,\do,\egroup,\footnotesize,\index,\itshape}
% \DoNotIndex{\linewidth,\llap,\makeatletter,\newbox,\newcommand,\newcount}
% \DoNotIndex{\newcounter,\newdimen,\newtoks,\newwrite,\nointerlineskip}
% \DoNotIndex{\normalbaselines,\normalfont,\numberline,\pretolerance,\protect}
% \DoNotIndex{\qquad,\refstepcounter,\removelastskip,\renewcommand,\rlap}
% \DoNotIndex{\small,\smallbreak,\smallskipamount,\smash,\space,\strut}
% \DoNotIndex{\strutbox,\tableofcontents,\textasciicircum,\textasciitilde}
% \DoNotIndex{\textasteriskcentered,\textbackslash,\textbar,\textbraceleft}
% \DoNotIndex{\textbraceright,\textdollar,\textendash,\textgreater,\textless}
% \DoNotIndex{\textunderscore,\textvisiblespace,\thechapter,\ttdefault}
% \DoNotIndex{\ttfamily,\typeout,\value,\vphantom}
%
%^^A
%^^A Don't index definitions from other packages.
%^^A
% \DoNotIndex{\MakePercentComment,\MakePercentIgnore}
%
%^^A
%^^A Don't index 0.17 definitions.
%^^A
% \DoNotIndex{\blankstringfalse,\blankstringtrue,\commentstyle}
% \DoNotIndex{\DeclareCommentLine,\DeclareDoubleComment,\DeclareNestedComment}
% \DoNotIndex{\DeclarePairedComment,\DeclareSingleComment,\inputlisting}
% \DoNotIndex{\inputlisting@,\keywords,\keywordstyle,\labelstyle}
% \DoNotIndex{\listingfalse,\listingtrue,\morekeywords,\normallisting}
% \DoNotIndex{\postlisting,\prelisting,\selectlisting,\selectlisting@}
% \DoNotIndex{\sensitivefalse,\sensitivetrue,\spreadlisting,\stringizer}
% \DoNotIndex{\stringizer@,\stringstyle,\tablength}
%
%^^A
%^^A Don't index 0.19 definitions.
%^^A
% \DoNotIndex{\listlistingsname,\listoflistings,\lstbox,\lstbox@}
% \DoNotIndex{\lstlanguage@}
%
%^^A
%^^A Don't index 0.20 subdefinitions.
%^^A
% \DoNotIndex{\lst@ATH@,\lst@BOLGobble@,\lst@BOLGobble@@,\lst@CArg@,\lst@CArg@@}
% \DoNotIndex{\lst@CBC@,\lst@CBC@@,\lst@CCECUse@,\lst@CCUseMacro@,\lst@DefLang@}
% \DoNotIndex{\lst@DefLang@@,\lst@DefOther@,\lst@DeleteKeysIn@,\lst@Escape@}
% \DoNotIndex{\lstframe@,\lst@frameH@,\lst@frameL@,\lst@frameR@}
% \DoNotIndex{\lst@FillOutputBox@,\lst@FindAlias@,\lst@FVConvert@}
% \DoNotIndex{\lst@IfNextChars@,\lst@IfNextChars@@,\lst@InsideConvert@}
% \DoNotIndex{\lst@InstallKeywords@,\lst@Key@,\lst@KeywordTestI@}
% \DoNotIndex{\lst@MakeActive@,\lst@MakeMoreKeywords@,\lst@MSkipToFirst@}
% \DoNotIndex{\lst@RC@,\lst@RC@@,\lst@ReplaceIn@,\lst@ReplaceInput@}
% \DoNotIndex{\lst@ReportAllocs@,\lst@SKS@,\lst@SKS@@,\lst@UBC@}
% \DoNotIndex{\lst@WorkingTestI@,\lstalias@,\lstalias@@,\lstalso@}
% \DoNotIndex{\lstdefinestyle@,\lstenv@BOLGobble@@,\lstenv@JSkipToFirst@}
% \DoNotIndex{\lstenv@ProcessJ@,\lstinline@,\lstKV@OptArg@,\lstKV@SetIf@}
% \DoNotIndex{\lstlang@,\lstnewenvironment@,\lstoutputpos@,\lstset@}
%
%
% \section{Overture}
%
% The required registers are listed in section \ref{dWhyLstAspects}.
% Furthermore, the required \packagename{keyval} package allocates one token register.
% The macros, boxes and counters |\@temp?a| and |\@temp?b| and the dimensions |\@tempdim?| are also used, see the index.
% And I shouldn't forget |\@gtempa|.
%
% Before considering the implementation, here some conventions I used:
% \begin{itemize}
% \item All public macros have lower case letters and contain |lst|.
% \item The name of all private macros and variables use the prefixes (possibly not up to date):
%	\begin{itemize}
%	\item |lst@| for a general macro or variable,
%	\item |lstenv@| if it is defined for the listing environment,
%	\item |lsts@| for |s|aved character meanings,
%	\item |\lsthk@|\meta{name of hook} holds hook material,
%	\item |lst|\meta{prefix}|@| for various kinds of keywords and working identifiers.
%
%	\item |\lstlang@|\meta{language}|@|\meta{dialect} contains a language definition,
%	\item |\lststy@|\meta{the style} contains style definition,
%
%   \item |\lstpatch@|\meta{aspect} to patch an aspect,
%
%	\item |\lsta@|\meta{language}|$|\meta{dialect} contains alias,
%	\item |\lsta@|\meta{language} contains alias for all dialects of a language,
%	\item |\lstdd@|\meta{language} contains default dialect of a language (if present).
%	\end{itemize}
% \item To distinguish procedure-like macros from macros holding data, the name of procedure macros use upper case letters with each beginning word, e.g.\ |\lst@AddTo|.
% \item If a submacro does the main work, e.g.\ |\lstinputlisting@| does it for |\lstinputlisting|, we use the suffix |@|.
% \end{itemize}
%
% \begingroup
% All files generated from this \texttt{listings.dtx} will get a header.
%    \begin{macrocode}
%% Please read the software license in listings.dtx or listings.dvi.
%%
%% (w)(c) 1996/1997/1998/1999 Carsten Heinz and/or any other author
%% listed elsewhere in this file.
%%
%% This file is distributed under the terms of the LaTeX Project Public
%% License from CTAN archives in directory  macros/latex/base/lppl.txt.
%% Either version 1.0 or, at your option, any later version.
%%
%% The listings package is free software.
%%
%% However, if you distribute the package as part of a commercial
%% product or if you use the package to prepare a document and sell the
%% document (books, journals, and so on), I'd like to encourage you to
%% make a donation to the LaTeX3 fund. The size of this `license fee'
%% should depend on the value of the package for your product.
%%
%% If you use the package to typeset a non-commercial document, please
%% send me a copy of the document (hardcopy, .dvi, .ps, .pdf, etc.) to
%% support further development.
%%
%% Permission is granted to change this file. You are not allowed to
%% distribute any changed version of this file, neither under the same
%% name nor under a different one.
%%
%% Send comments and ideas on the package, error reports and additional
%% programming languages to <cheinz@gmx.de>.
%%
%    \end{macrocode}
% The kernel now starts with identification.
%    \begin{macrocode}
%<*kernel>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{listings}[1999/07/12 v0.20 (Carsten Heinz)]
\def\lst@version{0.20}
%    \end{macrocode}
% If we input another file of the \packagename{listings} package, we change some catcodes:
% |@| and |"| become letters; tabulators and EOL characters are ignored.
% This avoids unwanted spaces (if I've forgotten a comment character |%|).
%    \begin{macrocode}
\def\lst@InputCatcodes{%
    \makeatletter \catcode`\"=12%
    \catcode`\^^@=\active
    \catcode`\^^I9%
    \catcode`\^^M9%
    \catcode`\~=\active}
\def\lst@RestoreCatcodes#1{%
    \ifx\relax#1\else
        \noexpand\catcode`\noexpand#1\the\catcode`#1\relax
        \expandafter\lst@RestoreCatcodes
    \fi}
\edef\lst@RestoreCatcodes{%
    \lst@RestoreCatcodes\"\^^I\^^M\~\^^@\relax}
\lst@InputCatcodes
%    \end{macrocode}
%    \begin{macrocode}
%</kernel>
%    \end{macrocode}
% The non-kernel file also starts with identification.
%    \begin{macrocode}
%<!kernel>\ProvidesFile{lstmisc.sty}[1999/07/12 v0.20 (Carsten Heinz)]
%    \end{macrocode}
% \endgroup
%
% \begingroup
%    \begin{macrocode}
%<*info>
%    \end{macrocode}
% \endgroup
% \begin{macro}{\lst@GetAllocs}
% \begin{macro}{\lst@ReportAllocs}
% Are used to show the allocated registers.
%    \begin{macrocode}
\def\lst@GetAllocs{%
    \edef\lst@allocs{%
        0\noexpand\count\the\count10,1\noexpand\dimen\the\count11,%
        2\noexpand\skip\the\count12,3\noexpand\muskip\the\count13,%
        4\noexpand\box\the\count14,5\noexpand\toks\the\count15,%
        6\noexpand\read\the\count16,7\noexpand\write\the\count17}}
\def\lst@ReportAllocs{%
    \message{^^JAllocs:}\def\lst@temp{none}%
    \expandafter\lst@ReportAllocs@\lst@allocs,\z@\relax\z@,}
\def\lst@ReportAllocs@#1#2#3,{%
    \ifx#2\relax \message{\lst@temp^^J}\else
        \@tempcnta\count1#1\relax \advance\@tempcnta -#3\relax
        \ifnum\@tempcnta=\z@\else
            \let\lst@temp\@empty
            \message{\the\@tempcnta \string#2,}%
        \fi
        \expandafter\lst@ReportAllocs@
    \fi}
\lst@GetAllocs
%    \end{macrocode}
% \end{macro}\end{macro}
% \begingroup
%    \begin{macrocode}
%</info>
%    \end{macrocode}
% \endgroup
%
%
% \section{General problems and \TeX niques}
%
% \begingroup
% All definitions in this section belong to the kernel.
%    \begin{macrocode}
%<*kernel>
%    \end{macrocode}
% \endgroup
%
%
% \subsection{Quick `if parameter empty'}
%
% There are many situations where you have to look whether a macro parameter is empty.
% We have at least two possibilities to test |#1|, for example:
% \begin{center}
% \begin{minipage}{0.35\linewidth}
% \begin{verbatim}
%\def\test{#1}%
%\ifx \test\empty
%        % #1 is empty
%\else
%        % #1 is not empty
%\fi\end{verbatim}
% \end{minipage}
% \hskip2em\vrule\hskip2em
% \begin{minipage}{0.35\linewidth}
% \begin{verbatim}
%\ifx \empty#1\empty
%        % #1 is empty
%\else
%        % #1 is not empty
%\fi\end{verbatim}
% \end{minipage}
% \end{center}
% where |\empty| is defined by |\def\empty{}|, of course.
% The left variant should be clear and works in any case.
% The right-hand side works correct if and only if the first token of |#1| is not equivalent to |\empty|.
% This granted, the |\ifx| is true if and only if |#1| is empty (since |\empty| left from |#1| is (not) compared with |\empty| on the right).
% The two |\empty|s might be replaced by any other macro, which is not equivalent to the first token of the argument.
% But the definition of that macro shouldn't be too complex since this would slow down the |\ifx|.
% In the examples above the right version needs about $45\%$ of the left's time.
% Note that this \TeX{}nique lost its importance from version 0.18 on.
%
%
% \subsection{Substring tests}\label{iSubstringTests}
%
% It's easy to decide whether a given character sequence --- let's say |def| --- is a substring of another string.
% First we define the temporary macro
% \begin{verbatim}
%     \def\lst@temp#1def#2\relax{%
%         \ifx \@empty#2\@empty
%                 % "def" is not substring
%         \else
%                 % "def" is substring
%         \fi}\end{verbatim}
% Then we call that macro as follows.
% \begin{quote}
% |\lst@temp| \meta{another string}|def\relax|
% \end{quote}
% When \TeX\ passes the arguments, the second is empty if and only if |def| is not a substring.
% Without the additional |def\@empty| you would get a ``runaway argument'' error if \meta{another string} doesn't contain |def|.
%
% We use substring tests mainly in the special case of an identifier (here |key|) and a comma separated list of key(word)s:
% \begin{verbatim}
%     \def\lst@temp#1,key,#2\relax{%
%         \ifx \@empty#2\@empty
%                 % `key' is not a keyword
%         \else
%                 % `key' is a keyword
%         \fi}\end{verbatim}
% \begin{quote}
% |\lst@temp,|\meta{list of keywords}|,key,\relax|
% \end{quote}
% It works very well and is quite fast.
% But we can reduce run time in the case that |key| is a keyword.
% Then |#2| takes the rest of the string, namely all keywords after |key|.
% Since \TeX\ inserts |#2| between the |\@empty|s, it must drop all of |#2| except the first character (which is compared with |\@empty|).
% We can redirect this rest to a third parameter:
% \begin{verbatim}
%     \def\lst@temp#1,key,#2#3\relax{%
%         \ifx \@empty#2%
%                 % "key" is not a keyword
%         \else
%                 % "key" is a keyword
%         \fi}\end{verbatim}
% \begin{quote}
% |\lst@temp,|\meta{list of keywords}|,key,\@empty\relax|
% \end{quote}
% That's a bit faster and an improvement for version 0.20.
% Unfortunately we don't use substring tests any more to detect keywords!
%
% \begin{macro}{\lst@IfSubstring}
% The implementation should be clear from the discussion above.
%    \begin{macrocode}
\def\lst@IfSubstring#1#2{%
    \def\lst@temp##1#1##2##3\relax{%
        \ifx \@empty##2\expandafter\@secondoftwo
                 \else \expandafter\@firstoftwo \fi}%
    \expandafter\lst@temp#2#1\@empty\relax}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@IfOneOf}
% Ditto.
%    \begin{macrocode}
\def\lst@IfOneOf#1\relax#2{%
    \def\lst@temp##1,#1,##2##3\relax{%
        \ifx \@empty##2\expandafter\@secondoftwo
                 \else \expandafter\@firstoftwo \fi}%
    \expandafter\lst@temp\expandafter,#2,#1,\@empty\relax}
%    \end{macrocode}
% \end{macro}
% \begin{REMOVED}
% Some day there's possibly need for a case insensitive keyword test again.
% We could use two |\uppercase|s to normalize the first parameter:
%    \begin{verbatim}
%\def\lst@IfOneOfInsensitive#1\relax#2{%
%    \uppercase{\def\lst@temp##1,#1},##2##3\relax{%
%        \ifx \@empty##2\expandafter\@secondoftwo
%                 \else \expandafter\@firstoftwo \fi}%
%    \uppercase{%
%        \expandafter\lst@temp\expandafter,#2,#1},\@empty\relax}\end{verbatim}
% Here we assume that macro |#2| already contains captial characters only.
% The macro
%    \begin{verbatim}
%\def\lst@MakeMacroUppercase#1{%
%    \ifx\@undefined#1\else \uppercase\expandafter
%        {\expandafter\def\expandafter#1\expandafter{#1}}%
%    \fi}\end{verbatim}
% makes the contents of a macro (if defined) upper case; use it in the |Init| hook.
% If we \emph{must not} assume that |#2| contains upper characters only, we could simply insert an |\expandafter| between the second |\uppercase| and the following brace.
% But this slows down the tests!
% \end{REMOVED}
%
% \begin{macro}{\lst@DeleteKeysIn}
% The submacro does the main work; we only need to expand the second macro (the list of keys to remove) and append the terminator |\relax|.
%    \begin{macrocode}
\def\lst@DeleteKeysIn#1#2{%
    \expandafter\lst@DeleteKeysIn@\expandafter#1#2,\relax,}
%    \end{macrocode}
% The loop terminates by `replacing' the very last |\lst@DeleteKeysIn@| by a macro, which removes all commas at the beginning of |#1|.
% Note: The |\@empty| after |#2| ensures that this macro also works if |#2| is empty --- I mean empty, not equivalent to |\@empty|, but it works in both cases.
%    \begin{macrocode}
\def\lst@DeleteKeysIn@#1#2,{%
    \ifx\relax#2\@empty
        \expandafter\@firstoftwo\expandafter\lst@RemoveCommas
    \else
        \ifx\@empty#2\@empty\else
%    \end{macrocode}
% If we haven't reached the end of list and the key is not empty, we define a temporary macro which removes all appearences.
% This is done by building up a new list step by step and leaving out the key(s) we want to remove.
%    \begin{macrocode}
            \def\lst@temp##1,#2,##2{%
                \ifx\@empty##2%
                    \lst@lAddTo#1{##1}%
                \else
                    \lst@lAddTo#1{,##1}%
                    \expandafter\lst@temp\expandafter,%
                \fi ##2}%
%    \end{macrocode}
% Now we empty the first macro and make the new list.
%    \begin{macrocode}
            \let\@tempa#1\let#1\@empty
            \expandafter\lst@temp\expandafter,\@tempa,#2,\@empty
        \fi
    \fi
    \lst@DeleteKeysIn@#1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@RemoveCommas}
% The macro drops commas at the beginning and assigns the new value to |#1|.
%    \begin{macrocode}
\def\lst@RemoveCommas#1{\expandafter\lst@RC@#1\@empty #1}
\def\lst@RC@#1{%
    \ifx,#1%
        \expandafter\lst@RC@
    \else
        \expandafter\lst@RC@@\expandafter#1%
    \fi}
\def\lst@RC@@#1\@empty#2{\def#2{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@ReplaceIn}
% \begin{macro}{\lst@ReplaceInArg}
% This macro is similar to |\lst@DeleteKeysIn|, \ldots
%    \begin{macrocode}
\def\lst@ReplaceIn#1#2{%
    \expandafter\lst@ReplaceIn@\expandafter#1#2\@empty\@empty}
\def\lst@ReplaceInArg#1#2{\lst@ReplaceIn@#1#2\@empty\@empty}
%    \end{macrocode}
% but we replace |#2| by |#3| instead of |,#2,| by |,| (which removed the key).
%    \begin{macrocode}
\def\lst@ReplaceIn@#1#2#3{%
    \ifx\@empty#3\relax\else
        \def\lst@temp##1#2##2{%
            \ifx\@empty##2%
                \lst@lAddTo#1{##1}%
            \else
                \lst@lAddTo#1{##1#3}\expandafter\lst@temp
            \fi ##2}%
        \let\@tempa#1\let#1\@empty
        \expandafter\lst@temp\@tempa#2\@empty
        \expandafter\lst@ReplaceIn@\expandafter#1%
    \fi}
%    \end{macrocode}
% \end{macro}\end{macro}
%
%
% \subsection{Flow of control}
%
% \begin{macro}{\lst@IfNextCharsArg}
% is quite easy:
% We define a macro and call |\lst@IfNextChars|.
%    \begin{macrocode}
\def\lst@IfNextCharsArg#1{%
    \def\lst@tofind{#1}\lst@IfNextChars\lst@tofind}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@IfNextChars}
% We save the arguments and start a loop.
%    \begin{macrocode}
\def\lst@IfNextChars#1#2#3{%
    \let\lst@tofind#1\def\@tempa{#2}\def\@tempb{#3}%
    \let\lst@eaten\@empty \lst@IfNextChars@}
%    \end{macrocode}
% Expand the characters we are looking for.
%    \begin{macrocode}
\def\lst@IfNextChars@{\expandafter\lst@IfNextChars@@\lst@tofind\relax}
%    \end{macrocode}
% Now we can refine |\lst@tofind| and append the input character |#3| to |\lst@eaten|.
%    \begin{macrocode}
\def\lst@IfNextChars@@#1#2\relax#3{%
    \def\lst@tofind{#2}\lst@lAddTo\lst@eaten{#3}%
    \ifx#1#3%
%    \end{macrocode}
% If the meanings are the same, we either execute |\@tempa| or continue the test.
%    \begin{macrocode}
        \ifx\lst@tofind\@empty
            \let\lst@next\@tempa
        \else
            \let\lst@next\lst@IfNextChars@
        \fi
        \expandafter\lst@next
    \else
%    \end{macrocode}
% If the characters are different, we have to call |\@tempb|.
%    \begin{macrocode}
        \expandafter\@tempb
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@IfNextCharActive}
% We compare the character |#3| with its active version |\lowercase{~}|.
% Note that the right brace between |\ifx~| and |#3| ends the |\lowercase|.
% The |\endgroup| restores the |\lccode|.
%    \begin{macrocode}
\def\lst@IfNextCharActive#1#2#3{%
    \begingroup \lccode`\~=`#3\lowercase{\endgroup
    \ifx~}#3%
        \def\lst@next{#1}%
    \else
        \def\lst@next{#2}%
    \fi \lst@next #3}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@for}
% A for-loop with expansion of the loop-variable.
%    \begin{macrocode}
\def\lst@for#1\do#2{%
    \def\lst@forbody##1{#2}%
    \@for\lst@forvar:=#1\do
	    {\expandafter\lst@forbody\expandafter{\lst@forvar}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@TestEOLChar}
% \begin{macro}{\lst@EOLCharError}
% Here we test for the two possible EOL characters.
%    \begin{macrocode}
\begingroup \lccode`\~=`\^^M\lowercase{%
\gdef\lst@TestEOLChar#1{%
    \ifx ~#1\@empty \lst@EOLCharError \else
    \ifx^^J#1\@empty \lst@EOLCharError \else
        \gdef\lst@intname{#1}%
    \fi \fi}
}\endgroup
%    \end{macrocode}
% The error message.
%    \begin{macrocode}
\def\lst@EOLCharError{%
    \PackageError{Listings}%
    {Oops! It seems you've forgotten the argument to\MessageBreak
     a listing environment. Assuming empty argument}%
    {Type <RETURN> to proceed.}}
%    \end{macrocode}
% \end{macro}\end{macro}
%
%
% \subsection{Catcode changes of characters already read}\label{iCatcodeChangesOfCharactersAlreadyRead}
%
% A character gets its catcode right after reading it and \TeX\ has no primitive command to change catcodes of characters already read.
% But we can replace these characters by characters with same ASCII codes and different catcodes.
% It's not the same but suffices since the result is the same.
% Here we treat the very special case that all characters become active.
% A prototype macro would be
% \begin{verbatim}
%     \def\lst@MakeActive#1{\lccode`\~=`#1\lowercase{\def\lst@arg{~}}}\end{verbatim}
% This macro handles a single character only:
% The |\lowercase| changes the ASCII code of |~| to that of |#1| since we have said that |~| is the lower case version of |#1|.
% Fortunately the |\lowercase| doesn't change the catcode, so we have an active version of |#1|.
% Note that |~| is usually active.
%
% \begin{macro}{\lst@MakeActive}
% We won't do this character by character.
% To increase speed we change nine characters at the same time (if nine characters are left).
% We get the argument, empty |\lst@arg| and begin a loop:
%    \begin{macrocode}
\def\lst@MakeActive#1{%
    \let\lst@temp\@empty \lst@MakeActive@#1%
    \relax\relax\relax\relax\relax\relax\relax\relax\relax}
%    \end{macrocode}
% There are nine |\relax|es since |\lst@MakeActive@| has nine parameters and we don't want any problems in the case that |#1| is empty.
% We need nine active characters now instead of a single |~|.
% We make these catcode changes local and define the coming macro |\global|.
%    \begin{macrocode}
\begingroup
\catcode`\^^@=\active \catcode`\^^A=\active \catcode`\^^B=\active %
\catcode`\^^C=\active \catcode`\^^D=\active \catcode`\^^E=\active %
\catcode`\^^F=\active \catcode`\^^G=\active \catcode`\^^H=\active %
%    \end{macrocode}
% First we |\let| the next operation be |\relax|.
% This aborts our loop for processing all characters (default and possibly changed later).
% Then we look if we have at least one character.
% If this is not the case, the loop terminates and all is done.
%    \begin{macrocode}
\gdef\lst@MakeActive@#1#2#3#4#5#6#7#8#9{\let\lst@next\relax %
    \ifx#1\relax %
    \else \lccode`\^^@=`#1%
%    \end{macrocode}
% Otherwise we say that |^^@|=chr(0) is the lower case version of the first character.
% Then we test the second character.
% If there is none, we append the lower case |^^@| to |\lst@temp|.
% Otherwise we say that |^^A|=chr(1) is the lower case version of the second character and we test the next argument, and so on.
%    \begin{macrocode}
    \ifx#2\relax %
        \lowercase{\lst@lAddTo\lst@temp{^^@}}%
    \else \lccode`\^^A=`#2%
    \ifx#3\relax %
        \lowercase{\lst@lAddTo\lst@temp{^^@^^A}}%
    \else \lccode`\^^B=`#3%
    \ifx#4\relax %
        \lowercase{\lst@lAddTo\lst@temp{^^@^^A^^B}}%
    \else \lccode`\^^C=`#4%
    \ifx#5\relax %
        \lowercase{\lst@lAddTo\lst@temp{^^@^^A^^B^^C}}%
    \else \lccode`\^^D=`#5%
    \ifx#6\relax %
        \lowercase{\lst@lAddTo\lst@temp{^^@^^A^^B^^C^^D}}%
    \else \lccode`\^^E=`#6%
    \ifx#7\relax %
        \lowercase{\lst@lAddTo\lst@temp{^^@^^A^^B^^C^^D^^E}}%
    \else \lccode`\^^F=`#7%
    \ifx#8\relax %
        \lowercase{\lst@lAddTo\lst@temp{^^@^^A^^B^^C^^D^^E^^F}}%
    \else \lccode`\^^G=`#8%
    \ifx#9\relax %
        \lowercase{\lst@lAddTo\lst@temp{^^@^^A^^B^^C^^D^^E^^F^^G}}%
%    \end{macrocode}
% If nine characters are present, we append (lower case versions of) nine active characters and call this macro again via redefining |\lst@next|.
%    \begin{macrocode}
    \else \lccode`\^^H=`#9%
        \lowercase{\lst@lAddTo\lst@temp{^^@^^A^^B^^C^^D^^E^^F^^G^^H}}%
        \let\lst@next\lst@MakeActive@ %
    \fi \fi \fi \fi \fi \fi \fi \fi \fi %
    \lst@next}
\endgroup
%    \end{macrocode}
% This |\endgroup| restores the catcodes of chr(0)--chr(8), but not the catcodes of the characters inside |\lst@MakeActive@| since they are already read.
% \end{macro}
%
% \begin{macro}{\lst@DefActive}
% An easy application of |\lst@MakeActive|.
%    \begin{macrocode}
\def\lst@DefActive#1#2{\lst@MakeActive{#2}\let#1\lst@temp}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@DefOther}
% We use the fact that |\meaning| produces catcode 12 characters --- except spaces stay spaces.
% |\escapechar| is modified locally to suppress the output of an escape character.
% Finally we remove spaces via \LaTeX's |\zap@space|, which was proposed by \lsthelper{Rolf~Niepraschk}{1997/04/24}{use \zap@space} (not in this context, but that doesn't matter).
%    \begin{macrocode}
\def\lst@DefOther#1#2{%
    \begingroup \def#1{#2}\escapechar\m@ne \expandafter\endgroup
    \expandafter\lst@DefOther@\meaning#1\relax#1}
\def\lst@DefOther@#1->#2\relax#3{\edef#3{\zap@space#2 \@empty}}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Applications to \ref{iCatcodeChangesOfCharactersAlreadyRead}}\label{iApplicationsTo}
%
% If an environment is used inside an argument the listing is already read and we can do nothing to preserve the catcodes.
% However, under certain circumstances the environment can be used inside an argument --- that's at least what I've said in the user's guide.
% And now I have to work for it coming true.
% Moreover we define an analogous conversion macro for the \packagename{fancyvrb} mode.
% \begin{macrosyntax}
% \item[0.19] |\lst@InsideConvert{|\meta{\TeX\ material \textup(already read\textup)}|}|
%
%       \emph{appends} a `verbatim' version of the argument to |\lst@arg|, but all appended characters are active.
%       Since it's not a character to character conversion, `verbatim' needs to be explained.
%       All characters can be typed in as they are except |\|, |{|, |}| and |%|.
%       If you want one of these, you must write |\\|, |\{|, |\}| and |\%| instead.
%       If two spaces should follow each other, the second (third, fourth, \ldots) space must be entered with a preceding backslash.
%
% \item[0.19] |\lst@FVConvert{|\meta{\TeX\ material \textup(already read\textup)}|}|
%
%       \emph{appends} a `verbatim' version of the argument to |\lst@arg|.
%       `Verbatim' is different here: Control sequences, |\bgroup| and |\egroup| characters are just copied, but the arguments enclosed in such groups and all other characters become active.
%       Moreover we insert some special macro calls not to loose the arguments.
%       This might go wrong if a `single token argument' is not enclosed in braces since in that case we insert no special macro calls.
%
% \end{macrosyntax}
%
% \begin{macro}{\lst@InsideConvert}
% We call a submacro (similar to |\zap@space|) to preserve single spaces, which are replaced by active spaces.
%    \begin{macrocode}
\def\lst@InsideConvert#1{\lst@InsideConvert@#1 \@empty}
\begingroup \lccode`\~=`\ \relax \lowercase{%
%    \end{macrocode}
% We make |#1| active and append these characters (plus an active space) to |\lst@arg|.
% If we haven't found the end |\@empty| of the input, we continue the process.
%    \begin{macrocode}
\gdef\lst@InsideConvert@#1 #2{%
    \lst@MakeActive{#1}%
    \ifx\@empty#2%
        \lst@lExtend\lst@arg{\lst@temp}%
    \else
        \lst@lExtend\lst@arg{\lst@temp~}%
        \expandafter\lst@InsideConvert@
    \fi #2}
%    \end{macrocode}
% Finally we end the |\lowercase| and close a group.
%    \begin{macrocode}
}\endgroup
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@FVConvert}
% looks for a |\bgroup| first.
%    \begin{macrocode}
\gdef\lst@FVConvert{%
    \@ifnextchar\bgroup{\lst@FVConvertArg}{\lst@FVConvert@}}%
%    \end{macrocode}
% Coming to such a character ('\{' with catcode 1) we convert the argument and add it together with group delimiters to |\lst@arg|.
% We also add |\lst@PrintToken|, which prints all collected characters before we forget them.
% Finally we continue the conversion.
%    \begin{macrocode}
\gdef\lst@FVConvertArg#1{%
    {\let\lst@arg\@empty \lst@FVConvert#1@\global\let\@gtempa\lst@arg}%
     \lst@lExtend\lst@arg{\expandafter{\@gtempa\lst@PrintToken}}%
     \lst@FVConvert}
%    \end{macrocode}
% If we haven't found a |\bgroup|, we look whether we've found the end of the input.
% If not, we convert one token ((non)active character or control sequence) and continue.
%    \begin{macrocode}
\gdef\lst@FVConvert@#1{%
    \ifx @#1\else
        \if\relax\noexpand#1%
            \lst@lAddTo\lst@arg{\lst@UseLostSpace\lst@PrintToken#1}%
        \else
            \lccode`\~=`#1\lowercase{\lst@lAddTo\lst@arg~}%
        \fi
        \expandafter\lst@FVConvert
    \fi}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Aspect commands}
%
% This section contains commands used in defining `\lst-aspects'.
% \begin{macro}{\lst@loadedaspects}
% is initially empty since it contains the names of all loaded aspects.
%    \begin{macrocode}
\global\let\lst@loadedaspects\@empty % init % \global
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@BeginAspect}
% A straight-forward implementation:
%    \begin{macrocode}
\newcommand*\lst@BeginAspect[2][]{%
    \ifx\@empty#2\@empty
        \expandafter\lst@GobbleAspect
    \else
        \def\lst@curraspect{#2}%
%    \end{macrocode}
% If \meta{aspect name} is not empty, there are certain other conditions not to define the aspect (as described in section \ref{dHowToDefineLstAspects}).
%    \begin{macrocode}
%<!info>        \def\lst@next{\lst@AddTo\lst@loadedaspects{,#2}}%
%<info>        \def\lst@next{\lst@AddTo\lst@loadedaspects{,#2}%
%<info>            \message{^^JDefine lst-aspect `#2':}\lst@GetAllocs}%
        \lst@IfOneOf#2\relax\lst@loadedaspects
            {\let\lst@next\lst@GobbleAspect}%
            {\ifx\lst@loadaspects\@undefined\else
                 \lst@IfOneOf#2\relax\lst@loadaspects
                     {}{\let\lst@next\lst@GobbleAspect}%
             \fi}%
        \ifx\lst@next\lst@GobbleAspect\else \ifx\@empty#1\@empty\else
            \lst@RequireAspects{#1}%
            \lst@ifRAloaded\else \let\lst@next\lst@GobbleAspect \fi
        \fi \fi
        \expandafter\lst@next
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@EndAspect}
% finishes an aspect definition.
%    \begin{macrocode}
\def\lst@EndAspect{%
    \csname lstpatch@\lst@curraspect\endcsname
%<info>    \lst@ReportAllocs
    \let\lst@curraspect\@empty}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@GobbleAspect}
% drops all code up to the next |\lst@EndAspect|.
%    \begin{macrocode}
\long\def\lst@GobbleAspect#1\lst@EndAspect{\let\lst@curraspect\@empty}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@RequireAspects}
% We define |\lst@loadaspects|, look for missing aspects \ldots
%    \begin{macrocode}
\def\lst@RequireAspects#1{%
    \begingroup
    \edef\lst@loadaspects{#1}\lst@ReplaceInArg\lst@loadaspects{{ }{}}%
    \lst@DeleteKeysIn\lst@loadaspects\lst@loadedaspects
%    \end{macrocode}
% and input \texttt{lstmisc.sty} if necessary.
%    \begin{macrocode}
    \global\let\lst@ifRAloaded\iftrue
    \ifx\lst@loadaspects\@empty\else
        \lst@InputCatcodes \input{lstmisc.sty}%
        \lst@DeleteKeysIn\lst@loadaspects\lst@loadedaspects
        \ifx\lst@loadaspects\@empty\else
            \global\lst@RAloadedfalse
            \PackageError{Listings}{Couldn't load requested aspects}%
            {The following aspects weren't loadable:^^J\@spaces
             \lst@loadaspects^^JThis may cause errors in the sequel.}%
        \fi
    \fi
    \endgroup}
%    \end{macrocode}
%    \begin{macrocode}
\def\lst@RAloadedfalse{\let\lst@ifRAloaded\iffalse}
\lst@RAloadedfalse
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstloadaspects}
% is easy now.
%    \begin{macrocode}
\let\lstloadaspects\lst@RequireAspects
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@UserCommand}
% is equivalent to |\gdef|.
%    \begin{macrocode}
%<!info>\let\lst@UserCommand\gdef
%<info>\def\lst@UserCommand#1{%
%<info>    \message{\string#1,}\gdef#1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@Key}
% The command simply defines the key.
% But we must take care of an optional parameter and the initialization argument |#2|.
%    \begin{macrocode}
\def\lst@Key#1#2{%
%<info>    \message{#1,}%
    \@ifnextchar[{\lstKV@def{#1}{#2}}%
                 {\def\lst@temp{\lst@Key@{#1}{#2}}
                  \afterassignment\lst@temp
                  \global\@namedef{KV@lst@#1}####1}}
%    \end{macrocode}
% Now comes a renamed and modified copy from a \packagename{keyval} macro:
% We need global key definitions.
%    \begin{macrocode}
\def\lstKV@def#1#2[#3]{%
    \global\@namedef{KV@lst@#1@default\expandafter}\expandafter
        {\csname KV@lst@#1\endcsname{#3}}%
    \def\lst@temp{\lst@Key@{#1}{#2}}\afterassignment\lst@temp
    \global\@namedef{KV@lst@#1}##1}
%    \end{macrocode}
% Now we initialize the key if the first token of |#2| is not |\relax|.
%    \begin{macrocode}
\def\lst@Key@#1#2{%
    \ifx\relax#2\@empty\else
        \begingroup \globaldefs\@ne
        \csname KV@lst@#1\endcsname{#2}%
        \endgroup
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@UseHook}
% is very, very, \ldots, very (hundreds of times) easy.
%    \begin{macrocode}
\def\lst@UseHook#1{\csname lsthk@#1\endcsname}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@AddToHook}
% \begin{macro}{\lst@AddToHookExe}
% \begin{macro}{\lst@AddToHookAtTop}
% All use the same submacro.
%    \begin{macrocode}
\def\lst@AddToHook{\lst@ATH@\iffalse\lst@AddTo}
\def\lst@AddToHookExe{\lst@ATH@\iftrue\lst@AddTo}
\def\lst@AddToHookAtTop{\lst@ATH@\iffalse\lst@AddToAtTop}
%    \end{macrocode}
% If and only if the boolean value is true, the new hook material is executed globally.
%    \begin{macrocode}
\long\def\lst@ATH@#1#2#3#4{%
    \@ifundefined{lsthk@#3}{%
%<info>        \message{^^Jnew hook `#3',^^J}%
        \expandafter\gdef\csname lsthk@#3\endcsname{}}{}%
    \expandafter#2\csname lsthk@#3\endcsname{#4}%
    \def\lst@temp{#4}%
    #1% \iftrue|false
        \begingroup \globaldefs\@ne \lst@temp \endgroup
    \fi}
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
%
% \begin{macro}{\lst@AddTo}
% Note that the definition is global!
%    \begin{macrocode}
\long\def\lst@AddTo#1#2{%
    \expandafter\gdef\expandafter#1\expandafter{#1#2}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@AddToAtTop}
% We need a couple of |\expandafter|s now.
% Simply note that we have\\
%	{\small\hspace*{2em}
%	|\expandafter\gdef\expandafter#1\expandafter{\lst@temp|$\langle$\textit{contents of }|#1|$\rangle$|}|
%	}\\
% after the first phase of expansion.
%    \begin{macrocode}
\def\lst@AddToAtTop#1#2{\def\lst@temp{#2}%
    \expandafter\expandafter\expandafter\gdef
    \expandafter\expandafter\expandafter#1%
    \expandafter\expandafter\expandafter{\expandafter\lst@temp#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@lAddTo}
% A local version of |\lst@AddTo| \ldots
%    \begin{macrocode}
\def\lst@lAddTo#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@Extend}
% \begin{macro}{\lst@lExtend}
% and here we expand the first token of the second argument first.
%    \begin{macrocode}
\def\lst@Extend#1#2{%
    \expandafter\lst@AddTo\expandafter#1\expandafter{#2}}
\def\lst@lExtend#1#2{%
    \expandafter\lst@lAddTo\expandafter#1\expandafter{#2}}
%    \end{macrocode}
% \begin{TODO}
% This should never be changed to
%    \begin{verbatim}
%    \def\lst@Extend#1{%
%        \expandafter\lst@AddTo\expandafter#1\expandafter}
%    \def\lst@lExtend#1{%
%        \expandafter\lst@lAddTo\expandafter#1}\end{verbatim}
% The first is not equivalent in case that the second argument is a single ($=$ non-braced) control sequence, and the second isn't in case of a braced second argument.
% \end{TODO}
% \end{macro}\end{macro}
%
%
% \subsection{Interfacing with \packagename{keyval}}
%
% The \packagename{keyval} package passes the value via the one and only paramater |#1| to the definition part of the key macro.
% The following commands may be used to analyse the value.
% Note that we need at least version 1.10 of the \packagename{keyval} package.
% \begingroup
%    \begin{macrocode}
\RequirePackage{keyval}[1997/11/10]
%    \end{macrocode}
% \endgroup
%
% \begin{macro}{\lstKV@TwoArg}
% \begin{macro}{\lstKV@ThreeArg}
% \begin{macro}{\lstKV@FourArg}
% Define temporary macros and call with given arguments |#1|.
% We add empty arguments for the case that the user doesn't provide enough arguments.
%    \begin{macrocode}
\def\lstKV@TwoArg#1#2{\def\lst@temp##1##2{#2}\lst@temp#1{}{}}
\def\lstKV@ThreeArg#1#2{\def\lst@temp##1##2##3{#2}\lst@temp#1{}{}{}}
\def\lstKV@FourArg#1#2{\def\lst@temp##1##2##3##4{#2}\lst@temp#1{}{}{}{}}
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
%
% \begin{macro}{\lstKV@OptArg}
% We define the temporary macro |\@gtempa| and insert default argument if necessary.
%    \begin{macrocode}
\def\lstKV@OptArg[#1]#2#3{%
    \gdef\@gtempa[##1]##2\@{#3}\lstKV@OptArg@{#1}#2\@}
\def\lstKV@OptArg@#1{\@ifnextchar[\@gtempa{\@gtempa[#1]}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstKV@CSTwoArg}
% Just define temporary macro and call it.
%    \begin{macrocode}
\def\lstKV@CSTwoArg#1#2{%
    \gdef\@gtempa##1,##2,##3\relax{#2}%
    \@gtempa#1,,\relax}
%    \end{macrocode}
% There's one question:
% What are the global definitions good for?
% The |\lst@Key| command might set |\globaldefs| to one and possibly calls this macro.
% That's the reason why we use global definitions here and in |\lstKV@OptArg|.
% \end{macro}
%
% \begin{macro}{\lstKV@SetIf}
% We simply test the lower case first character of |#1|.
%    \begin{macrocode}
\def\lstKV@SetIf#1{\lstKV@SetIf@#1\relax}
\def\lstKV@SetIf@#1#2\relax#3{\lowercase{%
    \expandafter\let\expandafter#3%
        \csname \ifx #1t}iftrue\else iffalse\fi\endcsname}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstset}
% Finally this main user interface macro.
% We change catcodes for reading the argument.
%    \begin{macrocode}
\lst@UserCommand\lstset{\begingroup \lstset@catcodes \lstset@}
\def\lstset@#1{\endgroup \ifx\@empty#1\@empty\else\setkeys{lst}{#1}\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstset@catcodes}
% contains all catcode changes for |\lstset|.
%    \begin{macrocode}
\def\lstset@catcodes{\makeatletter \catcode`\"=12\relax}
%    \end{macrocode}
% \begin{TODO}
% Change more catcodes?
% \end{TODO}
% \end{macro}
%
%
% \subsection{Internal modes}
%
% \begin{macro}{\lst@NewMode}
% The counter |\lst@mode| mainly keeps the current mode number.
% But it is also used to advance the number in |\lst@newmode|, which is a macro --- we don't waste another counter.
% We simply use |\chardef| for a mode definition.
%    \begin{macrocode}
\def\lst@NewMode#1{%
    \ifx\@undefined#1%
        \lst@mode\lst@newmode\relax \advance\lst@mode\@ne
        \xdef\lst@newmode{\the\lst@mode}%
        \global\chardef#1=\lst@mode
        \lst@mode\lst@nomode
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@mode}
% \begin{macro}{\lst@nomode}
% We allocate the counter and the first mode.
%    \begin{macrocode}
\newcount\lst@mode
\def\lst@newmode{\m@ne}% init
\lst@NewMode\lst@nomode % init (of \lst@mode :-)
%    \end{macrocode}
% \end{macro}\end{macro}
%
% \begin{macro}{\lst@modetrue}
% The usual macro to value a boolean, but we also execute a hook.
%    \begin{macrocode}
\def\lst@modetrue{\let\lst@ifmode\iftrue \lsthk@ModeTrue}
\let\lst@ifmode\iffalse % init
\lst@AddToHook{ModeTrue}{}% init
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@EnterMode}
% Each mode opens a group level, stores the mode number and execute mode specific tokens.
% Moreover we keep all these changes in mind (locally) and adjust internal variables if the user wants it.
%    \begin{macrocode}
\def\lst@EnterMode#1#2{%
    \bgroup \lst@mode=#1\relax #2%
    \lst@iffontadjust \lsthk@FontAdjust \fi
    \lst@lAddTo\lst@entermodes{\lst@EnterMode{#1}{#2}}}
%    \end{macrocode}
%    \begin{macrocode}
\lst@AddToHook{InitVars}{\let\lst@entermodes\@empty}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@LeaveMode}
% We simply close the group and call |\lsthk@EndGroup| if and only if the current mode is not |\lst@nomode|.
%    \begin{macrocode}
\def\lst@LeaveMode{%
    \ifnum\lst@mode=\lst@nomode\else
        \egroup \expandafter\lsthk@EndGroup
    \fi}
%    \end{macrocode}
%    \begin{macrocode}
\lst@AddToHook{EndGroup}{}% init
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@InterruptModes}
% The |\ifx| is \emph{currently} not necessary since empty |\lst@entermodes| implies that we don't leave any mode.
%    \begin{macrocode}
\def\lst@InterruptModes{%
    \ifx\lst@entermodes\@empty\else
        \global\let\lst@reenter\lst@entermodes
        \lst@LeaveAllModes
    \fi}
%    \end{macrocode}
%    \begin{macrocode}
\lst@AddToHook{InitVars}{\global\let\lst@reenter\@empty}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@ReenterModes}
% But we need the |\ifx| in the following macro.
%    \begin{macrocode}
\def\lst@ReenterModes{%
    \ifx\lst@reenter\@empty\else
        \lst@LeaveAllModes \lst@reenter
        \global\let\lst@reenter\@empty
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@LeaveAllModes}
% Leaving all modes means closing groups until the mode equals |\lst@nomode|.
%    \begin{macrocode}
\def\lst@LeaveAllModes{%
    \ifnum\lst@mode=\lst@nomode
        \expandafter\lsthk@EndGroup
    \else
        \expandafter\egroup\expandafter\lst@LeaveAllModes
    \fi}
%    \end{macrocode}
% We need that macro to end a listing correctly.
%    \begin{macrocode}
\lst@AddToHook{ExitVars}{\lst@LeaveAllModes}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@Pmode}
% \begin{macro}{\lst@GPmode}
% The `processing' and the general purpose mode.
%    \begin{macrocode}
\lst@NewMode\lst@Pmode
\lst@NewMode\lst@GPmode
%    \end{macrocode}
%    \begin{macrocode}
%</kernel>
%    \end{macrocode}
% \end{macro}\end{macro}
%
%
% \section{Character classes}\label{iCharacterClasses}
%
% \begin{macro}{\lst@token}
% \begin{macro}{\lst@length}
% The token register contains the current character string, for example |try2| if we have just read these characters and a whitespace before.
% The counter |\lst@length| holds the length of the string and that's 4 in the example.
% The registers get empty respectively zero at EOL.
%    \begin{macrocode}
%<*kernel>
\newtoks\lst@token \newcount\lst@length
\lst@AddToHook{InitVarsBOL}{\lst@token{}\lst@length\z@}
%    \end{macrocode}
% \end{macro}\end{macro}
%
% \begin{macro}{\lst@lastother}
% This macro will be equivalent to the last `other' character.
%    \begin{macrocode}
\lst@AddToHook{InitVarsBOL}{\let\lst@lastother\@empty}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@Append}
% appends the argument to the current character string and increases the counter |\lst@length| by one.
%    \begin{macrocode}
\def\lst@Append#1{\advance\lst@length\@ne
    \expandafter\lst@token\expandafter{\the\lst@token#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@AppendOther}
% Nearly the same, but we save the argument (a single character or a single macro) in |\lst@lastother|.
%    \begin{macrocode}
\def\lst@AppendOther#1{\let\lst@lastother=#1\advance\lst@length\@ne
    \expandafter\lst@token\expandafter{\the\lst@token#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@ifletter}
% indicates whether we are processing an identifier or not.
%    \begin{macrocode}
\def\lst@lettertrue{\let\lst@ifletter\iftrue}
\def\lst@letterfalse{\let\lst@ifletter\iffalse}
\lst@AddToHook{InitVars}{\lst@letterfalse}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@PrintToken}
% outputs the current character string in letter or nonletter mode.
%    \begin{macrocode}
\def\lst@PrintToken{%
    \lst@ifletter
        \lst@Output\lst@letterfalse
    \else
        \lst@OutputOther \let\lst@lastother\@empty
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@CArg}
% Finally we define this service macro.
% We make |#2#3| active and search for an undefined macro name.
% This is done by adding |@| to \meta{prefix} until the name is unused.
%    \begin{macrocode}
\def\lst@CArg#1#2#3\relax{%
    \lst@DefActive\lst@arg{#2#3}%
    \lccode`\/=`#2\lowercase{\def\lst@temp{/}}%
    \lst@CArg@{#1}}
\def\lst@CArg@#1{%
    \expandafter\ifx\csname lsts@#1\lst@temp\endcsname\relax
%    \end{macrocode}
% We build the undefined macro name, insert the now active \meta{characters} and use |\@empty\@empty\relax| as delimiter for the submacro.
%    \begin{macrocode}
        \def\lst@next{\expandafter\lst@CArg@@
            \csname lsts@#1\lst@temp\expandafter\endcsname\lst@arg
            \@empty\@empty\relax}%
    \else
        \def\lst@next{\lst@CArg@{#1@}}%
    \fi \lst@next}
%    \end{macrocode}
% We call the specified macro |#6| with correct arguments.
%    \begin{macrocode}
\def\lst@CArg@@#1#2#3#4\@empty#5\relax#6{#6#2#3{#4}#1}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Letters, digits and others}
%
% \begin{macro}{\lst@ProcessLetter}
% To process a letter |#1| we look at the last character.
% If it hasn't been a letter, we output the preceding other characters first and switch to letter mode.
% Finally we append the current letter |#1|.
%    \begin{macrocode}
\def\lst@ProcessLetter#1{%
    \lst@ifletter\else \lst@OutputOther\lst@lettertrue \fi
    \lst@Append{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@ProcessOther}
% `Other' characters are the other way round.
% If the last character has been a letter, the preceding letters are output and we switch to nonletter mode.
% Finally we append the current other character.
%    \begin{macrocode}
\def\lst@ProcessOther#1{%
    \lst@ifletter \lst@Output\lst@letterfalse \fi
    \lst@AppendOther{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@ProcessDigit}
% A digit simply appends the character to the current character string.
% But we must use the right macro.
% This allows digits to be part of an identifier or a numerical constant.
%    \begin{macrocode}
\def\lst@ProcessDigit#1{%
    \lst@ifletter \lst@Append{#1}\else \lst@AppendOther{#1}\fi}
%    \end{macrocode}
% \end{macro}
%
% \begingroup
% Some special code without explanation --- first I have to understand it completely.
%    \begin{macrocode}
\lst@AddToHook{OmegaOutputBox}
    {\let\lst@ProcessLetter\@firstofone
     \let\lst@ProcessDigit\@firstofone
     \let\lst@ProcessOther\@firstofone}
%    \end{macrocode}
% \endgroup
%
%
% \subsection{Tabulators, spaces and form feeds}
%
% Here we have to take care of two things:
% Dropping empty lines at the end of a listing and the flexible column format.
% In both cases we use |\lst@lostspace|.
% Lines containing only tabulators and spaces should be viewed as empty.
% In order to achieve this, tabulators and spaces at the beginning of a line don't output any characters but advance |\lst@lostspace|.
% Whenever this dimension is positive we insert that space before |\lst@token| is output.
% Thus, if there are only tabulators and spaces, the line is `empty' since we haven't done any output.
%
% We have to do more for flexible columns.
% The whitespaces can fix the column alignment:
% If the real line is wider than expected (|\lst@lostspace|$<$0pt), a tabulator is at least one space wide; all remaining width is used to make |\lst@lostspace| more positive.
% Spaces do the same: If there are two or more spaces, at least one space is printed; the others fix the column alignment.
% If we process a string, all spaces are output, of course.
%
% \begin{lstkey}{tabsize}
% We check for a legal argument before saving it.
% Default tabsize is 8 as proposed by \lsthelper{Rolf~Niepraschk}{1997/04/24}{tabsize=8}.
%    \begin{macrocode}
\lst@Key{tabsize}{8}
    {\ifnum#1>\z@ \def\lst@tabsize{#1}\else
         \PackageError{Listings}{Strict positive integer expected}%
         {You can't use `#1' as tabulator size.^^J%
          Type <RETURN> to forget it and to proceed.}%
     \fi}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{macro}{\lst@ProcessTabulator}
% A tabulator outputs the preceding characters.
% This decrements the counter |\lst@pos| by the number of printed characters.
%    \begin{macrocode}
\def\lst@ProcessTabulator{%
    \lst@PrintToken \lst@letterfalse
%    \end{macrocode}
% Then we calculate how many columns we need to reach the next tabulator stop:
% We add |\lst@tabsize| until |\lst@pos| is strict positive.
% That's all --- |\lst@column| keeps the current column and |\lst@pos| is the column modulo |tabsize|.
% We assign it to |\lst@length| and reset |\lst@pos| (at the end of the macro).
%    \begin{macrocode}
    \global\advance\lst@column -\lst@pos
    \@whilenum \lst@pos<\@ne \do
        {\global\advance\lst@pos\lst@tabsize}%
    \lst@length\lst@pos
    \lst@PreGotoTabStop}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@PreGotoTabStop}
% Visible tabs print |\lst@tab|.
%    \begin{macrocode}
\def\lst@PreGotoTabStop{%
    \lst@ifvisibletabs
        \setbox\@tempboxa\hbox to\lst@length\lst@width{\hss\lst@tab}%
        \lst@NewLine \lst@CalcLostSpaceAndOutput
    \else
%    \end{macrocode}
% If we are advised to keep spaces, we insert the correct number of them.
% Otherwise we go to the tabulator stop, e.g.\ |\lst@length| columns forward.
%    \begin{macrocode}
        \lst@ifkeepspaces
            \@tempcnta\lst@length \lst@length\z@
            \@whilenum \@tempcnta>\z@ \do
                {\lst@AppendOther\lst@outputspace
                 \advance\@tempcnta\m@ne}%
            \lst@OutputOther
        \else
            \lst@GotoTabStop
        \fi
    \fi
	\global\lst@pos\z@}
%    \end{macrocode}
% \end{macro}
%
% \begin{lstkey}{visibletabs}
% \begin{lstkey}{tab}
% Two user keys for tab control.
%    \begin{macrocode}
\lst@Key{visibletabs}f[t]{\lstKV@SetIf{#1}\lst@ifvisibletabs}
\lst@Key{tab}{\kern.06em\hbox{\vrule\@height.3ex}%
              \hrulefill\hbox{\vrule\@height.3ex}}
    {\def\lst@tab{#1}}
%    \end{macrocode}
% \end{lstkey}\end{lstkey}
%
% \begin{macro}{\lst@outputspace}
% \begin{macro}{\lst@visiblespace}
% The first macro is a default definition, \ldots
%    \begin{macrocode}
\def\lst@outputspace{\ }
\def\lst@visiblespace{\lst@ttfamily{\char32}\textvisiblespace}
%    \end{macrocode}
% \end{macro}\end{macro}
%
% \begin{lstkey}{visiblespaces}
% which is modified if the user wants it.
%    \begin{macrocode}
\lst@Key{visiblespaces}{false}[t]{\lstKV@SetIf{#1}\lst@ifkeepspaces}
\lst@AddToHook{Init}
    {\lst@ifkeepspaces \let\lst@outputspace\lst@visiblespace \fi}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{macro}{\lst@ProcessSpace}
% If the last character has been a letter, we output the current character string and append one space.
%    \begin{macrocode}
\def\lst@ProcessSpace{%
    \lst@ifletter
        \lst@Output\lst@letterfalse
        \lst@AppendOther\lst@outputspace
%    \end{macrocode}
% We look whether spaces fix the column alignment or not.
% In the latter case we must append a space; otherwise we must test if the hitherto line is empty.
%    \begin{macrocode}
    \else \lst@ifkeepspaces
        \lst@AppendOther\lst@outputspace
    \else \ifx\lst@NewLine\relax
%    \end{macrocode}
% If the line is not empty we either advance |\lst@lostspace| or append a space to the current character string.
%    \begin{macrocode}
        \lst@AppendSpecialSpace
    \else \ifnum\lst@length=\z@
%    \end{macrocode}
% If the line is empty so far, we advance |\lst@lostspace|.
% Otherwise we append the space.
%    \begin{macrocode}
            \global\advance\lst@lostspace\lst@width
            \global\advance\lst@pos\m@ne
        \else
            \lst@AppendSpecialSpace
        \fi
    \fi \fi \fi}
%    \end{macrocode}
% Note that this version works for fixed and flexible column output.
% \end{macro}
%
% \begin{macro}{\lst@AppendSpecialSpace}
% Now the macro used above.
% If there are at least two spaces, i.e.\ if the last character has been a space, we output preceding characters and advance |\lst@lostspace| to avoid alignment problems.
% Otherwise we append a space to the current character string.
%    \begin{macrocode}
\def\lst@AppendSpecialSpace{%
    \ifx\lst@lastother\lst@outputspace
        \lst@OutputOther
        \global\advance\lst@lostspace\lst@width
        \global\advance\lst@pos\m@ne
    \else
        \lst@AppendOther\lst@outputspace
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{lstkey}{formfeed}
% is due to communication with \lsthelper{Jan~Braun}{1998/04/27}{formfeed}.
%    \begin{macrocode}
\lst@Key{formfeed}{\bigbreak}{\def\lst@formfeed{#1}}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{macro}{\lst@ProcessFormFeed}
% Here we either execute some macros or append them to |\lst@NewLine| --- according to whether a new line has already begun or not.
% This makes lines with form feeds `empty' if at the end of a listing.
%    \begin{macrocode}
\def\lst@ProcessFormFeed{%
    \lst@PrintToken
    \ifx\lst@NewLine\relax
        \lst@EOLUpdate \lst@formfeed
    \else
        \lst@lAddTo\lst@NewLine{\lst@EOLUpdate \lst@formfeed}%
    \fi}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Character tables}\label{iCharacterTables}
%
% Now comes the standard character table.
% For example, the package says |\lst@CCUse| |\lst@ProcessLetter|\ldots|{"41}{A}|\ldots\ to make the code $41_{\mathrm{hex}}$ character act as a letter.
% It expands to |\def| |A{\lst@ProcessLetter| |A}|, but the first A is active and the second not.
% \begin{macrosyntax}
% \item[0.19] |\lst@CCUse|\meta{class macro}\meta{$c_1$}\meta{$t_1$}\ldots\meta{$c_k$}\meta{$t_k$}|\z@\@empty|
% \item[0.20] |\lst@CCUseMacro|\meta{class$_1$}\meta{$c_1$}\meta{definition$_1$}\ldots|\@empty\z@\@empty|
% \end{macrosyntax}
%
% \begin{macro}{\lst@Def}
% \begin{macro}{\lst@Let}
% For speed we won't use these helpers too often.
% The letter A definition from above could be achieved via |\lst@Def{"41}{\lst@ProcessLetter A}|.
%    \begin{macrocode}
\def\lst@Def#1{\lccode`\~=#1\lowercase{\def~}}
\def\lst@Let#1{\lccode`\~=#1\lowercase{\let~}}
%    \end{macrocode}
% \end{macro}\end{macro}
%
% \begin{macro}{\lst@SaveDef}
% \begin{macro}{\lst@DefSaveDef}
% \begin{macro}{\lst@LetSaveDef}
% Save definition and/or make/assign new one.
%    \begin{macrocode}
\def\lst@SaveDef#1#2{%
    \begingroup \lccode`\~=#1\relax \lowercase{\endgroup\let#2~}}
\def\lst@DefSaveDef#1#2{%
    \begingroup \lccode`\~=#1\relax \lowercase{\endgroup\let#2~\def~}}
\def\lst@LetSaveDef#1#2{%
    \begingroup \lccode`\~=#1\relax \lowercase{\endgroup\let#2~\let~}}
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
%
% \begin{macro}{\lst@SelectStdCharTable}
% The first three standard characters.
%    \begin{macrocode}
\def\lst@SelectStdCharTable{%
    \lst@Let{9}\lst@ProcessTabulator
    \lst@Let{12}\lst@ProcessFormFeed
    \lst@Let{32}\lst@ProcessSpace}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@CCUse}
% extends the standard character table.
% The first argument gives the character class.
% Then each two following arguments are a `character code/\emph{printable} character' pair.
% We either append |\def#2{#1#3}| (where |#1| is |\lst@ProcessLetter| for example) or we gobble the two token after |\fi| to terminate the loop.
%    \begin{macrocode}
\def\lst@CCUse#1#2#3{%
    \ifnum#2=\z@
        \expandafter\@gobbletwo
    \else
        \lccode`\~=#2\lowercase{\lst@CCUse@~}{#1#3}%
    \fi
    \lst@CCUse#1}
\def\lst@CCUse@#1#2{\lst@lAddTo\lst@SelectStdCharTable{\def#1{#2}}}
%    \end{macrocode}
% Limitation:
% Each second argument to |\lst@CCUse| (beginning with the third) must be a single character.
% The reason is not the definition here.
% |\lst@AppendOther| says |\let\lst@lastother#1| and that works with the mentioned limitation only.
% I'll get over this since |\let| is faster than |\def|, and that's the motivation.
% \emph{Caution}: Don't change that |\let| to a definition with |\def|.
% All |\ifx\lst@lastother|\ldots\ in all character classes wouldn't work any more!
% And rewriting all this would slow down the package.
% Beware of that.
%
% Now we insert more standard characters.
%    \begin{macrocode}
\lst@CCUse \lst@ProcessOther
    {"21}!{"22}"{"27}'{"28}({"29}){"2B}+{"2C},{"2E}.{"2F}/
    {"3A}:{"3B};{"3D}={"3F}?{"5B}[{"5D}]{"60}{`}{"7F}-
    \z@\@empty
\lst@CCUse \lst@ProcessDigit
    {"30}0{"31}1{"32}2{"33}3{"34}4{"35}5{"36}6{"37}7{"38}8{"39}9
    \z@\@empty
\lst@CCUse \lst@ProcessLetter
    {"40}@%
    {"41}A{"42}B{"43}C{"44}D{"45}E{"46}F{"47}G{"48}H{"49}I{"4A}J
    {"4B}K{"4C}L{"4D}M{"4E}N{"4F}O{"50}P{"51}Q{"52}R{"53}S{"54}T
    {"55}U{"56}V{"57}W{"58}X{"59}Y{"5A}Z
    {"61}a{"62}b{"63}c{"64}d{"65}e{"66}f{"67}g{"68}h{"69}i{"6A}j
    {"6B}k{"6C}l{"6D}m{"6E}n{"6F}o{"70}p{"71}q{"72}r{"73}s{"74}t
    {"75}u{"76}v{"77}w{"78}x{"79}y{"7A}z
    \z@\@empty
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@CCUseMacro}
% Now we come to a delicate point.
% Some characters aren't printable (|_|, |$|, \ldots) or aren't printed well (|*|, |-|, \ldots) if we enter these characters.
% Thus we use macros which print the characters correctly.
% The restriction from above that |\lst@CCUse| must get printable characters is not true.
% In fact, we could also use macros or even arbitrary strings (enclosed in double braces), the latter in the case that they are treated as letters.
% But we would get in trouble with fast keyword tests:
% On the one hand the current character string is printable for speed (i.e.\ |_| is already replaced by a macro version), on the other hand the new keyword tests need the original characters (e.g.\ |_|).
%
% The solution:
% We define |\def _{\lst@ProcessLetter\lstum@_}| where the first underscore is active and the second belongs to the control sequence.
% Moreover we have |\def\lstum@_{\lst@UM _}| where the second underscore has the usual meaning.
% Now the keyword tests can access the original character simply by making |\lst@UM| empty.
% The default definition gets the following token and builds the control sequence |\lstum@_@|, which we'll define to print the character properly.
%
% The following definition does all this for us.
% The first parameter gives the character class, the second the character code, and the last the definition which actually prints the character.
% We build the names |\lstum@_| and |\lstum@_@| and give them to a submacro.
%    \begin{macrocode}
\def\lst@CCUseMacro#1#2#3{%
    \ifnum#2=\z@ \else
        \begingroup\lccode`\~=#2\relax \lccode`\/=#2\relax
        \lowercase{\endgroup\expandafter\lst@CCUseMacro@
            \csname lstum@/\expandafter\endcsname
            \csname lstum@/@\endcsname /~}#1{#3}%
        \expandafter\lst@CCUseMacro
    \fi}
%    \end{macrocode}
% The arguments to this submacro are |\lstum@_|, |\lstum@_@|, nonactive character, active character, character class and printing definition.
% We add |\def| |_| |{\lst@ProcessLetter\lstum@_}| to |\lst@SelectStdCharTable| (and similarly other special characters), define |\def\lstum@_{\lst@UM _}| and |\lstum@_@|.
%    \begin{macrocode}
\def\lst@CCUseMacro@#1#2#3#4#5#6{%
    \lst@lAddTo\lst@SelectStdCharTable{\def#4{#5#1}}%
    \def#1{\lst@UM#3}%
    \def#2{#6}}
%    \end{macrocode}
% The default definition of |\lst@UM|:
%    \begin{macrocode}
\def\lst@UM#1{\csname lstum@#1@\endcsname}
%    \end{macrocode}
% And all remaining standard characters.
%    \begin{macrocode}
\lst@CCUseMacro
    \lst@ProcessOther{"23}\#
    \lst@ProcessLetter{"24}\textdollar
    \lst@ProcessOther{"25}\%
    \lst@ProcessOther{"26}\&
    \lst@ProcessOther{"2A}{\lst@ttfamily*\textasteriskcentered}
    \lst@ProcessOther{"2D}{\lst@ttfamily{-{}}{$-$}}
    \lst@ProcessOther{"3C}{\lst@ttfamily<\textless}
    \lst@ProcessOther{"3E}{\lst@ttfamily>\textgreater}
    \lst@ProcessOther{"5C}{\lst@ttfamily{\char92}\textbackslash}
    \lst@ProcessOther{"5E}\textasciicircum
    \lst@ProcessOther{"7B}{\lst@ttfamily{\char123}\textbraceleft}
    \lst@ProcessOther{"7C}{\lst@ttfamily|\textbar}
    \lst@ProcessOther{"7D}{\lst@ttfamily{\char125}\textbraceright}
    \lst@ProcessOther{"7E}\textasciitilde
    \lst@ProcessLetter{"5F}{\lst@ttfamily{\char95}\textunderscore}
    \@empty\z@\@empty
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@ttfamily}
% What is this ominous macro?
% It prints either the first or the second argument.
% In |\ttfamily| it ensures that |----| is typeset |----| and not $-$$-$$-$$-$ as in version 0.17.
% Bug encountered by \lsthelper{Dr.~Jobst~Hoffmann}{1998/03/30}{\lst@minus\ and \ttfamily}.
%    \begin{macrocode}
\def\lst@ttfamily#1#2{\ifx\f@family\ttdefault#1\else#2\fi}
%    \end{macrocode}
% |\ttdefault| is defined |\long|, so the |\ifx| doesn't work since |\f@family| isn't |\long|!
% We go around this problem by redefining |\ttdefault| locally:
%    \begin{macrocode}
\lst@AddToHook{Init}{\edef\ttdefault{\ttdefault}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@SaveOutputDef}
% We look for |\def| `active character |#1|' in |\lst@SelectStdCharTable|, get the replacement text, strip off the character class (via |\@gobble|), and assign the meaning.
% Note that you get a ``runaway argument'' error if an illegal \meta{character code}=|#1| is used.
%    \begin{macrocode}
\def\lst@SaveOutputDef#1#2{%
    \begingroup \lccode`\~=#1\relax \lowercase{%
    \def\lst@temp##1\def~##2##3\relax}{%
        \global\expandafter\let\expandafter#2\@gobble##2\relax}%
    \expandafter\lst@temp\lst@SelectStdCharTable\relax
    \endgroup}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstum@backslash}
% a commonly used character.
%    \begin{macrocode}
\lst@SaveOutputDef{"5C}\lstum@backslash
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@ifactivechars}
% A simple switch.
%    \begin{macrocode}
\def\lst@activecharstrue{\let\lst@ifactivechars\iftrue}
\def\lst@activecharsfalse{\let\lst@ifactivechars\iffalse}
\lst@activecharstrue
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@SelectCharTable}
% We select the standard character table, define extended characters 128--255, call a hook and initialize the backslash if necessary.
%    \begin{macrocode}
\def\lst@SelectCharTable{%
    \lst@SelectStdCharTable
    \lst@ifec \lst@DefEC \fi
    \lst@ifactivechars
        \catcode9\active \catcode12\active \catcode13\active
        \@tempcnta=32\relax
        \@whilenum\@tempcnta<128\do
            {\catcode\@tempcnta\active\advance\@tempcnta\@ne}%
    \fi
    \lsthk@SelectCharTable
    \lst@DeveloperSCT
    \ifx\lst@Backslash\relax\else
        \lst@LetSaveDef{"5C}\lsts@backslash\lst@Backslash
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{lstkey}{SelectCharTable}
% \begin{lstkey}{MoreSelectCharTable}
% The keys to adjust |\lst@DeveloperSCT|.
%    \begin{macrocode}
\lst@Key{SelectCharTable}{}{\def\lst@DeveloperSCT{#1}}
\lst@Key{MoreSelectCharTable}\relax{\lst@lAddTo\lst@DeveloperSCT{#1}}
%    \end{macrocode}
%    \begin{macrocode}
\lst@AddToHook{SetLanguage}{\let\lst@DeveloperSCT\@empty}
%    \end{macrocode}
% \end{lstkey}\end{lstkey}
%
% \begin{macro}{\lst@nfss@catcodes}
% \lsthelper{Anders~Edenbrandt}{1997/04/22}{preload of .fd files} found a bug with \texttt{.fd} files.
% Since we change catcodes and these files are read on demand, we must reset the catcodes before the files are input.
% We use a local redefinition of |\nfss@catcodes|.
%    \begin{macrocode}
\lst@AddToHook{Init}
    {\let\lsts@nfss@catcodes\nfss@catcodes
     \let\nfss@catcodes\lst@nfss@catcodes}
%    \end{macrocode}
%    \begin{macrocode}
\def\lst@nfss@catcodes{%
    \lst@makeletter
        ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\relax
    \@makeother 0\@makeother 1\@makeother 2\@makeother 3\@makeother 4%
    \@makeother 5\@makeother 6\@makeother 7\@makeother 8\@makeother 9%
    \lsts@nfss@catcodes}
%    \end{macrocode}
% The name of |\lst@makeletter| is an imitation of \LaTeX's |\@makeother|.
%    \begin{macrocode}
\def\lst@makeletter#1{%
    \ifx\relax#1\else\catcode`#111\relax \expandafter\lst@makeletter\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{lstkey}{alsoletter}
% \begin{lstkey}{alsodigit}
% \begin{lstkey}{alsoother}
% Three easy definitions.
%    \begin{macrocode}
\lst@Key{alsoletter}\relax{\lst@DefOther\lst@arg{#1}%
    \expandafter\lstalso@\lst@also \lst@arg\@empty\@empty}
\lst@Key{alsodigit}\relax{\lst@DefOther\lst@arg{#1}%
    \expandafter\lstalso@\lst@also \@empty\lst@arg\@empty}
\lst@Key{alsoother}\relax{\lst@DefOther\lst@arg{#1}%
    \expandafter\lstalso@\lst@also \@empty\@empty\lst@arg}
%    \end{macrocode}
% The submacro replaces one of the first three arguments by the first nonempty of |#4|, |#5| and |#6|.
%    \begin{macrocode}
\def\lstalso@#1#2#3#4#5#6{%
    \ifx#4\@empty \ifx#5\@empty \ifx#6\@empty \else
        \edef\lst@also{{#1}{#2}{#6}}%
    \fi\else
        \edef\lst@also{{#1}{#5}{#3}}%
    \fi\else
        \edef\lst@also{{#4}{#2}{#3}}%
    \fi}
%    \end{macrocode}
%    \begin{macrocode}
\lst@AddToHook{SetLanguage}{\def\lst@also{{}{}{}}}
%    \end{macrocode}
% \end{lstkey}\end{lstkey}\end{lstkey}
%
% \begin{macro}{\lst@UseBasicClasses}
% We insert the three arguments from |\lst@also| and merge three new arguments.
%    \begin{macrocode}
\def\lst@UseBasicClasses{\expandafter\lst@UBC@\lst@also}
\def\lst@UBC@#1#2#3#4#5#6{\def\lst@also{{#1#4}{#2#5}{#3#6}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@ChangeBasicClasses}
% Now a definition which actually moves the specified characters to the (implicit) given classes.
%    \begin{macrocode}
\lst@AddToHook{SelectCharTable}
    {\expandafter\lst@ChangeBasicClasses\lst@also}
\def\lst@ChangeBasicClasses#1#2#3{%
    \lst@CBC@\lst@ProcessOther#3\relax
    \lst@CBC@\lst@ProcessDigit#2\relax
    \lst@CBC@\lst@ProcessLetter#1\relax}
%    \end{macrocode}
% The submacro terminates if it reaches |\relax|.
% Otherwise we insert the new class macro |#1|; the submacro gobbles the old class and prevents the second argument from expansion.
% The |\lowercase| makes the character |#2| active.
%    \begin{macrocode}
\def\lst@CBC@#1#2{%
    \ifx\relax#2\expandafter\@gobbletwo \else
        \lccode`\~=`#2\lowercase
        {\edef~{\noexpand#1\expandafter\lst@CBC@@~}}%
    \fi
    \lst@CBC@#1}
\def\lst@CBC@@#1#2{\noexpand#2}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{National characters}
%
% \begin{lstkey}{extendedchars}
% The user key.
%    \begin{macrocode}
\lst@Key{extendedchars}{false}[t]{\lstKV@SetIf{#1}\lst@ifec}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{macro}{\lst@DefEC}
% Currently each character in the range 128--255 is treated as a letter.
%    \begin{macrocode}
\def\lst@DefEC{%
   \lst@CCECUse \lst@ProcessLetter
      ^^80^^81^^82^^83^^84^^85^^86^^87^^88^^89^^8a^^8b^^8c^^8d^^8e^^8f%
      ^^90^^91^^92^^93^^94^^95^^96^^97^^98^^99^^9a^^9b^^9c^^9d^^9e^^9f%
      ^^a0^^a1^^a2^^a3^^a4^^a5^^a6^^a7^^a8^^a9^^aa^^ab^^ac^^ad^^ae^^af%
      ^^b0^^b1^^b2^^b3^^b4^^b5^^b6^^b7^^b8^^b9^^ba^^bb^^bc^^bd^^be^^bf%
      ^^c0^^c1^^c2^^c3^^c4^^c5^^c6^^c7^^c8^^c9^^ca^^cb^^cc^^cd^^ce^^cf%
      ^^d0^^d1^^d2^^d3^^d4^^d5^^d6^^d7^^d8^^d9^^da^^db^^dc^^dd^^de^^df%
      ^^e0^^e1^^e2^^e3^^e4^^e5^^e6^^e7^^e8^^e9^^ea^^eb^^ec^^ed^^ee^^ef%
      ^^f0^^f1^^f2^^f3^^f4^^f5^^f6^^f7^^f8^^f9^^fa^^fb^^fc^^fd^^fe^^ff%
      ^^00}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@CCECUse}
% Reaching end of list (|^^00|) we terminate the loop.
% Otherwise we do the same as in |\lst@CCUse| if the character is not active.
% But if the character is active, we save the meaning before redefinition.
%    \begin{macrocode}
\def\lst@CCECUse#1#2{%
    \ifnum`#2=\z@
        \expandafter\@gobbletwo
    \else
        \ifnum\catcode`#2=\active
            \lccode`\~=`#2\lccode`\/=`#2\lowercase{\lst@CCECUse@#1~/}%
        \else
            \lst@ifactivechars \catcode`#2=\active \fi
            \lccode`\~=`#2\lowercase{\def~}{#1#2}%
        \fi
    \fi
    \lst@CCECUse#1}
%    \end{macrocode}
% We save the meaning before redefinition as mentioned.
%    \begin{macrocode}
\def\lst@CCECUse@#1#2#3{%
   \expandafter\let\csname lst@EC#3\endcsname #2%
   \edef#2{\noexpand#1\expandafter\noexpand\csname lst@EC#3\endcsname}}
%    \end{macrocode}
% $\Omega$ support looks easy --- I hope it works at least in some cases.
%    \begin{macrocode}
\@ifundefined{ocp}{}
    {\lst@AddToHook{OutputBox}{\lsthk@OmegaOutputBox}
     \lst@AddToHook{OmegaOutputBox}{}}
%    \end{macrocode}
%    \begin{macrocode}
%</kernel>
%    \end{macrocode}
% \end{macro}
%
% \begin{aspect}{unused}
% This is a completely untested aspect.
% The detection of unicode characters (here $\approx$ unicode $\setminus$ $\{\mathrm{chr}(32),\ldots,\mathrm{chr}(126)\}$) can only work if these characters are not active in the sense of \TeX.
% After usual character processing we look at the next character:
% We have nothing to do if it's active, otherwise we get that character and process it as a letter.
%    \begin{macrocode}
%<*unused>
\lst@BeginAspect{}
%    \end{macrocode}
%
% \begin{lstkey}{unicode}
% The key and \hookname{SelectCharTable} material.
%    \begin{macrocode}
\lst@Key{unicode}f[t]{\lstKV@SetIf{#1}\lst@ifunicode}
\lst@AddToHook{SelectCharTable}
    {\lst@ifunicode
         \lst@UnicodeAdaptA\lst@ProcessLetter\lsts@ProcessLetter
         \lst@UnicodeAdaptA\lst@ProcessOther\lsts@ProcessOther
         \lst@UnicodeAdaptA\lst@ProcessDigit\lsts@ProcessDigit
         \lst@UnicodeAdaptB\lst@ProcessTabulator\lsts@ProcessTabulator
         \lst@UnicodeAdaptB\lst@ProcessSpace\lsts@ProcessSpace
         \lst@UnicodeAdaptB\lst@ProcessFormFeed\lsts@ProcessFormFeed
     \fi}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{macro}{\lst@UnicodeAdaptA}
% \begin{macro}{\lst@UnicodeAdaptB}
% The new `process whatever' definition executes the old definition and tests the next character.
%    \begin{macrocode}
\gdef\lst@UnicodeAdaptA#1#2{\let#2#1\def#1##1{#2##1\lst@UnicodeTest}}
\gdef\lst@UnicodeAdaptB#1#2{\let#2#1\def#1{#2\lst@UnicodeTest}}
%    \end{macrocode}
% \end{macro}\end{macro}
%
% \begin{macro}{\lst@UnicodeTest}
% Nonactive characters are processed as letters.
%    \begin{macrocode}
\gdef\lst@UnicodeTest{\lst@XIfNextCharActive{}\lst@ProcessLetter}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@XIfNextCharActive}
% is a modification of |\lst@IfNextCharActive|:
% A control sequence is treated as active character.
%    \begin{macrocode}
\gdef\lst@XIfNextCharActive#1#2#3{%
    \if\relax\noexpand#3%
        \def\lst@next{#1}%
    \else
        \lccode`\~=`#3\lowercase{\ifx~}#3%
            \def\lst@next{#1}%
        \else
            \def\lst@next{#2}%
        \fi
    \fi
    \lst@next #3}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</unused>
%    \end{macrocode}
% \end{aspect}
%
%
% \subsection{Stringizer}
%
% \begin{aspect}{strings}
% Just starting a new aspect.
%    \begin{macrocode}
%<*strings>
\lst@BeginAspect{strings}
%    \end{macrocode}
%
% \begin{macro}{\lst@legalstringizer}
% Currently there are three different stringizer types: `d'oubled, `b'ackslashed and `m'atlabed.
% The naming of the first two is due to how the stringizer is represented in a string.
% Pascal doubles it, i.e.\ the string |'| is represented by four single quotes |''''|, where the first and last enclose the string and the two middle quotes represent the desired stringizer.
% In C++ we would write |"\""|: A backslash indicates that the next double quote belongs to the string and is not the end of string.
% The matlabed version is described below.
% I introduced it after communication with \lsthelper{Zvezdan~V.~Petkovic}{1997/11/26}{`single stringizer' not a stringizer in Ada (and Matlab)}.
%    \begin{macrocode}
\gdef\lst@legalstringizer{d,b,m,bd,db}
%    \end{macrocode}
% Furthermore we have the two mixed types |bd| and |db|, which in fact equal |b|.
% \end{macro}
%
% \begin{lstkey}{stringizer}
% Here we test whether the user type is supported or not --- the latter leading to an error message.
% Otherwise we (re-) define |\lst@DefStrings| after building the name |\lst@ProcessStringizer@|\meta{type}.
%    \begin{macrocode}
\lst@Key{stringizer}\relax{\lstKV@OptArg[d]{#1}%
    {\lst@IfOneOf##1\relax \lst@legalstringizer
         {\expandafter\def\expandafter\lst@DefStrings
          \expandafter{\expandafter\lst@Stringizer\csname
              lst@ProcessStringizer@##1\endcsname ##2\@empty}}%
         {\PackageError{Listings}{Illegal stringizer type `##1'}%
          {Available types are \lst@legalstringizer.}}}}
\lst@AddToHook{SetLanguage}{\let\lst@DefStrings\@empty}
\lst@AddToHook{SelectCharTable}{\lst@DefStrings}
%    \end{macrocode}
% The just added hook defines the strings after selecting the standard character table.
% This adjusts the character table to the user's demands.
% \end{lstkey}
%
% \begin{macro}{\lst@Stringizer}
% This macro is similar to |\lst@CCECUse|.
% The list of stringizer is terminated by |\@empty|.
%    \begin{macrocode}
\gdef\lst@Stringizer#1#2{%
    \ifx\@empty#2%
        \expandafter\@gobbletwo
%    \end{macrocode}
% We save the old meaning in |\lsts@s|\meta{the character} (catcode 12) and redefine it.
%    \begin{macrocode}
    \else
        \lccode`\~=`#2\lccode`\/=`#2\lowercase{%
            \expandafter\let\csname lsts@s/\endcsname~%
            \def~{#1/}}%
    \fi
    \lst@Stringizer#1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@stringmode}
% Before defining all `process stringizer' macros, we allocate a new mode.
%    \begin{macrocode}
\lst@NewMode\lst@stringmode
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@ProcessStringizer@d}
% `d' means no extra work.
% Reaching the (first) stringizer enters string mode and coming to the next leaves it, and so on.
% Then the character sequence |''''| produces the right output:
% The second quote leaves string mode, but we enter it immediately since the stringizer is doubled.
% And now the implementation.
% First we output any preceding letters.
%    \begin{macrocode}
\gdef\lst@ProcessStringizer@d#1{%
    \lst@ifletter \lst@Output\lst@letterfalse \fi
%    \end{macrocode}
% If we already process a string, we execute the saved meaning and look whether the last other (that's the stringizer) is the matching stringizer --- a single quote must not end a string starting with a double quote.
% The macro |\lst@EndString| is defined at the end of this section.
%    \begin{macrocode}
    \ifnum\lst@mode=\lst@stringmode
        \csname lsts@s#1\endcsname
        \ifx\lst@lastother\lst@closestring
            \lst@EndString
        \fi
    \else
        \lst@OutputOther
%    \end{macrocode}
% If we don't process a string, we test whether or not a string is allowed.
% |\lst@BeginString| enters string mode and defines the closing stringizer.
% This `begin string' macro gets one argument, hence we expand the control sequence name before executing the macro (if necessary).
%    \begin{macrocode}
        \lst@ifmode\else
            \expandafter\expandafter\expandafter\lst@BeginString
        \fi
        \csname lsts@s#1\endcsname
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@ProcessStringizer@b}
% `b' means an extra if: Only if the last other is not a backslash (5-th line) the stringizer can close the string.
% The rest is the same as above.
%    \begin{macrocode}
\gdef\lst@ProcessStringizer@b#1{%
    \lst@ifletter \lst@Output\lst@letterfalse \fi
    \ifnum\lst@mode=\lst@stringmode
        \let\lst@temp\lst@lastother \csname lsts@s#1\endcsname
        \ifx\lst@temp\lstum@backslash\else
        \ifx\lst@lastother\lst@closestring
            \lst@EndString
        \fi \fi
    \else
        \lst@OutputOther
        \lst@ifmode\else
            \expandafter\expandafter\expandafter\lst@BeginString
        \fi
        \csname lsts@s#1\endcsname
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@ProcessStringizer@bd}
% \begin{macro}{\lst@ProcessStringizer@db}
% are just the same and the same as |\lst@ProcessStringizer@b|:
%    \begin{macrocode}
\global\let\lst@ProcessStringizer@bd\lst@ProcessStringizer@b
\global\let\lst@ProcessStringizer@db\lst@ProcessStringizer@bd
%    \end{macrocode}
% \end{macro}\end{macro}
%
% \begin{macro}{\lst@ProcessStringizer@m}
% `M'atlabed is designed for programming languages where stringizers (for character or string literals) are also used for other purposes, like Matlab or Ada.
% Here we enter string mode only if the last character has not been a letter and has not been a right parenthesis.
% Hence, we have to move the |\lst@ifletter| and change the main |\else| part.
% By the way: The stringizer is doubled in a string.
%    \begin{macrocode}
\gdef\lst@ProcessStringizer@m#1{%
    \ifnum\lst@mode=\lst@stringmode
        \lst@ifletter \lst@Output\lst@letterfalse \fi
        \csname lsts@s#1\endcsname
        \ifx\lst@lastother\lst@closestring
            \lst@EndString
        \fi
    \else
%    \end{macrocode}
% And now the real `m' changes:
%    \begin{macrocode}
        \lst@ifletter
            \lst@Output\lst@letterfalse
        \else
            \lst@OutputOther
            \let\lst@CCnext\relax
            \ifx\lst@lastother)\else \lst@ifmode\else
                \let\lst@CCnext\lst@BeginString
            \fi \fi
            \expandafter\expandafter\expandafter\lst@CCnext
        \fi
        \csname lsts@s#1\endcsname
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begingroup
% Some more special code without explanation.
%    \begin{macrocode}
\lst@AddToHook{OmegaOutputBox}
    {\let\lst@ProcessStringizer@b\@firstofone
     \let\lst@ProcessStringizer@d\@firstofone
     \let\lst@ProcessStringizer@m\@firstofone
     \let\lst@ProcessStringizer@bd\@firstofone
     \let\lst@ProcessStringizer@db\@firstofone}
%    \end{macrocode}
% \endgroup
%
% \begin{lstkey}{stringstyle}
% \begin{lstkey}{stringspaces}
% Thanks to \lsthelper{Knut~M\"uller}{1997/04/28}{\blankstringtrue} for reporting problem with |\blankstringtrue| (which now is |stringspaces=false|).
% The problem has gone.
%    \begin{macrocode}
\lst@Key{stringstyle}{}{\def\lst@stringstyle{#1}}
\lst@Key{stringspaces}{true}[t]{\lstKV@SetIf{#1}\lst@ifstringspaces}
\lst@AddToHook{EmptyStyle}{\let\lst@stringstyle\@empty}
%    \end{macrocode}
% \end{lstkey}\end{lstkey}
%
% \begin{macro}{\lst@BeginString}
% \begin{macro}{\lst@EndString}
% To activate string mode we do the usual things, but here we also assign the correct closing stringizer and |\lst@outputspace|.
% Note that |\lst@NewLine| deactivates itself.
%    \begin{macrocode}
\gdef\lst@BeginString#1{%
    \lst@NewLine
    \lst@EnterMode{\lst@stringmode}{\lst@modetrue\lst@stringstyle}%
    #1%
    \let\lst@closestring\lst@lastother
    \lst@ifstringspaces
        \lst@keepspacestrue
        \let\lst@outputspace\lst@visiblespace
    \fi}
\gdef\lst@keepspacestrue{\let\lst@ifkeepspaces\iftrue}
%    \end{macrocode}
% We terminate that mode selection after printing the collected other characters --- at least the closing stringizer.
% And we reset some registers.
%    \begin{macrocode}
\gdef\lst@EndString{%
    \lst@OutputOther \lst@LeaveMode
    \lst@token{}\lst@length\z@}
%    \end{macrocode}
% \end{macro}\end{macro}
%
% \begin{lstkey}{stringtest}
% We |\let| the test macro |\relax| if necessary.
%    \begin{macrocode}
\lst@Key{stringtest}\relax[t]{\lstKV@SetIf{#1}\lst@ifstringtest}
\lst@AddToHook{SetLanguage}{\let\lst@ifstringtest\iftrue}
\lst@AddToHook{Init}
    {\lst@ifstringtest\else \let\lst@TestStringMode\relax \fi}
%    \end{macrocode}
% Default definition of the test macro:
%    \begin{macrocode}
\gdef\lst@TestStringMode{%
     \ifnum\lst@mode=\lst@stringmode
         \PackageWarning{Listings}{String constant exceeds line}%
         \lst@LeaveMode \lst@token{}\lst@length\z@
     \fi}
\lst@AddToHook{EOL}{\lst@TestStringMode}
%    \end{macrocode}
% \end{lstkey}
%
%    \begin{macrocode}
\lst@EndAspect
%</strings>
%    \end{macrocode}
% \end{aspect}
%
%
% \subsection{Comments}
%
% \begin{aspect}{comments}
% That's what we are working on.
%    \begin{macrocode}
%<*comments>
\lst@BeginAspect{comments}
%    \end{macrocode}
%
% \begin{macro}{\lst@CommentB}
% We save the meaning of \meta{1st}=|#1| in \meta{save 1st}=|#4|.
%    \begin{macrocode}
\gdef\lst@CommentB#1#2#3#4#5#6#7#8#9{%
    \let#4#1%
    \ifx\@empty#2\@empty
%    \end{macrocode}
% If a single character indicates a comment, the next operation is either |\relax| (since no mode change is allowed) or |\lst@BeginComment|.
% And we execute the saved character meaning.
%    \begin{macrocode}
        \def#1{%
            #6\let\lst@bnext\relax
            \lst@ifmode #7\else
                #8%
                \def\lst@bnext{\lst@BeginComment#5#9}%
            \fi
            \lst@bnext #4}%
    \else \ifx\@empty#3\@empty
%    \end{macrocode}
% Comments indicated by a sequence of two characters are just the same.
% But: We enter comment mode (if and) only if the next character equals |#2|.
% And we use a different macro to enter comment mode.
%    \begin{macrocode}
        \def#1##1{%
            #6\let\lst@bnext\relax
            \ifx##1#2%
                \lst@ifmode #7\else
                    #8%
                    \def\lst@bnext{\lst@@BeginComment#5#9}%
                \fi
            \fi
            \lst@bnext#4##1}%
    \else
%    \end{macrocode}
% Comments indicated by an arbitrary character sequence are somewhat different since we don't know how many characters to read ahead.
% Thus we use |\lst@IfNextChars| here.
% The rest is not new at all, but note that we expand the string |\lst@eaten| only if necessary.
% Note that the third argument to |\lst@IfNextChars| is the single |\lst@bnext|.
%    \begin{macrocode}
        \def#1{%
            #6\def\lst@bnext{\expandafter#4\lst@eaten}%
            \lst@IfNextCharsArg{#2#3}%
            {\lst@ifmode #7\else
                 #8%
                 \def\lst@bnext{\lst@@BeginComment#5#9#4\lst@eaten}%
             \fi
             \lst@bnext}\lst@bnext}%
    \fi \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@CommentE}
% Here we insert |\ifnum\lst@mode=#5| (6-th line), where |#5| is |\lst@SCmode| for example.
% This ensures that comment delimiters match each other.
%    \begin{macrocode}
\gdef\lst@CommentE#1#2#3#4#5#6#7#8{%
    \let#4#1%
    \ifx\@empty#2\@empty
        \def#1{%
            #6\let\lst@enext#4%
            \ifnum\lst@mode=#5%
                #7%
                \def\lst@enext{#4\lst@EndComment}%
            \else
                #8%
            \fi
            \lst@enext}%
    \else \ifx\@empty#3\@empty
        \def#1##1{%
            #6\def\lst@enext{#4##1}%
            \ifx##1#2%
                \ifnum\lst@mode=#5%
                    #7%
                    \def\lst@enext{#4##1\lst@EndComment}%
                \else
                    #8%
                \fi
            \fi
            \lst@enext}%
    \else
        \def#1{%
            #6\def\lst@enext{\expandafter#4\lst@eaten}%
            \lst@IfNextCharsArg{#2#3}%
            {\ifnum\lst@mode=#5%
                 #7%
                 \def\lst@enext{#4\lst@eaten\lst@EndComment}%
             \else
                 #8%
             \fi
             \lst@enext}\lst@enext}%
    \fi \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@BeginComment}
% \begin{macro}{\lst@@BeginComment}
% \begin{macro}{\lst@EndComment}
% We print preceding characters (if any), begin the comment and output the comment separator.
% The temporary mode change ensures that the characters can't end the current comment or start a new one.
%    \begin{macrocode}
\gdef\lst@BeginComment#1#2#3{%
    \lst@NewLine \lst@PrintToken
    \lst@EnterMode{#1}{\lst@modetrue\lst@commentstyle#2}%
    \lst@mode\lst@nomode #3\lst@mode#1\relax
    \lsthk@AfterBeginComment}
%    \end{macrocode}
%    \begin{macrocode}
\gdef\lst@@BeginComment#1#2#3#4{%
    \lst@NewLine \lst@PrintToken
    \lst@EnterMode{#1}{\lst@modetrue\lst@commentstyle#2}%
    \lst@mode\lst@nomode #3#4\lst@mode#1\relax
    \lsthk@AfterBeginComment}
%    \end{macrocode}
%    \begin{macrocode}
\gdef\lst@EndComment{%
    \lst@PrintToken \lst@LeaveMode
    \let\lst@lastother\@empty}
%    \end{macrocode}
%    \begin{macrocode}
\lst@AddToHook{AfterBeginComment}{}
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
%
% \begin{macro}{\@gobblethree}
% is defined if and only if undefined.
%    \begin{macrocode}
\@ifundefined{@gobblethree}{\gdef\@gobblethree#1#2#3{}}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{lstkey}{commentstyle}
% The first user key in this section.
%    \begin{macrocode}
\lst@Key{commentstyle}{}{\def\lst@commentstyle{#1}}
\lst@AddToHook{EmptyStyle}{\let\lst@commenstyle\itshape}
%    \end{macrocode}
% \end{lstkey}
%
% \begingroup
% Finally some initialization:
% The comments are reset every language selection, and every listing we define the comment characters after selecting the standard character table.
% These macros are redefined by the comment keys.
%    \begin{macrocode}
\lst@AddToHook{SetLanguage}
    {\let\lst@DefSC\@empty \let\lst@DefNC\@empty \let\lst@DefDC\@empty
     \let\lst@DefCL\@empty \let\lst@DefFCL\@empty}
\lst@AddToHook{SelectCharTable}
    {\lst@DefSC \lst@DefNC \lst@DefDC \lst@DefCL \lst@DefFCL}
\lst@AddToHook{Init}
    {\let\lst@CCnext\relax \let\lst@bnext\relax\let\lst@enext\relax}
%    \end{macrocode}
% \endgroup
%
%
% \subsubsection{Comment lines}
%
% \begin{lstkey}{commentline}
% The user key.
% |\lst@CArg| inserts some arguments behind |\lst@CommentB|, which actually defines the comment characters.
%    \begin{macrocode}
\lst@Key{commentline}{}
  {\ifx\@empty#1\@empty
       \let\lst@DefCL\@empty
   \else
       \def\lst@DefCL{\lst@CArg{CL}#1\relax
           \lst@CommentB\lst@CLmode{}{}{}\@empty}%
   \fi}
%    \end{macrocode}
%    \begin{macrocode}
\lst@NewMode\lst@CLmode
\lst@AddToHook{EOL}{\ifnum\lst@mode=\lst@CLmode \lst@LeaveMode \fi}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{lstkey}{fixedcommentline}
% Another user key.
%    \begin{macrocode}
\lst@Key{fixedcommentline}{}{\lstKV@OptArg[0]{#1}%
  {\ifx\@empty##1\@empty
       \let\lst@DefFCL\@empty
   \else
       \def\lst@DefFCL{\lst@FixedCL[##1]##2\@empty}%
   \fi}}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{macro}{\lst@FixedCL}
% The loop is terminated by |\@empty|.
% We enter comment mode (if and) only if the character is in column |#3|+1.
%    \begin{macrocode}
\gdef\lst@FixedCL[#1]#2{%
    \ifx\@empty#2\@empty\else
        \lst@CArg{FCL}#2\relax\lst@CommentB\lst@CLmode{}{}%
            {\lst@CalcLineLength
             \ifnum\@tempcnta=#1\else
                \expandafter\@gobblethree
             \fi}
            \@empty
        \def\lst@next{\lst@FixedCL[#1]}%
        \expandafter\lst@next
    \fi}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Single and double comments}
%
% \begin{lstkey}{singlecomment}
% \begin{lstkey}{doublecomment}
% Define the user keys \ldots
%    \begin{macrocode}
\lst@Key{singlecomment}{}{\lstKV@TwoArg{#1}%
  {\ifx\@empty##2\@empty
       \let\lst@DefSC\@empty
   \else
       \def\lst@DefSC{%
           \lst@CArg{BC}##1\relax\lst@CommentB\lst@SCmode{}{}{}\@empty
           \lst@CArg{EC}##2\relax\lst@CommentE\lst@SCmode{}{}{}}%
   \fi}}
%    \end{macrocode}
%    \begin{macrocode}
\lst@Key{doublecomment}{}{\lstKV@FourArg{#1}%
  {\ifx\@empty##4\@empty
       \let\lst@DefDC\@empty
   \else
       \def\lst@DefDC{%
           \lst@CArg{BCA}##1\relax\lst@CommentB\lst@DCAmode{}{}{}\@empty
           \lst@CArg{BCB}##3\relax\lst@CommentB\lst@DCBmode{}{}{}\@empty
           \lst@CArg{ECA}##2\relax\lst@CommentE\lst@DCAmode{}{}{}%
           \lst@CArg{ECB}##4\relax\lst@CommentE\lst@DCBmode{}{}{}}%
   \fi}}
%    \end{macrocode}
% \end{lstkey}\end{lstkey}
%
% \begin{macro}{\lst@SCmode}
% \begin{macro}{\lst@DCAmode}
% \begin{macro}{\lst@DCBmode}
% and allocate new internal modes.
%    \begin{macrocode}
\lst@NewMode\lst@SCmode \lst@NewMode\lst@DCAmode\lst@NewMode\lst@DCBmode
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
%
%
% \subsubsection{Nested comments}
%
% \begin{lstkey}{nestedcomment}
% Define new mode and the user key.
%    \begin{macrocode}
\lst@NewMode\lst@NCmode
\lst@Key{nestedcomment}{}{\lstKV@TwoArg{#1}%
  {\let\lst@DefNC\@empty
   \ifx\@empty##2\@empty\else
      \def\@tempa{##1}\def\@tempb{##2}%
      \ifx\@tempa\@tempb
         \PackageError{Listings}{Identical delimiters}%
         {These delimiters make no sense with nested comments.}%
      \else
         \def\lst@DefNC{%
             \lst@CArg{BNC}##1\relax\lst@CommentB\lst@NCmode
                 {}%
                 {\ifnum\lst@mode=\lst@NCmode \expandafter\@gobble \fi}%
                 {}\@empty
             \lst@CArg{ENC}##2\relax\lst@CommentE\lst@NCmode{}{}{}}%
      \fi
   \fi}}
%    \end{macrocode}
% \end{lstkey}
%
%    \begin{macrocode}
\lst@EndAspect
%</comments>
%    \end{macrocode}
% \end{aspect}
%
%
% \subsubsection{PODs}
%
% \begin{lstkey}{printpod}
% \begin{lstkey}{podcomment}
% We begin with the user keys, which I introduced after communication with \lsthelper{Michael~Piotrowski}{1997/11/11}{printpod}.
%    \begin{macrocode}
%<*pod>
\lst@BeginAspect{pod}
\lst@Key{printpod}{false}[t]{\lstKV@SetIf{#1}\lst@ifprintpod}
\lst@Key{podcomment}{false}[t]{\lstKV@SetIf{#1}\lst@ifpodcomment}
\lst@AddToHookExe{SetLanguage}{\let\lst@ifpodcomment\iffalse}
%    \end{macrocode}
% We adjust some characters if the user has selected |podcomment=true|.
%    \begin{macrocode}
\lst@NewMode\lst@PODmode
\lst@AddToHook{SelectCharTable}
    {\lst@ifpodcomment
         \lst@CArg{POD}=\relax\lst@CommentB\lst@PODmode
           {}{}%
%    \end{macrocode}
% The following code is executed if we've found an equality sign and haven't entered a mode (in fact if mode changes are allowed):
% We `begin drop output' and gobble the usual begin of comment sequence (via |\@goblethree|) if PODs shouldn't be printed.
% Moreover we gobble it if the current column number is not one --- |\@tempcnta| is valued below.
%    \begin{macrocode}
           {\ifnum\@tempcnta=\z@
                \lst@ifprintpod\else
                    \def\lst@bnext{\lst@BeginDropOutput\lst@PODmode}%
                    \expandafter\expandafter\expandafter\@gobblethree
                \fi
            \else
               \expandafter\@gobblethree
            \fi}%
           \@empty
%    \end{macrocode}
% If we come to |=|, we always calculate the current column number (minus one).
%    \begin{macrocode}
         \lst@CArg{POD}=cut\^^M\relax\lst@CommentE\lst@PODmode
           {\lst@CalcLineLength}%
%    \end{macrocode}
% If there is additionally |cut|+EOL character and if we are in |\lst@PODmode| but not in column one, we must gobble the `end comment sequence'.
%    \begin{macrocode}
           {\ifnum\@tempcnta=\z@\else
                \expandafter\@gobblethree
            \fi}%
           {}%
	 \fi}
%    \end{macrocode}
%    \begin{macrocode}
\lst@EndAspect
%</pod>
%    \end{macrocode}
% \end{lstkey}\end{lstkey}
%
%
% \subsection{Replacing input}
%
% \begin{macro}{\lst@ReplaceInput}
% works similar to |\lst@CommentB| or |\lst@CommentE|.
%    \begin{macrocode}
%<*kernel>
\def\lst@ReplaceInput#1{\lst@CArg{RI}#1\relax\lst@ReplaceInput@}
\def\lst@ReplaceInput@#1#2#3#4#5{%
    \let#4#1%
    \ifx\@empty#2\@empty
        \def#1{#5}%
    \else \ifx\@empty#3\@empty
        \def#1##1{%
            \ifx##1#2%
                \def\lst@next{#5}%
            \else
                \def\lst@next{#4##1}%
            \fi
            \lst@next}%
    \else
        \def#1{\lst@IfNextCharsArg{#2#3}{#5}{\expandafter#4\lst@eaten}}%
    \fi \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{lstkey}{literate}
% \lsthelper{Jason~Alexander}{1999/03/10}{literate programming} asked for something like that.
% The key simply saves the argument.
%    \begin{macrocode}
\lst@Key{literate}{}{\def\lst@literate{#1}}
\lst@AddToHook{SelectCharTable}
    {\ifx\lst@literate\@empty\else
         \expandafter\lst@Literate\lst@literate{}\relax\z@
     \fi}
%    \end{macrocode}
% Internally we make use of the `replace input' feature.
% We print the preceding text, assign token and length and output it.
%    \begin{macrocode}
\def\lst@Literate#1#2#3{%
    \ifx\relax#2\@empty\else
        \lst@CArg{RI}#1\relax\lst@ReplaceInput@
            {\lst@PrintToken \lst@letterfalse
             \lst@token{#2}\lst@length#3\relax\lst@PrintToken}%
        \expandafter\lst@Literate
    \fi}
%</kernel>
%    \end{macrocode}
% \end{lstkey}
%
%
% \subsection{Escaping to \LaTeX}
%
% \begin{aspect}{escape}
%    \begin{macrocode}
%<*escape>
\lst@BeginAspect{escape}
%    \end{macrocode}
%
% \begin{lstkey}{texcl}
% Communication with \lsthelper{J\"orn~Wilms}{1997/07/07}{\TeX\ comments} is responsible for this key.
% The definition and the first hooks are easy.
%    \begin{macrocode}
\lst@Key{texcl}{false}[t]{\lstKV@SetIf{#1}\lst@iftexcl}
\lst@AddToHook{InlineUnsave}{\let\lst@iftexcl\iffalse}
\lst@AddToHook{EOL}
    {\ifnum\lst@mode=\lst@TeXCLmode
         \expandafter\lst@escapeend
         \expandafter\lst@LeaveAllModes
         \expandafter\lst@ReenterModes
     \fi}
%    \end{macrocode}
% If the user wants \TeX\ comment lines, we print the comment separator and interrupt the normal processing.
%    \begin{macrocode}
\lst@AddToHook{AfterBeginComment}
    {\lst@iftexcl \ifnum\lst@mode=\lst@CLmode
         \lst@PrintToken
         \lst@LeaveMode \lst@InterruptModes
         \lst@EnterMode{\lst@TeXCLmode}{\lst@modetrue\lst@commentstyle}%
         \expandafter\expandafter\expandafter\lst@escapebegin
     \fi \fi}
%    \end{macrocode}
%    \begin{macrocode}
\lst@NewMode\lst@TeXCLmode
%    \end{macrocode}
% \end{lstkey}
%
% \begin{macro}{\lst@Escape}
% gets three arguments all in all.
% The first is the escape character, the second is executed when the escape starts and the third right before ending it.
% We use the same mechanism as for \TeX\ comment lines.
%    \begin{macrocode}
\gdef\lst@Escape#1#2{%
    \lccode`\~=`#1\lccode`\^^@=`#2\lowercase{\lst@Escape@~^^@}}
\gdef\lst@Escape@#1#2#3#4{%
    \def#1{%
        \lst@NewLine\lst@UseLostSpace \lst@PrintToken
        \lst@InterruptModes
        \lst@EnterMode{\lst@TeXmode}{\lst@modetrue}%
%    \end{macrocode}
% Now we must define the character to end the escape.
%    \begin{macrocode}
        \catcode`#2=\active
        \def#2{\lst@escapeend #4\lst@LeaveAllModes \lst@ReenterModes}%
        #3\lst@escapebegin}}
%    \end{macrocode}
%    \begin{macrocode}
\lst@NewMode\lst@TeXmode
%    \end{macrocode}
% \end{macro}
%
% \begin{lstkey}{escapebegin}
% \begin{lstkey}{escapeend}
% The keys simply store the arguments.
%    \begin{macrocode}
\lst@Key{escapebegin}{}{\def\lst@escapebegin{#1}}
\lst@Key{escapeend}{}{\def\lst@escapeend{#1}}
%    \end{macrocode}
% \end{lstkey}\end{lstkey}
%
% \begin{lstkey}{escapechar}
% The introduction of this key is due to a communication with \lsthelper{Rui~Oliveira}{1998/06/05}{escape characters}.
% We define |\lst@DefEsc| and execute it after selecting the standard character table.
%    \begin{macrocode}
\lst@Key{escapechar}{}
    {\ifx\@empty#1\@empty
         \let\lst@DefEsc\relax
     \else
         \def\lst@DefEsc{\lst@Escape{#1}{#1}{}{}}%
     \fi}
\lst@AddToHook{InlineUnsave}{\let\lst@DefEsc\relax}
\lst@AddToHook{SelectCharTable}{\lst@DefEsc}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{lstkey}{escapeinside}
% Nearly the same.
%    \begin{macrocode}
\lst@Key{escapeinside}{}{\lstKV@TwoArg{#1}%
    {\let\lst@DefEsc\relax
     \ifx\@empty##1@empty\else \ifx\@empty##2\@empty\else
         \def\lst@DefEsc{\lst@Escape{##1}{##2}{}{}}%
     \fi\fi}}
\lst@AddToHook{InlineUnsave}{\let\lst@DefEsc\relax}
\lst@AddToHook{SelectCharTable}{\lst@DefEsc}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{lstkey}{mathescape}
% This is a switch tested after character table selection.
% We use |\lst@Escape| with math shifts as arguments.
%    \begin{macrocode}
\lst@Key{mathescape}{false}[t]{\lstKV@SetIf{#1}\lst@ifmathescape}
\lst@AddToHook{InlineUnsave}{\let\lst@ifmathescape\iffalse}
\lst@AddToHook{SelectCharTable}
    {\lst@ifmathescape \lst@Escape{\$}{\$}{$}{$}\fi}
%    \end{macrocode}
% \end{lstkey}
%
%    \begin{macrocode}
\lst@EndAspect
%</escape>
%    \end{macrocode}
% \end{aspect}
%
%
% \section{Doing output}
%
%
% \subsection{General keys and registers}
%
% \begin{lstkey}{flexiblecolumns}
% Do you have any idea what to write here?
%    \begin{macrocode}
%<*kernel>
\lst@Key{flexiblecolumns}{false}[t]{\lstKV@SetIf{#1}\lst@ifflexible}
%    \end{macrocode}
% We assign the correct output macros defined below.
% As you can see there are three main macros, which handle identifiers, all other printing units and tabulator stops.
%    \begin{macrocode}
\lst@AddToHook{Init}
    {\lst@ifflexible
         \let\lst@Output\lst@OutputFlexible
         \let\lst@OutputOther\lst@OutputOtherFlexible
         \let\lst@GotoTabStop\lst@GotoTabStopFlexible
     \fi}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{lstkey}{identifierstyle}
% A simple definition.
%    \begin{macrocode}
\lst@Key{identifierstyle}{}{\def\lst@identifierstyle{#1}}
\lst@AddToHook{EmptyStyle}{\let\lst@identifierstyle\@empty}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{lstkey}{fontadjust}
% A simple \texttt{if} used in |\lst@EnterMode|.
% We always adjust internal variables to the current font at |InitVars|.
%    \begin{macrocode}
\lst@Key{fontadjust}{false}[t]{\lstKV@SetIf{#1}\lst@iffontadjust}
\lst@AddToHook{InitVars}{\lsthk@FontAdjust}
\lst@AddToHook{FontAdjust}{}% init
%    \end{macrocode}
%    \begin{macrocode}
\def\lst@FontAdjustPre{%
    \lst@iffontadjust
        \setbox\@tempboxa\hbox{{\lst@thestyle{\lsthk@FontAdjust
            \xdef\@gtempa{\noexpand\lst@width\the\lst@width\relax}}}}%
        \@gtempa
    \fi}
\def\lst@FontAdjustPost{\lst@iffontadjust \lsthk@FontAdjust \fi}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{lstkey}{basewidth}
% Another simple definition:
% We assign the values and test whether they are negative.
%    \begin{macrocode}
\lst@Key{basewidth}{0.6em,0.45em}{\lstKV@CSTwoArg{#1}%
    {\def\lst@widthfixed{##1}\def\lst@widthflexible{##2}%
     \ifx\lst@widthflexible\@empty
         \let\lst@widthflexible\lst@widthfixed
     \fi
     \gdef\lst@error{\PackageError{Listings}%
         {Nonnegative value(s) expected}%
         {I'll treat the value(s) as zero.^^J%
          Type <RETURN> to proceed.}}%
     \global\let\@gtempa\relax
     \ifdim \lst@widthfixed<\z@
         \global\let\@gtempa\lst@error \let\lst@widthfixed\z@
     \fi
     \ifdim \lst@widthflexible<\z@
         \global\let\@gtempa\lst@error \let\lst@widthflexible\z@
     \fi
     \@gtempa}}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{macro}{\lst@width}
% \begin{macro}{\lst@linewidth}
% \begin{macro}{\lst@column}
% \begin{macro}{\lst@pos}
% The width of a single character box, \ldots
%    \begin{macrocode}
\newdimen\lst@width
\lst@AddToHook{FontAdjust}
    {\lst@width=\lst@ifflexible\lst@widthflexible
                          \else\lst@widthfixed\fi \relax}
%    \end{macrocode}
% the current line width and two counters.
%    \begin{macrocode}
\newdimen\lst@linewidth % \global
\newcount\lst@column \newcount\lst@pos % \global
\lst@AddToHook{InitVarsBOL}
    {\global\lst@linewidth\z@ \global\lst@pos\z@ \global\lst@column\z@}
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}
%
% \begin{macro}{\lst@CalcLineLength}
% returns in |\@tempcnta| the sum of |\lst@column| and |\lst@length| minus |\lst@pos| --- |\lst@pos| will be nonpositive.
%    \begin{macrocode}
\def\lst@CalcLineLength{%
            \@tempcnta\lst@column
    \advance\@tempcnta\lst@length
    \advance\@tempcnta-\lst@pos}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@lostspace}
% Whenever this dimension is positive we can insert space to fix the column alignment.
% A negative `lost space' means that the printed line is wider than expected.
%    \begin{macrocode}
\newdimen\lst@lostspace % \global
\lst@AddToHook{InitVarsBOL}{\global\lst@lostspace\z@}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@UseLostSpace}
% We insert space and reset it (if and) only if |\lst@lostspace| is positive.
%    \begin{macrocode}
\def\lst@UseLostSpace{%
    \ifdim\lst@lostspace>\z@
        \global\advance\lst@linewidth\lst@lostspace
        \kern\lst@lostspace \global\lst@lostspace\z@
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@InsertLostSpace}
% \begin{macro}{\lst@InsertHalfLostSpace}
% Ditto, but insert always (even if negative).
%    \begin{macrocode}
\def\lst@InsertLostSpace{%
    \global\advance\lst@linewidth\lst@lostspace
    \kern\lst@lostspace \global\lst@lostspace\z@}
\def\lst@InsertHalfLostSpace{%
    \global\lst@lostspace.5\lst@lostspace \kern\lst@lostspace
    \global\advance\lst@linewidth\lst@lostspace}
%    \end{macrocode}
% \end{macro}\end{macro}
%
% \begin{lstkey}{outputpos}
% We test for |l|, |c| and |r|.
% If none of them is given, we issue a warning and assume |r| --- it's default since it looks most bad to me.
% The fixed column format makes use of |\lst@lefthss| and |\lst@righthss|, whereas the flexible needs only |\lst@leftinsert|.
%    \begin{macrocode}
\def\lstoutputpos@#1#2\relax{%
    \ifx #1l%
        \let\lst@lefthss\relax \let\lst@righthss\hss
        \let\lst@leftinsert\relax
    \else\ifx #1c%
        \let\lst@lefthss\hss \let\lst@righthss\hss
        \let\lst@leftinsert\lst@InsertHalfLostSpace
    \else
        \let\lst@lefthss\hss \let\lst@righthss\relax
        \let\lst@leftinsert\lst@InsertLostSpace
        \ifx #1r\else \PackageWarning{Listings}%
            {Unknown positioning for output boxes}%
        \fi
    \fi\fi}
%    \end{macrocode}
% And now the key.
%    \begin{macrocode}
\lst@Key{outputpos}{c}{\lstoutputpos@#1\relax\relax}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{macro}{\lst@CalcLostSpaceAndOutput}
% The update of |\lst@lostspace| and |\lst@linewidth| is simple.
%    \begin{macrocode}
\def\lst@CalcLostSpaceAndOutput{%
    \global\advance\lst@lostspace \lst@length\lst@width
    \global\advance\lst@lostspace-\wd\@tempboxa
    \global\advance\lst@linewidth \wd\@tempboxa
%    \end{macrocode}
% Moreover we keep track of |\lst@pos| and reset some variables.
%    \begin{macrocode}
    \global\advance\lst@pos -\lst@length
    \lst@token{}\lst@length\z@
%    \end{macrocode}
% Before |\@tempboxa| is output, we insert appropriate space if there is enough lost space.
%    \begin{macrocode}
    \ifdim\lst@lostspace>\z@ \lst@leftinsert \fi
    \box\@tempboxa \lsthk@PostOutput}
%    \end{macrocode}
%    \begin{macrocode}
\lst@AddToHook{PostOutput}{}% init
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Dropping empty lines}
%
% \begin{macro}{\lst@NewLineMacro}
% This macro is assigned to |\lst@NewLine|, which is executed whenever the (next) line is not empty.
% Once called, it deactivates itself.
%    \begin{macrocode}
\def\lst@NewLineMacro{%
    \global\let\lst@NewLine\relax \par\noindent\hbox{}}
\lst@AddToHook{InitVars}{\global\let\lst@NewLine\lst@NewLineMacro}
%    \end{macrocode}
% What we have said about |\lst@NewLine| is not the whole truth.
% Most times we'll assign |\lst@NewLineMacro|, but sometimes we append |\par\noindent\hbox{}| to prepare a new line, namely in the case that the last line has been empty.
% Then |\lst@NewLine| deactivates itself and begins two, three or more (empty) lines.
% This drops empty lines at the end of a listing.
%    \begin{macrocode}
\lst@AddToHook{EOL}
    {\ifx\lst@NewLine\relax
        \global\let\lst@NewLine\lst@NewLineMacro
     \else
         \lst@AddTo\lst@NewLine{\par\noindent\hbox{}}%
     \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@RemovePars}
% is used to discard two |\par\noindent\hbox{}| from |\lst@NewLine|.
% This is done in |\lst@DeInit| to ensure the correct number of empty lines at the end of a listing.
% In particular we ensure correct labelling.
%    \begin{macrocode}
\long\def\lst@RemovePars#1\hbox#2\hbox#3#4\@empty{\gdef\lst@NewLine{#4}}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Fixed columns}
%
% \begin{macro}{\lst@OutputOther}
% This macro outputs a character string with nonletters.
% If there is anything to output, we possibly start a new line.
%    \begin{macrocode}
\def\lst@OutputOther{%
    \ifnum\lst@length=\z@\else
        \lst@NewLine \lst@UseLostSpace
        \lsthk@OutputOther
%    \end{macrocode}
% The box must take |\lst@length| characters, each |\lst@width| wide.
%    \begin{macrocode}
        \setbox\@tempboxa\hbox to \lst@length\lst@width
            {\lsthk@OutputBox
             \lst@lefthss
             \expandafter\lst@FillOutputBox\the\lst@token\relax
             \lst@righthss}%
        \lst@CalcLostSpaceAndOutput
    \fi}
%    \end{macrocode}
%    \begin{macrocode}
\lst@AddToHook{OutputOther}{}% init
\lst@AddToHook{OutputBox}{}% init
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@Output}
% We reset |\lst@lastother| and use |\lst@thestyle|.
%    \begin{macrocode}
\def\lst@Output{%
    \ifnum\lst@length=\z@\else
        \lst@NewLine \lst@UseLostSpace
        \let\lst@thestyle\lst@identifierstyle
        \lsthk@Output
        \lst@FontAdjustPre
        \setbox\@tempboxa\hbox to \lst@length\lst@width
            {\lsthk@OutputBox
            {\lst@lefthss
             \lst@thestyle
                 {\expandafter\lst@FillOutputBox\the\lst@token\relax}%
            \lst@righthss}}%
        \lst@CalcLostSpaceAndOutput
        \lst@FontAdjustPost
    \fi
    \let\lst@lastother\relax}
%    \end{macrocode}
% Note that |\lst@lastother| becomes equivalent to |\relax| and not equivalent to |\@empty| as everywhere else (e.g.\ InitVarsEOL).
% I don't know whether this will be important in future or not.
%    \begin{macrocode}
\lst@AddToHook{Output}{}% init
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@FillOutputBox}
% Filling up a box is easy.
%    \begin{macrocode}
\def\lst@FillOutputBox#1{#1\lst@FillOutputBox@}
%    \end{macrocode}
% If we come to the end (the |\relax| from above), we do nothing.
% Otherwise we insert dynamic space, output the argument and call the submacro again.
%    \begin{macrocode}
\def\lst@FillOutputBox@#1{%
    \ifx\relax#1\else \hss#1\expandafter\lst@FillOutputBox@ \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@GotoTabStop}
% For fixed column format we only need to advance |\lst@lostspace| (which is inserted by the output macros above) and update the column.
%    \begin{macrocode}
\def\lst@GotoTabStop{%
    \global\advance\lst@lostspace \lst@length\lst@width
    \global\advance\lst@column\lst@length \lst@length\z@}%
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Flexible columns}
%
% \begin{macro}{\lst@OutputOtherFlexible}
% If there is something to output, we first insert the space lost by the flexible column format.
% Then we typeset the box and update the lost space.
% Note that we don't use any |\hss| here.
%    \begin{macrocode}
\def\lst@OutputOtherFlexible{%
    \ifnum\lst@length=\z@\else
        \lst@NewLine \lst@UseLostSpace
        \lsthk@OutputOther
        \setbox\@tempboxa\hbox{\lsthk@OutputBox\the\lst@token}%
        \lst@CalcLostSpaceAndOutput
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@OutputFlexible}
% Nothing new here.
%    \begin{macrocode}
\def\lst@OutputFlexible{%
    \ifnum\lst@length=\z@\else
        \lst@NewLine \lst@UseLostSpace
        \let\lst@thestyle\lst@identifierstyle
        \lsthk@Output
        \lst@FontAdjustPre
        \setbox\@tempboxa\hbox{\lsthk@OutputBox
            {\lst@thestyle{\the\lst@token}}}%
        \lst@CalcLostSpaceAndOutput
        \lst@FontAdjustPost
    \fi
    \let\lst@lastother\relax}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@GotoTabStopFlexible}
% Here we look whether or not the line already contains printing characters.
%    \begin{macrocode}
\def\lst@GotoTabStopFlexible{%
    \ifx\lst@NewLine\relax
%    \end{macrocode}
% If some characters are already printed, we output a box, which has the width of a blank space.
% Possibly more space is inserted, but that's upto the current value of |\lst@lostspace|.
%    \begin{macrocode}
        \setbox\@tempboxa\hbox{\lst@outputspace}\@tempdima\wd\@tempboxa
        \setbox\@tempboxa\hbox{}\wd\@tempboxa\@tempdima
        \lst@CalcLostSpaceAndOutput
        \global\lst@pos\z@
    \else
%    \end{macrocode}
% Otherwise (no printed characters) we do the same as for fixed columns.
%    \begin{macrocode}
        \global\advance\lst@lostspace \lst@length\lst@width
        \global\advance\lst@column\lst@length \lst@length\z@
    \fi}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Dropping the whole output}
%
% \begin{macro}{\lst@BeginDropOutput}
% It's sometimes useful to process a part of a listing as usual, but to drop the output.
% This macro does the main work and gets one argument, namely the internal mode it enters.
% We save |\lst@NewLine|, restore it |\aftergroup| and redefine the output macros.
%    \begin{macrocode}
\def\lst@BeginDropOutput#1{%
    \let\lst@BDONewLine\lst@NewLine
    \lst@EnterMode{#1}%
        {\lst@modetrue
         \let\lst@Output\lst@EmptyOutput
         \let\lst@OutputOther\lst@EmptyOutputOther
         \let\lst@PreGotoTabStop\lst@EmptyGotoTabStop
         \aftergroup\lst@BDORestore}}
%    \end{macrocode}
% Restoring |\lst@NewLine| is quite easy:
%    \begin{macrocode}
\def\lst@BDORestore{\global\let\lst@NewLine\lst@BDONewLine}
%    \end{macrocode}
% Note that there is no |\lst@EndDropOutput| since this macro would be equivalent to |\lst@LeaveMode|.
% \end{macro}
%
% \begin{macro}{\lst@EmptyOutputOther}
% \begin{macro}{\lst@EmptyOutput}
% \begin{macro}{\lst@EmptyGotoTabStop}
% Here we only keep track of registers (possibly) needed by other macros.
%    \begin{macrocode}
\def\lst@EmptyOutputOther{%
    \global\advance\lst@pos -\lst@length
    \lst@token{}\lst@length\z@}
%    \end{macrocode}
%    \begin{macrocode}
\def\lst@EmptyOutput{\let\lst@lastother\relax \lst@EmptyOutputOther}
%    \end{macrocode}
%    \begin{macrocode}
\def\lst@EmptyGotoTabStop{%
    \global\advance\lst@column\lst@length \lst@length\z@}
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
% \begingroup
%    \begin{macrocode}
%</kernel>
%    \end{macrocode}
% \endgroup
%
%
% \subsection{Writing to an external file}
%
% \begin{aspect}{writefile}
%    \begin{macrocode}
%<*writefile>
\lst@BeginAspect{writefile}
%    \end{macrocode}
%
% \begin{macro}{\lst@WF}
% \begin{macro}{\lst@WFtoken}
% The contents of the token will be written to the file.
%    \begin{macrocode}
\newwrite\lst@WF \newtoks\lst@WFtoken
\lst@AddToHook{InitVarsBOL}{\global\lst@WFtoken{}}
%    \end{macrocode}
% \end{macro}\end{macro}
%
% \begin{macro}{\lst@WFWriteToFile}
% To do this we have to expand the contents and then expand this via |\edef|.
% Empty |\lst@UM| ensures that `special characters' (underscore, dollar, etc.) are written correctly.
%    \begin{macrocode}
\gdef\lst@WFWriteToFile{%
  \begingroup
   \let\lst@UM\@empty
   \expandafter\edef\expandafter\lst@temp\expandafter{\the\lst@WFtoken}%
   \immediate\write\lst@WF{\lst@temp}%
  \endgroup
  \global\lst@WFtoken{}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@WFAppend}
% Similar to |\lst@Append| but works with |\lst@WFtoken|.
%    \begin{macrocode}
\gdef\lst@WFAppend#1{%
    \global\expandafter\lst@WFtoken\expandafter{\the\lst@WFtoken#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@BeginWriteFile}
% redefines some macros additionally to |\lst@WFBegin|.
%    \begin{macrocode}
\gdef\lst@BeginWriteFile{%
    \begingroup
    \let\lst@Output\lst@EmptyOutput
    \let\lst@OutputOther\lst@EmptyOutputOther
    \let\lst@PreGotoTabStop\lst@EmptyGotoTabStop
    \lst@WFBegin}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@BeginAlsoWriteFile}
% just opens a group and calls |\lst@WFBegin|.
%    \begin{macrocode}
\gdef\lst@BeginAlsoWriteFile{\begingroup \lst@WFBegin}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@BeginWF}
% redefines some (more) macros to meet our purpose:
% The |\lst@Append...| macros and |\lst@PreGotoTabStop| must update |\lst@WFtoken|, and we need slightly different `EOL' and `DeInit' definitions to write the token register to file.
%    \begin{macrocode}
\begingroup \catcode`\^^I=11
\gdef\lst@WFBegin#1{%
    \def\lst@Append##1{\advance\lst@length\@ne
        \expandafter\lst@token\expandafter{\the\lst@token##1}%
        \lst@WFAppend##1}%
    \def\lst@AppendOther##1{%
        \let\lst@lastother=##1\advance\lst@length\@ne
        \expandafter\lst@token\expandafter{\the\lst@token##1}%
        \ifx ##1\lst@outputspace
            \lst@WFAppend{ }%
        \else
            \lst@WFAppend##1%
        \fi}%
    \lst@lAddTo\lst@PreGotoTabStop{\lst@WFAppend{^^I}}%
    \def\lst@ProcessSpace{%
        \lst@ifletter \lst@Output\lst@letterfalse \fi
        \lst@AppendOther\lst@outputspace}%
    \let\lst@DeInit\lst@WFDeInit
    \let\lst@MProcessListing\lst@WFMProcessListing
    \immediate\openout\lst@WF=#1\relax}%
\endgroup
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@EndWriteFile}
% closes the file and restores original macro meanings.
%    \begin{macrocode}
\gdef\lst@EndWriteFile{\immediate\closeout\lst@WF \endgroup}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@WFMProcessListing}
% \begin{macro}{\lst@WFDeInit}
% write (additionally) |\lst@WFtoken| to external file.
%    \begin{macrocode}
\global\let\lst@WFMProcessListing\lst@MProcessListing
\global\let\lst@WFDeInit\lst@DeInit
\lst@AddToAtTop\lst@WFMProcessListing{\lst@WFWriteToFile}
\lst@AddToAtTop\lst@WFDeInit{%
    \ifnum\lst@length=\z@\else \lst@WFWriteToFile \fi}
%    \end{macrocode}
% \end{macro}\end{macro}
%
%    \begin{macrocode}
\lst@EndAspect
%</writefile>
%    \end{macrocode}
% \end{aspect}
%
%
% \section{Main \lst-aspects and keys}
%
% \begingroup
%    \begin{macrocode}
%<*kernel>
%    \end{macrocode}
% \endgroup
% \begin{lstkey}{basicstyle}
% There is no better place to define this key, I think.
%    \begin{macrocode}
\lst@Key{basicstyle}{}{\def\lst@basicstyle{#1}}
\lst@AddToHook{Init}{\lst@basicstyle}
\lst@AddToHook{EmptyStyle}{\let\lst@basicstyle\@empty}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{macro}{\lst@NormedDef}
% works like |\def| (without any parameters!), but normalizes the replacement text by making all characters lower case and stripping off spaces.
%    \begin{macrocode}
\def\lst@NormedDef#1#2{\lowercase{\edef#1{\zap@space#2 \@empty}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@NormedNameDef}
% works like |\global\@namedef| (again without any parameters!), but normalizes both the macro name and the replacement text.
%    \begin{macrocode}
\def\lst@NormedNameDef#1#2{%
    \lowercase{\edef\lst@temp{\zap@space#1 \@empty}%
    \expandafter\xdef\csname\lst@temp\endcsname{\zap@space#2 \@empty}}}
%</kernel>
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Styles and languages}
%
% \begin{aspect}{style}
% We begin with style definition and selection.
%    \begin{macrocode}
%<*style>
\lst@BeginAspect{style}
%    \end{macrocode}
%
% \begin{macro}{\lstdefinestyle}
% The internal name of a style is |\lststy@|\meta{name} (normalized).
% That macro is defined to set the keys.
%    \begin{macrocode}
\lst@UserCommand\lstdefinestyle#1{\lst@NormedDef\lst@temp{#1}%
    \begingroup \lstset@catcodes \lstdefinestyle@}
\gdef\lstdefinestyle@#1{\endgroup
    \global\@namedef{lststy@\lst@temp}{\lstset{#1}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{lstkey}{style}
% We give an error message if the style macro doesn't exist.
%    \begin{macrocode}
\lst@Key{style}\relax
    {\lst@NormedDef\lst@temp{#1}%
     \@ifundefined{lststy@\lst@temp}%
        {\PackageError{Listings}{Style `#1' undefined}%
         {You might have misspelt the name here or before.^^J%
          Type <RETURN> to proceed without changing the style.}}%
%    \end{macrocode}
% Otherwise we execute the hook and call the macro.
%    \begin{macrocode}
        {\lsthk@SetStyle \csname lststy@\lst@temp\endcsname}}
%    \end{macrocode}
%    \begin{macrocode}
\lst@AddToHook{SetStyle}{}% init
%    \end{macrocode}
% \end{lstkey}
%
% \begin{macro}{\lststy@}
% The `empty' style calls the initial empty hook |EmptyStyle|.
%    \begin{macrocode}
\gdef\lststy@{\lsthk@EmptyStyle}
\lst@AddToHook{EmptyStyle}{}% init
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\lst@EndAspect
%</style>
%    \end{macrocode}
% \end{aspect}
%
% \begin{aspect}{language}
% Now we deal with commands used in defining and selecting programming languages, in particular with aliases and load of driver files.
%    \begin{macrocode}
%<*language>
\lst@BeginAspect{language}
%    \end{macrocode}
%
% \begin{macro}{\lstalias}
% First we concentrate on aliases and default dialects.
% |\lsta@|\meta{language}|$|\meta{dialect} and |\lsta@|\meta{language} contain the aliases of a particular dialect respectively a complete language.
% We'll use a |$|-character to separate a language name from its dialect.
%    \begin{macrocode}
\lst@UserCommand\lstalias{\@ifnextchar[\lstalias@\lstalias@@}
\gdef\lstalias@[#1]#2[#3]#4{\lst@NormedNameDef{lsta@#2$#1}{#4$#3}}
\gdef\lstalias@@#1#2{\lst@NormedNameDef{lsta@#1}{#2}}
%    \end{macrocode}
% \end{macro}
%
% \begin{lstkey}{defaultdialect}
% We simply store the dialect.
%    \begin{macrocode}
\lst@Key{defaultdialect}\relax
    {\lstKV@OptArg[]{#1}{\lst@NormedNameDef{lstdd@##2}{##1}}}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{macro}{\lst@FindAlias}
% Now we have to find a language.
% First we test for a complete language alias, then we set the default dialect if necessary.
%    \begin{macrocode}
\gdef\lst@FindAlias[#1]#2{%
    \lst@NormedDef\lst@dialect@{#1}%
    \lst@NormedDef\lst@language@{#2}%
    \@ifundefined{lsta@\lst@language@}{}%
        {\edef\lst@language@{\csname lsta@\lst@language@\endcsname}}%
%    \end{macrocode}
%    \begin{macrocode}
    \ifx\@empty\lst@dialect@ \@ifundefined{lstdd@\lst@language@}{}%
        {\edef\lst@dialect@{\csname lstdd@\lst@language@\endcsname}}%
    \fi
%    \end{macrocode}
% Now we are ready for an alias of a single dialect.
%    \begin{macrocode}
    \edef\lst@temp{\lst@language@ $\lst@dialect@}%
    \@ifundefined{lsta@\lst@temp}{}%
        {\edef\lst@temp{\csname lsta@\lst@temp\endcsname}}%
%    \end{macrocode}
% Finally we again set the default dialect --- for the case of a dialect alias.
%    \begin{macrocode}
    \expandafter\lst@FindAlias@\lst@temp $}
\gdef\lst@FindAlias@#1$#2${%
    \def\lst@language@{#1}\def\lst@dialect@{#2}%
    \ifx\@empty\lst@dialect@ \@ifundefined{lstdd@\lst@language@}{}%
        {\edef\lst@dialect@{\csname lstdd@\lst@language@\endcsname}}%
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstdriverfiles}
% This macro is defined if and only if it's undefined yet.
%    \begin{macrocode}
\@ifundefined{lstdriverfiles}
    {\lst@UserCommand\lstdriverfiles{lstlang0.sty}}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@RequireLanguages}
% This definition will be equivalent to |\lstloadlanguages|.
% First we put (the alias of) each requested and undefined language in a list.
% Then we input all necessary driver files (and give a warning), and load additionally required aspects.
%    \begin{macrocode}
\gdef\lst@RequireLanguages#1{%
    \lst@for #1\do{\lstKV@OptArg[]{##1}{%
        \lst@FindAlias[####1]{####2}%
        \@ifundefined{lstlang@\lst@language@ $\lst@dialect@}%
            {\xdef\lst@loadlanguages{\lst@loadlanguages,%
             \lst@language@ $\lst@dialect@}}{}}}%
%    \end{macrocode}
%    \begin{macrocode}
    \begingroup
        \lst@InputCatcodes
        \lst@for\lstdriverfiles\do{%
            \ifx\lst@loadlanguages\@empty\else
                \InputIfFileExists{##1}{}{}%
                \lst@DeleteKeysIn\lst@loadlanguages\lst@loadedlanguages
            \fi}%
        \global\let\lst@loadlanguages\lst@loadlanguages
    \endgroup
    \ifx\lst@loadlanguages\@empty\else
        \PackageWarning{Listings}{Couldn't load all languages}%
    \fi
%    \end{macrocode}
%    \begin{macrocode}
    \ifx\lst@loadaspects\@empty\else
        \lst@RequireAspects\lst@loadaspects
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstloadlanguages}
% became quite easy.
% We only take care of whether the aspect is loaded in the preamble or not.
%    \begin{macrocode}
\ifx\@onlypreamble\@notprerr
    \global\let\lstloadlanguages\@notprerr
\else
    \global\let\lstloadlanguages\lst@RequireLanguages
    \@onlypreamble\lstloadlanguages
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstdefinelanguage}
% \begin{macro}{\lst@definelanguage}
% are defined in terms of |\lst@DefLang|.
%    \begin{macrocode}
\lst@UserCommand\lstdefinelanguage{\lst@DefLang\iftrue}
\lst@UserCommand\lst@definelanguage{\lst@DefLang\iffalse}
%    \end{macrocode}
% Currently no languages are defined and no are requested.
%    \begin{macrocode}
\global\let\lst@loadedlanguages\@empty % init % \global
\global\let\lst@loadlanguages\@empty % init % \global
%    \end{macrocode}
% \end{macro}\end{macro}
%
% \begin{macro}{\lst@DefLang}
% We save the argument {\ttfamily|\if|true$\vert$false} from above and look for the optional dialect argument.
%    \begin{macrocode}
\gdef\lst@DefLang#1{%
    \let\lst@ifdeflang#1%
    \@ifnextchar[\lst@DefLang@{\lst@DefLang@[]}}
\gdef\lst@DefLang@[#1]#2{%
    \lst@NormedDef\lstlang@{#2$#1}%
    \begingroup
%    \end{macrocode}
% If called from |\lst@definelanguage|, we set |\lst@ifdeflang| locally true if and only if the language has been requested.
%    \begin{macrocode}
    \lst@ifdeflang\else
        \expandafter\lst@IfOneOf\lstlang@\relax\lst@loadlanguages
        {\lst@deflangtrue}{}%
    \fi
    \lstset@catcodes
    \@ifnextchar[\lst@XDefLang\lst@DefLang@@}
%    \end{macrocode}
% Note that |\lst@XDefLang| takes optional `base language' arguments, but eventually calls |\lst@DefLang@@|.
% We define the language (in case of need), and |\endgroup| resets some catcodes and |\lst@ifdeflang|, i.e.\ |\lst@XXDefLang| knows whether called by |\lstdefinelanguage| or |\lst@definelanguage|.
%    \begin{macrocode}
\gdef\lst@DefLang@@#1{%
    \lst@ifdeflang
        \global\@namedef{lstlang@\lstlang@}{\lstset{#1}}%
        \xdef\lst@loadedlanguages{\lst@loadedlanguages,\lstlang@}%
    \fi
    \endgroup
    \@ifnextchar[\lst@XXDefLang\@empty}
%    \end{macrocode}
% We get the aspect argument, and (if not empty) load the aspects immediately if called by |\lstdefinelanguage| or extend the list of required aspects or simply ignore the argument if the language is undefined.
%    \begin{macrocode}
\gdef\lst@XXDefLang[#1]{%
    \ifx\@empty#1\@empty\else
        \lst@ifdeflang
            \lstloadaspects{#1}%
        \else
            \@ifundefined{lstlang@\lstlang@}{}%
            {\xdef\lst@loadaspects{\lst@loadaspects,#1}}%
        \fi
    \fi}
%    \end{macrocode}
% If the user gives a `base language' and the current language is to be defined, we extend the required languages.
% In any case we use an additional |language=|value, which doesn't matter here if the language is not defined.
%    \begin{macrocode}
\gdef\lst@XDefLang[#1]#2#3{%
    \lst@ifdeflang
        \lst@NormedDef\lst@temp{#2$#1}%
        \xdef\lst@loadlanguages{\lst@loadlanguages,\lst@temp}%
    \fi
    \lst@DefLang@@{language=[#1]#2,#3}}
%    \end{macrocode}
% Finally a helper \ldots
%    \begin{macrocode}
\gdef\lst@deflangtrue{\let\lst@ifdeflang\iftrue}
%    \end{macrocode}
% and the empty language.
%    \begin{macrocode}
\lstdefinelanguage{}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{lstkey}{language}
% We request language |[#1]#2| and give an error message if the language macro doesn't exist.
%    \begin{macrocode}
\lst@Key{language}\relax{\lstKV@OptArg[]{#1}%
    {\lst@RequireLanguages{[##1]{##2}}%
     \@ifundefined{lstlang@\lst@language@ $\lst@dialect@}%
        {\PackageError{Listings}%
         {\ifx\@empty\lst@dialect@\else \lst@dialect@\space of \fi
          \lst@language@\space undefined}%
         {The language is not loadable or just mispellt.^^J%
          Type <RETURN> to proceed without changing the language.}}%
%    \end{macrocode}
% Otherwise we execute the hook and select the language.
%    \begin{macrocode}
        {\lsthk@SetLanguage
         \csname lstlang@\lst@language@ $\lst@dialect@\endcsname
%    \end{macrocode}
% We must refresh |\lst@language@| and |\lst@dialect@|.
%    \begin{macrocode}
         \lst@FindAlias[##1]{##2}%
         \let\lst@language\lst@language@
         \let\lst@dialect\lst@dialect@}}}
%    \end{macrocode}
%    \begin{macrocode}
\lst@AddToHook{SetLanguage}{}% init
%    \end{macrocode}
% \end{lstkey}
%
%    \begin{macrocode}
\lst@EndAspect
%</language>
%    \end{macrocode}
% \end{aspect}
%
%
% \subsection{Keywords}\label{iKeywords}
%
% \begin{aspect}{keywords}
% We start this aspect with the main service macros described in section \ref{dKeywordsAndWorkingIdentifiers}.
%    \begin{macrocode}
%<*keywords>
\lst@BeginAspect{keywords}
%    \end{macrocode}
%
% \begin{macro}{\lst@InstallKeywords}
% We insert the following arguments:
% |{|\meta{prefix}|}|, |{|\meta{key name}|}|, |\lst@|\meta{key name}, |\lst@|\meta{key name}|@also|, |\lst@g|\meta{key name}|tyle|, |\lst@g|\meta{key name}.
%    \begin{macrocode}
\gdef\lst@InstallKeywords#1#2{%
    \def\lst@arg{{#1}{#2}}%
    \lst@lExtend\lst@arg{%
        \csname lst@#2\expandafter\endcsname
        \csname lst@#2@also\expandafter\endcsname
        \csname lst@g#2tyle\expandafter\endcsname
        \csname lst@g#2\endcsname}%
    \expandafter\lst@InstallKeywords@\lst@arg}
%    \end{macrocode}
% We define the keys, which store keywords in |\lst@|\meta{key name}, \ldots
%    \begin{macrocode}
\gdef\lst@InstallKeywords@#1#2#3#4#5#6#7{%
    \lst@Key{#2}\relax{\lst@MakeKeywords#3#4{##1}}%
    \def\@tempa{%
        \lst@Key{more#2}\relax{\lst@MakeMoreKeywords#3#4{####1}}%
        \lst@Key{delete#2}\relax{\lst@DeleteKeywords#3#4{####1}}%
        \lst@Key{#2tyle}\relax{\def#7{####1}}%
        \lst@AddToHook{SetLanguage}{\let#3\@empty}}%
    \def\lst@arg{#1}\def\lst@temp{k}%
    \ifx\lst@arg\lst@temp \@tempa \fi
%    \end{macrocode}
% and initialize some macros.
% In particular we put \meta{style macro} inside |\lst@g|\meta{key name}|tyle|.
%    \begin{macrocode}
    \global\let#3\@empty \global\let#4\@empty % init
    \gdef#5{#7}\global\let#6\@empty % init
    \lst@AddToHook{Init}{\expandafter\lst@UseBasicClasses#4{}{}{}}%
    \lst@InstallKeywordTest{#1}#3#6#5}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@InstallKeywordTest}
% First we keep track of the keywords, and what does that mean?
% The global macro |\lst@g|\meta{key name} contains all keywords currently defined (`all' refering to this class), whereas |\lst@|\meta{key name} contains the user given keywords of this class.
% So we are able to undefine out-dated keywords and provide all user keywords.
%    \begin{macrocode}
\gdef\lst@InstallKeywordTest#1#2#3#4#5{%
    \lst@AddToHook{Init}{\lst@UpdateKeywords{#1}#2#3#4}%
%    \end{macrocode}
% Now installing `keyword' or `working identifier' test if it's not already done.
%    \begin{macrocode}
    \@ifundefined{lst@if#1installed}%
    {\global\@namedef{lst@if#1installed}{}%
     \edef\lst@arg{#1}\def\lst@temp{k}%
     \edef\@tempa{%
         \noexpand\lst@AddToHook{#5DetectKeywords\else Output\fi}%
             \ifx\lst@arg\lst@temp
                  \noexpand\lst@KeywordTest
             \else
                 {\noexpand\lst@WorkingTest{#1}}%
             \fi}
     \@tempa}{}}
%    \end{macrocode}
% Finally we need to detect the keywords somewhere:
%    \begin{macrocode}
\lst@AddToHook{Output}{\lst@ifkeywords \lsthk@DetectKeywords \fi}
\lst@AddToHook{ModeTrue}{\let\lst@ifkeywords\iffalse}
\lst@AddToHook{Init}{\let\lst@ifkeywords\iftrue}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@KeywordTest}
% Sensitive tests take advance of the |\lst@CCUseMacro| construction in section \ref{iCharacterTables}:
% If |\lst@UM| is empty, all `macro characters' expand to the original characters (instead of to a printable version of the character).
%    \begin{macrocode}
\gdef\lst@KeywordTestSensitive{%
    \begingroup \let\lst@UM\@empty
    \global\expandafter\let\expandafter\@gtempa
        \csname lstk@\the\lst@token\endcsname
    \endgroup
    \ifx\@gtempa\relax\else
        \let\lst@thestyle\@gtempa
    \fi}
%    \end{macrocode}
% For insensitive keyword tests we make the current character string upper case and give it to a submacro, which is similar to |\lst@KeywordTest|.
%    \begin{macrocode}
\gdef\lst@KeywordTestInsensitive{%
    \uppercase\expandafter{\expandafter
        \lst@KeywordTestI@\the\lst@token}\relax}
\gdef\lst@KeywordTestI@#1\relax{%
    \begingroup \let\lst@UM\@empty
    \global\expandafter\let\expandafter\@gtempa
        \csname lstk@#1\endcsname
    \endgroup
    \ifx\@gtempa\relax\else
        \let\lst@thestyle\@gtempa
    \fi}
%    \end{macrocode}
% Finally some initialization.
%    \begin{macrocode}
\lst@AddToHook{Init}
    {\lst@ifsensitive\else
         \let\lst@KeywordTest\lst@KeywordTestInsensitive
     \fi}
\global\let\lst@KeywordTest\lst@KeywordTestSensitive % init
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@WorkingTest}
% We need no temporary macro |\@gtempa| since we have `working' (and no style) macros here.
%    \begin{macrocode}
\gdef\lst@WorkingTestSensitive#1{%
    \begingroup \let\lst@UM\@empty
    \global\expandafter\let\expandafter\@gtempa
        \csname lst#1@\the\lst@token\endcsname
    \endgroup
    \@gtempa}
%    \end{macrocode}
%    \begin{macrocode}
\gdef\lst@WorkingTestInsensitive{%
    \uppercase\expandafter{\expandafter
        \lst@WorkingTestI@\the\lst@token}\relax}
\gdef\lst@WorkingTestI@#1\relax#2{%
    \begingroup \let\lst@UM\@empty
    \global\expandafter\let\expandafter\@gtempa
        \csname lst#2@#1\endcsname
    \endgroup
    \@gtempa}
%    \end{macrocode}
% And again initialization.
%    \begin{macrocode}
\lst@AddToHook{Init}
    {\lst@ifsensitive\else
         \let\lst@WorkingTest\lst@WorkingTestInsensitive
     \fi}
\global\let\lst@WorkingTest\lst@WorkingTestSensitive % init
%    \end{macrocode}
% \end{macro}
%
% \begin{lstkey}{sensitive}
% is an \texttt{if}, preset |true| every language selection.
%    \begin{macrocode}
\lst@Key{sensitive}\relax[t]{\lstKV@SetIf{#1}\lst@ifsensitive}
\lst@AddToHookExe{SetLanguage}{\let\lst@ifsensitive\iftrue}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{macro}{\lst@UpdateKeywords}
% Keywords must be updated in two cases: If keywords or |sensitive| changed.
%    \begin{macrocode}
\gdef\lst@UpdateKeywords#1#2#3#4{%
    \ifx\lst@ifsensitive\lst@ifsensitivedefed
        \ifx#2#3\else
            \lst@UndefineKeywords{#1}#3#4%
            \lst@DefineKeywords{#1}#2#4%
            \global\let#3#2%
        \fi
    \else
        \lst@UndefineKeywords{#1}#3#4%
        \lst@DefineKeywords{#1}#2#4%
        \global\let#3#2%
    \fi}
%    \end{macrocode}
% Keywords are up-to-date after |Init|:
%    \begin{macrocode}
\lst@AddToHook{InitVars}
    {\global\let\lst@ifsensitivedefed\lst@ifsensitive}
\global\let\lst@ifsensitivedefed\iffalse % init % \global
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@DefineKeywords}
% We make the keywords uppercase if necessary, \ldots
%    \begin{macrocode}
\gdef\lst@DefineKeywords#1#2#3{%
    \lst@ifsensitive
        \def\lst@next{\lst@for#2}%
    \else
        \def\lst@next{\uppercase\expandafter{\expandafter\lst@for#2}}%
    \fi
    \lst@next\do
%    \end{macrocode}
% iterate through the list and make |\lst|\meta{k$\vert$w}|@|\meta{keyword} (if not already defined) equivalent to |\lst@|\meta{key name}|@style| (which is possibly a working macro).
%    \begin{macrocode}
    {\expandafter\ifx\csname lst#1@##1\endcsname\relax
        \global\expandafter\let\csname lst#1@##1\endcsname#3%
     \fi}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@UndefineKeywords}
% We make the keywords uppercase if necessary, \ldots
%    \begin{macrocode}
\gdef\lst@UndefineKeywords#1#2#3{%
    \lst@ifsensitivedefed
        \def\lst@next{\lst@for#2}%
    \else
        \def\lst@next{\uppercase\expandafter{\expandafter\lst@for#2}}%
    \fi
    \lst@next\do
%    \end{macrocode}
% iterate through the list and `undefine' |\lst|\meta{k$\vert$w}|@|\meta{keyword} if it's equivalent to |\lst@|\meta{key name}|@style| (which is possibly a working macro).
%    \begin{macrocode}
    {\expandafter\ifx\csname lst#1@##1\endcsname#2%
        \global\expandafter\let\csname lst#1@##1\endcsname\relax
     \fi}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@DeleteKeywords}
% We convert the keyword list |#3| via |\lst@MakeKeywords|, remove the keywords from |#1| and scan for special characters.
%    \begin{macrocode}
\gdef\lst@DeleteKeywords#1#2#3{%
    \lst@MakeKeywords\lst@arg#2{#3}%
    \lst@DeleteKeysIn#1\lst@arg
    \lst@SpecialKeywordScan#1#2{}{}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@MakeKeywords}
% We simply empty |\lst@|\meta{key name} and |\lst@|\meta{key name}|@also|, and make use of |\lst@MakeMoreKeywords|.
%    \begin{macrocode}
\gdef\lst@MakeKeywords#1#2{%
    \let#1\@empty \let#2\@empty
    \lst@MakeMoreKeywords#1#2}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@MakeMoreKeywords}
% Now we must work a little bit.
% The first macro call inserts |\lststore|d|keywords| (if such definitions are used).
% Then we convert the keyword string.
% Finally we scan for special characters (= nonletters and nondigits), which must become `letters' or `digits' for correct keyword detection.
% Note the two empty arguments |{}{}|, which are needed if |#2| equals |\@empty|.
%    \begin{macrocode}
\gdef\lst@MakeMoreKeywords#1#2#3{%
    \lst@MakeMoreKeywords@#1#3,\relax,%
    \expandafter\lst@DefOther\expandafter#1\expandafter{#1}%
    \expandafter\lst@SpecialKeywordScan\expandafter
        #1\expandafter#2#2{}{}}
%    \end{macrocode}
% To insert |\lststore|d|keywords| we iterate through the keyword list and either expand the stored keywords or append the current keyword.
%    \begin{macrocode}
\gdef\lst@MakeMoreKeywords@#1#2,{%
    \ifx\relax#2\@empty
        \expandafter\@gobbletwo
    \else
        \lst@IfOneOf#2\relax\lst@storedkeywords
        {\lst@lExtend#1{\expandafter,#2}}%
        {\lst@lAddTo#1{,#2}}%
    \fi
    \lst@MakeMoreKeywords@#1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@SpecialKeywordScan}
% The list of nonletters we are scanning for:
%    \begin{macrocode}
\lst@DefOther\lst@others{!"\#\%&'()*+-./0123456789:;<=>?[\]^`\{|\}~}
\global\let\lst@others\lst@others % init
%    \end{macrocode}
% We define first which other characters already have a letter respectively digit status.
% The scan extends these two macros, which are finally expanded inside |\lst@|\meta{key name}|@also| (with surrounding braces).
%    \begin{macrocode}
\gdef\lst@SpecialKeywordScan#1#2#3#4{%
    \def\lst@ialsoletter{#3}\def\lst@ialsodigit{#4}%
    \expandafter\lst@SKS@\expandafter#1\lst@others\relax
    \edef#2{{\lst@ialsoletter}{\lst@ialsodigit}}}
%    \end{macrocode}
% Reaching the end of our `other' list we terminate the loop by gobbling two tokens after the latest |\fi|.
%    \begin{macrocode}
\gdef\lst@SKS@#1#2{%
    \ifx\relax#2%
        \expandafter\@gobbletwo
    \else
%    \end{macrocode}
% Otherwise we look for the character |#2|.
% Refer section \ref{iSubstringTests} on how we scan for substrings.
%    \begin{macrocode}
        \def\lst@temp##1#2##2##3\relax{%
            \ifx\@empty##2\else
                \def\lst@temp####1,#2####2####3\relax{%
%    \end{macrocode}
% If we've found |#2|, we scan for |,#2| --- i.e.\ we look whether |#2| starts a keyword or not.
% Then we are able to decide whether |#2| gets letter or digit status.
% Note that a digit need not to become a digit; we use a submacro to test it.
%    \begin{macrocode}
                    \ifx\@empty####2%
                        \lst@SKS@@#2%
                    \else
                        \lst@SKSAdd\lst@ialsoletter#2%
                    \fi}%
                \expandafter\lst@temp\expandafter,#1,#2\@empty\relax
            \fi}%
        \expandafter\lst@temp #1#2\@empty\relax
    \fi
    \lst@SKS@#1}
%    \end{macrocode}
% The special test for digits:
%    \begin{macrocode}
\gdef\lst@SKS@@#1{%
    \ifnum`#1<`0%
        \lst@SKSAdd\lst@ialsodigit#1%
    \else\ifnum`#1>`9%
        \lst@SKSAdd\lst@ialsodigit#1%
    \fi \fi}
%    \end{macrocode}
% Here we actually append the character, but only if it's necessary.
%    \begin{macrocode}
\gdef\lst@SKSAdd#1#2{%
    \def\lst@temp##1#2##2\relax{%
        \ifx\@empty##2\@empty \lst@lAddTo#1{#2}\fi}%
    \expandafter\lst@temp#1#2\relax}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lststorekeywords}
% We store the keywords globally and extend the list of keyword macros.
%    \begin{macrocode}
\lst@UserCommand\lststorekeywords#1#2
    {\gdef#1{#2}%
     \lst@AddTo\lst@storedkeywords{,#1}}
\global\let\lst@storedkeywords\@empty % init % \global
%    \end{macrocode}
% \end{macro}
%
% \begin{lstkey}{keywords}
% \begin{lstkey}{ndkeywords}
% The \packagename{keyval} package removes a naming conflict with AMS classes --- reported by \lsthelper{Ralf~Quast}{1998/01/08}{\keywords conflicts with AMS classes}.
% First and second order keywords became very, very easy.
%    \begin{macrocode}
\lst@InstallKeywords k{keywords}\lst@keywordstyle\iftrue
\lst@InstallKeywords k{ndkeywords}\lst@ndkeywordstyle\iftrue
\lst@AddToHook{EmptyStyle}{\let\lst@keywordstyle\bfseries}
%    \end{macrocode}
%    \begin{macrocode}
\global\let\lst@keywordstyle\@empty % init
\lst@AddToHook{Init}
    {\ifx\lst@ndkeywordstyle\@undefined
         \let\lst@ndkeywordstyle\lst@keywordstyle
     \fi}
%    \end{macrocode}
% \end{lstkey}\end{lstkey}
%
% \begin{lstkey}{otherkeywords}
% Save the argument and define `keywords' when selecting the character table.
%    \begin{macrocode}
\lst@Key{otherkeywords}{}{\def\lst@otherkeywords{#1}}
\lst@AddToHook{SelectCharTable}
    {\expandafter\lst@DefineOtherKeywords\lst@otherkeywords,\relax,}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{macro}{\lst@DefineOtherKeywords}
% Iterates through the list.
%    \begin{macrocode}
\gdef\lst@DefineOtherKeywords#1,{%
    \ifx\relax#1\@empty\else
        \ifx\@empty#1\@empty\else
            \lst@CArg{ok}#1\relax\lst@DefineOtherKeywords@
        \fi
        \expandafter\lst@DefineOtherKeywords
    \fi}
%    \end{macrocode}
% The submacro works like |\lst@ReplaceInput@| and uses another macro to print the `keywords'.
%    \begin{macrocode}
\gdef\lst@DefineOtherKeywords@#1#2#3#4{%
    \let#4#1%
    \ifx\@empty#2\@empty
        \def#1{\lst@PrintOtherKeyword#4}%
    \else \ifx\@empty#3\@empty
        \def#1##1{%
            \ifx##1#2%
                \def\lst@next{\lst@PrintOtherKeyword{#4##1}}%
            \else
                \def\lst@next{#4##1}%
            \fi
            \lst@next}%
    \else
        \def#1{\lst@IfNextCharsArg{#2#3}%
               {\lst@PrintOtherKeyword{#4\lst@eaten}}%
               {\expandafter#4\lst@eaten}}%
    \fi \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@PrintOtherKeyword}
% prints preceding characters, prepares the output and typesets the argument in keyword style.
%    \begin{macrocode}
\gdef\lst@PrintOtherKeyword#1{%
    \lst@PrintToken
    \begingroup
        \lst@modetrue \lsthk@InlineUnsave
        \let\lst@ProcessDigit\lst@ProcessLetter
        \let\lst@ProcessOther\lst@ProcessLetter
        \lst@lettertrue
        \lst@gkeywordstyle{#1\lst@PrintToken}%
    \endgroup}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\lst@EndAspect
%</keywords>
%    \end{macrocode}
% \end{aspect}
%
% \begin{aspect}{rdkeywords}
% \begin{lstkey}{rdkeywords}
% A third keyword class.
%    \begin{macrocode}
%<*rdkeywords>
\lst@BeginAspect[keywords]{rdkeywords}
\lst@InstallKeywords k{rdkeywords}\lst@rdkeywordstyle\iftrue
\lst@AddToHook{Init}
    {\ifx\lst@rdkeywordstyle\@undefined
         \let\lst@rdkeywordstyle\lst@keywordstyle
     \fi}
\lst@EndAspect
%</rdkeywords>
%    \end{macrocode}
% \end{lstkey}\end{aspect}
%
%
% \subsubsection{Restricting keywords}
%
% \begin{aspect}{html}
% Supports HTML, what else?
%    \begin{macrocode}
%<*html>
\lst@BeginAspect[keywords]{html}
%    \end{macrocode}
%
% \begin{lstkey}{keywordsinside}
% Allocate a new mode and start the key.
%    \begin{macrocode}
\lst@NewMode\lst@insidemode
\lst@Key{keywordsinside}{}{\lstKV@TwoArg{#1}
    {\let\lst@DefInside\@empty
     \ifx\@empty##1\@empty\else \ifx\@empty##2\@empty\else
         \def\lst@DefInside{%
%    \end{macrocode}
% The redefinitions of the characters enter respectively leave the mode and execute the old meanings.
%    \begin{macrocode}
             \lst@DefSaveDef{`##1}\lsts@insideb
                 {\lst@ifmode\else \ifnum\lst@mode=\lst@insidemode\else
                      \lst@EnterMode\lst@insidemode{}%
                  \fi\fi
                  \lsts@insideb}%
             \lst@DefSaveDef{`##2}\lsts@insidee
                  {\ifnum\lst@mode=\lst@insidemode
                       \lsts@insidee \lst@PrintToken\lst@LeaveMode
                   \else
                       \expandafter\lsts@insidee
                   \fi}}%
     \fi\fi}}
%    \end{macrocode}
% The redefinition is done via \hookname{SelectCharTable}.
%    \begin{macrocode}
\lst@AddToHook{SelectCharTable}{\lst@DefInside}
%    \end{macrocode}
% We reset |\lst@thestyle| if necessary.
%    \begin{macrocode}
\lst@AddToHook{Output}
    {\ifx\lst@DefInside\@empty\else \ifx\lst@thestyle\lst@gkeywordstyle
         \ifnum\lst@mode=\lst@insidemode\else
             \let\lst@thestyle\@empty
         \fi
     \fi\fi}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{lstkey}{usekeywordsinside}
% Here we set |\lst@thestyle| to keyword style if necessary.
%    \begin{macrocode}
\lst@Key{usekeywordsinside}t[t]{\lstKV@SetIf{#1}\lst@ifusekeysinside}
\lst@AddToHook{Output}
    {\ifnum\lst@mode=\lst@insidemode \lst@ifusekeysinside\else
         \let\lst@thestyle\lst@gkeywordstyle
     \fi\fi}
%    \end{macrocode}
% \end{lstkey}
%
%    \begin{macrocode}
\lst@EndAspect
%</html>
%    \end{macrocode}
% \end{aspect}
%
%
% \subsubsection{\TeX\ control sequences}
%
% \begin{aspect}{tex}
%    \begin{macrocode}
%<*tex>
\lst@BeginAspect[keywords]{tex}
%    \end{macrocode}
%
% \begin{lstkey}{texcs}
% \begin{lstkey}{moretexcs}
% The control sequence key, \ldots
%    \begin{macrocode}
\lst@InstallKeywords{cs}{texcs}
    {\ifx\lst@lastother\lstum@backslash
         \let\lst@thestyle\lst@texcsstyle
     \fi}
    \iftrue
%    \end{macrocode}
%    \begin{macrocode}
\lst@Key{moretexcs}\relax
    {\lst@MakeMoreKeywords\lst@texcs\lst@texcs@also{#1}}
%    \end{macrocode}
% \end{lstkey}\end{lstkey}
%
% \begin{lstkey}{texcsstyle}
% and the style key.
%    \begin{macrocode}
\lst@Key{texcsstyle}\relax{\def\lst@texcsstyle{#1}}
\lst@AddToHook{Init}
    {\ifx\@undefined\lst@texcsstyle
         \let\lst@texcsstyle\lst@keywordstyle
     \fi}
%    \end{macrocode}
% \end{lstkey}
%
%    \begin{macrocode}
\lst@EndAspect
%</tex>
%    \end{macrocode}
% \end{aspect}
%
%
% \subsubsection{Compiler directives}
%
% \begin{aspect}{directives}
%    \begin{macrocode}
%<*directives>
\lst@BeginAspect[keywords]{directives}
%    \end{macrocode}
%
% \begin{lstkey}{directives}
% First some usual stuff:
%    \begin{macrocode}
\lst@NewMode\lst@CDmode
\lst@AddToHook{EOL}{\ifnum\lst@mode=\lst@CDmode \lst@LeaveMode \fi}
\lst@InstallKeywords{d}{directives}
    {\ifnum\lst@mode=\lst@CDmode
         \let\lst@thestyle\lst@cdstyle
     \fi}
    \iftrue
\lst@AddToHook{SetLanguage}{\let\lst@directives\@empty}
%    \end{macrocode}
% If the user has defined directives, we redefine the character |#| (but save the old meaning before):
%    \begin{macrocode}
\lst@AddToHook{SelectCharTable}
    {\ifx\lst@directives\@empty\else
         \lst@DefSaveDef{`\#}\lsts@CCD
         {\lst@CalcLineLength
          \lst@ifmode\else
%    \end{macrocode}
% We enter `directive mode' only if we are in column 1 (without setting |\lst@ifmode| true).
%    \begin{macrocode}
              \ifnum\@tempcnta=\z@
                  \lst@EnterMode{\lst@CDmode}{}%
              \fi
          \fi
          \ifnum\lst@mode=\lst@CDmode
              \ifnum\@tempcnta=\z@
                  \lst@PrintToken{\lst@cdstyle\lsts@CCD\lst@PrintToken}%
              \else \lsts@CCD
              \fi
          \else \lsts@CCD
          \fi}%
     \fi}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{lstkey}{directivestyle}
% as seen before.
%    \begin{macrocode}
\lst@Key{directivestyle}\relax{\def\lst@cdstyle{#1}}
\lst@AddToHook{Init}
    {\ifx\@undefined\lst@cdstyle
         \let\lst@cdstyle\lst@keywordstyle
     \fi}
%    \end{macrocode}
% \end{lstkey}
%
%    \begin{macrocode}
\lst@EndAspect
%</directives>
%    \end{macrocode}
% \end{aspect}
%
%
% \subsubsection{Export of identifiers}
%
% \begin{aspect}{index}
% \begin{lstkey}{index}
% \begin{lstkey}{ndindex}
% \begin{lstkey}{indexmacro}
% \begin{lstkey}{ndindexmacro}
% \begin{macro}{\lstindexmacro}
% One more `keyword' class.
%    \begin{macrocode}
%<*index>
\lst@BeginAspect[keywords]{index}
\lst@InstallKeywords w{index}
    {\expandafter\lst@indexmacro\expandafter{\the\lst@token}}\iftrue
\lst@InstallKeywords w{ndindex}
    {\expandafter\lst@ndindexmacro\expandafter{\the\lst@token}}\iftrue
\lst@UserCommand\lstindexmacro#1{\index{{\ttfamily#1}}}
\lst@Key{indexmacro}\lstindexmacro{\let\lst@indexmacro#1}
\lst@Key{ndindexmacro}\lstindexmacro{\let\lst@ndindexmacro#1}
\lst@EndAspect
%</index>
%    \end{macrocode}
% \end{macro}
% \end{lstkey}\end{lstkey}\end{lstkey}\end{lstkey}
% \end{aspect}
%
% \begin{aspect}{procnames}
% \begin{lstkey}{procnamestyle}
% \begin{lstkey}{prockeywords}
% \begin{lstkey}{indexprocnames}
% The `idea' here is the usage of a global |\lst@ifprocname|, indicating a preceding `procedure keyword'.
% All the other is known stuff.
%    \begin{macrocode}
%<*procnames>
\lst@BeginAspect[keywords]{procnames}
\gdef\lst@procnametrue{\global\let\lst@ifprocname\iftrue}
\gdef\lst@procnamefalse{\global\let\lst@ifprocname\iffalse}
\lst@AddToHook{Init}{\lst@procnamefalse}
\lst@AddToHook{DetectKeywords}
    {\lst@ifprocname
         \let\lst@thestyle\lst@procnamestyle
         \lst@ifindexproc \lst@gindextyle \fi
         \lst@procnamefalse
     \fi}
%    \end{macrocode}
%    \begin{macrocode}
\lst@Key{procnamestyle}{}{\def\lst@procnamestyle{#1}}
\lst@Key{indexprocnames}{false}[t]{\lstKV@SetIf{#1}\lst@ifindexproc}
\lst@AddToHook{Init}
    {\lst@ifindexproc \ifx\lst@indexmacro\@undefined
         \let\lst@indexmacro\@gobble
     \fi \fi}
%    \end{macrocode}
%    \begin{macrocode}
\lst@InstallKeywords w{procnamekeys}
    {\global\let\lst@PNpost\lst@procnametrue}\iftrue
\lst@AddToHook{PostOutput}{\lst@PNpost\global\let\lst@PNpost\@empty}
\global\let\lst@PNpost\@empty % init
\lst@EndAspect
%</procnames>
%    \end{macrocode}
% \end{lstkey}\end{lstkey}\end{lstkey}
% \end{aspect}
%
%
% \subsubsection{Keyword comments}
%
% \begin{aspect}{keywordcomments}
% includes both comment types and is possibly splitted into this and |dkcs|.
%    \begin{macrocode}
%<*keywordcomments>
\lst@BeginAspect[keywords,comments]{keywordcomments}
%    \end{macrocode}
%
% \begin{macro}{\lst@BeginKC}
% \begin{macro}{\lst@BeginKCS}
% Starting a keyword comment is easy, but \ldots
%    \begin{macrocode}
\lst@NewMode\lst@KCmode \lst@NewMode\lst@KCSmode
\gdef\lst@BeginKC{\lst@BeginComment\lst@KCmode\lst@modetrue\@empty}
\gdef\lst@BeginKCS{\lst@BeginComment\lst@KCSmode\lst@modetrue\@empty}
%    \end{macrocode}
% we must ensure that the comment starts after printing the comment delimiter since it is possibly a keyword.
% We'll assign |\lst@BeginKC|(|S|) to |\lst@KCpost|, which is executed and reset in \hookname{PostOutput}.
%    \begin{macrocode}
\lst@AddToHook{PostOutput}{\lst@KCpost \global\let\lst@KCpost\@empty}
\global\let\lst@KCpost\@empty
%    \end{macrocode}
% \end{macro}\end{macro}
%
% \begin{macro}{\lst@EndKC}
% leaves the comment mode before the comment delimiter is printed.
% This ruins the current character string in |\lst@token|.
% The solution: |\@gtempa| becomes\\
% \ \qquad |\lst@token{|\meta{current character string}|}\lst@length|\meta{current length}|\relax|\\
% and is executed after leaving the mode.
%    \begin{macrocode}
\gdef\lst@EndKC{%
    \xdef\@gtempa{%
        \noexpand\lst@token{\the\lst@token}%
        \noexpand\lst@length\the\lst@length\relax}%
    \aftergroup\@gtempa \lst@LeaveMode}
%    \end{macrocode}
% \end{macro}
%
% \begin{lstkey}{keywordcomment}
% The delimiters must be identical here, thus we use |\lst@KCmatch|.
% Note the last argument |\iffalse| to |\lst@InstallKeywords|:
% The working test is installed in the \hookname{Output} hook and not in \hookname{DetectKeywords}.
% Otherwise we couldn't detect the ending delimiter since keyword detection is done if and only if mode changes are allowed.
%    \begin{macrocode}
\lst@InstallKeywords{kc}{keywordcomment}
    {\ifnum\lst@mode=\lst@KCmode
         \edef\lst@temp{\the\lst@token}%
         \ifx\lst@temp\lst@KCmatch
             \lst@EndKC
         \fi
     \else
         \lst@ifmode\else
             \xdef\lst@KCmatch{\the\lst@token}%
             \global\let\lst@KCpost\lst@BeginKC
         \fi
     \fi}\iffalse
%    \end{macrocode}
% \end{lstkey}
%
% \begin{lstkey}{keywordcommentsemicolon}
% The key simply stores the keywords.
%    \begin{macrocode}
\lst@Key{keywordcommentsemicolon}{}{\lstKV@ThreeArg{#1}%
    {\def\lst@KCAkeywordsB{##1}%
     \def\lst@KCAkeywordsE{##2}%
     \def\lst@KCBkeywordsB{##3}%
     \def\lst@KCkeywords{##1##2##3}}}
%    \end{macrocode}
% We define an appropriate semicolon if this keyword comment type is defined.
% Appropriate means that we leave any keyword comment mode if active.
%    \begin{macrocode}
\lst@AddToHook{SelectCharTable}
    {\ifx\lst@KCkeywords\@empty\else
        \lst@DefSaveDef{`\;}\lsts@EKC
            {\lst@ifletter \lst@Output\lst@letterfalse \fi
             \ifnum\lst@mode=\lst@KCmode \lst@EndComment \else
             \ifnum\lst@mode=\lst@KCSmode \lst@EndComment
             \fi \fi
             \lsts@EKC}%
     \fi}
%    \end{macrocode}
% The `working identifier' macros enter respectively leave comment mode.
%    \begin{macrocode}
\gdef\lst@KCAWorkB{%
    \lst@ifmode\else \global\let\lst@KCpost\lst@BeginKC \fi}
\gdef\lst@KCBWorkB{%
    \lst@ifmode\else \global\let\lst@KCpost\lst@BeginKCS \fi}
\gdef\lst@KCAWorkE{\ifnum\lst@mode=\lst@KCmode \lst@EndKC \fi}
%    \end{macrocode}
% Now we install the tests and \ldots
%    \begin{macrocode}
\lst@InstallKeywordTest{kcb}
    \lst@KCAkeywordsB\lst@gKCAkeywordsB\lst@KCAWorkB\iffalse
\lst@InstallKeywordTest{kce}
    \lst@KCAkeywordsE\lst@gKCAkeywordsE\lst@KCAWorkE\iffalse
\lst@InstallKeywordTest{kc}
    \lst@KCBkeywordsB\lst@gKCBkeywordsB\lst@KCBWorkB\iffalse
%    \end{macrocode}
% initialize the global keyword macros.
%    \begin{macrocode}
\global\let\lst@gKCAkeywordsB\@empty\global\let\lst@gKCAkeywordsE\@empty
\global\let\lst@gKCBkeywordsB\@empty
%    \end{macrocode}
% \end{lstkey}
%
%    \begin{macrocode}
\lst@EndAspect
%</keywordcomments>
%    \end{macrocode}
% \end{aspect}
%
%
% \subsection{Labels}
%
% \begin{aspect}{labels}
% \lsthelper{Rolf~Niepraschk}{1997/04/24}{labels} asked for labels.
%    \begin{macrocode}
%<*labels>
\lst@BeginAspect{labels}
%    \end{macrocode}
%
% \begin{lstkey}{labelstyle}
% \begin{lstkey}{labelsep}
% \begin{lstkey}{labelstep}
% \begin{lstkey}{firstlabel}
% \begin{lstkey}{advancelabel}
% Definition of the keys.
%    \begin{macrocode}
\lst@Key{labelstyle}{}{\def\lst@labelstyle{#1}}
\lst@Key{labelsep}{10pt}{\def\lst@labelsep{#1}}
\lst@Key{labelstep}{0}{\def\lst@labelstep{#1\relax}}
\lst@Key{firstlabel}\relax{\def\lst@firstlabel{#1\relax}}
\lst@Key{advancelabel}\relax{\def\lst@advancelabel{#1\relax}}
\lst@AddToHook{EmptyStyle}{\let\lst@labelstep\z@}
%    \end{macrocode}
% \keyname{firstlabel} and \keyname{advancelabel} need no initialization since this is done via \hookname{PreSet}.
%    \begin{macrocode}
\lst@AddToHook{PreSet}
    {\let\lst@firstlabel\@undefined \let\lst@advancelabel\z@}
\lst@AddToHook{PreInit}
    {\ifx\lst@firstlabel\@undefined
         \let\lst@firstlabel\lst@firstline
     \fi}
%    \end{macrocode}
% \end{lstkey}\end{lstkey}\end{lstkey}\end{lstkey}
% \end{lstkey}
%
% \begin{macro}{\lst@SetFirstLabel}
% \begin{macro}{\lst@SaveFirstLabel}
% \lsthelper{Boris~Veytsman}{1998/03/25}{continue line numbering: a.c b.c a.c} proposed to continue line numbers according to listing names.
% We define the label number of the first printing line here.
%    \begin{macrocode}
\gdef\lst@SetFirstLabel{%
    \ifx\lst@firstlabel\@undefined
        \@tempcnta 0\csname lstno@\lst@intname\endcsname\relax
        \ifnum\@tempcnta=\z@ \@tempcnta\@ne \else \lst@continuetrue \fi
        \advance\@tempcnta\lst@advancelabel
        \edef\lst@firstlabel{\the\@tempcnta\relax}%
    \fi}
%    \end{macrocode}
% The current label is stored in|\lstno@|\meta{name}.
% If the name is empty, we use a space instead, which leaves |\lstno@| undefined.
%    \begin{macrocode}
\gdef\lst@SaveFirstLabel{%
    \expandafter\xdef
        \csname lstno\ifx\lst@intname\@empty @ \else @\lst@intname\fi
        \endcsname{\the\c@lstlabel}}
%    \end{macrocode}
% \end{macro}\end{macro}
%
% \begin{macro}{\c@lstlabel}
% This counter keeps the current label number.
% It advances \emph{before} the label is printed and not afterwards.
% Otherwise we have wrong references --- reported by \lsthelper{Gregory~Van~Vooren}{1999/06/04}{reference one unit too large}.
%    \begin{macrocode}
\newcounter{lstlabel}% \global
\renewcommand*\thelstlabel{\@arabic\c@lstlabel}
\lst@AddToHook{EveryLine}
    {\global\advance\c@lstlabel\lst@labeladvance \lst@SkipOrPrintLabel}
\global\let\lst@labeladvance\@ne
%    \end{macrocode}
% We use it as current label to make line numbers referenced by |\ref|.
% This was proposed by \lsthelper{Boris~Veytsman}{1998/03/25}{make line numbers referenced via \label and \ref}.
%    \begin{macrocode}
\lst@AddToHook{Init}{\def\@currentlabel{\thelstlabel}}
%    \end{macrocode}
% The label number is initialized and we ensure correct line numbers for continued listings.
%    \begin{macrocode}
\lst@AddToHook{InitVars}
    {\global\c@lstlabel\lst@firstlabel
     \global\advance\c@lstlabel\lst@advancelabel
     \global\advance\c@lstlabel-\lst@labeladvance}
\lst@AddToHook{ExitVars}
    {\global\advance\c@lstlabel\lst@labeladvance}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@skiplabels}
% There are more things to do.
% We calculate how many lines must skip their label.
% The formula is
%	$$|\lst@skiplabels|=
%		\textrm{\emph{first printing line}}\bmod|\lst@labelstep|.$$
% Note that we use a nonpositive representative for |\lst@skiplabels|.
%    \begin{macrocode}
\newcount\lst@skiplabels % \global
\lst@AddToHook{Init}
    {\ifnum \z@<\lst@labelstep
         \global\lst@skiplabels\lst@firstlabel
         \global\divide\lst@skiplabels\lst@labelstep
         \global\multiply\lst@skiplabels-\lst@labelstep
         \global\advance\lst@skiplabels\lst@firstlabel
         \ifnum\lst@skiplabels>\z@
             \global\advance\lst@skiplabels -\lst@labelstep
         \fi
%    \end{macrocode}
% If |\lst@labelstep| is nonpositive (in fact zero), no labels are printed:
%    \begin{macrocode}
     \else
         \let\lst@SkipOrPrintLabel\relax
     \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@SkipOrPrintLabel}
% But default is this.
% We use the fact that |\lst@skiplabels| is nonpositive.
% The counter advances every line and if that counter is zero, we print a line number and decrement the counter by |\lst@labelstep|.
%    \begin{macrocode}
\gdef\lst@SkipOrPrintLabel{%
    \ifnum\lst@skiplabels=\z@
        \global\advance\lst@skiplabels-\lst@labelstep\relax
        \llap{\normalfont\lst@labelstyle{\thelstlabel}%
              \kern\lst@labelsep}%
    \fi
    \global\advance\lst@skiplabels\@ne}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\lst@EndAspect
%</labels>
%    \end{macrocode}
% \end{aspect}
%
%
% \subsection{Line shape and line breaking}
%
% \begin{macro}{\lst@parshape}
% We define a default version of |\lst@parshape| for the case that the \aspectname{lineshape} aspect is not loaded.
% We use this parshape every line (in fact every paragraph).
% Furthermore we must repeat the parshape if we close a group level --- or the shape is forgotten.
%    \begin{macrocode}
%<*kernel>
\def\lst@parshape{\parshape\@ne \z@ \linewidth}
\lst@AddToHookAtTop{EveryLine}{\lst@parshape}
\lst@AddToHookAtTop{EndGroup}{\lst@parshape}
%</kernel>
%    \end{macrocode}
% \end{macro}
%
% \begin{aspect}{lineshape}
% Our first aspect in this section.
%    \begin{macrocode}
%<*lineshape>
\lst@BeginAspect{lineshape}
%    \end{macrocode}
%
% \begin{macro}{\lst@innerspread}
% \begin{macro}{\lst@outerspread}
% Just allocate these dimensions.
%    \begin{macrocode}
\newdimen\lst@innerspread \newdimen\lst@outerspread
%    \end{macrocode}
% They become zero if we make an exact box around the listing.
%    \begin{macrocode}
\lst@AddToHook{BoxUnsave}{\lst@outerspread\z@ \lst@innerspread\z@}
%    \end{macrocode}
% \end{macro}\end{macro}
%
% \begin{lstkey}{wholeline}
% \begin{lstkey}{indent}
% \begin{lstkey}{spread}
% Usual stuff.
%    \begin{macrocode}
\lst@Key{wholeline}{false}[t]{\lstKV@SetIf{#1}\lst@ifwholeline}
\lst@Key{indent}{\z@}{\def\lst@indent{#1}}
%    \end{macrocode}
% \lsthelper{Harald~Harders}{1998/03/30}{inner- and outerspread} had the idea of two spreads (inner and outer).
% We either divide the dimension by two or assign the two dimensions to inner- and outerspread.
%    \begin{macrocode}
\lst@Key{spread}{\z@,\z@}{\lstKV@CSTwoArg{#1}%
    {\lst@innerspread##1\relax
     \ifx\@empty##2\@empty
         \divide\lst@innerspread\tw@\relax
         \lst@outerspread\lst@innerspread
     \else
         \lst@outerspread##2\relax
     \fi}}
%    \end{macrocode}
% \end{lstkey}\end{lstkey}\end{lstkey}
%
% \begin{macro}{\lst@parshape}
% The definition itself is easy.
%    \begin{macrocode}
\gdef\lst@parshape{%
    \parshape\@ne
        \ifodd\c@page -\lst@innerspread\else -\lst@outerspread\fi
        \linewidth}
%    \end{macrocode}
% We calculate the line width and (inner/outer) indent for a listing.
%    \begin{macrocode}
\lst@AddToHook{Init}
    {\advance\linewidth\lst@innerspread
     \advance\linewidth\lst@outerspread
     \advance\linewidth-\lst@indent\relax
     \advance\lst@innerspread-\lst@indent\relax
     \advance\lst@outerspread-\lst@indent\relax
     \lst@ifwholeline
         \advance\linewidth\@totalleftmargin
     \else
         \advance\lst@innerspread-\@totalleftmargin
         \advance\lst@outerspread-\@totalleftmargin
     \fi
     \if@twoside\else \lst@outerspread\lst@innerspread \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{lstkey}{lineskip}
% The introduction of this key is due to communication with \lsthelper{Andreas~Bartelt}{1997/09/11}{problem with redefed \parskip; \lstlineskip introduced}.
%    \begin{macrocode}
\lst@Key{lineskip}{\z@}{\def\lst@lineskip{#1\relax}}
\lst@AddToHook{Init}{\parskip\lst@lineskip}
%    \end{macrocode}
% \end{lstkey}
%
%    \begin{macrocode}
\lst@EndAspect
%</lineshape>
%    \end{macrocode}
% \end{aspect}
%
% \begin{aspect}{breaklines}
% As usual \ldots
%    \begin{macrocode}
%<*breaklines>
\lst@BeginAspect[lineshape]{breaklines}
%    \end{macrocode}
%
% \begin{lstkey}{breaklines}
% \begin{lstkey}{breakindent}
% \begin{lstkey}{breakautoindent}
% \begin{lstkey}{prebreak}
% \begin{lstkey}{postbreak}
% we have no problems in announcing the keys.
%    \begin{macrocode}
\lst@Key{breaklines}{false}[t]{\lstKV@SetIf{#1}\lst@ifbreaklines}
\lst@Key{breakindent}{20pt}{\def\lst@breakindent{#1}}
\lst@Key{breakautoindent}{t}[t]{\lstKV@SetIf{#1}\lst@ifbreakautoindent}
\lst@Key{prebreak}{}{\def\lst@prebreak{#1}}
\lst@Key{postbreak}{}{\def\lst@postbreak{#1}}
%    \end{macrocode}
% We assign some different macros and (if necessary) suppress ``underfull |\hbox|'' messages (and use different pretolerance):
%    \begin{macrocode}
\lst@AddToHook{Init}
    {\lst@ifbreaklines
         \hbadness\@M \pretolerance\@M
         \let\lst@NewLineMacro\lst@breakNewLineMacro
%    \end{macrocode}
% We use the normal parshape and the calculated |\lst@breakshape| (see below).
%    \begin{macrocode}
         \def\lst@parshape{\parshape\tw@
             \ifodd\c@page -\lst@innerspread\else -\lst@outerspread\fi
             \linewidth %
             \lst@breakshape}%
     \else
         \let\lst@discretionary\relax
     \fi}
%    \end{macrocode}
% \end{lstkey}\end{lstkey}\end{lstkey}\end{lstkey}
% \end{lstkey}
%
% \begin{macro}{\lst@discretionary}
% \begin{macro}{\lst@spacekern}
% Here comes the whole magic:
% We set a discretionary break after each `output unit'.
% However we redefine |\space| to be used inside |\discretionary|.
%    \begin{macrocode}
\gdef\lst@discretionary{%
    \discretionary{\let\space\lst@spacekern\lst@prebreak}%
                  {\let\space\lst@spacekern\lst@postbreak}{}}
\lst@AddToHook{PostOutput}{\lst@discretionary}
\gdef\lst@spacekern{\kern\lst@width}
%    \end{macrocode}
% \begin{TODO}
% |\penalty\@M \hskip\z@ plus 1fil \penalty0 \hskip\z@ plus-1fil| \emph{before} each `output unit' (i.e.\ before |\hbox{...}| in the output macros) also break the lines as desired.
% If we use this alternative, the discretionary break should be removed since it has no effect.
% Ditto |prebreak| and |postbreak|, of course.
% \end{TODO}
% \end{macro}\end{macro}
%
% \begin{macro}{\lst@breakNewLineMacro}
% We use |breakindent|, and additionally the current line indention (coming from white spaces at the beginning of the line) if `auto indent' is on.
%    \begin{macrocode}
\gdef\lst@breakNewLineMacro{%
    \@tempdima\lst@breakindent\relax
    \lst@ifbreakautoindent \advance\@tempdima\lst@lostspace \fi
%    \end{macrocode}
% Now we calculate the inner/outer spread and line width of the wrapped part.
%    \begin{macrocode}
    \@tempdimb\@tempdima \@tempdimc-\@tempdima
    \advance\@tempdima-\lst@innerspread
    \advance\@tempdimb-\lst@outerspread
    \advance\@tempdimc\linewidth
%    \end{macrocode}
% And store it in |\lst@breakshape|.
%    \begin{macrocode}
    \xdef\lst@breakshape{%
        \noexpand\ifodd\c@page \the\@tempdima
        \noexpand\else \the\@tempdimb \noexpand\fi
        \the\@tempdimc}%
    \global\let\lst@NewLine\relax \par\noindent\hbox{}}
%    \end{macrocode}
% \begin{TODO}
% We could speed this up by allocating three more (global) dimensions.
% \end{TODO}
% \end{macro}
%
%    \begin{macrocode}
\lst@EndAspect
%</breaklines>
%    \end{macrocode}
% \end{aspect}
%
%
% \subsection{Frames}
%
% \begin{aspect}{frames}
% Another aspect.
%    \begin{macrocode}
%<*frames>
\lst@BeginAspect[lineshape]{frames}
%    \end{macrocode}
%
% \begin{lstkey}{framerulewidth}
% \begin{lstkey}{framerulesep}
% \begin{lstkey}{frametextsep}
% \begin{lstkey}{framespread}
% \begin{lstkey}{frameshape}
% All keys store the argument.
%    \begin{macrocode}
\lst@Key{framerulewidth}{.4pt}{\def\lst@framerulewidth{#1}}
\lst@Key{framerulesep}{2pt}{\def\lst@framerulesep{#1}}
\lst@Key{frametextsep}{3pt}{\def\lst@frametextsep{#1}}
\lst@Key{framespread}{\z@}{\def\lst@framespread{#1}}
\lst@Key{frameshape}{}{\lstKV@FourArg{#1}%
    {\uppercase{\def\lst@frametshape{##1}}%
     \uppercase{\def\lst@framelshape{##2}}%
     \uppercase{\def\lst@framershape{##3}}%
     \uppercase{\def\lst@framebshape{##4}}%
     \let\lst@ifframeround\iffalse
     \lst@IfSubstring R\lst@frametshape{\let\lst@ifframeround\iftrue}{}%
     \lst@IfSubstring R\lst@framebshape{\let\lst@ifframeround\iftrue}{}%
     \def\lst@frame{##1##2##3##4}}}
%    \end{macrocode}
% \end{lstkey}\end{lstkey}\end{lstkey}\end{lstkey}
% \end{lstkey}
%
% \begin{lstkey}{frameround}
% \begin{lstkey}{frame}
% We have to do some conversion here.
%    \begin{macrocode}
\lst@Key{frameround}\relax
    {\uppercase{\def\lst@frameround{#1}}%
     \expandafter\lstframe@\lst@frameround ffff\relax}
\global\let\lst@frameround\@empty
\lst@Key{frame}\relax
    {\def\lst@frame{#1}%
     \expandafter\lstframe@\lst@frameround ffff\relax}
%    \end{macrocode}
% Adding |t|, |r|, |b|, and |l| in case of their upper case versions makes later tests easier.
%    \begin{macrocode}
\gdef\lstframe@#1#2#3#4#5\relax{%
    \lst@IfSubstring T\lst@frame{\edef\lst@frame{t\lst@frame}}{}%
    \lst@IfSubstring R\lst@frame{\edef\lst@frame{r\lst@frame}}{}%
    \lst@IfSubstring B\lst@frame{\edef\lst@frame{b\lst@frame}}{}%
    \lst@IfSubstring L\lst@frame{\edef\lst@frame{l\lst@frame}}{}%
%    \end{macrocode}
% We now check top and bottom frame rules, \ldots
%    \begin{macrocode}
    \let\lst@frametshape\@empty \let\lst@framebshape\@empty
    \lst@frameCheck
        ltr\lst@framelshape\lst@frametshape\lst@framershape #4#1%
    \lst@frameCheck
        LTR\lst@framelshape\lst@frametshape\lst@framershape #4#1%
    \lst@frameCheck
        lbr\lst@framelshape\lst@framebshape\lst@framershape #3#2%
    \lst@frameCheck
        LBR\lst@framelshape\lst@framebshape\lst@framershape #3#2%
%    \end{macrocode}
% look for round corners \ldots
%    \begin{macrocode}
    \let\lst@ifframeround\iffalse
    \lst@IfSubstring R\lst@frametshape{\let\lst@ifframeround\iftrue}{}%
    \lst@IfSubstring R\lst@framebshape{\let\lst@ifframeround\iftrue}{}%
%    \end{macrocode}
% and define left and right frame shape.
%    \begin{macrocode}
    \let\lst@framelshape\@empty \let\lst@framershape\@empty
    \lst@IfSubstring L\lst@frame
        {\def\lst@framelshape{YY}}%
        {\lst@IfSubstring l\lst@frame{\def\lst@framelshape{Y}}{}}%
    \lst@IfSubstring R\lst@frame
        {\def\lst@framershape{YY}}%
        {\lst@IfSubstring r\lst@frame{\def\lst@framershape{Y}}{}}}
%    \end{macrocode}
% Now comes the macro used to define top and bottom frame shape.
% It extends the macro |#5|.
% The last two arguments show whether left and right corners are round.
% |#4| and |#6| are temporary macros.
% |#1#2#3| are the three characters we test for.
%    \begin{macrocode}
\gdef\lst@frameCheck#1#2#3#4#5#6#7#8{%
    \lst@IfSubstring #1\lst@frame
        {\if #7T\def#4{R}\else \def#4{Y}\fi}%
        {\def#4{N}}%
    \lst@IfSubstring #3\lst@frame
        {\if #8T\def#6{R}\else \def#6{Y}\fi}%
        {\def#6{N}}%
    \lst@IfSubstring #2\lst@frame{\edef#5{#5#4Y#6}}{}}
%    \end{macrocode}
% \end{lstkey}\end{lstkey}
%
% \begin{macro}{\lst@frameR}
% typesets right rules.
% We only need to iterate through |\lst@framershape|.
%    \begin{macrocode}
\gdef\lst@frameR{%
    \strut\smash{\expandafter\lst@frameR@\lst@framershape\relax}}
\gdef\lst@frameR@#1{%
    \ifx\relax#1\@empty\else
        \if #1Y\lst@framevrule \else \kern\lst@framerulewidth \fi
        \kern\lst@framerulesep
        \expandafter\lst@frameR@
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@frameL}
% Ditto left rules.
%    \begin{macrocode}
\gdef\lst@frameL{%
    \strut\smash{\expandafter\lst@frameL@\lst@framelshape\relax}}
\gdef\lst@frameL@#1{%
    \ifx\relax#1\@empty\else
        \kern\lst@framerulesep
        \if#1Y\lst@framevrule \else \kern\lst@framerulewidth \fi
        \expandafter\lst@frameL@
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@frameH}
% This is the central macro used to draw top and bottom frame rules.
% The first argument is either |T| or |B| and the second contains the shape.
% We use |\@tempcntb| as size counter.
%    \begin{macrocode}
\gdef\lst@frameH#1#2{%
    \setbox\z@\hbox{}\@tempcntb\z@
    \expandafter\lst@frameH@\expandafter#1#2\relax\relax\relax}
\gdef\lst@frameH@#1#2#3#4{%
    \ifx\relax#4\@empty\else
        \lst@frameh \@tempcntb#1#2#3#4%
        \advance\@tempcntb\@ne
        \expandafter\lst@frameH@\expandafter#1%
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@frameh}
% This is the low-level macro used to draw top and bottom frame rules.
% It \emph{adds} one rule plus corners to box 0.
% The first parameter gives the size of the corners and the second is either |T| or |B|.
% |#3#4#5| is a left-to-right description of the frame and is in $\{$\texttt{Y,N,R}$\}\times\{$\texttt{Y,N}$\}\times\{$\texttt{Y,N,R}$\}$.
% We move to the correct horizontal position, set the left corner, the horizontal line, and the right corner.
%    \begin{macrocode}
\gdef\lst@frameh#1#2#3#4#5{%
    \lst@frameCalcDimA#1%
    \lst@ifframeround \@getcirc\@tempdima \fi
%    \end{macrocode}
%    \begin{macrocode}
    \setbox\z@=\hbox{\rlap{\copy\z@}%
      \setbox\z@=\hbox{%
        \kern-\lst@indent
        \kern\ifodd\c@page -\lst@innerspread\else -\lst@outerspread\fi
        \kern-\lst@framehalfspread
%    \end{macrocode}
% |\lst@frameCorner| gets three arguments:
% |\llap|, |TL| or |BL|, and the corner type $\in\{$\texttt{Y,N,R}$\}$.
%    \begin{macrocode}
        \lst@frameCornerX\llap{#2L}#3%
        \begingroup
        \if#4Y\else\let\lst@framerulewidth\z@ \fi
        \vrule\@width\lst@framespread\@height\lst@framerulewidth
              \@depth\z@
        \vrule\@width\lst@indent\@height\lst@framerulewidth\@depth\z@
        \vrule\@width\linewidth\@height\lst@framerulewidth\@depth\z@
        \endgroup
        \lst@frameCornerX\rlap{#2R}#5%
        \kern-\lst@framehalfspread}%
%    \end{macrocode}
%    \begin{macrocode}
    \if#2T\raise\dp\z@\copy\z@
     \else\lower\ht\z@\copy\z@ \fi}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@frameCornerX}
% typesets a single corner.
%    \begin{macrocode}
\gdef\lst@frameCornerX#1#2#3{%
    \if #3R%
        #1{\csname lst@frameR#2\endcsname}%
    \else
        \if #3Y\expandafter#1\else \expandafter\vphantom \fi
        {\csname lst@frame#2\endcsname}
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@frameCalcDimA}
% calculates an all over width; used by |\lst@frameh| and |\lst@frameInit|.
%    \begin{macrocode}
\gdef\lst@frameCalcDimA#1{%
            \@tempdima\lst@framerulesep
    \advance\@tempdima\lst@framerulewidth
    \multiply\@tempdima#1\relax
    \advance\@tempdima\lst@frametextsep
    \advance\@tempdima\lst@framerulewidth
    \multiply\@tempdima\tw@}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@frameInit}
% First we look which frame types we have on the left and on the right.
% We speed up things if there are no vertical rules.
%    \begin{macrocode}
\lst@AddToHook{Init}{\ifx\lst@frame\@empty\else \lst@frameInit \fi}
\gdef\lst@frameInit{%
    \ifx\lst@framelshape\@empty \let\lst@frameL\relax \fi
    \ifx\lst@framershape\@empty \let\lst@frameR\relax \fi
    \def\lst@framelr{%
        \llap{\lst@frameL \kern\lst@frametextsep
              \kern\lst@framehalfspread \kern\lst@indent}%
        \rlap{\kern\linewidth
              \kern\lst@framehalfspread \kern\lst@frametextsep
              \lst@frameR}}
    \ifx\lst@frameL\relax \ifx\lst@frameR\relax
        \let\lst@framelr\strut
    \fi \fi
%    \end{macrocode}
% We determine the height and depth of a vertical rule \ldots
%    \begin{macrocode}
    \@tempdima\ht\strutbox\advance\@tempdima\lst@lineskip
    \@tempdimb\dp\strutbox\advance\@tempdimb\lst@lineskip
    \edef\lst@framevrule{%
        \vrule\noexpand\@height\the\@tempdima
              \noexpand\@depth\the\@tempdimb
              \noexpand\@width\noexpand\lst@framerulewidth}%
%    \end{macrocode}
% and two other dimensions.
%    \begin{macrocode}
    \@tempdima\lst@framerulewidth \divide\@tempdima\tw@
    \edef\lst@framerulehalfwidth{\the\@tempdima}%
    \@tempdima\lst@framespread\relax \divide\@tempdima\tw@
    \edef\lst@framehalfspread{\the\@tempdima}%
%    \end{macrocode}
% We adjust values to round corners if necessary.
%    \begin{macrocode}
    \lst@ifframeround
        \lst@frameCalcDimA\z@ \@getcirc\@tempdima
        \@tempdimb\@tempdima \divide\@tempdimb\tw@
        \advance\@tempdimb -\@wholewidth
        \edef\lst@frametextsep{\the\@tempdimb}%
        \edef\lst@framerulewidth{\the\@wholewidth}%
        \edef\lst@framerulehalfwidth{\the\@halfwidth}%
%    \end{macrocode}
%    \begin{macrocode}
        \lst@frameCalcDimA\@ne \@getcirc\@tempdima
        \@tempdimb\@tempdima \divide\@tempdimb\tw@
        \advance\@tempdimb -\tw@\@wholewidth
        \advance\@tempdimb -\lst@frametextsep
        \edef\lst@framerulesep{\the\@tempdimb}%
    \fi
%    \end{macrocode}
% Finally we typeset the rules (+ corners).
%    \begin{macrocode}
    \expandafter\lst@frameH T\lst@frametshape
    \ifvoid\z@\else
        \par\parshape\z@\nointerlineskip\noindent\box\z@
    \fi
    \lst@frameSpreadV}
%    \end{macrocode}
% |\parshape\z@| ensures that the top rules aren't indented any more.
% The bug was reported by \lsthelper{Marcin~Kasperski}{1999/04/28}{top rules indented right inside itemize}.
%
% We typeset left and right rules every line.
%    \begin{macrocode}
\lst@AddToHook{EveryLine}{\lst@framelr}
\global\let\lst@framelr\@empty
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@frameExit}
% The rules at the bottom.
%    \begin{macrocode}
\lst@AddToHook{DeInit}{\ifx\lst@frame\@empty\else \lst@frameExit \fi}
\gdef\lst@frameExit{%
    \lst@frameSpreadV
    \lst@frameH B\lst@framebshape
    \ifvoid\z@\else
        \everypar{}\par\nointerlineskip\noindent\box\z@
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@frameSpreadV}
% sets rules for vertical spread.
%    \begin{macrocode}
\gdef\lst@frameSpreadV{%
    \ifdim\z@=\lst@framespread\else
        \everypar{}\par\parshape\z@\nointerlineskip\noindent
        \setbox\z@=\hbox{%
            \def\lst@framevrule{\vrule\@height\lst@framehalfspread
                \@depth\z@\@width\lst@framerulewidth}%
            \let\strut\@empty
            \lst@framelr
            \vrule\@height\lst@framehalfspread\@depth\z@\@width\z@}%
        \llap{\box\z@}%
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@frameTR}
% \begin{macro}{\lst@frameBR}
% \begin{macro}{\lst@frameBL}
% \begin{macro}{\lst@frameTL}
% These macros make a vertical and horizontal rule.
% The implicit argument |\@tempdima| gives the size of two corners and is provided by |\lst@frameh|.
%    \begin{macrocode}
\gdef\lst@frameTR{%
    \vrule\@width.5\@tempdima\@height\lst@framerulewidth\@depth\z@
    \kern-\lst@framerulewidth
    \raise\lst@framerulewidth\hbox{%
        \vrule\@width\lst@framerulewidth\@height\z@\@depth.5\@tempdima}}
\gdef\lst@frameBR{%
    \vrule\@width.5\@tempdima\@height\lst@framerulewidth\@depth\z@
    \kern-\lst@framerulewidth
    \vrule\@width\lst@framerulewidth\@height.5\@tempdima\@depth\z@}
\gdef\lst@frameBL{%
    \vrule\@width\lst@framerulewidth\@height.5\@tempdima\@depth\z@
    \kern-\lst@framerulewidth
    \vrule\@width.5\@tempdima\@height\lst@framerulewidth\@depth\z@}
\gdef\lst@frameTL{%
    \raise\lst@framerulewidth\hbox{%
        \vrule\@width\lst@framerulewidth\@height\z@\@depth.5\@tempdima}%
    \kern-\lst@framerulewidth
    \vrule\@width.5\@tempdima\@height\lst@framerulewidth\@depth\z@}
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}
%
% \begin{macro}{\lst@frameRTR}
% \begin{macro}{\lst@frameRBR}
% \begin{macro}{\lst@frameRBL}
% \begin{macro}{\lst@frameRTL}
% The round corners.
%    \begin{macrocode}
\gdef\lst@frameRTR{%
    \kern-\lst@framerulewidth
                           \kern.5\@tempdima \@circlefnt\char\@tempcnta}
\gdef\lst@frameRBR{%
    \kern-\lst@framerulewidth
    \advance\@tempcnta\@ne \kern.5\@tempdima \@circlefnt\char\@tempcnta}
\gdef\lst@frameRBL{%
    \advance\@tempcnta\tw@ \@circlefnt\char\@tempcnta
    \kern-.5\@tempdima}
\gdef\lst@frameRTL{%
    \advance\@tempcnta\thr@@\@circlefnt\char\@tempcnta
    \kern-.5\@tempdima}
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}
%
%    \begin{macrocode}
\lst@EndAspect
%</frames>
%    \end{macrocode}
% \end{aspect}
%
%
% \subsection{Macro use for make}
%
% \begin{aspect}{make}
% \begin{macro}{\lst@makemode}
% \begin{macro}{\lst@ifmakekey}
% We begin with preliminaries.
%    \begin{macrocode}
%<*make>
\lst@BeginAspect[keywords]{make}
%    \end{macrocode}
%    \begin{macrocode}
\lst@NewMode\lst@makemode
\def\lst@makekeyfalse{\let\lst@ifmakekey\iffalse}
\def\lst@makekeytrue{\let\lst@ifmakekey\iftrue}
\lst@makekeyfalse
%    \end{macrocode}
% \end{macro}\end{macro}
%
% \begin{lstkey}{makemacrouse}
% adjusts the character table if necessary
%    \begin{macrocode}
\lst@Key{makemacrouse}f[t]{\lstKV@SetIf{#1}\lst@ifmakemacrouse}
\lst@AddToHook{SelectCharTable}
    {\lst@ifmakemacrouse
%    \end{macrocode}
% The opening |$(| prints preceding characters, enters a special mode and stores the two characters in |\lst@aside|.
%    \begin{macrocode}
         \lst@ReplaceInput{$(}{%
             \lst@PrintToken
             \lst@EnterMode\lst@makemode{\lst@makekeyfalse}%
             \def\lst@aside{\lst@ProcessOther\$\lst@ProcessOther(}}%
%    \end{macrocode}
% The closing parenthesis tests for the mode and either processes |)| as usual or outputs it right here (in keyword style if a keyword was between |$(| and |)|).
%    \begin{macrocode}
         \lst@ReplaceInput{)}{%
             \ifnum\lst@mode=\lst@makemode
                 \lst@PrintToken
                 \begingroup
                     \lst@ProcessOther)%
                     \lst@ifmakekey
                         \lst@gkeywordstyle\lst@OutputOther
                     \else
                         \lst@OutputOther
                     \fi
                 \endgroup
                 \lst@LeaveMode
             \else
                 \expandafter\lst@ProcessOther\expandafter)%
             \fi}%
%    \end{macrocode}
% If `makemacrouse' is off but the programming language Make is active, then both characters |$(| are treated `other'.
%    \begin{macrocode}
     \else \ifx\lst@language\lst@make
         \lst@ReplaceInput{$(}{\lst@ProcessOther\$\lst@ProcessOther(}%
     \fi \fi}
%    \end{macrocode}
%    \begin{macrocode}
\gdef\lst@make{make}
\lst@AddToHook{InitVars}{\let\lst@aside\@empty}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{macro}{\lst@makePrintAside}
% does what the name says.
% The argument |#1| determines the printing style.
% This will be either |\relax| or |\lst@thestyle|.
% Because of recursion we must empty |\lst@aside| twice.
%    \begin{macrocode}
\def\lst@makePrintAside#1{%
    \ifx\lst@aside\@empty\else
        \begingroup
        \lst@token{}\lst@length\z@ \lst@aside \let\lst@aside\@empty
        #1{\lst@OutputOther}%
        \endgroup
        \let\lst@aside\@empty
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begingroup
% \noindent
% The remaining part is easy and important since we switch to |\lst@makekeytrue| if `make mode' is active and a keyword was found.
% Here we print all characters put aside.
%    \begin{macrocode}
\lst@AddToHook{OutputOther}{\lst@makePrintAside\relax}
\lst@AddToHook{Output}{%
    \ifnum\lst@mode=\lst@makemode
        \ifx\lst@thestyle\lst@gkeywordstyle
            \lst@makekeytrue
        \fi
    \fi
    \lst@makePrintAside\lst@thestyle}
%    \end{macrocode}
% \endgroup
%
%    \begin{macrocode}
\lst@EndAspect
%</make>
%    \end{macrocode}
% \end{aspect}
%
%
% \section{Obsolete definitions}
%
%
% \subsection{Pre and post listing}
%
% \begin{lstkey}{pre}
% \begin{lstkey}{post}
% Use |[{#1}]| instead of the empty |[]| after communication with \lsthelper{Holger~Danielsson}{1999/01/24}{use <commands to execute> if <continue> empty}.
%    \begin{macrocode}
%<*kernel>
\lst@Key{pre}{}{\lstKV@OptArg[{#1}]{#1}%
    {\def\lst@prelisting{##2}\def\lst@@prelisting{##1}}}
\lst@Key{post}{}{\lstKV@OptArg[{#1}]{#1}%
    {\def\lst@postlisting{##2}\def\lst@@postlisting{##1}}}
%    \end{macrocode}
%    \begin{macrocode}
\lst@AddToHook{Init}{\lst@ifcontinue \expandafter\lst@@prelisting
                               \else \expandafter\lst@prelisting\fi}
\lst@AddToHook{DeInit}{\lst@ifcontinue \expandafter\lst@@postlisting
                                 \else \expandafter\lst@postlisting\fi}
%    \end{macrocode}
% They are possibly unsave if we put the listing in a box.
%    \begin{macrocode}
\lst@AddToHook{BoxUnsave}
    {\let\lst@prelisting\relax \let\lst@postlisting\relax
     \let\lst@@prelisting\relax\let\lst@@postlisting\relax}
%</kernel>
%    \end{macrocode}
% \end{lstkey}\end{lstkey}
%
%
% \section{Typesetting a listing}
%
% \begingroup
%    \begin{macrocode}
%<*kernel>
%    \end{macrocode}
% \endgroup
% \begin{macro}{\lst@lineno}
% \begin{lstkey}{print}
% \begin{lstkey}{first}
% \begin{lstkey}{last}
% The `current line' counter and three keys.
%    \begin{macrocode}
\newcount\lst@lineno % \global
\lst@AddToHook{InitVars}{\global\lst@lineno\@ne}
%    \end{macrocode}
%    \begin{macrocode}
\lst@Key{print}{true}[t]{\lstKV@SetIf{#1}\lst@ifprint}
\lst@Key{first}\relax{\def\lst@firstline{#1\relax}}
\lst@Key{last}\relax{\def\lst@lastline{#1\relax}}
%    \end{macrocode}
%    \begin{macrocode}
\lst@AddToHook{PreSet}
    {\let\lst@firstline\@ne \def\lst@lastline{9999999\relax}}
%    \end{macrocode}
% \end{lstkey}\end{lstkey}\end{lstkey}\end{macro}
%
% \begin{lstkey}{continue}
% |\lst@ifcontinue| is undefined if the key is not used explicitly.
% But if undefined it becomes false before the \hookname{Init} hook is executed.
%    \begin{macrocode}
\lst@Key{continue}\relax[t]{\lstKV@SetIf{#1}\lst@ifcontinue}
\def\lst@continuetrue{\let\lst@ifcontinue\iftrue}
\def\lst@continuefalse{\let\lst@ifcontinue\iffalse}
%    \end{macrocode}
%    \begin{macrocode}
\lst@AddToHook{PreSet}{\let\lst@ifcontinue\@undefined}
\lst@AddToHook{PreInit}
    {\ifx\lst@ifcontinue\@undefined \lst@continuefalse \fi}
%    \end{macrocode}
% \end{lstkey}
%
%
% \subsection{Floats, boxes and captions}
%
% \begin{lstkey}{caption}
% \begin{lstkey}{captionpos}
% \begin{lstkey}{abovecaptionskip}
% \begin{lstkey}{belowcaptionskip}
% Some keys, \ldots
%    \begin{macrocode}
\lst@Key{caption}\relax{\lstKV@OptArg[{#1}]{#1}%
    {\def\lst@caption{##2}\def\lst@@caption{##1}}}
\lst@AddToHook{PreSet}{\let\lst@caption\@empty \let\lst@@caption\@empty}
\lst@Key{captionpos}{t}{\def\lst@captionpos{#1}}
\lst@Key{abovecaptionskip}\smallskipamount{\def\lst@abovecaption{#1}}
\lst@Key{belowcaptionskip}\smallskipamount{\def\lst@belowcaption{#1}}
%    \end{macrocode}
% \end{lstkey}\end{lstkey}\end{lstkey}\end{lstkey}
%
% \begin{macro}{\thelstlisting}
% \begin{macro}{\lstlistingname}
% and how the caption numbers look like.
%    \begin{macrocode}
\ifx\chapter\@undefined
    \newcounter{lstlisting}
    \renewcommand\thelstlisting{\@arabic\c@lstlisting}
\else
    \newcounter{lstlisting}[chapter]
    \renewcommand\thelstlisting
         {\ifnum \c@chapter>\z@ \thechapter.\fi \@arabic\c@lstlisting}
\fi
%    \end{macrocode}
%    \begin{macrocode}
\lst@UserCommand\lstlistingname{Listing}
%    \end{macrocode}
% \end{macro}\end{macro}
%
% \begin{macro}{\lst@MakeCaption}
% We make a caption if and only if the caption is not empty and the user requested a caption at |#1| $\in\{\mathtt t,\mathtt b\}$.
% Moreover we use the listing counter if and only if |\lst@@caption| is not empty.
%    \begin{macrocode}
\def\lst@MakeCaption#1{%
    \ifx\lst@caption\@empty\else
        \ifx\lst@@caption\@empty\else
            \if #1t\refstepcounter{lstlisting}\fi
        \fi
        \lst@IfSubstring #1\lst@captionpos
            {\par\@makecaption
                {\noindent\lstlistingname
                 \ifx\lst@@caption\@empty\else~\thelstlisting\fi}%
                \lst@caption}{}%
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{lstkey}{boxpos}
% \begin{macro}{\lst@boxtrue}
% sets the vertical alignment of the (possibly) used box respectively indicates that a box is used.
%    \begin{macrocode}
\lst@Key{boxpos}{c}{\def\lst@boxpos{#1}}
%    \end{macrocode}
%    \begin{macrocode}
\def\lst@boxtrue{\let\lst@ifbox\iftrue}
\let\lst@ifbox\iffalse
%    \end{macrocode}
% \end{macro}\end{lstkey}
%
% \begin{lstkey}{float}
% Just the key.
%    \begin{macrocode}
\lst@Key{float}\relax[tbp]{\def\lst@float{#1}}
\lst@AddToHook{PreSet}{\let\lst@float\relax}
%    \end{macrocode}
% The float type |\ftype@lstlisting| is set according to whether the \packagename{float} package is loaded and whether \texttt{figure} and \texttt{table} floats are defined.
%    \begin{macrocode}
\ifx\c@float@type\@undefined
    \edef\ftype@lstlisting{\ifx\c@figure\@undefined 1\else 4\fi}
\else
    \edef\ftype@lstlisting{\the\c@float@type}
    \addtocounter{float@type}{\value{float@type}}
\fi
%    \end{macrocode}
% \end{lstkey}
%
%
% \subsection{Init and EOL}
%
% \begin{macro}{\lst@Init}
% Begin a float if requested.
%    \begin{macrocode}
\def\lst@Init#1{%
    \begingroup
    \ifx\lst@float\relax\else
        \edef\@tempa{\noexpand\@float{lstlisting}[\lst@float]}%
        \expandafter\@tempa
    \fi
%    \end{macrocode}
% In restricted horizontal \TeX\ mode we switch to |\lst@boxtrue|.
% In that case we make appropriate box(es) around the listing.
%    \begin{macrocode}
    \ifhmode\ifinner \lst@boxtrue \fi\fi
    \lst@ifbox
        \lsthk@BoxUnsave
        \hbox to\z@\bgroup
             $\if t\lst@boxpos \vtop
        \else \if b\lst@boxpos \vbox
        \else \vcenter \fi\fi
        \bgroup
    \else
        \smallbreak
    \fi
%    \end{macrocode}
% Making the top caption.
%    \begin{macrocode}
    \normalbaselines
    \abovecaptionskip\lst@abovecaption\relax
    \belowcaptionskip\lst@belowcaption\relax
    \lst@MakeCaption t%
%    \end{macrocode}
% Some initialization:
%    \begin{macrocode}
    \lsthk@PreInit \lsthk@Init
    \par\nointerlineskip \normalbaselines
    \everypar{\lsthk@EveryLine}%
    \lsthk@InitVars \lsthk@InitVarsBOL
%    \end{macrocode}
% The end of line character chr(13)=|^^M| controls the processing, see the definition of |\lst@MProcessListing| below.
% The argument |#1| is either |\relax| or |\lstenv@backslash|.
%    \begin{macrocode}
    \lst@Let{13}\lst@MProcessListing
    \let\lst@Backslash#1%
    \lst@EnterMode{\lst@Pmode}{\lst@SelectCharTable}}
%    \end{macrocode}
% Note: From version 0.19 on `listing processing' is implemented as an internal mode, namely a mode with special character table.
%    \begin{macrocode}
\lst@AddToHook{InitVars}
    {\rightskip\z@ \leftskip\z@ \parfillskip=\z@ plus 1fil
     \let\par\@@par}
%    \end{macrocode}
% \end{macro}
%
% \begin{lstkey}{showlines}
% lets the user control whether empty lines at the end of a listing are printed.
% But you know that if you've read the user's guide.
%    \begin{macrocode}
\lst@Key{showlines}f[t]{\lstKV@SetIf{#1}\lst@ifshowlines}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{macro}{\lst@DeInit}
% Output the remaining characters and update all things.
% Note that we remove two 
%    \begin{macrocode}
\def\lst@DeInit{%
    \lst@PrintToken \lst@EOLUpdate
    \ifx\lst@NewLine\lst@NewLineMacro\else
        \expandafter\lst@RemovePars\lst@NewLine\@empty
        \lst@ifshowlines
            \lst@NewLine
        \else
            \setbox\@tempboxa\vbox{\lst@NewLine}%
        \fi
    \fi
    \par\removelastskip
    \lsthk@ExitVars \lsthk@DeInit
%    \end{macrocode}
% Making the bottom caption.
%    \begin{macrocode}
    \lst@MakeCaption b%
%    \end{macrocode}
% Close the boxes if necessary and make a rule to get the right width.
%    \begin{macrocode}
    \lst@ifbox
        \egroup $\hss \egroup
        \vrule\@width\lst@maxwidth\@height\z@\@depth\z@
    \else
        \smallbreak
    \fi
%    \end{macrocode}
% End the float if necessary.
%    \begin{macrocode}
    \ifx\lst@float\relax\else
        \expandafter\end@float
    \fi
    \endgroup}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@maxwidth}
% is to be allocated, initialized and updated.
%    \begin{macrocode}
\newdimen\lst@maxwidth % \global
\lst@AddToHook{InitVars}{\global\lst@maxwidth\z@}
\lst@AddToHook{InitVarsEOL}
    {\ifdim\lst@linewidth>\lst@maxwidth
         \global\lst@maxwidth\lst@linewidth
     \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@EOLUpdate}
% What do you think this macro does?
%    \begin{macrocode}
\def\lst@EOLUpdate{\lsthk@EOL \lsthk@InitVarsEOL \lsthk@InitVarsBOL}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@MProcessListing}
% This is what we have to do at EOL while processing a listing.
% We output all remaining characters and update the variables.
% We call |\lst@EndProcessListing| if the next line number is greater than the last printing line.
% Finally we gobble characters to come to the beginning of the next line.
%    \begin{macrocode}
\def\lst@MProcessListing{%
    \lst@PrintToken \lst@EOLUpdate \global\advance\lst@lineno\@ne
    \ifnum \lst@lineno>\lst@lastline
        \expandafter\lst@EndProcessListing
    \else
        \expandafter\lst@BOLGobble
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@EndProcessListing}
% Default definition is |\endinput|.
% This works for |\lstinputlisting|.
%    \begin{macrocode}
\let\lst@EndProcessListing\endinput
%    \end{macrocode}
% \end{macro}
%
% \begin{lstkey}{gobble}
% The key sets the number of characters to gobble each line.
%    \begin{macrocode}
\lst@Key{gobble}{0}{\def\lst@gobble{#1}}
%    \end{macrocode}
% \end{lstkey}
%
% \begin{macro}{\lst@BOLGobble}
% If the number is positive, we set a temporary counter and start a loop.
%    \begin{macrocode}
\def\lst@BOLGobble{%
    \ifnum\lst@gobble>\z@
        \@tempcnta\lst@gobble\relax
        \expandafter\lst@BOLGobble@
	\fi}
%    \end{macrocode}
% A nonpositive number terminates the loop (by not continuing).
% Note: This is not the macro just used in |\lst@BOLGobble|.
%    \begin{macrocode}
\def\lst@BOLGobble@@{%
    \ifnum\@tempcnta>\z@
        \expandafter\lst@BOLGobble@
    \fi}
%    \end{macrocode}
% If we gobble a backslash, we have to look whether this backslash ends an environment.
% Whether the coming characters equal e.g.\ |end{lstlisting}|, we either end the environment or insert all just eaten characters after the `continue loop' macro.
%    \begin{macrocode}
\def\lstenv@BOLGobble@@{%
    \lst@IfNextChars\lstenv@endstring{\lstenv@End}%
    {\advance\@tempcnta\m@ne \expandafter\lst@BOLGobble@@\lst@eaten}}
%    \end{macrocode}
% Now comes the loop:
% If we read |\relax|, EOL or FF, the next operation is exactly the same token.
%    \begin{macrocode}
\def\lst@BOLGobble@#1{%
    \let\lst@next#1%
    \ifx \lst@next\relax\else
    \ifx \lst@next\lst@MProcessListing\else
    \ifx \lst@next\lst@ProcessFormFeed\else
%    \end{macrocode}
% Otherwise we use one of the two submacros.
%    \begin{macrocode}
    \ifx \lst@next\lstenv@backslash
        \let\lst@next\lstenv@BOLGobble@@
    \else
        \let\lst@next\lst@BOLGobble@@
%    \end{macrocode}
% Now we really gobble characters.
% A tabulator decreases the temporary counter by |\lst@tabsize| (and deals with remaining amounts, if necessary), \ldots
%    \begin{macrocode}
        \ifx #1\lst@ProcessTabulator
            \advance\@tempcnta-\lst@tabsize\relax
            \ifnum\@tempcnta<\z@
                \lst@length-\@tempcnta \lst@PreGotoTabStop
            \fi
%    \end{macrocode}
% whereas any other character decreases the counter by one.
%    \begin{macrocode}
        \else
            \advance\@tempcnta\m@ne
        \fi
    \fi \fi \fi \fi
    \lst@next}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{List of listings}
%
% \begin{macro}{\lstname}
% \begin{macro}{\lstintname}
% As proposed by \lsthelper{Boris~Veytsman}{1998/03/22}{listing name accessible for user} the name of a listing (file name or argument to the environment) is user accessible.
% Each pretty-printing command values |\lst@intname| before setting any keys.
% We define default |\lstintname| and |\lstname|.
%    \begin{macrocode}
\lst@AddToHook{PreSet}{\global\let\lst@intname\@empty}
\lst@AddToHook{PreInit}{%
    \global\let\lstintname\lst@intname
    \let\lst@arg\lst@intname \lst@ReplaceIn\lst@arg\lst@filenamerpl
    \global\let\lstname\lst@arg}
\global\let\lst@intname\@empty
%    \end{macrocode}
% Usage of |\lst@ReplaceIn| removes a bug first reported by \lsthelper{Magne~Rudshaug}{1998/01/09}{_ and list of listings}.
% Here is the replacement list.
%    \begin{macrocode}
\def\lst@filenamerpl{_\textunderscore $\textdollar -\textendash}
%    \end{macrocode}
% \end{macro}\end{macro}
%
% \begin{macro}{\l@lstlisting}
% prints one `lol' line.
%    \begin{macrocode}
\def\l@lstlisting#1#2{\@dottedtocline{1}{1.5em}{2.3em}{#1}{#2}}
%    \end{macrocode}
% We make a `lol' entry if the name is neither empty nor a single space.
% But we test |\lst@|(|@|)|caption| and |\lst@ifcontinue| first.
%    \begin{macrocode}
\lst@AddToHook{Init}
    {\ifx\lst@@caption\@empty
         \ifx\lst@caption\@empty
             \lst@ifcontinue\else
                 \ifx\lst@intname\@empty \else \def\lst@temp{ }%
                 \ifx\lst@intname\lst@temp \else
                     \addcontentsline{lol}{lstlisting}\lstname
                 \fi\fi
             \fi
         \fi
     \else
         \addcontentsline{lol}{lstlisting}%
             {\protect\numberline\thelstlisting\lst@@caption}%
     \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstlistlistingname}
% contains simply the header name.
%    \begin{macrocode}
\lst@UserCommand\lstlistlistingname{Listings}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstlistoflistings}
% We make local adjustments and call |\tableofcontents|.
% This way redefinitions of that macro (e.g.\ without any |\MakeUppercase| inside) also take effect on the list of listings.
%    \begin{macrocode}
\lst@UserCommand\lstlistoflistings{\bgroup
    \let\contentsname\lstlistlistingname
    \let\lst@temp\@starttoc \def\@starttoc##1{\lst@temp{lol}}%
    \tableofcontents \egroup}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Inline listings}\label{iInlineListings}
%
% \begin{macro}{\lstinline}
% In addition to |\lsthk@PreSet|, we use |boxpos=b| and flexiblecolumns.
% Finally we test the delimiter.
%    \begin{macrocode}
\newcommand\lstinline[1][]{%
    \hbox\bgroup
        \def\lst@boxpos{b}\let\lst@ifflexible\iftrue
        \lsthk@PreSet\lstset{#1}%
        \lsthk@InlineUnsave \lst@Init\relax 
        \everypar{}%
        \lstinline@}
\def\lstinline@#1{\lst@IfNextCharActive{\lst@InlineM#1}{\lst@InlineJ#1}}
\lst@AddToHook{InlineUnsave}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@InlineM}
% \begin{macro}{\lst@InlineJ}
% treat the cases of `normal' inlines and inline listings inside an argument.
% In the first case the given character ends the inline listing and EOL within such a listing immediately ends it and produces an error message.
%    \begin{macrocode}
\def\lst@InlineM#1{%
    \lst@Def{`#1}{\lst@DeInit\egroup}%
    \lst@Def{13}{\lst@DeInit\egroup
        \PackageError{Listings}{lstinline ended by EOL}\@ehc}}
%    \end{macrocode}
% In the other case we get all characters up to |#1|, make these characters active, execute (typeset) them and end the listing (all via temporary macro).
% That's all about it.
%    \begin{macrocode}
\def\lst@InlineJ#1{%
    \def\lst@temp##1#1{%
        \let\lst@arg\@empty \lst@InsideConvert{##1}\lst@arg
        \lst@DeInit\egroup}%
    \lst@temp}
%    \end{macrocode}
% \end{macro}\end{macro}
%
%
% \subsection{The input command}\label{iTheInputCommand}
%
% \begin{macro}{\lstinputlisting}
% inputs the listing or asks the user for a new file name.
%    \begin{macrocode}
\newcommand\lstinputlisting[2][]{%
    \def\lst@set{#1}%
    \IfFileExists{#2}%
        {\lst@InputListing{#2}}%
        {\filename@parse{#2}%
         \edef\reserved@a{\noexpand\lst@MissingFileError
             {\filename@area\filename@base}%
             {\ifx\filename@ext\relax tex\else\filename@ext\fi}}%
         \reserved@a}%
    \@doendpe \ignorespaces}
%    \end{macrocode}
% We use |\@doendpe| to remove indention at the beginning of the next line --- except there is an empty line after |\lstinputlisting|.
% Bug was reported by \lsthelper{David~John~Evans}{1999/06/08}{indention after listings} and \lsthelper{David~Carlisle}{1999/06/08}{LaTeX `display environment' code} pointed me to the solution.
% \end{macro}
%
% \begin{macro}{\lst@MissingFileError}
% is a derivation of \LaTeX's |\@missingfileerror|:
%    \begin{macrocode}
\def\lst@MissingFileError#1#2{%
    \typeout{^^J! Package Listings Error: File `#1.#2' not found.^^J^^J%
        Type X to quit or <RETURN> to proceed,^^J%
        or enter new name. (Default extension: #2)^^J}%
    \message{Enter file name: }%
    {\endlinechar\m@ne \global\read\m@ne to\@gtempa}%
%    \end{macrocode}
% Typing |x| or |X| exits.
%    \begin{macrocode}
    \ifx\@gtempa\@empty \else %
        \def\reserved@a{x}\ifx\reserved@a\@gtempa\batchmode\@@end\fi
        \def\reserved@a{X}\ifx\reserved@a\@gtempa\batchmode\@@end\fi
%    \end{macrocode}
% In all other cases we try the new file name.
%    \begin{macrocode}
        \filename@parse\@gtempa %
        \edef\filename@ext{%
            \ifx\filename@ext\relax#2\else\filename@ext\fi}%
        \edef\reserved@a{\noexpand\IfFileExists %
                {\filename@area\filename@base.\filename@ext}%
            {\noexpand\lst@InputListing %
                {\filename@area\filename@base.\filename@ext}}%
            {\noexpand\lst@MissingFileError
                {\filename@area\filename@base}{\filename@ext}}}%
        \expandafter\reserved@a %
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@InputListing}
% The one and only argument is the file name, but we have the `implicit' argument |\lst@set|.
% Note that |\lst@Init| takes |\relax| as argument.
%    \begin{macrocode}
\def\lst@InputListing#1{%
    \begingroup
    \lsthk@PreSet \gdef\lst@intname{#1}%
    \expandafter\lstset\expandafter{\lst@set}%
    \lst@ifprint
        \lst@Init\relax \lst@SkipToFirst \input{#1}\lst@DeInit
    \else
        \begin{center}%
        \footnotesize  ---  Listing of #1 has been skipped.  --- 
        \end{center}%
    \fi
    \endgroup}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@SkipToFirst}
% The end of line character either processes the listing or is responsible for dropping lines up to first printing line.
%    \begin{macrocode}
\def\lst@SkipToFirst{%
    \ifnum \lst@lineno=\lst@firstline \else
%    \end{macrocode}
% To drop input lines we begin a new group level (which makes our changes local) and prohibit mode changes.
% We redefine the end of line character and all output macros becomes equivalent to |\relax|, i.e.\ nothing is typeset.
%    \begin{macrocode}
        \bgroup \lst@modetrue
        \let\lst@Output\relax \let\lst@OutputOther\relax
        \let\lst@PreGotoTabStop\relax
        \lst@Let{13}\lst@MSkipToFirst
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@MSkipToFirst}
% At the moment we use a fast and not `everything is looking good' way.
% One input line has already been dropped when |\lst@MSkipToFirst| is executed.
% We end the group opened in |\lst@SkipToFirst|, which restores the definition of chr(13).
% Then we look whether to skip more lines.
%    \begin{macrocode}
\def\lst@MSkipToFirst{%
    \egroup \global\lst@lineno\tw@
    \ifnum \lst@lineno=\lst@firstline
        \expandafter\lst@BOLGobble
    \else
        \expandafter\lst@MSkipToFirst@
    \fi}
%    \end{macrocode}
% The argument of |\lst@MSkipToFirst@| ends with the next active chr(13), which means that the next input line is read.
% Again we look whether to skip more lines.
%    \begin{macrocode}
\begingroup \lccode`\~=`\^^M%
\lowercase{\gdef\lst@MSkipToFirst@#1~}{%
    \global\advance\lst@lineno\@ne
    \ifnum \lst@lineno=\lst@firstline
        \expandafter\lst@BOLGobble
    \else
        \expandafter\lst@MSkipToFirst@
    \fi}
\endgroup
%    \end{macrocode}
% \begin{TODO}
% This definition gives rise to a ``runaway argument'' if the line with number |\lst@firstline| doesn't exist since no |^^M| is found.
% Alternatively we could use |\lst@BeginDropOutput|.
% \end{TODO}
% \end{macro}
%
%
% \subsection{The environment}
%
%
% \subsubsection{\keyname{first} and \keyname{last} helpers}
%
% Partial output is more complicated for environments.
% We define some helpers.
%
% \begin{macro}{\lstenv@SkipToFirst}
% looks familiar.
%    \begin{macrocode}
\def\lstenv@SkipToFirst{%
    \ifnum \lst@lineno=\lst@firstline
        \expandafter\lst@BOLGobble
    \else
        \expandafter\lst@MSkipToFirst@
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstenv@JSkipToFirst@}
% Same as |\lst@MSkipToFirst@| but |^^M| is replaced by |^^J|.
%    \begin{macrocode}
\begingroup\lccode`\~=`\^^J
\lowercase{\gdef\lstenv@JSkipToFirst@#1~}{%
    \global\advance\lst@lineno\@ne
    \ifnum \lst@lineno=\lst@firstline
        \expandafter\lst@BOLGobble
    \else
        \expandafter\lstenv@JSkipToFirst@
    \fi}
\endgroup
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstenv@SkipToEnd}
% We use the temporary definition
% \begin{itemize}\item[]
%    |\long\def\lst@temp##1\|\meta{content of \textup{\cs{lstenv@endstring}}}|{\lstenv@End}|
% \end{itemize}
% which gobbles all characters up to the end of environment and finishes the environment.
%    \begin{macrocode}
\begingroup \lccode`\~=`\\\lowercase{%
\gdef\lstenv@SkipToEnd{%
    \long\expandafter\def\expandafter\lst@temp\expandafter##\expandafter
        1\expandafter~\lstenv@endstring{\lstenv@End}%
    \lst@temp}
}\endgroup
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Low level processing}
%
% \begin{macro}{\lstenv@DroppedWarning}
% gives a warning if characters have been dropped.
%    \begin{macrocode}
\def\lstenv@DroppedWarning{%
    \ifx\lst@dropped\@undefined\else
        \PackageWarning{Listings}{Text dropped after begin of listing}%
    \fi}
\let\lst@dropped\@undefined % init
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstenv@Process}
% We execute `|\lstenv@ProcessM|' or |\lstenv@ProcessJ| according to whether we find an active EOL or a nonactive |^^J|.
%    \begin{macrocode}
\begingroup \lccode`\~=`\^^M\lowercase{%
\gdef\lstenv@Process#1{%
    \ifx~#1%
%    \end{macrocode}
% We make no extra |\lstenv@ProcessM| definition since there is nothing to do at all if we've found an active EOL.
%    \begin{macrocode}
        \lstenv@DroppedWarning \let\lst@next\lstenv@SkipToFirst
    \else\ifx^^J#1%
        \lstenv@DroppedWarning \let\lst@next\lstenv@ProcessJ
    \else
        \let\lst@dropped#1\let\lst@next\lstenv@Process
    \fi \fi
    \lst@next}
}\endgroup
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstenv@ProcessJ}
% Now comes the horrible scenario: A listing inside an argument.
% We've already worked in section \ref{iApplicationsTo} for this.
% Here we must get all characters up to `end environment'.
% We distinguish the cases `command fashion' and `true environment'.
%    \begin{macrocode}
\def\lstenv@ProcessJ{%
    \let\lst@arg\@empty
    \ifx\@currenvir\lstenv@name
        \expandafter\lstenv@ProcessJEnv
    \else
%    \end{macrocode}
% The first case is pretty simple:
% The code is terminated by |\end|\meta{name of environment}.
% Thus we expand that control sequence before defining a temporary macro, which gets the listing and does all the rest.
% Back to the definition of |\lstenv@ProcessJ| we call the temporary macro after expanding |\fi|.
%    \begin{macrocode}
        \expandafter\def\expandafter\lst@temp\expandafter##1%
            \csname end\lstenv@name\endcsname
                {\lst@InsideConvert{##1}\lstenv@ProcessJ@}%
        \expandafter\lst@temp
    \fi}
%    \end{macrocode}
% We must append an active backslash and the `end string' to |\lst@arg|.
% So all (in fact most) other processing won't notice that the code has been inside an argument.
% But the EOL character is chr(10)=|^^J| now and not chr(13).
%    \begin{macrocode}
\begingroup \lccode`\~=`\\\lowercase{%
\gdef\lstenv@ProcessJ@{%
    \lst@lExtend\lst@arg
        {\expandafter\ \expandafter~\lstenv@endstring}%
    \catcode10=\active \lst@Let{10}\lst@MProcessListing
%    \end{macrocode}
% We execute |\lst@arg| to typeset the listing.
%    \begin{macrocode}
    \let\lst@MSkipToFirst\lstenv@JSkipToFirst
    \expandafter\lstenv@SkipToFirst\lst@arg}
}\endgroup
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstenv@ProcessJEnv}
% The `true environment' case is more complicated.
% We get all characters up to an |\end| and the following argument.
% If that equals |\lstenv@name|, we have found the end of environment and start typesetting.
%    \begin{macrocode}
\def\lstenv@ProcessJEnv#1\end#2{\def\lst@temp{#2}%
    \ifx\lstenv@name\lst@temp
        \lst@InsideConvert{#1}%
        \expandafter\lstenv@ProcessJ@
    \else
%    \end{macrocode}
% Otherwise we append the characters including the eaten |\end| and the eaten argument to current |\lst@arg|.
% And we look for the end of environment again.
%    \begin{macrocode}
        \lst@InsideConvert{#1\\end\{#2\}}%
        \expandafter\lstenv@ProcessJEnv
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstenv@backslash}
% Coming to a backslash we either end the listing or process a backslash and insert the eaten characters again.
%    \begin{macrocode}
\def\lstenv@backslash{%
    \lst@IfNextChars\lstenv@endstring
        {\lstenv@End}%
        {\expandafter\lsts@backslash \lst@eaten}}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstenv@End}
% This macro has just been used and terminates a listing environment:
% We call the `end environment' macro using |\end| or as a command.
%    \begin{macrocode}
\def\lstenv@End{%
    \ifx\@currenvir\lstenv@name
        \edef\lst@next{\noexpand\end{\lstenv@name}}%
    \else
        \def\lst@next{\csname end\lstenv@name\endcsname}%
    \fi
    \lst@next}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{\cs{lstnewenvironment}}
%
% \begin{macro}{\lstnewenvironment}
% Now comes the main command.
% We define undefined environments only.
% On the parameter text |#1#2#| (in particular the last sharp) see the paragraph following example 20.5 on page 204 of `The \TeX book'.
%    \begin{macrocode}
\lst@UserCommand\lstnewenvironment#1#2#{%
    \@ifundefined{#1}%
        {\lstnewenvironment@{#1}{#2}}%
        {\PackageError{Listings}{Environment `#1' already defined}\@eha
         \@gobbletwo}}
\def\lstnewenvironment@#1#2#3#4{%
%    \end{macrocode}
% A lonely `end environment' produces an error.
%    \begin{macrocode}
    \global\@namedef{end#1}{\lstenv@Error{#1}}%
%    \end{macrocode}
% The `main' environment macro defines the environment name for later use and calls a submacro getting all arguments.
% We open a group and make EOL active.
% This ensures |\@ifnextchar[| not to read characters of the listing --- it reads the active EOL instead.
%    \begin{macrocode}
    \global\@namedef{#1}{\def\lstenv@name{#1}%
        \begingroup \catcode\active=\active \csname#1@\endcsname}%
%    \end{macrocode}
% The submacro is defined via |\new@command|.
% We misuse |\l@ngrel@x| to make the definition |\global|.
% First we execute |#3|$=$\meta{begin code}.
%    \begin{macrocode}
    \let\l@ngrel@x\global %
    \expandafter\new@command\csname#1@\endcsname#2%
        {\lsthk@PreSet #3%
%    \end{macrocode}
% The definition of the terminating string (|end{lstlisting}| or |endlstlisting|, for example):
%    \begin{macrocode}
         \ifx\@currenvir\lstenv@name
             \edef\lstenv@endstring{%
                 end\noexpand\{\lstenv@name\noexpand\}}%
         \else
             \edef\lstenv@endstring{end\lstenv@name}%
         \fi
         \expandafter\lst@DefActive\expandafter\lstenv@endstring
             \expandafter{\lstenv@endstring}%
%    \end{macrocode}
% We redefine (locally) `end environment' since ending is legal now.
% Note that the redefinition also works inside a \TeX\ comment line.
%    \begin{macrocode}
         \@namedef{end#1}{\lst@DeInit #4\endgroup
                          \@doendpe \@ignoretrue}%
%    \end{macrocode}
% |\@doendpe| again removes the indention problem.
% Finally we start the processing.
%    \begin{macrocode}
         \lst@Init\lstenv@backslash
         \let\lst@EndProcessListing\lstenv@SkipToEnd
         \lst@ifprint
             \expandafter\lstenv@Process
         \else
             \expandafter\lstenv@SkipToEnd
         \fi}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstenv@Error}
% is called by a lonely `end environment'.
%    \begin{macrocode}
\def\lstenv@Error#1{\PackageError{Listings}{Extra \string\end#1}%
    {I'm ignoring this, since I wasn't doing a \csname#1\endcsname.}}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Two environments}
%
% \begin{environment}{lstlisting}
% The awkward work is done, the definition is quite easy now.
% We test whether the user has forgotten the name argument, set the keys, and deal with continued line numbering.
%    \begin{macrocode}
\lstnewenvironment{lstlisting}[2][]
    {\lst@TestEOLChar{#2}%
     \lstset{#1}%
     \csname lst@SetFirstLabel\endcsname}
    {\csname lst@SaveFirstLabel\endcsname}
%    \end{macrocode}
%    \begin{macrocode}
%</kernel>
%    \end{macrocode}
% \end{environment}
%
% \begin{aspect}{doc}
% Contains some private definitions used for documentation.
%    \begin{macrocode}
%<*doc>
\lst@BeginAspect[writefile]{doc}
%    \end{macrocode}
%
% \begin{environment}{lstsample}
% The documentation uses a special environment.
% Roughly speaking all material between |\begin{lstsample}| and |\end{lstsample}| is executed `on the left side' and typeset verbatim on the right.
% The one and only argument is executed before the code `on the left'.
%    \begin{macrocode}
\newbox\lst@samplebox
\lstnewenvironment{lstsample}[1]
    {\lst@TestEOLChar{#1}\global\let\lst@intname\@empty
     \gdef\lst@sample{#1}%
     \setbox\lst@samplebox=\hbox\bgroup
         \setkeys{lst}{language={},style={},tabsize=4,gobble=5,%
		     basicstyle=\small\ttfamily,basewidth=0.51em}
         \lstsampleverbcmd
         \lst@BeginAlsoWriteFile{\jobname.tmp}}
    {\lst@EndWriteFile\egroup
%    \end{macrocode}
% Now |\lst@samplebox| contains the verbatim part.
% If it's too wide, we use atop and below instead of left and right.
%    \begin{macrocode}
     \ifdim \wd\lst@samplebox>.5\linewidth
         \smallbreak
         \lst@sampleInput
         \begin{center}
         \begin{minipage}{0.9\linewidth}%
             \hbox to\linewidth{\box\lst@samplebox\hss}%
         \end{minipage}%
         \end{center}%
     \else
         \begin{center}%
         \begin{minipage}{0.45\linewidth}\lst@sampleInput\end{minipage}%
         \qquad
         \begin{minipage}{0.45\linewidth}%
             \hbox to\linewidth{\box\lst@samplebox\hss}%
         \end{minipage}%
         \end{center}%
     \fi}
%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\lstsampleverbcmd}
% can be used to adjust the appearance of the verbatim part.
%    \begin{macrocode}
\global\let\lstsampleverbcmd\@empty
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lst@sampleInput}
% inputs the `left-hand' side.
%    \begin{macrocode}
\gdef\lst@sampleInput{%
    \MakePercentComment\catcode`\^^M=9\relax
    \small\lst@sample
    \setkeys{lst}{SelectCharTable=\lst@ReplaceInput{\^\^I}%
                                  {\lst@ProcessTabulator}}%
    \input{\jobname.tmp}\MakePercentIgnore}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\lst@EndAspect
%</doc>
%    \end{macrocode}
% \end{aspect}
%
%
% \section{Interfaces to other packages}
%
%
% \subsection{0.17 compatibility}
%
% \begin{aspect}{0.17}
% We give a warning first.
%    \begin{macrocode}
%<*0.17>
\lst@BeginAspect{0.17}
%    \end{macrocode}
%    \begin{macrocode}
\message{^^J%
***^^J
*** You have requested compatibility mode `0.17'.^^J%
*** This mode is for documents created with version 0.17 only.^^J%
*** I T\@spaces I S\@spaces N O T\@spaces F U L L Y\@spaces
C O M P A T I B L E.^^J
***^^J^^J}
%    \end{macrocode}
%
%
% \paragraph{Language names.}
% Since some programming languages changed their names, we define aliases here.
%    \begin{macrocode}
\lstalias[]{blank}[]{}
\lstalias{cpp}{C++}
\lstalias[vc]{C++}[Visual]{C++}
\lstalias{comal}{Comal 80}
\lstalias{modula}{Modula-2}
\lstalias{oberon}{Oberon-2}
\lstalias[]{pxsc}[XSC]{Pascal}
\lstalias[]{tp}[Borland6]{Pascal}
\lstalias{pli}{PL/I}
%    \end{macrocode}
%
%
% \paragraph{User commands.}
% Old commands in terms of keys:
%    \begin{macrocode}
\gdef\inputlisting{%
    \@ifnextchar[\inputlisting@{\inputlisting@[1,999999]}}
\gdef\inputlisting@[#1,#2]{\lstinputlisting[first=#1,last=#2]}
%    \end{macrocode}
%    \begin{macrocode}
\gdef\selectlisting{\@ifnextchar[\selectlisting@{\selectlisting@[]}}
\gdef\selectlisting@[#1]#2{\lstset{language=[#1]#2}}
%    \end{macrocode}
%    \begin{macrocode}
\gdef\stringizer{\@ifnextchar[\stringizer@{\stringizer@[d]}}
\gdef\stringizer@[#1]#2{\lstset{stringizer=[#1]#2}}
%    \end{macrocode}
%    \begin{macrocode}
\gdef\listingtrue{\lstset{print=true}}
\gdef\listingfalse{\lstset{print=false}}
\gdef\tablength#1{\lstset{tabsize=#1}}\tablength{4}% init
\gdef\keywordstyle#1{\lstset{keywordstyle={#1}}}
\gdef\commentstyle#1{\lstset{commentstyle={#1}}}
\gdef\stringstyle#1{\lstset{stringstyle={#1}}}
\gdef\labelstyle#1{\lstset{labelstyle={#1}}}
\gdef\blankstringtrue{\lstset{stringspaces=false}}
\gdef\blankstringfalse{\lstset{stringspaces=true}}
\gdef\spreadlisting#1{\lstset{spread={#1}}}
\gdef\prelisting#1{\lstset{pre={#1}}}
\gdef\postlisting#1{\lstset{post={#1}}}
\gdef\normallisting{\lstset{style={},spread=\z@,pre={},post={}}}
\gdef\keywords#1{\lstset{keywords={#1}}}
\gdef\morekeywords#1{\lstset{morekeywords={#1}}}
\gdef\sensitivetrue{\lstset{sensitive=true}}
\gdef\sensitivefalse{\lstset{sensitive=false}}
\global\let\lst@stringblank\textvisiblespace
%    \end{macrocode}
% We define the (new) old environment.
%    \begin{macrocode}
\lstnewenvironment{listing}[1][]{\gdef\lst@intname{#1}}{}
%    \end{macrocode}
%
%
% \paragraph{Comments.}
% The implementation of old comment commands in terms of the new ones is all the same:
% If the last argument is empty, we remove the comment; otherwise we execute the new key with correct syntax.
%    \begin{macrocode}
\gdef\DeclareCommentLine#1\relax{%
    \ifx\@empty#1\@empty
        \let\lst@DefCL\relax
    \else
        \lstset{commentline=#1}%
    \fi}
%    \end{macrocode}
%    \begin{macrocode}
\gdef\DeclareSingleComment#1 #2\relax{%
    \ifx\@empty#2\@empty
        \let\lst@DefSC\relax \let\lst@DefDC\relax
    \else
        \lstset{singlecomment={#1}{#2}}%
    \fi}
%    \end{macrocode}
%    \begin{macrocode}
\gdef\DeclarePairedComment#1\relax{%
    \ifx\@empty#1\@empty
        \let\lst@DefSC\relax \let\lst@DefDC\relax
    \else
        \lstset{singlecomment={#1}{#1}}%
    \fi}
%    \end{macrocode}
%    \begin{macrocode}
\gdef\DeclareNestedComment#1 #2\relax{%
    \ifx\@empty#2\@empty
        \let\lst@DefSC\relax \let\lst@DefDC\relax
    \else
        \lstset{nestedcomment={#1}{#2}}%
    \fi}
%    \end{macrocode}
%    \begin{macrocode}
\gdef\DeclareDoubleComment#1 #2 #3 #4\relax{%
    \ifx\@empty#4\@empty
        \let\lst@DefSC\relax \let\lst@DefDC\relax
    \else
        \lstset{doublecomment={#1}{#2}{#3}{#4}}%
    \fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\lst@EndAspect
%</0.17>
%    \end{macrocode}
% \end{aspect}
%
%
% \subsection{0.19 compatibility}
%
% \begin{aspect}{0.19}
% Some keys have just been renamed.
%    \begin{macrocode}
%<*0.19>
\lst@BeginAspect{0.19}
%    \end{macrocode}
%    \begin{macrocode}
\lst@Key{nonkeywordstyle}\relax{\setkeys{lst}{identifierstyle={#1}}}
\lst@Key{cdirectives}\relax{\setkeys{lst}{directives={#1}}}
\lst@Key{doublekeywordcommentsemicolon}\relax
    {\setkeys{lst}{keywordcommentsemicolon={#1}}}
%    \end{macrocode}
% Ditto two commands.
%    \begin{macrocode}
\lst@UserCommand\listoflistings{%
    \bgroup
    \let\lstlistlistingname\listlistingsname
    \lstlistoflistings
    \egroup}
\lst@UserCommand\listlistingsname{Listings}
%    \end{macrocode}
% \keyname{baseem} appends one or two |em| and uses \keyname{basewidth}.
%    \begin{macrocode}
\lst@Key{baseem}\relax{\lstKV@CSTwoArg{#1}%
    {\ifx\@empty##2\@empty
         \setkeys{lst}{basewidth=##1em}%
     \else
         \setkeys{lst}{basewidth={##1em,##2em}}%
     \fi}}
%    \end{macrocode}
% \keyname{blankstring} is the opposite of \keyname{stringspaces}.
% We simply expand |\iffalse| or |\iftrue| and assign it.
%    \begin{macrocode}
\lst@Key{blankstring}\relax
    {\lstKV@SetIf\lst@ifblankstring
     \expandafter\let\expandafter\lst@ifstringspaces\csname
         if\lst@ifblankstring false\else true\fi \endcsname}
%    \end{macrocode}
% For |\lstbox| we use the internal |\lst@boxpos| and hope that |\lst@boxtrue| is not necessary.
% If this is wrong, the kernel needs to be changed.
%    \begin{macrocode}
\lst@UserCommand\lstbox{\@ifnextchar[{\lstbox@}{\lstbox@[c]}}
\gdef\lstbox@[#1]#2{\def\lst@boxpos{#1}}
%    \end{macrocode}
%
%    \begin{macrocode}
\lst@EndAspect
%</0.19>
%    \end{macrocode}
% \end{aspect}
%
% \subsection{\packagename{fancyvrb}}
%
% \lsthelper{Denis~Girou}{1998/07/26}{fancyvrb} asked whether \packagename{fancyvrb} and \packagename{listings} could work together.
% This is the second attempt.
%
% \begin{lstkey}{fancyvrb}
% We set the boolean and call a submacro.
%    \begin{macrocode}
%<*kernel>
\lst@Key{fancyvrb}\relax[t]{%
    \lstKV@SetIf{#1}\lst@iffancyvrb
    \lstFV@fancyvrb}
\ifx\lstFV@fancyvrb\@undefined
    \gdef\lstFV@fancyvrb{\lst@RequireAspects{fancyvrb}\lstFV@fancyvrb}
\fi
%</kernel>
%    \end{macrocode}
% \end{lstkey}
%
% \begin{aspect}{fancyvrb}
% We end the job if \packagename{fancyvrb} is not present.
%    \begin{macrocode}
%<*fancyvrb>
\lst@BeginAspect{fancyvrb}
%    \end{macrocode}
%    \begin{macrocode}
\@ifundefined{FancyVerbFormatLine}
    {\typeout{^^J%
     ***^^J%
     *** `listings.sty' needs `fancyvrb.sty' right now.^^J%
     *** Please ensure its availability and try again.^^J%
     ***^^J}%
     \batchmode \@@end}{}
%    \end{macrocode}
%
% \begin{macro}{\lstFV@fancyvrb}
% We assign the correct |\FancyVerbFormatLine| macro.
%    \begin{macrocode}
\gdef\lstFV@fancyvrb{%
    \lst@iffancyvrb
        \ifx\FancyVerbFormatLine\lstFV@FancyVerbFormatLine\else
            \let\lstFV@FVFL\FancyVerbFormatLine
            \let\FancyVerbFormatLine\lstFV@FancyVerbFormatLine
        \fi
    \else
        \ifx\lstFV@FVFL\@undefined\else
            \let\FancyVerbFormatLine\lstFV@FVFL
            \let\lstFV@FVFL\@undefined
        \fi
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstFV@VerbatimBegin}
% We initialize things if necessary.
%    \begin{macrocode}
\gdef\lstFV@VerbatimBegin{%
    \ifx\FancyVerbFormatLine\lstFV@FancyVerbFormatLine
        \lsthk@InlineUnsave \lsthk@BoxUnsave
        \lsthk@PreSet
        \lst@activecharsfalse
        \let\smallbreak\relax \let\normalbaselines\relax
%    \end{macrocode}
% \begin{TODO}
% These two |\let|s are possibly bad.
% \end{TODO}
%    \begin{macrocode}
        \lst@Init\relax
        \everypar{}\global\let\lst@NewLine\relax
        \lst@mode\lst@nomode \let\lst@entermodes\@empty
        \lst@InterruptModes
%    \end{macrocode}
% \lsthelper{Rolf~Niepraschk}{1998/11/25}{problem with ligatures} reported a bug concerning ligatures to \lsthelper{Denis~Girou}{1998/11/27}{use \@noligs}.
%    \begin{macrocode}
% D.G. modification begin - Nov. 25, 1998
        \let\@noligs\relax
% D.G. modification end
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lstFV@VerbatimEnd}
% A box and macro must exist after |\lst@DeInit|.
% We store them globally.
%    \begin{macrocode}
\gdef\lstFV@VerbatimEnd{%
    \ifx\FancyVerbFormatLine\lstFV@FancyVerbFormatLine
        \global\setbox\lstFV@gtempboxa\box\@tempboxa
        \global\let\@gtempa\FV@ProcessLine
        \lst@mode\lst@Pmode
        \lst@DeInit
        \let\FV@ProcessLine\@gtempa
        \setbox\@tempboxa\box\lstFV@gtempboxa
    \fi}
%    \end{macrocode}
%    \begin{macrocode}
\newbox\lstFV@gtempboxa
%    \end{macrocode}
% \end{macro}
%
% \noindent
% We insert |\lstFV@VerbatimBegin| and |\lstFV@VerbatimEnd| where necessary.
%    \begin{macrocode}
\lst@AddTo\FV@VerbatimBegin\lstFV@VerbatimBegin
\lst@AddToAtTop\FV@VerbatimEnd\lstFV@VerbatimEnd
\lst@AddTo\FV@LVerbatimBegin\lstFV@VerbatimBegin
\lst@AddToAtTop\FV@LVerbatimEnd\lstFV@VerbatimEnd
\lst@AddTo\FV@BVerbatimBegin\lstFV@VerbatimBegin
\lst@AddToAtTop\FV@BVerbatimEnd\lstFV@VerbatimEnd
%    \end{macrocode}
%
% \begin{macro}{\lstFV@FancyVerbFormatLine}
% `@' terminates the argument of |\lst@FVConvert|.
% Moreover |\lst@ReenterModes| and |\lst@InterruptModes| encloses some code.
% This ensures that we have same group level at the beginning and at the end of the macro --- even if the user begins but doesn't end a comment, which means one open group.
% Furthermore we use |\vtop| and reset |\lst@NewLine| to allow line breaking.
%    \begin{macrocode}
\gdef\lstFV@FancyVerbFormatLine#1{%
    \let\lst@arg\@empty\lst@FVConvert#1@%
    \let\lst@NewLine\lst@NewLineMacro
    \vtop{\lst@ReenterModes
          \lst@arg \lst@PrintToken\lst@EOLUpdate
          \lst@InterruptModes}}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\lst@EndAspect
%</fancyvrb>
%    \end{macrocode}
% \end{aspect}
%
%
% \section{Epilogue}
%
% \begingroup
%    \begin{macrocode}
%<*kernel>
%    \end{macrocode}
% Each option adds the aspect name to |\lst@loadaspects| or removes it from that data macro.
%    \begin{macrocode}
\DeclareOption*{\expandafter\lst@ProcessOption\CurrentOption\relax}
\def\lst@ProcessOption#1#2\relax{%
    \ifx #1!%
        \lst@DeleteKeysIn\lst@loadaspects{#2}%
    \else
        \lst@lAddTo\lst@loadaspects{,#1#2}%
    \fi}
%    \end{macrocode}
% The following aspects are loaded by default.
%    \begin{macrocode}
\ifx\lst@loadaspects\@undefined
    \def\lst@loadaspects{strings,comments,escape,style,language,%
        keywords,labels,lineshape,frames}%
\fi
%    \end{macrocode}
% We end the job if the patch file has wrong version.
%    \begin{macrocode}
\IfFileExists{lstpatch.sty}
    {\def\lst@topatch{0.19}\input{lstpatch.sty}%
     \let\lst@next\relax
     \ifx\lstlanguage@\@undefined\else \let\lst@next\@empty \fi
     \ifx\lst@version\lst@topatch\else \let\lst@next\@empty \fi
     \ifx\lst@next\relax\else
        \typeout{^^J%
        ***^^J%
        *** Patch file `lstpatch.sty' for version \lst@topatch^^J%
        *** is not suitable for `listings.sty' version \lst@version.^^J%
        *** Please delete old patch files and try again.^^J%
        ***^^J}%
        \batchmode \@@end
     \fi}{}
%    \end{macrocode}
% Process the options and load the aspects.
%    \begin{macrocode}
\ProcessOptions
\lst@RequireAspects\lst@loadaspects
\let\lst@loadaspects\@empty
%    \end{macrocode}
% Now selecting empty style and language (if present).
%    \begin{macrocode}
\lst@UseHook{SetStyle}\lst@UseHook{EmptyStyle}
\lst@UseHook{SetLanguage}\lst@UseHook{EmptyLanguage}
%    \end{macrocode}
% Finally we load the configuration file.
%    \begin{macrocode}
\InputIfFileExists{listings.cfg}{}{}
\lst@RestoreCatcodes
%<info>\lst@ReportAllocs
%    \end{macrocode}
%    \begin{macrocode}
%</kernel>
%    \end{macrocode}
% \endgroup
%
%
% \begingroup\small
% \section{History}
% Only major changes after version 0.15 are listed here.
% Previous changes are still present in the \texttt{.dtx}-file.
% Introductory version numbers of commands and keys are listed in the user's guide, which makes this history fairly short.
% \renewcommand\labelitemi{--}
% \begin{itemize}
% \iffalse
% \item[0.1] from 1996/03/09
%   \item test version to look whether package is possible or not
% \item[0.11] from 1996/08/19
%   \item additional blank option (= language)
%   \item alignment improved by rewriting some macros
% \item[0.12] from 1997/01/16
%   \item nearly `perfect' alignment
% \item[0.13] from 1997/02/11
%   \item additional languages: Eiffel, Fortran 90, Modula-2, Pascal XSC
%   \item load on demand: language specific macros moved to driver files
%   \item comments are declared now and not implemented for each language again (this makes the \TeX\ sources easier to read)
% \item[0.14] from 1997/02/18
%   \item user's guide rewritten
%   \item implementation guide uses macro environment from the doc package
%   \item (non) case sensitivity implemented, e.g.\ Pascal is not
%   \item multiple stringizer implemented, i.e.\ Modula-2 handles both string types: quotes and double quotes
%   \item comment declaration is user-accessible
%   \item package compatible to \verb!german.sty!
% \item[0.15] from 1997/04/18
%   \item additional languages: Java, Turbo Pascal
%   \item package renamed from listing.dtx to listings.dtx since there is already a package named listing
% \fi
% \item[0.16] from 1997/06/01
% \iffalse
%   \item changed `$<$' to `$>$' in \verb!\lst@SkipToFirst!
%   \item bug removed: \verb!\lst@Init! must be placed before \verb!\lst@SkipToFirst!
% \fi
%   \item listing environment rewritten
% \item[0.17] from 1997/09/29
%   \item |\spreadlisting| works correct now (e.g.\ page numbers don't move right any more)
%   \item speed up things (quick `if parameter empty', all |\long| except one removed, faster \verb!\lst@GotoNextTabStop!, etc.)
%   \item alignment of wide other characters improved (e.g.\ $==$)
% \iffalse
%   \item many new languages: Ada, Algol, Cobol, Comal 80, Elan, Fortran 77, Lisp, Logo, Matlab, Oberon, Perl, PL/I, Simula, SQL, \TeX
% \fi
% \item[pre-0.18] from 1998/03/24 (unpublished)
%   \item bug concerning |\labelstyle| removed (now oldstylenum example works)
%   \item experimental implementation of character classes
% \item[0.19] from 1998/11/09
%   \item character classes and new \lst-aspects seem to be the ultimate
%   \item user interface uses \packagename{keyval} package
%   \item \packagename{fancyvrb} support
% \item[0.20] from 1999/07/12
%   \item new keyword detection mechanism
%   \item new aspects: \aspectname{writefile}, \aspectname{breaklines}, captions, \aspectname{html}
%   \item improved \packagename{fancyvrb} support
%   \item all aspects reside in a single file and the language drivers in currently two files
% \end{itemize}
% \endgroup
%
% \setcounter{IndexColumns}{2}
% \PrintIndex
%
%
% \Finale
%
\endinput


