--- /dev/null
+\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}
-\documentclass[titlepage]{article}
+\documentclass{article}
\usepackage{listings}
\usepackage{clean}
\usepackage{spl}
+\usepackage{hyperref}
\usepackage[a4paper]{geometry}
-\title{SPLC}
+\title{Compiler Construction: SPL Compiler}
\author{Pim Jager\and Mart Lubbers}
\date{\today}
\lstset{%
basicstyle=\ttfamily\footnotesize,
- breaklines
+ breaklines,
+ captionpos=b
}
\newcommand{\SPLC}{\texttt{SPLC}}
\begin{document}
\maketitle
-\section{Introduction}
-\SPLC{} is a program that, in several phases, generates \SSM{}
-assembly for a given \SPL{} program. \SPLC{} is a program that acts as a
-filter. The tool reads the standard input and the output is printed on standard
-output. By default only the generated assembly code is outputted. But if the
-user wants to inspect outputs of intermediate phases it can be done so by
-setting command line flags. Listing~\ref{lst:splchelp} shows the output for
-\texttt{spl -h}. There is also a \emph{manpage} that shows the same info.
-
-\begin{lstlisting}[label={lst:splchelp},caption={\texttt{./spl -h}}]
-Usage: spl [OPTION] [FILE]
-<splc> ::= <spl> <compiler>
-Compile spl code from FILE or stdin
-
-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}
+\tableofcontents
+\newpage
+
+\input{intro.tex}
\input{pars.tex}