\section{Introduction}
\subsection{\SPLC}
\SPLC{} is a program written in the purely functional lazy programming language
Clean\footnote{\url{http://clean.cs.ru.nl/Clean}}. \SPLC{} has a standardized
UNIX like command line interface and functions as a filter in a way that it
processes standard input in standard output. Default command line argument such
as \texttt{--version} and \texttt{--help} provide the expected output. To
illustrate all the command line interface options the output of \texttt{spl
--help} is given in Listing~\ref{lst:splchelp}.

\begin{lstlisting}[
	label={lst:splchelp},
	caption={\texttt{./spl -h}}]
Usage: spl [OPTION] [FILE]

Options:
  --help             Show this help
  --version          Show the version
  --[no-]lex         Lexer output(default: disabled)
  --[no-]parse       Parser output(default: disabled)
  --[no-]sem         Semantic analysis output(default: disabled)
  --[no-]code        Code generation output(default: enabled)
\end{lstlisting}

\subsection{Outline}
\SPLC{} has several phases that each can produce their own output. Via command
line flags the user can enable or disable the printing of the output of
specific phases. The output for the code generation is enabled by default and
the output for the other phases are disabled by default.

The first and second step are lexing and parsing, which are both explained in
Section~\ref{sec:pars}. When one enables only the parsing the program will show
the pretty printed parsed source which is valid \SPL{} code. A simple selftest
can thus be done by feeding the pretty printed output back into \SPLC{}. This
is show in Listing~\ref{lst:splcex}.

The third phase is the semantic analysis phase. In this phase the types are
inferred where necessary and they are checked. There are also some trivial
sanity checks executed to make sure the program is a valid one. When one
enables the printing of the third phase you are shown the pretty printed source
code with all types inferred and the internal dictionary used for typechecking.
This phase is elaborated upon in Section~\ref{sec:sem}.

The last and fourth phase is the code generation phase. \SPLC{} generates 
\SSM\footnote{\url{http://www.staff.science.uu.nl/~dijks106/SSM/}}
assembly. \SSM{} assembly is a educational assembly language designed for
compiler construction courses and provides the programmer with handy tools such
as an emulator, breakpoints and a couple of higher level assembly instructions.
Details on code generation is explained in Section~\ref{sec:gen}. Since \SPLC{}
acts as a filter and the \SSM{} emulator does too one can chain the commands
together with standard pipes as shown in Listing~\ref{lst:splcex}.

In the Section~\ref{sec:ext} it is explained what extra features \SPLC{}
contains. Some syntactic sugars have been added in combination with support for
higher order functions.

\begin{lstlisting}[
	label={lst:splcex},
	caption={Example \SPLC{} run},
	language=sh]
# Run a program
spl input.spl | java -jar ssm.jar --stdin --cli
# Selftest parser
diff -q \
	<(spl --parse --no-code input.spl) \
	<(spl --parse --no-code input.spl | spl --parse --no-code)
\end{lstlisting}
