codebased/scirpt/lexer.h
2023-04-12 01:59:42 +02:00

32 lines
795 B
C

#ifndef LEXER_H
#define LEXER_H
#include "scirpt/lexer.h"
#include "scirpt/token.h"
#include "utils/stringmap.h"
#include <stdbool.h>
#include <stddef.h>
struct ScirptLexer {
const char* text;
size_t text_length;
size_t index;
int line, col;
StringMap* keywords;
};
void scirpt_lexer_create(
ScirptLexer* lexer, const char* text, size_t text_length
);
void scirpt_lexer_destroy(ScirptLexer* lexer);
void scirpt_lexer_step(ScirptLexer* lexer);
ScirptPosition scirpt_lexer_pos(const ScirptLexer* lexer);
ScirptToken scirpt_lexer_token(
const ScirptLexer* lexer, ScirptTokenType type, ScirptPosition start
);
bool scirpt_lexer_current_is(const ScirptLexer* lexer, char value);
bool scirpt_lexer_done(const ScirptLexer* lexer);
char scirpt_lexer_current(const ScirptLexer* lexer);
#endif