Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
VariableStatement.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <alib/string>
9#include <ast/Statement.h>
10
11namespace cli {
12
13class VariableStatement final : public Statement {
14 std::unique_ptr < cli::Arg > m_name;
15
16public:
17 VariableStatement ( std::unique_ptr < cli::Arg > name ) : m_name ( std::move ( name ) ) {
18 }
19
20 std::shared_ptr < abstraction::Value > translateAndEval ( const std::shared_ptr < abstraction::Value > &, Environment & environment ) const override {
21 return environment.getVariable ( m_name->eval ( environment ) );
22 }
23
24};
25
26} /* namespace cli */
27
Definition: Environment.h:29
std::shared_ptr< abstraction::Value > getVariable(const std::string &name) const
Definition: Environment.h:68
Definition: Statement.h:14
Definition: VariableStatement.h:13
std::shared_ptr< abstraction::Value > translateAndEval(const std::shared_ptr< abstraction::Value > &, Environment &environment) const override
Definition: VariableStatement.h:20
VariableStatement(std::unique_ptr< cli::Arg > name)
Definition: VariableStatement.h:17
Definition: Arg.h:11
Definition: FordFulkerson.hpp:16