% run this through LaTeX with the appropriate wrapper

\chapter	{Pepsy}\label{pepsy}
The \man pepsy(1) program is a table-driven replacement for \pgm{pepy} and
\pgm{posy}.
At present,
all three compilers are available as a part of the standard distribution.
In the next major release,
\pgm{pepy} and \pgm{posy} will remain,
but most likely will not be installed by default.

The remainder of this chapter describes how to use \pgm{pepsy}.
By virtue of having presented the preceeding two chapters,
only a terse discussion is needed!

\section	{Abstract Syntax Module}
As with \pgm{posy},
the \pgm{pepsy} program reads a description of an {\em abstract syntax
module\/}
and produces the corresponding {\em C\/} structures along with several tables
that define the mapping between the ASN.1 objects in the module and the
{\em C\/} structures.
This tables replaces the work done by the \pgm{pepy} program.

Note that unlike \pgm{posy},
\pgm{pepsy} does not accept annotations in the abstract syntax module.
It should be raw ASN.1,
either entered by hand,
or produced by the \pgm{rosy} program.
Note that you must tell \pgm{rosy} when \pgm{pepsy} will be used.
This is accomplished with the \switch"pepsy" option,
e.g.,
\begin{quote}\small\begin{verbatim}
.ry.py:;          rosy -pepsy $(RYFLAGS) $<
\end{verbatim}\end{quote}

\section	{PEPSY Environment}
The \pgm{pepsy} program will produce two files after reading its abstract
syntax module.

\subsection	{C Language Structures}
For each type in the abstract syntax module,
\pgm{pepy} will define a corresponding {\em C\/} language structure
(\verb"struct"),
using the same rules as \pgm{posy}
(see Section~\ref{posy:c-struct} on page~\pageref{posy:c-struct}).

\subsection	{Mapping tables}
In addition to the definition of {\em C\/} language structures,
\pgm{pepsy} will generate a {\em C\/} file containing several tables that
define the mapping between the structures and the corresponding ASN.1 objects.
As this is entirely an automatic process,
the contents of the tables are relatively unimportant.

\section	{Known Deficiences}
\pgm{pepsy} uses essentially the same front-end as the \man posy(1) program,
so it has some limitations in the ASN.1 syntax it can accept.
Consult Section~\ref{posy:deficiencies} on page~\pageref{posy:deficiencies}
for the details.

\section	{Running PEPSY}
Here are a few things to know when running \pgm{pepsy}.

\subsection	{Options}
The \pgm{pepsy} program has a few options to modify its behavior.

The \switch"A" switch directs \pgm{pepsy} to produce mapping tables for
encoding, decoding, and printing.

The \switch"a" switch directs \pgm{pepy} to augment the \verb"#include" file
it generates with commentary text.

The \switch"d" switch is a no-op with \pgm{pepsy},
as it always ignores all \pgm{pepy}-style augmentations,
including the 
``verbatim'' actions occuring at the very beginning and end of the module.

The \switch"f" switch directs \pgm{posy} to generate {\em C\/} macros to
deallocate the structures it defines
(e.g., for type \verb"type_MODULE_type",
a macro called \verb"free_MODULE_type" is defined).

As with \pgm{posy},
the \switch"h" switch enables additional heuristics when \pgm{pepsy} generates
a {\em C\/} language structure definition.
See Section~\ref{posy:options} on page~\pageref{posy:options}.

Normally, \pgm{posy} prints the name of each type as it works.
The \switch"s" switch disables this behavior.

\subsection	{Makefiles}
By convention,
input files to \pgm{pepsy} have the extension \verb".py".
In order to remain consistent with the naming scheme used by \pgm{posy},
rather than starting with file \verb"module.py",
we assume we are starting with file \verb"MODULE-asn.py".
Let us arbitrarily select the file named \verb"MODULE-types.py" for the
augmented abstract syntax module produced by \pgm{posy}.
Hence
\begin{quote}\begin{verbatim}
pepsy MODULE-asn.py
\end{verbatim}\end{quote}
will produce:
\begin{describe}
\item[\verb"MODULE-types.h":]	the {\em C\/} language structures;
				and,

\item[\verb"MODULE_tables.c":]	the mapping tables.
\end{describe}

Our \man make(1) rules are:
\begin{quote}\small\begin{verbatim}
MODULE_tables.o:  MODULE_tables.c MODULE-types.h

MODULE_tables.c MODULE_tables.h: MODULE-asn.py
		pepsy -A -f -h MODULE-asn.py
\end{verbatim}\end{quote}
