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:
2025-06-26 23:24:03 -05:00
parent 3a5788f4ab
commit 428556a7a1
9 changed files with 141 additions and 63 deletions
+21 -1
View File
@@ -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
+1
View File
@@ -16,6 +16,7 @@ typedef enum {
Register,
Mnemonic,
Keyword,
Label,
LineEnd = '\n',
Colon = ':',
Comma = ',',
+1 -1
View File
@@ -5,6 +5,6 @@
#include "dictionary.h"
#include "token.h"
Array* Tokenize(const char* text, Dictionary** variables);
Array* Tokenize(const char* text);
#endif