Add integers
diff --git a/Token.cpp b/Token.cpp
index 20e2a16..53ba43a 100644
--- a/Token.cpp
+++ b/Token.cpp
@@ -1,6 +1,8 @@
#include "Token.h"
#include "AstNode.h"
+#include <QDebug>
+
template class TokenBase<Token>;
// This is kind of ugly and breaks separation of concerns; but if I don't do
@@ -45,6 +47,17 @@
}
template <typename T>
+T TokenBase<T>::fromInteger(int integer)
+{
+ T tok;
+
+ tok._type = INTEGER;
+ tok._intVal = integer;
+
+ return tok;
+}
+
+template <typename T>
TokenBase<T>::TokenBase(char varType, const QString name)
{
_type = VAR;
@@ -89,7 +102,15 @@
template <typename T>
bool TokenBase<T>::operator==(const T &other) const
{
- return _type == other._type && _stringVal == other._stringVal && _charVal == other._charVal && _listVal == other._listVal;
+ // Why is this needed? Beats me.
+ if (isInteger() && other.isInteger())
+ return _intVal == other._intVal;
+
+ return _type == other._type &&
+ _stringVal == other._stringVal &&
+ _charVal == other._charVal &&
+ _listVal == other._listVal &&
+ _intVal == other._intVal;
}
template <typename T>