LCOV - code coverage report
Current view: top level - src/parse - ASTDot.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 6 0.0 %
Date: 2025-03-25 01:19:55 Functions: 0 1 0.0 %
Branches: 0 6 0.0 %

           Branch data     Line data    Source code
       1                 :            : #pragma once
       2                 :            : 
       3                 :            : #include <iostream>
       4                 :            : #include <mutable/parse/AST.hpp>
       5                 :            : 
       6                 :            : 
       7                 :            : namespace m {
       8                 :            : 
       9                 :            : namespace ast {
      10                 :            : 
      11                 :            : /** Implements printing the AST in dot language. */
      12                 :            : struct ASTDot : ConstASTVisitor
      13                 :            : {
      14                 :            :     static constexpr const char * const GRAPH_TYPE = "graph";
      15                 :            :     static constexpr const char * const EDGE = " -- ";
      16                 :            : 
      17                 :            :     std::ostream &out; ///< the output stream to print to
      18                 :            : 
      19                 :            :     private:
      20                 :            :     int indent_; ///< the current indentation for pretty printing
      21                 :            : 
      22                 :            :     public:
      23                 :            :     /**
      24                 :            :      * @param out the output stream to print to
      25                 :            :      * @param indent the initial indentation
      26                 :            :      */
      27                 :            :     ASTDot(std::ostream &out, int indent = 0);
      28                 :            :     ~ASTDot();
      29                 :            : 
      30                 :            :     using ConstASTVisitor::operator();
      31                 :            : #define DECLARE(CLASS) void operator()(Const<CLASS>&) override;
      32                 :            :     M_AST_LIST(DECLARE)
      33                 :            : #undef DECLARE
      34                 :            : 
      35                 :            :     private:
      36                 :            :     /** Start a new line with proper indentation. */
      37                 :          0 :     std::ostream & indent() const {
      38                 :          0 :         M_insist(indent_ >= 0, "Indent must not be negative!  Missing increment or superfluous decrement?");
      39         [ #  # ]:          0 :         if (indent_)
      40   [ #  #  #  # ]:          0 :             out << '\n' << std::string(2 * indent_, ' ');
      41                 :          0 :         return out;
      42                 :          0 :     }
      43                 :            : 
      44                 :            :     /** Emit the given clause `c` in a dot cluster.
      45                 :            :      *
      46                 :            :      * @param c the clause to emit
      47                 :            :      * @param name the internal name of the clause (must contain no white spaces)
      48                 :            :      * @param label the human-readable name of this clause (may contain white spaces)
      49                 :            :      * @param color the color to use for highlighting this cluster
      50                 :            :      */
      51                 :            :     void cluster(Const<Clause> &c, const char *name, const char *label, const char *color);
      52                 :            : };
      53                 :            : 
      54                 :            : }
      55                 :            : 
      56                 :            : }

Generated by: LCOV version 1.16