aboutsummaryrefslogtreecommitdiffstats
path: root/c_compiler/include/declaration.hpp
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-03-01 17:18:54 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-03-01 17:18:54 +0000
commit9e761324895d098a87f0ba66b7eb1794cd3ed6b4 (patch)
treeb46b0eb0eb91f6784d586acb8611495de81b92e4 /c_compiler/include/declaration.hpp
parent2e5cacc6633a6973f8e96adc6bafa633487fc2a1 (diff)
downloadCompiler-9e761324895d098a87f0ba66b7eb1794cd3ed6b4.tar.gz
Compiler-9e761324895d098a87f0ba66b7eb1794cd3ed6b4.zip
Finished parser
Diffstat (limited to 'c_compiler/include/declaration.hpp')
-rw-r--r--c_compiler/include/declaration.hpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/c_compiler/include/declaration.hpp b/c_compiler/include/declaration.hpp
new file mode 100644
index 0000000..bfd3070
--- /dev/null
+++ b/c_compiler/include/declaration.hpp
@@ -0,0 +1,50 @@
+#ifndef AST_DECLARATION_HPP
+#define AST_DECLARATION_HPP
+
+#include "ast.hpp"
+
+#include <vector>
+
+// Declaration that holds a list of declarations
+
+class DeclarationList : public Base {
+private:
+ mutable std::vector<const Base*> dec_list;
+
+public:
+ DeclarationList(const Base* _dec) {
+ dec_list.push_back(_dec);
+ }
+
+ virtual void print() const {
+ for(size_t i = 0; i < dec_list.size(); ++i) {
+ dec_list[i]->print();
+ }
+ }
+
+ virtual void push(const Base* _dec) const {
+ dec_list.push_back(_dec);
+ }
+};
+
+class VariableDeclaration : public Base {
+private:
+ mutable std::vector<const Base*> var_list;
+
+public:
+ VariableDeclaration(const Base* _var) {
+ var_list.push_back(_var);
+ }
+
+ virtual void print() const {
+ for(size_t i = 0; i < var_list.size(); ++i) {
+ var_list[i]->print();
+ }
+ }
+
+ virtual void push(const Base* _var) const {
+ var_list.push_back(_var);
+ }
+};
+
+#endif