summaryrefslogtreecommitdiff
path: root/comp/lucas-standen-NEA/code
diff options
context:
space:
mode:
authorstandenboy <standenboy@seacrossedlovers.xyz>2024-05-16 18:39:21 +0100
committerstandenboy <standenboy@seacrossedlovers.xyz>2024-05-16 18:39:21 +0100
commitdc28082a9ba55dac68883cb7b26514f921aa8edd (patch)
tree563c3b1c3f177f79e7e301b079b1d56f5904c384 /comp/lucas-standen-NEA/code
parent14b5defaa1a106afd51e3c64f6791e1ed081feea (diff)
added a load of files
Diffstat (limited to 'comp/lucas-standen-NEA/code')
-rw-r--r--comp/lucas-standen-NEA/code/Makefile0
-rw-r--r--comp/lucas-standen-NEA/code/ads/ast/Makefile0
-rw-r--r--comp/lucas-standen-NEA/code/ads/ast/ast.c0
-rw-r--r--comp/lucas-standen-NEA/code/ads/ast/ast.h0
-rw-r--r--comp/lucas-standen-NEA/code/ads/ast/types.c0
-rw-r--r--comp/lucas-standen-NEA/code/ads/ast/types.h0
-rw-r--r--comp/lucas-standen-NEA/code/execution/Makefile0
-rw-r--r--comp/lucas-standen-NEA/code/execution/exec.c0
-rw-r--r--comp/lucas-standen-NEA/code/execution/exec.h0
-rw-r--r--comp/lucas-standen-NEA/code/execution/types.c0
-rw-r--r--comp/lucas-standen-NEA/code/execution/types.h0
-rw-r--r--comp/lucas-standen-NEA/code/libs/Makefile0
-rw-r--r--comp/lucas-standen-NEA/code/libs/graphs/graphs.zpy0
-rw-r--r--comp/lucas-standen-NEA/code/libs/io/io.zpy0
-rw-r--r--comp/lucas-standen-NEA/code/libs/stdlib/Makefile0
-rw-r--r--comp/lucas-standen-NEA/code/libs/stdlib/stdlib.c0
-rw-r--r--comp/lucas-standen-NEA/code/libs/stdlib/stdlib.zpy0
-rw-r--r--comp/lucas-standen-NEA/code/libs/string/string.zpy0
-rw-r--r--comp/lucas-standen-NEA/code/proto/ast/ast.c12
-rw-r--r--comp/lucas-standen-NEA/code/proto/ast/left0
-rw-r--r--comp/lucas-standen-NEA/code/proto/ast/right0
-rw-r--r--comp/lucas-standen-NEA/code/tokenizer/Makefile5
-rw-r--r--comp/lucas-standen-NEA/code/tokenizer/parser.c37
-rw-r--r--comp/lucas-standen-NEA/code/tokenizer/parser.h3
-rw-r--r--comp/lucas-standen-NEA/code/tokenizer/sample.zpy5
-rw-r--r--comp/lucas-standen-NEA/code/tokenizer/tokenizer.c3
-rw-r--r--comp/lucas-standen-NEA/code/tokenizer/tokenizer.h0
-rw-r--r--comp/lucas-standen-NEA/code/tokenizer/types.c0
-rw-r--r--comp/lucas-standen-NEA/code/tokenizer/types.h0
-rw-r--r--comp/lucas-standen-NEA/code/tokenizer/util.c27
-rw-r--r--comp/lucas-standen-NEA/code/tokenizer/util.h3
-rw-r--r--comp/lucas-standen-NEA/code/zpy/Makefile0
-rw-r--r--comp/lucas-standen-NEA/code/zpy/zpy.c0
-rw-r--r--comp/lucas-standen-NEA/code/zpy/zpycheck.c0
-rw-r--r--comp/lucas-standen-NEA/code/zpycheck/Makefile0
-rw-r--r--comp/lucas-standen-NEA/code/zpycheck/errors.c0
-rw-r--r--comp/lucas-standen-NEA/code/zpycheck/errors.h0
-rw-r--r--comp/lucas-standen-NEA/code/zpycheck/zpycheck.c0
-rw-r--r--comp/lucas-standen-NEA/code/zpycheck/zpycheck.h0
-rw-r--r--comp/lucas-standen-NEA/code/zpypkg/deps.zpy0
-rw-r--r--comp/lucas-standen-NEA/code/zpypkg/download.zpy0
-rw-r--r--comp/lucas-standen-NEA/code/zpypkg/zpypkg.zpy0
42 files changed, 89 insertions, 6 deletions
diff --git a/comp/lucas-standen-NEA/code/Makefile b/comp/lucas-standen-NEA/code/Makefile
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/Makefile
diff --git a/comp/lucas-standen-NEA/code/ads/ast/Makefile b/comp/lucas-standen-NEA/code/ads/ast/Makefile
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/ads/ast/Makefile
diff --git a/comp/lucas-standen-NEA/code/ads/ast/ast.c b/comp/lucas-standen-NEA/code/ads/ast/ast.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/ads/ast/ast.c
diff --git a/comp/lucas-standen-NEA/code/ads/ast/ast.h b/comp/lucas-standen-NEA/code/ads/ast/ast.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/ads/ast/ast.h
diff --git a/comp/lucas-standen-NEA/code/ads/ast/types.c b/comp/lucas-standen-NEA/code/ads/ast/types.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/ads/ast/types.c
diff --git a/comp/lucas-standen-NEA/code/ads/ast/types.h b/comp/lucas-standen-NEA/code/ads/ast/types.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/ads/ast/types.h
diff --git a/comp/lucas-standen-NEA/code/execution/Makefile b/comp/lucas-standen-NEA/code/execution/Makefile
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/execution/Makefile
diff --git a/comp/lucas-standen-NEA/code/execution/exec.c b/comp/lucas-standen-NEA/code/execution/exec.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/execution/exec.c
diff --git a/comp/lucas-standen-NEA/code/execution/exec.h b/comp/lucas-standen-NEA/code/execution/exec.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/execution/exec.h
diff --git a/comp/lucas-standen-NEA/code/execution/types.c b/comp/lucas-standen-NEA/code/execution/types.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/execution/types.c
diff --git a/comp/lucas-standen-NEA/code/execution/types.h b/comp/lucas-standen-NEA/code/execution/types.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/execution/types.h
diff --git a/comp/lucas-standen-NEA/code/libs/Makefile b/comp/lucas-standen-NEA/code/libs/Makefile
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/libs/Makefile
diff --git a/comp/lucas-standen-NEA/code/libs/graphs/graphs.zpy b/comp/lucas-standen-NEA/code/libs/graphs/graphs.zpy
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/libs/graphs/graphs.zpy
diff --git a/comp/lucas-standen-NEA/code/libs/io/io.zpy b/comp/lucas-standen-NEA/code/libs/io/io.zpy
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/libs/io/io.zpy
diff --git a/comp/lucas-standen-NEA/code/libs/stdlib/Makefile b/comp/lucas-standen-NEA/code/libs/stdlib/Makefile
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/libs/stdlib/Makefile
diff --git a/comp/lucas-standen-NEA/code/libs/stdlib/stdlib.c b/comp/lucas-standen-NEA/code/libs/stdlib/stdlib.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/libs/stdlib/stdlib.c
diff --git a/comp/lucas-standen-NEA/code/libs/stdlib/stdlib.zpy b/comp/lucas-standen-NEA/code/libs/stdlib/stdlib.zpy
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/libs/stdlib/stdlib.zpy
diff --git a/comp/lucas-standen-NEA/code/libs/string/string.zpy b/comp/lucas-standen-NEA/code/libs/string/string.zpy
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/libs/string/string.zpy
diff --git a/comp/lucas-standen-NEA/code/proto/ast/ast.c b/comp/lucas-standen-NEA/code/proto/ast/ast.c
index 5163032..d76107b 100644
--- a/comp/lucas-standen-NEA/code/proto/ast/ast.c
+++ b/comp/lucas-standen-NEA/code/proto/ast/ast.c
@@ -4,11 +4,12 @@
#include "astg.h"
-void getBrackets(char *in, int bpos, char *out){ // gets the content of the brackets that open at bpos
+void getBrackets(char *in, int bpos, char *out){
+ // gets the content of the brackets that open at bpos
if (in[0] != '(' && in[0] != '[')
out = NULL;
- char *input = malloc(strlen(in) + 1);
+ char *input = malloc(strlen(in) + 1); // cpy in for mem safety
char *Pinput = input;
memcpy(input, in, strlen(in) + 1);
@@ -19,7 +20,7 @@ void getBrackets(char *in, int bpos, char *out){ // gets the content of the brac
}
i = 0;
int depth = 0;
- while (input[0] != '\0'){
+ while (input[0] != '\0'){ // loop through input
out[i] = input[0];
if (input[0] == '(' || input[0] == '[')
depth++;
@@ -38,7 +39,7 @@ void getBrackets(char *in, int bpos, char *out){ // gets the content of the brac
free(Pinput);
}
-int getContents(char *brackets){
+int getContents(char *brackets){ // get all the content in brackets
int i = 0;
char *num = malloc(strlen(brackets));
while (brackets[0] != '\0'){
@@ -133,9 +134,8 @@ ast_node *genAst(char *expression){
return out;
}
-
int main(int argc, char **argv){
- if (argc < 2)
+ if (argc < 2) // die if no argument given
exit(1);
ast_node *head = genAst(argv[1]);
diff --git a/comp/lucas-standen-NEA/code/proto/ast/left b/comp/lucas-standen-NEA/code/proto/ast/left
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/proto/ast/left
diff --git a/comp/lucas-standen-NEA/code/proto/ast/right b/comp/lucas-standen-NEA/code/proto/ast/right
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/proto/ast/right
diff --git a/comp/lucas-standen-NEA/code/tokenizer/Makefile b/comp/lucas-standen-NEA/code/tokenizer/Makefile
new file mode 100644
index 0000000..b5cfe56
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/tokenizer/Makefile
@@ -0,0 +1,5 @@
+
+parser: parser.c util
+ cc -O3 parser.c util.o -c -o parser.o
+util: util.c
+ cc -O3 util.c -c -o util.o
diff --git a/comp/lucas-standen-NEA/code/tokenizer/parser.c b/comp/lucas-standen-NEA/code/tokenizer/parser.c
new file mode 100644
index 0000000..9ac9fde
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/tokenizer/parser.c
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "util.h"
+
+char *Parse(char *fileName); // general parser function
+
+char *ReadFile(char *fileName); // reads the file into a single var
+
+char *ReadFile(char *filename){
+ FILE *f = fopen(filename, "r");
+ if (f == NULL)
+ Die();
+
+ fseek(f, 0, SEEK_END);
+ size_t len = ftell(f);
+ rewind(f);
+
+ char *out = malloc(len+1);
+
+ char c;
+ for (int i = 0; i < len; i++){
+ c = fgetc(f);
+ if (c == '\n' || c == '\t')
+ out[i] = ' ';
+ else
+ out[i] = c;
+ }
+ out[len+1] = '\0';
+
+ fclose(f);
+ return out;
+}
+
+char *Parser(char *fileName){
+ return ReadFile(fileName);
+}
diff --git a/comp/lucas-standen-NEA/code/tokenizer/parser.h b/comp/lucas-standen-NEA/code/tokenizer/parser.h
new file mode 100644
index 0000000..e4f69a8
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/tokenizer/parser.h
@@ -0,0 +1,3 @@
+char *Parse(char *fileName); // general parser function
+
+char *ReadFile(char *fileName); // reads the file into a single var
diff --git a/comp/lucas-standen-NEA/code/tokenizer/sample.zpy b/comp/lucas-standen-NEA/code/tokenizer/sample.zpy
new file mode 100644
index 0000000..f0d9700
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/tokenizer/sample.zpy
@@ -0,0 +1,5 @@
+(let x:char[] "he
+llo")
+
+(let y:i32 20)
+
diff --git a/comp/lucas-standen-NEA/code/tokenizer/tokenizer.c b/comp/lucas-standen-NEA/code/tokenizer/tokenizer.c
new file mode 100644
index 0000000..a643455
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/tokenizer/tokenizer.c
@@ -0,0 +1,3 @@
+#include "parser.h"
+
+
diff --git a/comp/lucas-standen-NEA/code/tokenizer/tokenizer.h b/comp/lucas-standen-NEA/code/tokenizer/tokenizer.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/tokenizer/tokenizer.h
diff --git a/comp/lucas-standen-NEA/code/tokenizer/types.c b/comp/lucas-standen-NEA/code/tokenizer/types.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/tokenizer/types.c
diff --git a/comp/lucas-standen-NEA/code/tokenizer/types.h b/comp/lucas-standen-NEA/code/tokenizer/types.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/tokenizer/types.h
diff --git a/comp/lucas-standen-NEA/code/tokenizer/util.c b/comp/lucas-standen-NEA/code/tokenizer/util.c
new file mode 100644
index 0000000..de5b6b2
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/tokenizer/util.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <error.h>
+
+void Die(); // brings down the program
+void *CheckedMalloc(long size); // malloc checked
+void *CheckedRealloc(void *out, long size); // realloc checked
+
+void Die(){
+ perror("zpy parser");
+ exit(errno);
+}
+
+void *CheckedMalloc(long size){
+ void *out = malloc(size);
+ if (out == NULL)
+ Die();
+ return out;
+}
+
+void *CheckedRealloc(void *orig, long size){
+ void *out = realloc(orig, size);
+ if (out == NULL)
+ Die();
+ return out;
+}
diff --git a/comp/lucas-standen-NEA/code/tokenizer/util.h b/comp/lucas-standen-NEA/code/tokenizer/util.h
new file mode 100644
index 0000000..cbcbdfa
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/tokenizer/util.h
@@ -0,0 +1,3 @@
+void Die(); // brings down the program
+void *CheckedMalloc(long size); // malloc checked
+void *CheckedRealloc(void *out, long size); // realloc checked
diff --git a/comp/lucas-standen-NEA/code/zpy/Makefile b/comp/lucas-standen-NEA/code/zpy/Makefile
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/zpy/Makefile
diff --git a/comp/lucas-standen-NEA/code/zpy/zpy.c b/comp/lucas-standen-NEA/code/zpy/zpy.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/zpy/zpy.c
diff --git a/comp/lucas-standen-NEA/code/zpy/zpycheck.c b/comp/lucas-standen-NEA/code/zpy/zpycheck.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/zpy/zpycheck.c
diff --git a/comp/lucas-standen-NEA/code/zpycheck/Makefile b/comp/lucas-standen-NEA/code/zpycheck/Makefile
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/zpycheck/Makefile
diff --git a/comp/lucas-standen-NEA/code/zpycheck/errors.c b/comp/lucas-standen-NEA/code/zpycheck/errors.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/zpycheck/errors.c
diff --git a/comp/lucas-standen-NEA/code/zpycheck/errors.h b/comp/lucas-standen-NEA/code/zpycheck/errors.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/zpycheck/errors.h
diff --git a/comp/lucas-standen-NEA/code/zpycheck/zpycheck.c b/comp/lucas-standen-NEA/code/zpycheck/zpycheck.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/zpycheck/zpycheck.c
diff --git a/comp/lucas-standen-NEA/code/zpycheck/zpycheck.h b/comp/lucas-standen-NEA/code/zpycheck/zpycheck.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/zpycheck/zpycheck.h
diff --git a/comp/lucas-standen-NEA/code/zpypkg/deps.zpy b/comp/lucas-standen-NEA/code/zpypkg/deps.zpy
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/zpypkg/deps.zpy
diff --git a/comp/lucas-standen-NEA/code/zpypkg/download.zpy b/comp/lucas-standen-NEA/code/zpypkg/download.zpy
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/zpypkg/download.zpy
diff --git a/comp/lucas-standen-NEA/code/zpypkg/zpypkg.zpy b/comp/lucas-standen-NEA/code/zpypkg/zpypkg.zpy
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/comp/lucas-standen-NEA/code/zpypkg/zpypkg.zpy