breaklines
}
+\newcommand{\SPLC}{\texttt{SPLC}}
+\newcommand{\SPL}{\texttt{SPLC}}
+\newcommand{\SSM}{\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}
+
\input{pars.tex}
\input{sem.tex}
}
}
+plus(x, y){
+ return x + y;
+}
+
main(){
var x = 5;
- print("faculty of 5 is: ", foldr(\x y->x*y, 1, intList(5)));
- print("sum of 1..5 is: ", foldr(\x y->x+y, 0, intList(5)));
- print("sum of 0..12 but only the evens: ",
- foldr(\x y->x+y, 0, filter(\x->x%2 == 0, intList(12))));
+
+ var a = plus(3);
+ print("3+5=", a(5));
+
+// print("faculty of 5 is: ", foldr(\x y->x*y, 1, intList(5)));
+// print("sum of 1..5 is: ", foldr(\x y->x+y, 0, intList(5)));
+// print("sum of 0..12 but only the evens: ",
+// foldr(\x y->x+y, 0, filter(\x->x%2 == 0, intList(12))));
}
+ackerman(m, n){
+ if(m ==0){
+ return n+1;
+ } else {
+ if(m>0 && n == 0){
+ return ackerman(m-1, 1);
+ } else {
+ return ackerman(m-1, ackerman(m, n-1));
+ }
+ }
+}
+
hyper(n, a, b){
if(n == 0){ return b + 1;
} else { if(b == 0 && n == 1){ return a;
print("3*3=", hyper(2, 3, 3));
print("3^4=", hyper(3, 3, 4));
print("2|3=", hyper(4, 2, 3));
+
+ print("a(0, 0)=", ackerman(0, 0));
+ print("a(0, 1)=", ackerman(0, 1));
+ print("a(0, 2)=", ackerman(0, 2));
+ print("a(0, 3)=", ackerman(0, 3));
+
+ print("a(1, 0)=", ackerman(1, 0));
+ print("a(1, 1)=", ackerman(1, 1));
+ print("a(1, 2)=", ackerman(1, 2));
+ print("a(1, 3)=", ackerman(1, 3));
+
+ print("a(2, 0)=", ackerman(2, 0));
+ print("a(2, 1)=", ackerman(2, 1));
+ print("a(2, 2)=", ackerman(2, 2));
+ print("a(2, 3)=", ackerman(2, 3));
+
+ print("a(3, 0)=", ackerman(3, 0));
+ print("a(3, 1)=", ackerman(3, 1));
+ print("a(3, 2)=", ackerman(3, 2));
+ print("a(3, 3)=", ackerman(3, 3));
+
+ print("a(4, 0)=", ackerman(4, 0));
+/* print("a(4, 1)=", ackerman(4, 1));
+ print("a(4, 2)=", ackerman(4, 2));
+ print("a(4, 3)=", ackerman(4, 3));*/
}