rename parser funcs for clarity

This commit is contained in:
EDiasAlberto 2024-06-03 23:09:40 +01:00
parent 036e163fe8
commit cadac4e1bb

View File

@ -8,13 +8,13 @@
//input as an a64 instruction //input as an a64 instruction
//TODO: //TODO:
// - use string matching to get opcode, and operands // - use string matching to get opcode, and operands (DONE)
// - check operand count // - check operand count (DONE)
// - match opcode to a64 struct types // - match opcode to a64 struct types
// - count operands and match type/values // - count operands and match type/values
// - generate final a64inst and return // - generate final a64inst and return
char *splitOperands(char* str, int operandCount, char *operands[]){ char *tokeniseOperands(char* str, int operandCount, char *operands[]){
char *operandsDupe = strdup(str); char *operandsDupe = strdup(str);
int operandCount = 0; int operandCount = 0;
char *operand = strtok(operandsDupe, OPERAND_DELIMITER); char *operand = strtok(operandsDupe, OPERAND_DELIMITER);
@ -29,7 +29,7 @@ char *splitOperands(char* str, int operandCount, char *operands[]){
} }
a64inst_instruction *tokeniser(char asmLine[]){ a64inst_instruction *parser(char asmLine[]){
a64inst_instruction *instr = malloc(sizeof(a64inst_instruction)); a64inst_instruction *instr = malloc(sizeof(a64inst_instruction));
if (instr == NULL){ if (instr == NULL){
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -49,8 +49,11 @@ a64inst_instruction *tokeniser(char asmLine[]){
//type is instruction //type is instruction
int operandCount = 0; int operandCount = 0;
const char *operandList[4]; const char *operandList[4];
splitOperands(operands, &operandCount, operandList); tokeniseOperands(operands, &operandCount, operandList);
} }
} return(a64inst_instruction);
}