Fixed up annotation printing. Added help command to eval

This commit is contained in:
Jonathan Turner 2009-07-09 17:02:46 +00:00
parent 0f5ff57a46
commit 57aeacab2e
2 changed files with 23 additions and 12 deletions

View File

@ -2,6 +2,13 @@
#include "chaiscript.hpp" #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[]) { int main(int argc, char *argv[]) {
std::string input; std::string input;
@ -15,6 +22,10 @@ int main(int argc, char *argv[]) {
dispatchkit::Boxed_Value val; dispatchkit::Boxed_Value val;
if (input == "help") {
print_help();
}
else {
val = chai.evaluate_string(input); val = chai.evaluate_string(input);
if (val.get_type_info().m_bare_type_info && *(val.get_type_info().m_bare_type_info) != typeid(void)) { 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 { try {
dispatchkit::dispatch(chai.get_eval_engine().get_function("print"), dispatchkit::Param_List_Builder() << val); dispatchkit::dispatch(chai.get_eval_engine().get_function("print"), dispatchkit::Param_List_Builder() << val);
} catch (const std::runtime_error &e) { } catch (const std::runtime_error &e) {
//do nothing for the time being std::cout << e.what() << std::endl;
} }
} }
}
std::cout << "eval> "; std::cout << "eval> ";
std::getline(std::cin, input); std::getline(std::cin, input);
} }

View File

@ -289,9 +289,7 @@ namespace dispatchkit
std::string annotation = f.second->annotation(); std::string annotation = f.second->annotation();
if (annotation.size() > 0) { if (annotation.size() > 0) {
std::cout << "##############" << std::endl;
std::cout << annotation; std::cout << annotation;
std::cout << "##############" << std::endl;
} }
dump_type(params.front(), e); dump_type(params.front(), e);
std::cout << " " << f.first << "("; std::cout << " " << f.first << "(";