diff --git a/src/ast.cpp b/src/ast.cpp index 543fc92..fac190c 100644 --- a/src/ast.cpp +++ b/src/ast.cpp @@ -182,7 +182,7 @@ ValuePtr HashMap::get(ValuePtr key) std::string HashMap::getKeyString(ValuePtr key) { if (!is(key.get()) && !is(key.get())) { - Error::the().add(format("wrong argument type: string or keyword, {}", key)); + Error::the().add(::format("wrong argument type: string or keyword, {}", key)); return {}; } diff --git a/src/environment.cpp b/src/environment.cpp index 3d48efa..a4f2152 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -39,7 +39,7 @@ EnvironmentPtr Environment::create(const ValuePtr lambda, const ValueVector& arg for (size_t i = 0; i < bindings.size(); ++i, ++it) { if (bindings[i] == "&") { if (i + 2 != bindings.size()) { - Error::the().add(format("invalid function: {}", lambda)); + Error::the().add(::format("invalid function: {}", lambda)); return nullptr; } @@ -53,7 +53,7 @@ EnvironmentPtr Environment::create(const ValuePtr lambda, const ValueVector& arg } if (it == arguments.end()) { - Error::the().add(format("wrong number of arguments: {}, {}", lambda, arguments.size())); + Error::the().add(::format("wrong number of arguments: {}, {}", lambda, arguments.size())); return nullptr; } @@ -61,7 +61,7 @@ EnvironmentPtr Environment::create(const ValuePtr lambda, const ValueVector& arg } if (it != arguments.end()) { - Error::the().add(format("wrong number of arguments: {}, {}", lambda, arguments.size())); + Error::the().add(::format("wrong number of arguments: {}, {}", lambda, arguments.size())); return nullptr; } diff --git a/src/eval.cpp b/src/eval.cpp index 318f1d0..9f4788c 100644 --- a/src/eval.cpp +++ b/src/eval.cpp @@ -153,7 +153,7 @@ ValuePtr Eval::evalAst(ValuePtr ast, EnvironmentPtr env) if (is(ast_raw_ptr)) { auto result = env->get(std::static_pointer_cast(ast)->symbol()); if (!result) { - Error::the().add(format("'{}' not found", ast)); + Error::the().add(::format("'{}' not found", ast)); return nullptr; } return result; @@ -245,7 +245,7 @@ ValuePtr Eval::apply(std::shared_ptr evaluated_list) auto nodes = evaluated_list->nodes(); if (!is(nodes.front().get())) { - Error::the().add(format("invalid function: {}", nodes.front())); + Error::the().add(::format("invalid function: {}", nodes.front())); return nullptr; } diff --git a/src/functions.cpp b/src/functions.cpp index 6e7f209..ed00943 100644 --- a/src/functions.cpp +++ b/src/functions.cpp @@ -181,7 +181,7 @@ ADD_FUNCTION( result = std::static_pointer_cast(*begin)->size(); } else { - Error::the().add(format("wrong argument type: Collection, '{}'", *begin)); + Error::the().add(::format("wrong argument type: Collection, '{}'", *begin)); return nullptr; } @@ -191,20 +191,20 @@ ADD_FUNCTION( // ----------------------------------------- -#define PRINTER_STRING(print_readably, concatenation) \ - { \ - std::string result; \ - \ - Printer printer; \ - for (auto it = begin; it != end; ++it) { \ - result += format("{}", printer.printNoErrorCheck(*it, print_readably)); \ - \ - if (it != end && std::next(it) != end) { \ - result += concatenation; \ - } \ - } \ - \ - return makePtr(result); \ +#define PRINTER_STRING(print_readably, concatenation) \ + { \ + std::string result; \ + \ + Printer printer; \ + for (auto it = begin; it != end; ++it) { \ + result += ::format("{}", printer.printNoErrorCheck(*it, print_readably)); \ + \ + if (it != end && std::next(it) != end) { \ + result += concatenation; \ + } \ + } \ + \ + return makePtr(result); \ } ADD_FUNCTION("str", PRINTER_STRING(false, "")); @@ -869,7 +869,7 @@ ADD_FUNCTION( if (!is(front_raw_ptr) && // List / Vector !is(front_raw_ptr) && // HashMap !is(front_raw_ptr)) { // Function / Lambda - Error::the().add(format("wrong argument type: Collection, HashMap or Callable, {}", front)); + Error::the().add(::format("wrong argument type: Collection, HashMap or Callable, {}", front)); return nullptr; } @@ -888,7 +888,7 @@ ADD_FUNCTION( if (!is(front_raw_ptr) && // List / Vector !is(front_raw_ptr) && // HashMap !is(front_raw_ptr)) { // Function / Lambda - Error::the().add(format("wrong argument type: Collection, HashMap or Callable, {}", front)); + Error::the().add(::format("wrong argument type: Collection, HashMap or Callable, {}", front)); return nullptr; } @@ -968,7 +968,7 @@ ADD_FUNCTION( return result; } - Error::the().add(format("wrong argument type: Collection or String, {}", front)); + Error::the().add(::format("wrong argument type: Collection or String, {}", front)); return nullptr; }); diff --git a/src/printer.cpp b/src/printer.cpp index 1eecf9f..5d7c6bf 100644 --- a/src/printer.cpp +++ b/src/printer.cpp @@ -90,7 +90,7 @@ void Printer::printImpl(ValuePtr node, bool print_readably) m_previous_node_is_list = true; auto elements = std::static_pointer_cast(node)->elements(); for (auto it = elements.begin(); it != elements.end(); ++it) { - m_print += format("{} ", (it->first.front() == 0x7f) ? ":" + it->first.substr(1) : '"' + it->first + '"'); // 127 + m_print += ::format("{} ", (it->first.front() == 0x7f) ? ":" + it->first.substr(1) : '"' + it->first + '"'); // 127 printImpl(it->second, print_readably); if (!isLast(it, elements)) { @@ -109,15 +109,15 @@ void Printer::printImpl(ValuePtr node, bool print_readably) text = "\"" + text + "\""; } printSpacing(); - m_print += format("{}", text); + m_print += ::format("{}", text); } else if (is(node_raw_ptr)) { printSpacing(); - m_print += format(":{}", std::static_pointer_cast(node)->keyword().substr(1)); + m_print += ::format(":{}", std::static_pointer_cast(node)->keyword().substr(1)); } else if (is(node_raw_ptr)) { printSpacing(); - m_print += format("{}", std::static_pointer_cast(node)->number()); + m_print += ::format("{}", std::static_pointer_cast(node)->number()); } else if (is(node_raw_ptr)) { printSpacing(); @@ -127,23 +127,23 @@ void Printer::printImpl(ValuePtr node, bool print_readably) case Constant::True: value = "true"; break; case Constant::False: value = "false"; break; } - m_print += format("{}", value); + m_print += ::format("{}", value); } else if (is(node_raw_ptr)) { printSpacing(); - m_print += format("{}", std::static_pointer_cast(node)->symbol()); + m_print += ::format("{}", std::static_pointer_cast(node)->symbol()); } else if (is(node_raw_ptr)) { printSpacing(); - m_print += format("#({})", std::static_pointer_cast(node)->name()); + m_print += ::format("#({})", std::static_pointer_cast(node)->name()); } else if (is(node_raw_ptr)) { printSpacing(); - m_print += format("#({:p})", node_raw_ptr); + m_print += ::format("#({:p})", node_raw_ptr); } else if (is(node_raw_ptr)) { printSpacing(); - m_print += format("#({:p})", node_raw_ptr); + m_print += ::format("#({:p})", node_raw_ptr); } else if (is(node_raw_ptr)) { printSpacing(); @@ -158,15 +158,15 @@ void Printer::printError() m_print = "Error: "; if (Error::the().hasTokenError()) { Token error = Error::the().tokenError(); - m_print += format("{}", error.symbol); + m_print += ::format("{}", error.symbol); } else if (Error::the().hasOtherError()) { std::string error = Error::the().otherError(); - m_print += format("{}", error); + m_print += ::format("{}", error); } else if (Error::the().hasException()) { ValuePtr error = Error::the().exception(); - m_print += format("{}", error); + m_print += ::format("{}", error); } } diff --git a/src/reader.cpp b/src/reader.cpp index 0d115aa..dfd81ab 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -188,7 +188,7 @@ ValuePtr Reader::readHashMap() } if (!is(key.get()) && !is(key.get())) { - Error::the().add(format("wrong argument type: string or keyword, {}", key)); + Error::the().add(::format("wrong argument type: string or keyword, {}", key)); return nullptr; } diff --git a/src/util.h b/src/util.h index aa38500..588d239 100644 --- a/src/util.h +++ b/src/util.h @@ -34,10 +34,10 @@ // ----------------------------------------- -#define CHECK_ARG_COUNT_IS_IMPL(name, size, expected, result) \ - if (size != expected) { \ - Error::the().add(format("wrong number of arguments: {}, {}", name, size)); \ - return result; \ +#define CHECK_ARG_COUNT_IS_IMPL(name, size, expected, result) \ + if (size != expected) { \ + Error::the().add(::format("wrong number of arguments: {}, {}", name, size)); \ + return result; \ } #define CHECK_ARG_COUNT_IS_3(name, size, expected) \ @@ -52,10 +52,10 @@ // ----------------------------------------- -#define CHECK_ARG_COUNT_AT_LEAST_IMPL(name, size, min, result) \ - if (size < min) { \ - Error::the().add(format("wrong number of arguments: {}, {}", name, size)); \ - return result; \ +#define CHECK_ARG_COUNT_AT_LEAST_IMPL(name, size, min, result) \ + if (size < min) { \ + Error::the().add(::format("wrong number of arguments: {}, {}", name, size)); \ + return result; \ } #define CHECK_ARG_COUNT_AT_LEAST_3(name, size, min) \ @@ -70,10 +70,10 @@ // ----------------------------------------- -#define CHECK_ARG_COUNT_BETWEEN_IMPL(name, size, min, max, result) \ - if (size < min || size > max) { \ - Error::the().add(format("wrong number of arguments: {}, {}", name, size)); \ - return result; \ +#define CHECK_ARG_COUNT_BETWEEN_IMPL(name, size, min, max, result) \ + if (size < min || size > max) { \ + Error::the().add(::format("wrong number of arguments: {}, {}", name, size)); \ + return result; \ } #define CHECK_ARG_COUNT_BETWEEN_4(name, size, min, max) \ @@ -88,10 +88,10 @@ // ----------------------------------------- -#define CHECK_ARG_COUNT_EVEN_IMPL(name, size, result) \ - if (size % 2 != 0) { \ - Error::the().add(format("wrong number of arguments: {}, {}", name, size)); \ - return result; \ +#define CHECK_ARG_COUNT_EVEN_IMPL(name, size, result) \ + if (size % 2 != 0) { \ + Error::the().add(::format("wrong number of arguments: {}, {}", name, size)); \ + return result; \ } #define CHECK_ARG_COUNT_EVEN_2(name, size) \ @@ -106,10 +106,10 @@ // ----------------------------------------- -#define IS_VALUE_IMPL(type, value, result) \ - if (!is(value.get())) { \ - Error::the().add(format("wrong argument type: {}, {}", #type, value)); \ - return result; \ +#define IS_VALUE_IMPL(type, value, result) \ + if (!is(value.get())) { \ + Error::the().add(::format("wrong argument type: {}, {}", #type, value)); \ + return result; \ } #define IS_VALUE_2(type, value) \