diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2016-08-31 19:50:57 +0000 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2016-08-31 19:50:57 +0000 |
| commit | 1ba5c17a68f13633d6a20785c722b22032ba45c4 (patch) | |
| tree | 40b3aac27fe9af4c9d82965d714acde0b5508435 /value.cpp | |
| parent | b7eeb6676b8f67be7cc1560d9586f2672a5ad0eb (diff) | |
Add runtime and value classes
Diffstat (limited to 'value.cpp')
| -rw-r--r-- | value.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/value.cpp b/value.cpp new file mode 100644 index 0000000..acf80ce --- /dev/null +++ b/value.cpp @@ -0,0 +1,26 @@ +#include "value.h" +#include <string> + +Value::Value(std::string& lexeme) { + if (lexeme.find_first_not_of("0123456789")) { + m_type = Value::Type::Integer; + m_intData = std::stoi(lexeme, nullptr, 10); + } + else { + m_type = Value::Type::String; + m_strData = lexeme; + } +} + + +const Value::Type Value::getType() const { + return m_type; +} + +const int Value::getIntData() const { + return m_intData; +} + +const std::string& Value::getStrData() const { + return m_strData; +} |
