% LAST EDIT: Tue Sep  3 13:04:44 1996 by Peter Pepper (basti!pepper) 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Scanner
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\section{How the Scanner Recognizes Symbols}
\label{sec:Scanner}

The style \texttt{scanner.sty} essentially implements a \emph{scanner} for
analyzing (program) texts. It thus is a prerequisite for providing
\begin{itemize}
  \item readable notations for graphemes (such as "\verb+<==>+" for
    obtaining $\Longleftrightarrow$),
  \item nice appearance for identifiers in math mode (such as
    $\mathit{buffer}$ instead of $buffer$),
  \item more flexible notations for keywords (such as \verb=FUN= instead of
    \verb=\FUN=).
\end{itemize}


The style provides commands that can be used by other styles to scan certain
text areas. These text areas are usually programs, but one can also scan
math formulas (see below).
The commands scan the designated text area and assemble essentially three
classes of tokens:
\begin{itemize}
  \item \emph{Identifiers}, that is, sequences of letters (e.g.~\verb=foo=).
  \item \emph{Digits}.
  \item \emph{Graphemes}, that is, sequences of ``other'' characters
    (e.g.~\verb=[+]=).

    \emph{Note}: The characters `\verb+(+', `\verb+)+', and `\verb+,+' are
    \emph{not} considered as ``other'' characters and therefore cannot be
    used as parts of fancy symbols.
\end{itemize}

For identifiers and graphemes the principle of \emph{longest match}
applies. This is no problem, since spaces can be used as separators without
problems.


In addition, the scanner recognizes:
\begin{itemize}
  \item End of line.
  \item \TeX~comments (i.e. \verb+\%+).
  \item Program comments i.e. \verb+\-+).
\end{itemize}







\subsection{Using the scanner in math mode}

The scanner is usually used by other styles such as \verb=opal2x.sty= to
analyze program texts. However, it is also possible to use it in math
mode, that is, within \verb=$...$=. In order to activate the scanner in
math mode, the command

\quad\verb=\ActivateMathScan=

has to be issued. (It is equivalent to
\verb=\everymath{\ScanMath}\EnableMathScan=.)

Afterwards, the two commands

\quad\verb=\DisableMathScan=

\quad\verb=\EnableMathScan=

can be used arbitrarily often to disable and reenable the scanner for math
mode. 




