-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathlexer.h
More file actions
46 lines (39 loc) · 846 Bytes
/
lexer.h
File metadata and controls
46 lines (39 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef LEXER_H_
#define LEXER_H_
#include <stddef.h>
#include "./la.h"
#include "./free_glyph.h"
typedef enum {
TOKEN_END = 0,
TOKEN_INVALID,
TOKEN_TAB,
TOKEN_PREPROC,
TOKEN_SYMBOL,
TOKEN_OPEN_PAREN,
TOKEN_CLOSE_PAREN,
TOKEN_OPEN_CURLY,
TOKEN_CLOSE_CURLY,
TOKEN_SEMICOLON,
TOKEN_KEYWORD,
TOKEN_COMMENT,
TOKEN_STRING,
} Token_Kind;
const char *token_kind_name(Token_Kind kind);
typedef struct {
Token_Kind kind;
const char *text;
size_t text_len;
Vec2f position;
} Token;
typedef struct {
Free_Glyph_Atlas *atlas;
const char *content;
size_t content_len;
size_t cursor;
size_t line;
size_t bol;
float x;
} Lexer;
Lexer lexer_new(Free_Glyph_Atlas *atlas, const char *content, size_t content_len);
Token lexer_next(Lexer *l);
#endif // LEXER_H_