-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLexer.h
50 lines (39 loc) · 909 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
#pragma once
#include <cstdint>
#include <vector>
#include <string>
#include <iostream>
#include <unordered_map>
#include "Token.h"
#include "Utils.h"
class COMPUTE_DUCK_API Lexer
{
public:
public:
Lexer();
~Lexer();
const std::vector<Token> &GenerateTokens(std::string_view src, std::string_view filePath = "RootFile");
private:
void ResetStatus();
void GenerateToken();
bool IsMatchCurChar(char c);
bool IsMatchCurCharAndStepOnce(char c);
char GetCurCharAndStepOnce();
char GetCurChar();
void AddToken(TokenType type);
void AddToken(TokenType type, std::string_view literal);
bool IsAtEnd();
bool IsNumber(char c);
bool IsLetter(char c);
bool IsLetterOrNumber(char c);
void Number();
void Identifier();
void String();
uint32_t m_StartPos;
uint32_t m_CurPos;
uint32_t m_Line;
uint32_t m_Column;
std::string m_Source;
std::vector<Token> m_Tokens;
std::string m_FilePath;
};