diff options
Diffstat (limited to 'comp/cw/code')
39 files changed, 0 insertions, 536 deletions
diff --git a/comp/cw/code/ads/dict/Makefile b/comp/cw/code/ads/dict/Makefile deleted file mode 100644 index f224267..0000000 --- a/comp/cw/code/ads/dict/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: dict.c - cc dict.c -c -o dict.o -test: all - cc dict.o dicttest.c -o dicttest diff --git a/comp/cw/code/ads/dict/dict.c b/comp/cw/code/ads/dict/dict.c deleted file mode 100644 index 551afca..0000000 --- a/comp/cw/code/ads/dict/dict.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <stdlib.h> -#include <string.h> - -typedef struct dict_t { - int id; - void *data; -}dict_t; - -dict_t *dictalloc(){ - dict_t *output = malloc(sizeof(dict_t)); - return output; -} - -int dictset(dict_t *dict, int id, void *data){ - dict->id = id; - - dict->data = malloc(sizeof(data)); - if (dict->data == NULL) - return 1; - memcpy(dict->data, data, sizeof(data)); - - return 0; -} - -void dictfree(dict_t *dict){ - free(dict->data); - free(dict); -} - diff --git a/comp/cw/code/ads/dict/dict.h b/comp/cw/code/ads/dict/dict.h deleted file mode 100644 index e6ab69d..0000000 --- a/comp/cw/code/ads/dict/dict.h +++ /dev/null @@ -1,9 +0,0 @@ -typedef struct dict_t { - int id; - void *data; -}dict_t; - -dict_t *dictalloc(); -int dictset(dict_t *dict, int id, void *data); -void dictfree(dict_t *dict); - diff --git a/comp/cw/code/ads/dict/dicttest b/comp/cw/code/ads/dict/dicttest Binary files differdeleted file mode 100755 index dddf2a0..0000000 --- a/comp/cw/code/ads/dict/dicttest +++ /dev/null diff --git a/comp/cw/code/ads/dict/dicttest.c b/comp/cw/code/ads/dict/dicttest.c deleted file mode 100644 index 4a20870..0000000 --- a/comp/cw/code/ads/dict/dicttest.c +++ /dev/null @@ -1,10 +0,0 @@ -#include <stdio.h> - -#include "dict.h" - -int main(){ - dict_t *dict = dictalloc(); - dictset(dict, 1, "hello"); - printf("%d:%s\n", dict->id, (char *)dict->data); - dictfree(dict); -} diff --git a/comp/cw/code/ads/ll/Makefile b/comp/cw/code/ads/ll/Makefile deleted file mode 100644 index aaf0241..0000000 --- a/comp/cw/code/ads/ll/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -all: ll.c - cc ll.c -c -o ll.o - -test: all - cc ll.o lltest.c -o lltest diff --git a/comp/cw/code/ads/ll/ll.c b/comp/cw/code/ads/ll/ll.c deleted file mode 100644 index c45ab0c..0000000 --- a/comp/cw/code/ads/ll/ll.c +++ /dev/null @@ -1,50 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -typedef struct ll_t ll_t; - -typedef struct ll_t { - void *data; - ll_t *next; -} ll_t; - -ll_t *llalloc(){ - ll_t *output = malloc(sizeof(ll_t)); - if (output == NULL) - return NULL; - output->next = NULL; - return output; -} - -void llsetdata(ll_t *node, void *data){ - node->data = malloc(sizeof(data)); - memcpy(node->data, data, sizeof(data)); -} - -void llsetnext(ll_t *node, ll_t *next){ - if (node->next == NULL) - node->next = next; - else - llsetnext(node->next, next); -} - -void *llgetat(ll_t *head, int index){ - if (index == 0) - return head->data; - else { - if (head->next != NULL) { - return llgetat(head->next, index - 1); - }else { - return NULL; - } - } -} - -void llfreeall(ll_t *head){ - if (head->next != NULL) - llfreeall(head->next); - free(head->data); - free(head); -} - diff --git a/comp/cw/code/ads/ll/ll.h b/comp/cw/code/ads/ll/ll.h deleted file mode 100644 index 30830b1..0000000 --- a/comp/cw/code/ads/ll/ll.h +++ /dev/null @@ -1,15 +0,0 @@ -#include <stdlib.h> -#include <string.h> - -typedef struct ll_t ll_t; - -typedef struct ll_t { - void *data; - ll_t *next; -} ll_t; - -ll_t *llalloc(); -void llsetdata(ll_t *node, void *data); -void llsetnext(ll_t *node, ll_t *next); -void *llgetat(ll_t *head, int index); -void llfreeall(ll_t *head); diff --git a/comp/cw/code/ads/ll/lltest b/comp/cw/code/ads/ll/lltest Binary files differdeleted file mode 100755 index b98c5de..0000000 --- a/comp/cw/code/ads/ll/lltest +++ /dev/null diff --git a/comp/cw/code/ads/ll/lltest.c b/comp/cw/code/ads/ll/lltest.c deleted file mode 100644 index 8aa6514..0000000 --- a/comp/cw/code/ads/ll/lltest.c +++ /dev/null @@ -1,18 +0,0 @@ -#include <stdio.h> - -#include "ll.h" - -int main(){ - ll_t *head = llalloc(); - llsetdata(head, "hello"); - - for (int i = 0; i < 3; i++){ - ll_t *node = llalloc(); - llsetdata(node, "hi"); - llsetnext(head, node); - } - for (int i = 0; i < 4; i++) - printf("%s\n", (char *)llgetat(head, i)); - - llfreeall(head); -} diff --git a/comp/cw/code/parser/Makefile b/comp/cw/code/parser/Makefile deleted file mode 100644 index 9325d95..0000000 --- a/comp/cw/code/parser/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -all: readfile preprocesor parser - cc readfile.o preprocessor.o parser.o -o parser - -readfile: - cc -c readfile.c -o readfile.o -preprocesor: - cc -c preprocessor.c -o preprocessor.o -parser: parser.c - cc -c parser.c -o parser.o - -clean: - rm -rf *.o parser diff --git a/comp/cw/code/parser/parser b/comp/cw/code/parser/parser Binary files differdeleted file mode 100755 index 9d996a8..0000000 --- a/comp/cw/code/parser/parser +++ /dev/null diff --git a/comp/cw/code/parser/parser.c b/comp/cw/code/parser/parser.c deleted file mode 100644 index 3162841..0000000 --- a/comp/cw/code/parser/parser.c +++ /dev/null @@ -1,32 +0,0 @@ -#include <string.h> -#include <stdio.h> -#include <stdbool.h> - -#include "preprocessor.h" - -int main(int argc, char **argv){ - if (argc <= 1){ - printf("no args given!\n"); - return 1; - } - char *code = preprocessor(argc, argv); - if (code == NULL){ - printf("falled to open file\n"); - return 1; - } - for (int i = 0; i < strlen(code); i++){ - if (code[i] == '{'){ - printf("\nopen-scope\n"); - } else if (code[i] == '}'){ - printf("\nclose-scope\n"); - }else { - if (code[i] == '(') - printf("\n"); - else if (code[i] != ')') - printf("%c", code[i]); - } - } - printf("\n"); - free(code); - return 0; -} diff --git a/comp/cw/code/parser/parser.o b/comp/cw/code/parser/parser.o Binary files differdeleted file mode 100644 index baccd37..0000000 --- a/comp/cw/code/parser/parser.o +++ /dev/null diff --git a/comp/cw/code/parser/preprocessor.c b/comp/cw/code/parser/preprocessor.c deleted file mode 100644 index 92c6127..0000000 --- a/comp/cw/code/parser/preprocessor.c +++ /dev/null @@ -1,24 +0,0 @@ -#include <stdbool.h> -#include <string.h> - -#include "readfile.h" - -char *preprocessor(int argc, char **argv){ - char *buf = readfile(argv[1]); - if (buf == NULL) - return NULL; - - int i = 0; - - while (buf[i] != '\0'){ - if (buf[i] == '\n'){ - buf[i] = ' '; - } - if (buf[i] == '\t'){ - buf[i] = ' '; - } - i++; - } - - return buf; -} diff --git a/comp/cw/code/parser/preprocessor.h b/comp/cw/code/parser/preprocessor.h deleted file mode 100644 index 855240f..0000000 --- a/comp/cw/code/parser/preprocessor.h +++ /dev/null @@ -1,5 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -char *preprocessor(int argc, char **argv); diff --git a/comp/cw/code/parser/preprocessor.o b/comp/cw/code/parser/preprocessor.o Binary files differdeleted file mode 100644 index fad2c87..0000000 --- a/comp/cw/code/parser/preprocessor.o +++ /dev/null diff --git a/comp/cw/code/parser/readfile.c b/comp/cw/code/parser/readfile.c deleted file mode 100644 index 391d5a5..0000000 --- a/comp/cw/code/parser/readfile.c +++ /dev/null @@ -1,61 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <stdbool.h> - -bool instring = false; - -char *readfile(char *filepath){ - FILE *fptr; - fptr = fopen(filepath, "r"); - - if (fptr == NULL) - return NULL; - int size = 10; - char *buf = malloc(size); - char c; - - int i = 0; - - buf = buf+i; - buf[0] = '{'; - buf = buf-i; - - i++; - - while ((c = getc(fptr)) != EOF){ - if (i > size + 1){ - size = size + 10; - buf = realloc(buf, size); - } - if (c == '"'){ - if (instring == false) - instring = true; - else - instring = false; - } - - if (c == '!' && instring == false){ - while ((c = getc(fptr)) != EOF && c != '\n'){} - } - buf = buf+i; - buf[0] = c; - buf = buf-i; - i++; - - } - - buf = buf+i; - buf[0] = '}'; - buf = buf-i; - - i++; - - buf = buf+i; - buf[0] = '\0'; - buf = buf-i; - - fclose(fptr); - - return buf; -} diff --git a/comp/cw/code/parser/readfile.h b/comp/cw/code/parser/readfile.h deleted file mode 100644 index 12d98ec..0000000 --- a/comp/cw/code/parser/readfile.h +++ /dev/null @@ -1 +0,0 @@ -char *readfile(char *filepath); diff --git a/comp/cw/code/parser/readfile.o b/comp/cw/code/parser/readfile.o Binary files differdeleted file mode 100644 index 32bc31d..0000000 --- a/comp/cw/code/parser/readfile.o +++ /dev/null diff --git a/comp/cw/code/parser/sample.zpy b/comp/cw/code/parser/sample.zpy deleted file mode 100644 index e289d9d..0000000 --- a/comp/cw/code/parser/sample.zpy +++ /dev/null @@ -1,15 +0,0 @@ -{ -(let fib:function -(defun num:i32 i32 - (if (< num 2) - (return num) - ) - (else - (return (+ (fib (- num 1)) (fib (- num 2)) )) - ) -)) -} -(let a:i32 (fib 5)) -(const str[]:char "hello!") -! returns the 5th fib number -(const str[]:char "hello!") diff --git a/comp/cw/code/tokenizer/ads/dict/Makefile b/comp/cw/code/tokenizer/ads/dict/Makefile deleted file mode 100644 index f224267..0000000 --- a/comp/cw/code/tokenizer/ads/dict/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: dict.c - cc dict.c -c -o dict.o -test: all - cc dict.o dicttest.c -o dicttest diff --git a/comp/cw/code/tokenizer/ads/dict/dict.c b/comp/cw/code/tokenizer/ads/dict/dict.c deleted file mode 100644 index 551afca..0000000 --- a/comp/cw/code/tokenizer/ads/dict/dict.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <stdlib.h> -#include <string.h> - -typedef struct dict_t { - int id; - void *data; -}dict_t; - -dict_t *dictalloc(){ - dict_t *output = malloc(sizeof(dict_t)); - return output; -} - -int dictset(dict_t *dict, int id, void *data){ - dict->id = id; - - dict->data = malloc(sizeof(data)); - if (dict->data == NULL) - return 1; - memcpy(dict->data, data, sizeof(data)); - - return 0; -} - -void dictfree(dict_t *dict){ - free(dict->data); - free(dict); -} - diff --git a/comp/cw/code/tokenizer/ads/dict/dict.h b/comp/cw/code/tokenizer/ads/dict/dict.h deleted file mode 100644 index e6ab69d..0000000 --- a/comp/cw/code/tokenizer/ads/dict/dict.h +++ /dev/null @@ -1,9 +0,0 @@ -typedef struct dict_t { - int id; - void *data; -}dict_t; - -dict_t *dictalloc(); -int dictset(dict_t *dict, int id, void *data); -void dictfree(dict_t *dict); - diff --git a/comp/cw/code/tokenizer/ads/dict/dict.o b/comp/cw/code/tokenizer/ads/dict/dict.o Binary files differdeleted file mode 100644 index aefd77a..0000000 --- a/comp/cw/code/tokenizer/ads/dict/dict.o +++ /dev/null diff --git a/comp/cw/code/tokenizer/ads/dict/dicttest b/comp/cw/code/tokenizer/ads/dict/dicttest Binary files differdeleted file mode 100755 index dddf2a0..0000000 --- a/comp/cw/code/tokenizer/ads/dict/dicttest +++ /dev/null diff --git a/comp/cw/code/tokenizer/ads/dict/dicttest.c b/comp/cw/code/tokenizer/ads/dict/dicttest.c deleted file mode 100644 index 4a20870..0000000 --- a/comp/cw/code/tokenizer/ads/dict/dicttest.c +++ /dev/null @@ -1,10 +0,0 @@ -#include <stdio.h> - -#include "dict.h" - -int main(){ - dict_t *dict = dictalloc(); - dictset(dict, 1, "hello"); - printf("%d:%s\n", dict->id, (char *)dict->data); - dictfree(dict); -} diff --git a/comp/cw/code/tokenizer/ads/dll/Makefile b/comp/cw/code/tokenizer/ads/dll/Makefile deleted file mode 100644 index 651681d..0000000 --- a/comp/cw/code/tokenizer/ads/dll/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -all: dll.c - cc dll.c -c -o dll.o - -test: all - cc dll.o dlltest.c -o dlltest diff --git a/comp/cw/code/tokenizer/ads/dll/dll.c b/comp/cw/code/tokenizer/ads/dll/dll.c deleted file mode 100644 index b24b13f..0000000 --- a/comp/cw/code/tokenizer/ads/dll/dll.c +++ /dev/null @@ -1,62 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -typedef struct dll_t dll_t; - -typedef struct dll_t { - void *data; - dll_t *next; - dll_t *prev; -} dll_t; - -dll_t *dllalloc(){ - dll_t *output = malloc(sizeof(dll_t)); - if (output == NULL) - return NULL; - output->next = NULL; - output->prev = NULL; - return output; -} - -void dllsetdata(dll_t *node, void *data){ - node->data = malloc(sizeof(data)); - memcpy(node->data, data, sizeof(data)); -} - -void dllsetnext(dll_t *node, dll_t *next){ - if (node->next == NULL) { - node->next = next; - node->next->prev = node; - } - else - dllsetnext(node->next, next); -} -void dllsetprev(dll_t *node, dll_t *prev){ - if (node->prev == NULL) { - node->prev = prev; - node->prev->next = node; - } - else - dllsetprev(node->prev, prev); -} - -void *dllgetat(dll_t *head, int index){ - if (index == 0) - return head->data; - else { - if (head->next != NULL) { - return dllgetat(head->next, index - 1); - }else { - return NULL; - } - } -} - -void dllfreeall(dll_t *head){ - if (head->next != NULL) - dllfreeall(head->next); - free(head->data); - free(head); -} - diff --git a/comp/cw/code/tokenizer/ads/dll/dll.h b/comp/cw/code/tokenizer/ads/dll/dll.h deleted file mode 100644 index 44940ce..0000000 --- a/comp/cw/code/tokenizer/ads/dll/dll.h +++ /dev/null @@ -1,19 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -typedef struct dll_t dll_t; - -typedef struct dll_t { - void *data; - dll_t *next; - dll_t *prev; -} dll_t; - -dll_t *dllalloc(); -void dllsetdata(dll_t *node, void *data); -void dllsetnext(dll_t *node, dll_t *next); -void dllsetprev(dll_t *node, dll_t *prev); -void *dllgetat(dll_t *head, int index); -void dllfreeall(dll_t *head); - diff --git a/comp/cw/code/tokenizer/ads/dll/dll.o b/comp/cw/code/tokenizer/ads/dll/dll.o Binary files differdeleted file mode 100644 index 2c9a145..0000000 --- a/comp/cw/code/tokenizer/ads/dll/dll.o +++ /dev/null diff --git a/comp/cw/code/tokenizer/ads/dll/dlltest b/comp/cw/code/tokenizer/ads/dll/dlltest Binary files differdeleted file mode 100755 index 83f900c..0000000 --- a/comp/cw/code/tokenizer/ads/dll/dlltest +++ /dev/null diff --git a/comp/cw/code/tokenizer/ads/dll/dlltest.c b/comp/cw/code/tokenizer/ads/dll/dlltest.c deleted file mode 100644 index 4544d2e..0000000 --- a/comp/cw/code/tokenizer/ads/dll/dlltest.c +++ /dev/null @@ -1,20 +0,0 @@ -#include <stdio.h> - -#include "dll.h" - -int main(){ - dll_t *head = dllalloc(); - dllsetdata(head, "hello"); - - for (int i = 0; i < 3; i++){ - dll_t *node = dllalloc(); - dllsetdata(node, "hi"); - dllsetnext(head, node); - } - - for (int i = 0; i < 4; i++) - printf("%s\n", (char *)dllgetat(head, i)); - printf("%s\n", (char *)head->prev->next->data); - - dllfreeall(head); -} diff --git a/comp/cw/code/tokenizer/ads/ll/Makefile b/comp/cw/code/tokenizer/ads/ll/Makefile deleted file mode 100644 index aaf0241..0000000 --- a/comp/cw/code/tokenizer/ads/ll/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -all: ll.c - cc ll.c -c -o ll.o - -test: all - cc ll.o lltest.c -o lltest diff --git a/comp/cw/code/tokenizer/ads/ll/ll.c b/comp/cw/code/tokenizer/ads/ll/ll.c deleted file mode 100644 index c45ab0c..0000000 --- a/comp/cw/code/tokenizer/ads/ll/ll.c +++ /dev/null @@ -1,50 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -typedef struct ll_t ll_t; - -typedef struct ll_t { - void *data; - ll_t *next; -} ll_t; - -ll_t *llalloc(){ - ll_t *output = malloc(sizeof(ll_t)); - if (output == NULL) - return NULL; - output->next = NULL; - return output; -} - -void llsetdata(ll_t *node, void *data){ - node->data = malloc(sizeof(data)); - memcpy(node->data, data, sizeof(data)); -} - -void llsetnext(ll_t *node, ll_t *next){ - if (node->next == NULL) - node->next = next; - else - llsetnext(node->next, next); -} - -void *llgetat(ll_t *head, int index){ - if (index == 0) - return head->data; - else { - if (head->next != NULL) { - return llgetat(head->next, index - 1); - }else { - return NULL; - } - } -} - -void llfreeall(ll_t *head){ - if (head->next != NULL) - llfreeall(head->next); - free(head->data); - free(head); -} - diff --git a/comp/cw/code/tokenizer/ads/ll/ll.h b/comp/cw/code/tokenizer/ads/ll/ll.h deleted file mode 100644 index 30830b1..0000000 --- a/comp/cw/code/tokenizer/ads/ll/ll.h +++ /dev/null @@ -1,15 +0,0 @@ -#include <stdlib.h> -#include <string.h> - -typedef struct ll_t ll_t; - -typedef struct ll_t { - void *data; - ll_t *next; -} ll_t; - -ll_t *llalloc(); -void llsetdata(ll_t *node, void *data); -void llsetnext(ll_t *node, ll_t *next); -void *llgetat(ll_t *head, int index); -void llfreeall(ll_t *head); diff --git a/comp/cw/code/tokenizer/ads/ll/ll.o b/comp/cw/code/tokenizer/ads/ll/ll.o Binary files differdeleted file mode 100644 index b033278..0000000 --- a/comp/cw/code/tokenizer/ads/ll/ll.o +++ /dev/null diff --git a/comp/cw/code/tokenizer/ads/ll/lltest b/comp/cw/code/tokenizer/ads/ll/lltest Binary files differdeleted file mode 100755 index b98c5de..0000000 --- a/comp/cw/code/tokenizer/ads/ll/lltest +++ /dev/null diff --git a/comp/cw/code/tokenizer/ads/ll/lltest.c b/comp/cw/code/tokenizer/ads/ll/lltest.c deleted file mode 100644 index 8aa6514..0000000 --- a/comp/cw/code/tokenizer/ads/ll/lltest.c +++ /dev/null @@ -1,18 +0,0 @@ -#include <stdio.h> - -#include "ll.h" - -int main(){ - ll_t *head = llalloc(); - llsetdata(head, "hello"); - - for (int i = 0; i < 3; i++){ - ll_t *node = llalloc(); - llsetdata(node, "hi"); - llsetnext(head, node); - } - for (int i = 0; i < 4; i++) - printf("%s\n", (char *)llgetat(head, i)); - - llfreeall(head); -} |