mpw-shell/phase2.h

45 lines
618 B
C
Raw Normal View History

2016-01-30 03:23:14 +00:00
#ifndef __phase2_h__
#define __phase2_h__
#include <string>
#include <functional>
class phase2 {
public:
typedef std::function<void(int, std::string &&)> next_function_type;
2016-01-30 17:44:42 +00:00
phase2() = default;
2016-01-30 17:44:42 +00:00
void parse(std::string &&);
2016-01-30 03:23:14 +00:00
void finish();
void reset();
void abort() { reset(); }
2016-01-30 03:23:14 +00:00
bool continuation() const { return false; }
2016-01-31 05:41:02 +00:00
void set_next(next_function_type &&fx) { _then = std::move(fx); }
2016-02-05 17:42:22 +00:00
2016-01-30 03:23:14 +00:00
private:
void parse(int type, std::string &&s);
2016-01-30 17:44:42 +00:00
2016-01-30 03:23:14 +00:00
std::string scratch;
int type = 0;
int pcount = 0;
2016-01-30 03:23:14 +00:00
void flush();
bool special();
int classify();
2016-01-30 03:23:14 +00:00
void exec();
next_function_type _then;
2016-01-30 03:23:14 +00:00
};
2016-01-30 17:44:42 +00:00
2016-01-30 03:23:14 +00:00
#endif