-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLexer.h
52 lines (41 loc) · 943 Bytes
/
Lexer.h
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
52
#pragma once
#include <cstdint>
#include <vector>
#include <string>
#include <iostream>
#include <unordered_map>
#include "Token.h"
#include "Utils.h"
namespace lwscript
{
class LWSCRIPT_API Lexer
{
public:
Lexer();
~Lexer() = default;
const std::vector<Token *> &ScanTokens(STD_STRING_VIEW src);
private:
void ResetStatus();
void ScanToken();
bool IsMatchCurChar(CHAR_T c);
bool IsMatchCurCharAndStepOnce(CHAR_T c);
CHAR_T GetCurCharAndStepOnce();
CHAR_T GetCurChar();
void AddToken(TokenKind type);
void AddToken(TokenKind type, STD_STRING_VIEW literal);
bool IsAtEnd();
bool IsNumber(CHAR_T c);
bool IsLetter(CHAR_T c, bool isAscii);
bool IsLetterOrNumber(CHAR_T c, bool isAscii);
void Number();
void Identifier();
void String();
void Character();
uint64_t mStartPos;
uint64_t mCurPos;
uint64_t mLine;
uint64_t mColumn;
STD_STRING mSource;
std::vector<Token *> mTokens;
};
}