mpw-shell/phase2.h

45 lines
618 B
C
Raw Normal View History

2016-01-29 22:23:14 -05: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 12:44:42 -05:00
phase2() = default;
2016-01-30 12:44:42 -05:00
void parse(std::string &&);
2016-01-29 22:23:14 -05:00
void finish();
void reset();
void abort() { reset(); }
2016-01-29 22:23:14 -05:00
bool continuation() const { return false; }
2016-01-31 00:41:02 -05:00
void set_next(next_function_type &&fx) { _then = std::move(fx); }
2016-02-05 12:42:22 -05:00
2016-01-29 22:23:14 -05:00
private:
void parse(int type, std::string &&s);
2016-01-30 12:44:42 -05:00
2016-01-29 22:23:14 -05:00
std::string scratch;
int type = 0;
int pcount = 0;
2016-01-29 22:23:14 -05:00
void flush();
bool special();
int classify();
2016-01-29 22:23:14 -05:00
void exec();
next_function_type _then;
2016-01-29 22:23:14 -05:00
};
2016-01-30 12:44:42 -05:00
2016-01-29 22:23:14 -05:00
#endif