Skip to content
Snippets Groups Projects
Select Git revision
  • 3369b1f2a70de3702f353e14cd4a625ce6ad06b6
  • develop default protected
  • save_clemence
  • feature/composite-scheme-other-fluxes
  • feature/advection
  • origin/stage/bouguettaia
  • feature/local-dt-fsi
  • feature/variational-hydro
  • feature/gmsh-reader
  • feature/reconstruction
  • feature/kinetic-schemes
  • feature/composite-scheme-sources
  • feature/serraille
  • feature/composite-scheme
  • hyperplastic
  • feature/polynomials
  • feature/gks
  • feature/implicit-solver-o2
  • feature/coupling_module
  • feature/implicit-solver
  • feature/merge-local-dt-fsi
  • v0.5.0 protected
  • v0.4.1 protected
  • v0.4.0 protected
  • v0.3.0 protected
  • v0.2.0 protected
  • v0.1.0 protected
  • Kidder
  • v0.0.4 protected
  • v0.0.3 protected
  • v0.0.2 protected
  • v0 protected
  • v0.0.1 protected
33 results

ASTPrinter.hpp

Blame
  • ASTPrinter.hpp 1.16 KiB
    #ifndef AST_PRINTER_HPP
    #define AST_PRINTER_HPP
    
    #include <language/ASTNode.hpp>
    
    class ASTPrinter
    {
     public:
      enum class Format
      {
        raw,
        pretty
      };
    
      using InfoBaseType = uint32_t;
    
      enum class Info : InfoBaseType
      {
        none      = 0,
        data_type = 1 << 0,
        exec_type = 1 << 1,
        all       = std::numeric_limits<InfoBaseType>::max()
      };
    
     private:
      const ASTNode& m_node;
    
      InfoBaseType m_info;
    
      mutable std::string prefix;
      mutable std::vector<int> last_prefix_size;
    
      std::string T_junction;
      std::string L_junction;
    
      std::string pipe_space;
      std::string space_space;
    
      void _print(std::ostream& os, const ASTNode& node) const;
    
      template <typename NodeVector>
      void _print(std::ostream& os, const NodeVector& node_list) const;
    
     public:
      friend std::ostream& operator<<(std::ostream& os, const ASTPrinter& ast_printer);
    
      ASTPrinter(const ASTNode& node,
                 Format format                                = Format::pretty,
                 std::initializer_list<Info> initializer_list = {Info::all});
    
      ASTPrinter(const ASTPrinter&) = delete;
    
      ASTPrinter(ASTPrinter&&) = delete;
    
      ~ASTPrinter() = default;
    };
    
    #endif   // AST_PRINTER_HPP