-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtokenizer.h
45 lines (37 loc) · 1.16 KB
/
tokenizer.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
#pragma once
#include <vector>
#include <utility>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/fstream.hpp>
#include "utils/utils.h"
#include "funds.h"
std::vector< std::string > tokenize(const std::string &in);
/*
* Some notes on this Metamath parser:
* + It does not require that label tokens do not match any math token.
*/
class TokenGenerator {
public:
virtual std::pair< bool, std::string > next() = 0;
virtual ~TokenGenerator();
};
class FileTokenizer : public TokenGenerator {
public:
//FileTokenizer(const std::string &filename);
FileTokenizer(const boost::filesystem::path &filename, Reportable *reportable = NULL);
std::pair< bool, std::string > next();
~FileTokenizer();
private:
FileTokenizer(std::string filename, boost::filesystem::path base_path);
void set_file_size();
char get_char();
boost::filesystem::ifstream fin;
boost::filesystem::path base_path;
FileTokenizer *cascade;
bool white;
std::vector< char > buf;
std::pair< bool, std::string > finalize_token(bool comment);
boost::filesystem::ifstream::pos_type filesize;
size_t pos = 0;
Reportable *reportable;
};