-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlispy.hpp
58 lines (46 loc) · 1.36 KB
/
lispy.hpp
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
50
51
52
53
54
55
56
57
58
#ifndef LISPY_HPP
#define LISPY_HPP
#include <linenoise.h>
#include <tclap/CmdLine.h>
#include "lenv.hpp"
#include "mpc.h"
#define LISPY_NO_FLAGS 0x0
#define LISPY_FLAG_INTERACTIVE 0x1
#define LISPY_FLAG_CLEAR_OUTPUT 0x2
#define LISPY_FLAG_EXIT 0x4
class lispy {
public:
lispy();
~lispy();
static lispy *instance();
int run(int argc, char *argv[]);
mpc_parser_t *parser();
uint flags;
private:
lenv env;
static lispy *_instance;
bool load_prelude();
void run_interactive();
bool process_interactive_result(lval *result);
bool load_files(const std::vector<std::string> &files);
bool eval_strings(const std::vector<std::string> &strings);
friend void completion_hook(char const *prefix, linenoiseCompletions *lc);
// Grammar parsers
mpc_parser_t *integer_parser;
mpc_parser_t *decimal_parser;
mpc_parser_t *number_parser;
mpc_parser_t *symbol_parser;
mpc_parser_t *string_parser;
mpc_parser_t *sexpr_parser;
mpc_parser_t *qexpr_parser;
mpc_parser_t *expr_parser;
mpc_parser_t *comment_parser;
mpc_parser_t *command_parser;
mpc_parser_t *lispy_parser;
// Command line arguments parsing
TCLAP::CmdLine cmd_line;
TCLAP::SwitchArg interactive_arg;
TCLAP::MultiArg<std::string> eval_args;
TCLAP::UnlabeledMultiArg<std::string> file_args;
};
#endif // LISPY_HPP