rename parser funcs for clarity
This commit is contained in:
parent
036e163fe8
commit
cadac4e1bb
15
src/parser.c
15
src/parser.c
@ -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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user