changed enum to enum class

This commit is contained in:
Lauchmelder 2021-11-24 14:50:20 +01:00
parent f1f0be77ae
commit 2ab8c2eaee
4 changed files with 11 additions and 11 deletions

View file

@ -3,7 +3,7 @@
#include <string>
enum TokenType
enum class TokenType
{
KEYWORD,
IDENTIFIER,
@ -11,7 +11,7 @@ enum TokenType
ID_OR_LIT
};
enum ValueType
enum class ValueType
{
STRING,
NUMBER,
@ -24,8 +24,8 @@ struct Instruction;
struct Keyword;
struct Runtime;
const std::string resolve_TokenType_str(enum TokenType);
const std::string resolve_ValueType_str(enum ValueType);
std::string resolve_TokenType_str(enum class TokenType);
std::string resolve_ValueType_str(enum class ValueType);
#endif //BISCUIT_INTERPRETER_COMMON_HPP

View file

@ -29,9 +29,9 @@ struct WrongArgumentCountExcept : public std::exception
struct WrongTokenExcept : public std::exception
{
enum TokenType expected, got;
enum class TokenType expected, got;
std::string keyword_name, token_str;
inline WrongTokenExcept(const std::string& _keyword_name, const std::string& _token_str, const enum TokenType& _expected, const enum TokenType& _got)
inline WrongTokenExcept(const std::string& _keyword_name, const std::string& _token_str, enum class TokenType _expected, enum class TokenType _got)
: expected(_expected), got(_got), keyword_name(_keyword_name), token_str(_token_str) {}
};
@ -39,9 +39,9 @@ struct WrongTokenExcept : public std::exception
// Runtime errors
struct TypeErrorExcept : public std::exception
{
enum ValueType expected, got;
enum class ValueType expected, got;
std::string token_str;
inline TypeErrorExcept(const std::string& _token_str, const enum ValueType& _expected, const enum ValueType& _got)
inline TypeErrorExcept(const std::string& _token_str, enum class ValueType _expected, enum class ValueType _got)
: expected(_expected), got(_got), token_str(_token_str) {}
};

View file

@ -279,7 +279,7 @@ Instruction::Instruction(std::vector<Token>& _token_list)
// Make sure the keyword gets the number of arguments it needs
if(keyword_ptr->expected_num_args != -1 && (keyword_ptr->expected_num_args != tokens.size() - 1))
throw WrongArgumentCountExcept(keyword_ptr->name, keyword_ptr->expected_num_args, tokens.size() - 1);
throw WrongArgumentCountExcept(keyword_ptr->name, keyword_ptr->expected_num_args, static_cast<int>(tokens.size() - 1));
// Check the arguments supplied are the right kind of tokens
for(int i = 0; i < keyword_ptr->expected_num_args; i++)

View file

@ -1,7 +1,7 @@
#include "common.hpp"
#include <string>
const std::string resolve_TokenType_str(enum TokenType ttype)
std::string resolve_TokenType_str(TokenType ttype)
{
switch(ttype)
{
@ -22,7 +22,7 @@ const std::string resolve_TokenType_str(enum TokenType ttype)
return "UNKNOW TOKENTYPE";
}
const std::string resolve_ValueType_str(enum ValueType vtype)
std::string resolve_ValueType_str(ValueType vtype)
{
switch(vtype)
{