From 68baa2efd72cb150dd6138d7b208b2621bcfc431 Mon Sep 17 00:00:00 2001 From: thing 1 Date: Thu, 5 Dec 2024 12:04:08 +0000 Subject: made a load of stuff --- comp/lucas-standen-NEA/code2/Makefile | 5 +++-- comp/lucas-standen-NEA/code2/comp.c | 16 ++++++++-------- comp/lucas-standen-NEA/code2/examples/fib_example | Bin 0 -> 24664 bytes .../lucas-standen-NEA/code2/examples/spaceinvaders | Bin 0 -> 21832 bytes comp/lucas-standen-NEA/code2/examples/str_example | Bin 0 -> 19704 bytes comp/lucas-standen-NEA/code2/examples/tmp.zpy.c | 2 ++ comp/lucas-standen-NEA/code2/fileread.c | 2 +- comp/lucas-standen-NEA/code2/stdlib/Makefile | 21 +++++++++++---------- .../lucas-standen-NEA/code2/stdlib/String/Makefile | 17 +++++++++++++---- comp/lucas-standen-NEA/code2/tokenizer.c | 2 +- comp/lucas-standen-NEA/code2/zpy | Bin 22360 -> 22072 bytes comp/lucas-standen-NEA/code2/zpy.c | 2 +- 12 files changed, 40 insertions(+), 27 deletions(-) create mode 100755 comp/lucas-standen-NEA/code2/examples/fib_example create mode 100755 comp/lucas-standen-NEA/code2/examples/spaceinvaders create mode 100755 comp/lucas-standen-NEA/code2/examples/str_example create mode 100644 comp/lucas-standen-NEA/code2/examples/tmp.zpy.c (limited to 'comp/lucas-standen-NEA/code2') diff --git a/comp/lucas-standen-NEA/code2/Makefile b/comp/lucas-standen-NEA/code2/Makefile index e01a111..847b50d 100644 --- a/comp/lucas-standen-NEA/code2/Makefile +++ b/comp/lucas-standen-NEA/code2/Makefile @@ -16,10 +16,11 @@ install: all cd stdlib && make install cd zpypkg && make install clean: - rm -rf zpy*.o + rm -rf zpy *.o cd stdlib && make clean cd examples && make clean uninstall: - rm /usr/local/bin/zpy + rm -f /usr/local/bin/zpy + cd stdlib && make uninstall .PHONY: all clean install uninstall diff --git a/comp/lucas-standen-NEA/code2/comp.c b/comp/lucas-standen-NEA/code2/comp.c index a2440e2..a056b44 100644 --- a/comp/lucas-standen-NEA/code2/comp.c +++ b/comp/lucas-standen-NEA/code2/comp.c @@ -34,7 +34,7 @@ void errorhandle(int type){ } //# this function will check if the value given is null, if it is, it will cause a sig segv and set the error msg -void checkNULL(void *value, char *msg){ +static void checkNULL(void *value, char *msg){ if (value == NULL) { errmsg = msg; kill(pid, SIGSEGV); @@ -82,10 +82,10 @@ char *names[] = { }; // function prototype for recursion of the compile function -char *compile(astNode *node); +static char *compile(astNode *node); //# this function will convert the zpy style variable defintion, to the c style -char *vartypeToC(char *str, char *out){ +static char *vartypeToC(char *str, char *out){ char *name = malloc(strlen(str)); char *type = malloc(strlen(str)); @@ -120,7 +120,7 @@ char *vartypeToC(char *str, char *out){ } //# this function will give the user the variable name, without its type, which is useful for translation -char *getVarName(char *exp){ +static char *getVarName(char *exp){ char *out = malloc(strlen(exp)); memcpy(out, exp, strlen(exp)); char *pos = strchr(out, ':'); @@ -130,7 +130,7 @@ char *getVarName(char *exp){ } //# this function will give the user the type, without its name, which is useful for translation -char *getVarType(char *exp){ +static char *getVarType(char *exp){ char *out = malloc(strlen(exp)); char *pos = strchr(exp, ':')+1; if (pos == NULL) checkNULL(NULL, "expected var type, got nothing"); @@ -138,7 +138,7 @@ char *getVarType(char *exp){ return out; } //# this will convert mathmatical expressions, to the c style of maths -char *reversepolishToC(astNode *exp, char *out){ +static char *reversepolishToC(astNode *exp, char *out){ out = appendsnprintf(out, MAXOUTLEN, "%s ", exp->args[0]); if (exp->func[0] == '=') out = appendsnprintf(out, MAXOUTLEN, "=="); else out = appendsnprintf(out, MAXOUTLEN, "%s", exp->func); @@ -147,7 +147,7 @@ char *reversepolishToC(astNode *exp, char *out){ } //# this is a recursive loop that will call the compile function recursivly to flatten the tree -astNode *processChildren(astNode *node){ +static astNode *processChildren(astNode *node){ for (int i = 0; i < 8; i++){ if (node->children[i] != NULL){ node->args[i] = compile(node->children[i]); @@ -158,7 +158,7 @@ astNode *processChildren(astNode *node){ } //# this function will do the bulk of converting from zpy into c code -char *compile(astNode *node){ +static char *compile(astNode *node){ char *out = calloc(0, MAXOUTLEN); node = processChildren(node); if (strcmp(names[0], node->func) == 0){ // converting function definitions diff --git a/comp/lucas-standen-NEA/code2/examples/fib_example b/comp/lucas-standen-NEA/code2/examples/fib_example new file mode 100755 index 0000000..5422fe2 Binary files /dev/null and b/comp/lucas-standen-NEA/code2/examples/fib_example differ diff --git a/comp/lucas-standen-NEA/code2/examples/spaceinvaders b/comp/lucas-standen-NEA/code2/examples/spaceinvaders new file mode 100755 index 0000000..5d4134c Binary files /dev/null and b/comp/lucas-standen-NEA/code2/examples/spaceinvaders differ diff --git a/comp/lucas-standen-NEA/code2/examples/str_example b/comp/lucas-standen-NEA/code2/examples/str_example new file mode 100755 index 0000000..084ef05 Binary files /dev/null and b/comp/lucas-standen-NEA/code2/examples/str_example differ diff --git a/comp/lucas-standen-NEA/code2/examples/tmp.zpy.c b/comp/lucas-standen-NEA/code2/examples/tmp.zpy.c new file mode 100644 index 0000000..2305f24 --- /dev/null +++ b/comp/lucas-standen-NEA/code2/examples/tmp.zpy.c @@ -0,0 +1,2 @@ +#include +int main(){ diff --git a/comp/lucas-standen-NEA/code2/fileread.c b/comp/lucas-standen-NEA/code2/fileread.c index 0bfc497..296ff55 100644 --- a/comp/lucas-standen-NEA/code2/fileread.c +++ b/comp/lucas-standen-NEA/code2/fileread.c @@ -11,7 +11,7 @@ typedef struct strings { } strings; //# counts the number of times c ocurrs in s -int countChars(char *s, char c){ +static int countChars(char *s, char c){ int count = 0; for (int i = 0; i < strlen(s); i++){ if (s[i] == c) count++; diff --git a/comp/lucas-standen-NEA/code2/stdlib/Makefile b/comp/lucas-standen-NEA/code2/stdlib/Makefile index c69992c..7d70f73 100644 --- a/comp/lucas-standen-NEA/code2/stdlib/Makefile +++ b/comp/lucas-standen-NEA/code2/stdlib/Makefile @@ -4,20 +4,21 @@ CFLAGS=-O3 SRC = zpylib.c OBJ = ${SRC:.c=.o} -all: zpy -.c.o: - ${CC} -c ${CFLAGS} $< +all: + ${CC} -c ${SRC} -o ${OBJ} ${CFLAGS} cd String && make install: all - cp zpy /usr/local/bin/zpy - cd stdlib && make install - cd zpypkg && make install + mkdir -p /usr/local/share/zpylib + cp zpylib.o /usr/local/share/zpylib/ + + mkdir -p /usr/local/share/zpylib/include + cp zpylib.h /usr/local/share/zpylib/include/ + cd String && make install clean: - rm -rf zpy*.o - cd stdlib && make clean - cd examples && make clean + rm -rf *.o + cd String && make clean uninstall: - rm /usr/local/bin/zpy + rm -rf /usr/local/share/zpylib .PHONY: all clean install uninstall diff --git a/comp/lucas-standen-NEA/code2/stdlib/String/Makefile b/comp/lucas-standen-NEA/code2/stdlib/String/Makefile index 053ab59..65c308b 100644 --- a/comp/lucas-standen-NEA/code2/stdlib/String/Makefile +++ b/comp/lucas-standen-NEA/code2/stdlib/String/Makefile @@ -1,7 +1,16 @@ CC=cc CFLAGS=-O3 -all: String.c - ${CC} String.c -c -o String.o ${CFLAGS} -clean: - rm -rf String.o +SRC = String.c +OBJ = ${SRC:.c=.o} + + +all: + ${CC} -c ${SRC} -o ${OBJ} ${CFLAGS} +install: all + cp String.o /usr/local/share/zpylib/ + cp String.h /usr/local/share/zpylib/include/ +clean: + rm -rf *.o + +.PHONY: all clean install uninstall diff --git a/comp/lucas-standen-NEA/code2/tokenizer.c b/comp/lucas-standen-NEA/code2/tokenizer.c index 0326057..65dd4a1 100644 --- a/comp/lucas-standen-NEA/code2/tokenizer.c +++ b/comp/lucas-standen-NEA/code2/tokenizer.c @@ -12,7 +12,7 @@ typedef struct astNode { } astNode; //# reads a block of code from src, until char, outputting to dst, it allows for brackets so it stays on the same depth -int readuntil(char *src, char c, char *dst){ +static int readuntil(char *src, char c, char *dst){ int ptr = 0; int depth = 0; int i = 0; diff --git a/comp/lucas-standen-NEA/code2/zpy b/comp/lucas-standen-NEA/code2/zpy index 85eb8a2..6ad15f3 100755 Binary files a/comp/lucas-standen-NEA/code2/zpy and b/comp/lucas-standen-NEA/code2/zpy differ diff --git a/comp/lucas-standen-NEA/code2/zpy.c b/comp/lucas-standen-NEA/code2/zpy.c index 65fd7ae..3f19a06 100644 --- a/comp/lucas-standen-NEA/code2/zpy.c +++ b/comp/lucas-standen-NEA/code2/zpy.c @@ -16,7 +16,7 @@ char compilerflags[64][128]; int compilerflagscount = 0; //# this function return will deal with the args given to stdin, and put the needed values into globals -void processargs(int argc, char **argv){ +static void processargs(int argc, char **argv){ for (int i = 1; i < argc; i++){ if (argv[i][0] == '-'){ switch (argv[i][1]){ -- cgit v1.2.3