-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathphase1.h
More file actions
40 lines (25 loc) · 740 Bytes
/
phase1.h
File metadata and controls
40 lines (25 loc) · 740 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
32
33
34
35
36
37
38
39
40
#ifndef __phase1_h__
#define __phase1_h__
#include <string>
#include <functional>
class phase1 {
public:
typedef std::function<void(std::string &&)> next_function_type;
phase1() = default;
void parse(const unsigned char *begin, const unsigned char *end);
void parse(const std::string &s) { parse((const unsigned char *)s.data(), (const unsigned char *)s.data() + s.size()); }
void finish();
void reset();
void abort() { reset(); }
bool continuation() const { return multiline; }
void set_next(next_function_type &&fx) { _then = std::move(fx); }
private:
int process(unsigned char, int);
void flush();
std::string scratch;
int line = 1;
int cs = 0;
bool multiline = false;
next_function_type _then;
};
#endif