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

Class representing an assignment expression. More...

#include <expr.hpp>

Inheritance diagram for Assign:
Collaboration diagram for Assign:

Public Member Functions

 Assign (Token name, std::shared_ptr< Expr > value)
 
std::any accept (ExprVisitor &visitor) override
 
Token getName () const
 
std::shared_ptr< ExprgetValue () const
 

Private Attributes

const Token name
 
const std::shared_ptr< Exprvalue
 

Detailed Description

Class representing an assignment expression.

This class represents an assignment expression in the AST, which consists of a variable name and a value to assign to it. It inherits from the Expr class and implements the accept method for visitor pattern.

Definition at line 145 of file expr.hpp.

Constructor & Destructor Documentation

◆ Assign()

Assign::Assign ( Token  name,
std::shared_ptr< Expr value 
)
inline

Definition at line 151 of file expr.hpp.

152 : name(std::move(name)), value(std::move(value)) {}
const Token name
Definition expr.hpp:147
const std::shared_ptr< Expr > value
Definition expr.hpp:148

Member Function Documentation

◆ accept()

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

Implements Expr.

Definition at line 154 of file expr.hpp.

154 {
155 return visitor.visitAssignExpr(shared_from_this());
156 }
virtual std::any visitAssignExpr(std::shared_ptr< Assign > expr)=0

◆ getName()

Token Assign::getName ( ) const
inline

Definition at line 158 of file expr.hpp.

158{ return name; }

◆ getValue()

std::shared_ptr< Expr > Assign::getValue ( ) const
inline

Definition at line 160 of file expr.hpp.

160{ return value; }

Member Data Documentation

◆ name

const Token Assign::name
private

Definition at line 147 of file expr.hpp.

◆ value

const std::shared_ptr<Expr> Assign::value
private

Definition at line 148 of file expr.hpp.


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