diff options
author | standenboy <standenboy@seacrossedlovers.xyz> | 2024-04-30 14:22:45 +0100 |
---|---|---|
committer | standenboy <standenboy@seacrossedlovers.xyz> | 2024-04-30 14:22:45 +0100 |
commit | c460a26850eca5ded047d0eb0d183b861087aa53 (patch) | |
tree | 000c4a117746de71870fbee820809f7df49bcfcf /comp/cw/code/parser | |
parent | 2e239a4ed2265f7c7dc2aabedfdb7d7b011704cb (diff) |
write up update
Diffstat (limited to 'comp/cw/code/parser')
-rw-r--r-- | comp/cw/code/parser/Makefile | 12 | ||||
-rwxr-xr-x | comp/cw/code/parser/parser | bin | 20880 -> 0 bytes | |||
-rw-r--r-- | comp/cw/code/parser/parser.c | 32 | ||||
-rw-r--r-- | comp/cw/code/parser/parser.o | bin | 2256 -> 0 bytes | |||
-rw-r--r-- | comp/cw/code/parser/preprocessor.c | 24 | ||||
-rw-r--r-- | comp/cw/code/parser/preprocessor.h | 5 | ||||
-rw-r--r-- | comp/cw/code/parser/preprocessor.o | bin | 1504 -> 0 bytes | |||
-rw-r--r-- | comp/cw/code/parser/readfile.c | 61 | ||||
-rw-r--r-- | comp/cw/code/parser/readfile.h | 1 | ||||
-rw-r--r-- | comp/cw/code/parser/readfile.o | bin | 2208 -> 0 bytes | |||
-rw-r--r-- | comp/cw/code/parser/sample.zpy | 15 |
11 files changed, 0 insertions, 150 deletions
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!") |