Updated the parser to be able to correctly sync via a longjmp. Fixed a few bugs in the tokenizer, like not allowing underscores in symbol / label names and taught it how to detect a label declaration. Fixed the code that gets the register name.
This commit is contained in:
+21
-1
@@ -3,15 +3,35 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <setjmp.h>
|
||||
#include "dictionary.h"
|
||||
#include "opcodes.h"
|
||||
#include "token.h"
|
||||
#include "array.h"
|
||||
#include "keywords.h"
|
||||
|
||||
typedef struct _instruction Instruction;
|
||||
typedef Array Instructions;
|
||||
|
||||
typedef struct parameter {
|
||||
bool Pointer;
|
||||
TokenType Type;
|
||||
union {
|
||||
char* Name;
|
||||
Registers Register;
|
||||
uint32_t Number;
|
||||
} Value;
|
||||
} Parameter;
|
||||
|
||||
typedef struct instruction {
|
||||
bool IsOpcode;
|
||||
union {
|
||||
Mnemonics Opcode;
|
||||
Keywords Directive;
|
||||
} Inst;
|
||||
int ParameterCount;
|
||||
Parameter Parameters[2];
|
||||
} Instruction;
|
||||
|
||||
Instructions* ParseTokens(Array* tokens);
|
||||
|
||||
#endif
|
||||
@@ -16,6 +16,7 @@ typedef enum {
|
||||
Register,
|
||||
Mnemonic,
|
||||
Keyword,
|
||||
Label,
|
||||
LineEnd = '\n',
|
||||
Colon = ':',
|
||||
Comma = ',',
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
#include "dictionary.h"
|
||||
#include "token.h"
|
||||
|
||||
Array* Tokenize(const char* text, Dictionary** variables);
|
||||
Array* Tokenize(const char* text);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user