summaryrefslogtreecommitdiff
path: root/comp/lucas-standen-NEA/writeup2/writeup.tex
diff options
context:
space:
mode:
authorthing 1 <thing1@seacrossedlovers.xyz>2024-12-09 12:46:53 +0000
committerthing 1 <thing1@seacrossedlovers.xyz>2024-12-09 12:46:53 +0000
commitc05d7ddb124a259fd08e0073a58ab6439011eceb (patch)
treedd43d8d5557593259706dfd1bca0a337e0df02d5 /comp/lucas-standen-NEA/writeup2/writeup.tex
parent4f6eeda94c025416a05f4421f59bc9964d094359 (diff)
finished the first full draft of the write-up
Diffstat (limited to 'comp/lucas-standen-NEA/writeup2/writeup.tex')
-rw-r--r--comp/lucas-standen-NEA/writeup2/writeup.tex53
1 files changed, 33 insertions, 20 deletions
diff --git a/comp/lucas-standen-NEA/writeup2/writeup.tex b/comp/lucas-standen-NEA/writeup2/writeup.tex
index e36fbc3..0869295 100644
--- a/comp/lucas-standen-NEA/writeup2/writeup.tex
+++ b/comp/lucas-standen-NEA/writeup2/writeup.tex
@@ -79,9 +79,9 @@ and out's of simpler compiler design and programming languages as a
whole.
This is the second version of this document, it was writen in GNU
-roff before, however I decided to move over to latex for the
-more moddern features (notably image support). The latex source for
-this document is also avalible along with all referenced code at
+roff before, however I decided to move over to {\LaTeX} for the
+more modern features (notably image support). The {\LaTeX} source for
+this document is also available along with all referenced code at
\url{https://github.com/standenboy/school}
Any questions relating to this document should be sent to
@@ -164,7 +164,7 @@ older projects.
it easy to see what parts of code will effect what, and make
things easy to tokenize.
\item[Perl]
- Perl is scripting language designed for use in linux, when bash is
+ Perl is scripting language designed for use in Linux, when bash is
too slow, or not suited for the job. Perl is often described as the glue
of the universe (see xkcd \url{https://3d.xkcd.com/224/}. Its syntax is
quite strange however and it is slow. Making it poorly suited towards
@@ -214,7 +214,7 @@ older projects.
too many times have I segfaulted due to a tiny mistake. Zippy should
also look to Hare's small size, you can buy a copy of Hare on a
- \textbf{SINGLE 3 1/2" FLOLPY}
+ \textbf{SINGLE 3 1/2" FLOPPY}
This is something I too should try to achieve.
\end{description}
@@ -286,7 +286,7 @@ project this should make the final outcome more helpful and what people want.
already implemented?]
Potentially if it is simple enough to implement new things.
\end{description}
-\subsubsection{Notes from questionnare 1}
+\subsubsection{Notes from questionnaire 1}
Some of the key things that I'm taking away from this first questionnaire, are my
client/users initial needs and use cases. I think it's clear my language can be of
assistance to my client, Zippy will be a good language for web back ends and
@@ -637,7 +637,7 @@ and a template executable. It will be a very simple tool, that copies needed fil
it will be written using Bash, (the main scripting language used by unix, along with sh and perl). It will have the
following arguments to allow the programmer to quickly write zippy code.
-C\begin{description}
+\begin{description}
\item[init] this will initialize the package manager, creating the needed files.
\item[advinit] this is an advanced form of init, it will set things up to have interoperability with C.
\item[build] this command can be used from within a zippy project directory, and will build the project into an executable.
@@ -669,9 +669,9 @@ C\begin{description}
\draw [arrow] (proc2) -- (proc3);
\draw [arrow] (proc3) -- (out1);
\draw [arrow] (out1) -- (dec1);
- \draw [arrow] (dec1) -- (out2);
+ \draw [arrow] (dec1) -- node[anchor=east] {Yes} (out2);
\draw [arrow] (out2) -- (end);
- \draw [arrow] (dec1) -- (proc4);
+ \draw [arrow] (dec1) -- node[anchor=north] {No} (proc4);
\draw [arrow] (proc4) |- (proc2);
\end{tikzpicture}
This is a high level diagram of what will go on in my code, with each box corresponding to around 1 function.
@@ -737,6 +737,7 @@ else; they have faster runtime speeds and a cleaner syntax that makes them prefe
C projects will follow this phylosophy, as it generally leads to better projects.
\section{Implementation}
+\subsection{Main C code}
As has been previously mentioned, zippy will have its compiler written in C and its package manager writen in bash.
The code will be displayed bellow, it has been commented to use a tool I wrote called autodoc, which can function
like a doc-string in python, after each file I will explain in detail what it does and why it is in its own file.
@@ -783,7 +784,7 @@ This function is used to set the current line, which is used if there is an erro
the output file and add newlines, if needed. And finally it handles the automatic free function of zippy.
The main function that this provides is the compile function, this starts by processing child arguments, A child argument can be created
-by the tokenizer when a nest function is used in zpy, for example (let a:int (+ 2 2)), in this case the child function is (+ 2 2). It
+by the tokeniser when a nest function is used in zpy, for example (let a:int (+ 2 2)), in this case the child function is (+ 2 2). It
will compile the children function first, using the processChildren function, assigning their outputs to the argument section of the AST.
It then uses a large if block, to determine which function it is needing to generate. Each branch, use the appendsnprintf function to
combine the arguments and templated C code. The checkNULL function is used a lot in this function. This is because if the user does
@@ -793,7 +794,7 @@ will cause the interrupt handler function to be triggered, telling the user the
of the issue.
Also in this file are a handful of helper functions in the conversion process, these convert zippy's reverse polish notation to traditional
-infix definition, and convert zippy's type annotations to C's type annotations.
+infix definition, and convert Zippy's type annotations to C's type annotations.
Finally, as previously mention there is the errorhandle function. This is triggered by a signal being sent to the program, and will cause
it to stop instantly, and will trigger an error print.
@@ -824,8 +825,8 @@ These will convert the C code into ASM, (sometimes through a middle man language
easier), which then gets assembled into an object file. These object files are not executable, in this state they
are libraries that can be used in other code. To make them executable they must be linked with the C stdlib and any
other used binary files; this is done by the linker. The linker will take the list of symbols defined in the object file,
-each symbol will correspond to one function in C. It will also take all the symbols in the libarys that the code is linked
-with. This means common libraries only need to be compiled once, and the linker can take pre compiled binarys.
+each symbol will correspond to one function in C. It will also take all the symbols in the libraries that the code is linked
+with. This means common libraries only need to be compiled once, and the linker can take pre compiled binaries and use them.
In this project, each .c file is converted to a .o file (an object file), and then the linker will link all of them together
to produce the final executable.
@@ -837,7 +838,7 @@ that will compile all the given code. Here is makefile:
This may look confusing, however its goal is very simple, each label (which are denoted with a ':') is a function
that can be run, the 'all' function is an omni function ran when the user types in 'make' with no arguments, whereas the others
-can be called with 'make install' and 'make clean'. The .c.o label is special, it compiles every C file, to a .o file, this is a
+can be called with 'make install' and 'make clean'. The .c.o label is special, it compiles every C file, into a .o file, this is a
shorthand syntax, that isn't very readable, but is easy to use. The .PHONY function is another special option, this is used to ensure
autocomplete works in the terminal when typing the make commands. Finally the variables defined at the top, are used to define compiler
options. In this case, im using -O3, which tells the compiler to perform the maximum optimisations to my code. Ensuring the compiler is
@@ -872,7 +873,7 @@ destroy and insert into strings. This library allows the user to easily make par
\subsection{Other libraries}
While I haven't ported or made any other libraries for zpy, this doesn't mean they can't be used, as long as a library can be linked
with C code (see the linking section above for more info), it can be used within zpy, and any function in the C stdlib is already
-available to use. I will use this later in my examples to use the raylib graphics library.
+available to use. I will use this later in my examples to use the Raylib graphics library.
\section{Testing}
\subsection{Introduction}
@@ -883,7 +884,7 @@ test the following
\item[String splitting] A small program that splits a string, to test the string processing class
\item[A incorrect program] To test the languages error messages
\item[A hello world program using zpypkg] To test that zpypkg can be used to manage projects
- \item[Space invaders] Using the raylib graphics library, I will build a clone of space invaders
+ \item[Space invaders] Using the Raylib graphics library, I will build a clone of space invaders
\end{description}
\subsection{Fibonacci}
The N'th number in the Fibonacci sequence can be calculated by adding the previous 2 numbers in the sequence, and assuming the first
@@ -973,8 +974,8 @@ Its as simple as that! Out of the way, and customizable via the build.sh file th
\subsection{Space invaders}
\subsubsection{Background}
-To build a small space invaders game, I'm going to use the raylib graphics library
-(\url{https://www.raylib.com/})
+To build a small space invaders game, I'm going to use the Raylib graphics library
+(\url{https://www.Raylib.com/})
based on GLFW. It is well known and over 10 years old at this point, it is fast, supports most devices and
operating systems under the sun, and is written in C for C, and due to this, it is also compatible with Zippy!
\subsubsection{Code}
@@ -1090,12 +1091,24 @@ on the C stdlib and many of its downsides have been passed over into Zippy.
\subsection{Extra objectives}
While these were optional, I still took the liberty of making them to make a more achieved project. I did not complete them
all due to time constraints. I made string parsing and graphics available in the standard library, via the string functions
-previously shown, and linking with the raylib graphics library.
+previously shown, and linking with the Raylib graphics library.
One could argue that all of these things are possible, as it is possible to link with a pre existing library to do the work
for you, but in some ways that cheating, and also won't work for libraries written in c++.
+\section{Conclusion}
+\subsection{Final thoughts}
+Overall I believe this project has achieved its goals nicely, I have made a simple language that has the power of C and
+the syntax of lisp, with added memory safety; this is what I set out to do. Along this project many things changed, from
+the scope of the language to the style it would take. When this project first started it was going to be a fully lisp
+like language with its own interpreter (not compiler), and was going to focus on higher level concepts that the final
+product. I decided to rewrite the code, and this write-up due to a ballooning code base and lack of features, the code
+was becoming impossible to manage and I had learned better ways of implementing features that what was originally used.
+When I began the re-write of the code, I thought it wise to re-write this write-up as my goals had changed, I also wanted
+to move it from GROFF MS to {\LaTeX} as GROFF had been giving challenges with including code segments.
+
+While if I had more time available I would like to flesh this out more, with features like text editor integration, and
+a nicer standard library, I believe I took this project to a good state.
}
-
\end{document}