CG_Gen::Parser class
#include <Parser.hpp>

class Parser

Constructors, destructors, conversion operators

Parser(const std::string& i_logExpression, const std::map<std::string, std::vector<int32_t>>& i_info)
Parser(const std::vector<std::string>& i_logExpressions, const std::map<std::string, std::vector<int32_t>>& i_info)
Parser(const std::string& i_logExpression, const GatesInfo& i_info)
Parser(const std::vector<std::string>& i_logExpressions, const GatesInfo& i_info)
Parser() defaulted
Parser(const Parser& other) defaulted
Parser(Parser&& other) defaulted

Public functions

auto operator=(const Parser& other) -> Parser& defaulted
auto operator=(Parser&& other) -> Parser& defaulted
auto getGraph() const -> GraphPtr
getGraph Get the graph object This method returns a pointer to the graph object associated with the Parser instance
auto splitLogicExpression(std::string i_expr) -> std::pair<int32_t, std::vector<std::string>>
auto multipleVerteciesToOne(std::vector<VertexPtr> curLayout, Gates operation, GraphPtr graph) -> VertexPtr
multipleVerteciesToOne This method takes a vector of vertices representing the current layout, combines them into a single vertex using the specified logical operation, and returns the resulting vertex
auto parseToVertex(const std::string& i_expr) -> VertexPtr
parseToVertex This method takes a logical expression, splits it, and converts it into a vertex within the graph.
auto parseAll() -> bool
parseAll Parse all logical expressions and construct the graph.
void setGatesInputsInfo(const std::map<std::string, std::vector<int32_t>>& i_info)
setGatesInputsInfo Set information about gates inputs
void setGatesInputsInfo(const GatesInfo& i_info)
setGatesInputsInfo TO DO: Analog setGatesInputsInfo

Function documentation

GraphPtr CG_Gen::Parser::getGraph() const

getGraph Get the graph object This method returns a pointer to the graph object associated with the Parser instance

Returns A pointer to the graph object

VertexPtr CG_Gen::Parser::multipleVerteciesToOne(std::vector<VertexPtr> curLayout, Gates operation, GraphPtr graph)

multipleVerteciesToOne This method takes a vector of vertices representing the current layout, combines them into a single vertex using the specified logical operation, and returns the resulting vertex

Parameters
curLayout The vector of vertices representing the current layout
operation The logical operation to apply
graph A pointer to the graph object
Returns A pointer to the resulting vertex after combining the input vertices

VertexPtr CG_Gen::Parser::parseToVertex(const std::string& i_expr)

parseToVertex This method takes a logical expression, splits it, and converts it into a vertex within the graph.

Parameters
i_expr The logical expression to parse
Returns A pointer to the resulting vertex representing the expression, or nullptr on failure

It recursively parses sub-expressions until it constructs the complete expression tree

bool CG_Gen::Parser::parseAll()

parseAll Parse all logical expressions and construct the graph.

Returns True if parsing is successful for all expressions, false otherwise

This method initializes a new oriented graph and iterates through all logical expressions stored in the d_logExpressions member variable. For each expression, it checks if it has balanced brackets using the createBrackets method. If the brackets are balanced, it calls the parseToVertex method to parse the expression and construct the corresponding vertex in the graph. If parsing fails for any expression, the method returns false. Otherwise, it returns true indicating successful parsing of all expressions.

void CG_Gen::Parser::setGatesInputsInfo(const std::map<std::string, std::vector<int32_t>>& i_info)

setGatesInputsInfo Set information about gates inputs

Parameters
i_info A map where keys are gate names as strings and values are vectors of integers specifying the number of inputs for each gate