summaryrefslogtreecommitdiff
path: root/comp/lucas-standen-NEA/code/global
diff options
context:
space:
mode:
authorthing1 <thing1@seacrossedlovers.xyz>2024-07-09 15:40:55 +0100
committerthing1 <thing1@seacrossedlovers.xyz>2024-07-09 15:40:55 +0100
commitb6cf209e65721c9b749124e6c5866b9359fc6583 (patch)
tree6426e7481f864b3a1d72c0bc21e4c89df6e9463e /comp/lucas-standen-NEA/code/global
parent3f23b452f8ab504a3337f88ddc714c3a660d2648 (diff)
made alot work with vars
Diffstat (limited to 'comp/lucas-standen-NEA/code/global')
-rw-r--r--comp/lucas-standen-NEA/code/global/types.h6
-rw-r--r--comp/lucas-standen-NEA/code/global/util.c11
2 files changed, 12 insertions, 5 deletions
diff --git a/comp/lucas-standen-NEA/code/global/types.h b/comp/lucas-standen-NEA/code/global/types.h
index 67c4a58..885c780 100644
--- a/comp/lucas-standen-NEA/code/global/types.h
+++ b/comp/lucas-standen-NEA/code/global/types.h
@@ -60,6 +60,12 @@ typedef union literal {
Vdef *vdef;
} literal;
+typedef struct var {
+ literal *value;
+ types type;
+ char *id;
+} var;
+
// built in functions
typedef enum builtInFuncs {
// general
diff --git a/comp/lucas-standen-NEA/code/global/util.c b/comp/lucas-standen-NEA/code/global/util.c
index a29bbbc..5f41dbc 100644
--- a/comp/lucas-standen-NEA/code/global/util.c
+++ b/comp/lucas-standen-NEA/code/global/util.c
@@ -17,8 +17,8 @@ literal *giveType(char *tok);
void Die(){
- perror("zpy parser");
- exit(errno);
+ fprintf(stderr, "error occured, bringing down the program\n");
+ exit(1);
}
void *CheckedMalloc(long size){
@@ -103,7 +103,10 @@ Vdef *isVdef(char *str){
if (strchr(str, ':') != NULL){
Vdef *out = CheckedMalloc(sizeof(Vdef));
char *type;
- type = strtok(str, ":");
+
+ out->id = strtok(str, ":");
+
+ type = strtok(NULL, ":");
if (strcmp(type, "i64") == 0) out->type = TI64;
else if (strcmp(type, "i32") == 0) out->type = TI32;
else if (strcmp(type, "u64") == 0) out->type = TU64;
@@ -117,7 +120,6 @@ Vdef *isVdef(char *str){
Die();
}
- out->id = strtok(NULL, ":");
return out;
}
return NULL;
@@ -143,7 +145,6 @@ literal *giveType(char *tok){
out->vdef = vdef;
} else {
fprintf(stderr, "data %s could not be typed\n", tok);
- errno = 22;
Die();
}
return out;