From c9b5b9b607eef63e166e49af365c626c6c7869da Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Thu, 9 Jun 2016 10:55:45 +0200 Subject: [PATCH] update' git pus --- .gitignore | 1 + deliverables/report/pars.tex | 5 +++++ deliverables/report/report.tex | 27 +++++++++++++++++++++++++ examples/higher.spl | 16 +++++++++++---- examples/peano.spl | 37 ++++++++++++++++++++++++++++++++++ spl.icl | 2 +- 6 files changed, 83 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 42f32dd..ec728ed 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ spl.1 *.prj a.out rwst +*.jar diff --git a/deliverables/report/pars.tex b/deliverables/report/pars.tex index cef446b..8a2029c 100644 --- a/deliverables/report/pars.tex +++ b/deliverables/report/pars.tex @@ -1,4 +1,9 @@ \section{Lexing \& parsing} +\subsection{Yard} + +\subsection{Lexing} + +\subsection{Parsing} %On March 10 you have to give a very brief presentation. In this presentation you tell the other %students and us how your parser is constructed and demonstrate your parser and pretty printer. %You should mention things like implementation language used, changes to the grammar, and other diff --git a/deliverables/report/report.tex b/deliverables/report/report.tex index d3f4349..42e494f 100644 --- a/deliverables/report/report.tex +++ b/deliverables/report/report.tex @@ -14,8 +14,35 @@ 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] + ::= +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} diff --git a/examples/higher.spl b/examples/higher.spl index 3e923d7..c5bac9e 100644 --- a/examples/higher.spl +++ b/examples/higher.spl @@ -34,10 +34,18 @@ intList(x){ } } +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)))); } diff --git a/examples/peano.spl b/examples/peano.spl index 1c2cb78..f8e8c70 100644 --- a/examples/peano.spl +++ b/examples/peano.spl @@ -1,3 +1,15 @@ +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; @@ -13,4 +25,29 @@ main(){ 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));*/ } diff --git a/spl.icl b/spl.icl index 4305f8d..6c75e68 100644 --- a/spl.icl +++ b/spl.icl @@ -56,7 +56,7 @@ Start w # (stdin, w) = stdio w | args.version # stdin = stdin - <<< "spl 0.1 (17 march 2016)\n" + <<< "spl 1.0 (9 June 2016)\n" <<< "Copyright Pim Jager and Mart Lubbers\n" = snd $ fclose stdin w | args.help -- 2.20.1