updated readme

This commit is contained in:
Tommaso Rodolfo Masera 2018-12-12 19:52:48 +01:00
parent c19a9da695
commit 8227c356c2
2 changed files with 81 additions and 2 deletions

Binary file not shown.

View file

@ -41,6 +41,8 @@ The eight commands \brainfuck is based on are the following:
\subsection{About the Interpreter} \subsection{About the Interpreter}
\paragraph{The interpreter is written in Racket and was developed using DrRacket 7.0}
\subsubsection{Running the Program} \subsubsection{Running the Program}
You have two different options to run the program: a GUI and a CLI. You have two different options to run the program: a GUI and a CLI.
@ -51,12 +53,89 @@ As for the CLI version of the program you should use the ``\texttt{./cli.rkt}''
\subsubsection{Current Features} \subsubsection{Current Features}
\textbf{\large TODO} The current status of the project includes a fully functioning \brainfuck interpreter with
a GUI capable of displaying input and output of the program.
The GUI includes a live display of a Turing machine tape as the program runs.
The program is also supported via command line as well as allowing direct user input in
the \brainfuck program while it runs.
\section{Developer Level} \section{Developer Level}
\subsection{Interpreter Execution} \subsection{Interpreter Execution}
\textbf{\large TODO} \subsubsection{Program State}
The entire program revolves around the main struct defined as:\\
\texttt{
; A ProgState is a (prog-state tape dp output program ip) where: \\
; - tape: Tape\\
; - dp: DataPointer\\
; - tape-len: Nat\\
; - output: String\\
; - program: Program\\
; - ip: InstructionPointer\\
; - error: Option<ErrorCode>\\
; Interpretation: the current state of execution of a brainf*ck program.\\ \\
\textbf{\large (struct prog-state (tape dp tape-len output program ip error)}}
And, likewise, each term in the struct has its own type definition: \\
\texttt{
; A Byte is an Int between 0 and 255 \\
; Interpretation: a byte in decimal notation.\\ \\
; A Tape is a NEList<Byte>\\
; Interpretation: a tape in brainf*ck's Turing machine.\\\\
; A DataPointer (DP) is a NonNegInt\\
; Interpretation: a data pointer in the \brainfuck language in a tape.\\\\
; A Program is a String of:\\
; - ">" (tape-right)\\
; - "<" (tape-left)\\
; - "+" (add1)\\
; - "-" (sub1)\\
; - "." (out)\\
; - ","\\
; - "[" (loop-start)\\
; - "]" (loop-end)\\
; Interpretation: the brainf*ck program.\\\\
; A InstructionPointer (IP) is a NonNegInt\\
; Interpretation: a pointer to the instruction to execute.\\\\
; An ErrorCode is one of:\\
; - 'error1\\
; Interpretation: an error code for the bf interpreter.}
\subsubsection{Execute Function}
The main aspects of the \texttt{execute} function, other than executing the program, include:
\begin{itemize}
\item[-] The world state previously defined as a program state
\item[-] An asynchronous function call to get the user input when required by the program
\item[-] A callback function call defined as ``\texttt{done}'' which is called when an instruction is executed and that returns \texttt{\#false} when the program is at its last instruction.
\end{itemize}
\subsubsection{Interpreter Execution}
In order to parse the \brainfuck instructions correctly and ignore all other characters
in a \brainfuck file, the execute function requires a \texttt{cond} to give a condition to
each valid \brainfuck character and call the right function.
List of helper functions for execute:
\begin{itemize}
\item[] \textbf{\large \texttt{exec-tape-right}}:\\ ProgState -$>$ ProgState\\ Given a ProgState, returns a new ProgState with the $>$ instruction executed.
\item[] \textbf{\large \texttt{exec-tape-left}}:\\ ProgState -$>$ ProgState\\ Given a ProgState, returns a new ProgState with the $<$ instruction executed.
\item[] \textbf{\large \texttt{exec-add1}}:\\ ProgState -$>$ ProgState\\ Given a ProgState, returns a new ProgState with the $+$ instruction executed.
\item[] \textbf{\large \texttt{exec-sub1}}:\\ ProgState -$>$ ProgState\\ Given a ProgState, returns a new ProgState with the $-$ instruction executed.
\item[] \textbf{\large \texttt{exec-out}}:\\ ProgState -$>$ ProgState\\ Given a ProgState, returns a new ProgState with the . instruction executed.
\item[] \textbf{\large \texttt{exec-loop-start}}:\\ ProgState -$>$ ProgState\\ Given a ProgState, returns a new ProgState with the $[$ instruction executed.
\item[] \textbf{\large \texttt{exec-loop-end}}:\\ ProgState -$>$ ProgState\\ Given a ProgState, returns a new ProgState with the $]$ instruction executed.
\item[] \textbf{\large \texttt{exec-in}}:\\ ProgState ((Byte -$>$ \_) -$>$ \_) (ProgState -$>$ \_) -$>$ \_\\ Given a ProgState, a function that takes a callback function requiring a Byte and a function which takes the new ProgState, calls done with the input provided by get-input (provided by the call to the callback given in get-input).
\end{itemize}
\end{document} \end{document}