Added lists of tokens and keywords, ready for use

This commit is contained in:
2024-05-20 02:35:19 +10:00
parent 607dc2c22a
commit 0b8bf4119f
9 changed files with 223 additions and 4 deletions

25
source/toy_lexer.h Normal file
View File

@@ -0,0 +1,25 @@
#pragma once
#include "toy_token_types.h"
#include "toy_common.h"
//lexers are bound to a string of code
typedef struct {
int start; //start of the current token
int current; //current position of the lexer
int line; //track this for error handling
const char* source;
} Toy_Lexer;
//tokens are intermediaries between lexers and parsers
typedef struct {
Toy_TokenType type;
int length;
int line;
const char* lexeme;
} Toy_Token;
TOY_API void Toy_bindLexer(Toy_Lexer* lexer, const char* source);
TOY_API Toy_Token Toy_private_scanLexer(Toy_Lexer* lexer);
TOY_API void Toy_private_printToken(Toy_Token* token);