Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
Antares::Expressions::Visitors::AstDOTStyleVisitor Class Reference

A visitor class for generating DOT style output for ASTs (Abstract Syntax Trees). More...

#include <AstDOTStyleVisitor.h>

Inheritance diagram for Antares::Expressions::Visitors::AstDOTStyleVisitor:
Antares::Expressions::Visitors::NodeVisitor< void, std::ostream & > Antares::Expressions::IName

Public Member Functions

 AstDOTStyleVisitor ()=default
 Default constructor.
 
void NewTreeGraph (std::ostream &os, const std::string &tree_name="ExpressionTree")
 Begins a new tree graph.
 
void EndTreeGraph (std::ostream &os)
 Ends the current tree graph.
 
std::string name () const override
 Returns the name of this visitor.
 
void operator() (std::ostream &os, const Nodes::Node *root)
 Outputs the DOT representation of a node to a stream.
 
- Public Member Functions inherited from Antares::Expressions::Visitors::NodeVisitor< void, std::ostream & >
void dispatch (const Nodes::Node *node, Args... args)
 
virtual void visit (const Nodes::SumNode *, Args... args)=0
 Visits a SumNode and processes its children.
 
virtual void visit (const Nodes::SubtractionNode *, Args... args)=0
 Visits a SubtractionNode and processes its children.
 
virtual void visit (const Nodes::MultiplicationNode *, Args... args)=0
 Visits a MultiplicationNode and processes its children.
 
virtual void visit (const Nodes::DivisionNode *, Args... args)=0
 Visits a DivisionNode and processes its children.
 
virtual void visit (const Nodes::EqualNode *, Args... args)=0
 Visits an EqualNode and processes its children.
 
virtual void visit (const Nodes::LessThanOrEqualNode *, Args... args)=0
 Visits a LessThanOrEqualNode and processes its children.
 
virtual void visit (const Nodes::GreaterThanOrEqualNode *, Args... args)=0
 Visits a GreaterThanOrEqualNode and processes its children.
 
virtual void visit (const Nodes::NegationNode *, Args... args)=0
 Visits a NegationNode and processes its child.
 
virtual void visit (const Nodes::LiteralNode *, Args... args)=0
 Visits a LiteralNode.
 
virtual void visit (const Nodes::VariableNode *, Args... args)=0
 Visits a VariableNode.
 
virtual void visit (const Nodes::ParameterNode *, Args... args)=0
 Visits a ParameterNode.
 
virtual void visit (const Nodes::PortFieldNode *, Args... args)=0
 Visits a PortFieldNode.
 
virtual void visit (const Nodes::PortFieldSumNode *, Args... args)=0
 Visits a PortFieldSumNode.
 
virtual void visit (const Nodes::ComponentVariableNode *, Args... args)=0
 Visits a ComponentVariableNode.
 
virtual void visit (const Nodes::ComponentParameterNode *, Args... args)=0
 Visits a ComponentParameterNode.
 
- Public Member Functions inherited from Antares::Expressions::IName
bool operator== (const IName &other) const =default
 

Detailed Description

A visitor class for generating DOT style output for ASTs (Abstract Syntax Trees).

This class extends the NodeVisitor template class to produce a DOT representation of a given AST. The DOT format is commonly used for graph visualization tools, such as Graphviz. The visitor generates the graph structure, including nodes and edges, and outputs it to a stream.

Template Parameters
NodeVisitorA base class template for visiting nodes.
std::ostream&The type of the output stream where the DOT representation is written.

Member Function Documentation

◆ EndTreeGraph()

void Antares::Expressions::Visitors::AstDOTStyleVisitor::EndTreeGraph ( std::ostream & os)

Ends the current tree graph.

Finalizes the DOT graph representation.

Parameters
osThe output stream to which the DOT representation is written.

◆ name()

std::string Antares::Expressions::Visitors::AstDOTStyleVisitor::name ( ) const
overridevirtual

Returns the name of this visitor.

Returns
A string representing the name of the visitor.

Implements Antares::Expressions::IName.

◆ NewTreeGraph()

void Antares::Expressions::Visitors::AstDOTStyleVisitor::NewTreeGraph ( std::ostream & os,
const std::string & tree_name = "ExpressionTree" )

Begins a new tree graph.

Initializes the DOT graph representation and sets the tree name.

Parameters
osThe output stream to which the DOT representation is written.
tree_nameThe name of the tree graph. Defaults to "ExpressionTree".

◆ operator()()

void Antares::Expressions::Visitors::AstDOTStyleVisitor::operator() ( std::ostream & os,
const Nodes::Node * root )

Outputs the DOT representation of a node to a stream.

This operator overload facilitates the use of the AstDOTStyleVisitor with a node for direct streaming of the DOT representation.

Parameters
osThe output stream to which the DOT representation is written.
rootThe root of the expression to be output.

The documentation for this class was generated from the following files: