Reworked the tokens to include a broad class to make parameter matching a bit easier, and removed the hexadecimal distinction.
This commit is contained in:
+5
-11
@@ -7,29 +7,23 @@
|
||||
#define OPCODECOUNT 10
|
||||
#define REGISTERCOUNT 8
|
||||
|
||||
typedef enum {
|
||||
None = 0,
|
||||
Reg,
|
||||
Imm8,
|
||||
Imm16
|
||||
} ParameterType;
|
||||
|
||||
typedef struct {
|
||||
char* lexeme;
|
||||
TokenType op;
|
||||
ParameterType parameter_one;
|
||||
ParameterType parameter_two;
|
||||
} OpCode;
|
||||
TokenClass parameter_one;
|
||||
TokenClass parameter_two;
|
||||
} Instruction;
|
||||
|
||||
typedef struct {
|
||||
char* lexeme;
|
||||
TokenType type;
|
||||
} Register;
|
||||
|
||||
extern OpCode opcodes[OPCODECOUNT];
|
||||
extern Instruction instructions[OPCODECOUNT];
|
||||
extern Register registers[REGISTERCOUNT];
|
||||
|
||||
int IsOpcode(const char*, TokenType*);
|
||||
int IsRegister(const char*, TokenType*);
|
||||
const Instruction* GetOpcodeDetails(TokenType);
|
||||
|
||||
#endif
|
||||
+8
-1
@@ -21,7 +21,6 @@ typedef enum {
|
||||
IDENTIFIER,
|
||||
LABEL,
|
||||
NUMBER,
|
||||
HEX,
|
||||
//Keywords
|
||||
DB, ORG,
|
||||
//Opcodes
|
||||
@@ -31,11 +30,19 @@ typedef enum {
|
||||
R1, R2, R3, R4, R5, R6, R7, R8
|
||||
} TokenType;
|
||||
|
||||
typedef enum {
|
||||
None,
|
||||
Reg,
|
||||
Immediate16,
|
||||
Opcode
|
||||
} TokenClass;
|
||||
|
||||
typedef struct {
|
||||
TokenType type;
|
||||
char* lexeme;
|
||||
void* value;
|
||||
int line;
|
||||
TokenClass token_class;
|
||||
} Token;
|
||||
|
||||
Token* CreateToken(char*, void*, int, TokenType);
|
||||
|
||||
Reference in New Issue
Block a user