diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-01 17:18:54 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-01 17:18:54 +0000 |
commit | 9e761324895d098a87f0ba66b7eb1794cd3ed6b4 (patch) | |
tree | b46b0eb0eb91f6784d586acb8611495de81b92e4 /c_compiler/include/primitives.hpp | |
parent | 2e5cacc6633a6973f8e96adc6bafa633487fc2a1 (diff) | |
download | Compiler-9e761324895d098a87f0ba66b7eb1794cd3ed6b4.tar.gz Compiler-9e761324895d098a87f0ba66b7eb1794cd3ed6b4.zip |
Finished parser
Diffstat (limited to 'c_compiler/include/primitives.hpp')
-rw-r--r-- | c_compiler/include/primitives.hpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/c_compiler/include/primitives.hpp b/c_compiler/include/primitives.hpp new file mode 100644 index 0000000..2eeaa19 --- /dev/null +++ b/c_compiler/include/primitives.hpp @@ -0,0 +1,40 @@ +#ifndef AST_PRIMITIVES_HPP +#define AST_PRIMITIVES_HPP + +#include "ast.hpp" + +#include <string> + +class Variable : public Base { +private: + std::string id; +public: + Variable(const std::string& _id) : id(_id) {} + + virtual void print() const { + std::cout << "<Variable id=\"" << id << "\" />" << std::endl; + } + + virtual void push(const Base* var) const { + std::cerr << "Error: Can't call this function on this class" << std::endl; + (void)var; + } +}; + +class Parameter : public Base { +private: + std::string id; +public: + Parameter(const std::string& _id) : id(_id) {} + + virtual void print() const { + std::cout << "<Parameter id=\"" << id << "\" />" << std::endl; + } + + virtual void push(const Base* var) const { + std::cerr << "Error: Can't call this function on this class" << std::endl; + (void)var; + } +}; + +#endif |