-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtokenizer.h
More file actions
31 lines (28 loc) · 718 Bytes
/
tokenizer.h
File metadata and controls
31 lines (28 loc) · 718 Bytes
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
#pragma once
#include "enums.h"
#include "hack_map.h"
#include "token.h"
#include <filesystem>
#include <fstream>
#include <memory>
#include <string>
#include <vector>
class Tokenizer {
public:
Tokenizer (std::filesystem::path, std::shared_ptr<HackMap>);
bool has_more_tokens ();
Token advance ();
Token next ();
TokenType token_type ();
private:
void tokenize ();
void trim_codeline (std::string&);
void process_word (const std::string&);
void process_value (const std::string&, bool is_string = false);
private:
std::vector<Token> tokens_vec;
std::ifstream inp_file;
bool in_comment_block, in_string;
std::shared_ptr<HackMap> hack_map;
int current = -1;
};