35 lines
730 B
C
35 lines
730 B
C
#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);
|
|
|
|
void lexer_consume_next(struct lexer* self);
|
|
struct token* lexer_try_new_next(struct lexer* self);
|
|
struct token* lexer_try_scan_int(struct lexer* self);
|
|
struct token* lexer_try_scan_text(struct lexer* self,
|
|
char const* text,
|
|
TokenKind kind);
|
|
|
|
#endif
|