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

Class representing a literal expression. More...

#include <expr.hpp>

Inheritance diagram for Literal:
Collaboration diagram for Literal:

Public Member Functions

 Literal (std::any value)
 
std::any accept (ExprVisitor &visitor) override
 
std::any getValue () const
 

Private Attributes

const std::any value
 

Detailed Description

Class representing a literal expression.

This class represents a literal expression in the AST, which can hold a value of any type. It inherits from the Expr class and implements the accept method for visitor pattern.

Definition at line 101 of file expr.hpp.

Constructor & Destructor Documentation

◆ Literal()

Literal::Literal ( std::any  value)
inline

Definition at line 106 of file expr.hpp.

106: value(std::move(value)) {}
const std::any value
Definition expr.hpp:103

Member Function Documentation

◆ accept()

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

Implements Expr.

Definition at line 108 of file expr.hpp.

108 {
109 return visitor.visitLiteralExpr(shared_from_this());
110 }
virtual std::any visitLiteralExpr(std::shared_ptr< Literal > expr)=0

◆ getValue()

std::any Literal::getValue ( ) const
inline

Definition at line 112 of file expr.hpp.

112{ return value; }

Member Data Documentation

◆ value

const std::any Literal::value
private

Definition at line 103 of file expr.hpp.


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