diff --git a/src/parser.c b/src/parser.c index 1d7c2cd..1c30fc3 100644 --- a/src/parser.c +++ b/src/parser.c @@ -8,13 +8,13 @@ //input as an a64 instruction //TODO: -// - use string matching to get opcode, and operands -// - check operand count +// - use string matching to get opcode, and operands (DONE) +// - check operand count (DONE) // - match opcode to a64 struct types // - count operands and match type/values // - 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); int operandCount = 0; 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)); if (instr == NULL){ exit(EXIT_FAILURE); @@ -49,8 +49,11 @@ a64inst_instruction *tokeniser(char asmLine[]){ //type is instruction int operandCount = 0; const char *operandList[4]; - splitOperands(operands, &operandCount, operandList); + tokeniseOperands(operands, &operandCount, operandList); } -} \ No newline at end of file + return(a64inst_instruction); + +} +