forked from jckarter/clay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lexer.hpp
51 lines (41 loc) · 919 Bytes
/
lexer.hpp
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
47
48
49
50
51
#pragma once
#include "clay.hpp"
namespace clay {
//
// Token
//
enum TokenKind {
T_NONE,
T_UOPSTRING,
T_OPSTRING,
T_SYMBOL,
T_KEYWORD,
T_IDENTIFIER,
T_OPIDENTIFIER,
T_STRING_LITERAL,
T_CHAR_LITERAL,
T_INT_LITERAL,
T_FLOAT_LITERAL,
T_STATIC_INDEX,
T_SPACE,
T_LINE_COMMENT,
T_BLOCK_COMMENT,
T_LLVM,
T_DOC_START,
T_DOC_PROPERTY,
T_DOC_TEXT,
T_DOC_END
};
struct Token {
Location location;
llvm::SmallString<16> str;
TokenKind tokenKind;
Token() : tokenKind(T_NONE) {}
explicit Token(TokenKind tokenKind) : tokenKind(tokenKind) {}
explicit Token(TokenKind tokenKind, llvm::StringRef str) : str(str), tokenKind(tokenKind) {}
};
void tokenize(SourcePtr source, vector<Token> &tokens);
void tokenize(SourcePtr source, unsigned offset, size_t length,
vector<Token> &tokens);
bool isSpace(char c);
}