Initial commit

This commit is contained in:
2025-11-23 13:37:08 +11:00
commit d1711accde
10 changed files with 499 additions and 0 deletions

32
src/parser.c Normal file
View File

@@ -0,0 +1,32 @@
#include "parser.h"
#include "types.h"
#include "lexer.h"
#include <stdio.h>
GroundProgram createGroundProgram() {
GroundProgram gp;
gp.size = 0;
return gp;
}
void addInstructionToProgram(GroundProgram* gp, GroundInstruction instruction) {
gp->size++;
GroundInstruction* ptr = realloc(gp->instructions, gp->size * sizeof(GroundInstruction));
if (ptr == NULL) {
perror("Couldn't allocate memory for instruction");
exit(1);
}
gp->instructions = ptr;
gp->instructions[gp->size - 1] = instruction;
}
void freeGroundProgram(GroundProgram* gp) {
for (int i = 0; i < gp->size; i++) {
freeGroundInstruction(&gp->instructions[i]);
}
}
GroundProgram parseFile(LexedFile file) {
GroundProgram gp;
return gp;
}