aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--runtime.cpp11
-rw-r--r--runtime.h11
-rw-r--r--value.cpp26
-rw-r--r--value.h21
4 files changed, 69 insertions, 0 deletions
diff --git a/runtime.cpp b/runtime.cpp
new file mode 100644
index 0000000..8478da7
--- /dev/null
+++ b/runtime.cpp
@@ -0,0 +1,11 @@
+#include "runtime.h"
+
+Runtime::Runtime() {
+
+}
+
+void Runtime::run(std::vector<Token>& tokens) {
+ for (auto& token : tokens) {
+
+ }
+}
diff --git a/runtime.h b/runtime.h
new file mode 100644
index 0000000..f1b050d
--- /dev/null
+++ b/runtime.h
@@ -0,0 +1,11 @@
+#pragma once
+#include "value.h"
+#include <vector>
+
+class Runtime {
+ private:
+ std::vector<Value> m_values;
+ public:
+ Runtime();
+ void run(std::vector<Token>& tokens);
+};
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;
+}
diff --git a/value.h b/value.h
new file mode 100644
index 0000000..71d5101
--- /dev/null
+++ b/value.h
@@ -0,0 +1,21 @@
+#pragma once
+#include <string>
+
+class Value {
+ public:
+ enum Type {
+ Integer,
+ String
+ };
+
+ Value(std::string& lexeme);
+ const Value::Type getType() const;
+ const int getIntData() const;
+ const std::string& getStrData() const;
+
+ private:
+ int m_intData;
+ std::string m_strData;
+
+ Value::Type m_type;
+};