diff --git a/src/language/ASTDotPrinter.cpp b/src/language/ASTDotPrinter.cpp
index 270438e16b90d4cfd4c31ac35955878e9bcb81b1..7339d62307aa7f501ec73b2ef98dbceab2b5a51d 100644
--- a/src/language/ASTDotPrinter.cpp
+++ b/src/language/ASTDotPrinter.cpp
@@ -7,20 +7,21 @@ void
 ASTDotPrinter::_print(std::ostream& os, const ASTNode& node) const
 {
   if (node.is_root()) {
-    os << "  x" << &node << " [ label=\"root \\n" << dataTypeName(node.m_data_type) << "\" ]\n";
+    os << "  x" << m_node_number_map.at(&node) << " [ label=\"root \\n" << dataTypeName(node.m_data_type) << "\" ]\n";
   } else {
     if (node.has_content()) {
-      os << "  x" << &node << " [ label=\"" << node.name() << "\\n"
+      os << "  x" << m_node_number_map.at(&node) << " [ label=\"" << node.name() << "\\n"
          << node.string_view() << "\\n"
          << dataTypeName(node.m_data_type) << "\" ]\n";
     } else {
-      os << "  x" << &node << " [ label=\"" << node.name() << "\\n" << dataTypeName(node.m_data_type) << "\" ]\n";
+      os << "  x" << m_node_number_map.at(&node) << " [ label=\"" << node.name() << "\\n"
+         << dataTypeName(node.m_data_type) << "\" ]\n";
     }
   }
   if (!node.children.empty()) {
-    os << "  x" << &node << " -> { ";
+    os << "  x" << m_node_number_map.at(&node) << " -> { ";
     for (auto& child : node.children) {
-      os << "x" << child.get() << ((child == node.children.back()) ? " }\n" : ", ");
+      os << "x" << m_node_number_map.at(child.get()) << ((child == node.children.back()) ? " }\n" : ", ");
     }
     for (auto& child : node.children) {
       this->_print(os, *child);
@@ -37,7 +38,17 @@ operator<<(std::ostream& os, const ASTDotPrinter& ast_printer)
   return os;
 }
 
+void
+ASTDotPrinter::_buildNodeNumberMap(const ASTNode& node)
+{
+  m_node_number_map[&node] = m_node_number_map.size();
+  for (auto& child : node.children) {
+    this->_buildNodeNumberMap(*child);
+  }
+}
+
 ASTDotPrinter::ASTDotPrinter(const ASTNode& node) : m_node{node}
 {
   Assert(node.is_root());
+  this->_buildNodeNumberMap(node);
 }
diff --git a/src/language/ASTDotPrinter.hpp b/src/language/ASTDotPrinter.hpp
index 522f59b17a800664f21226da6f629c8aa83cebb3..6dabb0ce197b8ed3aa2bfb690f0aceed3dc63314 100644
--- a/src/language/ASTDotPrinter.hpp
+++ b/src/language/ASTDotPrinter.hpp
@@ -2,14 +2,19 @@
 #define AST_DOT_PRINTER_HPP
 
 #include <ASTNode.hpp>
+#include <map>
 
 class ASTDotPrinter
 {
  private:
   const ASTNode& m_node;
 
+  std::map<const ASTNode*, uint32_t> m_node_number_map;
+
   void _print(std::ostream& os, const ASTNode& node) const;
 
+  void _buildNodeNumberMap(const ASTNode& node);
+
  public:
   friend std::ostream& operator<<(std::ostream& os, const ASTDotPrinter& ast_printer);