Skip to content
Snippets Groups Projects
Commit b5430ab4 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Fix parse tree dot-file output when dealing with strings

String must be escaped to prevent dot-file bad syntax
parent 053613f0
No related branches found
No related tags found
1 merge request!37Feature/language
...@@ -11,7 +11,7 @@ ASTDotPrinter::_print(std::ostream& os, const ASTNode& node) const ...@@ -11,7 +11,7 @@ ASTDotPrinter::_print(std::ostream& os, const ASTNode& node) const
} else { } else {
if (node.has_content()) { if (node.has_content()) {
os << " x" << m_node_number_map.at(&node) << " [ label=\"" << node.name() << "\\n" os << " x" << m_node_number_map.at(&node) << " [ label=\"" << node.name() << "\\n"
<< node.string_view() << "\\n" << escapeString(node.string_view()) << "\\n"
<< dataTypeName(node.m_data_type) << "\" ]\n"; << dataTypeName(node.m_data_type) << "\" ]\n";
} else { } else {
os << " x" << m_node_number_map.at(&node) << " [ label=\"" << node.name() << "\\n" os << " x" << m_node_number_map.at(&node) << " [ label=\"" << node.name() << "\\n"
......
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <string_view>
#include <PugsMacros.hpp> #include <PugsMacros.hpp>
PUGS_INLINE std::string PUGS_INLINE std::string
unescapeString(const std::string& input_string) unescapeString(const std::string_view& input_string)
{ {
std::stringstream ss; std::stringstream ss;
for (size_t i = 1; i < input_string.size() - 1; ++i) { for (size_t i = 1; i < input_string.size() - 1; ++i) {
...@@ -70,7 +71,7 @@ unescapeString(const std::string& input_string) ...@@ -70,7 +71,7 @@ unescapeString(const std::string& input_string)
} }
PUGS_INLINE std::string PUGS_INLINE std::string
escapeString(const std::string& input_string) escapeString(const std::string_view& input_string)
{ {
std::stringstream ss; std::stringstream ss;
for (size_t i = 0; i < input_string.size(); ++i) { for (size_t i = 0; i < input_string.size(); ++i) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment