-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathheader.h
More file actions
69 lines (55 loc) · 1.46 KB
/
header.h
File metadata and controls
69 lines (55 loc) · 1.46 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
63
64
65
66
67
68
#ifndef AWK_PARSER_H
#define AWK_PARSER_H
#include <fstream>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>
enum class Operation {
AND,
OR,
NONE
};
// Should take a string lhs, and some template type of RHS, and compare them
// For example, if T is an int, and the string is "5", then check if rhs == 5
template <typename T>
bool compare_op(const std::string &lhs, const T &rhs, const std::string &op) {
std::stringstream ss(lhs);
}
class FileParser {
public:
FileParser(std::string &&filename, char delimiter = ' ');
const std::vector<std::vector<std::string>> &get_parsed() const;
private:
std::vector<std::vector<std::string>> parsed;
};
class PatternParser {
public:
PatternParser(const std::string &str);
bool check_pattern(const std::vector<std::string> &tokens, int row_num);
const std::vector<std::string> &get_pattern() const;
private:
std::vector<std::string> vect_patterns;
Operation op_type = Operation::AND;
};
class Stmt {
public:
virtual void run(const std::vector<std::string> &tokens) = 0;
};
class PrintStmt : public Stmt {
public:
PrintStmt(std::string::const_iterator &it, const std::string &input);
void run(const std::vector<std::string> &tokens);
private:
std::vector<int> fields;
};
class ActionParser {
public:
ActionParser(const std::string &input);
void run(const std::vector<std::string> &tokens);
private:
std::vector<Stmt *> stmts;
};
#endif