move list of builtins to ml_util.cpp
this is not final solution, just for now
This commit is contained in:
parent
6700c04159
commit
35cf6b13e5
9
ml.cpp
9
ml.cpp
|
|
@ -1830,16 +1830,7 @@ std::vector<std::string> MlEnvironment::get_lambdas_list() const {
|
||||||
lambdas.push_back(it->first);
|
lambdas.push_back(it->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::vector<std::string> commands {
|
|
||||||
"eval", "type", "parse", "do", "if", "for", "while", "scope", "quote", "defun",
|
|
||||||
"define", "lambda", "benchmark", "=", "!=", ">", "<", ">=", "<=", "+", "-", "*", "/", "%",
|
|
||||||
"list", "insert", "index", "remove", "len", "push", "pop", "head", "tail", "first", "last",
|
|
||||||
"range", "map", "filter", "reduce", "exit", "quit", "print", "input", "random", "include",
|
|
||||||
"read-file", "write-file", "read-url", "system-cmd", "ls-dir", "is-file?", "is-dir?",
|
|
||||||
"parse-csv", "parse-json", "get-universal-time", "date-to-str", "str-to-date", "date-add", "debug",
|
|
||||||
"sprintf", "display", "string-replace", "string-regex?", "string-pad", "int", "float", "string" };
|
|
||||||
|
|
||||||
lambdas.insert(end(lambdas), begin(commands), end(commands));
|
|
||||||
return lambdas;
|
return lambdas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
11
ml_util.cpp
11
ml_util.cpp
|
|
@ -4,6 +4,14 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
const std::vector<std::string> commands {
|
||||||
|
"eval", "type", "parse", "do", "if", "for", "while", "scope", "quote", "defun",
|
||||||
|
"define", "lambda", "benchmark", "=", "!=", ">", "<", ">=", "<=", "+", "-", "*", "/", "%",
|
||||||
|
"list", "insert", "index", "remove", "len", "push", "pop", "head", "tail", "first", "last",
|
||||||
|
"range", "map", "filter", "reduce", "exit", "quit", "print", "input", "random", "include",
|
||||||
|
"read-file", "write-file", "read-url", "system-cmd", "ls-dir", "is-file?", "is-dir?",
|
||||||
|
"parse-csv", "parse-json", "get-universal-time", "date-to-str", "str-to-date", "date-add", "debug",
|
||||||
|
"sprintf", "display", "string-replace", "string-regex?", "string-pad", "int", "float", "string" };
|
||||||
|
|
||||||
std::string get_history_file_dir() {
|
std::string get_history_file_dir() {
|
||||||
// TODO not portable and in function
|
// TODO not portable and in function
|
||||||
|
|
@ -58,7 +66,10 @@ void completion(const char *buf, linenoiseCompletions *lc) {
|
||||||
std::string token = str.substr(pos+1);
|
std::string token = str.substr(pos+1);
|
||||||
std::string begining = str.substr(0, pos+1);
|
std::string begining = str.substr(0, pos+1);
|
||||||
|
|
||||||
|
// TODO optimize not to get all lambdas, but those begining with token
|
||||||
std::vector<std::string> lambdas = repl_env->get_lambdas_list();
|
std::vector<std::string> lambdas = repl_env->get_lambdas_list();
|
||||||
|
lambdas.insert(end(lambdas), begin(commands), end(commands));
|
||||||
|
|
||||||
for (std::vector<std::string>::iterator t = lambdas.begin(); t != lambdas.end(); ++t) {
|
for (std::vector<std::string>::iterator t = lambdas.begin(); t != lambdas.end(); ++t) {
|
||||||
if(t->find(token) == 0) {
|
if(t->find(token) == 0) {
|
||||||
std::string completion_string = begining + *t;
|
std::string completion_string = begining + *t;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue