From e998428ee62ec119c9e46c688f2949346990af60 Mon Sep 17 00:00:00 2001
From: jwansek <eddie.atten.ea29@gmail.com>
Date: Mon, 15 Nov 2021 15:33:39 +0000
Subject: added testing of previous sprints to repository

---
 report/esoteric_project_report.tex | 198 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 197 insertions(+), 1 deletion(-)

(limited to 'report/esoteric_project_report.tex')

diff --git a/report/esoteric_project_report.tex b/report/esoteric_project_report.tex
index a347d87..b8c4f93 100644
--- a/report/esoteric_project_report.tex
+++ b/report/esoteric_project_report.tex
@@ -322,11 +322,207 @@ blablabla
 
 In this chapter you cover the actual implementation of your project. Implementation will be done in sprints so you may wish to use different sub-sections for each sprint and then dedicate a section to your final deliverable. Section \ref{Figures} with figures  should not remain in the final report.
 
+The long string following the sprint number is the git commit at the point in the git repository at which the tests were conducted.
+
 \section{Early sprints}
-\subsection{Sprint 1}
+\subsection{Sprint 1 - \texttt{cb29252f1e0d29d555fb232f39d343930fc76105}}
+The first functional program version was a simple lexical analyser. At this stage no calculations were done. For example:
+
+\begin{verbatim}
+Code: 3-1+2
+\end{verbatim}
+Produces the output:
+\begin{verbatim}
+NUMBER 3 3.0
+MINUS - null
+NUMBER 1 1.0
+PLUS + null
+NUMBER 2 2.0
+\end{verbatim}
+A more complex example:
+\begin{verbatim}
+Code: (36/2 + 45.2) * 3
+\end{verbatim}
+Produces the result:
+\begin{verbatim}
+LEFT_PAREN ( null
+NUMBER 36 36.0
+SLASH / null
+NUMBER 2 2.0
+PLUS + null
+NUMBER 45.2 45.2
+RIGHT_PAREN ) null
+STAR * null
+NUMBER 3 3.0
+\end{verbatim}
+
+\subsection{Sprint 2 - \texttt{69b0ad07bac30beca1397ff187468e7597203c44}}
+This version added simple variable declaration and assignment, as well as a simple calculator. It also added reading from files. For example, running \texttt{java Interpreter.Language example2.txt} where \texttt{example2.txt} is the following:
+
+\begin{verbatim}
+var :: a
+a=5
+a=a+1
+print a
+\end{verbatim}
+Produces the result:
+\begin{verbatim}
+6.0
+\end{verbatim}
+Testing involved making sure the program worked with the rules of left-associativity; for example, the program:
+\begin{verbatim}
+var :: a
+a=3-1+2
+print a
+\end{verbatim}
+Produces the result \texttt{4.0}.
+We also tested BIDMAS rules by using complex expressions:
+\begin{verbatim}
+var :: a
+a=(36/2 + 45.2) * 3
+print a
+\end{verbatim}
+Returns \texttt{189.60000000000002}, which is correct considering the inaccuracy of floating points in computers. Finally, a test of a more complex program:
+\begin{verbatim}
+var :: a
+a=5
+a=a+1
+print a
+
+a=7
+a=a*2
+print a
+
+var :: b
+b = 10
+print a+b
+\end{verbatim}
+Produces the result:
+\begin{verbatim}
+6.0
+14.0
+24.0
+\end{verbatim}
+You can test the error handling in several ways. For example the program
+\begin{verbatim}
+a=3
+print a
+\end{verbatim}
+Uses an undefined variable \texttt{a}. The output of running this is:
+\begin{verbatim}
+An error was encountered
+Variable undefined
+\end{verbatim}
+You can also try and run a program with a syntax error, for example:
+\begin{verbatim}
+var :: a
+a=3+
+print a
+\end{verbatim}
+Produces:
+\begin{verbatim}
+An error was encountered
+Expected Expression
+\end{verbatim}
+This is how it reacts to using an undefined token:
+\begin{verbatim}
+var :: a
+a=3
+pprint a
+\end{verbatim}
+Produces:
+\begin{verbatim}
+An error was encountered
+Undefined Variable
+\end{verbatim}
+
+\subsection{Sprint 3 - \texttt{a12094123dcacee41a7472031db6fe6027b083a7}}
+This version added full compilation to a binary by translating to a C program and using gcc to compile it straight away. It also added strings as lists of characters, and simple if statements. For example running \texttt{java Compiler.Language example.txt} where \texttt{example.txt} is the program:
+\begin{verbatim}
+character (len=10)::hello
+hello="hello"
+if 5==5 then
+hello="goodbye "
+endif
+print *,hello,6," test" endprint
+\end{verbatim}
+Produces, in the \texttt{build/} folder, \texttt{example.c}:
+\begin{verbatim}
+#include <stdio.h>
+#include <string.h>
+int main(){
+char hello[11];
+strcpy(hello,"hello");
+if(5==5){
+strcpy(hello,"goodbye ");
+}
+printf("%s%d%s",hello,6," test");
+}
+\end{verbatim} 
+It also compiles this file automatically, checking for errors during the process, and produces the executable binary \texttt{example.exe} in windows, or \texttt{./example} if run in a distribution of GNU+Linux. It then runs the binary straight away, checking for runtime errors. The output of running this binary is:
+\begin{verbatim}
+goodbye 6 test
+\end{verbatim}
+Here's an example of a program which produces a runtime error:
+\begin{verbatim}
+character (len=3)::hello
+hello="hello"
+if 5==5 then
+hello="goodbye "
+endif
+print *,hello,6," test" endprint
+\end{verbatim}
+It produces a runtime error since the character string is too short. When it's run, it says:
+\begin{verbatim}
+An error was encountered
+Runtime Error
+\end{verbatim}
+This version also added better error messages. For example \texttt{hello="hello} produces:
+\begin{verbatim}
+An error was encountered
+Strings must end with "
+\end{verbatim}
+Moreover, the program
+\begin{verbatim}
+character (len=10)::hello
+hello="hello"
+if 5==5 then
+hello="goodbye "
+print *,hello,6," test" endprint
+\end{verbatim}
+Produces the error message:
+\begin{verbatim}
+An error was encountered
+endif missing
+\end{verbatim}
+Finally, lets test if statements with another program:
+\begin{verbatim}
+character (len=10)::hello
+hello="hello"
+if 4==5 then
+hello="goodbye "
+endif
+print *,hello,6," world" endprint
+\end{verbatim}
+Produces the result:
+\begin{verbatim}
+include <stdio.h>
+#include <string.h>
+int main(){
+char hello[11];
+strcpy(hello,"hello");
+if(4==5){
+strcpy(hello,"goodbye ");
+}
+printf("%s%d%s",hello,6," world");
+}
+
+hello6 world
+\end{verbatim}
 
 \subsection{Sprint n}
 
+
 \section{Final implementation}
 
 \section{Figures, tables, etc.}
-- 
cgit v1.2.3

