-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtokenizer.h
More file actions
62 lines (55 loc) · 1.35 KB
/
Copy pathtokenizer.h
File metadata and controls
62 lines (55 loc) · 1.35 KB
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
53
54
55
56
57
58
59
60
61
62
#ifndef TOKENIZER_H
#define TOKENIZER_H
#include "..\constants\constants.h"
#include "..\inter\interactive.h"
#include <string>
#include <sstream>
#include <vector>
#include <fstream>
#include<iostream>
struct Token{
std::string data;
int type;
int lineno;
int columnno;
int indentLevel;
std::string file_path;
std::string to_string(){
std::stringstream s;
s << "[{" << indentLevel << "}(" << getTypeStringforType(type) << ") " << data << "]";
return s.str();
}
};
class CTokenizer {
private:
std::string file_path;
Mediator* md;
bool interactive;
int currentIndentLevel;
int line_counter;
int column_counter;
std::string cline; // Current Line
std::vector<Token> tokens;
std::ifstream opened_file;
int columnlimit;
public:
CTokenizer(std::string name, Mediator* md);
CTokenizer(std::string _file_path);
void tokenize();
std::string string_list(bool addHiddedTokens);
std::vector<Token> get_tokens();
~CTokenizer();
private:
bool load_next_line();
void _tokenize();
void parseInteger();
void tryParseIdentifier();
void parseStringLiteral();
void parseMultilineComment();
void parseComment();
void addToken(int type, std::string data);
void push_and_clear(std::string& collection);
Token create_token(std::string data);
};
std::vector<Token> tokenizer_Main(std::string file_path);
#endif // TOKENIZER_H