Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
StatementList.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <ast/Statement.h>
9
10namespace cli {
11
12class StatementList final : public Statement {
14
15public:
16 StatementList ( ext::vector < std::shared_ptr < Statement > > statements ) : m_statements ( std::move ( statements ) ) {
17 }
18
19 std::shared_ptr < abstraction::Value > translateAndEval ( const std::shared_ptr < abstraction::Value > &, Environment & environment ) const override {
20 if ( m_statements.empty ( ) )
21 throw std::invalid_argument ( "Statement list can't be empty" );
22
23 std::shared_ptr < abstraction::Value > next = m_statements [ 0 ]->translateAndEval ( nullptr, environment );
24 for ( size_t i = 1; i < m_statements.size ( ); ++ i )
25 next = m_statements [ i ]->translateAndEval ( next, environment );
26
27 return next;
28 }
29
30 void append ( std::shared_ptr < Statement > statement ) {
31 m_statements.emplace_back ( std::move ( statement ) );
32 }
33
34};
35
36} /* namespace cli */
37
Definition: Environment.h:29
Definition: StatementList.h:12
void append(std::shared_ptr< Statement > statement)
Definition: StatementList.h:30
StatementList(ext::vector< std::shared_ptr< Statement > > statements)
Definition: StatementList.h:16
std::shared_ptr< abstraction::Value > translateAndEval(const std::shared_ptr< abstraction::Value > &, Environment &environment) const override
Definition: StatementList.h:19
Definition: Statement.h:14
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
int i
Definition: AllEpsilonClosure.h:118
Definition: Arg.h:11
Definition: FordFulkerson.hpp:16