From cfdd3c90877b59dc674cc9f68c0b7b4bb7c14ba8 Mon Sep 17 00:00:00 2001 From: Thing1 Date: Tue, 27 Aug 2024 10:36:18 +0100 Subject: rewrite --- comp/lucas-standen-NEA/code/execution/exec | Bin 42120 -> 37792 bytes comp/lucas-standen-NEA/code/proto/AST/ast | Bin 24200 -> 19888 bytes comp/lucas-standen-NEA/code/proto/parser/test | Bin 29728 -> 25464 bytes comp/lucas-standen-NEA/code/tokenizer/parser.c | 5 +++-- comp/lucas-standen-NEA/code/zpy/zpy | Bin 30432 -> 30272 bytes 5 files changed, 3 insertions(+), 2 deletions(-) (limited to 'comp/lucas-standen-NEA/code') diff --git a/comp/lucas-standen-NEA/code/execution/exec b/comp/lucas-standen-NEA/code/execution/exec index de1cd68..d69d951 100755 Binary files a/comp/lucas-standen-NEA/code/execution/exec and b/comp/lucas-standen-NEA/code/execution/exec differ diff --git a/comp/lucas-standen-NEA/code/proto/AST/ast b/comp/lucas-standen-NEA/code/proto/AST/ast index 69ccc93..be44ef5 100755 Binary files a/comp/lucas-standen-NEA/code/proto/AST/ast and b/comp/lucas-standen-NEA/code/proto/AST/ast differ diff --git a/comp/lucas-standen-NEA/code/proto/parser/test b/comp/lucas-standen-NEA/code/proto/parser/test index 6989562..6945399 100755 Binary files a/comp/lucas-standen-NEA/code/proto/parser/test and b/comp/lucas-standen-NEA/code/proto/parser/test differ diff --git a/comp/lucas-standen-NEA/code/tokenizer/parser.c b/comp/lucas-standen-NEA/code/tokenizer/parser.c index 78ba919..b2c3657 100644 --- a/comp/lucas-standen-NEA/code/tokenizer/parser.c +++ b/comp/lucas-standen-NEA/code/tokenizer/parser.c @@ -57,7 +57,7 @@ FILE *preProcess(char *contents){ } char **getExpressions(char *file){ // this doesn't work because str gets overwritten which changes the data stored at it's pointer, memcpy should be used - char **code = CheckedMalloc((strlen(file)/2)*sizeof(char *)); + char **code = CheckedMalloc(strlen(file)/4); int counter = 0; int depth = 0; char *str = CheckedMalloc(strlen(file)+1); @@ -73,7 +73,8 @@ char **getExpressions(char *file){ // this doesn't work because str gets overwri if (depth == 0) { str[pos] = '\0'; printf("%s\n", str); - code[counter] = str; + code[counter] = malloc(strlen(str)+1); + memcpy(code[counter], str, strlen((str)+1)); counter++; pos = 0; } diff --git a/comp/lucas-standen-NEA/code/zpy/zpy b/comp/lucas-standen-NEA/code/zpy/zpy index f3a466f..53c09ad 100755 Binary files a/comp/lucas-standen-NEA/code/zpy/zpy and b/comp/lucas-standen-NEA/code/zpy/zpy differ -- cgit v1.2.3