-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathgareplxx.h
More file actions
43 lines (31 loc) · 1.22 KB
/
gareplxx.h
File metadata and controls
43 lines (31 loc) · 1.22 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
#ifndef GAREPLXX_H
#define GAREPLXX_H
/* Previously, we used GNU Readline on unix and a simple scanf()
* loop on Windows. This was less than optimal, as all development
* is done on unix and the Windows REPL frequently fell out of parity.
*
* The new method is the replxx library, which provides readline-like
* features in a portable way.
*
* https://github.com/AmokHuginnsson/replxx
*/
class GoodASM;
#include <replxx.hxx>
int gareplxx_encode(GoodASM *goodasm);
// FIXME: Replace this separator with one from the real parser.
char const Ifs[]{ " \t\n\r\v\f=+*&^%$#@,/?<>;:`~'\"[]{}()|" };
class GAReplXX : public replxx::Replxx {
public:
using Command = std::function<void(GAReplXX& rxx, const std::string& arg)>;
GAReplXX(GoodASM *goodasm, const std::string& historyFile = "");
void start();
private:
GoodASM *goodasm=0;
using CommandWithResult = std::function<bool(GAReplXX& cli, const std::string& arg)>;
std::string historyFile;
std::string prompt{ "goodasm> " };
std::vector<std::pair<std::string, CommandWithResult>> commands;
Replxx::completions_t CompleteContext(const std::string& line, int& lastWordLength);
std::vector<std::string> Matches(const std::string& line);
};
#endif