skopy/lib/include/lexer.h

31 lines
528 B
C
Raw Normal View History

2024-03-31 21:10:56 +00:00
#ifndef SK_LEXER_H
#define SK_LEXER_H
#include "commons.h"
#include "token.h"
struct context
{
int line;
size_t cursor;
};
struct lexer
{
char* source;
size_t len;
struct context context;
};
void lexer_init(struct lexer* self, char const* source);
void lexer_free(struct lexer* self);
void lexer_skip_spaces(struct lexer* self);
bool lexer_next_is(struct lexer* self, TokenKind kind);
struct token* lexer_try_new_next(struct lexer* self);
struct token* lexer_try_scan_int(struct lexer* self);
#endif