aboutsummaryrefslogtreecommitdiffstats
path: root/c_parser/include/ast_statement.hpp
blob: f2c717532a2f23e5f3f796f849a8c75498b93634 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef AST_STATEMENT_HPP
#define AST_STATEMENT_HPP

class ast_Statement : public ast_Base {
protected:
    mutable std::vector<const ast_Base*> ast_list;
    
public:
    ast_Statement() {}
    ast_Statement(const ast_Base* _el) {
	ast_list.push_back(_el);
    }

    virtual void print() const {
	for(size_t i = 0; i < ast_list.size(); ++i) {
	    ast_list[i]->print();
	}
    }

    virtual void push(const ast_Base* _var) const {
	ast_list.push_back(_var);
    }
};

class ast_CompoundStatement : public ast_Statement {
public:
    ast_CompoundStatement() : ast_Statement() {}
    ast_CompoundStatement(const ast_Base* _el) : ast_Statement(_el) {}

    virtual void print() const override {
	std::cout << "<Scope>" << std::endl;
	for(size_t i = 0; i < ast_list.size(); ++i) {
	    ast_list[i]->print();
	}
	std::cout << "</Scope>" << std::endl;
    }
};

#endif