GSC Interpreter
A Turing-complete interpreter developed for a compiler course
Loading...
Searching...
No Matches
Unary Class Reference

Class representing a unary expression. More...

#include <expr.hpp>

Inheritance diagram for Unary:
Collaboration diagram for Unary:

Public Member Functions

 Unary (Token op, std::shared_ptr< Expr > right)
 
std::any accept (ExprVisitor &visitor) override
 
std::shared_ptr< ExprgetRight () const
 
Token getOp () const
 

Private Attributes

const Token op
 
const std::shared_ptr< Exprright
 

Detailed Description

Class representing a unary expression.

This class represents a unary expression in the AST, which consists of an operator and a right operand. It inherits from the Expr class and implements the accept method for visitor pattern.

Definition at line 122 of file expr.hpp.

Constructor & Destructor Documentation

◆ Unary()

Unary::Unary ( Token  op,
std::shared_ptr< Expr right 
)
inline

Definition at line 128 of file expr.hpp.

129 : op(std::move(op)), right(std::move(right)) {}
const std::shared_ptr< Expr > right
Definition expr.hpp:125
const Token op
Definition expr.hpp:124

Member Function Documentation

◆ accept()

std::any Unary::accept ( ExprVisitor visitor)
inlineoverridevirtual

Implements Expr.

Definition at line 131 of file expr.hpp.

131 {
132 return visitor.visitUnaryExpr(shared_from_this());
133 }
virtual std::any visitUnaryExpr(std::shared_ptr< Unary > expr)=0

◆ getOp()

Token Unary::getOp ( ) const
inline

Definition at line 136 of file expr.hpp.

136{ return op; }

◆ getRight()

std::shared_ptr< Expr > Unary::getRight ( ) const
inline

Definition at line 135 of file expr.hpp.

135{ return right; }

Member Data Documentation

◆ op

const Token Unary::op
private

Definition at line 124 of file expr.hpp.

◆ right

const std::shared_ptr<Expr> Unary::right
private

Definition at line 125 of file expr.hpp.


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