-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTokens.h
47 lines (36 loc) · 1.05 KB
/
Tokens.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
#pragma once
#include <iostream>
#include <vector>
#include <string>
class Tokens
{
public:
enum Type
{
NUMBER = 0, LETTER = 1, SPECIAL = 2, STRING = 3, BRACKET = 4
};
Tokens* parent = nullptr;
std::vector<Tokens*> children;
Type type;
std::string value;
size_t line = 0;
Tokens(size_t line = 0);
Tokens(Tokens& original);
~Tokens();
void loadFromFile(std::string path);
void loadFromString(std::string code);
std::string information(std::string);
bool isChildType(size_t position,Tokens::Type type);
std::string getChildValue(size_t position);
size_t size();
private:
void loadFromString(std::string& code, size_t& position);
bool loadNumber(std::string& code, size_t& position);
bool loadLetter(std::string& code, size_t& position);
bool loadSpecial(std::string& code, size_t& position);
bool loadBracket(std::string& code, size_t& position);
bool loadString(std::string& code, size_t& position);
bool loadWhite(std::string& code, size_t& position);
bool contain(char str, std::string keys);
unsigned int toHex(std::string s);
};