Fixed up annotation printing. Added help command to eval
This commit is contained in:
parent
0f5ff57a46
commit
57aeacab2e
@ -2,6 +2,13 @@
|
||||
|
||||
#include "chaiscript.hpp"
|
||||
|
||||
void print_help() {
|
||||
std::cout << "ChaiScript evaluator. To evaluate and expression, type it and press <enter>." << std::endl;
|
||||
std::cout << "Additionally, you can inspect the runtime system using:" << std::endl;
|
||||
std::cout << " dump_system() - outputs all functions registered to the system" << std::endl;
|
||||
std::cout << " dump_object(x) - dumps information about the given symbol" << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
std::string input;
|
||||
|
||||
@ -15,6 +22,10 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
dispatchkit::Boxed_Value val;
|
||||
|
||||
if (input == "help") {
|
||||
print_help();
|
||||
}
|
||||
else {
|
||||
val = chai.evaluate_string(input);
|
||||
|
||||
if (val.get_type_info().m_bare_type_info && *(val.get_type_info().m_bare_type_info) != typeid(void)) {
|
||||
@ -22,10 +33,12 @@ int main(int argc, char *argv[]) {
|
||||
try {
|
||||
dispatchkit::dispatch(chai.get_eval_engine().get_function("print"), dispatchkit::Param_List_Builder() << val);
|
||||
} catch (const std::runtime_error &e) {
|
||||
//do nothing for the time being
|
||||
std::cout << e.what() << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "eval> ";
|
||||
std::getline(std::cin, input);
|
||||
}
|
||||
|
@ -289,9 +289,7 @@ namespace dispatchkit
|
||||
std::string annotation = f.second->annotation();
|
||||
|
||||
if (annotation.size() > 0) {
|
||||
std::cout << "##############" << std::endl;
|
||||
std::cout << annotation;
|
||||
std::cout << "##############" << std::endl;
|
||||
}
|
||||
dump_type(params.front(), e);
|
||||
std::cout << " " << f.first << "(";
|
||||
|
Loading…
x
Reference in New Issue
Block a user