From a95193c1baea31f30d6b4009fd7e21a3bab5c2f8 Mon Sep 17 00:00:00 2001
From: AidenRushbrooke <72034940+AidenRushbrooke@users.noreply.github.com>
Date: Mon, 15 Nov 2021 16:00:16 +0000
Subject: Merged new BNF and testing section

---
 report/esoteric_project_report.tex | 125 ++++++++++++++++++++++++++++---------
 1 file changed, 94 insertions(+), 31 deletions(-)

(limited to 'report/esoteric_project_report.tex')

diff --git a/report/esoteric_project_report.tex b/report/esoteric_project_report.tex
index bddb721..dcb0e63 100644
--- a/report/esoteric_project_report.tex
+++ b/report/esoteric_project_report.tex
@@ -155,55 +155,62 @@ asdf
 		
 		\begin{tabular}{|l|r|}
 			\hline
-			\textbf{Token} & \textbf{Replaces}\\
-			\hline
-			! & \slash\slash \\
-			\hline
-			PROGRAM x & public class x \{ \\
-			\hline
-			END PROGRAM & \} \\
-			\hline
-			INTEGER & int \\
-			\hline
-			LOGICAL & boolean \\
+			\textbf{Abbreviation} & \textbf{Term}\\
 			\hline
-			.FALSE. & false \\
+			$<$program$>$ ::= & $<$statement$>$* \\
 			\hline
-			.TRUE. & true \\
+			$<$statement$>$ ::= & $<$declaration$>$ $|$ \\
+			& $<$expr-Statement$>$ $|$\\
+			& $<$print-Statement$>$ $|$ \\
+			& $<$if-Statement$>$ \\
 			\hline
-			CHARACTER(LEN=x) & String \\
+			$<$declaration$>$ ::= & "character (len = "$<$number$>$")::"$<$identifier$>$ $|$ \\
+			& "int::"$<$identifier$>$ \\
+			& "real::"$<$identifier$>$ \\
 			\hline
-			:: & = \\
+			$<$print-Statement$>$ ::= & "print *" (","$<$expression$>$)* "endprint" \\
 			\hline
-			IF (x) THEN & if(x) \{ \\
+			$<$if-Statement$>$ ::= & "if ("$<$expression$>$") then" $<$statement$>$* \\
+			& ("else" $<$statement$>$*)?\\
+			& "endif"\\
 			\hline
-			ELSE & else \\
+			$<$expr-statement$>$ ::= & $<$expression$>$\\
 			\hline
-			END IF & \} \\
+			$<$expression$>$ ::= & $<$assignment$>$\\
 			\hline
-			SELECT CASE (x) & switch(x) \{ \\
+			$<$assignment$>$ ::= & $<$identifier$>$"="$<$equality$>$$|$\\
+			& $<$equality$>$$|$\\
 			\hline
-			CASE (x) & case x: \\
+			$<$equality$>$ ::= & $<$comparison$>$"=="$<$comparison$>$$|$\\
+			& $<$comparison$>$$|$\\
 			\hline
-			CASE DEFAULT & default: \\
+			$<$comparison$>$ ::= & $<$term$>$("$>$"$|$"$<$")$<$term$>$$|$\\
+			& $<$term$>$$|$\\
 			\hline
-			END SELECT & \} \\
+			$<$term$>$ ::= & $<$factor$>$("+"$|$"-")$<$factor$>$$|$\\
+			& $<$factor$>$$|$\\
 			\hline
-			x & x; \\
+			$<$comparison$>$ ::= & $<$primary$>$("*"$|$"/")$<$primary$>$$|$\\
+			& $<$primary$>$$|$\\
 			\hline
-			DO x = y, z & for(x = y, x < z; x++) \{ \\
+			$<$primary$>$ ::= & $<$number$>$$|$\\
+			& $<$identifier$>$$|$\\
+			& $<$string$>$\\
+			
 			\hline
-			END DO & \} \\
+			$<$number$>$ ::= & $<$digit$>$*("."$<$digit$>$*)?\\
 			\hline
-			PRINT *, x & System.out.println(x); \\
+			
+			$<$identifier$>$ ::= & $<$alpha$>$*\\
 			\hline
-			SUBROUTINE x & static void x() \{ \\
+			$<$string$>$ ::= & """$<$alpha$>$*"""\\
 			\hline
-			END SUBROUTINE & \} \\
+			
+			$<$digit$>$::=&0\textbar1\textbar2\textbar3\textbar4\textbar5\textbar6\textbar7\textbar8\textbar9 \\
 			\hline
-			CALL x & x(); \\
+			
+			$<$alpha$>$::=&"a"..."z"$|$"A"..."Z"\\
 			\hline
-		
 		\end{tabular}
 		\label{tab:table1}
 		\caption{Grammar table for Fortran}
@@ -603,7 +610,63 @@ Note that code snippets or lists of crucial programming code or large UML diagra
 
 \chapter{Testing}
 
-Describe various experiments you designed to test your software product. This could be subdivided to be in line with the Sprints in Chapter \ref{Impl}. In case you have protocols which cover various pages, please put them in an appendix (e.g. Appendix A) instead.
+The testing was done in two main stages, first unit tests after each sprint were done in order to check correctness of the additions made, then large scale tests in order to check the compiler works as expected, is Turing complete and can handle any inputs.
+\section{Sprint testing}
+The testing that occurred after each sprint was done in two main stages. Firstly, the lexical scanner was unit tested independently from the rest of the code, then once we were confident that the scanner was working correctly, we tested the scanner and parser together. Due to the nature of the parsers output, we utilised a simple tree-walk interpreter for the first two sprints, then used the full compiler for the later sprints. The results of each test are shown in the tables below, giving the reason for the test, the input and output, and whether the test was successful.
+\subsection{Sprint 1 testing}
+\begin{table}[h]
+	\caption[]{Sprint 1 Tests and their results}
+	\begin{center}
+		\begin{tabular}{|l|l|l|l|}\hline
+			Reason & Input & Output & Success \\ \hline
+			Basic expression scanning & 1+1 & \parbox{2.5cm}{NUMBER 1 \\ PLUS + \\ NUMBER 1 \\EOF} & True \\ \hline
+			Decimal number scanning & 1.5 & \parbox{2.5cm}{NUMBER 1.5\\EOF} & True \\ \hline
+			Multiple character token scanning & 4==6 & \parbox{3.5cm}{NUMBER 4\\EQUALITY ==\\NUMBER 6\\EOF} & True \\ \hline
+			Invalid token character scanning & \# & \parbox{3cm}{Unexpected Character Error} & True \\ \hline
+			Literal expression parsing & 5 & 5 & True \\ \hline
+			Binary expression parsing & 1+1 & 2 & True \\ \hline
+			Bracketed expression parsing & (2*3) & 6 & True \\ \hline
+			Comparison parsing& 4$>$3 & true & True \\ \hline
+			Invalid syntax checking& 5+(3+2 & Error: Expected ')' & True \\ \hline
+			Invalid expression checking& 5++1 & Error: Syntax Error & True \\ \hline
+			Full expression test& 5*(3+1)-9/3 & 17 & True \\ \hline
+		\end{tabular}
+		\label{sprint1Test}
+	\end{center}
+\end{table}
+\newpage
+\subsection{Sprint 2 testing}
+\begin{table}[h]
+	\caption[]{Sprint 2 Tests and their results}
+	\begin{center}
+		\begin{tabular}{|l|l|l|l|}\hline
+			Reason & Input & Output & Success \\ \hline
+			Keyword scanning & print 5 & \parbox{2.5cm}{PRINT print \\ NUMBER 5 \\ EOF} & True \\ \hline
+			Identifier scanning & test & \parbox{3.5cm}{IDENTIFIER test\\EOF} & True \\ \hline
+			Print Expression test & print 5 & \parbox{3cm}{5} & True \\ \hline
+			Variable test & \parbox{3cm}{var::a\\a=5\\print a} & \parbox{3cm}{5} & True \\ \hline
+			Undefined variable test & \parbox{3cm}{a=5\\print a} & Error: Undefined Variable & True \\ \hline
+			Invalid syntax error & \parbox{3cm}{a=5\\prit 5} & Error: Syntax Error & True \\ \hline
+		\end{tabular}
+		\label{sprint2Test}
+	\end{center}
+\end{table}
+\subsection{Sprint 3 testing}
+\begin{table}[h]
+	\caption[]{Sprint 3 Tests and their results}
+	\begin{center}
+		\begin{tabular}{|l|l|l|l|}\hline
+			Reason & Input & Output & Success \\ \hline
+			If statement scanning & \parbox{3.5cm}{if 5==5 then\\endif} & \parbox{4cm}{IF \\ NUMBER 5 \\ EQUALS == \\ NUMBER 5\\ THEN\\ ENDIF \\EOF} & True \\ \hline
+			Print statement scanning & print*,5 endprint & \parbox{3.5cm}{PRINT\\STAR *\\COMMA ,\\NUMBER 5\\ENDPRINT\\EOF} & True \\ \hline
+			String scanning test & "test" & \parbox{3cm}{STRING test} & True \\ \hline
+			If statement parsing & \parbox{3cm}{int::a\\if 5==5 then\\a=3\\endif\\print*, a endprint} & \parbox{3cm}{3} & True \\ \hline
+			String parsing & \parbox{3cm}{print*,"hello world" endprint} & \parbox{3cm}{hello world} & True \\ \hline
+			Multiple print values & \parbox{3cm}{print*,5,"hello",6} & \parbox{3cm}{5hello6} & True \\ \hline
+		\end{tabular}
+		\label{sprint3Test}
+	\end{center}
+\end{table}
 
 \chapter{Discussion, conclusion and future work}
 
-- 
cgit v1.2.3

