stuffs
This commit is contained in:
@@ -52,6 +52,8 @@ Program createProgramFromText(const char* input) {
|
||||
size_t programLen = strlen(input);
|
||||
size_t current = 0;
|
||||
|
||||
uint8_t currentInstruction = 0;
|
||||
|
||||
bool processingInstWord = true;
|
||||
uint8_t processingArgNum = 0;
|
||||
|
||||
@@ -134,6 +136,7 @@ Program createProgramFromText(const char* input) {
|
||||
fprintf(stderr, "couldn't convert %s to a number\n", buf);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
processingArgNum++;
|
||||
@@ -148,15 +151,23 @@ Program createProgramFromText(const char* input) {
|
||||
// Ignore extra new lines
|
||||
break;
|
||||
}
|
||||
addInstructionToProgram(&program, instruction);
|
||||
instruction = (Instruction){};
|
||||
processingInstWord = true;
|
||||
processingArgNum = 0;
|
||||
buf[0] = '\0';
|
||||
bufSize = 0;
|
||||
currentInstruction++;
|
||||
break;
|
||||
}
|
||||
case ':': {
|
||||
if (!processingInstWord) {
|
||||
fprintf(stderr, "label must be first word on a new line");
|
||||
fprintf(stderr, "label must be first word on a new line\n");
|
||||
exit(1);
|
||||
}
|
||||
addLabelToProgram(&program, buf, currentInstruction);
|
||||
if (input[current + 1] != '\n') {
|
||||
fprintf(stderr, "expecting new line after label\n");
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user