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

Class representing a binary expression. More...

#include <expr.hpp>

Inheritance diagram for Binary:
Collaboration diagram for Binary:

Public Member Functions

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

Private Attributes

const std::shared_ptr< Exprleft
 
const Token op
 
const std::shared_ptr< Exprright
 

Detailed Description

Class representing a binary expression.

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

Definition at line 53 of file expr.hpp.

Constructor & Destructor Documentation

◆ Binary()

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

Definition at line 60 of file expr.hpp.

61 : left(std::move(left)), op(std::move(op)), right(std::move(right)) {}
const std::shared_ptr< Expr > left
Definition expr.hpp:55
const std::shared_ptr< Expr > right
Definition expr.hpp:57
const Token op
Definition expr.hpp:56

Member Function Documentation

◆ accept()

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

Implements Expr.

Definition at line 63 of file expr.hpp.

63 {
64 return visitor.visitBinaryExpr(shared_from_this());
65 }
virtual std::any visitBinaryExpr(std::shared_ptr< Binary > expr)=0

◆ getLeft()

std::shared_ptr< Expr > Binary::getLeft ( ) const
inline

Definition at line 67 of file expr.hpp.

67{ return left; }

◆ getOp()

Token Binary::getOp ( ) const
inline

Definition at line 69 of file expr.hpp.

69{ return op; }

◆ getRight()

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

Definition at line 68 of file expr.hpp.

68{ return right; }

Member Data Documentation

◆ left

const std::shared_ptr<Expr> Binary::left
private

Definition at line 55 of file expr.hpp.

◆ op

const Token Binary::op
private

Definition at line 56 of file expr.hpp.

◆ right

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

Definition at line 57 of file expr.hpp.


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