aboutsummaryrefslogtreecommitdiffstats
path: root/c_parser/include
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-02-14 14:02:40 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-02-14 14:02:40 +0000
commitec1bd2264a19542b4e36df08ad2dba2c50f437b3 (patch)
tree808dd28f552355f78b92465071c4abacc9935eba /c_parser/include
parent494894c2072494f199214acc5855155baae6d174 (diff)
downloadCompiler-ec1bd2264a19542b4e36df08ad2dba2c50f437b3.tar.gz
Compiler-ec1bd2264a19542b4e36df08ad2dba2c50f437b3.zip
Working vector in parser
Diffstat (limited to 'c_parser/include')
-rw-r--r--c_parser/include/ast.hpp3
-rw-r--r--c_parser/include/ast_base.hpp5
-rw-r--r--c_parser/include/ast_base.hpp~14
-rw-r--r--c_parser/include/ast_declaration.hpp6
-rw-r--r--c_parser/include/ast_top.hpp23
-rw-r--r--c_parser/include/ast_top.hpp~23
-rw-r--r--c_parser/include/top_ast.hpp~14
7 files changed, 69 insertions, 19 deletions
diff --git a/c_parser/include/ast.hpp b/c_parser/include/ast.hpp
index 91c0796..a0889ae 100644
--- a/c_parser/include/ast.hpp
+++ b/c_parser/include/ast.hpp
@@ -3,7 +3,8 @@
#include "ast_base.hpp"
#include "ast_declaration.hpp"
+#include "ast_top.hpp"
-extern const ast_Base *parseAST();
+ast_Top *parseAST();
#endif
diff --git a/c_parser/include/ast_base.hpp b/c_parser/include/ast_base.hpp
index 7f8d56e..432a54b 100644
--- a/c_parser/include/ast_base.hpp
+++ b/c_parser/include/ast_base.hpp
@@ -1,8 +1,9 @@
-#ifndef AST_EXPRESSION_HPP
-#define AST_EXPRESSION_HPP
+#ifndef AST_BASE_HPP
+#define AST_BASE_HPP
#include <string>
#include <iostream>
+#include <vector>
class ast_Base {
public:
diff --git a/c_parser/include/ast_base.hpp~ b/c_parser/include/ast_base.hpp~
deleted file mode 100644
index ef0368a..0000000
--- a/c_parser/include/ast_base.hpp~
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef AST_EXPRESSION_HPP
-#define AST_EXPRESSION_HPP
-
-#include <string>
-#include <iostream>
-
-class ast_base {
-public:
- virtual ~ast_base() {}
-
- virtual void print() const = 0;
-};
-
-#endif
diff --git a/c_parser/include/ast_declaration.hpp b/c_parser/include/ast_declaration.hpp
index 2eed3a2..e529378 100644
--- a/c_parser/include/ast_declaration.hpp
+++ b/c_parser/include/ast_declaration.hpp
@@ -6,9 +6,11 @@
class ast_Declaration : public ast_Base {
private:
const std::string id;
+
+protected:
+
public:
- ast_Declaration(const std::string& _id) : id(_id) {}
-
+ ast_Declaration(const std::string _id) : id(_id) {}
virtual void print() const override {
std::cout << id;
}
diff --git a/c_parser/include/ast_top.hpp b/c_parser/include/ast_top.hpp
new file mode 100644
index 0000000..cafae3a
--- /dev/null
+++ b/c_parser/include/ast_top.hpp
@@ -0,0 +1,23 @@
+#ifndef TOP_AST_HPP
+#define TOP_AST_HPP
+
+#include "ast.hpp"
+
+#include <vector>
+
+class ast_Top {
+public:
+ void print_vec() {
+ for(size_t i = 0; i < ast_vec.size(); ++i) {
+ ast_vec[i]->print();
+ }
+ }
+
+ void push_back(const ast_Base *stmnt) {
+ ast_vec.push_back(stmnt);
+ }
+private:
+ std::vector<const ast_Base *> ast_vec;
+};
+
+#endif
diff --git a/c_parser/include/ast_top.hpp~ b/c_parser/include/ast_top.hpp~
new file mode 100644
index 0000000..89cf415
--- /dev/null
+++ b/c_parser/include/ast_top.hpp~
@@ -0,0 +1,23 @@
+#ifndef TOP_AST_HPP
+#define TOP_AST_HPP
+
+#include "ast.hpp"
+
+#include <vector>
+
+class ast_Top {
+public:
+ void print_vec() {
+ for(size_t i = 0; i < ast_vec.size(); ++i) {
+ ast_vec[i]->print();
+ }
+ }
+
+ void push_back(const ast_Base *stmnt) {
+ ast_vec.push_back(stmnt);
+ }
+private:
+ ast_Top_t ast_vec;
+};
+
+#endif
diff --git a/c_parser/include/top_ast.hpp~ b/c_parser/include/top_ast.hpp~
new file mode 100644
index 0000000..0252bde
--- /dev/null
+++ b/c_parser/include/top_ast.hpp~
@@ -0,0 +1,14 @@
+#ifndef TOP_AST_HPP
+#define TOP_AST_HPP
+
+#include "ast.hpp"
+
+#include <vector>
+
+class top_ast {
+public:
+private:
+ std::vector<const ast_Base*> ast_vec;
+};
+
+#endif