diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-06 17:37:51 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-06 17:37:51 +0000 |
commit | fdd6ff07cee824078c5315bf07926ee15bbdde85 (patch) | |
tree | 25ae7097f5f1ee88b7e9d0f27297f38c08a29009 /c_compiler/src/type.cpp | |
parent | 3cef694323c53a19c8c7c0fab19432eb74f8792a (diff) | |
download | Compiler-fdd6ff07cee824078c5315bf07926ee15bbdde85.tar.gz Compiler-fdd6ff07cee824078c5315bf07926ee15bbdde85.zip |
making changes to type in lexer now
Diffstat (limited to 'c_compiler/src/type.cpp')
-rw-r--r-- | c_compiler/src/type.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/c_compiler/src/type.cpp b/c_compiler/src/type.cpp new file mode 100644 index 0000000..b7c3fec --- /dev/null +++ b/c_compiler/src/type.cpp @@ -0,0 +1,70 @@ +#include "ast.hpp" + + +// Type definition + +void Type::print() const +{ + std::cout << getType() << " " << std::endl; +} + +void Type::printxml() const +{} + +void Type::printasm() const +{} + + +// Pointer definition + +Pointer::Pointer(Type* _pointer_type) : pointer_type(_pointer_type) +{} + +std::string Pointer::getType() const +{ + return "pointer " + pointer_type->getType(); +} + + +// Array definition + +Array::Array(Type* _array_type, int32_t _size) : size(_size), array_type(_array_type) +{} + +std::string Array::getType() const +{ + return "array " + array_type->getType(); +} + + +// Void definition + +Void::Void() +{} + +std::string Void::getType() const +{ + return "void"; +} + + +// Int defintion + +Int::Int() +{} + +std::string Int::getType() const +{ + return "int"; +} + + +// Char definition + +Char::Char() +{} + +std::string Char::getType() const +{ + return "char"; +} |