Attempting to declutter the lexer and tokenizer by rereolling them into the 'Scanner' object.

This commit is contained in:
2022-05-03 21:20:38 +00:00
parent 1900b504e7
commit 2c9478d311
4 changed files with 207 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
#ifndef SCANNER_H
#define SCANNER_H
#include <stdio.h>
#include <string.h>
#include "stdlib.h"
#include "token.h"
#include "list.h"
List* GenerateTokenList(const char*);
#endif
+38
View File
@@ -0,0 +1,38 @@
#ifndef TOKEN_H
#define TOKEN_H
#include "stdlib.h"
typedef enum {
PLUS,
MINUS,
STAR,
SLASH,
POWER,
LPARAM,
RPARAM,
LBRACKET,
RBracket,
COMMA,
STRING,
IDENTIFIER,
NUMBER,
HEX,
//Keywords
DB, ORG,
//Opcodes
COPY, ADD, SUB, JZ, INT, YLD, RET,
CMP, IN, OUT,
//Registers
R1, R2, R3, R4, R5, R6, R7, R8
} TokenType;
typedef struct {
TokenType type;
char* value;
} Token;
Token* CreateToken(TokenType type, char* value);
void FreeToken(Token*);
#endif