Add enums

This commit is contained in:
WerWolv
2020-11-14 14:40:21 +01:00
parent 999db12a3a
commit 41c70bce44
4 changed files with 85 additions and 6 deletions

View File

@@ -3,6 +3,7 @@
#include "token.hpp"
#include <optional>
#include <unordered_map>
#include <vector>
namespace hex::lang {
@@ -13,6 +14,7 @@ namespace hex::lang {
VariableDecl,
TypeDecl,
Struct,
Enum,
Scope,
};
@@ -78,4 +80,19 @@ namespace hex::lang {
std::string m_name, m_customTypeName;
};
class ASTNodeEnum : public ASTNode {
public:
explicit ASTNodeEnum(const Token::TypeToken::Type &type, const std::string &name)
: ASTNode(Type::Enum), m_type(type), m_name(name) { }
const std::string& getName() const { return this->m_name; };
const Token::TypeToken::Type& getUnderlyingType() const { return this->m_type; }
std::vector<std::pair<u64, std::string>>& getValues() { return this->m_values; }
private:
Token::TypeToken::Type m_type;
std::string m_name;
std::vector<std::pair<u64, std::string>> m_values;
};
}