code_generation_error( std::string const& generator_name, String const& msg, helper::colorizer const c = helper::colorizer{} ) noexcept : std::runtime_error( c.red("Error ") + c.bold(msg) + "\n" "1 error generated in " + generator_name ) {}
std::string visit(local_scope const& l, size_t const i) const { return indent(i) + c.green("LOCAL_SCOPE") + visit_symbols(l->local_vars, i+1, "SYMBOL: ") + visit_scopes(l->children, i+1) + visit_scopes(l->unnamed_funcs, i+1); }
std::string visit(class_scope const& cl, size_t const i) const { return indent(i) + c.green("CLASS_SCOPE: ") + cl->name + visit_symbols(cl->member_var_symbols, i+1, "SYMBOL: ") + visit_scopes(cl->member_func_scopes, i+1) + visit_scopes(cl->inherited_class_scopes, i+1); }
std::string visit(global_scope const& g, size_t const i) const { return indent(i) + c.green("GLOBAL_SCOPE") + visit_symbols(g->const_symbols, i+1, "SYMBOL: ") + visit_scopes(g->functions, i+1) + visit_scopes(g->classes, i+1); }
not_implemented_error(char const* const file, char const* const func, std::size_t const line, String const& what_feature, helper::colorizer const c = helper::colorizer{}) noexcept : std::runtime_error( ( boost::format( c.red("Error") + '\n' + c.bold(" %1% is not implemented yet.\n") + " Note: You can contribute to Dachs with implementing this feature. " "Clone https://github.com/rhysd/Dachs and see %2%, %3%(), line:%4%" ) % what_feature % file % func % line ).str() ) {}
std::string visit(func_scope const& f, size_t const i) const { return indent(i) + c.green("FUNCTION_SCOPE: ") + f->to_string() + visit_symbols(f->params, i+1, "SYMBOL: ") + '\n' + visit(f->body, i+1); }
std::string visit_symbols(Range const& symbols, size_t const i, char const* const prefix) const { if (boost::empty(symbols)) { return ""; } return boost::accumulate(symbols | transformed([this, i, &prefix](auto const& s){ return indent(i) + c.yellow(prefix) + s->name + (s->type ? ": " + c.cyan(s->type.to_string()) : ""); }), std::string{}, [](auto const& acc, auto const& item){ return acc + '\n' + item; }); }