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

Class representing a variable expression. More...

#include <expr.hpp>

Inheritance diagram for Variable:
Collaboration diagram for Variable:

Public Member Functions

 Variable (Token name)
 
std::any accept (ExprVisitor &visitor) override
 
Token getName () const
 

Private Attributes

const Token name
 

Detailed Description

Class representing a variable expression.

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

Definition at line 170 of file expr.hpp.

Constructor & Destructor Documentation

◆ Variable()

Variable::Variable ( Token  name)
inline

Definition at line 175 of file expr.hpp.

175: name(std::move(name)) {}
const Token name
Definition expr.hpp:172

Member Function Documentation

◆ accept()

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

Implements Expr.

Definition at line 177 of file expr.hpp.

177 {
178 return visitor.visitVariableExpr(shared_from_this());
179 }
virtual std::any visitVariableExpr(std::shared_ptr< Variable > expr)=0

◆ getName()

Token Variable::getName ( ) const
inline

Definition at line 181 of file expr.hpp.

181{ return name; }

Member Data Documentation

◆ name

const Token Variable::name
private

Definition at line 172 of file expr.hpp.


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