-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.hpp
More file actions
49 lines (40 loc) · 1.09 KB
/
parser.hpp
File metadata and controls
49 lines (40 loc) · 1.09 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
#pragma once
#include <iostream>
#include <stddef.h>
#include <string_view>
#include <vector>
namespace parser {
enum class STATE { NORMAL, UTF8, ESCAPE, CSI, OSI, CHARSET };
class VTParser {
std::string command;
STATE state;
public:
VTParser();
virtual ~VTParser() {}
void parse_input(const char *input, size_t length);
void parse_input(char c);
void dispatch_osi(const char *input, size_t length);
void dispatch_csi(const char *input, size_t length);
void dispatch_esc(char op);
public:
virtual void on_glyph(const char *glyph, size_t length) {
(void)glyph;
(void)length;
}
virtual void on_newline(){}
virtual void on_return(){}
virtual void on_tab(){}
virtual void on_backspace(){}
virtual void on_bell(){}
virtual void on_charset(char c) { (void)c; }
virtual void on_csi(char op, const std::vector<int> &args,
std::string_view options) {
(void)op;
(void)args;
(void)options;
}
virtual void on_ri(){}
virtual void on_esc(char op){ (void)op; }
virtual void on_osi(int, std::string_view) = 0;
};
} // namespace parser