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