Meta: Improve formatting
This commit is contained in:
+8
-7
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <iterator> // std::next
|
||||
#include <memory> // std::static_pointer_cast
|
||||
#include <string>
|
||||
|
||||
#include "ruc/format/format.h"
|
||||
@@ -74,7 +75,7 @@ void Printer::printImpl(ASTNodePtr node)
|
||||
m_print += '(';
|
||||
m_first_node = false;
|
||||
m_previous_node_is_list = true;
|
||||
auto nodes = static_pointer_cast<List>(node)->nodes();
|
||||
auto nodes = std::static_pointer_cast<List>(node)->nodes();
|
||||
for (size_t i = 0; i < nodes.size(); ++i) {
|
||||
printImpl(nodes[i]);
|
||||
m_previous_node_is_list = false;
|
||||
@@ -86,7 +87,7 @@ void Printer::printImpl(ASTNodePtr node)
|
||||
m_print += '[';
|
||||
m_first_node = false;
|
||||
m_previous_node_is_list = true;
|
||||
auto nodes = static_pointer_cast<Vector>(node)->nodes();
|
||||
auto nodes = std::static_pointer_cast<Vector>(node)->nodes();
|
||||
for (size_t i = 0; i < nodes.size(); ++i) {
|
||||
printImpl(nodes[i]);
|
||||
m_previous_node_is_list = false;
|
||||
@@ -98,7 +99,7 @@ void Printer::printImpl(ASTNodePtr node)
|
||||
m_print += "{";
|
||||
m_first_node = false;
|
||||
m_previous_node_is_list = true;
|
||||
auto elements = static_pointer_cast<HashMap>(node)->elements();
|
||||
auto elements = std::static_pointer_cast<HashMap>(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
|
||||
printImpl(it->second);
|
||||
@@ -113,19 +114,19 @@ void Printer::printImpl(ASTNodePtr node)
|
||||
else if (is<String>(node_raw_ptr)) {
|
||||
// TODO: Implement string readably printing
|
||||
printSpacing();
|
||||
m_print += format("{}", static_pointer_cast<String>(node)->data());
|
||||
m_print += format("{}", std::static_pointer_cast<String>(node)->data());
|
||||
}
|
||||
else if (is<Keyword>(node_raw_ptr)) {
|
||||
printSpacing();
|
||||
m_print += format(":{}", static_pointer_cast<Keyword>(node)->keyword().substr(1));
|
||||
m_print += format(":{}", std::static_pointer_cast<Keyword>(node)->keyword().substr(1));
|
||||
}
|
||||
else if (is<Number>(node_raw_ptr)) {
|
||||
printSpacing();
|
||||
m_print += format("{}", static_pointer_cast<Number>(node)->number());
|
||||
m_print += format("{}", std::static_pointer_cast<Number>(node)->number());
|
||||
}
|
||||
else if (is<Symbol>(node_raw_ptr)) {
|
||||
printSpacing();
|
||||
m_print += format("{}", static_pointer_cast<Symbol>(node)->symbol());
|
||||
m_print += format("{}", std::static_pointer_cast<Symbol>(node)->symbol());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@
|
||||
#include <cstddef> // size_t
|
||||
#include <cstdint> // uint64_t
|
||||
#include <cstdlib> // std::strtoll
|
||||
#include <memory> // makePtr, std::shared_ptr
|
||||
#include <memory> // std::static_pointer_cast
|
||||
#include <utility> // std::move
|
||||
|
||||
#include "error.h"
|
||||
@@ -196,7 +196,7 @@ ASTNodePtr Reader::readHashMap()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string keyString = is<String>(key.get()) ? static_pointer_cast<String>(key)->data() : static_pointer_cast<Keyword>(key)->keyword();
|
||||
std::string keyString = is<String>(key.get()) ? std::static_pointer_cast<String>(key)->data() : std::static_pointer_cast<Keyword>(key)->keyword();
|
||||
hash_map->addElement(keyString, value);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user